Class: LicenseScout::DependencyManager::Bundler

Inherits:
Base
  • Object
show all
Defined in:
lib/license_scout/dependency_manager/bundler.rb

Instance Attribute Summary

Attributes inherited from Base

#directory

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LicenseScout::DependencyManager::Base

Instance Method Details

#dependenciesObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/license_scout/dependency_manager/bundler.rb', line 50

def dependencies
  dependency_data.map do |gem_data|
    dep_name = gem_data["name"]
    dep_version = gem_data["version"]
    dep_license = gem_data["license"]

    dep_path = if dep_name == "bundler"
                 # Bundler is weird. It inserts itself as a dependency, but is a
                 # special case, so rubygems cannot correctly report the license.
                 # Additionally, rubygems reports the gem path as a path inside
                 # bundler's lib/ dir, so we have to munge it.
                 "https://github.com/bundler/bundler"
               elsif dep_name == "json"
                 # json is different weird. When project is using the json that is prepackaged with
                 # Ruby, its included not as a full fledged gem but an *.rb file at:
                 # /opt/opscode/embedded/lib/ruby/2.2.0/json.rb
                 # Because of this its license is reported as nil and its license files can not be
                 # found. That is why we need to provide them manually here.
                 "https://github.com/flori/json"
               else
                 gem_data["path"]
               end

    dependency = new_dependency(dep_name, dep_version, dep_path)

    # If the gemspec has defined a license, include that as well.
    unless dep_license.nil?
      dependency.add_license(dep_license, "https://rubygems.org/gems/#{dep_name}/versions/#{dep_version}")
    end

    dependency
  end.compact
end

#detected?Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
# File 'lib/license_scout/dependency_manager/bundler.rb', line 40

def detected?
  # We check the existence of both Gemfile and Gemfile.lock. We need both
  # of them to be able to get a concrete set of dependencies which we can
  # search. We used to raise an error when Gemfile.lock did not exist but
  # that created issues with projects like oc_bifrost which is a rebar
  # project but have a Gemfile at its root to be able to run some rake
  # commands.
  File.exist?(gemfile_path) && File.exist?(lockfile_path)
end

#install_commandObject



36
37
38
# File 'lib/license_scout/dependency_manager/bundler.rb', line 36

def install_command
  "bundle install"
end

#nameObject



24
25
26
# File 'lib/license_scout/dependency_manager/bundler.rb', line 24

def name
  "ruby_bundler"
end

#signatureObject



32
33
34
# File 'lib/license_scout/dependency_manager/bundler.rb', line 32

def signature
  "Gemfile and Gemfile.lock files"
end

#typeObject



28
29
30
# File 'lib/license_scout/dependency_manager/bundler.rb', line 28

def type
  "ruby"
end