caracara 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -1
- data/lib/caracara/group.rb +2 -2
- data/lib/caracara/task.rb +3 -2
- data/lib/caracara/utils.rb +15 -0
- data/lib/caracara/version.rb +1 -1
- data/lib/caracara.rb +1 -0
- data/spec/caracara/utils_spec.rb +47 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab96b125ff43b99cabeb03ac79df39650ac0450d
|
4
|
+
data.tar.gz: 792bb59a52125237feb0ec0338e0b342d0d0f3ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 414c81ea3959f9cfdca06fba6e779babad9c099c87cc2a06961534fda43da645d4c66b4d874f39398417e2df62a065d343f7cc265f7ac774efd6017a5bd456ac
|
7
|
+
data.tar.gz: 07320448213273898f202449443cbda54127a1b587ebdb4afdf162830904d1b4d93f2804b305ef37f8882408a441f13f1362969dde5a799301836e3c6bbb8c42
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -72,9 +72,14 @@ deploy = DeployGroup.init options
|
|
72
72
|
commands = deploy.compile_all
|
73
73
|
```
|
74
74
|
|
75
|
+
**Generate the SSH Command**
|
76
|
+
```ruby
|
77
|
+
ssh_command = Caracara::SSH.generate 'user', 'localhost', commands
|
78
|
+
```
|
79
|
+
|
75
80
|
**Run the command in your server**
|
76
81
|
```ruby
|
77
|
-
Caracara::SSH.exec
|
82
|
+
Caracara::SSH.exec ssh_command
|
78
83
|
```
|
79
84
|
|
80
85
|
# Development
|
data/lib/caracara/group.rb
CHANGED
@@ -14,7 +14,7 @@ module Caracara
|
|
14
14
|
# Compile the tasks
|
15
15
|
def compile(name, options = {})
|
16
16
|
# Set options
|
17
|
-
options =
|
17
|
+
options = Utils.merge @options, options
|
18
18
|
|
19
19
|
# Get the tasks
|
20
20
|
task = @tasks[name]
|
@@ -35,7 +35,7 @@ module Caracara
|
|
35
35
|
# Generate the SSH command
|
36
36
|
def command(name, options = {}, ssh_command = true, escape = true)
|
37
37
|
# Set options
|
38
|
-
options =
|
38
|
+
options = Utils.merge @options, options
|
39
39
|
|
40
40
|
# Generate task command
|
41
41
|
task = @tasks[name].command options, false
|
data/lib/caracara/task.rb
CHANGED
@@ -23,12 +23,13 @@ module Caracara
|
|
23
23
|
# Compile the tasks
|
24
24
|
def compile(args = {})
|
25
25
|
# Merge args with defult options
|
26
|
-
options =
|
26
|
+
options = Utils.merge @options, args
|
27
27
|
|
28
28
|
# Each the steps
|
29
29
|
@steps.map.with_index do |step, index|
|
30
30
|
# Append with the fixed options
|
31
|
-
options = options.merge(@fixed_options[index]) unless @fixed_options[index].nil?
|
31
|
+
# options = options.merge(@fixed_options[index]) unless @fixed_options[index].nil?
|
32
|
+
options = Utils.merge(options, @fixed_options[index]) unless @fixed_options[index].nil?
|
32
33
|
|
33
34
|
# Compile the mustache template
|
34
35
|
Mustache.render step, options
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
module Caracara
|
3
|
+
module Utils
|
4
|
+
# Merge the options in an intelligent way
|
5
|
+
def self.merge(a, b)
|
6
|
+
a.merge(b) do |key, oldval, newval|
|
7
|
+
# Return if both of the values are Hash instances
|
8
|
+
next merge(oldval, newval) if oldval.is_a?(Hash) && newval.is_a?(Hash)
|
9
|
+
|
10
|
+
# Return the value
|
11
|
+
newval
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/caracara/version.rb
CHANGED
data/lib/caracara.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Include the helper
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
# Tests
|
5
|
+
describe 'Utils' do
|
6
|
+
context 'merge method' do
|
7
|
+
# Define the first array
|
8
|
+
let(:first) {
|
9
|
+
{
|
10
|
+
a: 1,
|
11
|
+
b: {
|
12
|
+
c: 2,
|
13
|
+
d: 3
|
14
|
+
},
|
15
|
+
e: {
|
16
|
+
f: 4,
|
17
|
+
g: 5
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
# Define the second array
|
23
|
+
let(:second) {
|
24
|
+
{
|
25
|
+
b: {
|
26
|
+
c: 15,
|
27
|
+
abc: '123'
|
28
|
+
},
|
29
|
+
e: {
|
30
|
+
g: 35
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
it 'should merge to arrays perfectly' do
|
36
|
+
# Merge first -> second
|
37
|
+
first_merge_result = Caracara::Utils.merge first, second
|
38
|
+
|
39
|
+
# Merge second -> first
|
40
|
+
second_merge_result = Caracara::Utils.merge second, first
|
41
|
+
|
42
|
+
# Assertions
|
43
|
+
expect(first_merge_result).to eq({a: 1, b: {abc: '123', c: 15, d: 3}, e: {f: 4, g: 35}})
|
44
|
+
expect(second_merge_result).to eq({b: {c: 2, abc: '123', d: 3}, e: {g: 5, f: 4}, a: 1})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caracara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Corado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mustache
|
@@ -55,10 +55,12 @@ files:
|
|
55
55
|
- lib/caracara/group.rb
|
56
56
|
- lib/caracara/ssh.rb
|
57
57
|
- lib/caracara/task.rb
|
58
|
+
- lib/caracara/utils.rb
|
58
59
|
- lib/caracara/version.rb
|
59
60
|
- spec/caracara/group_spec.rb
|
60
61
|
- spec/caracara/ssh_spec.rb
|
61
62
|
- spec/caracara/task_spec.rb
|
63
|
+
- spec/caracara/utils_spec.rb
|
62
64
|
- spec/spec_helper.rb
|
63
65
|
homepage: http://github.com/gabrielcorado/caracara
|
64
66
|
licenses: []
|