lib/twitter_cldr/resources/importer.rb in twitter_cldr-4.4.5 vs lib/twitter_cldr/resources/importer.rb in twitter_cldr-5.0.0
- old
+ new
@@ -36,11 +36,11 @@
end
def default_params
parameters.merge(
output_path: @output_path,
- locales: @locales,
+ locales: get_locales,
ruby_engine: @ruby_engine || DEFAULT_ENGINE
)
end
def requirements
@@ -48,10 +48,20 @@
end
def parameters
@parameters ||= {}
end
+
+ private
+
+ def get_locales
+ if ENV.include?('LOCALES')
+ ENV['LOCALES'].split(',').map { |loc| loc.strip.to_sym }
+ else
+ @locales
+ end
+ end
end
attr_reader :params, :requirements
def initialize(options = {})
@@ -63,23 +73,33 @@
importability_errors.empty?
end
def import
if can_import?
+ puts "Importing #{name}..."
prepare
execute
else
- raise "Can't import #{self.class.name}: #{importability_errors.first}"
+ raise "Can't import #{name}: #{importability_errors.first}"
end
end
def prepare
before_prepare
requirements.each { |_, req| req.prepare }
after_prepare
end
private
+
+ def name
+ @name ||= self.class.name
+ .split('::').last
+ .chomp('Importer')
+ .gsub(/([A-Z])([a-z])/) { " #{$1.downcase}#{$2}" }
+ .strip
+ .tap { |n| n << 's' unless n.end_with?('s') }
+ end
def importability_errors
@importability_errors ||= [].tap do |errors|
errors << 'incompatible RUBY_ENGINE' unless compatible_engine?
end