pagoda 0.3.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/.DS_Store +0 -0
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +33 -24
  4. data/README.md +68 -0
  5. data/Rakefile +4 -7
  6. data/bin/pagoda +100 -8
  7. data/lib/pagoda/cli/commands/clone.rb +13 -0
  8. data/lib/pagoda/cli/commands/create.rb +13 -0
  9. data/lib/pagoda/cli/commands/deploy.rb +12 -0
  10. data/lib/pagoda/cli/commands/destroy.rb +16 -0
  11. data/lib/pagoda/cli/commands/info.rb +13 -0
  12. data/lib/pagoda/cli/commands/init.rb +13 -0
  13. data/lib/pagoda/cli/commands/list.rb +20 -0
  14. data/lib/pagoda/cli/commands/rename.rb +17 -0
  15. data/lib/pagoda/cli/commands/rollback.rb +12 -0
  16. data/lib/pagoda/cli/commands/ssh_key.rb +27 -0
  17. data/lib/pagoda/cli/commands/tunnel.rb +18 -0
  18. data/lib/pagoda/cli/commands.rb +11 -0
  19. data/lib/pagoda/{helpers.rb → cli/core_ext.rb} +10 -118
  20. data/lib/pagoda/cli/helpers/app.rb +143 -0
  21. data/lib/pagoda/cli/helpers/base.rb +199 -0
  22. data/lib/pagoda/cli/helpers/key.rb +69 -0
  23. data/lib/pagoda/cli/helpers/tunnel.rb +36 -0
  24. data/lib/pagoda/cli/helpers.rb +127 -0
  25. data/lib/pagoda/cli/override.rb +23 -0
  26. data/lib/pagoda/cli/version.rb +5 -0
  27. data/lib/pagoda/cli.rb +11 -0
  28. data/lib/pagoda-cli.rb +1 -0
  29. data/pagoda.gemspec +20 -24
  30. data/pagoda.rdoc +139 -0
  31. data/pkg/newpagoda-0.1.10.gem +0 -0
  32. data/pkg/newpagoda-0.1.11.gem +0 -0
  33. data/pkg/newpagoda-0.1.12.gem +0 -0
  34. data/pkg/newpagoda-0.1.13.gem +0 -0
  35. data/pkg/newpagoda-0.1.15.gem +0 -0
  36. data/pkg/newpagoda-0.1.4.gem +0 -0
  37. data/pkg/newpagoda-0.1.6.gem +0 -0
  38. data/pkg/newpagoda-0.1.7.gem +0 -0
  39. data/pkg/newpagoda-0.1.8.gem +0 -0
  40. data/pkg/newpagoda-0.1.9.gem +0 -0
  41. data/pkg/newpagoda-0.5.0.gem +0 -0
  42. data/spec/lib/helper_spec.rb +32 -0
  43. data/spec/lib/helpers/app_spec.rb +104 -0
  44. data/spec/lib/helpers/base_spec.rb +27 -0
  45. data/spec/lib/helpers/key_spec.rb +42 -0
  46. data/spec/lib/helpers/tunnel_spec.rb +30 -0
  47. data/spec/spec_helper.rb +17 -0
  48. metadata +74 -50
  49. data/.bundle/config +0 -1
  50. data/README +0 -3
  51. data/lib/pagoda/client.rb +0 -225
  52. data/lib/pagoda/command.rb +0 -96
  53. data/lib/pagoda/commands/app.rb +0 -247
  54. data/lib/pagoda/commands/auth.rb +0 -149
  55. data/lib/pagoda/commands/base.rb +0 -184
  56. data/lib/pagoda/commands/db.rb +0 -18
  57. data/lib/pagoda/commands/help.rb +0 -100
  58. data/lib/pagoda/commands/tunnel.rb +0 -49
  59. data/lib/pagoda/tunnel_proxy.rb +0 -130
  60. data/lib/pagoda/version.rb +0 -3
  61. data/lib/pagoda.rb +0 -3
  62. data/spec/base.rb +0 -21
  63. data/spec/client_spec.rb +0 -255
  64. data/spec/command_spec.rb +0 -26
  65. data/spec/commands/auth_spec.rb +0 -57
data/spec/client_spec.rb DELETED
@@ -1,255 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/base"
2
- require "#{File.dirname(__FILE__)}/../lib/pagoda/client"
3
-
4
- describe Pagoda::Client do
5
-
6
- before do
7
- @client = Pagoda::Client.new(nil, nil)
8
- end
9
-
10
- describe "app" do
11
-
12
- # errors come back like this:
13
- # <?xml version="1.0" encoding="UTF-8"?>
14
- # <errors>
15
- # <error>Username can't be blank</error>
16
- # <error>Email can't be blank</error>
17
- # <error>Password can't be blank</error>
18
- # </errors>
19
-
20
- it "should display information" do
21
- stub = %{
22
- <?xml version='1.0' encoding='UTF-8'?>
23
- <app>
24
- <name>testapp</name>
25
- <git-url>git@github.com:tylerflint/pagoda-pilot.git</git-url>
26
- <owner>
27
- <username>owner1</username>
28
- <email>owner1@test.com</email>
29
- </owner>
30
- <collaborators type="array">
31
- <collaborator>
32
- <username>guy1</username>
33
- <email>guy1@test.com</email>
34
- </collaborator>
35
- <collaborator>
36
- <username>guy2</username>
37
- <email>guy2@test.com</email>
38
- </collaborator>
39
- </collaborators>
40
- <transactions type="array">
41
- <transaction>
42
- <id>1</id>
43
- <name>app.init</name>
44
- <description>Deploying app to the Pagoda grid</description>
45
- <state>started</state>
46
- <status></status>
47
- </transaction>
48
- </transactions>
49
- </app>
50
- }
51
- stub_api_request(:get, "/apps/testapp.xml").to_return(:body => stub)
52
- @client.app_info('testapp').should == {
53
- :name => 'testapp',
54
- :git_url => 'git@github.com:tylerflint/pagoda-pilot.git',
55
- :owner => {
56
- :username => 'owner1',
57
- :email => 'owner1@test.com'
58
- },
59
- :collaborators => [
60
- {:username => 'guy1', :email => 'guy1@test.com'},
61
- {:username => 'guy2', :email => 'guy2@test.com'}
62
- ],
63
- :transactions => [
64
- {:id => '1', :name => 'app.init', :description => 'Deploying app to the Pagoda grid', :state => 'started', :status => nil}
65
- ]
66
- }
67
- end
68
-
69
- it "lists incomplete transactions" do
70
- stub = %{
71
- <?xml version='1.0' encoding='UTF-8'?>
72
- <transactions type="array">
73
- <transaction>
74
- <id>1</id>
75
- <name>app.increment</name>
76
- <description>spawn new instance of app</description>
77
- <state>started</state>
78
- <status></status>
79
- </transaction>
80
- <transaction>
81
- <id>2</id>
82
- <name>app.deploy</name>
83
- <description>deploy code</description>
84
- <state>ready</state>
85
- <status></status>
86
- </transaction>
87
- </transactions>
88
- }
89
- stub_api_request(:get, "/apps/testapp/transactions.xml").to_return(:body => stub)
90
- @client.transaction_list('testapp').should == [
91
- {:id => '1', :name => 'app.increment', :description => 'spawn new instance of app', :state => 'started', :status => nil},
92
- {:id => '2', :name => 'app.deploy', :description => 'deploy code', :state => 'ready', :status => nil}
93
- ]
94
- end
95
-
96
- it "lists details of a transaction" do
97
- stub = %{
98
- <?xml version='1.0' encoding='UTF-8'?>
99
- <transaction>
100
- <id>1</id>
101
- <name>app.increment</name>
102
- <description>spawn new instance of app</description>
103
- <state>started</state>
104
- <status></status>
105
- </transaction>
106
- }
107
- stub_api_request(:get, "/apps/testapp/transactions/123.xml").to_return(:body => stub)
108
- @client.transaction_status('testapp', '123').should == {:id => '1', :name => 'app.increment', :description => 'spawn new instance of app', :state => 'started', :status => nil}
109
- end
110
-
111
- it "deploys" do
112
- stub = %{
113
- <?xml version='1.0' encoding='UTF-8'?>
114
- <transaction>
115
- <id>1</id>
116
- <name>app.deploy</name>
117
- <description>deploy new code</description>
118
- <state>started</state>
119
- <status></status>
120
- </transaction>
121
- }
122
- stub_api_request(:put, "/apps/testapp/deploy.xml").to_return(:body => stub)
123
- @client.deploy('testapp').should == {:id => '1', :name => 'app.deploy', :description => 'deploy new code', :state => 'started', :status => nil}
124
- end
125
-
126
- it "rewinds deploy list" do
127
- stub = %{
128
- <?xml version='1.0' encoding='UTF-8'?>
129
- <transaction>
130
- <id>1</id>
131
- <name>app.traverse</name>
132
- <description>traverse the code</description>
133
- <state>started</state>
134
- <status></status>
135
- </transaction>
136
- }
137
- stub_api_request(:put, "/apps/testapp/rewind.xml").to_return(:body => stub)
138
- @client.rewind('testapp', 1).should == {:id => '1', :name => 'app.traverse', :description => 'traverse the code', :state => 'started', :status => nil}
139
- end
140
-
141
- it "fast-forwards deploy list" do
142
- stub = %{
143
- <?xml version='1.0' encoding='UTF-8'?>
144
- <transaction>
145
- <id>1</id>
146
- <name>app.traverse</name>
147
- <description>traverse the code</description>
148
- <state>started</state>
149
- <status></status>
150
- </transaction>
151
- }
152
- stub_api_request(:put, "/apps/testapp/fast-forward.xml").to_return(:body => stub)
153
- @client.fast_forward('testapp', 1).should == {:id => '1', :name => 'app.traverse', :description => 'traverse the code', :state => 'started', :status => nil}
154
- end
155
-
156
- it "scales up" do
157
- stub = %{
158
- <?xml version='1.0' encoding='UTF-8'?>
159
- <transaction>
160
- <id>1</id>
161
- <name>app.scaleup</name>
162
- <description>scaling app</description>
163
- <state>started</state>
164
- <status></status>
165
- </transaction>
166
- }
167
- stub_api_request(:put, "/apps/testapp/scale-up.xml").to_return(:body => stub)
168
- @client.scale_up('testapp', 1).should == {:id => '1', :name => 'app.scaleup', :description => 'scaling app', :state => 'started', :status => nil}
169
- end
170
-
171
- it "scales down" do
172
- stub = %{
173
- <?xml version='1.0' encoding='UTF-8'?>
174
- <transaction>
175
- <id>1</id>
176
- <name>app.scaledown</name>
177
- <description>scaling app</description>
178
- <state>started</state>
179
- <status></status>
180
- </transaction>
181
- }
182
- stub_api_request(:put, "/apps/testapp/scale-down.xml").to_return(:body => stub)
183
- @client.scale_down('testapp', 1).should == {:id => '1', :name => 'app.scaledown', :description => 'scaling app', :state => 'started', :status => nil}
184
- end
185
-
186
- end
187
-
188
- describe "user" do
189
-
190
- it "should list all active apps" do
191
- stub = %{
192
- <?xml version='1.0' encoding='UTF-8'?>
193
- <apps type="array">
194
- <app>
195
- <id>1</id>
196
- <name>burt</name>
197
- <git-url>git@github.com:tylerflint/pagoda-pilot.git</git-url>
198
- </app>
199
- <app>
200
- <id>2</id>
201
- <name>ernie</name>
202
- <git-url>git@github.com:tylerflint/pagoda-pilot.git</git-url>
203
- </app>
204
- </apps>
205
- }
206
- stub_api_request(:get, "/apps.xml").to_return(:body => stub)
207
- @client.app_list.should == [{:id => '1', :name => 'burt', :git_url => 'git@github.com:tylerflint/pagoda-pilot.git'}, {:id => '2', :name => 'ernie', :git_url => 'git@github.com:tylerflint/pagoda-pilot.git'}]
208
- end
209
-
210
- it "should create a new app" do
211
- stub = %{
212
- <?xml version='1.0' encoding='UTF-8'?>
213
- <app>
214
- <name>testapp</name>
215
- <git-url>git@github.com:tylerflint/pagoda-pilot.git</git-url>
216
- <owner>
217
- <username>tylerflint</username>
218
- <email>tylerflint@gmail.com</email>
219
- </owner>
220
- <collaborators>
221
- </collaborators>
222
- <transactions type="array">
223
- <transaction>
224
- <id>1</id>
225
- <name>app.init</name>
226
- <description>Deploying app to the Pagoda grid</description>
227
- <state>started</state>
228
- <status></status>
229
- </transaction>
230
- </transactions>
231
- </app>
232
- }
233
- stub_api_request(:post, '/apps.xml').with(:body => "app[name]=testapp&app[git_url]=git%40github.com%3Atylerflint%2Fpagoda-pilot.git").to_return(:body => stub)
234
- @client.app_create('testapp', 'git@github.com:tylerflint/pagoda-pilot.git').should == {
235
- :name => 'testapp',
236
- :git_url => 'git@github.com:tylerflint/pagoda-pilot.git',
237
- :owner => {
238
- :username => 'tylerflint',
239
- :email => 'tylerflint@gmail.com'
240
- },
241
- :collaborators => [],
242
- :transactions => [
243
- {:id => '1', :name => 'app.init', :description => 'Deploying app to the Pagoda grid', :state => 'started', :status => nil}
244
- ]
245
- }
246
- end
247
-
248
- it "should destroy an active app" do
249
- stub_api_request(:delete, '/apps/testapp.xml')
250
- @client.app_destroy('testapp')
251
- end
252
-
253
- end
254
-
255
- end
data/spec/command_spec.rb DELETED
@@ -1,26 +0,0 @@
1
-
2
- describe Pagoda::Command do
3
-
4
- it "extracts error messages from response when available in XML" do
5
- Pagoda::Command.extract_error('<errors><error>Invalid app name</error></errors>').should == ' ! Invalid app name'
6
- end
7
-
8
- it "shows Internal Server Error when the response doesn't contain a XML" do
9
- Pagoda::Command.extract_error('<h1>HTTP 500</h1>').should == ' ! Internal server error'
10
- end
11
-
12
- it "handles a nil body in parse_error_xml" do
13
- lambda { Pagoda::Command.parse_error_xml(nil) }.should_not raise_error
14
- end
15
-
16
- it "correctly resolves commands" do
17
- class Pagoda::Command::Test; end
18
- class Pagoda::Command::Test::Multiple; end
19
-
20
- Pagoda::Command.parse("foo").should == [ Pagoda::Command::App, :foo ]
21
- Pagoda::Command.parse("test").should == [ Pagoda::Command::Test, :index ]
22
- Pagoda::Command.parse("test:foo").should == [ Pagoda::Command::Test, :foo ]
23
- Pagoda::Command.parse("test:multiple:foo").should == [ Pagoda::Command::Test::Multiple, :foo ]
24
- end
25
-
26
- end
@@ -1,57 +0,0 @@
1
- module Pagoda::Command
2
- describe Auth do
3
- before do
4
- @cli = prepare_command(Auth)
5
- @sandbox = "#{Dir.tmpdir}/cli_spec_#{Process.pid}"
6
- File.open(@sandbox, "w") { |f| f.write "user\npass\n" }
7
- @cli.stub!(:credentials_file).and_return(@sandbox)
8
- @cli.stub!(:running_on_a_mac?).and_return(false)
9
- end
10
-
11
- after do
12
- FileUtils.rm_rf(@sandbox)
13
- end
14
-
15
- it "reads credentials from the credentials file" do
16
- @cli.read_credentials.should == %w(user pass)
17
- end
18
-
19
- it "takes the user from the first line and the password from the second line" do
20
- @cli.user.should == 'user'
21
- @cli.password.should == 'pass'
22
- end
23
-
24
- it "asks for credentials when the file doesn't exist" do
25
- FileUtils.rm_rf(@sandbox)
26
- @cli.should_receive(:ask_for_credentials).and_return([ 'u', 'p'])
27
- @cli.should_receive(:save_credentials)
28
- @cli.get_credentials.should == [ 'u', 'p' ]
29
- end
30
-
31
- it "writes the credentials to a file" do
32
- @cli.stub!(:credentials).and_return(['one', 'two'])
33
- @cli.should_receive(:set_credentials_permissions)
34
- @cli.write_credentials
35
- File.read(@sandbox).should == "one\ntwo\n"
36
- end
37
-
38
- it "sets ~/.pagoda/credentials to be readable only by the user" do
39
- unless RUBY_PLATFORM =~ /mswin32|mingw32/
40
- sandbox = "#{Dir.tmpdir}/cli_spec_#{Process.pid}"
41
- FileUtils.rm_rf(sandbox)
42
- FileUtils.mkdir_p(sandbox)
43
- fname = "#{sandbox}/file"
44
- system "touch #{fname}"
45
- @cli.stub!(:credentials_file).and_return(fname)
46
- @cli.set_credentials_permissions
47
- File.stat(sandbox).mode.should == 040700
48
- File.stat(fname).mode.should == 0100600
49
- end
50
- end
51
-
52
- it "deletes the credentials file" do
53
- FileUtils.should_receive(:rm_f).with(@cli.credentials_file)
54
- @cli.delete_credentials
55
- end
56
- end
57
- end