aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/vendor/thor-0.11.1/lib/thor/tasks/install.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/vendor/thor-0.11.1/lib/thor/tasks/install.rb')
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/tasks/install.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/tasks/install.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/tasks/install.rb
new file mode 100644
index 0000000000..6b20ff1634
--- /dev/null
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/tasks/install.rb
@@ -0,0 +1,35 @@
+class Thor
+ # Creates an install task.
+ #
+ # ==== Parameters
+ # spec<Gem::Specification>
+ #
+ # ==== Options
+ # :dir - The directory where the package is hold before installation. Defaults to ./pkg.
+ #
+ def self.install_task(spec, options={})
+ package_task(spec, options)
+ tasks['install'] = Thor::InstallTask.new(spec, options)
+ end
+
+ class InstallTask < Task
+ attr_accessor :spec, :config
+
+ def initialize(gemspec, config={})
+ super(:install, "Install the gem", "install", {})
+ @spec = gemspec
+ @config = { :dir => File.join(Dir.pwd, "pkg") }.merge(config)
+ end
+
+ 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
+ end
+end