class Bones::GemPackageTask

Attributes

gem_spec[RW]

Ruby GEM spec containing the metadata for this package. The name, version and package_files are automatically determined from the GEM spec and don't need to be explicitly provided.

Public Class Methods

new(gem_spec) { |self| ... } click to toggle source

Create a GEM Package task library. Automatically define the gem if a block is given. If no block is supplied, then define needs to be called to define the task.

# File lib/bones/gem_package_task.rb, line 23
def initialize(gem_spec)
  init(gem_spec)
  yield self if block_given?
  define if block_given?
end

Public Instance Methods

define() click to toggle source

Create the Rake tasks and actions specified by this GemPackageTask. (define is automatically called if a block is given to new).

Calls superclass method
# File lib/bones/gem_package_task.rb, line 42
def define
  super
  task :prereqs
  task :package => ["#{package_dir_path}/#{gem_file}"]

  file "#{package_dir_path}/#{gem_file}" => [package_dir_path] + package_files do
    when_writing("Creating GEM") {
      chdir(package_dir_path) do
        if RUBY_VERSION >= "2"
          Gem::Package.build(gem_spec)
        else
          Gem::Builder.new(gem_spec).build
        end
        verbose(true) {
          mv gem_file, "../#{gem_file}"
        }
      end
    }
  end

  file package_dir_path => 'gem:prereqs' do
    mkdir_p package_dir rescue nil
  end
end
gem_file() click to toggle source
# File lib/bones/gem_package_task.rb, line 69
def gem_file
  if @gem_spec.platform == Gem::Platform::RUBY
    "#{package_name}.gem"
  else
    "#{package_name}-#{@gem_spec.platform}.gem"
  end
end
init(gem) click to toggle source

Initialization tasks without the “yield self” or define operations.

Calls superclass method
# File lib/bones/gem_package_task.rb, line 32
def init(gem)
  super(gem.name, gem.version)
  @gem_spec = gem
  @package_files += gem_spec.files if gem_spec.files
end