Class: Thor::PackageTask
- Defined in:
- lib/thor/lib/thor/tasks/package.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#spec ⇒ Object
Returns the value of attribute spec.
Attributes inherited from Task
#description, #klass, #meth, #usage
Instance Method Summary collapse
-
#initialize(gemspec, opts = {}) ⇒ PackageTask
constructor
A new instance of PackageTask.
- #run ⇒ Object
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
#opts ⇒ Object
Returns the value of attribute opts.
5 6 7 |
# File 'lib/thor/lib/thor/tasks/package.rb', line 5 def opts @opts end |
#spec ⇒ Object
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
#run ⇒ Object
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 |