Class: TwitterCldr::Resources::Importer
- Inherits:
-
Object
- Object
- TwitterCldr::Resources::Importer
show all
- Defined in:
- lib/twitter_cldr/resources/importer.rb
Direct Known Subclasses
AliasesImporter, Bcp47TimezoneMetadataImporter, BidiTestImporter, CalendarsImporter, CasefolderClassGenerator, CollationTestsImporter, CollationTriesImporter, CurrencySymbolsImporter, DayPeriodRulesImporter, HyphenationImporter, LanguageCodesImporter, ListFormatsImporter, LocalesResourcesImporter, NumberFormatsImporter, ParentLocalesImporter, PostalCodesImporter, Properties::PropertyImporter, RbnfTestImporter, SegmentDictionariesImporter, SegmentRulesImporter, SegmentTestsImporter, TailoringImporter, TerritoriesImporter, TimezoneRegionsImporter, TimezoneTestsImporter, TimezonesImporter, TransformTestsImporter, TransformsImporter, UnicodeDataImporter, UnicodePropertyAliasesImporter, UnitsImporter, ValidityDataImporter
Constant Summary
collapse
- DEFAULT_ENGINE =
:mri
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Importer
Returns a new instance of Importer.
67
68
69
70
|
# File 'lib/twitter_cldr/resources/importer.rb', line 67
def initialize(options = {})
@params = self.class.default_params.merge(options)
@requirements = self.class.requirements
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
65
66
67
|
# File 'lib/twitter_cldr/resources/importer.rb', line 65
def params
@params
end
|
#requirements ⇒ Object
Returns the value of attribute requirements.
65
66
67
|
# File 'lib/twitter_cldr/resources/importer.rb', line 65
def requirements
@requirements
end
|
Class Method Details
.default_params ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/twitter_cldr/resources/importer.rb', line 38
def default_params
parameters.merge(
output_path: @output_path,
locales: get_locales,
ruby_engine: @ruby_engine || DEFAULT_ENGINE
)
end
|
.locales(locs) ⇒ Object
30
31
32
|
# File 'lib/twitter_cldr/resources/importer.rb', line 30
def locales(locs)
@locales = locs
end
|
.output_path(path) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/twitter_cldr/resources/importer.rb', line 22
def output_path(path)
@output_path = if path.start_with?('/')
path
else
File.join(TwitterCldr::RESOURCES_DIR, path)
end
end
|
.parameter(key, value) ⇒ Object
34
35
36
|
# File 'lib/twitter_cldr/resources/importer.rb', line 34
def parameter(key, value)
parameters[key] = value
end
|
.parameters ⇒ Object
50
51
52
|
# File 'lib/twitter_cldr/resources/importer.rb', line 50
def parameters
@parameters ||= {}
end
|
.requirement(name, *args) ⇒ Object
13
14
15
16
|
# File 'lib/twitter_cldr/resources/importer.rb', line 13
def requirement(name, *args)
const_name = "#{name.to_s.capitalize}Requirement".to_sym
requirements[name] = Requirements.const_get(const_name).new(*args)
end
|
.requirements ⇒ Object
46
47
48
|
# File 'lib/twitter_cldr/resources/importer.rb', line 46
def requirements
@requirements ||= {}
end
|
.ruby_engine(engine) ⇒ Object
18
19
20
|
# File 'lib/twitter_cldr/resources/importer.rb', line 18
def ruby_engine(engine)
@ruby_engine = engine
end
|
Instance Method Details
#can_import? ⇒ Boolean
72
73
74
|
# File 'lib/twitter_cldr/resources/importer.rb', line 72
def can_import?
importability_errors.empty?
end
|
#import ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/twitter_cldr/resources/importer.rb', line 76
def import
if can_import?
puts "Importing #{name}..."
prepare
execute
else
raise "Can't import #{name}: #{importability_errors.first}"
end
end
|
#prepare ⇒ Object
86
87
88
89
90
|
# File 'lib/twitter_cldr/resources/importer.rb', line 86
def prepare
before_prepare
requirements.each { |_, req| req.prepare }
after_prepare
end
|