Class: Pakman::Gen
- Inherits:
-
Object
- Object
- Pakman::Gen
- Includes:
- LogUtils::Logging, ManifestHelper
- Defined in:
- lib/pakman/cli/commands/gen.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Gen
constructor
A new instance of Gen.
- #run(args) ⇒ Object
Methods included from ManifestHelper
#installed_template_manifest_patterns, #installed_template_manifests
Constructor Details
#initialize(opts) ⇒ Gen
Returns a new instance of Gen.
11 12 13 |
# File 'lib/pakman/cli/commands/gen.rb', line 11 def initialize( opts ) @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
15 16 17 |
# File 'lib/pakman/cli/commands/gen.rb', line 15 def opts @opts end |
Instance Method Details
#run(args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pakman/cli/commands/gen.rb', line 17 def run( args ) manifest_name = opts.manifest manifest_name = manifest_name.downcase.gsub('.txt', '' ) # remove .txt if present logger.debug "manifest=#{manifest_name}" # check for matching manifests manifests = installed_template_manifests.select { |m| m[0] == manifest_name+'.txt' } if manifests.empty? puts "*** error: unknown template pack '#{manifest_name}'; use pakman -l to list installed template packs" exit 2 end manifestsrc = manifests[0][1] pakpath = opts.output_path if args.empty? Copier.new.copy_pak( manifestsrc, pakpath ) else args.each do |arg| data = YAML.load_file( arg ) name = File.basename( arg, '.*' ) puts "#{name}:" pp data Templater.new.merge_pak( manifestsrc, pakpath, Ctx.new(data).ctx, name ) end end end |