roku_builder 4.6.2 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f5ee06bef7a559cd71fdb1406b39a5b97e98ebe
4
- data.tar.gz: 0fd27354c80130d18413c7f9c03d32da4dc77d32
3
+ metadata.gz: d66d868225c4eb2c7f87bd746d98d5bf8b89d992
4
+ data.tar.gz: 4c11ace0819ab0716dc1de8d5daa8c7540193945
5
5
  SHA512:
6
- metadata.gz: ecce7558ba6b19ce6c4038dc621900608e005d6fbab5134bebb0c038db2b5d9480a64fd40281f654748138e05a6f3dee412c75e2bd4ac4793a7e23bd182271e8
7
- data.tar.gz: c152454c7f0a93a925508ec6251443d6fb7c05cf83d0f84bbe2e9b49fbcc405ba0a8f10b6ef3d5b25979b175a4df20a43b8969601a616b127429bdda0b76a769
6
+ metadata.gz: 8ac93633b3abf5c576ab8338305d28d014c36a5c324be1c38f002ec186c6ca36557e2a14d9fd351454010c691b9673b97ac33984f4724498673d02aec2846f23
7
+ data.tar.gz: be543060ea17d28ceafc13636d5cb86cc1d5e4141e35566c397e401cf26e1e1c4cfb5b749565cb14ab8129b70163530410ceb93ca3cedc8bad20c3600c0a0ea0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roku_builder (4.6.2)
4
+ roku_builder (4.7.0)
5
5
  faraday (~> 0.13)
6
6
  faraday-digestauth (~> 0.2)
7
7
  git (~> 1.3)
@@ -95,6 +95,7 @@ module RokuBuilder
95
95
  raise InvalidConfig, "Parent Configs Too Deep." if depth > 10
96
96
  end
97
97
  merge_local_config
98
+ expand_repeatable_stages
98
99
  fix_config_symbol_values
99
100
  end
100
101
 
@@ -138,6 +139,48 @@ module RokuBuilder
138
139
  end
139
140
  end
140
141
 
142
+ def expand_repeatable_stages
143
+ if @config[:projects]
144
+ @config[:projects].each_pair do |project_key, project|
145
+ unless is_skippable_project_key?(project_key)
146
+ if project[:stages]
147
+ stages_to_add = {}
148
+ project[:stages].each_pair do |repeat, repeat_config|
149
+ if repeat.to_s =~ /!repeat.*/
150
+ repeat_config[:for].each do |key|
151
+ repeat_config[:stages].each_pair do |stage_key, stage|
152
+ stage = deep_copy_replace_key(key, stage)
153
+ stages_to_add[stage_key.to_s.gsub("{key}", key).to_sym] = stage
154
+ end
155
+ end
156
+ project[:stages].delete(repeat)
157
+ end
158
+ end
159
+ project[:stages].merge!(stages_to_add)
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
165
+
166
+ def deep_copy_replace_key(key, object)
167
+ object = object.dup
168
+ if object.class == Hash
169
+ object.each_pair do |hash_key, hash_value|
170
+ object[hash_key] = deep_copy_replace_key(key, hash_value)
171
+ end
172
+ elsif object.class == Array
173
+ object.each_with_index do |i, value|
174
+ object[i] = deep_copy_replace_key(key, object[i])
175
+ end
176
+ elsif object.class == String
177
+ object.gsub!("{key}", key)
178
+ elsif object.class == Symbol
179
+ object = object.to_s.gsub("{key}", key).to_sym
180
+ end
181
+ object
182
+ end
183
+
141
184
  def fix_config_symbol_values
142
185
  if @config[:devices]
143
186
  @config[:devices][:default] = @config[:devices][:default].to_sym
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RokuBuilder
4
4
  # Version of the RokuBuilder Gem
5
- VERSION = "4.6.2"
5
+ VERSION = "4.7.0"
6
6
  end
@@ -62,6 +62,40 @@ module RokuBuilder
62
62
  assert_equal :p1, config.raw[:projects][:default]
63
63
  end
64
64
 
65
+ def test_config_read_repeat_stages
66
+ options = build_options({config: File.join(test_files_path(ConfigTest), "repeat_stages.json"), validate: true})
67
+ config = Config.new(options: options)
68
+ config.load
69
+ assert_equal "stage_script a", config.raw[:projects][:p1][:stages][:a][:script][:stage]
70
+ assert_equal "stage_script b", config.raw[:projects][:p1][:stages][:b][:script][:stage]
71
+ assert_equal "unstage_script", config.raw[:projects][:p1][:stages][:a][:script][:unstage]
72
+ assert_equal "key", config.raw[:projects][:p1][:stages][:a][:key]
73
+ assert_nil config.raw[:projects][:p1][:stages][:"!repeat"]
74
+ end
75
+
76
+ def test_config_read_repeat_multi_stages
77
+ options = build_options({config: File.join(test_files_path(ConfigTest), "repeat_multi_stages.json"), validate: true})
78
+ config = Config.new(options: options)
79
+ config.load
80
+ assert_equal "stage_script a", config.raw[:projects][:p1][:stages][:a][:script][:stage]
81
+ assert_equal "stage_script b", config.raw[:projects][:p1][:stages][:b][:script][:stage]
82
+ assert_equal "stage_script a", config.raw[:projects][:p1][:stages][:a_2][:script][:stage]
83
+ assert_equal "stage_script b", config.raw[:projects][:p1][:stages][:b_2][:script][:stage]
84
+ assert_nil config.raw[:projects][:p1][:stages][:"!repeat"]
85
+ end
86
+
87
+ def test_config_read_multi_repeat_stages
88
+ options = build_options({config: File.join(test_files_path(ConfigTest), "multi_repeat_stages.json"), validate: true})
89
+ config = Config.new(options: options)
90
+ config.load
91
+ assert_equal "stage_script a", config.raw[:projects][:p1][:stages][:a][:script][:stage]
92
+ assert_equal "stage_script b", config.raw[:projects][:p1][:stages][:b][:script][:stage]
93
+ assert_equal "stage_script2 c", config.raw[:projects][:p1][:stages][:c][:script][:stage]
94
+ assert_equal "stage_script2 d", config.raw[:projects][:p1][:stages][:d][:script][:stage]
95
+ assert_nil config.raw[:projects][:p1][:stages][:"!repeat_1"]
96
+ assert_nil config.raw[:projects][:p1][:stages][:"!repeat_2"]
97
+ end
98
+
65
99
  def test_config_read_parent_child_part
66
100
  options = build_options({config: File.join(test_files_path(ConfigTest), "child.json"), validate: true})
67
101
  config = Config.new(options: options)
@@ -0,0 +1,43 @@
1
+ {
2
+ "devices": {
3
+ "default": "roku",
4
+ "roku": {
5
+ "ip": "111.222.333.444",
6
+ "user": "user",
7
+ "password": "pass"
8
+ }
9
+ },
10
+ "projects": {
11
+ "default": "p1",
12
+ "p1": {
13
+ "directory": "/tmp",
14
+ "folders": ["resources","source"],
15
+ "files": ["manifest"],
16
+ "app_name": "app",
17
+ "stage_method": "git",
18
+ "stages":{
19
+ "!repeat_1": {
20
+ "for": ["a", "b"],
21
+ "stages": {
22
+ "{key}": {
23
+ "script": {"stage": "stage_script {key}", "unstage": "unstage_script"},
24
+ "key": "key"
25
+ }
26
+ }
27
+ },
28
+ "!repeat_2": {
29
+ "for": ["c", "d"],
30
+ "stages": {
31
+ "{key}": {
32
+ "script": {"stage": "stage_script2 {key}", "unstage": "unstage_script"},
33
+ "key": "key"
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ },
40
+ "input_mappings": {
41
+ "a": ["home", "Home"]
42
+ }
43
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "devices": {
3
+ "default": "roku",
4
+ "roku": {
5
+ "ip": "111.222.333.444",
6
+ "user": "user",
7
+ "password": "pass"
8
+ }
9
+ },
10
+ "projects": {
11
+ "default": "p1",
12
+ "p1": {
13
+ "directory": "/tmp",
14
+ "folders": ["resources","source"],
15
+ "files": ["manifest"],
16
+ "app_name": "app",
17
+ "stage_method": "git",
18
+ "stages":{
19
+ "!repeat": {
20
+ "for": ["a", "b"],
21
+ "stages": {
22
+ "{key}": {
23
+ "script": {"stage": "stage_script {key}", "unstage": "unstage_script"},
24
+ "key": "key"
25
+ },
26
+ "{key}_2": {
27
+ "script": {"stage": "stage_script {key}", "unstage": "unstage_script"},
28
+ "key": "key"
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ },
35
+ "input_mappings": {
36
+ "a": ["home", "Home"]
37
+ }
38
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "devices": {
3
+ "default": "roku",
4
+ "roku": {
5
+ "ip": "111.222.333.444",
6
+ "user": "user",
7
+ "password": "pass"
8
+ }
9
+ },
10
+ "projects": {
11
+ "default": "p1",
12
+ "p1": {
13
+ "directory": "/tmp",
14
+ "folders": ["resources","source"],
15
+ "files": ["manifest"],
16
+ "app_name": "app",
17
+ "stage_method": "git",
18
+ "stages":{
19
+ "!repeat": {
20
+ "for": ["a", "b"],
21
+ "stages": {
22
+ "{key}": {
23
+ "script": {"stage": "stage_script {key}", "unstage": "unstage_script"},
24
+ "key": "key"
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ },
31
+ "input_mappings": {
32
+ "a": ["home", "Home"]
33
+ }
34
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.2
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeneca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-27 00:00:00.000000000 Z
11
+ date: 2018-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -504,9 +504,12 @@ files:
504
504
  - test/roku_builder/test_files/config_test/child.json
505
505
  - test/roku_builder/test_files/config_test/config.json
506
506
  - test/roku_builder/test_files/config_test/local.json
507
+ - test/roku_builder/test_files/config_test/multi_repeat_stages.json
507
508
  - test/roku_builder/test_files/config_test/non_json.json
508
509
  - test/roku_builder/test_files/config_test/parent.json
509
510
  - test/roku_builder/test_files/config_test/parent_projects.json
511
+ - test/roku_builder/test_files/config_test/repeat_multi_stages.json
512
+ - test/roku_builder/test_files/config_test/repeat_stages.json
510
513
  - test/roku_builder/test_files/controller_commands_test/manifest_template
511
514
  - test/roku_builder/test_files/controller_config_test/valid_config.json
512
515
  - test/roku_builder/test_files/controller_test/load_config_test.json
@@ -598,9 +601,12 @@ test_files:
598
601
  - test/roku_builder/test_files/config_test/child.json
599
602
  - test/roku_builder/test_files/config_test/config.json
600
603
  - test/roku_builder/test_files/config_test/local.json
604
+ - test/roku_builder/test_files/config_test/multi_repeat_stages.json
601
605
  - test/roku_builder/test_files/config_test/non_json.json
602
606
  - test/roku_builder/test_files/config_test/parent.json
603
607
  - test/roku_builder/test_files/config_test/parent_projects.json
608
+ - test/roku_builder/test_files/config_test/repeat_multi_stages.json
609
+ - test/roku_builder/test_files/config_test/repeat_stages.json
604
610
  - test/roku_builder/test_files/controller_commands_test/manifest_template
605
611
  - test/roku_builder/test_files/controller_config_test/valid_config.json
606
612
  - test/roku_builder/test_files/controller_test/load_config_test.json