class Licensed::Sources::Mix
Constants
- LOCKFILE
Public Instance Methods
Source
# File lib/licensed/sources/mix.rb, line 10 def enabled? File.exist?(lockfile_path) end
Returns whether a mix.lock is present
Source
# File lib/licensed/sources/mix.rb, line 14 def enumerate_dependencies find_packages.map do |package| convert_package_to_dependency(package) end end
Private Instance Methods
Source
# File lib/licensed/sources/mix.rb, line 55 def check_dep_path(pkg) path = dep_path(pkg[:name]) if File.directory?(path) return [path, []] else return [path, ["Not installed by `mix deps.get` in deps/"]] end end
Check that the package has been installed in deps/.
pkg - The package information as a Hash
Returns an Array with two members; the path as a String and an Array of any errors.
Source
# File lib/licensed/sources/mix.rb, line 38 def convert_package_to_dependency(pkg) path, errors = check_dep_path(pkg) Dependency.new( name: pkg[:name], version: pkg[:version], path: path, metadata: pkg[:metadata].merge("type" => self.class.type), errors: errors + Array(pkg[:error]) ) end
Converts a raw package representation to a dependency.
name - The name of the package as a String. pkg - The parsed package data as a Hash.
Returns a Dependency
.
Source
# File lib/licensed/sources/mix.rb, line 69 def dep_path(name) config.pwd.join("deps", name) end
Generate the absolute path to the named package.
name - The name of the package dependency as a String.
Returns a Pathname.
Source
# File lib/licensed/sources/mix.rb, line 23 def find_packages LockfileParser.read(lockfile_path) end
Returns the parsed mix.lock information as an Array of Hash objects.
Source
# File lib/licensed/sources/mix.rb, line 28 def lockfile_path config.pwd.join(LOCKFILE) end
Returns the absolute path to the mix.lock as a Pathname.