Class: Rabbit::GemPusher
- Inherits:
-
Object
- Object
- Rabbit::GemPusher
- Includes:
- GetText, Rake::DSL
- Defined in:
- lib/rabbit/gem-pusher.rb
Constant Summary
Constants included from GetText
Instance Method Summary collapse
-
#initialize(gem_path, user) ⇒ GemPusher
constructor
A new instance of GemPusher.
- #push ⇒ Object
Methods included from GetText
Constructor Details
#initialize(gem_path, user) ⇒ GemPusher
Returns a new instance of GemPusher.
29 30 31 32 |
# File 'lib/rabbit/gem-pusher.rb', line 29 def initialize(gem_path, user) @gem_path = gem_path @user = user end |
Instance Method Details
#push ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rabbit/gem-pusher.rb', line 34 def push credentials_path = File.("~/.gem/credentials") credentials_path_exist = File.exist?(credentials_path) if credentials_path_exist credentials = YAMLLoader.load(File.read(credentials_path)) else credentials = {} end unless credentials.key?(@user.to_sym) credentials[@user.to_sym] = retrieve_api_key FileUtils.mkdir_p(File.dirname(credentials_path)) 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 |