lib/gooday/index.rb in gooday-0.1.1 vs lib/gooday/index.rb in gooday-0.1.2
- old
+ new
@@ -27,18 +27,22 @@
@min = context.min
@sec = context.sec
@zone = context.zone
end
- def locale(locale, path: false, target: "ruby")
+ def locale(locale, path: nil, target: "ruby")
if target.downcase.match?(/^(yml|yaml)/)
- raise Gooday::Error, "#{locale.inspect} doesn't exist as a YAML locale format" unless File.exist?(File.expand_path("#{locale}.yml", path))
+ raise Gooday::Error, "#{locale.inspect} doesn't exist as a YAML locale format" unless File.exist?(File.expand_path("#{locale}.yml", File.dirname(path)))
require "gooday/yaml_parser"
@translations = YAMLParser.new(File.expand_path("#{locale}.yml", path))
.translations.transform_keys(&:to_sym)
else
- raise Gooday::Error, "#{locale.inspect} doesn't exist as a RUBY locale format" unless File.exist?(path ? File.expand_path("#{locale}.rb", path) : "./lib/gooday/locales/#{locale}.rb")
+ if path
+ raise Gooday::Error, "#{locale.inspect} doesn't exist as a RUBY locale format" unless File.file?(File.expand_path("#{locale}.rb", path))
+ else
+ raise Gooday::Error, "#{locale.inspect} doesn't exist as a RUBY locale format" unless File.file?(File.expand_path("./locales/#{locale}.rb", File.dirname(__FILE__)))
+ end
file = if path
File.expand_path("#{locale}.rb", path)
else
File.expand_path("./locales/#{locale}.rb", File.dirname(__FILE__))