Class: Spandx::Java::Index

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/spandx/java/index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/spandx/java/index.rb', line 10

def name
  @name
end

#sourceObject (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

#eachObject



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