Module: Lowendinsight::GemspecDependencies

Defined in:
lib/lowendinsight/gemspec_dependencies.rb

Class Method Summary collapse

Class Method Details

.get_all_dependencies_from_file(file) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/lowendinsight/gemspec_dependencies.rb', line 43

def self.get_all_dependencies_from_file(file)
  d = []
  top_level = get_dependencies_from_file(file)
  if top_level[0]["message"]
    d = top_level
  else
    top_level.each do |dep|
      version = dep["specified"].split(" ")[1].strip
      deps = Lowendinsight::GemfileDependencies.get_dependencies_from_rubygems(dep["name"], version)
      d << {"name" => dep["name"], "specified" => version,
        "available" => Lowendinsight::GemfileDependencies.get_latest_version_from_rubygems(dep["name"]),
        "dependencies" => deps}
    end
  end
  return d
end

.get_dependencies_from_file(file) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/lowendinsight/gemspec_dependencies.rb', line 60

def self.get_dependencies_from_file(file)
  gf = Gemnasium::Parser.gemspec file
  d = []
  if gf.dependencies.empty?
    d << {"message"=>"no dependencies defined in gemspec"}
  else
    gf.dependencies.each do |dep|
      d << {"name" => dep.name, "specified" => dep.requirement.to_s}
    end
  end
  return d
end

.get_dependencies_from_repo(url) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/lowendinsight/gemspec_dependencies.rb', line 27

def self.get_dependencies_from_repo(url)
  @url = url
  paths = URI(@url).path.split("/")
  @name = paths[(paths.size)-1]
  g = Git.clone(@url, @name, :path => '/tmp/checkout')
  gf = Gemnasium::Parser.gemspec Bundler.read_file("/tmp/checkout/#{@name}/#{@name}.gemspec")
  d = []
  gf.dependencies.each do |dep|
    d << {"name" => dep.name, "specified" => dep.requirement.to_s}
  end

  FileUtils.rm_rf("/tmp/checkout/#{@name}")

  return d
end