Class: LicenseFinder::Core

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/license_finder/core.rb

Overview

Coordinates setup

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Core

Default options:

project_path: Pathname.pwd
logger: nil,   # can be :quiet or :debug
decisions_file: "doc/dependency_decisions.yml",
gradle_command: "gradle",
rebar_command: "rebar",
rebar_deps_dir: "deps",



33
34
35
36
37
# File 'lib/license_finder/core.rb', line 33

def initialize(configuration)
  @logger = Logger.new(configuration.logger_mode)
  @config = configuration
  @scanner = Scanner.new(options)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



18
19
20
# File 'lib/license_finder/core.rb', line 18

def config
  @config
end

Class Method Details

.default_loggerObject



20
21
22
# File 'lib/license_finder/core.rb', line 20

def self.default_logger
  Logger.new
end

Instance Method Details

#decisionsObject



55
56
57
# File 'lib/license_finder/core.rb', line 55

def decisions
  @decisions ||= DecisionsFactory.decisions(config.decisions_file_path)
end

#modifyingObject



39
40
41
42
# File 'lib/license_finder/core.rb', line 39

def modifying
  yield
  decisions.save!(config.decisions_file_path)
end

#prepare_projectsObject



59
60
61
62
63
64
65
66
67
# File 'lib/license_finder/core.rb', line 59

def prepare_projects
  clear_logs
  package_managers = @scanner.active_package_managers
  package_managers.each do |manager|
    logger.debug manager.class, 'Running prepare on project'
    manager.prepare
    logger.debug manager.class, 'Finished prepare on project', color: :green
  end
end

#project_nameObject



47
48
49
# File 'lib/license_finder/core.rb', line 47

def project_name
  decisions.project_name || config.project_path.basename.to_s
end

#project_pathObject



51
52
53
# File 'lib/license_finder/core.rb', line 51

def project_path
  config.project_path
end