Class: LicenseFinder::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/license_finder/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(primary_config, saved_config) ⇒ Configuration

Returns a new instance of Configuration.



12
13
14
15
# File 'lib/license_finder/configuration.rb', line 12

def initialize(primary_config, saved_config)
  @primary_config = primary_config
  @saved_config = saved_config
end

Class Method Details

.with_optional_saved_config(primary_config) ⇒ Object



5
6
7
8
9
10
# File 'lib/license_finder/configuration.rb', line 5

def self.with_optional_saved_config(primary_config)
  project_path = Pathname(primary_config.fetch(:project_path, Pathname.pwd)).expand_path
  config_file =  project_path.join('config', 'license_finder.yml')
  saved_config = config_file.exist? ? YAML.load(config_file.read) : {}
  new(primary_config, saved_config)
end

Instance Method Details

#decisions_file_pathObject



56
57
58
59
# File 'lib/license_finder/configuration.rb', line 56

def decisions_file_path
  path = get(:decisions_file) || 'doc/dependency_decisions.yml'
  project_path.join(path).expand_path
end

#go_full_versionObject



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

def go_full_version
  get(:go_full_version)
end

#gradle_commandObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/license_finder/configuration.rb', line 24

def gradle_command
  get(:gradle_command) || (
    if Platform.windows?
      wrapper = 'gradlew.bat'
      gradle = 'gradle.bat'
    else
      wrapper = 'gradlew'
      gradle = 'gradle'
    end

    executable = File.exist?(wrapper) ? wrapper : gradle
    "#{executable} --console plain"
  )
end

#gradle_include_groupsObject



43
44
45
# File 'lib/license_finder/configuration.rb', line 43

def gradle_include_groups
  get(:gradle_include_groups)
end

#project_pathObject



61
62
63
# File 'lib/license_finder/configuration.rb', line 61

def project_path
  Pathname(path_prefix).expand_path
end

#rebar_commandObject



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

def rebar_command
  get(:rebar_command) || 'rebar'
end

#rebar_deps_dirObject



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

def rebar_deps_dir
  path = get(:rebar_deps_dir) || 'deps'
  project_path.join(path).expand_path
end

#valid_project_path?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
# File 'lib/license_finder/configuration.rb', line 17

def valid_project_path?
  if get(:project_path)
    return project_path.exist?
  end
  true
end