Class: GoNative::Utils::TemplateInflator
- Inherits:
-
Object
- Object
- GoNative::Utils::TemplateInflator
- Extended by:
- DSL::Serviceable
- Defined in:
- lib/gonative/utils/template_inflator.rb
Instance Method Summary collapse
- #call ⇒ Object
- #contents(file) ⇒ Object
- #inflate_files ⇒ Object
-
#initialize(options) ⇒ TemplateInflator
constructor
A new instance of TemplateInflator.
- #normalized_name(file_name) ⇒ Object
Constructor Details
#initialize(options) ⇒ TemplateInflator
Returns a new instance of TemplateInflator.
10 11 12 |
# File 'lib/gonative/utils/template_inflator.rb', line 10 def initialize() @options = end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gonative/utils/template_inflator.rb', line 14 def call Dir.glob('*/').each do |dir| FileUtils.cd(dir) call FileUtils.cd('..') dir_name = dir.delete_suffix('/') normalized_name = normalized_name(dir_name) FileUtils.mv(dir_name, normalized_name) if dir_name != normalized_name end inflate_files end |
#contents(file) ⇒ Object
33 34 35 36 |
# File 'lib/gonative/utils/template_inflator.rb', line 33 def contents(file) content = File.read(file) Utils::ContentEvaluator.call(content, ) end |
#inflate_files ⇒ Object
26 27 28 29 30 31 |
# File 'lib/gonative/utils/template_inflator.rb', line 26 def inflate_files Dir.glob("*#{TEMPLATE_FILES_EXTENSION}").each do |file| File.write(normalized_name(file), contents(file)) FileUtils.rm(file) end end |
#normalized_name(file_name) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/gonative/utils/template_inflator.rb', line 38 def normalized_name(file_name) new_name = file_name.dup .each do |key, value| new_name.gsub!(key.to_s.upcase, value) end new_name.delete_suffix(TEMPLATE_FILES_EXTENSION) end |