Class: LicenseFinder::ErlangmkPackage

Inherits:
Package
  • Object
show all
Defined in:
lib/license_finder/packages/erlangmk_package.rb

Instance Attribute Summary collapse

Attributes inherited from Package

#authors, #children, #description, #groups, #homepage, #install_path, #license_names_from_spec, #logger, #manual_approval, #name, #package_url, #parents, #summary, #version

Instance Method Summary collapse

Methods inherited from Package

#<=>, #activations, #approved?, #approved_manually!, #approved_manually?, #decide_on_license, #eql?, #hash, #license_files, license_names_from_standard_spec, #licenses, #licenses_from_spec, #licensing, #log_activation, #missing?, #notice_files, #permitted!, #permitted?, #restricted!, #restricted?

Constructor Details

#initialize(dep_string_from_query_deps) ⇒ ErlangmkPackage

Returns a new instance of ErlangmkPackage.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/license_finder/packages/erlangmk_package.rb', line 17

def initialize(dep_string_from_query_deps)
  @dep_parent,
  @dep_name,
  @dep_fetch_method,
  @dep_repo_unformatted,
  @dep_version_unformatted,
  @dep_absolute_path = dep_string_from_query_deps.split

  raise_invalid(dep_string_from_query_deps) unless all_parts_valid?

  super(
    dep_name,
    dep_version,
    homepage: dep_repo,
    install_path: dep_absolute_path
  )
end

Instance Attribute Details

#dep_absolute_pathObject (readonly)

Returns the value of attribute dep_absolute_path.



10
11
12
# File 'lib/license_finder/packages/erlangmk_package.rb', line 10

def dep_absolute_path
  @dep_absolute_path
end

#dep_fetch_methodObject (readonly)

Returns the value of attribute dep_fetch_method.



10
11
12
# File 'lib/license_finder/packages/erlangmk_package.rb', line 10

def dep_fetch_method
  @dep_fetch_method
end

#dep_nameObject (readonly)

Returns the value of attribute dep_name.



10
11
12
# File 'lib/license_finder/packages/erlangmk_package.rb', line 10

def dep_name
  @dep_name
end

#dep_parentObject (readonly)

Returns the value of attribute dep_parent.



10
11
12
# File 'lib/license_finder/packages/erlangmk_package.rb', line 10

def dep_parent
  @dep_parent
end

#dep_repo_unformattedObject (readonly)

Returns the value of attribute dep_repo_unformatted.



10
11
12
# File 'lib/license_finder/packages/erlangmk_package.rb', line 10

def dep_repo_unformatted
  @dep_repo_unformatted
end

#dep_version_unformattedObject (readonly)

Returns the value of attribute dep_version_unformatted.



10
11
12
# File 'lib/license_finder/packages/erlangmk_package.rb', line 10

def dep_version_unformatted
  @dep_version_unformatted
end

Instance Method Details

#all_parts_valid?Boolean

Returns:

  • (Boolean)


55
56
57
58
59
60
61
62
# File 'lib/license_finder/packages/erlangmk_package.rb', line 55

def all_parts_valid?
  dep_part_valid?(dep_parent) &&
    dep_part_valid?(dep_name) &&
    set?(dep_fetch_method) &&
    dep_repo_valid? &&
    dep_version_valid? &&
    set?(dep_absolute_path)
end

#dep_repoObject



43
44
45
46
47
# File 'lib/license_finder/packages/erlangmk_package.rb', line 43

def dep_repo
  @dep_repo ||= dep_repo_unformatted
                .chomp('.git')
                .sub('[email protected]:', 'https://github.com/')
end

#dep_versionObject



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

def dep_version
  @dep_version ||= dep_version_unformatted.sub(version_prefix_re, '')
end

#package_managerObject



35
36
37
# File 'lib/license_finder/packages/erlangmk_package.rb', line 35

def package_manager
  'Erlangmk'
end

#raise_invalid(dep_string) ⇒ Object



49
50
51
52
53
# File 'lib/license_finder/packages/erlangmk_package.rb', line 49

def raise_invalid(dep_string)
  invalid_dep_message = "'#{dep_string}' does not look like a valid Erlank.mk dependency"
  valid_dep_example = "A valid dependency example: 'lager: goldrush git https://github.com/DeadZen/goldrush.git 0.1.9 /absolute/path/to/dep'"
  raise(InvalidErlangmkPackageError, "#{invalid_dep_message}. #{valid_dep_example}")
end