Class: Licensed::Sources::Swift

Inherits:
Source
  • Object
show all
Defined in:
lib/licensed/sources/swift.rb

Instance Attribute Summary

Attributes inherited from Source

#config

Instance Method Summary collapse

Methods inherited from Source

#dependencies, full_type, #ignored?, inherited, #initialize, type, type_and_version

Constructor Details

This class inherits a constructor from Licensed::Sources::Source

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/licensed/sources/swift.rb', line 9

def enabled?
  return unless Licensed::Shell.tool_available?("swift") && swift_package?
  File.exist?(package_resolved_file_path)
end

#enumerate_dependenciesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/licensed/sources/swift.rb', line 14

def enumerate_dependencies
  pins.map { |pin|
    name = pin["package"]
    version = pin.dig("state", "version")
    path = dependency_path_for_url(pin["repositoryURL"])
    error = "Unable to determine project path from #{url}" unless path

    Dependency.new(
      name: name,
      path: path,
      version: version,
      errors: Array(error),
      metadata: {
        "type"      => Swift.type,
        "homepage"  => homepage_for_url(pin["repositoryURL"])
      }
    )
  }
end