Path::Shell
Pack is the base class for all other packaging services.
This is a subclass of Path::Shell to provide shell utilities.
New package creator.
Valid options:
:debug :noop :verbose :quiet :force :spec :manifest
# File lib/box/pack.rb, line 32 def initialize(location, options={}) if $TRIAL || options[:trial] options[:noop] = true options[:verbose] = true end super(location, options) @force = options[:force] @spec = options[:spec] @manif = options[:manifest] @project = POM::Project.new(location, :lookup=>true) #, :load=>true) @location = @project.root #dir(location) @metadata = @project.metadata #POM::Metadata.new(location.to_s) # If a dedicated package directory exists (ie. pkg/ or pack/) # use that instead of default locations. if options[:output] if File.directory?(options[:output]) @pack_folder = dir(options[:output]) else raise ArgumentError, "#{options[:output]} is not a directory" end elsif inside? # TODO: Should we go ahead and force project.pack? pkgdir = project.pack @pack_folder = dir(pkgdir) if File.directory?(pkgdir) #@temp_folder = @pack_folder else @pack_folder = dir(Dir.pwd) # or project.pack ? end end
Current platform.
# File lib/box/pack.rb, line 161 def current_platform Platform.local.to_s end
# File lib/box/pack.rb, line 165 def extension raise "must override #extension" end
TODO: Pathname should have contains? too.
# File lib/box/pack.rb, line 74 def inside? FileTest.contains?(Dir.pwd, @location.to_s) end
Manifest list
# File lib/box/pack.rb, line 117 def manifest @manifest ||= ( list = [] manifest_file.readlines.each do |line| next if line =~ /^\s*$/ next if line =~ /^\s*[#]/ list << line.strip end list ) end
Manifest file
# File lib/box/pack.rb, line 112 def manifest_file @manifest_file ||= location.glob('MANIFEST{,.txt}', :casefold).first end
Unless otherwise specified packages will be saved to current working directory.
# File lib/box/pack.rb, line 156 def pack_folder @pack_folder ||= location end
# File lib/box/pack.rb, line 79 def package unless package_needed? or force? report_package_already_built(package_file) return end if manifest? && !dryrun? files = metadata.distribute # generate manifest in root directory generate_manifest(location, *files) end if !manifest_file.exist? puts "MANIFEST file is missing" return end file = nil cd(location) do file = Pathname.new(package_build) end file = transfer(file, pack_folder) report_package_built(file) end
Generated with the Darkfish Rdoc Generator 2.