gemjar 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +118 -0
- data/Rakefile +1 -0
- data/bin/gemjar +4 -0
- data/gemjar.gemspec +26 -0
- data/lib/gemjar.rb +19 -0
- data/lib/gemjar/cli.rb +133 -0
- data/lib/gemjar/client.rb +12 -0
- data/lib/gemjar/resource.rb +7 -0
- data/lib/gemjar/resource/base.rb +29 -0
- data/lib/gemjar/resource/rubygem.rb +3 -0
- data/lib/gemjar/resource/user.rb +3 -0
- data/lib/gemjar/version.rb +4 -0
- metadata +158 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 George Drummond
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# Gemjar HQ
|
2
|
+
|
3
|
+
***[GemJar HQ](https://gemjarhq.com)*** is a private RubyGem hosting service that is compatible with all hosting platforms, including ***Heroku***!
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install gemjar
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Running ```gemjar help``` will give you a list of the available commands:
|
14
|
+
|
15
|
+
```
|
16
|
+
Tasks:
|
17
|
+
gemjar help [TASK] # Describe available tasks or one specific task
|
18
|
+
gemjar list # List rubygems in my GemJar
|
19
|
+
gemjar login # Sign into your GemJar account
|
20
|
+
gemjar logout # Sign out of your GemJar account
|
21
|
+
gemjar push # Push a new gem to GemJar
|
22
|
+
gemjar user:add # Add a new collaborator
|
23
|
+
gemjar user:list # List collaborators
|
24
|
+
gemjar user:remove # Remove a collaborator
|
25
|
+
gemjar version # Output GemJar version number
|
26
|
+
```
|
27
|
+
|
28
|
+
## API Usage
|
29
|
+
|
30
|
+
With the GemJar gem you can also interact directly with the API. For this you will probably want to add GemJar to your gem file.
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
gem 'gemjar'
|
34
|
+
```
|
35
|
+
|
36
|
+
Now configure GemJar with your **api_token** which you can find on the overview page.
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
GemJar.configure do |config|
|
40
|
+
config.api_token = 'api_token'
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
Then you can create a new ```GemJar::Client``` object.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
client = GemJar::Client.new
|
48
|
+
```
|
49
|
+
|
50
|
+
### Users
|
51
|
+
|
52
|
+
Add a collaborator to your account:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
client.users.create(:email => 'user@example.com')
|
56
|
+
```
|
57
|
+
List collaborators linked to your account:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
client.users.all
|
61
|
+
# returns:
|
62
|
+
# [
|
63
|
+
# {:email => 'user@example.com', :id => '50f08648cf60c9300e000001'},
|
64
|
+
# {:email => 'collaborator@example.com', :id => '50f5c1afcf60c95013000004'}
|
65
|
+
# ]
|
66
|
+
```
|
67
|
+
|
68
|
+
Remove a collaborator from your account:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
client.users.destroy('50f5c1afcf60c95013000004')
|
72
|
+
```
|
73
|
+
|
74
|
+
### Rubygems
|
75
|
+
|
76
|
+
List all Rubygems
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
client.rubygems.all
|
80
|
+
```
|
81
|
+
|
82
|
+
Upload a Rubygem to your GemJar
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
file = File.new(PATH_TO_GEM), 'rb')
|
86
|
+
client.rubygems.create(:file => file)
|
87
|
+
```
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
|
91
|
+
Feel free to hack away and send me a pull request!
|
92
|
+
|
93
|
+
## License
|
94
|
+
|
95
|
+
```
|
96
|
+
Copyright (c) 2013 George Drummond
|
97
|
+
|
98
|
+
MIT License
|
99
|
+
|
100
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
101
|
+
a copy of this software and associated documentation files (the
|
102
|
+
"Software"), to deal in the Software without restriction, including
|
103
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
104
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
105
|
+
permit persons to whom the Software is furnished to do so, subject to
|
106
|
+
the following conditions:
|
107
|
+
|
108
|
+
The above copyright notice and this permission notice shall be
|
109
|
+
included in all copies or substantial portions of the Software.
|
110
|
+
|
111
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
112
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
113
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
114
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
115
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
116
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
117
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
118
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/gemjar
ADDED
data/gemjar.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gemjar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "gemjar"
|
8
|
+
gem.version = GemJar::GEM_VERSION
|
9
|
+
gem.authors = ["George Drummond"]
|
10
|
+
gem.email = ["georgedrummond@gmail.com"]
|
11
|
+
gem.description = %q{Official GemJar HQ RubyGem.}
|
12
|
+
gem.summary = %q{Official GemJar HQ RubyGem.}
|
13
|
+
gem.homepage = "https://gemjarhq.com"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'rest-client', '1.6.7'
|
21
|
+
gem.add_dependency 'json', '1.7.6'
|
22
|
+
gem.add_dependency 'thor', '0.16.0'
|
23
|
+
gem.add_dependency 'smart_colored', '1.1.1'
|
24
|
+
gem.add_dependency 'launchy', '2.1.2'
|
25
|
+
gem.add_dependency 'highline', '1.6.15'
|
26
|
+
end
|
data/lib/gemjar.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'gemjar/version'
|
2
|
+
|
3
|
+
module GemJar
|
4
|
+
autoload :Cli, 'gemjar/cli'
|
5
|
+
autoload :Client, 'gemjar/client'
|
6
|
+
autoload :Resource, 'gemjar/resource'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :api_key
|
10
|
+
|
11
|
+
def endpoint
|
12
|
+
'https://gemjarhq.com/api/v1'
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure(&block)
|
16
|
+
yield GemJar
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/gemjar/cli.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'rest_client'
|
3
|
+
require 'smart_colored/extend'
|
4
|
+
require 'launchy'
|
5
|
+
require 'highline'
|
6
|
+
|
7
|
+
module GemJar
|
8
|
+
class Cli < Thor
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
desc 'user:add', 'Add a new collaborator'.cyan
|
12
|
+
map 'user:add' => 'user_add'
|
13
|
+
def user_add(email)
|
14
|
+
with_rescue do
|
15
|
+
client.users.create :email => email
|
16
|
+
puts "#{email} was added as a collaborator".green
|
17
|
+
end
|
18
|
+
rescue RestClient::Conflict
|
19
|
+
puts "#{email} is already associated with an account".red
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'user:list', 'List collaborators'.cyan
|
23
|
+
map 'user:list' => 'user_list'
|
24
|
+
def user_list
|
25
|
+
with_rescue do
|
26
|
+
puts '=== Users'
|
27
|
+
users = client.users.all.sort { |a, b| a['email'] <=> b['email'] }
|
28
|
+
users.each { |u| puts u['email'] }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'user:remove', 'Remove a collaborator'.cyan
|
33
|
+
map 'user:remove' => 'user_remove'
|
34
|
+
def user_remove(email)
|
35
|
+
with_rescue do
|
36
|
+
user = client.users.all.select { |u| u['email'] == email }.first
|
37
|
+
if user
|
38
|
+
client.users.destroy user['id']
|
39
|
+
puts "#{email} has been removed as a collaborator".green
|
40
|
+
else
|
41
|
+
puts "#{email} does not exist as a collaborator".red
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'auth:login', 'Sign into your GemJar account'.cyan
|
47
|
+
map 'auth:login' => 'auth_login'
|
48
|
+
def auth_login
|
49
|
+
authenticate_session
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'auth:logout', 'Sign out of your GemJar account'.cyan
|
53
|
+
map 'auth:logout' => 'auth_logout'
|
54
|
+
def auth_logout
|
55
|
+
remove_file config, :verbose => false
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'list', 'List rubygems in my GemJar'.cyan
|
59
|
+
def list
|
60
|
+
with_rescue do
|
61
|
+
puts '=== GemJar'
|
62
|
+
client.rubygems.all.each do |gem|
|
63
|
+
gems = []
|
64
|
+
gem['versions'].each { |version| gems << version['number'] }
|
65
|
+
puts "#{gem['name']} (#{gems.join ', '})"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
desc 'push', 'Push a new gem to GemJar'.cyan
|
71
|
+
def push(rubygem)
|
72
|
+
with_rescue do
|
73
|
+
if File.exists?(rubygem)
|
74
|
+
client.rubygems.create :file => File.new(rubygem, 'rb')
|
75
|
+
puts "#{rubygem} was pushed to GemJar HQ".green
|
76
|
+
else
|
77
|
+
puts 'Rubygem does not exist'.red
|
78
|
+
end
|
79
|
+
end
|
80
|
+
rescue RestClient::Conflict
|
81
|
+
puts 'The gem you tried to upload already exists in your GemJar'.red
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'version', 'Output GemJar version number'.cyan
|
85
|
+
def version
|
86
|
+
puts "Gem: #{GemJar::GEM_VERSION.green}, API: #{GemJar::API_VERSION.green}"
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'signup', 'Sign up for a GemJar HQ account'.cyan
|
90
|
+
def signup
|
91
|
+
Launchy.open 'https://gemjarhq.com/signup'
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def config
|
97
|
+
File.join(Gem.user_home, '.gem', 'gemjar')
|
98
|
+
end
|
99
|
+
|
100
|
+
def with_rescue(&block)
|
101
|
+
block.call
|
102
|
+
rescue RestClient::NotAcceptable => e
|
103
|
+
puts JSON.parse(e.response)['error_message'].red
|
104
|
+
rescue RestClient::Unauthorized
|
105
|
+
auth_logout
|
106
|
+
@highline.say "\n\n-------------------\nLooks like your login session wasnt valid\n\n"
|
107
|
+
authenticate_session
|
108
|
+
end
|
109
|
+
|
110
|
+
def authenticate_session
|
111
|
+
with_rescue do
|
112
|
+
highline = HighLine.new
|
113
|
+
puts "Please log in to continue..\n\n"
|
114
|
+
email = highline.ask("Email Address:")
|
115
|
+
password = highline.ask("Password:") { |q| q.echo = false }
|
116
|
+
api_key = RestClient.post("#{GemJar.endpoint}/authentications",
|
117
|
+
:email => email,
|
118
|
+
:password => password
|
119
|
+
)
|
120
|
+
add_file config, api_key, :verbose => false
|
121
|
+
return api_key
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def client
|
126
|
+
api_key = File.open(config).read rescue authenticate_session
|
127
|
+
GemJar.configure do |config|
|
128
|
+
config.api_key = api_key
|
129
|
+
end
|
130
|
+
@client ||= GemJar::Client.new
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class GemJar::Resource::Base
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def resource(resource)
|
8
|
+
@resource = resource
|
9
|
+
@rest = RestClient::Resource.new(
|
10
|
+
GemJar.endpoint,
|
11
|
+
:user => 'x',
|
12
|
+
:password => GemJar.api_key
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def all
|
17
|
+
JSON.parse @rest[@resource].get(:accept => :json)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(opts)
|
21
|
+
@rest[@resource].post opts.merge(:accept => :json)
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy(id)
|
25
|
+
path = [@resource, id].join('/')
|
26
|
+
@rest[path].delete
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemjar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- George Drummond
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.7
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.7
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.7.6
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.7.6
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: thor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - '='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.16.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.16.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: smart_colored
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.1.1
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.1.1
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: launchy
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.1.2
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.1.2
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: highline
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - '='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.6.15
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - '='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.6.15
|
110
|
+
description: Official GemJar HQ RubyGem.
|
111
|
+
email:
|
112
|
+
- georgedrummond@gmail.com
|
113
|
+
executables:
|
114
|
+
- gemjar
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- bin/gemjar
|
124
|
+
- gemjar.gemspec
|
125
|
+
- lib/gemjar.rb
|
126
|
+
- lib/gemjar/cli.rb
|
127
|
+
- lib/gemjar/client.rb
|
128
|
+
- lib/gemjar/resource.rb
|
129
|
+
- lib/gemjar/resource/base.rb
|
130
|
+
- lib/gemjar/resource/rubygem.rb
|
131
|
+
- lib/gemjar/resource/user.rb
|
132
|
+
- lib/gemjar/version.rb
|
133
|
+
homepage: https://gemjarhq.com
|
134
|
+
licenses: []
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ! '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 1.8.24
|
154
|
+
signing_key:
|
155
|
+
specification_version: 3
|
156
|
+
summary: Official GemJar HQ RubyGem.
|
157
|
+
test_files: []
|
158
|
+
has_rdoc:
|