ruroku 0.0.1 → 0.0.2
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/.travis.yml +5 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +9 -0
- data/README.md +180 -48
- data/Rakefile +7 -1
- data/TODO.md +0 -4
- data/lib/ruroku.rb +9 -1
- data/lib/ruroku/addon.rb +8 -10
- data/lib/ruroku/addon_set.rb +4 -1
- data/lib/ruroku/api.rb +20 -1
- data/lib/ruroku/app.rb +29 -20
- data/lib/ruroku/app_set.rb +13 -0
- data/lib/ruroku/base.rb +20 -3
- data/lib/ruroku/collaborator.rb +5 -2
- data/lib/ruroku/collaborator_set.rb +4 -1
- data/lib/ruroku/config_var.rb +9 -2
- data/lib/ruroku/config_var_set.rb +5 -2
- data/lib/ruroku/domain.rb +8 -9
- data/lib/ruroku/domain_set.rb +4 -1
- data/lib/ruroku/key.rb +8 -0
- data/lib/ruroku/key_set.rb +17 -0
- data/lib/ruroku/nested_base.rb +3 -2
- data/lib/ruroku/nested_resource_set.rb +28 -0
- data/lib/ruroku/process.rb +14 -11
- data/lib/ruroku/process_set.rb +11 -28
- data/lib/ruroku/release.rb +9 -5
- data/lib/ruroku/release_set.rb +4 -1
- data/lib/ruroku/resource_set.rb +61 -6
- data/lib/ruroku/stack.rb +10 -0
- data/lib/ruroku/stack_set.rb +13 -0
- data/lib/ruroku/user.rb +15 -0
- data/lib/ruroku/version.rb +1 -1
- data/ruroku.gemspec +4 -5
- data/spec/helpers/addon.rb +12 -0
- data/spec/helpers/app.rb +18 -0
- data/spec/helpers/collaborator.rb +11 -0
- data/spec/helpers/config_var.rb +11 -0
- data/spec/helpers/domain.rb +13 -0
- data/spec/helpers/keys.rb +12 -0
- data/spec/helpers/process.rb +15 -0
- data/spec/helpers/release.rb +15 -0
- data/spec/helpers/stack.rb +11 -0
- data/spec/helpers/user.rb +15 -0
- data/spec/ruroku/addon_set_spec.rb +29 -0
- data/spec/ruroku/api_spec.rb +55 -0
- data/spec/ruroku/app_set_spec.rb +15 -0
- data/spec/ruroku/app_spec.rb +113 -0
- data/spec/ruroku/collaborator_set_spec.rb +22 -0
- data/spec/ruroku/domain_set_spec.rb +22 -0
- data/spec/ruroku/key_set_spec.rb +29 -0
- data/spec/ruroku/nested_resource_set_spec.rb +27 -0
- data/spec/ruroku/process_set_spec.rb +36 -0
- data/spec/ruroku/release_set_spec.rb +15 -0
- data/spec/ruroku/resource_set_spec.rb +26 -0
- data/spec/ruroku/stack_set_spec.rb +15 -0
- data/spec/spec_helper.rb +72 -0
- metadata +70 -15
data/lib/ruroku/stack.rb
ADDED
data/lib/ruroku/user.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ruroku
|
2
|
+
class User < Base
|
3
|
+
attribute :id, Integer
|
4
|
+
attribute :name, String
|
5
|
+
attribute :email, String
|
6
|
+
attribute :confirmed, Boolean, default: false
|
7
|
+
attribute :verified, Boolean, default: false
|
8
|
+
attribute :confirmed_at, Time
|
9
|
+
attribute :verified_at, Time
|
10
|
+
attribute :last_login, Time
|
11
|
+
attribute :created_at, Time
|
12
|
+
|
13
|
+
resource_id :email
|
14
|
+
end
|
15
|
+
end
|
data/lib/ruroku/version.rb
CHANGED
data/ruroku.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/ruroku/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Gosha Arinich"]
|
6
6
|
gem.email = ["me@goshakkk.name"]
|
7
|
-
gem.description = %q{Ruby client for the Heroku API}
|
8
|
-
gem.summary = %q{Ruby client for the Heroku API}
|
7
|
+
gem.description = %q{The better Ruby client for the Heroku API}
|
8
|
+
gem.summary = %q{The better Ruby client for the Heroku API}
|
9
9
|
gem.homepage = ""
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
@@ -15,8 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Ruroku::VERSION
|
17
17
|
|
18
|
-
gem.add_runtime_dependency 'heroku-api', '~> 0.2
|
18
|
+
gem.add_runtime_dependency 'heroku-api', '~> 0.2'
|
19
19
|
gem.add_runtime_dependency 'activesupport', '~> 3.2.5'
|
20
|
-
|
21
|
-
gem.add_development_dependency 'rspec'
|
20
|
+
gem.add_runtime_dependency 'virtus', '~> 0.5'
|
22
21
|
end
|
data/spec/helpers/app.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Helpers
|
2
|
+
def app_data
|
3
|
+
{
|
4
|
+
id: 1, name: 'test-app', create_status: 'complete', stack: 'cedar',
|
5
|
+
requested_stack: nil, git_url: nil, repo_migrate_status: 'complete',
|
6
|
+
slug_size: 1_000_000, repo_size: 1_000_000, dynos: 10, workers: 0,
|
7
|
+
created_at: Time.parse('01/01/2012 00:00')
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def app_response
|
12
|
+
stubbed_response app_data
|
13
|
+
end
|
14
|
+
|
15
|
+
def apps_response
|
16
|
+
stubbed_response [app_data]
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Helpers
|
2
|
+
def domain_data
|
3
|
+
{
|
4
|
+
id: 1, app_id: 1, domain: 'foo.bar.com', base_domain: 'bar.com',
|
5
|
+
default: nil, created_at: Time.parse('05/05/2012 00:00'),
|
6
|
+
updated_at: Time.parse('06/06/2012 00:00')
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
def domains_response
|
11
|
+
stubbed_response [domain_data]
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Helpers
|
2
|
+
def key_data
|
3
|
+
{
|
4
|
+
contents: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCz29znMi/UJX/nvkRSO5FFugKhU9DkkI53E0vXUnP8zeLFxMgyUqmXryPVjWtGzz2LRWqjm14SbqHAmM44pGHVfBIp6wCKBWSUYGv/FxOulwYgtWzz4moxWLZrFyWWgJAnehcVUifHNgzKwT2ovWm2ns52681Z8yFK3K8/uLStDjLIaPePEOaxaTvgIxZNsfyEoXoHcyTPwdR1GtQuDTuDYqYmjmPCoKybYnXrTQ1QFuQxDneBkswQYSl0H2aLf3uBK4F01hr+azXQuSe39eSV4I/TqzmNJlanpILT9Jz3/J1i4r6brpF3AxLnFnb9ufIbzQAIa/VZIulfrZkcBsUl david@carbon.local',
|
5
|
+
email: 'keyownder@domain.com'
|
6
|
+
}
|
7
|
+
end
|
8
|
+
|
9
|
+
def keys_response
|
10
|
+
stubbed_response [key_data]
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Helpers
|
2
|
+
def process_data
|
3
|
+
{
|
4
|
+
upid: '0000000', process: 'web.1', type: 'Dyno',
|
5
|
+
command: 'bundle exec puma', app_name: 'the-demo', slug: '0000000_0000',
|
6
|
+
action: 'down', state: 'idle', pretty_state: 'idle for 1h', elapsed: 0,
|
7
|
+
rendezvous_url: nil, attached: false,
|
8
|
+
transitioned_at: Time.parse('06/06/2012 23:59')
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def processes_response
|
13
|
+
stubbed_response [process_data]
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Helpers
|
2
|
+
def release_data
|
3
|
+
{
|
4
|
+
name: 'v1', descr: 'Add-on add example:basic',
|
5
|
+
user: 'releasing-user@me.com', commit: '0f0e0d',
|
6
|
+
env: { 'KEY1' => 'value' }, addons: ['example:basic'],
|
7
|
+
pstable: { 'web' => 'bundle exec puma' },
|
8
|
+
created_at: Time.parse('06/06/2012 00:00')
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def releases_response
|
13
|
+
stubbed_response [release_data]
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Helpers
|
2
|
+
def user_data
|
3
|
+
{
|
4
|
+
id: 1, name: 'Test User', email: 'example@me.com', confirmed: true,
|
5
|
+
verified: true, confirmed_at: Time.parse('01/01/2012 00:00'),
|
6
|
+
verified_at: Time.parse('01/01/2012 00:01'),
|
7
|
+
last_login: Time.parse('06/06/2012 11:50'),
|
8
|
+
created_at: Time.parse('01/01/2012 00:00')
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def user_response
|
13
|
+
stubbed_response user_data
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ruroku::AddonSet do
|
4
|
+
before do
|
5
|
+
@set = Ruroku::AddonSet.new stubbed_app
|
6
|
+
@set_api = @set.api
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#add' do
|
10
|
+
it 'maps to post_addon api method' do
|
11
|
+
@set_api.should_receive :post_addon
|
12
|
+
@set.add 'example:basic'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#upgrade' do
|
17
|
+
it 'maps to put_addon api method' do
|
18
|
+
@set_api.should_receive :put_addon
|
19
|
+
@set.upgrade 'example:pro'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#delete' do
|
24
|
+
it 'maps to delete_addon api method' do
|
25
|
+
@set_api.should_receive :delete_addon
|
26
|
+
@set.delete 'example:basic'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ruroku::API do
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
describe '#apps' do
|
7
|
+
it 'gets apps from api' do
|
8
|
+
heroku.should_receive(:get_apps)
|
9
|
+
api.apps
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns array of apps' do
|
13
|
+
apps = api.apps
|
14
|
+
apps.instance_of?(Ruroku::AppSet).should be_true
|
15
|
+
apps.each { |app| app.instance_of?(Ruroku::App).should be_true }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#app' do
|
20
|
+
it 'gets app from api' do
|
21
|
+
heroku.should_receive(:get_app)
|
22
|
+
api.app 'test-app'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns app' do
|
26
|
+
app = api.app 'test-app'
|
27
|
+
app.instance_of?(Ruroku::App).should be_true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#keys' do
|
32
|
+
it 'gets keys from api' do
|
33
|
+
heroku.should_receive(:get_keys)
|
34
|
+
api.keys
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns key set' do
|
38
|
+
keys = api.keys
|
39
|
+
keys.instance_of?(Ruroku::KeySet).should be_true
|
40
|
+
keys.each { |key| key.instance_of?(Ruroku::Key).should be_true }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#user' do
|
45
|
+
it 'gets user from api' do
|
46
|
+
heroku.should_receive(:get_user)
|
47
|
+
api.user
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'returns the user' do
|
51
|
+
user = api.user
|
52
|
+
user.instance_of?(Ruroku::User).should be_true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ruroku::AppSet do
|
4
|
+
before do
|
5
|
+
@set = Ruroku::AppSet.new stubbed_api
|
6
|
+
@set_api = @set.api
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#create' do
|
10
|
+
it 'maps to post_app api method' do
|
11
|
+
@set_api.should_receive :post_app
|
12
|
+
@set.create 'another-app', 'cedar'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ruroku::App do
|
4
|
+
before do
|
5
|
+
@app = Ruroku::App.new heroku, app_data
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#addons' do
|
9
|
+
it 'gets addons from api' do
|
10
|
+
heroku.should_receive(:get_addons)
|
11
|
+
@app.addons
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns addon set' do
|
15
|
+
addons = @app.addons
|
16
|
+
addons.instance_of?(Ruroku::AddonSet).should be_true
|
17
|
+
addons.each { |addon| addon.instance_of?(Ruroku::Addon).should be_true }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#collaborators' do
|
22
|
+
it 'gets collaborators from api' do
|
23
|
+
heroku.should_receive(:get_collaborators)
|
24
|
+
@app.collaborators
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns collaborator set' do
|
28
|
+
collaborators = @app.collaborators
|
29
|
+
collaborators.instance_of?(Ruroku::CollaboratorSet).should be_true
|
30
|
+
collaborators.each { |collaborator| collaborator.instance_of?(Ruroku::Collaborator).should be_true }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#config_vars' do
|
35
|
+
it 'gets config vars from api' do
|
36
|
+
heroku.should_receive(:get_config_vars)
|
37
|
+
@app.config_vars
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns config var set' do
|
41
|
+
config_vars = @app.config_vars
|
42
|
+
config_vars.instance_of?(Ruroku::ConfigVarSet).should be_true
|
43
|
+
config_vars.each { |config_var| config_var.instance_of?(Ruroku::ConfigVar).should be_true }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#domains' do
|
48
|
+
it 'gets domains from api' do
|
49
|
+
heroku.should_receive(:get_domains)
|
50
|
+
@app.domains
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'returns domain set' do
|
54
|
+
domains = @app.domains
|
55
|
+
domains.instance_of?(Ruroku::DomainSet).should be_true
|
56
|
+
domains.each { |domain| domain.instance_of?(Ruroku::Domain).should be_true }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#processes' do
|
61
|
+
it 'gets processes from api' do
|
62
|
+
heroku.should_receive(:get_ps)
|
63
|
+
@app.processes
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns process set' do
|
67
|
+
processes = @app.processes
|
68
|
+
processes.instance_of?(Ruroku::ProcessSet).should be_true
|
69
|
+
processes.each { |process| process.instance_of?(Ruroku::Process).should be_true }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#releases' do
|
74
|
+
it 'gets releases from api' do
|
75
|
+
heroku.should_receive(:get_releases)
|
76
|
+
@app.releases
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'returns release set' do
|
80
|
+
|
81
|
+
releases = @app.releases
|
82
|
+
releases.instance_of?(Ruroku::ReleaseSet).should be_true
|
83
|
+
releases.each { |release| release.instance_of?(Ruroku::Release).should be_true }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#stacks' do
|
88
|
+
it 'gets stacks from api' do
|
89
|
+
heroku.should_receive(:get_stack)
|
90
|
+
@app.stacks
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'returns stack set' do
|
94
|
+
stacks = @app.stacks
|
95
|
+
stacks.instance_of?(Ruroku::StackSet).should be_true
|
96
|
+
stacks.each { |stack| stack.instance_of?(Ruroku::Stack).should be_true }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#maintenance!' do
|
101
|
+
it 'turns maintenance mode on' do
|
102
|
+
heroku.should_receive(:post_app_maintenance).with(@app.name, '1')
|
103
|
+
@app.maintenance!
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#no_maintenance' do
|
108
|
+
it 'turns maintenance mode off' do
|
109
|
+
heroku.should_receive(:post_app_maintenance).with(@app.name, '0')
|
110
|
+
@app.no_maintenance!
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ruroku::CollaboratorSet do
|
4
|
+
before do
|
5
|
+
@set = Ruroku::CollaboratorSet.new stubbed_app
|
6
|
+
@set_api = @set.api
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#add' do
|
10
|
+
it 'maps to post_collaborator api method' do
|
11
|
+
@set_api.should_receive :post_collaborator
|
12
|
+
@set.add 'example@me.com'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#delete' do
|
17
|
+
it 'maps to delete_collaborator api method' do
|
18
|
+
@set_api.should_receive :delete_collaborator
|
19
|
+
@set.delete 'example@me.com'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|