Class: Locraft::ConstantsGenerator
- Inherits:
-
Generator
show all
- Includes:
- FileUtils
- Defined in:
- lib/locraft/generators/constants_generator.rb
Instance Method Summary
collapse
Methods inherited from Generator
#generate, #initialize, #valid?
Instance Method Details
#constant_from(_key) ⇒ Object
27
28
29
|
# File 'lib/locraft/generators/constants_generator.rb', line 27
def constant_from(_key)
raise NotImplementedError
end
|
#constants_keys_with(localizations) ⇒ Object
21
22
23
24
25
|
# File 'lib/locraft/generators/constants_generator.rb', line 21
def constants_keys_with(localizations)
localizations.select(&:valid?).map do |l|
{ key: l.key, const: constant_from(l.key) }
end
end
|
31
32
33
|
# File 'lib/locraft/generators/constants_generator.rb', line 31
def
Utils.resource_file('macro_files_header.txt')
end
|
#files_name ⇒ Object
17
18
19
|
# File 'lib/locraft/generators/constants_generator.rb', line 17
def files_name
@config.dev_prefix + @config.macro_file
end
|
#write_file_content(file, content) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/locraft/generators/constants_generator.rb', line 10
def write_file_content(file, content)
File.open(file, 'w+') do |f|
f.puts + "\n"
f.puts content
end
end
|