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 to use shortcut key of config #540

Merged
merged 2 commits into from
Apr 13, 2016
Merged
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
2 changes: 1 addition & 1 deletion lib/epubmaker/producer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def coverimage

# Update parameters by merging from new parameter hash +params+.
def merge_params(params)
@params = @params.deep_merge(params)
@params.deep_merge!(params)
complement

unless @params["epubversion"].nil?
Expand Down
7 changes: 4 additions & 3 deletions lib/review/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ def self.values
end

def [](key)
maker = self.maker
if maker && self.key?(maker) && self.fetch(maker).key?(key)
return self.fetch(maker).fetch(key, nil)
end
if self.key?(key)
return self.fetch(key)
end
if @maker && self.key?(@maker)
return self.fetch(@maker).fetch(key, nil)
end
end

def name_of(key)
Expand Down
1 change: 1 addition & 0 deletions lib/review/epubmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def load_yaml(yamlfile)
@producer = Producer.new(@params)
@producer.load(yamlfile)
@params = @producer.params
@params.maker = "epubmaker"
end

def produce(yamlfile, bookname=nil)
Expand Down
1 change: 1 addition & 0 deletions lib/review/pdfmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def parse_opts(args)

def execute(*args)
@config = ReVIEW::Configure.values
@config.maker = "pdfmaker"
cmd_config, yamlfile = parse_opts(args)
loader = YAMLLoader.new
@config.deep_merge!(loader.load_file(yamlfile))
Expand Down
10 changes: 9 additions & 1 deletion test/test_configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def setup
"urnid" => "http://example.jp/",
"date" => "2011-01-01",
"language" => "ja",
"epubmaker" => {"flattocindent" => true},
"epubmaker" => {"flattocindent" => true,
"title" => "Sample Book(EPUB)"},
})
@output = StringIO.new
I18n.setup(@config["language"])
Expand All @@ -41,6 +42,13 @@ def test_configure_with_maker
assert_equal true, @config["epubmaker"]["flattocindent"]
end

def test_configure_with_maker_override
@config.maker = "epubmaker"
assert_equal "Sample Book(EPUB)", @config["title"]
@config.maker = "pdfmaker"
assert_equal "Sample Book", @config["title"]
end

def test_configure_with_invalidmaker
@config.maker = "pdfmaker"
assert_equal nil, @config["flattocindent"]
Expand Down