Class: LicenseFinder::Bundler

Inherits:
PackageManager show all
Defined in:
lib/license_finder/package_managers/bundler.rb

Instance Method Summary collapse

Methods inherited from PackageManager

#active?, #command_exists?, #current_packages_with_relations, #detected_package_path, id, #installed?, #prepare, #project_root?, takes_priority_over

Constructor Details

#initialize(options = {}) ⇒ Bundler

Returns a new instance of Bundler.



8
9
10
11
12
# File 'lib/license_finder/package_managers/bundler.rb', line 8

def initialize(options = {})
  super
  @ignored_groups = options[:ignored_groups]
  @definition = options[:definition] # dependency injection for tests
end

Instance Method Details

#current_packagesObject



14
15
16
17
18
19
20
21
# File 'lib/license_finder/package_managers/bundler.rb', line 14

def current_packages
  logger.debug self.class, "including groups #{included_groups.inspect}"
  details.map do |gem_detail, bundle_detail|
    BundlerPackage.new(gem_detail, bundle_detail, logger: logger).tap do |package|
      log_package_dependencies package
    end
  end
end

#package_management_commandObject



23
24
25
# File 'lib/license_finder/package_managers/bundler.rb', line 23

def package_management_command
  'bundle'
end

#possible_package_pathsObject



36
37
38
# File 'lib/license_finder/package_managers/bundler.rb', line 36

def possible_package_paths
  [project_path.join(gemfile)]
end

#prepare_commandObject



27
28
29
30
31
32
33
34
# File 'lib/license_finder/package_managers/bundler.rb', line 27

def prepare_command
  ignored_groups_argument = !ignored_groups.empty? ? "--without #{ignored_groups.to_a.join(' ')}" : ''

  gem_path = "lf-bundler-gems-#{SecureRandom.uuid}"
  logger.info self.class, "Running bundle install for #{Dir.pwd} with path #{gem_path}", color: :blue

  "bundle install #{ignored_groups_argument} --path #{gem_path}".strip
end