engineyard 1.4.20 → 1.4.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -357,5 +357,21 @@ module EY
357
357
  EY.ui.say "#{user.name} (#{user.email})"
358
358
  end
359
359
 
360
+ desc "login", "Log in and verify access to EY Cloud."
361
+ def login
362
+ whoami
363
+ end
364
+
365
+ desc "logout", "Remove the current API key from ~/.eyrc or env $EYRC"
366
+ def logout
367
+ eyrc = EYRC.load
368
+ if eyrc.delete_api_token
369
+ EY.ui.say "API token removed: #{eyrc.path}"
370
+ EY.ui.say "Run any other command to login again."
371
+ else
372
+ EY.ui.say "Already logged out. Run any other command to login again."
373
+ end
374
+ end
375
+
360
376
  end # CLI
361
377
  end # EY
@@ -16,6 +16,10 @@ module EY
16
16
  path.exist?
17
17
  end
18
18
 
19
+ def delete_api_token
20
+ delete('api_token')
21
+ end
22
+
19
23
  def api_token
20
24
  self['api_token']
21
25
  end
@@ -35,17 +39,24 @@ module EY
35
39
  end
36
40
 
37
41
  def []=(key,val)
38
- merge_and_write(key.to_s => val)
42
+ new_data = read_data.merge(key.to_s => val)
43
+ write_data new_data
39
44
  val
40
45
  end
41
46
 
47
+ def delete(key)
48
+ data = read_data.dup
49
+ res = data.delete(key)
50
+ write_data data
51
+ res
52
+ end
53
+
42
54
  def read_data
43
55
  exist? && YAML.load(path.read) || {}
44
56
  end
45
57
 
46
- def merge_and_write(new_data)
47
- to_write = read_data.merge(new_data)
48
- path.open("w") {|f| YAML.dump(to_write, f) }
58
+ def write_data(new_data)
59
+ path.open("w") {|f| YAML.dump(new_data, f) }
49
60
  end
50
61
 
51
62
  end
@@ -1,3 +1,3 @@
1
1
  module EY
2
- VERSION = '1.4.20'
2
+ VERSION = '1.4.21'
3
3
  end
@@ -41,6 +41,11 @@ describe EY::EYRC do
41
41
  EY::EYRC.load.api_token.should == 'abcd'
42
42
  end
43
43
 
44
+ it "deletes the api_token" do
45
+ EY::EYRC.load.delete_api_token
46
+ EY::EYRC.load.api_token.should be_nil
47
+ end
48
+
44
49
  it "writes the api_token to api_token: .eyrc" do
45
50
  read_yaml(ENV['EYRC']).should == {"api_token" => "abcd"}
46
51
  end
@@ -57,6 +62,11 @@ describe EY::EYRC do
57
62
  EY::EYRC.load.api_token.should == 'abcd'
58
63
  end
59
64
 
65
+ it "deletes the api token safely on logout" do
66
+ EY::EYRC.load.delete_api_token
67
+ read_yaml(ENV['EYRC']).should == {"http://localhost/" => {"api_token" => "5678"}}
68
+ end
69
+
60
70
  it "maintains other random info in the file" do
61
71
  read_yaml(ENV['EYRC']).should == {"api_token" => "abcd", "http://localhost/" => {"api_token" => "5678"}}
62
72
  end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey login" do
4
+ context "logged in" do
5
+ given "integration"
6
+
7
+ it "returns the logged in user name" do
8
+ ey %w[login]
9
+ @out.should include("User Name (test@test.test)")
10
+ end
11
+ end
12
+
13
+ context "not logged in" do
14
+ given "integration without an eyrc file"
15
+
16
+ it "prompts for authentication before outputting the logged in user" do
17
+ ey(%w[login], :hide_err => true) do |input|
18
+ input.puts("test@test.test")
19
+ input.puts("test")
20
+ end
21
+
22
+ @out.should include("We need to fetch your API token; please log in.")
23
+ @out.should include("Email:")
24
+ @out.should include("Password:")
25
+
26
+ @out.should include("User Name (test@test.test)")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey logout" do
4
+ context "logged in" do
5
+ given "integration"
6
+
7
+ it "logs you out" do
8
+ ey %w[logout]
9
+ @out.should include("API token removed: #{ENV['EYRC']}")
10
+ @out.should include("Run any other command to login again.")
11
+ end
12
+ end
13
+
14
+ context "not logged in" do
15
+ given "integration without an eyrc file"
16
+
17
+ it "prompts for authentication before outputting the logged in user" do
18
+ ey %w[logout]
19
+ @out.should_not include("API token removed:")
20
+ @out.should include("Already logged out.")
21
+ @out.should include("Run any other command to login again.")
22
+ end
23
+ end
24
+ end
@@ -4,10 +4,6 @@ describe "ey whoami" do
4
4
  context "logged in" do
5
5
  given "integration"
6
6
 
7
- before(:all) do
8
- api_scenario "empty"
9
- end
10
-
11
7
  it "outputs the currently logged in user" do
12
8
  ey %w[whoami]
13
9
  @out.should include("User Name (test@test.test)")
@@ -17,10 +13,6 @@ describe "ey whoami" do
17
13
  context "not logged in" do
18
14
  given "integration without an eyrc file"
19
15
 
20
- before(:each) do
21
- api_scenario "empty"
22
- end
23
-
24
16
  it "prompts for authentication before outputting the logged in user" do
25
17
  ey(%w[whoami], :hide_err => true) do |input|
26
18
  input.puts("test@test.test")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 45
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 20
10
- version: 1.4.20
9
+ - 21
10
+ version: 1.4.21
11
11
  platform: ruby
12
12
  authors:
13
13
  - EY Cloud Team
@@ -15,10 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-13 00:00:00 Z
18
+ date: 2012-01-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
21
+ prerelease: false
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
22
24
  none: false
23
25
  requirements:
24
26
  - - ~>
@@ -29,12 +31,12 @@ dependencies:
29
31
  - 14
30
32
  - 6
31
33
  version: 0.14.6
32
- requirement: *id001
33
- type: :runtime
34
- prerelease: false
35
34
  name: thor
35
+ version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ type: :runtime
39
+ requirement: &id002 !ruby/object:Gem::Requirement
38
40
  none: false
39
41
  requirements:
40
42
  - - ~>
@@ -45,12 +47,12 @@ dependencies:
45
47
  - 6
46
48
  - 0
47
49
  version: 1.6.0
48
- requirement: *id002
49
- type: :runtime
50
- prerelease: false
51
50
  name: rest-client
51
+ version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
53
+ prerelease: false
54
+ type: :runtime
55
+ requirement: &id003 !ruby/object:Gem::Requirement
54
56
  none: false
55
57
  requirements:
56
58
  - - ~>
@@ -61,12 +63,12 @@ dependencies:
61
63
  - 6
62
64
  - 1
63
65
  version: 1.6.1
64
- requirement: *id003
65
- type: :runtime
66
- prerelease: false
67
66
  name: highline
67
+ version_requirements: *id003
68
68
  - !ruby/object:Gem::Dependency
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ prerelease: false
70
+ type: :runtime
71
+ requirement: &id004 !ruby/object:Gem::Requirement
70
72
  none: false
71
73
  requirements:
72
74
  - - ">="
@@ -75,12 +77,12 @@ dependencies:
75
77
  segments:
76
78
  - 0
77
79
  version: "0"
78
- requirement: *id004
79
- type: :runtime
80
- prerelease: false
81
80
  name: json_pure
81
+ version_requirements: *id004
82
82
  - !ruby/object:Gem::Dependency
83
- version_requirements: &id005 !ruby/object:Gem::Requirement
83
+ prerelease: false
84
+ type: :runtime
85
+ requirement: &id005 !ruby/object:Gem::Requirement
84
86
  none: false
85
87
  requirements:
86
88
  - - ~>
@@ -91,12 +93,12 @@ dependencies:
91
93
  - 0
92
94
  - 4
93
95
  version: 0.0.4
94
- requirement: *id005
95
- type: :runtime
96
- prerelease: false
97
96
  name: escape
97
+ version_requirements: *id005
98
98
  - !ruby/object:Gem::Dependency
99
- version_requirements: &id006 !ruby/object:Gem::Requirement
99
+ prerelease: false
100
+ type: :runtime
101
+ requirement: &id006 !ruby/object:Gem::Requirement
100
102
  none: false
101
103
  requirements:
102
104
  - - "="
@@ -107,12 +109,12 @@ dependencies:
107
109
  - 5
108
110
  - 25
109
111
  version: 1.5.25
110
- requirement: *id006
111
- type: :runtime
112
- prerelease: false
113
112
  name: engineyard-serverside-adapter
113
+ version_requirements: *id006
114
114
  - !ruby/object:Gem::Dependency
115
- version_requirements: &id007 !ruby/object:Gem::Requirement
115
+ prerelease: false
116
+ type: :runtime
117
+ requirement: &id007 !ruby/object:Gem::Requirement
116
118
  none: false
117
119
  requirements:
118
120
  - - ~>
@@ -123,12 +125,12 @@ dependencies:
123
125
  - 2
124
126
  - 1
125
127
  version: 2.2.1
126
- requirement: *id007
127
- type: :runtime
128
- prerelease: false
129
128
  name: net-ssh
129
+ version_requirements: *id007
130
130
  - !ruby/object:Gem::Dependency
131
- version_requirements: &id008 !ruby/object:Gem::Requirement
131
+ prerelease: false
132
+ type: :runtime
133
+ requirement: &id008 !ruby/object:Gem::Requirement
132
134
  none: false
133
135
  requirements:
134
136
  - - "="
@@ -139,12 +141,12 @@ dependencies:
139
141
  - 0
140
142
  - 5
141
143
  version: 2.0.5
142
- requirement: *id008
143
- type: :runtime
144
- prerelease: false
145
144
  name: launchy
145
+ version_requirements: *id008
146
146
  - !ruby/object:Gem::Dependency
147
- version_requirements: &id009 !ruby/object:Gem::Requirement
147
+ prerelease: false
148
+ type: :development
149
+ requirement: &id009 !ruby/object:Gem::Requirement
148
150
  none: false
149
151
  requirements:
150
152
  - - ~>
@@ -154,12 +156,12 @@ dependencies:
154
156
  - 2
155
157
  - 0
156
158
  version: "2.0"
157
- requirement: *id009
158
- type: :development
159
- prerelease: false
160
159
  name: rspec
160
+ version_requirements: *id009
161
161
  - !ruby/object:Gem::Dependency
162
- version_requirements: &id010 !ruby/object:Gem::Requirement
162
+ prerelease: false
163
+ type: :development
164
+ requirement: &id010 !ruby/object:Gem::Requirement
163
165
  none: false
164
166
  requirements:
165
167
  - - ">="
@@ -168,12 +170,12 @@ dependencies:
168
170
  segments:
169
171
  - 0
170
172
  version: "0"
171
- requirement: *id010
172
- type: :development
173
- prerelease: false
174
173
  name: rake
174
+ version_requirements: *id010
175
175
  - !ruby/object:Gem::Dependency
176
- version_requirements: &id011 !ruby/object:Gem::Requirement
176
+ prerelease: false
177
+ type: :development
178
+ requirement: &id011 !ruby/object:Gem::Requirement
177
179
  none: false
178
180
  requirements:
179
181
  - - ">="
@@ -182,12 +184,12 @@ dependencies:
182
184
  segments:
183
185
  - 0
184
186
  version: "0"
185
- requirement: *id011
186
- type: :development
187
- prerelease: false
188
187
  name: rdoc
188
+ version_requirements: *id011
189
189
  - !ruby/object:Gem::Dependency
190
- version_requirements: &id012 !ruby/object:Gem::Requirement
190
+ prerelease: false
191
+ type: :development
192
+ requirement: &id012 !ruby/object:Gem::Requirement
191
193
  none: false
192
194
  requirements:
193
195
  - - ">="
@@ -196,12 +198,12 @@ dependencies:
196
198
  segments:
197
199
  - 0
198
200
  version: "0"
199
- requirement: *id012
200
- type: :development
201
- prerelease: false
202
201
  name: fakeweb
202
+ version_requirements: *id012
203
203
  - !ruby/object:Gem::Dependency
204
- version_requirements: &id013 !ruby/object:Gem::Requirement
204
+ prerelease: false
205
+ type: :development
206
+ requirement: &id013 !ruby/object:Gem::Requirement
205
207
  none: false
206
208
  requirements:
207
209
  - - ">="
@@ -210,12 +212,12 @@ dependencies:
210
212
  segments:
211
213
  - 0
212
214
  version: "0"
213
- requirement: *id013
214
- type: :development
215
- prerelease: false
216
215
  name: fakeweb-matcher
216
+ version_requirements: *id013
217
217
  - !ruby/object:Gem::Dependency
218
- version_requirements: &id014 !ruby/object:Gem::Requirement
218
+ prerelease: false
219
+ type: :development
220
+ requirement: &id014 !ruby/object:Gem::Requirement
219
221
  none: false
220
222
  requirements:
221
223
  - - ">="
@@ -224,12 +226,12 @@ dependencies:
224
226
  segments:
225
227
  - 0
226
228
  version: "0"
227
- requirement: *id014
228
- type: :development
229
- prerelease: false
230
229
  name: sinatra
230
+ version_requirements: *id014
231
231
  - !ruby/object:Gem::Dependency
232
- version_requirements: &id015 !ruby/object:Gem::Requirement
232
+ prerelease: false
233
+ type: :development
234
+ requirement: &id015 !ruby/object:Gem::Requirement
233
235
  none: false
234
236
  requirements:
235
237
  - - ~>
@@ -240,12 +242,12 @@ dependencies:
240
242
  - 2
241
243
  - 2
242
244
  version: 0.2.2
243
- requirement: *id015
244
- type: :development
245
- prerelease: false
246
245
  name: realweb
246
+ version_requirements: *id015
247
247
  - !ruby/object:Gem::Dependency
248
- version_requirements: &id016 !ruby/object:Gem::Requirement
248
+ prerelease: false
249
+ type: :development
250
+ requirement: &id016 !ruby/object:Gem::Requirement
249
251
  none: false
250
252
  requirements:
251
253
  - - ~>
@@ -256,10 +258,8 @@ dependencies:
256
258
  - 0
257
259
  - 1
258
260
  version: 1.0.1
259
- requirement: *id016
260
- type: :development
261
- prerelease: false
262
261
  name: open4
262
+ version_requirements: *id016
263
263
  description: This gem allows you to deploy your rails application to the Engine Yard cloud directly from the command line.
264
264
  email: cloud@engineyard.com
265
265
  executables:
@@ -317,6 +317,8 @@ files:
317
317
  - spec/ey/deploy_spec.rb
318
318
  - spec/ey/ey_spec.rb
319
319
  - spec/ey/list_environments_spec.rb
320
+ - spec/ey/login_spec.rb
321
+ - spec/ey/logout_spec.rb
320
322
  - spec/ey/logs_spec.rb
321
323
  - spec/ey/rebuild_spec.rb
322
324
  - spec/ey/recipes/apply_spec.rb
@@ -379,7 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
379
381
  requirements: []
380
382
 
381
383
  rubyforge_project:
382
- rubygems_version: 1.8.10
384
+ rubygems_version: 1.8.15
383
385
  signing_key:
384
386
  specification_version: 3
385
387
  summary: Command-line deployment for the Engine Yard cloud
@@ -400,6 +402,8 @@ test_files:
400
402
  - spec/ey/deploy_spec.rb
401
403
  - spec/ey/ey_spec.rb
402
404
  - spec/ey/list_environments_spec.rb
405
+ - spec/ey/login_spec.rb
406
+ - spec/ey/logout_spec.rb
403
407
  - spec/ey/logs_spec.rb
404
408
  - spec/ey/rebuild_spec.rb
405
409
  - spec/ey/recipes/apply_spec.rb