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.
- data/Manifest +88 -4
- data/PostInstall.txt +42 -9
- data/README.rdoc +6 -0
- data/Rakefile +16 -19
- data/assets/webbynode.png +0 -0
- data/bin/webbynode +3 -3
- data/bin/wn +7 -0
- data/cucumber.yml +1 -0
- data/devver.rake +174 -0
- data/features/bootstrap.feature +17 -0
- data/features/step_definitions/command_steps.rb +14 -0
- data/features/support/env.rb +22 -0
- data/features/support/hooks.rb +8 -0
- data/{test/test_webbynode.rb → features/support/io_features.rb} +0 -0
- data/features/support/mocha.rb +15 -0
- data/lib/templates/api_token +14 -0
- data/lib/templates/backup +15 -0
- data/lib/templates/gitignore +4 -0
- data/lib/templates/help +53 -0
- data/lib/webbynode/api_client.rb +121 -0
- data/lib/webbynode/application.rb +21 -0
- data/lib/webbynode/command.rb +332 -0
- data/lib/webbynode/commands/add_backup.rb +33 -0
- data/lib/webbynode/commands/add_key.rb +24 -0
- data/lib/webbynode/commands/alias.rb +153 -0
- data/lib/webbynode/commands/change_dns.rb +29 -0
- data/lib/webbynode/commands/config.rb +15 -0
- data/lib/webbynode/commands/delete.rb +25 -0
- data/lib/webbynode/commands/help.rb +25 -0
- data/lib/webbynode/commands/init.rb +77 -0
- data/lib/webbynode/commands/push.rb +70 -0
- data/lib/webbynode/commands/remote.rb +28 -0
- data/lib/webbynode/commands/restart.rb +25 -0
- data/lib/webbynode/commands/start.rb +23 -0
- data/lib/webbynode/commands/stop.rb +23 -0
- data/lib/webbynode/commands/tasks.rb +149 -0
- data/lib/webbynode/commands/version.rb +8 -0
- data/lib/webbynode/commands/webbies.rb +30 -0
- data/lib/webbynode/git.rb +112 -0
- data/lib/webbynode/io.rb +175 -0
- data/lib/webbynode/notify.rb +19 -0
- data/lib/webbynode/option.rb +84 -0
- data/lib/webbynode/parameter.rb +27 -0
- data/lib/webbynode/properties.rb +43 -0
- data/lib/webbynode/push_and.rb +16 -0
- data/lib/webbynode/remote_executor.rb +21 -0
- data/lib/webbynode/server.rb +39 -0
- data/lib/webbynode/ssh.rb +65 -0
- data/lib/webbynode/ssh_keys.rb +36 -0
- data/lib/webbynode.rb +56 -0
- data/spec/fixtures/aliases +0 -0
- data/spec/fixtures/api/credentials +3 -0
- data/spec/fixtures/api/dns +30 -0
- data/spec/fixtures/api/dns_a_record +20 -0
- data/spec/fixtures/api/dns_a_record_already_exists +15 -0
- data/spec/fixtures/api/dns_a_record_error +13 -0
- data/spec/fixtures/api/dns_new_zone +17 -0
- data/spec/fixtures/api/webbies +26 -0
- data/spec/fixtures/api/webbies_unauthorized +12 -0
- data/spec/fixtures/api/webby +6 -0
- data/spec/fixtures/commands/tasks/after_push +3 -0
- data/spec/fixtures/fixture_helpers +2 -0
- data/spec/fixtures/git/config/210.11.13.12 +9 -0
- data/spec/fixtures/git/config/67.23.79.31 +9 -0
- data/spec/fixtures/git/config/67.23.79.32 +9 -0
- data/spec/fixtures/git/config/config +9 -0
- data/spec/fixtures/git/status/clean +2 -0
- data/spec/fixtures/git/status/dirty +9 -0
- data/spec/fixtures/pushand +2 -0
- data/spec/spec_helper.rb +58 -0
- data/spec/webbynode/api_client_spec.rb +227 -0
- data/spec/webbynode/application_spec.rb +50 -0
- data/spec/webbynode/command_spec.rb +285 -0
- data/spec/webbynode/commands/add_backup_spec.rb +66 -0
- data/spec/webbynode/commands/add_key_spec.rb +58 -0
- data/spec/webbynode/commands/alias_spec.rb +213 -0
- data/spec/webbynode/commands/change_dns_spec.rb +51 -0
- data/spec/webbynode/commands/config_spec.rb +22 -0
- data/spec/webbynode/commands/delete_spec.rb +78 -0
- data/spec/webbynode/commands/help_spec.rb +43 -0
- data/spec/webbynode/commands/init_spec.rb +326 -0
- data/spec/webbynode/commands/push_spec.rb +175 -0
- data/spec/webbynode/commands/remote_spec.rb +76 -0
- data/spec/webbynode/commands/tasks_spec.rb +288 -0
- data/spec/webbynode/commands/version_spec.rb +18 -0
- data/spec/webbynode/commands/webbies_spec.rb +27 -0
- data/spec/webbynode/git_spec.rb +310 -0
- data/spec/webbynode/io_spec.rb +198 -0
- data/spec/webbynode/option_spec.rb +48 -0
- data/spec/webbynode/parameter_spec.rb +70 -0
- data/spec/webbynode/push_and_spec.rb +28 -0
- data/spec/webbynode/remote_executor_spec.rb +25 -0
- data/spec/webbynode/server_spec.rb +101 -0
- data/webbynode.gemspec +25 -16
- metadata +182 -14
- data/lib/wn.rb +0 -106
- data/test/test_helper.rb +0 -9
- 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
|