Class: Gem::Commands::FromGitCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::FromGitCommand
- Defined in:
- lib/rubygems/commands/from_git_command.rb
Instance Method Summary collapse
- #arguments ⇒ Object
- #description ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ FromGitCommand
constructor
A new instance of FromGitCommand.
- #usage ⇒ Object
Constructor Details
#initialize ⇒ FromGitCommand
Returns a new instance of FromGitCommand.
9 10 11 12 13 14 15 16 |
# File 'lib/rubygems/commands/from_git_command.rb', line 9 def initialize super 'from_git', description add_option('-b', '--branch LOCATION', arguments) do |branch| [:branch] = branch end end |
Instance Method Details
#arguments ⇒ Object
18 19 20 21 |
# File 'lib/rubygems/commands/from_git_command.rb', line 18 def arguments "PATH https://github.com/user/repo.git" "BRANCH Git branch to use" end |
#description ⇒ Object
5 6 7 |
# File 'lib/rubygems/commands/from_git_command.rb', line 5 def description "Allows you to install gem from git repository" end |
#execute ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubygems/commands/from_git_command.rb', line 27 def execute require 'fileutils' require 'tempfile' require 'colored' destination = Dir.mktmpdir begin error "No repository specified" unless [:args].length > 0 run "git clone #{options[:args][0]} #{destination}", "Error cloning repository" Dir.chdir destination do if [:branch] run "git checkout #{options[:branch]}", "Error checkouting branch" end run "gem build *.gemspec", "Error building gem" run "gem install *.gem", "Error installing gem" end puts "Done".green exit 0 ensure FileUtils.rm_rf destination end end |
#usage ⇒ Object
23 24 25 |
# File 'lib/rubygems/commands/from_git_command.rb', line 23 def usage "#{program_name} [LOCATION] -b [BRANCH]" end |