Module: GemInstallBranch

Defined in:
lib/gem_install_branch.rb,
lib/gem_install_branch/version.rb

Constant Summary collapse

VERSION =
File.read(File.expand_path('../../../VERSION', __FILE__)).strip

Class Method Summary collapse

Class Method Details

.github_repo(gem) ⇒ Object



14
15
16
# File 'lib/gem_install_branch.rb', line 14

def self.github_repo(gem)
  github_uri(gem).match(/github.com[:\/](.*)/)[1].split('/').take(2).join('/')
end

.github_uri(gem) ⇒ Object



18
19
20
21
# File 'lib/gem_install_branch.rb', line 18

def self.github_uri(gem)
   = (gem)
  ['source_code_uri'] || ['homepage_uri']
end

.install(gem, branch) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/gem_install_branch.rb', line 6

def self.install(gem, branch)
  puts gem + " " + branch
  command = "git clone --branch #{branch} https://github.com/#{github_repo(gem)} #{gem}"
  Dir.mktmpdir do |dir|
    system("cd #{dir} ; #{command} ; cd #{gem} ; gem build #{gem}.gemspec ; gem install --local #{gem}-*.gem")
  end
end

.metadata(gem) ⇒ Object



23
24
25
26
# File 'lib/gem_install_branch.rb', line 23

def self.(gem)
  uri = URI("https://rubygems.org/api/v1/gems/#{gem}.json")
  JSON.parse(Net::HTTP.get_response(uri).body)
end