webbynode 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of webbynode might be problematic. Click here for more details.

Files changed (98) hide show
  1. data/Manifest +88 -4
  2. data/PostInstall.txt +42 -9
  3. data/README.rdoc +6 -0
  4. data/Rakefile +16 -19
  5. data/assets/webbynode.png +0 -0
  6. data/bin/webbynode +3 -3
  7. data/bin/wn +7 -0
  8. data/cucumber.yml +1 -0
  9. data/devver.rake +174 -0
  10. data/features/bootstrap.feature +17 -0
  11. data/features/step_definitions/command_steps.rb +14 -0
  12. data/features/support/env.rb +22 -0
  13. data/features/support/hooks.rb +8 -0
  14. data/{test/test_webbynode.rb → features/support/io_features.rb} +0 -0
  15. data/features/support/mocha.rb +15 -0
  16. data/lib/templates/api_token +14 -0
  17. data/lib/templates/backup +15 -0
  18. data/lib/templates/gitignore +4 -0
  19. data/lib/templates/help +53 -0
  20. data/lib/webbynode/api_client.rb +121 -0
  21. data/lib/webbynode/application.rb +21 -0
  22. data/lib/webbynode/command.rb +332 -0
  23. data/lib/webbynode/commands/add_backup.rb +33 -0
  24. data/lib/webbynode/commands/add_key.rb +24 -0
  25. data/lib/webbynode/commands/alias.rb +153 -0
  26. data/lib/webbynode/commands/change_dns.rb +29 -0
  27. data/lib/webbynode/commands/config.rb +15 -0
  28. data/lib/webbynode/commands/delete.rb +25 -0
  29. data/lib/webbynode/commands/help.rb +25 -0
  30. data/lib/webbynode/commands/init.rb +77 -0
  31. data/lib/webbynode/commands/push.rb +70 -0
  32. data/lib/webbynode/commands/remote.rb +28 -0
  33. data/lib/webbynode/commands/restart.rb +25 -0
  34. data/lib/webbynode/commands/start.rb +23 -0
  35. data/lib/webbynode/commands/stop.rb +23 -0
  36. data/lib/webbynode/commands/tasks.rb +149 -0
  37. data/lib/webbynode/commands/version.rb +8 -0
  38. data/lib/webbynode/commands/webbies.rb +30 -0
  39. data/lib/webbynode/git.rb +112 -0
  40. data/lib/webbynode/io.rb +175 -0
  41. data/lib/webbynode/notify.rb +19 -0
  42. data/lib/webbynode/option.rb +84 -0
  43. data/lib/webbynode/parameter.rb +27 -0
  44. data/lib/webbynode/properties.rb +43 -0
  45. data/lib/webbynode/push_and.rb +16 -0
  46. data/lib/webbynode/remote_executor.rb +21 -0
  47. data/lib/webbynode/server.rb +39 -0
  48. data/lib/webbynode/ssh.rb +65 -0
  49. data/lib/webbynode/ssh_keys.rb +36 -0
  50. data/lib/webbynode.rb +56 -0
  51. data/spec/fixtures/aliases +0 -0
  52. data/spec/fixtures/api/credentials +3 -0
  53. data/spec/fixtures/api/dns +30 -0
  54. data/spec/fixtures/api/dns_a_record +20 -0
  55. data/spec/fixtures/api/dns_a_record_already_exists +15 -0
  56. data/spec/fixtures/api/dns_a_record_error +13 -0
  57. data/spec/fixtures/api/dns_new_zone +17 -0
  58. data/spec/fixtures/api/webbies +26 -0
  59. data/spec/fixtures/api/webbies_unauthorized +12 -0
  60. data/spec/fixtures/api/webby +6 -0
  61. data/spec/fixtures/commands/tasks/after_push +3 -0
  62. data/spec/fixtures/fixture_helpers +2 -0
  63. data/spec/fixtures/git/config/210.11.13.12 +9 -0
  64. data/spec/fixtures/git/config/67.23.79.31 +9 -0
  65. data/spec/fixtures/git/config/67.23.79.32 +9 -0
  66. data/spec/fixtures/git/config/config +9 -0
  67. data/spec/fixtures/git/status/clean +2 -0
  68. data/spec/fixtures/git/status/dirty +9 -0
  69. data/spec/fixtures/pushand +2 -0
  70. data/spec/spec_helper.rb +58 -0
  71. data/spec/webbynode/api_client_spec.rb +227 -0
  72. data/spec/webbynode/application_spec.rb +50 -0
  73. data/spec/webbynode/command_spec.rb +285 -0
  74. data/spec/webbynode/commands/add_backup_spec.rb +66 -0
  75. data/spec/webbynode/commands/add_key_spec.rb +58 -0
  76. data/spec/webbynode/commands/alias_spec.rb +213 -0
  77. data/spec/webbynode/commands/change_dns_spec.rb +51 -0
  78. data/spec/webbynode/commands/config_spec.rb +22 -0
  79. data/spec/webbynode/commands/delete_spec.rb +78 -0
  80. data/spec/webbynode/commands/help_spec.rb +43 -0
  81. data/spec/webbynode/commands/init_spec.rb +326 -0
  82. data/spec/webbynode/commands/push_spec.rb +175 -0
  83. data/spec/webbynode/commands/remote_spec.rb +76 -0
  84. data/spec/webbynode/commands/tasks_spec.rb +288 -0
  85. data/spec/webbynode/commands/version_spec.rb +18 -0
  86. data/spec/webbynode/commands/webbies_spec.rb +27 -0
  87. data/spec/webbynode/git_spec.rb +310 -0
  88. data/spec/webbynode/io_spec.rb +198 -0
  89. data/spec/webbynode/option_spec.rb +48 -0
  90. data/spec/webbynode/parameter_spec.rb +70 -0
  91. data/spec/webbynode/push_and_spec.rb +28 -0
  92. data/spec/webbynode/remote_executor_spec.rb +25 -0
  93. data/spec/webbynode/server_spec.rb +101 -0
  94. data/webbynode.gemspec +25 -16
  95. metadata +182 -14
  96. data/lib/wn.rb +0 -106
  97. data/test/test_helper.rb +0 -9
  98. data/test/test_wn.rb +0 -220
data/test/test_wn.rb DELETED
@@ -1,220 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestWn < Test::Unit::TestCase
4
-
5
- def command(s)
6
- Wn::App.new(s.split(" "))
7
- end
8
-
9
- context "Parsing commands" do
10
- should "trigger the proper method" do
11
- app = command("init")
12
- app.expects(:init)
13
- app.run
14
-
15
- app = command("push")
16
- app.expects(:push)
17
- app.run
18
- end
19
-
20
- should "separate commands and parameters" do
21
- app = command("init myshot.com")
22
- app.command.should == "init"
23
- app.params.should == ["myshot.com"]
24
- end
25
- end
26
-
27
- context "File exists" do
28
- should "be true if file exists" do
29
- File.expects(:exists?).with(".pushand").returns(true)
30
- app = Wn::App.new(["abcdef"])
31
- app.file_exists(".pushand").should == true
32
- end
33
-
34
- should "be false if file exists" do
35
- File.expects(:exists?).with(".gitignore").returns(false)
36
- app = Wn::App.new(["abcdef"])
37
- app.file_exists(".gitignore").should == false
38
- end
39
- end
40
-
41
- context "Dir exists" do
42
- should "be true if dir exists" do
43
- File.expects(:directory?).with(".git").returns(true)
44
- app = Wn::App.new(["abcdef"])
45
- app.dir_exists(".git").should == true
46
-
47
- File.expects(:directory?).with(".gita").returns(false)
48
- app = Wn::App.new(["abcdef"])
49
- app.dir_exists(".gita").should == false
50
- end
51
- end
52
-
53
- context "Out" do
54
- app = Wn::App.new(["abcdef"])
55
- app.expects(:puts).with("help!")
56
- app.out "help!"
57
-
58
- app = Wn::App.new(["abcdef"])
59
- app.expects(:puts).with("help me!")
60
- app.out "help me!"
61
- end
62
-
63
- context "Create file" do
64
- should "create a file with the given contexts" do
65
- app = Wn::App.new(["abcdef"])
66
-
67
- file = mock("file")
68
- File.expects(:open).with("/var/rails/my_gosh", "w").yields(file)
69
- file.expects(:write).with("my\nfair\nlady")
70
- app.create_file "/var/rails/my_gosh", "my\nfair\nlady"
71
-
72
- file = mock("file")
73
- File.expects(:open).with("/var/rails/yahoo", "w").yields(file)
74
- file.expects(:write).with("another_brick_in_the_wall")
75
- app.create_file "/var/rails/yahoo", "another_brick_in_the_wall"
76
- end
77
- end
78
-
79
- context "Git init" do
80
- should "call git init and commit initial commit" do
81
- app = Wn::App.new(["abcdef"])
82
- app.expects(:sys_exec).with("git init")
83
-
84
- app.expects(:app_name).with().returns("my_app")
85
- app.expects(:sys_exec).with("git remote add webbynode git@2.2.3.3:my_app")
86
-
87
- app.expects(:sys_exec).with("git add .")
88
- app.expects(:sys_exec).with("git commit -m \"Initial commit\"")
89
-
90
- app.git_init "2.2.3.3"
91
-
92
- app = Wn::App.new(["abcdef"])
93
- app.expects(:sys_exec).with("git init")
94
-
95
- app.expects(:app_name).with().returns("another_app")
96
- app.expects(:sys_exec).with("git remote add webbynode git@5.4.2.1:another_app")
97
-
98
- app.expects(:sys_exec).with("git add .")
99
- app.expects(:sys_exec).with("git commit -m \"Initial commit\"")
100
-
101
- app.git_init "5.4.2.1"
102
- end
103
- end
104
-
105
- context "Push command" do
106
- should "push to webbynode master" do
107
- app = command("push")
108
- app.expects(:dir_exists).with(".git").returns(true)
109
- app.expects(:app_name).with().returns("another_app")
110
- app.expects(:out).with("Publishing another_app to Webbynode...")
111
- app.expects(:sys_exec).with("git push webbynode master")
112
- app.run
113
- end
114
-
115
- should "indicate not initialized" do
116
- app = command("push")
117
- app.expects(:dir_exists).with(".git").returns(false)
118
- app.expects(:out).with("Not an application or missing initialization. Use 'webbynode init'.")
119
- app.run
120
- end
121
- end
122
-
123
- context "Init command" do
124
- should "require one arguments" do
125
- app = command("init")
126
- app.expects(:out).with("usage: webbynode init webby_ip [host]")
127
- app.run
128
- end
129
-
130
- should "create .gitignore" do
131
- app = command("init 2.2.2.2 teste.myserver.com")
132
- app.expects(:out).with("Creating .gitignore file...")
133
- app.expects(:dir_exists).with(".git").times(2).returns(true)
134
- app.expects(:out).with("Adding Webbynode remote host to git...")
135
- app.expects(:file_exists).with(".pushand").returns(true)
136
- app.expects(:file_exists).with(".gitignore").returns(false)
137
- app.expects(:create_file).with(".gitignore", <<EOS)
138
- config/database.yml
139
- log/*
140
- tmp/*
141
- db/*.sqlite3
142
- EOS
143
-
144
- app.expects(:app_name).with().returns("teste.myserver.com")
145
- app.expects(:sys_exec).with("git remote add webbynode git@2.2.2.2:teste_myserver_com")
146
- app.expects(:sys_exec).with("git add .")
147
- app.expects(:sys_exec).with("git commit -m \"Initial commit\"")
148
-
149
- app.run
150
-
151
- app = command("init 2.2.2.2")
152
- app.expects(:out).with("Creating .gitignore file...")
153
- app.expects(:app_name).with().returns("myapp")
154
- app.expects(:dir_exists).with(".git").returns(true)
155
- app.expects(:file_exists).with(".pushand").returns(true)
156
- app.expects(:file_exists).with(".gitignore").returns(false)
157
- app.expects(:create_file).with(".gitignore", <<EOS)
158
- config/database.yml
159
- log/*
160
- tmp/*
161
- db/*.sqlite3
162
- EOS
163
- app.run
164
- end
165
-
166
- should "create .pushand with host if missing" do
167
- app = command("init 2.2.2.2 teste.myserver.com")
168
-
169
- app.expects(:dir_exists).with(".git").returns(false)
170
- app.expects(:out).with("Initializing git repository...")
171
- app.expects(:git_init).with("2.2.2.2")
172
-
173
- app.expects(:out).with("Initializing deployment descriptor for teste.myserver.com...")
174
- app.expects(:file_exists).with(".gitignore").returns(true)
175
- app.expects(:file_exists).with(".pushand").returns(false)
176
- app.expects(:sys_exec).with("chmod +x .pushand")
177
- app.expects(:create_file).with(".pushand", <<EOS)
178
- #! /bin/bash
179
- phd $0 teste.myserver.com
180
- EOS
181
- app.run
182
- end
183
-
184
- should "create .pushand with app name as the host if not specified" do
185
- app = command("init 3.3.3.3")
186
-
187
- app.expects(:dir_exists).with(".git").returns(true)
188
- app.expects(:out).with("Adding Webbynode remote host to git...")
189
- app.expects(:app_name).with().times(2).returns("myapp")
190
-
191
- app.expects(:sys_exec).with("git remote add webbynode git@3.3.3.3:myapp")
192
- app.expects(:sys_exec).with("git add .")
193
- app.expects(:sys_exec).with("git commit -m \"Initial commit\"")
194
-
195
- app.expects(:out).with("Initializing deployment descriptor for myapp...")
196
- app.expects(:file_exists).with(".gitignore").returns(true)
197
- app.expects(:file_exists).with(".pushand").returns(false)
198
- app.expects(:sys_exec).with("chmod +x .pushand")
199
- app.expects(:create_file).with(".pushand", <<EOS)
200
- #! /bin/bash
201
- phd $0 myapp
202
- EOS
203
- app.run
204
- end
205
-
206
- should "tell the app has already been initialized" do
207
- app = command("init 5.5.5.5 teste.myserver.com")
208
- app.expects(:dir_exists).times(2).with(".git").returns(true)
209
- app.expects(:file_exists).with(".pushand").returns(true)
210
- app.expects(:file_exists).with(".gitignore").returns(true)
211
- app.expects(:create_file).never
212
-
213
- app.expects(:sys_exec).with("git remote add webbynode git@5.5.5.5:webbynode")
214
- app.expects(:sys_exec).with("git add .")
215
- app.expects(:sys_exec).with("git commit -m \"Initial commit\"")
216
- app.run
217
- end
218
- end
219
-
220
- end