webbynode 1.0.1 → 1.0.2
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/Rakefile +1 -1
- data/lib/webbynode/api_client.rb +1 -1
- data/lib/webbynode/git.rb +16 -13
- data/lib/webbynode/io.rb +21 -3
- data/lib/webbynode/server.rb +1 -1
- data/lib/webbynode.rb +1 -1
- data/spec/webbynode/git_spec.rb +11 -1
- data/spec/webbynode/io_spec.rb +4 -2
- data/spec/webbynode/server_spec.rb +2 -2
- data/webbynode.gemspec +2 -2
- metadata +4 -4
data/Rakefile
CHANGED
data/lib/webbynode/api_client.rb
CHANGED
@@ -5,7 +5,7 @@ module Webbynode
|
|
5
5
|
include HTTParty
|
6
6
|
base_uri "https://manager.webbynode.com/api/yaml"
|
7
7
|
|
8
|
-
CREDENTIALS_FILE = "#{
|
8
|
+
CREDENTIALS_FILE = "#{Io.home_dir}/.webbynode"
|
9
9
|
|
10
10
|
Unauthorized = Class.new(StandardError)
|
11
11
|
InactiveZone = Class.new(StandardError)
|
data/lib/webbynode/git.rb
CHANGED
@@ -153,21 +153,24 @@ module Webbynode
|
|
153
153
|
|
154
154
|
private
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
156
|
+
def warning?(output)
|
157
|
+
output =~ /^warning: /
|
158
|
+
end
|
159
|
+
|
160
|
+
def exec(cmd, &blk)
|
161
|
+
handle_output io.exec(cmd), &blk
|
162
|
+
end
|
163
|
+
|
164
|
+
def handle_output(output, &blk)
|
165
|
+
raise GitNotRepoError, output if output =~ /Not a git repository/
|
162
166
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
true
|
167
|
+
if blk
|
168
|
+
raise GitError, output unless blk.call(output)
|
169
|
+
else
|
170
|
+
raise GitError, output unless output.nil? or output.empty? or warning?(output)
|
170
171
|
end
|
171
172
|
|
173
|
+
true
|
174
|
+
end
|
172
175
|
end
|
173
176
|
end
|
data/lib/webbynode/io.rb
CHANGED
@@ -10,10 +10,14 @@ module Webbynode
|
|
10
10
|
|
11
11
|
TemplatesPath = File.join(File.dirname(__FILE__), '..', 'templates')
|
12
12
|
|
13
|
-
def is_windows?
|
13
|
+
def self.is_windows?
|
14
14
|
Config::CONFIG["host_os"] =~ /mswin|mingw/
|
15
15
|
end
|
16
16
|
|
17
|
+
def is_windows?
|
18
|
+
Io.is_windows?
|
19
|
+
end
|
20
|
+
|
17
21
|
def exists_in_path?(file)
|
18
22
|
search_in_path { |f| File.exists?("#{f}/#{file}") }
|
19
23
|
end
|
@@ -136,9 +140,23 @@ module Webbynode
|
|
136
140
|
exit
|
137
141
|
end
|
138
142
|
|
143
|
+
def self.home_dir
|
144
|
+
if is_windows?
|
145
|
+
if ENV['USERPROFILE'].nil?
|
146
|
+
userdir = "C:/My Documents/"
|
147
|
+
else
|
148
|
+
userdir = ENV['USERPROFILE']
|
149
|
+
end
|
150
|
+
else
|
151
|
+
userdir = ENV['HOME'] unless ENV['HOME'].nil?
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
139
155
|
def create_local_key(passphrase="")
|
140
156
|
unless File.exists?(LocalSshKey)
|
141
|
-
|
157
|
+
mkdir File.dirname(LocalSshKey)
|
158
|
+
key_file = LocalSshKey.gsub(/\.pub$/, "")
|
159
|
+
exec "ssh-keygen -t rsa -N \"#{passphrase}\" -f \"#{key_file}\""
|
142
160
|
end
|
143
161
|
end
|
144
162
|
|
@@ -176,7 +194,7 @@ module Webbynode
|
|
176
194
|
end
|
177
195
|
|
178
196
|
def general_settings
|
179
|
-
@general_settings ||= properties("#{
|
197
|
+
@general_settings ||= properties("#{Io.home_dir}/.webbynode")
|
180
198
|
end
|
181
199
|
|
182
200
|
def with_settings_for(file, &blk)
|
data/lib/webbynode/server.rb
CHANGED
@@ -24,7 +24,7 @@ module Webbynode
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def add_ssh_key(key_file, passphrase="")
|
27
|
-
io.create_local_key(
|
27
|
+
io.create_local_key(passphrase) unless io.file_exists?(key_file)
|
28
28
|
remote_executor.create_folder("~/.ssh")
|
29
29
|
|
30
30
|
key_contents = io.read_file(key_file)
|
data/lib/webbynode.rb
CHANGED
data/spec/webbynode/git_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe Webbynode::Git do
|
|
31
31
|
should_raise_when_response Webbynode::GitNotRepoError, command,
|
32
32
|
"fatal: Not a git repository (or any of the parent directories): .git", &blk
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should have an io instance" do
|
36
36
|
pending "Check out why this is being mocked"
|
37
37
|
Webbynode::Git.new.io.class.should == Webbynode::Io
|
@@ -267,6 +267,16 @@ describe Webbynode::Git do
|
|
267
267
|
should_raise_giterror("git add something") { |git| git.add("something") }
|
268
268
|
end
|
269
269
|
end
|
270
|
+
|
271
|
+
|
272
|
+
it "raises no error when just a warning is issued" do
|
273
|
+
io_handler = mock("io")
|
274
|
+
io_handler.should_receive(:exec).with("git add .").and_return("warning: LF will be replaced by CRLF in public/placeholder")
|
275
|
+
|
276
|
+
git = Webbynode::Git.new
|
277
|
+
git.should_receive(:io).and_return(io_handler)
|
278
|
+
lambda { git.add "." }.should_not raise_error
|
279
|
+
end
|
270
280
|
end
|
271
281
|
|
272
282
|
describe "#commit" do
|
data/spec/webbynode/io_spec.rb
CHANGED
@@ -103,14 +103,16 @@ describe Webbynode::Io do
|
|
103
103
|
|
104
104
|
context "with no passphrase" do
|
105
105
|
it "should create the key with an empty passphrase" do
|
106
|
-
@io.should_receive(:
|
106
|
+
@io.should_receive(:mkdir).with(File.dirname(LocalSshKey))
|
107
|
+
@io.should_receive(:exec).with(%Q(ssh-keygen -t rsa -N "" -f "#{LocalSshKey.gsub(/\.pub$/, "")}")).and_return("")
|
107
108
|
@io.create_local_key
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
112
|
context "with a passphrase" do
|
112
113
|
it "should create the key with the provided passphrase" do
|
113
|
-
@io.should_receive(:
|
114
|
+
@io.should_receive(:mkdir).with(File.dirname(LocalSshKey))
|
115
|
+
@io.should_receive(:exec).with(%Q(ssh-keygen -t rsa -N "passphrase" -f "#{LocalSshKey.gsub(/\.pub$/, "")}")).and_return("")
|
114
116
|
@io.create_local_key("passphrase")
|
115
117
|
end
|
116
118
|
end
|
@@ -31,14 +31,14 @@ describe Webbynode::Server do
|
|
31
31
|
context "when unsuccessful" do
|
32
32
|
it "should create a local SSH key with empty passphrase" do
|
33
33
|
@io.should_receive(:file_exists?).with("xyz").and_return(false)
|
34
|
-
@io.should_receive(:create_local_key).with("
|
34
|
+
@io.should_receive(:create_local_key).with("")
|
35
35
|
|
36
36
|
@server.add_ssh_key "xyz"
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should create a local SSH key with the provided passphrase" do
|
40
40
|
@io.should_receive(:file_exists?).with("abc").and_return(false)
|
41
|
-
@io.should_receive(:create_local_key).with("
|
41
|
+
@io.should_receive(:create_local_key).with("my_passphrase")
|
42
42
|
|
43
43
|
@server.add_ssh_key "abc", "my_passphrase"
|
44
44
|
end
|
data/webbynode.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{webbynode}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Felipe Coury"]
|
9
|
-
s.date = %q{2010-08-
|
9
|
+
s.date = %q{2010-08-06}
|
10
10
|
s.description = %q{Webbynode Deployment Gem}
|
11
11
|
s.email = %q{felipe@webbynode.com}
|
12
12
|
s.executables = ["webbynode", "wn"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webbynode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Felipe Coury
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-06 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|