summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2024-12-31 11:51:58 -0700
committermo khan <mo@mokhan.ca>2024-12-31 14:40:07 -0700
commit78c6a086164aa83ce2e4e57daadfbdb53a31a37f (patch)
tree2718cbb345bb3c8257ccbaf9e1b8e7913699a3a5 /lib
parent80d59246ec0752128548d6c61a2d44ec498771d7 (diff)
feat: Add support for Ruby 3.2+HEADv0.19.0main
Diffstat (limited to 'lib')
-rw-r--r--lib/spandx.rb2
-rw-r--r--lib/spandx/cli/printers/table.rb1
-rw-r--r--lib/spandx/core/gateway.rb6
-rw-r--r--lib/spandx/core/license_plugin.rb1
-rw-r--r--lib/spandx/core/registerable.rb1
-rw-r--r--lib/spandx/dotnet/nuget_gateway.rb6
-rw-r--r--lib/spandx/java/gateway.rb6
-rw-r--r--lib/spandx/js/yarn_lock.rb2
-rw-r--r--lib/spandx/js/yarn_pkg.rb5
-rw-r--r--lib/spandx/php/packagist_gateway.rb6
-rw-r--r--lib/spandx/python/pypi.rb6
-rw-r--r--lib/spandx/ruby/gateway.rb8
-rw-r--r--lib/spandx/ruby/parsers/gemfile_lock.rb2
-rw-r--r--lib/spandx/terraform/parsers/lock_file.rb1
-rw-r--r--lib/spandx/version.rb2
15 files changed, 17 insertions, 38 deletions
diff --git a/lib/spandx.rb b/lib/spandx.rb
index 16ba8dc..4b9b150 100644
--- a/lib/spandx.rb
+++ b/lib/spandx.rb
@@ -47,7 +47,7 @@ module Spandx
@git ||= {
cache: ::Spandx::Core::Git.new(url: 'https://github.com/spandx/cache.git'),
rubygems: ::Spandx::Core::Git.new(url: 'https://github.com/spandx/rubygems-cache.git'),
- spdx: ::Spandx::Core::Git.new(url: 'https://github.com/spdx/license-list-data.git', default_branch: 'master'),
+ spdx: ::Spandx::Core::Git.new(url: 'https://github.com/spdx/license-list-data.git'),
}
end
end
diff --git a/lib/spandx/cli/printers/table.rb b/lib/spandx/cli/printers/table.rb
index 13899e0..0c99a1e 100644
--- a/lib/spandx/cli/printers/table.rb
+++ b/lib/spandx/cli/printers/table.rb
@@ -8,6 +8,7 @@ module Spandx
def initialize(output: $stderr)
@spinner = TTY::Spinner.new('[:spinner] Scanning...', output: output, clear: true, format: :dots)
+ super()
end
def match?(format)
diff --git a/lib/spandx/core/gateway.rb b/lib/spandx/core/gateway.rb
index 68f0ec7..1ec0b17 100644
--- a/lib/spandx/core/gateway.rb
+++ b/lib/spandx/core/gateway.rb
@@ -3,6 +3,12 @@
module Spandx
module Core
class Gateway
+ attr_reader :http
+
+ def initialize(http: Spandx.http)
+ @http = http
+ end
+
def matches?(_dependency)
raise ::Spandx::Error, :matches?
end
diff --git a/lib/spandx/core/license_plugin.rb b/lib/spandx/core/license_plugin.rb
index a6ce742..3fb17ae 100644
--- a/lib/spandx/core/license_plugin.rb
+++ b/lib/spandx/core/license_plugin.rb
@@ -5,6 +5,7 @@ module Spandx
class LicensePlugin < Spandx::Core::Plugin
def initialize(catalogue: Spdx::Catalogue.default)
@guess = Guess.new(catalogue)
+ super()
end
def enhance(dependency)
diff --git a/lib/spandx/core/registerable.rb b/lib/spandx/core/registerable.rb
index 0e25e24..a9e1001 100644
--- a/lib/spandx/core/registerable.rb
+++ b/lib/spandx/core/registerable.rb
@@ -17,6 +17,7 @@ module Spandx
def inherited(subclass)
registry.push(subclass)
+ super
end
def registry
diff --git a/lib/spandx/dotnet/nuget_gateway.rb b/lib/spandx/dotnet/nuget_gateway.rb
index 089d2bb..f22bcb3 100644
--- a/lib/spandx/dotnet/nuget_gateway.rb
+++ b/lib/spandx/dotnet/nuget_gateway.rb
@@ -6,10 +6,6 @@ module Spandx
# https://api.nuget.org/v3-flatcontainer/#{package.name}/index.json
# https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource
class NugetGateway < ::Spandx::Core::Gateway
- def initialize(http: Spandx.http)
- @http = http
- end
-
def licenses_for(dependency)
extract_licenses_from(nuspec_for(dependency.name, dependency.version))
end
@@ -28,8 +24,6 @@ module Spandx
private
- attr_reader :http
-
def each_page(start_page:)
url = 'https://api.nuget.org/v3/catalog0/index.json'
items_from(fetch_json(url))
diff --git a/lib/spandx/java/gateway.rb b/lib/spandx/java/gateway.rb
index 9850bef..8df51ec 100644
--- a/lib/spandx/java/gateway.rb
+++ b/lib/spandx/java/gateway.rb
@@ -5,12 +5,6 @@ module Spandx
class Gateway < ::Spandx::Core::Gateway
DEFAULT_SOURCE = 'https://repo.maven.apache.org/maven2'
- attr_reader :http
-
- def initialize(http: Spandx.http)
- @http = http
- end
-
def matches?(dependency)
dependency.package_manager == :maven
end
diff --git a/lib/spandx/js/yarn_lock.rb b/lib/spandx/js/yarn_lock.rb
index f71fd9d..80d2b57 100644
--- a/lib/spandx/js/yarn_lock.rb
+++ b/lib/spandx/js/yarn_lock.rb
@@ -5,7 +5,7 @@ module Spandx
class YarnLock
include Enumerable
- START_OF_DEPENDENCY_REGEX = %r{^"?(?<name>(@|\w|-|\.|/)+)@}i.freeze
+ START_OF_DEPENDENCY_REGEX = %r{^"?(?<name>(?<item>@|\w|-|\.|/)+)@}i.freeze
INJECT_COLON = /(?<=\w|")\s(?=\w|")/.freeze
attr_reader :file_path
diff --git a/lib/spandx/js/yarn_pkg.rb b/lib/spandx/js/yarn_pkg.rb
index bb479b4..66b5b6b 100644
--- a/lib/spandx/js/yarn_pkg.rb
+++ b/lib/spandx/js/yarn_pkg.rb
@@ -4,11 +4,6 @@ module Spandx
module Js
class YarnPkg < ::Spandx::Core::Gateway
DEFAULT_SOURCE = 'https://registry.yarnpkg.com'
- attr_reader :http
-
- def initialize(http: Spandx.http)
- @http = http
- end
def matches?(dependency)
%i[npm yarn].include?(dependency.package_manager)
diff --git a/lib/spandx/php/packagist_gateway.rb b/lib/spandx/php/packagist_gateway.rb
index 8580072..623eaac 100644
--- a/lib/spandx/php/packagist_gateway.rb
+++ b/lib/spandx/php/packagist_gateway.rb
@@ -3,12 +3,6 @@
module Spandx
module Php
class PackagistGateway < ::Spandx::Core::Gateway
- attr_reader :http
-
- def initialize(http: Spandx.http)
- @http = http
- end
-
def matches?(dependency)
dependency.package_manager == :composer
end
diff --git a/lib/spandx/python/pypi.rb b/lib/spandx/python/pypi.rb
index ef3080a..8871bf9 100644
--- a/lib/spandx/python/pypi.rb
+++ b/lib/spandx/python/pypi.rb
@@ -13,8 +13,8 @@ module Spandx
].freeze
def initialize(http: Spandx.http)
- @http = http
@definitions = {}
+ super
end
def matches?(dependency)
@@ -54,15 +54,13 @@ module Spandx
section = path.scan(/-\d+\..*/)
section = path.scan(/-\d+\.?.*/) if section.empty?
- section[-1][1..-1]
+ section[-1][1..]
rescue StandardError => error
warn([url, error].inspect)
end
private
- attr_reader :http
-
def cleanup(url)
SUBSTITUTIONS.inject(URI.parse(url).path.split('/')[-1]) do |memo, item|
memo.gsub(item, '')
diff --git a/lib/spandx/ruby/gateway.rb b/lib/spandx/ruby/gateway.rb
index 6ab6313..2d9a5cc 100644
--- a/lib/spandx/ruby/gateway.rb
+++ b/lib/spandx/ruby/gateway.rb
@@ -2,12 +2,8 @@
module Spandx
module Ruby
+ # https://guides.rubygems.org/rubygems-org-api-v2/
class Gateway < ::Spandx::Core::Gateway
- # https://guides.rubygems.org/rubygems-org-api-v2/
- def initialize(http: Spandx.http)
- @http = http
- end
-
def each
response = http.get('https://index.rubygems.org/versions')
return unless http.ok?(response)
@@ -31,8 +27,6 @@ module Spandx
private
- attr_reader :http
-
def parse_each_from(io)
_created_at = io.readline
_triple_dash = io.readline
diff --git a/lib/spandx/ruby/parsers/gemfile_lock.rb b/lib/spandx/ruby/parsers/gemfile_lock.rb
index dc8e207..5071402 100644
--- a/lib/spandx/ruby/parsers/gemfile_lock.rb
+++ b/lib/spandx/ruby/parsers/gemfile_lock.rb
@@ -4,7 +4,7 @@ module Spandx
module Ruby
module Parsers
class GemfileLock < ::Spandx::Core::Parser
- STRIP_BUNDLED_WITH = /^BUNDLED WITH$(\r?\n) (?<major>\d+)\.\d+\.\d+/m.freeze
+ STRIP_BUNDLED_WITH = /^BUNDLED WITH$\r?\n \d+\.\d+\.\d+/m.freeze
def match?(pathname)
basename = pathname.basename
diff --git a/lib/spandx/terraform/parsers/lock_file.rb b/lib/spandx/terraform/parsers/lock_file.rb
index 9130d22..8cc23be 100644
--- a/lib/spandx/terraform/parsers/lock_file.rb
+++ b/lib/spandx/terraform/parsers/lock_file.rb
@@ -6,6 +6,7 @@ module Spandx
class LockFile < ::Spandx::Core::Parser
def initialize
@parser = Hcl2::Parser.new
+ super()
end
def match?(pathname)
diff --git a/lib/spandx/version.rb b/lib/spandx/version.rb
index f18de8b..7d5fc75 100644
--- a/lib/spandx/version.rb
+++ b/lib/spandx/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module Spandx
- VERSION = '0.18.3'
+ VERSION = '0.19.0'
end