Class: Thor::PackageTask
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#spec ⇒ Object
Returns the value of attribute spec.
Attributes inherited from Task
#description, #name, #options, #usage
Instance Method Summary collapse
-
#initialize(gemspec, config = {}) ⇒ PackageTask
constructor
A new instance of PackageTask.
- #run(instance, args = []) ⇒ Object
Methods inherited from Task
dynamic, #formatted_arguments, #formatted_options, #formatted_usage, #initialize_copy, #short_description
Constructor Details
#initialize(gemspec, config = {}) ⇒ PackageTask
Returns a new instance of PackageTask.
19 20 21 22 23 |
# File 'lib/thor/tasks/package.rb', line 19 def initialize(gemspec, config={}) super(:package, "Build a gem package", "package", {}) @spec = gemspec @config = {:dir => File.join(Dir.pwd, "pkg")}.merge(config) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
17 18 19 |
# File 'lib/thor/tasks/package.rb', line 17 def config @config end |
#spec ⇒ Object
Returns the value of attribute spec.
17 18 19 |
# File 'lib/thor/tasks/package.rb', line 17 def spec @spec end |
Instance Method Details
#run(instance, args = []) ⇒ Object
25 26 27 28 29 |
# File 'lib/thor/tasks/package.rb', line 25 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 |