Class: Gems::V2::Client

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/gems/v2/client.rb

Instance Method Summary collapse

Methods included from Request

#delete, #get, #post, #put

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
17
# File 'lib/gems/v2/client.rb', line 12

def initialize(options = {})
  options = Gems.options.merge(options)
  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end

Instance Method Details

#info(gem_name, version) ⇒ Hash

Returns information about the given gem for a sepcific version

Examples:

Gems::V2.info 'rails', '7.0.6'

Parameters:

  • gem_name (String)

    The name of a gem.

  • version (String)

    The requested version of the gem.

Returns:

  • (Hash)

Requires Authentication:

  • false



27
28
29
30
31
32
# File 'lib/gems/v2/client.rb', line 27

def info(gem_name, version)
  response = get("/api/v2/rubygems/#{gem_name}/versions/#{version}.json")
  JSON.parse(response)
rescue JSON::ParserError
  {}
end