Class: Puppet::ModuleTool::Applications::Generator::ParsedFileNode

Inherits:
Node
  • Object
show all
Defined in:
lib/vendor/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::ModuleTool::Applications::Generator::Node

Class Method Details

.matches?(path) ⇒ Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/vendor/puppet/module_tool/applications/generator.rb', line 115

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

Instance Method Details

#contentsObject



122
123
124
125
# File 'lib/vendor/puppet/module_tool/applications/generator.rb', line 122

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

#install!Object



126
127
128
# File 'lib/vendor/puppet/module_tool/applications/generator.rb', line 126

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

#targetObject



118
119
120
121
# File 'lib/vendor/puppet/module_tool/applications/generator.rb', line 118

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