Skip to content

Commit

Permalink
Merge pull request #73 from skoji/allow-nil-and-ignore
Browse files Browse the repository at this point in the history
Allow nil and ignore (fix #71)
  • Loading branch information
skoji committed May 23, 2018
2 parents c8ca9ff + 4c3de0a commit f189a7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/gepub/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def oldstyle_meta_clear
define_method(node+'=') {
|content|
send(node + "_clear")
return if content.nil?
if node == 'date'
add_date(content, nil)
else
Expand Down
18 changes: 18 additions & 0 deletions spec/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,23 @@
book.generate_epub(epubname)
epubcheck(epubname)
end

it 'should generate simple EPUB3 with some nil metadata' do
book = GEPUB::Book.new
book.identifier = 'http://example.jp/bookid_in_url'
book.title = 'GEPUB Sample Book'
book.creator = 'KOJIMA Satoshi'
book.language = 'ja'
book.publisher = nil

book.ordered do
item = book.add_item('name.xhtml')
item.add_content StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c1</title></head><body><p>the first page</p></body></html>')
end

epubname = File.join(File.dirname(__FILE__), 'example_test.epub')
book.generate_epub(epubname)
epubcheck(epubname)
end
end
end

0 comments on commit f189a7a

Please sign in to comment.