Parent

Syckle::Plugins::Box

Box Packaging Service

The Box plugin, as the name suggests, utilizes the stand-alone box tool to build packages.

Constants

DEFAULT_EXCLUDE

Directories that a typically excluded from a distribution.

DEFAULT_IGNORE

File pattern are files/dirs that are typically ignored.

DEFAULT_INCLUDE

Default patterns of files to include in a manifest file.

DEFAULT_TYPES

Default package types passed to the box command.

Attributes

exclude[RW]

Globs of files and/or directories to exclude from manifest. This is not used unless master is set to true.

ignore[RW]

Standard files to ignore. Defaults to hidden files (.*). Unlike exclude these match against the basename, rather than the full pathname. This is not used unless master is set to true.

include[RW]

Globs of files and/or directories to include in manifest. This is not used unless master is set to true.

manifest[RW]

Manifest file to use. Default is MANIFEST case-insensitve with optional .txt extension.

master[RW]

Regenerate manifest (true or false)? The default is false. Unless this is set to true a MANIFEST file must already be present in the project’s root directory.

It is generally considered good practice to manually manitain a MANIFEST file. However, if a project has complex packaging needs, such as special manifests per specific package types, then auto-generating the MANIFEST file proves invaluable.

master?[RW]

Regenerate manifest (true or false)? The default is false. Unless this is set to true a MANIFEST file must already be present in the project’s root directory.

It is generally considered good practice to manually manitain a MANIFEST file. However, if a project has complex packaging needs, such as special manifests per specific package types, then auto-generating the MANIFEST file proves invaluable.

spec[RW]

Save spec file (if applicable)

types[RW]

Package types to produce.

Public Instance Methods

collect_files(with_dirs=false) click to toggle source

Collect distributable files. This methid is called and cached by files.

# File plug/syckle/services/box.rb, line 183
def collect_files(with_dirs=false)
  files = []

  Dir.chdir(project.source) do
    files = amass(distribute, exclude, ignore)
    #files += Dir.multiglob_r(*distribute)
    #files -= Dir.multiglob_r(*exclude)
    #files -= Dir.multiglob_r(*ignore)

    #files -= Dir.multiglob_r(project.pack.to_s) #package_directory
  end

  # Do not include symlinks
  files.reject!{ |f| FileTest.symlink?(f) }

  # Option to exclude directories
  unless with_dirs
    files = files.select{ |f| !File.directory?(f) }
  end

  return files
end
create_manifest() click to toggle source

Generate a manifest.

TODO: Use Mast? TODO: Compare manifests and skip overwrite if they are the same?

# File plug/syckle/services/box.rb, line 158
def create_manifest #(*files)
  return if dryrun?
  manifest_file = manifest || 'MANIFEST'
  #
  files = files().flatten.compact
  files = ['**/*'] if files.empty?
  #Dir.chdir(project.root) do
    files = multiglob(*files).sort
    rm(manifest_file) if File.exist?(manifest_file)
    File.open(manifest_file, 'w') do |f|
      f << files.join("\n")
    end
  #end
end
exclude=(val) click to toggle source

Set file patterns to exclude from package. This is a special writer to allow for a single glob or a list of globs.

# File plug/syckle/services/box.rb, line 85
def exclude=(val)
  @exclude = [val].flatten
end
files() click to toggle source

List of files included in the package. This is generated using include and exclude.

# File plug/syckle/services/box.rb, line 176
def files
  @files ||= collect_files(true)
end
ignore=(val) click to toggle source

Set file patterns to ignore. This is a special writer to allow for a single glob or a list of globs.

# File plug/syckle/services/box.rb, line 91
def ignore=(val)
  @ignore = [val].flatten
end
include=(val) click to toggle source

Set file patterns used to select files to distribute in package. This is a special writer to allow for a single glob or a list of globs.

# File plug/syckle/services/box.rb, line 79
def include=(val)
  @include = [val].flatten
end
initialize_defaults() click to toggle source
# File plug/syckle/services/box.rb, line 96
def initialize_defaults
  super
  @manifest   = project.root.glob('MANIFEST{,.txt}', :casefold).first
  @types      = DEFAULT_TYPES
  @include    = DEFAULT_INCLUDE #metadata.distribute || DEFAULT_INCLUDE
  @exclude    = DEFAULT_EXCLUDE
  @ignore     = DEFAULT_IGNORE
  @spec       = false
end
package() click to toggle source
# File plug/syckle/services/box.rb, line 114
    def package
      require 'box'

      loc = Dir.pwd

      # DEPRECATE: safe option is replaced by dryrun
      opts = {
        :force  => force?,
        :dryrun => dryrun?,
        :safe   => dryrun?,
        :spec   => spec
      }
#p spec
      create_manifest if master? #(*files)

      types.each do |type|
        case type
        when 'zip'
          status("Building #{package_name}.zip")
          box = ::Box::Zip.new(loc, opts)
        when 'gz', 'tar' #TODO: probably remove tar
          status("Building #{package_name}.tar.gz")
          box = ::Box::Gz.new(loc, opts)
        when 'gem'
          status("Building #{package_name}.gem")
          box = ::Box::Gem.new(loc, opts)
        end
        box.package
      end

      #report_package_built(file)
    end
package_name() click to toggle source

Returns package name from metadata. This is generally in the form or +#{package}-#{version}+.

# File plug/syckle/services/box.rb, line 149
def package_name
  metadata.package_name
end
preconfigure() click to toggle source

Check for available MANIFEST file if needed.

# File plug/syckle/services/box.rb, line 107
def preconfigure
  if !master && !manifest #project.root.glob('MANIFEST{,.txt}', :casefold).first
    abort "No Manifest file available for Box.\nUse 'master' option or create a MANIFEST file."
  end
end
types=(val) click to toggle source

Set package types to produce. This is a special writer to allow for a single glob or a list of globs.

# File plug/syckle/services/box.rb, line 73
def types=(val)
  @types = [val].flatten
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.