class Rabbit::GemPusher
Public Class Methods
new(gem_path, user)
click to toggle source
# File lib/rabbit/gem-pusher.rb, line 29 def initialize(gem_path, user) @gem_path = gem_path @user = user end
Public Instance Methods
push()
click to toggle source
# File lib/rabbit/gem-pusher.rb, line 34 def push credentials_path = File.expand_path("~/.gem/credentials") credentials_path_exist = File.exist?(credentials_path) if credentials_path_exist credentials = YAML.load(File.read(credentials_path)) else credentials = {} end unless credentials.key?(@user.to_sym) credentials[@user.to_sym] = retrieve_api_key File.open(credentials_path, "w") do |credentials_file| credentials_file.print(credentials.to_yaml) end unless credentials_path_exist File.chmod(0600, credentials_path) end end ruby("-S", "gem", "push", @gem_path, "--key", @user) end
Private Instance Methods
retrieve_api_key()
click to toggle source
# File lib/rabbit/gem-pusher.rb, line 56 def retrieve_api_key prompt = _("Enter password on RubyGems.org [%{user}]: ") % {:user => @user} reader = PasswordReader.new(prompt) password = reader.read open("https://rubygems.org/api/v1/api_key.yaml", :http_basic_authentication => [@user, password]) do |response| YAML.load(response.read)[:rubygems_api_key] end end