blob: 603d61b4abb009fe8f8dbe578d376c689cda1606 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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
|