Class: Thor::PackageTask

Inherits:
Task
  • Object
show all
Defined in:
lib/thor/lib/thor/tasks/package.rb

Instance Attribute Summary collapse

Attributes inherited from Task

#description, #klass, #meth, #usage

Instance Method Summary collapse

Methods inherited from Task

dynamic, #formatted_usage, #full_opts, #namespace, #parse, #with_klass

Constructor Details

#initialize(gemspec, opts = {}) ⇒ PackageTask

Returns a new instance of PackageTask.



7
8
9
10
11
# File 'lib/thor/lib/thor/tasks/package.rb', line 7

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

Instance Attribute Details

#optsObject

Returns the value of attribute opts.



5
6
7
# File 'lib/thor/lib/thor/tasks/package.rb', line 5

def opts
  @opts
end

#specObject

Returns the value of attribute spec.



4
5
6
# File 'lib/thor/lib/thor/tasks/package.rb', line 4

def spec
  @spec
end

Instance Method Details

#runObject



13
14
15
16
17
# File 'lib/thor/lib/thor/tasks/package.rb', line 13

def run
  FileUtils.mkdir_p(@opts[:dir])
  Gem::Builder.new(spec).build
  FileUtils.mv(spec.file_name, File.join(@opts[:dir], spec.file_name))
end