Class: Puppet::Module::Tool::Applications::Generator
- Inherits:
-
Application
- Object
- Application
- Puppet::Module::Tool::Applications::Generator
- Defined in:
- lib/puppet/module/tool/applications/generator.rb
Defined Under Namespace
Classes: DirectoryNode, FileNode, Node, ParsedFileNode
Instance Attribute Summary
Attributes inherited from Application
Instance Method Summary collapse
- #destination ⇒ Object
-
#initialize(full_name, options) ⇒ Generator
constructor
A new instance of Generator.
- #run ⇒ Object
- #skeleton ⇒ Object
Methods inherited from Application
#discuss, #load_modulefile!, #metadata, #parse_filename!, #repository, run
Methods included from Utils::Interrogation
#confirms?, #header, #prompt, #say, #subheader
Constructor Details
#initialize(full_name, options) ⇒ Generator
Returns a new instance of Generator.
10 11 12 13 14 15 16 17 |
# File 'lib/puppet/module/tool/applications/generator.rb', line 10 def initialize(full_name, ) begin @metadata = Metadata.new(:full_name => full_name) rescue ArgumentError abort "Could not generate directory #{full_name.inspect}, you must specify a dash-separated username and module name." end super() end |
Instance Method Details
#destination ⇒ Object
43 44 45 |
# File 'lib/puppet/module/tool/applications/generator.rb', line 43 def destination @destination ||= Pathname.new(@metadata.dashed_name) end |
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/puppet/module/tool/applications/generator.rb', line 23 def run if destination.directory? abort "#{destination} already exists." end header "Generating module at #{Dir.pwd}/#{@metadata.dashed_name}" skeleton.path.find do |path| if path == skeleton destination.mkpath else node = Node.on(path, self) if node node.install! say node.target else say "Could not generate from #{path}" end end end end |
#skeleton ⇒ Object
19 20 21 |
# File 'lib/puppet/module/tool/applications/generator.rb', line 19 def skeleton @skeleton ||= Skeleton.new end |