Class: Locraft::ConstantsGenerator
- Inherits:
-
Object
- Object
- Locraft::ConstantsGenerator
show all
- Includes:
- FileUtils
- Defined in:
- lib/locraft/generators/constants_generator.rb
Instance Method Summary
collapse
Constructor Details
#initialize(config, localizations) ⇒ ConstantsGenerator
Returns a new instance of ConstantsGenerator.
8
9
10
11
|
# File 'lib/locraft/generators/constants_generator.rb', line 8
def initialize(config, localizations)
@config = config
@localizations = localizations
end
|
Instance Method Details
#constant_from(_key) ⇒ Object
34
35
36
|
# File 'lib/locraft/generators/constants_generator.rb', line 34
def constant_from(_key)
raise NotImplementedError
end
|
#constants_keys ⇒ Object
28
29
30
31
32
|
# File 'lib/locraft/generators/constants_generator.rb', line 28
def constants_keys
@localizations.select(&:valid?).map do |l|
{ key: l.key, const: constant_from(l.key) }
end
end
|
38
39
40
|
# File 'lib/locraft/generators/constants_generator.rb', line 38
def
resource_file('macro_files_header.txt')
end
|
#files_name ⇒ Object
24
25
26
|
# File 'lib/locraft/generators/constants_generator.rb', line 24
def files_name
@config.dev_prefix + @config.macro_file
end
|
#generate ⇒ Object
13
14
15
|
# File 'lib/locraft/generators/constants_generator.rb', line 13
def generate
raise NotImplementedError
end
|
#resource_file(file) ⇒ Object
42
43
44
|
# File 'lib/locraft/generators/constants_generator.rb', line 42
def resource_file(file)
File.read(File.expand_path("../../resources/#{file}", __FILE__))
end
|
#write_file_content(file, content) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/locraft/generators/constants_generator.rb', line 17
def write_file_content(file, content)
File.open(file, 'w+') do |f|
f.puts + "\n"
f.puts content
end
end
|