caracara 0.3.1 → 0.4.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 +1 -1
- data/lib/caracara/task.rb +34 -8
- data/lib/caracara/version.rb +1 -1
- data/spec/caracara/task_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38f11b7e5046f36a5e073b2121fd0092e112db24
|
4
|
+
data.tar.gz: 19139ef72f333155cd5e557e6e2dd0853e64a14b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8759b163b1139a15b127feb70edcdd1bc49f8942b9fb492555281e3c813d8ec0436d88f65f977934b08c70a86b7c8efa14cdf166f64c548cc38c0df5b030f375
|
7
|
+
data.tar.gz: 6184d8f96e7b0d20d2e034168faea6754959e95795ccf3210263fdd61cbb5ccc65649d29dcf653012593784a8a02265a6c55448d86001f6fda12d7429c7d0e82
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Caracara [](https://travis-ci.org/gabrielcorado/caracara)
|
1
|
+
# Caracara [](https://travis-ci.org/gabrielcorado/caracara) [](http://badge.fury.io/rb/caracara)
|
2
2
|
Task runner based on [Envoy](http://laravel.com/docs/5.1/envoy) and [Mina](http://mina-deploy.github.io/mina/)
|
3
3
|
|
4
4
|
# Concepts
|
data/lib/caracara/task.rb
CHANGED
@@ -5,9 +5,13 @@ module Caracara
|
|
5
5
|
# Task steps
|
6
6
|
@steps = []
|
7
7
|
|
8
|
+
# Fixed options
|
9
|
+
@fixed_options = {}
|
10
|
+
|
8
11
|
# Initialize
|
9
|
-
def initialize(steps, args = {})
|
12
|
+
def initialize(steps, fixed_options = {}, args = {})
|
10
13
|
@steps = steps
|
14
|
+
@fixed_options = fixed_options
|
11
15
|
@options = args
|
12
16
|
end
|
13
17
|
|
@@ -22,7 +26,10 @@ module Caracara
|
|
22
26
|
options = @options.merge args
|
23
27
|
|
24
28
|
# Each the steps
|
25
|
-
@steps.map do |step|
|
29
|
+
@steps.map.with_index do |step, index|
|
30
|
+
# Append with the fixed options
|
31
|
+
options = options.merge(@fixed_options[index]) unless @fixed_options[index].nil?
|
32
|
+
|
26
33
|
# Compile the mustache template
|
27
34
|
Mustache.render step, options
|
28
35
|
end
|
@@ -35,8 +42,8 @@ module Caracara
|
|
35
42
|
|
36
43
|
# Static methods
|
37
44
|
class << self
|
38
|
-
#
|
39
|
-
attr_reader :steps
|
45
|
+
# Static attributes
|
46
|
+
attr_reader :steps, :fixed_options
|
40
47
|
|
41
48
|
# Run steps inside a dir
|
42
49
|
def dir(name, &blk)
|
@@ -54,23 +61,42 @@ module Caracara
|
|
54
61
|
end
|
55
62
|
|
56
63
|
# Add a step
|
57
|
-
def step(cmd)
|
64
|
+
def step(cmd, fixed_options = {})
|
58
65
|
# Define the step
|
59
66
|
@steps = [] if @steps.nil?
|
60
67
|
|
68
|
+
# Define the step
|
69
|
+
@fixed_options = {} if @fixed_options.nil?
|
70
|
+
|
61
71
|
# Add a new step
|
62
|
-
|
72
|
+
if cmd.is_a?(String)
|
73
|
+
# Push step and get the index
|
74
|
+
index = @steps.push(cmd).length - 1
|
75
|
+
|
76
|
+
# Add fixed options
|
77
|
+
@fixed_options[index] = fixed_options
|
78
|
+
|
79
|
+
# Default return
|
80
|
+
return @steps
|
81
|
+
end
|
63
82
|
|
64
83
|
# If it is another task
|
65
84
|
cmd.steps.each do |task_cmd|
|
66
|
-
|
85
|
+
# Push and get the index
|
86
|
+
index = @steps.push(task_cmd).length - 1
|
87
|
+
|
88
|
+
# Add fixed options
|
89
|
+
@fixed_options[index] = fixed_options
|
67
90
|
end
|
91
|
+
|
92
|
+
# Default return
|
93
|
+
@steps
|
68
94
|
end
|
69
95
|
|
70
96
|
# Initialize a task
|
71
97
|
def init(args = {})
|
72
98
|
# Create a new instance
|
73
|
-
new @steps, args
|
99
|
+
new @steps, @fixed_options, args
|
74
100
|
end
|
75
101
|
end
|
76
102
|
end
|
data/lib/caracara/version.rb
CHANGED
data/spec/caracara/task_spec.rb
CHANGED
@@ -10,7 +10,7 @@ class TaskSpec < Caracara::Task
|
|
10
10
|
step SharedTask
|
11
11
|
|
12
12
|
step 'mkdir {{folder.name}}/'
|
13
|
-
step 'chown -R {{user}} {{folder.name}}'
|
13
|
+
step 'chown -R {{user}} {{folder.name}}', user: 'forcedUser'
|
14
14
|
step 'chmod -R {{folder.permission}} {{folder.name}}/'
|
15
15
|
|
16
16
|
dir '{{folder.name}}' do
|
@@ -50,7 +50,7 @@ describe 'Task' do
|
|
50
50
|
# Assertions
|
51
51
|
expect(steps[0]).to eq("echo \"Im doing some tasks with Caracara\"")
|
52
52
|
expect(steps[1]).to eq('mkdir niceFolder/')
|
53
|
-
expect(steps[2]).to eq('chown -R
|
53
|
+
expect(steps[2]).to eq('chown -R forcedUser niceFolder')
|
54
54
|
expect(steps[3]).to eq('chmod -R 755 niceFolder/')
|
55
55
|
expect(steps[4]).to eq("(cd niceFolder && (echo \"Im doing some tasks with Caracara\"\\necho \"Some nice text!\" > file.txt))")
|
56
56
|
end
|
@@ -66,7 +66,7 @@ describe 'Task' do
|
|
66
66
|
# Assertions
|
67
67
|
expect(steps[0]).to eq("echo \"Im doing some tasks with Caracara\"")
|
68
68
|
expect(steps[1]).to eq('mkdir argsFolder/')
|
69
|
-
expect(steps[2]).to eq('chown -R
|
69
|
+
expect(steps[2]).to eq('chown -R forcedUser argsFolder')
|
70
70
|
expect(steps[3]).to eq('chmod -R 655 argsFolder/')
|
71
71
|
expect(steps[4]).to eq("(cd argsFolder && (echo \"Im doing some tasks with Caracara\"\\necho \"Some nice text!\" > file.txt))")
|
72
72
|
end
|
@@ -76,6 +76,6 @@ describe 'Task' do
|
|
76
76
|
command = task.command
|
77
77
|
|
78
78
|
# Assertions
|
79
|
-
expect(command).to eq("echo\\ \\\"Im\\ doing\\ some\\ tasks\\ with\\ Caracara\\\"'\n'mkdir\\ niceFolder/'\n'chown\\ -R\\
|
79
|
+
expect(command).to eq("echo\\ \\\"Im\\ doing\\ some\\ tasks\\ with\\ Caracara\\\"'\n'mkdir\\ niceFolder/'\n'chown\\ -R\\ forcedUser\\ niceFolder'\n'chmod\\ -R\\ 755\\ niceFolder/'\n'\\(cd\\ niceFolder\\ \\&\\&\\ \\(echo\\ \\\"Im\\ doing\\ some\\ tasks\\ with\\ Caracara\\\"\\\\necho\\ \\\"Some\\ nice\\ text\\!\\\"\\ \\>\\ file.txt\\)\\)")
|
80
80
|
end
|
81
81
|
end
|