Class: Puppet::Module::Tool::Applications::Generator::ParsedFileNode

Inherits:
Node
  • Object
show all
Defined in:
lib/puppet/module/tool/applications/generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

inherited, #initialize, on, #read, types

Constructor Details

This class inherits a constructor from Puppet::Module::Tool::Applications::Generator::Node

Class Method Details

.matches?(path) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/puppet/module/tool/applications/generator.rb', line 89

def self.matches?(path)
  path.file? && path.extname == '.erb'
end

Instance Method Details

#contentsObject



96
97
98
99
# File 'lib/puppet/module/tool/applications/generator.rb', line 96

def contents
  template = ERB.new(read)
  template.result(@generator.send(:binding))
end

#install!Object



100
101
102
# File 'lib/puppet/module/tool/applications/generator.rb', line 100

def install!
  target.open('w') { |f| f.write contents }
end

#targetObject



92
93
94
95
# File 'lib/puppet/module/tool/applications/generator.rb', line 92

def target
  path = super
  path.parent + path.basename('.erb')
end