Class: Spandx::Java::Index
- Inherits:
-
Object
- Object
- Spandx::Java::Index
- Includes:
- Enumerable
- Defined in:
- lib/spandx/java/index.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(directory:, source: 'https://repo.maven.apache.org/maven2') ⇒ Index
constructor
A new instance of Index.
- #update!(catalogue:, output:) ⇒ Object
Constructor Details
#initialize(directory:, source: 'https://repo.maven.apache.org/maven2') ⇒ Index
Returns a new instance of Index.
12 13 14 15 16 17 |
# File 'lib/spandx/java/index.rb', line 12 def initialize(directory:, source: 'https://repo.maven.apache.org/maven2') @directory = directory @source = source @name = 'maven' @cache = ::Spandx::Core::Cache.new(@name, root: directory) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/spandx/java/index.rb', line 10 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/spandx/java/index.rb', line 10 def source @source end |
Instance Method Details
#each ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/spandx/java/index.rb', line 28 def each each_index_url do |url| each_record_from("#{source}/.index/#{url}") do |record| group_id, artifact_id, version = record['u'].split('|') yield Metadata.new(artifact_id: artifact_id, group_id: group_id, version: version) end end end |
#update!(catalogue:, output:) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/spandx/java/index.rb', line 19 def update!(catalogue:, output:) each do || name = "#{.group_id}:#{.artifact_id}" output.puts [name, .version, .licenses_from(catalogue)].inspect @cache.insert(name, .version, .licenses_from(catalogue)) end @cache.rebuild_index end |