Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing creator attributes #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

21 changes: 21 additions & 0 deletions eeepub.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)

require 'eeepub/version'

spec = Gem::Specification.new do |gem|
gem.name = "eeepub"
gem.version = EeePub::VERSION
gem.platform = Gem::Platform::RUBY
gem.summary = %Q{ePub generator}
gem.description = %Q{EeePub is a Ruby ePub generator.}
gem.email = ["jugyo.org@gmail.com", "seb@cine7.net"]
gem.homepage = "http://github.com/jugyo/eeepub"
gem.authors = ["jugyo", "Sébastien Cevey"]
gem.files = Dir.glob("lib/**/*") + %w(LICENSE README.md)
gem.add_dependency "builder"
gem.add_development_dependency "rspec"
gem.add_development_dependency "rr"
end

1 change: 1 addition & 0 deletions lib/eeepub.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'eeepub/version'
require 'eeepub/container_item'
require 'eeepub/opf'
require 'eeepub/ocf'
Expand Down
6 changes: 5 additions & 1 deletion lib/eeepub/maker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module EeePub
class Maker
[
:title,
:creator,
:publisher,
:date,
:language,
Expand Down Expand Up @@ -59,6 +58,11 @@ def identifier(id, options)
@identifiers << {:value => id, :scheme => options[:scheme]}
end

def creator(name, options)
@creators ||= []
@creators << {:value => name, :role => options[:role]}
end

# @param [Proc] block the block for initialize
def initialize(&block)
@files ||= []
Expand Down
9 changes: 8 additions & 1 deletion lib/eeepub/opf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ def build_metadata(builder)
builder.dc :identifier, i[:value], attrs
end

[:title, :language, :subject, :description, :relation, :creator, :publisher, :date, :rights].each do |i|
creator.each do |i|
attrs = {}
attrs['opf:role'] = i[:role] if i[:role]
attrs['opf:file-as'] = i[:file_as] if i[:file_as]
builder.dc :creator, i[:value], attrs
end

[:title, :language, :subject, :description, :relation, :publisher, :date, :rights].each do |i|
value = self.send(i)
next unless value

Expand Down
3 changes: 3 additions & 0 deletions lib/eeepub/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module EeePub
VERSION = '0.6.2'
end