Class: GemEnforcer::Retrieve::GemServer
- Inherits:
-
Object
- Object
- GemEnforcer::Retrieve::GemServer
- Defined in:
- lib/gem_enforcer/retrieve/gem_server.rb
Instance Method Summary collapse
- #gem_versions(name:) ⇒ Object
-
#initialize(source: DEFAULT_SOURCE) ⇒ GemServer
constructor
A new instance of GemServer.
-
#raw_server_versions ⇒ Object
expensive call ..
Constructor Details
#initialize(source: DEFAULT_SOURCE) ⇒ GemServer
Returns a new instance of GemServer.
8 9 10 |
# File 'lib/gem_enforcer/retrieve/gem_server.rb', line 8 def initialize(source: DEFAULT_SOURCE) @source = source end |
Instance Method Details
#gem_versions(name:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gem_enforcer/retrieve/gem_server.rb', line 12 def gem_versions(name:) raw_gem_versions = raw_server_versions.select { _1.match?(/^#{name} /) } return [] if raw_gem_versions.nil? || raw_gem_versions.empty? versions = raw_gem_versions.map do || raw_name, raw_version_list, _sha = .split(" ") next if raw_name != name raw_version_list.split(",").map { Gem::Version.new(_1) } end.flatten.compact.uniq versions end |
#raw_server_versions ⇒ Object
expensive call .. do this once gem source
27 28 29 30 31 32 |
# File 'lib/gem_enforcer/retrieve/gem_server.rb', line 27 def raw_server_versions @server_versions ||= begin api_call = Faraday.new(url: @source).get("versions") api_call.body.split("\n") end end |