Class: Thor::InstallTask
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 = {}) ⇒ InstallTask
constructor
A new instance of InstallTask.
- #run(instance, args = []) ⇒ Object
Methods inherited from Task
dynamic, #formatted_arguments, #formatted_options, #formatted_usage, #initialize_copy, #short_description
Constructor Details
#initialize(gemspec, config = {}) ⇒ InstallTask
Returns a new instance of InstallTask.
18 19 20 21 22 |
# File 'lib/thor/tasks/install.rb', line 18 def initialize(gemspec, config={}) super(:install, "Install the gem", "install", {}) @spec = gemspec @config = { :dir => File.join(Dir.pwd, "pkg") }.merge(config) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
16 17 18 |
# File 'lib/thor/tasks/install.rb', line 16 def config @config end |
#spec ⇒ Object
Returns the value of attribute spec.
16 17 18 |
# File 'lib/thor/tasks/install.rb', line 16 def spec @spec end |
Instance Method Details
#run(instance, args = []) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/thor/tasks/install.rb', line 24 def run(instance, args=[]) null, sudo, gem = RUBY_PLATFORM =~ /mswin|mingw/ ? ['NUL', '', 'gem.bat'] : ['/dev/null', 'sudo', 'gem'] old_stderr, $stderr = $stderr.dup, File.open(null, "w") instance.invoke(:package) $stderr = old_stderr system %{#{sudo} #{Gem.ruby} -S #{gem} install #{config[:dir]}/#{spec.name}-#{spec.version} --no-rdoc --no-ri --no-update-sources} end |