caracara 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab96b125ff43b99cabeb03ac79df39650ac0450d
4
- data.tar.gz: 792bb59a52125237feb0ec0338e0b342d0d0f3ba
3
+ metadata.gz: 42a29332f3fa5bf0fe4401638b686036a7349990
4
+ data.tar.gz: 96464b4ae59be6cb174e9032723af4c9f1a91fc5
5
5
  SHA512:
6
- metadata.gz: 414c81ea3959f9cfdca06fba6e779babad9c099c87cc2a06961534fda43da645d4c66b4d874f39398417e2df62a065d343f7cc265f7ac774efd6017a5bd456ac
7
- data.tar.gz: 07320448213273898f202449443cbda54127a1b587ebdb4afdf162830904d1b4d93f2804b305ef37f8882408a441f13f1362969dde5a799301836e3c6bbb8c42
6
+ metadata.gz: 7774ba33ebb8c22fa95a2c5e33e9737d2037159298d72cbef6b29328079d4dd126cc90ead7ab816a3cc5c39f59f2e0d1415ea61ed076375358df9b93a39cb31d
7
+ data.tar.gz: b0524f25ace2614d93f84abea93bc5814e76b48174c0362fdf239fb28cca889ded156d646fe72e0089c01e12e3b62a1b00c996f90996b7dbb241174a11878468
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- caracara (0.5.0)
4
+ caracara (0.6.0)
5
5
  mustache (~> 1.0)
6
6
 
7
7
  GEM
@@ -28,11 +28,10 @@ module Caracara
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?
32
31
  options = Utils.merge(options, @fixed_options[index]) unless @fixed_options[index].nil?
33
32
 
34
33
  # Compile the mustache template
35
- Mustache.render step, options
34
+ Mustache.render step, compile_options(options, options)
36
35
  end
37
36
  end
38
37
 
@@ -41,6 +40,34 @@ module Caracara
41
40
  SSH.command compile(args), escape
42
41
  end
43
42
 
43
+ private
44
+
45
+ # Compile hash of options
46
+ # @param {Hash} compile The hash that will be compiled using Mustache
47
+ # @param {Hash} options Options used to compile this Hash
48
+ # @return {Hash} A compiled hash with the same structure of the `compile` one
49
+ def compile_options(compile, options)
50
+ # Compiled options
51
+ compiled_options = {}
52
+
53
+ # Each options
54
+ compile.each do |key, value|
55
+ # Check if the value is another hash
56
+ # Compile the content with the options
57
+ compiled = if value.is_a?(Hash)
58
+ compile_options value, options
59
+ else
60
+ Mustache.render value.to_s, options
61
+ end
62
+
63
+ # Put it into the compile_options
64
+ compiled_options[key] = compiled
65
+ end
66
+
67
+ # Return the compile options
68
+ compiled_options
69
+ end
70
+
44
71
  # Static methods
45
72
  class << self
46
73
  # Static attributes
@@ -1,5 +1,5 @@
1
1
  module Caracara
2
2
  def self.version
3
- '0.5.0'
3
+ '0.6.0'
4
4
  end
5
5
  end
@@ -19,6 +19,10 @@ class TaskSpec < Caracara::Task
19
19
  end
20
20
  end
21
21
 
22
+ class AnotherTaskSpec < Caracara::Task
23
+ step 'docker -d run {{image}}'
24
+ end
25
+
22
26
  # Tests
23
27
  describe 'Task' do
24
28
  # Initialize the task
@@ -31,6 +35,13 @@ describe 'Task' do
31
35
  text: 'Some nice text!'
32
36
  }
33
37
 
38
+ # Initialize the task
39
+ let(:another_task) {
40
+ AnotherTaskSpec.init project: 'app',
41
+ version: '1.5.0',
42
+ image: '{{project}}-{{version}}'
43
+ }
44
+
34
45
  it 'should return the steps' do
35
46
  # Get the steps
36
47
  steps = task.steps
@@ -55,6 +66,14 @@ describe 'Task' do
55
66
  expect(steps[4]).to eq("(cd niceFolder && (echo \"Im doing some tasks with Caracara\"\\necho \"Some nice text!\" > file.txt))")
56
67
  end
57
68
 
69
+ it 'should compile the steps from AnotherTask' do
70
+ # Compile the steps
71
+ steps = another_task.compile
72
+
73
+ # Assertions
74
+ expect(steps[0]).to eq('docker -d run app-1.5.0')
75
+ end
76
+
58
77
  it 'should compile the steps using specific args' do
59
78
  # Get the steps
60
79
  steps = task.compile user: 'root',
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.5.0
4
+ version: 0.6.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-14 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache