Class: Linecook::Commands::Package
- Defined in:
- lib/linecook/commands/package.rb
Overview
:startdoc::desc generates a package
Generates the package specified at ‘project_dir/packages/package_name.yml’. The package file should be a YAML files that specifies a package env. The full path to package file can be given instead of package name using the –file option.
If a cookbook file is present in the project_dir then it will be used to resolve resources available to the package. See the env command to interrogate a package env.
Constant Summary
Constants inherited from Command
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
- #default_package_dir(package_file) ⇒ Object
- #package_dependencies(package) ⇒ Object
- #process(package_file, package_dir = nil) ⇒ Object
Methods inherited from Command
#call, inherited, #initialize, #log, registry, #sh, #sh!
Constructor Details
This class inherits a constructor from Linecook::Commands::Command
Instance Method Details
#default_package_dir(package_file) ⇒ Object
52 53 54 |
# File 'lib/linecook/commands/package.rb', line 52 def default_package_dir(package_file) package_file.chomp(File.extname(package_file)) end |
#package_dependencies(package) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/linecook/commands/package.rb', line 40 def package_dependencies(package) dependencies = [] package.manifest.values.collect do |resources| dependencies.concat resources.values end $LOAD_PATH.each do |path| dependencies.concat Dir.glob("#{path}/**/*.rb") end dependencies end |
#process(package_file, package_dir = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/linecook/commands/package.rb', line 25 def process(package_file, package_dir=nil) package_dir ||= default_package_dir(package_file) package_dir = File.(package_dir) package = Linecook::Package.init(package_file, project_dir) dependencies = package_dependencies(package) + [package_file] if force || !FileUtils.uptodate?(package_dir, dependencies) package.build package.export(package_dir) $stdout.puts package_dir unless quiet end package_dir end |