diff --git a/lib/eeepub/maker.rb b/lib/eeepub/maker.rb index bae94a1..84fc878 100644 --- a/lib/eeepub/maker.rb +++ b/lib/eeepub/maker.rb @@ -54,6 +54,7 @@ def #{name}(value) :files, :nav, :cover, + :source, :ncx_file, :opf_file, :guide @@ -133,6 +134,7 @@ def create_epub :description => @descriptions, :rights => @rightss, :cover => @cover, + :source => @source, :relation => @relations, :manifest => @files.map{|file| case file diff --git a/lib/eeepub/opf.rb b/lib/eeepub/opf.rb index 237ad45..3798643 100644 --- a/lib/eeepub/opf.rb +++ b/lib/eeepub/opf.rb @@ -15,6 +15,7 @@ class OPF < ContainerItem :spine, :guide, :cover, + :source, :ncx, :toc @@ -71,7 +72,7 @@ def build_metadata(builder) builder.dc :identifier, i[:value], attrs end - [:title, :language, :subject, :description, :relation, :creator, :publisher, :date, :rights].each do |i| + [:title, :language, :subject, :description, :relation, :creator, :publisher, :date, :rights, :source].each do |i| value = self.send(i) next unless value diff --git a/spec/eeepub/maker_spec.rb b/spec/eeepub/maker_spec.rb index bd5b1d6..993b3d1 100644 --- a/spec/eeepub/maker_spec.rb +++ b/spec/eeepub/maker_spec.rb @@ -17,6 +17,7 @@ ncx_file 'toc.ncx' opf_file 'content.opf' cover 'cover.jpg' + source 'http://example.com/book/foo' files ['foo.html', 'bar.html'] nav [ {:label => '1. foo', :content => 'foo.html'}, @@ -34,6 +35,7 @@ it { @maker.instance_variable_get(:@ncx_file).should == 'toc.ncx' } it { @maker.instance_variable_get(:@opf_file).should == 'content.opf' } it { @maker.instance_variable_get(:@cover).should == 'cover.jpg' } + it { @maker.instance_variable_get(:@source).should == 'http://example.com/book/foo' } it { @maker.instance_variable_get(:@files).should == ['foo.html', 'bar.html'] } it { @maker.instance_variable_get(:@nav).should == [ @@ -54,20 +56,22 @@ :uid=>{:value=>"http://example.com/book/foo", :scheme=>"URL", :id=>"http://example.com/book/foo"} ) { stub!.save } mock(EeePub::OPF).new( - :title => ["sample"], - :creator => ["jugyo"], - :date => ["2010-05-06"], - :language => ['en'], - :subject => ['epub sample'], - :description => ['this is epub sample'], - :rights => ['xxx'], - :relation => ['xxx'], - :ncx => "toc.ncx", - :cover => 'cover.jpg', - :publisher => ["jugyo.org"], + :title=>["sample"], :unique_identifier=>"http://example.com/book/foo", - :identifier => [{:value => "http://example.com/book/foo", :scheme => "URL", :id => "http://example.com/book/foo"}], - :manifest => ['foo.html', 'bar.html'] + :identifier=>[{:value=>"http://example.com/book/foo",:scheme=>"URL", :id=>"http://example.com/book/foo"}], + :creator=>["jugyo"], + :publisher=>["jugyo.org"], + :date=>["2010-05-06"], + :language=>["en"], + :subject=>["epub sample"], + :description=>["this is epub sample"], + :rights=>["xxx"], + :cover=>"cover.jpg", + :source=>"http://example.com/book/foo", + :relation=>["xxx"], + :manifest=>["foo.html", "bar.html"], + :ncx=>"toc.ncx", + :guide=>nil ) { stub!.save } mock(EeePub::OCF).new( :container => "content.opf", @@ -94,6 +98,7 @@ ncx_file 'toc.ncx' opf_file 'content.opf' cover 'cover.jpg' + source 'http://example.com/book/foo' files [{'foo.html' => 'foo/bar'}, {'bar.html' => 'foo/bar/baz'}] nav [ {:label => '1. foo', :content => 'foo.html'}, @@ -108,20 +113,22 @@ mock(Dir).mktmpdir { '/tmp' } mock(EeePub::NCX).new.with_any_args { stub!.save } mock(EeePub::OPF).new( - :title => ["sample"], - :creator => ["jugyo"], - :date => ["2010-05-06"], - :language => ['en'], - :subject => ['epub sample'], - :description => ['this is epub sample'], - :rights => ['xxx'], - :relation => ['xxx'], - :ncx => "toc.ncx", - :cover => 'cover.jpg', - :publisher => ["jugyo.org"], - :unique_identifier=>"http://example.com/book/foo", - :identifier => [{:value => "http://example.com/book/foo", :scheme => "URL", :id=>"http://example.com/book/foo"}], - :manifest => ["foo/bar/foo.html", "foo/bar/baz/bar.html"] + :title=>["sample"], + :unique_identifier=>"http://example.com/book/foo", + :identifier=>[{:value=>"http://example.com/book/foo", :scheme=>"URL", :id=>"http://example.com/book/foo"}], + :creator=>["jugyo"], + :publisher=>["jugyo.org"], + :date=>["2010-05-06"], + :language=>["en"], + :subject=>["epub sample"], + :description=>["this is epub sample"], + :rights=>["xxx"], + :cover=>"cover.jpg", + :source=>"http://example.com/book/foo", + :relation=>["xxx"], + :manifest=>["foo/bar/foo.html", "foo/bar/baz/bar.html"], + :ncx=>"toc.ncx", + :guide=>nil ) { stub!.save } mock(EeePub::OCF).new.with_any_args { stub!.save } diff --git a/spec/eeepub/opf_spec.rb b/spec/eeepub/opf_spec.rb index db4d580..11b7ba7 100644 --- a/spec/eeepub/opf_spec.rb +++ b/spec/eeepub/opf_spec.rb @@ -119,7 +119,8 @@ :creator => 'creator', :publisher => 'publisher', :rights => 'rights', - :cover => 'cover.jpg' + :cover => 'cover.jpg', + :source => 'source' ) end @@ -136,6 +137,7 @@ ['dc:relation', 'relation'], ['dc:creator', 'creator'], ['dc:publisher', 'publisher'], + ['dc:source', 'source'], ['dc:rights', 'rights'], ].each do |xpath, expect| metadata.xpath(xpath,