ruroku 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
## Ruruku 0.0.2 (Jun 10, 2012)
|
2
|
+
|
3
|
+
* Added collection reloading
|
4
|
+
* Added collection caching
|
5
|
+
* Added support of keys
|
6
|
+
* Finding app by name
|
7
|
+
* Added support of stacks
|
8
|
+
|
9
|
+
## Ruroku 0.0.1 (Jun 9, 2012)
|
10
|
+
|
11
|
+
* First public release (app, app addons, app collaborators, app config
|
12
|
+
vars, app domains, app processes, app releases, app stacks)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# Ruroku
|
2
|
+
[![Build Status](https://secure.travis-ci.org/goshakkk/ruroku.png)](http://travis-ci.org/goshakkk/ruroku)
|
3
|
+
[![Dependency Status](https://gemnasium.com/goshakkk/ruroku.png?travis)](https://gemnasium.com/goshakkk/ruroku)
|
2
4
|
|
3
|
-
The Ruby client for Heroku API, built on top of official
|
4
|
-
gem.
|
5
|
+
The better Ruby client for Heroku API, built on top of official
|
6
|
+
`heroku.rb` gem.
|
5
7
|
|
6
8
|
## Installation
|
7
9
|
|
@@ -21,7 +23,9 @@ Or install it yourself as:
|
|
21
23
|
|
22
24
|
Start by initiating a connection with Heroku API:
|
23
25
|
|
24
|
-
|
26
|
+
```ruby
|
27
|
+
heroku = Ruroku::API.new api_key: YOUR_HEROKU_API_KEY
|
28
|
+
```
|
25
29
|
|
26
30
|
(You can leave out `:api_key` if `ENV['HEROKU_API_KEY']` is set
|
27
31
|
instead.)
|
@@ -33,106 +37,234 @@ Now you can interact with Heroku API using Ruroku.
|
|
33
37
|
Each API object has apps associated with the Heroku account. You can
|
34
38
|
access an Array of all the associated apps with `#apps`:
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
app = heroku.apps.first
|
40
|
+
```ruby
|
41
|
+
heroku.apps
|
42
|
+
# => [#<App>, #<App>, #<App>]
|
40
43
|
|
41
|
-
|
44
|
+
app = heroku.apps.first
|
45
|
+
```
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
To get specific app:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
app = heroku.app 'app-name'
|
51
|
+
```
|
52
|
+
|
53
|
+
And access its properties such as:
|
54
|
+
|
55
|
+
* `id`
|
56
|
+
* `name`
|
57
|
+
* `stack`
|
58
|
+
* `git_url`
|
59
|
+
* `slug_size`
|
60
|
+
* `repo_size`
|
61
|
+
* `dynos`
|
62
|
+
* `workers`
|
52
63
|
|
53
64
|
Maintenance mode can be turned on and off:
|
54
65
|
|
55
|
-
|
56
|
-
|
66
|
+
```ruby
|
67
|
+
app.maintenance!
|
68
|
+
app.no_maintenance!
|
69
|
+
```
|
57
70
|
|
58
|
-
|
71
|
+
Also, imagine you've created another app after you you queried
|
72
|
+
`heroku.app`. To refresh collection of apps (or other collections:
|
73
|
+
addons, config vars, collaborators, and so on), just call `#reload` on
|
74
|
+
collection:
|
59
75
|
|
60
|
-
|
76
|
+
```ruby
|
77
|
+
apps.reload
|
78
|
+
```
|
61
79
|
|
62
|
-
|
63
|
-
# => [#<Addon>, #<Addon>, #<Addon>]
|
64
|
-
|
65
|
-
addon = app.addons.first
|
80
|
+
### Addons
|
66
81
|
|
67
|
-
|
82
|
+
To get a list of addons used by a particular app:
|
68
83
|
|
69
|
-
|
84
|
+
```ruby
|
85
|
+
addons = app.addons
|
86
|
+
# => [#<Addon>, #<Addon>, #<Addon>]
|
70
87
|
|
71
|
-
|
88
|
+
addon = app.addons.first
|
89
|
+
```
|
72
90
|
|
73
|
-
|
91
|
+
It's possible perform several actions on addon collections:
|
74
92
|
|
75
|
-
|
93
|
+
```ruby
|
94
|
+
# Add an addon
|
95
|
+
addons.add 'addon:plan'
|
76
96
|
|
77
|
-
|
97
|
+
# Remove an addon
|
98
|
+
addons.delete 'addon-name'
|
78
99
|
|
79
|
-
|
100
|
+
# Upgrade an addon
|
101
|
+
addons.upgrade 'addon:new-plan'
|
102
|
+
```
|
80
103
|
|
81
104
|
Each addon object is associated with the application. You can delete
|
82
105
|
addons from the app by calling `#delete` method on the addon object as
|
83
106
|
well:
|
84
107
|
|
85
|
-
|
108
|
+
```ruby
|
109
|
+
addon.delete!
|
110
|
+
```
|
86
111
|
|
87
112
|
### Collaborators
|
88
113
|
|
89
114
|
List all app collaborators:
|
90
115
|
|
91
|
-
|
116
|
+
```ruby
|
117
|
+
collaborators = app.collaborators
|
118
|
+
```
|
92
119
|
|
93
|
-
|
120
|
+
and
|
94
121
|
|
95
|
-
|
122
|
+
```ruby
|
123
|
+
# Add a collaborator
|
124
|
+
collaborators.add 'email@me.com'
|
96
125
|
|
97
|
-
|
126
|
+
# Remove a collaborator
|
127
|
+
collaborators.delete 'email@me.com'
|
128
|
+
# or
|
129
|
+
collaborator.delete!
|
130
|
+
```
|
98
131
|
|
99
|
-
|
132
|
+
### Config variables
|
100
133
|
|
101
|
-
|
134
|
+
List all app config vars:
|
102
135
|
|
103
|
-
|
136
|
+
```ruby
|
137
|
+
config_vars = app.config_vars
|
138
|
+
```
|
104
139
|
|
105
|
-
|
140
|
+
Add or delete a config var:
|
106
141
|
|
107
|
-
|
142
|
+
```ruby
|
143
|
+
config_vars.add 'KEY' => 'value'
|
144
|
+
config_vars.delete 'KEY'
|
145
|
+
|
146
|
+
# or:
|
147
|
+
|
148
|
+
config_var.delete!
|
149
|
+
```
|
150
|
+
|
151
|
+
They can also be updated like that:
|
108
152
|
|
109
|
-
|
153
|
+
```ruby
|
154
|
+
config_var.value = 'new value'
|
155
|
+
```
|
156
|
+
|
157
|
+
And it'll instantly get updated.
|
110
158
|
|
111
159
|
### Domains
|
112
160
|
|
113
161
|
Access domains used by the application:
|
114
162
|
|
115
|
-
|
163
|
+
```ruby
|
164
|
+
domains = app.domains
|
165
|
+
```
|
166
|
+
|
167
|
+
Same as with other collection objects, they can be added or deleted:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
domains.add 'domain.com'
|
171
|
+
domains.delete 'domain.com'
|
172
|
+
|
173
|
+
# or:
|
174
|
+
|
175
|
+
domain.delete!
|
176
|
+
```
|
116
177
|
|
117
178
|
### Processes
|
118
179
|
|
119
180
|
Get current application processes:
|
120
181
|
|
121
|
-
|
182
|
+
```ruby
|
183
|
+
processes = app.processes
|
184
|
+
```
|
185
|
+
|
186
|
+
You can also run, restart, scale, and stop method collections:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
processes.run 'rake evolve'
|
190
|
+
processes.restart
|
191
|
+
processes.scale 'worker', 10
|
192
|
+
processes.stop 'ps' => 'run.1'
|
193
|
+
processes.stop 'type' => 'worker'
|
194
|
+
```
|
122
195
|
|
123
196
|
### Releases
|
124
197
|
|
125
198
|
List all app releases:
|
126
199
|
|
127
|
-
|
200
|
+
```ruby
|
201
|
+
releases = app.releases
|
202
|
+
```
|
203
|
+
|
204
|
+
And rollback to any release:
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
releases.rollback 'v1'
|
208
|
+
```
|
209
|
+
|
210
|
+
### Stacks
|
211
|
+
|
212
|
+
List stacks, available for the app:
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
app.stacks
|
216
|
+
```
|
217
|
+
|
218
|
+
Migrate the app to available stack:
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
stacks.migrate 'stack-name'
|
222
|
+
```
|
223
|
+
|
224
|
+
### User
|
225
|
+
|
226
|
+
Get User object associtaed with current heroku account:
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
heroku.user
|
230
|
+
```
|
231
|
+
|
232
|
+
### Keys
|
233
|
+
|
234
|
+
Access all keys:
|
235
|
+
|
236
|
+
```ruby
|
237
|
+
keys = heroku.keys
|
238
|
+
```
|
239
|
+
|
240
|
+
Add a key:
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
keys.add 'content of id_rsa.pub here...'
|
244
|
+
```
|
245
|
+
|
246
|
+
Delete specific key:
|
247
|
+
|
248
|
+
```ruby
|
249
|
+
keys.delete 'email@me.com'
|
250
|
+
key.delete!
|
251
|
+
```
|
252
|
+
|
253
|
+
Delete all keys:
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
keys.delete_all
|
257
|
+
```
|
128
258
|
|
129
259
|
## Mock
|
130
260
|
|
131
261
|
For practice or testing you can also use a simulated Heroku:
|
132
262
|
|
133
|
-
|
263
|
+
```ruby
|
264
|
+
require 'ruroku'
|
134
265
|
|
135
|
-
|
266
|
+
heroku = Ruroku::API.new api_key: API_KEY, mock: true
|
267
|
+
```
|
136
268
|
|
137
269
|
After that commands should still behave the same, but they will only modify some local data instead of updating the state of things on Heroku.
|
138
270
|
|
data/Rakefile
CHANGED
data/TODO.md
CHANGED
data/lib/ruroku.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
require "heroku-api"
|
2
1
|
require "time"
|
2
|
+
require "heroku-api"
|
3
|
+
require "virtus"
|
3
4
|
require "active_support/core_ext/numeric"
|
4
5
|
require "active_support/core_ext/string"
|
5
6
|
|
6
7
|
require "ruroku/base"
|
7
8
|
require "ruroku/nested_base"
|
8
9
|
require "ruroku/resource_set"
|
10
|
+
require "ruroku/nested_resource_set"
|
9
11
|
|
10
12
|
require "ruroku/api"
|
11
13
|
require "ruroku/app"
|
14
|
+
require "ruroku/app_set"
|
12
15
|
require "ruroku/addon"
|
13
16
|
require "ruroku/addon_set"
|
14
17
|
require "ruroku/collaborator"
|
@@ -21,6 +24,11 @@ require "ruroku/process"
|
|
21
24
|
require "ruroku/process_set"
|
22
25
|
require "ruroku/release"
|
23
26
|
require "ruroku/release_set"
|
27
|
+
require "ruroku/stack"
|
28
|
+
require "ruroku/stack_set"
|
29
|
+
require "ruroku/user"
|
30
|
+
require "ruroku/key"
|
31
|
+
require "ruroku/key_set"
|
24
32
|
require "ruroku/version"
|
25
33
|
|
26
34
|
module Ruroku
|
data/lib/ruroku/addon.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
module Ruroku
|
2
2
|
class Addon < NestedBase
|
3
|
-
|
4
|
-
|
3
|
+
attribute :name, String
|
4
|
+
attribute :description, String
|
5
|
+
attribute :url, String
|
6
|
+
attribute :state, String
|
7
|
+
attribute :price, Hash
|
8
|
+
attribute :beta, Boolean, default: false
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
!!beta
|
9
|
-
end
|
10
|
-
|
11
|
-
def price=(value)
|
12
|
-
@price = value
|
13
|
-
end
|
10
|
+
resource_id :name
|
11
|
+
deletable_resource
|
14
12
|
end
|
15
13
|
end
|
data/lib/ruroku/addon_set.rb
CHANGED
data/lib/ruroku/api.rb
CHANGED
@@ -10,7 +10,26 @@ module Ruroku
|
|
10
10
|
#
|
11
11
|
# Returns the Array[App].
|
12
12
|
def apps
|
13
|
-
|
13
|
+
@apps ||= AppSet.new heroku_api
|
14
|
+
end
|
15
|
+
|
16
|
+
# Public: Get specific app.
|
17
|
+
def app(app_name)
|
18
|
+
App.new heroku_api, heroku_api.get_app(app_name).body
|
19
|
+
end
|
20
|
+
|
21
|
+
# Public: Get keys associated with current heroku account.
|
22
|
+
def keys
|
23
|
+
@keys ||= KeySet.new heroku_api
|
24
|
+
end
|
25
|
+
|
26
|
+
# Public: Get User object associated with current heroku account.
|
27
|
+
def user
|
28
|
+
@user ||= User.new heroku_api, heroku_api.get_user.body
|
29
|
+
end
|
30
|
+
|
31
|
+
def inspect
|
32
|
+
"<#{self.class}>"
|
14
33
|
end
|
15
34
|
end
|
16
35
|
end
|