Class: GemSavvy

Inherits:
Object
  • Object
show all
Defined in:
lib/nod/gem_savvy.rb

Overview

Instance Method Summary collapse

Instance Method Details

#gem_home(gem_name) ⇒ Object



24
25
26
27
# File 'lib/nod/gem_savvy.rb', line 24

def gem_home(gem_name)
  info = info_for gem_name
  info['homepage_uri']
end

#gem_source_home(gem_name) ⇒ Object



29
30
31
32
# File 'lib/nod/gem_savvy.rb', line 29

def gem_source_home(gem_name)
  info = info_for gem_name
  info['source_code_uri']
end

#get_sub_string(http_url, to_replace) ⇒ Object



54
55
56
57
58
59
# File 'lib/nod/gem_savvy.rb', line 54

def get_sub_string(http_url, to_replace)
  if http_url.end_with?('/')
    http_url = http_url[0..-2]
  end
  "#{http_url.gsub(to_replace, 'git://')}.git"
end

#git_clone_url(gem_name) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/nod/gem_savvy.rb', line 34

def git_clone_url(gem_name)
  http_url = gem_home gem_name
  if !http_url.nil? && http_url.include?('http://github.com') 
    get_sub_string(http_url, 'http://')
  elsif !http_url.nil? && http_url.include?('https://github.com')
    get_sub_string(http_url, 'https://')
  else
    http_url = gem_source_home gem_name
    if !http_url.nil? && http_url.include?('http://github.com')
      get_sub_string(http_url, 'http://')
    elsif !http_url.nil? && http_url.include?('http://www.github.com')
      get_sub_string(http_url, 'http://www.')
    elsif !http_url.nil? && http_url.include?('https://github.com')
      get_sub_string(http_url, 'https://')
    else
      nil
    end
  end
end

#info_for(gem_name) ⇒ Object

def initialize(gemfile_path)

@lockfile = Bundler::LockfileParser.new(Bundler.read_file(gemfile_path))

end

def names

names = []
@lockfile.specs.each do |s|
  names << s.name
end
names

end



20
21
22
# File 'lib/nod/gem_savvy.rb', line 20

def info_for(gem_name)
  Gems.info gem_name
end