Class: R10K::ModuleRepository::Forge
- Inherits:
-
Object
- Object
- R10K::ModuleRepository::Forge
- Defined in:
- lib/r10k/module_repository/forge.rb
Instance Attribute Summary collapse
- #:conn(: conn) ⇒ Faraday readonly private
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#forge ⇒ Object
readonly
Returns the value of attribute forge.
Instance Method Summary collapse
-
#initialize(forge = 'forge.puppetlabs.com') ⇒ Forge
constructor
A new instance of Forge.
-
#latest_version(module_name) ⇒ String
Query for the newest published version of a module.
-
#versions(module_name) ⇒ Array<String>
Query for all published versions of a module.
Constructor Details
#initialize(forge = 'forge.puppetlabs.com') ⇒ Forge
Returns a new instance of Forge.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/r10k/module_repository/forge.rb', line 19 def initialize(forge = 'forge.puppetlabs.com') @forge = forge @conn = Faraday.new( :url => "https://#{@forge}", :user_agent => "Ruby/r10k #{R10K::VERSION}" ) do |builder| builder.request :multi_json builder.response :multi_json # This needs to be _after_ request/response configuration for testing # purposes. This comment is the result of much consternation. builder.adapter Faraday.default_adapter end end |
Instance Attribute Details
#:conn(: conn) ⇒ Faraday (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 |
# File 'lib/r10k/module_repository/forge.rb', line 17 attr_reader :conn |
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
17 18 19 |
# File 'lib/r10k/module_repository/forge.rb', line 17 def conn @conn end |
#forge ⇒ Object (readonly)
Returns the value of attribute forge.
12 13 14 |
# File 'lib/r10k/module_repository/forge.rb', line 12 def forge @forge end |
Instance Method Details
#latest_version(module_name) ⇒ String
Query for the newest published version of a module
61 62 63 |
# File 'lib/r10k/module_repository/forge.rb', line 61 def latest_version(module_name) versions(module_name).last end |
#versions(module_name) ⇒ Array<String>
Query for all published versions of a module
44 45 46 47 48 49 50 |
# File 'lib/r10k/module_repository/forge.rb', line 44 def versions(module_name) response = @conn.get("/api/v1/releases.json", {'module' => module_name}) response.body[module_name].map do |version_info| version_info['version'] end end |