Class: LicenseFinder::Mix
Class Method Summary
collapse
Instance Method Summary
collapse
#active?, #command_exists?, #current_packages_with_relations, #detected_package_path, id, #prepare, #project_root?, takes_priority_over
Constructor Details
#initialize(options = {}) ⇒ Mix
Returns a new instance of Mix.
5
6
7
8
9
10
|
# File 'lib/license_finder/package_managers/mix.rb', line 5
def initialize(options = {})
super
@command = options[:mix_command] || package_management_command
@elixir_command = options[:elixir_command] || 'elixir'
@deps_path = Pathname(options[:mix_deps_dir] || 'deps')
end
|
Class Method Details
.package_lock_file ⇒ Object
33
34
35
|
# File 'lib/license_finder/package_managers/mix.rb', line 33
def self.package_lock_file
'mix.lock'
end
|
Instance Method Details
#current_packages ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/license_finder/package_managers/mix.rb', line 12
def current_packages
mix_output.map do |name, version|
MixPackage.new(
name,
version,
install_path: @deps_path.join(name),
logger: logger,
spec_licenses: licenses(name)
)
end
end
|
#installed?(logger = Core.default_logger) ⇒ Boolean
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/license_finder/package_managers/mix.rb', line 45
def installed?(logger = Core.default_logger)
if package_management_command.nil?
logger.debug self.class, 'no command defined'
true
elsif command_exists?('elixir') && command_exists?('mix')
logger.debug self.class, 'is installed', color: :green
true
else
logger.info self.class, '(elixir) is not installed', color: :red
false
end
end
|
#licenses(name) ⇒ Object
24
25
26
27
|
# File 'lib/license_finder/package_managers/mix.rb', line 24
def licenses(name)
licenses_by_package = load_all_licenses
licenses_by_package.fetch(name, ['license is not in deps'])
end
|
#package_management_command ⇒ Object
29
30
31
|
# File 'lib/license_finder/package_managers/mix.rb', line 29
def package_management_command
'mix'
end
|
#possible_package_paths ⇒ Object
41
42
43
|
# File 'lib/license_finder/package_managers/mix.rb', line 41
def possible_package_paths
[project_path.join('mix.exs')]
end
|
#prepare_command ⇒ Object
37
38
39
|
# File 'lib/license_finder/package_managers/mix.rb', line 37
def prepare_command
'mix deps.get'
end
|