Class: Avm::EacRubyBase1::Rubygems::Providers::RubygemsOrg

Inherits:
Base
  • Object
show all
Defined in:
lib/avm/eac_ruby_base1/rubygems/providers/rubygems_org.rb

Constant Summary collapse

DEFAULT_ROOT_HTTP_URL =
'https://rubygems.org'.to_uri

Instance Method Summary collapse

Methods inherited from Base

#push_gem, #to_s

Constructor Details

#initialize(root_http_url = DEFAULT_ROOT_HTTP_URL) ⇒ RubygemsOrg

Returns a new instance of RubygemsOrg.

Parameters:

  • root_http_url (Pathname) (defaults to: DEFAULT_ROOT_HTTP_URL)


14
15
16
# File 'lib/avm/eac_ruby_base1/rubygems/providers/rubygems_org.rb', line 14

def initialize(root_http_url = DEFAULT_ROOT_HTTP_URL)
  super
end

Instance Method Details

#gem_versions(gem_name) ⇒ Enumerable<Hash>

Returns:

  • (Enumerable<Hash>)


19
20
21
22
23
24
25
# File 'lib/avm/eac_ruby_base1/rubygems/providers/rubygems_org.rb', line 19

def gem_versions(gem_name)
  ::EacEnvs::Http::Request.new
    .url(root_http_url + "/api/v1/versions/#{gem_name}.json")
    .response.body_data_or_raise
rescue EacEnvs::Http::Response => e
  e.status == 404 ? [] : raise(e)
end

#push_gem_command_args(gem_package_path) ⇒ Enumerable<String>

Parameters:

  • gem_package_path (Pathname)

Returns:

  • (Enumerable<String>)


29
30
31
32
33
34
35
# File 'lib/avm/eac_ruby_base1/rubygems/providers/rubygems_org.rb', line 29

def push_gem_command_args(gem_package_path)
  command = ['gem', 'push', gem_package_path]
  unless ::Avm::Launcher::Context.current.publish_options[:confirm]
    command = %w[echo] + command + %w[(Dry-run)]
  end
  command
end