Class: Puppet::Module::Tool::Applications::Generator::Node

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

Direct Known Subclasses

DirectoryNode, FileNode, ParsedFileNode

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, generator) ⇒ Node

Returns a new instance of Node.



60
61
62
63
# File 'lib/puppet/module/tool/applications/generator.rb', line 60

def initialize(source, generator)
  @generator = generator
  @source = source
end

Class Method Details

.inherited(klass) ⇒ Object



51
52
53
# File 'lib/puppet/module/tool/applications/generator.rb', line 51

def self.inherited(klass)
  types << klass
end

.on(path, generator) ⇒ Object



54
55
56
57
58
59
# File 'lib/puppet/module/tool/applications/generator.rb', line 54

def self.on(path, generator)
  klass = types.detect { |t| t.matches?(path) }
  if klass
    klass.new(path, generator)
  end
end

.typesObject



48
49
50
# File 'lib/puppet/module/tool/applications/generator.rb', line 48

def self.types
  @types ||= []
end

Instance Method Details

#install!Object

Raises:

  • (NotImplementedError)


74
75
76
# File 'lib/puppet/module/tool/applications/generator.rb', line 74

def install!
  raise NotImplementedError, "Abstract"
end

#readObject



64
65
66
# File 'lib/puppet/module/tool/applications/generator.rb', line 64

def read
  @source.read
end

#targetObject



67
68
69
70
71
72
73
# File 'lib/puppet/module/tool/applications/generator.rb', line 67

def target
  target = @generator.destination + @source.relative_path_from(@generator.skeleton.path)
  components = target.to_s.split(File::SEPARATOR).map do |part|
    part == 'NAME' ? @generator..name : part
  end
  Pathname.new(components.join(File::SEPARATOR))
end