deployments 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +27 -0
- data/config/deployments.yml +2 -1
- data/lib/deployments/dispatcher.rb +12 -2
- data/lib/deployments/version.rb +1 -1
- data/spec/deployments_spec.rb +1 -1
- data/spec/dispatcher_spec.rb +25 -10
- metadata +1 -1
data/README.md
CHANGED
@@ -18,6 +18,33 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
If you are using Rails 2 version you should add load method to your Rakefile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
load "#{Gem.searcher.find('deployments').full_gem_path}/lib/tasks/deployments.rake"
|
25
|
+
```
|
26
|
+
|
27
|
+
At first you need to create in the config folder deployments.yml file with
|
28
|
+
line:
|
29
|
+
|
30
|
+
```yaml
|
31
|
+
options:
|
32
|
+
server: "your deployments server that will save build version"
|
33
|
+
```
|
34
|
+
|
35
|
+
Add to your capistrano recipes the next following line, changing your_app_env
|
36
|
+
to the deployment environment like 'staging' or 'development':
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'deployments'
|
40
|
+
|
41
|
+
before 'deploy' do
|
42
|
+
sh <<-CMD
|
43
|
+
rake deployments:push app_env=your_app_env
|
44
|
+
CMD
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
21
48
|
|
22
49
|
## Contributing
|
23
50
|
|
data/config/deployments.yml
CHANGED
@@ -9,7 +9,7 @@ module Deployments
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
c = Curl::Easy.http_post(Deployments.server, fields)
|
12
|
+
c = Curl::Easy.http_post(Deployments.options.server, fields)
|
13
13
|
|
14
14
|
c.response_code.to_i == 200
|
15
15
|
end
|
@@ -18,7 +18,17 @@ module Deployments
|
|
18
18
|
|
19
19
|
def fields
|
20
20
|
build.to_params.map do |key, value|
|
21
|
-
|
21
|
+
if value.is_a?(Array)
|
22
|
+
field_as_array(key, value)
|
23
|
+
else
|
24
|
+
Curl::PostField.content(key, value.to_s)
|
25
|
+
end
|
26
|
+
end.flatten
|
27
|
+
end
|
28
|
+
|
29
|
+
def field_as_array(key, value)
|
30
|
+
value.map do |v|
|
31
|
+
Curl::PostField.content("#{key}[]", v.to_s)
|
22
32
|
end
|
23
33
|
end
|
24
34
|
end
|
data/lib/deployments/version.rb
CHANGED
data/spec/deployments_spec.rb
CHANGED
data/spec/dispatcher_spec.rb
CHANGED
@@ -6,12 +6,33 @@ describe Dispatcher do
|
|
6
6
|
let(:build) { Build.new("staging") }
|
7
7
|
let(:dispatcher) { Dispatcher.new(build) }
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
before { build.should_receive(:to_params).and_return(fields) }
|
10
|
+
|
11
|
+
describe "request params" do
|
12
|
+
let(:response) { double('response', :response_code => 200) }
|
13
|
+
let(:fields) do
|
14
|
+
{
|
15
|
+
:username => "james.bond",
|
16
|
+
:params => ["fish", "cat"]
|
17
|
+
}
|
18
|
+
end
|
12
19
|
|
13
|
-
|
20
|
+
it "should have right params in request" do
|
21
|
+
Curl::Easy.should_receive(:http_post) do |url, fields|
|
22
|
+
url.should == Deployments.options.server
|
23
|
+
|
24
|
+
fields.count.should == 3
|
25
|
+
fields[0].should == "username=james.bond"
|
26
|
+
fields[1].should == "params[]=fish"
|
27
|
+
fields[2].should == "params[]=cat"
|
28
|
+
end.and_return(response)
|
29
|
+
|
30
|
+
dispatcher.run
|
14
31
|
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "post deployment data" do
|
35
|
+
before { Curl::Easy.should_receive(:http_post).and_return(response) }
|
15
36
|
|
16
37
|
context "with valid data" do
|
17
38
|
let(:response) { double('response', :response_code => 200) }
|
@@ -50,11 +71,5 @@ describe Dispatcher do
|
|
50
71
|
end
|
51
72
|
end
|
52
73
|
end
|
53
|
-
|
54
|
-
def curl_fields
|
55
|
-
fields.map do |key, value|
|
56
|
-
Curl::PostField.content(key, value)
|
57
|
-
end
|
58
|
-
end
|
59
74
|
end
|
60
75
|
|