From dfd28f40e2c800f4ac7ee0431549810c15b37239 Mon Sep 17 00:00:00 2001 From: takahashim Date: Sat, 16 Apr 2016 01:35:45 +0900 Subject: [PATCH 1/2] remove backward compatibility * layout.erb -> layout.html.erb * locale.yaml -> locale.yml * PageMetric.a5 -> PageMetric::A5 --- lib/review/book/page_metric.rb | 10 ---------- lib/review/configure.rb | 2 +- lib/review/htmlbuilder.rb | 3 --- lib/review/i18n.rb | 5 ----- test/test_i18n.rb | 11 ----------- 5 files changed, 1 insertion(+), 30 deletions(-) diff --git a/lib/review/book/page_metric.rb b/lib/review/book/page_metric.rb index c48da8609..201c6a835 100644 --- a/lib/review/book/page_metric.rb +++ b/lib/review/book/page_metric.rb @@ -24,16 +24,6 @@ def initialize(list_lines, list_columns, text_lines, text_columns, page_per_kbyt A5 = PageMetric.new(46, 80, 30, 74, 1) B5 = PageMetric.new(46, 80, 30, 74, 2) - # backward compatible - def PageMetric.a5 - ReVIEW::Book::PageMetric::A5 - end - - # backward compatible - def PageMetric.b5 - ReVIEW::Book::PageMetric::B5 - end - attr_reader :list attr_reader :text attr_reader :page_per_kbyte diff --git a/lib/review/configure.rb b/lib/review/configure.rb index acefb9dd0..206b918e5 100644 --- a/lib/review/configure.rb +++ b/lib/review/configure.rb @@ -46,7 +46,7 @@ def self.values "reject_file" => 'REJECT', "predef_file" => 'PREDEF', "postdef_file" => 'POSTDEF', - "page_metric" => ReVIEW::Book::PageMetric.a5, + "page_metric" => ReVIEW::Book::PageMetric::A5, "ext" => '.re', "image_dir" => 'images', "image_types" => %w( .ai .psd .eps .pdf .tif .tiff .png .bmp .jpg .jpeg .gif .svg ), diff --git a/lib/review/htmlbuilder.rb b/lib/review/htmlbuilder.rb index 70e36d8fe..1f1ce0b02 100644 --- a/lib/review/htmlbuilder.rb +++ b/lib/review/htmlbuilder.rb @@ -63,9 +63,6 @@ def builder_init_file def result layout_file = File.join(@book.basedir, "layouts", "layout.html.erb") - unless File.exist?(layout_file) # backward compatibility - layout_file = File.join(@book.basedir, "layouts", "layout.erb") - end if File.exist?(layout_file) if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0 warn "user's layout is prohibited in safe mode. ignored." diff --git a/lib/review/i18n.rb b/lib/review/i18n.rb index ea240d3af..79d638584 100644 --- a/lib/review/i18n.rb +++ b/lib/review/i18n.rb @@ -20,11 +20,6 @@ def self.setup(locale="ja", ymlfile = "locale.yml") lfile = nil if ymlfile lfile = File.expand_path(ymlfile, Dir.pwd) - - # backward compatibility - if !File.exist?(lfile) && (ymlfile == "locale.yml") - lfile = File.expand_path("locale.yaml", Dir.pwd) - end end if lfile && File.file?(lfile) diff --git a/test/test_i18n.rb b/test/test_i18n.rb index b80eb6977..fdf17c339 100644 --- a/test/test_i18n.rb +++ b/test/test_i18n.rb @@ -18,17 +18,6 @@ def test_load_locale_yml end end - def test_load_locale_yaml - Dir.mktmpdir do |dir| - Dir.chdir(dir) do - file = File.join(dir, "locale.yaml") - File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")} - I18n.setup - assert_equal "bar", I18n.t("foo") - end - end - end - def test_load_foo_yaml Dir.mktmpdir do |dir| Dir.chdir(dir) do From da390b7d0b7a359cf99759f2091854c823805231 Mon Sep 17 00:00:00 2001 From: takahashim Date: Sun, 17 Apr 2016 17:00:30 +0900 Subject: [PATCH 2/2] raise error when using locale.yaml and layout.erb --- lib/review/htmlbuilder.rb | 3 +++ lib/review/i18n.rb | 5 +++++ test/test_i18n.rb | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/lib/review/htmlbuilder.rb b/lib/review/htmlbuilder.rb index 1f1ce0b02..e8b625fb4 100644 --- a/lib/review/htmlbuilder.rb +++ b/lib/review/htmlbuilder.rb @@ -63,6 +63,9 @@ def builder_init_file def result layout_file = File.join(@book.basedir, "layouts", "layout.html.erb") + if !File.exist?(layout_file) && File.exist?(File.join(@book.basedir, "layouts", "layout.erb")) + raise ReVIEW::ConfigError, "layout.erb is obsoleted. Please use layout.html.erb." + end if File.exist?(layout_file) if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0 warn "user's layout is prohibited in safe mode. ignored." diff --git a/lib/review/i18n.rb b/lib/review/i18n.rb index 79d638584..d4858f46b 100644 --- a/lib/review/i18n.rb +++ b/lib/review/i18n.rb @@ -20,6 +20,11 @@ def self.setup(locale="ja", ymlfile = "locale.yml") lfile = nil if ymlfile lfile = File.expand_path(ymlfile, Dir.pwd) + + # backward compatibility + if !File.exist?(lfile) && (ymlfile == "locale.yml") && File.exist?(File.expand_path("locale.yaml", Dir.pwd)) + raise ReVIEW::ConfigError, "locale.yaml is obsoleted. Please use locale.yml." + end end if lfile && File.file?(lfile) diff --git a/test/test_i18n.rb b/test/test_i18n.rb index fdf17c339..32795a72c 100644 --- a/test/test_i18n.rb +++ b/test/test_i18n.rb @@ -18,6 +18,18 @@ def test_load_locale_yml end end + def test_load_locale_yaml + Dir.mktmpdir do |dir| + Dir.chdir(dir) do + file = File.join(dir, "locale.yaml") + File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")} + assert_raise ReVIEW::ConfigError do + I18n.setup + end + end + end + end + def test_load_foo_yaml Dir.mktmpdir do |dir| Dir.chdir(dir) do