Sha256: 2e837a0a21fbd6b09abebeffa91d5f27fe3a9e49416a2e5501281ed554fae997

Contents?: true

Size: 757 Bytes

Versions: 32

Compression:

Stored size: 757 Bytes

Contents

require "fileutils"

class Thor
  # Creates a package task.
  #
  # ==== Parameters
  # spec<Gem::Specification>
  #
  # ==== Options
  # :dir - The package directory. Defaults to ./pkg.
  #
  def self.package_task(spec, options={})
    tasks['package'] = Thor::PackageTask.new(spec, options)
  end

  class PackageTask < Task
    attr_accessor :spec, :config

    def initialize(gemspec, config={})
      super(:package, "Build a gem package", "package", {})
      @spec   = gemspec
      @config = {:dir => File.join(Dir.pwd, "pkg")}.merge(config)
    end

    def run(instance, args=[])
      FileUtils.mkdir_p(config[:dir])
      Gem::Builder.new(spec).build
      FileUtils.mv(spec.file_name, File.join(config[:dir], spec.file_name))
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
josevalim-thor-0.10.0 lib/thor/tasks/package.rb
josevalim-thor-0.10.1 lib/thor/tasks/package.rb
josevalim-thor-0.10.10 lib/thor/tasks/package.rb
josevalim-thor-0.10.11 lib/thor/tasks/package.rb
josevalim-thor-0.10.12 lib/thor/tasks/package.rb
josevalim-thor-0.10.13 lib/thor/tasks/package.rb
josevalim-thor-0.10.14 lib/thor/tasks/package.rb
josevalim-thor-0.10.15 lib/thor/tasks/package.rb
josevalim-thor-0.10.16 lib/thor/tasks/package.rb
josevalim-thor-0.10.17 lib/thor/tasks/package.rb
josevalim-thor-0.10.18 lib/thor/tasks/package.rb
josevalim-thor-0.10.19 lib/thor/tasks/package.rb
josevalim-thor-0.10.2 lib/thor/tasks/package.rb
josevalim-thor-0.10.20 lib/thor/tasks/package.rb
josevalim-thor-0.10.21 lib/thor/tasks/package.rb
josevalim-thor-0.10.22 lib/thor/tasks/package.rb
josevalim-thor-0.10.23 lib/thor/tasks/package.rb
josevalim-thor-0.10.25 lib/thor/tasks/package.rb
josevalim-thor-0.10.26 lib/thor/tasks/package.rb
josevalim-thor-0.10.27 lib/thor/tasks/package.rb