Class: GemJar::Cli
- Inherits:
-
Thor
- Object
- Thor
- GemJar::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/gemjar/cli.rb
Instance Method Summary collapse
- #auth_login ⇒ Object
- #auth_logout ⇒ Object
- #list ⇒ Object
- #push(rubygem) ⇒ Object
- #signup ⇒ Object
- #user_add(email) ⇒ Object
- #user_list ⇒ Object
- #user_remove(email) ⇒ Object
- #version ⇒ Object
Instance Method Details
#auth_login ⇒ Object
48 49 50 |
# File 'lib/gemjar/cli.rb', line 48 def auth_login authenticate_session end |
#auth_logout ⇒ Object
54 55 56 |
# File 'lib/gemjar/cli.rb', line 54 def auth_logout remove_file config, :verbose => false end |
#list ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gemjar/cli.rb', line 59 def list with_rescue do puts '=== GemJar' client.rubygems.all.each do |gem| gems = [] gem['versions'].each { |version| gems << version['number'] } puts "#{gem['name']} (#{gems.join ', '})" end end end |
#push(rubygem) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gemjar/cli.rb', line 71 def push(rubygem) with_rescue do if File.exists?(rubygem) client.rubygems.create :file => File.new(rubygem, 'rb') puts "#{rubygem} was pushed to GemJar HQ".green else puts 'Rubygem does not exist'.red end end rescue RestClient::Conflict puts 'The gem you tried to upload already exists in your GemJar'.red end |
#signup ⇒ Object
90 91 92 |
# File 'lib/gemjar/cli.rb', line 90 def signup Launchy.open 'https://gemjarhq.com/signup' end |
#user_add(email) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/gemjar/cli.rb', line 13 def user_add(email) with_rescue do client.users.create :email => email puts "#{email} was added as a collaborator".green end rescue RestClient::Conflict puts "#{email} is already associated with an account".red end |
#user_list ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/gemjar/cli.rb', line 24 def user_list with_rescue do puts '=== Users' users = client.users.all.sort { |a, b| a['email'] <=> b['email'] } users.each { |u| puts u['email'] } end end |
#user_remove(email) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gemjar/cli.rb', line 34 def user_remove(email) with_rescue do user = client.users.all.select { |u| u['email'] == email }.first if user client.users.destroy user['id'] puts "#{email} has been removed as a collaborator".green else puts "#{email} does not exist as a collaborator".red end end end |
#version ⇒ Object
85 86 87 |
# File 'lib/gemjar/cli.rb', line 85 def version puts "Gem: #{GemJar::GEM_VERSION.green}, API: #{GemJar::API_VERSION.green}" end |