roku_builder 3.11.1 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -13
  3. data/Guardfile +6 -3
  4. data/README.md +171 -112
  5. data/bin/roku +2 -2
  6. data/config.json.example +2 -0
  7. data/lib/roku_builder/config_manager.rb +14 -2
  8. data/lib/roku_builder/config_parser.rb +6 -0
  9. data/lib/roku_builder/config_validator.rb +5 -2
  10. data/lib/roku_builder/version.rb +1 -1
  11. data/rakefile +1 -1
  12. data/roku_builder.gemspec +2 -1
  13. data/{tests/roku_builder/config_manager_test.rb → test/roku_builder/test_config_manager.rb} +38 -0
  14. data/{tests/roku_builder/config_parser_test.rb → test/roku_builder/test_config_parser.rb} +36 -0
  15. data/{tests/roku_builder/config_validator_test.rb → test/roku_builder/test_config_validator.rb} +0 -0
  16. data/{tests/roku_builder/controller_test.rb → test/roku_builder/test_controller.rb} +14 -0
  17. data/{tests/roku_builder/controller_commands_test.rb → test/roku_builder/test_controller_commands.rb} +31 -1
  18. data/{tests/roku_builder/error_handler_test.rb → test/roku_builder/test_error_handler.rb} +0 -0
  19. data/{tests → test}/roku_builder/test_files/controller_config_test/valid_config.json +0 -0
  20. data/{tests → test}/roku_builder/test_files/controller_test/load_config_test.json +0 -0
  21. data/{tests → test}/roku_builder/test_files/controller_test/parent_config.json +0 -0
  22. data/{tests → test}/roku_builder/test_files/controller_test/valid_config.json +0 -0
  23. data/{tests → test}/roku_builder/test_files/loader_test/a +0 -0
  24. data/{tests → test}/roku_builder/test_files/loader_test/manifest +0 -0
  25. data/{tests → test}/roku_builder/test_files/loader_test/source/b +0 -0
  26. data/{tests → test}/roku_builder/test_files/loader_test/source/c/d +0 -0
  27. data/{tests → test}/roku_builder/test_files/manifest_manager_test/manifest_comments +0 -0
  28. data/{tests → test}/roku_builder/test_files/manifest_manager_test/manifest_template +0 -0
  29. data/{tests → test}/roku_builder/test_files/manifest_manager_test/manifest_template_2 +0 -0
  30. data/{tests → test}/roku_builder/test_files/manifest_manager_test/test.zip +0 -0
  31. data/{tests → test}/roku_builder/test_files/manifest_manager_test/updated_title_manifest +0 -0
  32. data/{tests → test}/roku_builder/test_files/stager_test/a +0 -0
  33. data/{tests → test}/roku_builder/test_files/stager_test/manifest +0 -0
  34. data/{tests → test}/roku_builder/test_files/stager_test/source/b +0 -0
  35. data/{tests → test}/roku_builder/test_files/stager_test/source/c/d +0 -0
  36. data/{tests → test}/roku_builder/test_helper.rb +0 -0
  37. data/{tests/roku_builder/inspector_test.rb → test/roku_builder/test_inspector.rb} +0 -0
  38. data/{tests/roku_builder/keyer_test.rb → test/roku_builder/test_keyer.rb} +0 -0
  39. data/{tests/roku_builder/linker_test.rb → test/roku_builder/test_linker.rb} +0 -0
  40. data/{tests/roku_builder/loader_test.rb → test/roku_builder/test_loader.rb} +0 -0
  41. data/{tests/roku_builder/manifest_manager_test.rb → test/roku_builder/test_manifest_manager.rb} +0 -0
  42. data/{tests/roku_builder/monitor_test.rb → test/roku_builder/test_monitor.rb} +0 -0
  43. data/{tests/roku_builder/navigator_test.rb → test/roku_builder/test_navigator.rb} +0 -2
  44. data/{tests/roku_builder/packager_test.rb → test/roku_builder/test_packager.rb} +0 -0
  45. data/{tests/roku_builder/profiler_test.rb → test/roku_builder/test_profiler.rb} +0 -0
  46. data/test/roku_builder/test_ruby_git.rb +82 -0
  47. data/{tests/roku_builder/scripter_test.rb → test/roku_builder/test_scripter.rb} +0 -0
  48. data/{tests/roku_builder/stager_test.rb → test/roku_builder/test_stager.rb} +0 -0
  49. data/{tests/roku_builder/tester_test.rb → test/roku_builder/test_tester.rb} +0 -0
  50. data/{tests/roku_builder/util_test.rb → test/roku_builder/test_util.rb} +0 -0
  51. metadata +96 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24f62ca635f6a690606f53980f4b2de0d3206525
4
- data.tar.gz: 1d061880ae44bd0764ed4ec22583f2402749a917
3
+ metadata.gz: 93b0a591ad7b3ea224df548135d5630d63042720
4
+ data.tar.gz: b5af0760e8b9a2c914ec483fe28c0be45bee1b6b
5
5
  SHA512:
6
- metadata.gz: 8583f7c075a0fce0cc992d0f215b27e0145b147a88da14b4785887a84e70e60f85ecb0b91d5548081850c4347b2457c3bab4f1644fde1abbdbeb21832fb23960
7
- data.tar.gz: afe84a4778c8ac21c3c97cf450e73ec5215d80f67d9dfba5a2dbc034f4637c7b9e7479b0d362ae775a21b5008be08dd21b58d6104fd7ed8a14efbde9ddcf3327
6
+ metadata.gz: b553af68d7eae9b5e2b3c40b7eef3b7852ab01b86704b1aa7548c37ee57914bc502cee6c820f32c48c5f562e46750241571ccecd83dc76784fcf329bb98b0d30
7
+ data.tar.gz: 0b51fbe386fe0944f114c26057dc0f2267bd88fc5f238a4007f1b6d8f9a3a9435f6e3f47c5819599afa13c82c960ae61788f83e720d67fd2566a55729b3674ac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roku_builder (3.11.1)
4
+ roku_builder (3.12.0)
5
5
  faraday (~> 0.11)
6
6
  faraday-digestauth (~> 0.2)
7
7
  git (~> 1.3)
@@ -22,10 +22,6 @@ GEM
22
22
  thor (~> 0.19.1)
23
23
  tins (~> 1.6)
24
24
  docile (1.1.5)
25
- em-websocket (0.5.1)
26
- eventmachine (>= 0.12.9)
27
- http_parser.rb (~> 0.6.0)
28
- eventmachine (1.2.1)
29
25
  faraday (0.11.0)
30
26
  multipart-post (>= 1.2, < 3)
31
27
  faraday-digestauth (0.2.1)
@@ -44,12 +40,9 @@ GEM
44
40
  shellany (~> 0.0)
45
41
  thor (>= 0.18.1)
46
42
  guard-compat (1.2.1)
47
- guard-livereload (2.5.2)
48
- em-websocket (~> 0.5)
49
- guard (~> 2.8)
50
- guard-compat (~> 1.0)
51
- multi_json (~> 1.8)
52
- http_parser.rb (0.6.0)
43
+ guard-minitest (2.4.6)
44
+ guard-compat (~> 1.2)
45
+ minitest (>= 3.0)
53
46
  json (2.0.3)
54
47
  listen (3.1.5)
55
48
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -63,7 +56,6 @@ GEM
63
56
  minitest-server (~> 1.0)
64
57
  minitest-server (1.0.4)
65
58
  minitest (~> 5.0)
66
- multi_json (1.12.1)
67
59
  multipart-post (2.0.0)
68
60
  nenv (0.3.0)
69
61
  net-http-digest_auth (1.4)
@@ -104,7 +96,8 @@ DEPENDENCIES
104
96
  bundler (~> 1.7)
105
97
  byebug (~> 9.0)
106
98
  coveralls (~> 0.8)
107
- guard-livereload (~> 2.5)
99
+ guard (~> 2.14)
100
+ guard-minitest (~> 2.4)
108
101
  minitest (~> 5.10)
109
102
  minitest-autotest (~> 1.0)
110
103
  minitest-server (~> 1.0)
data/Guardfile CHANGED
@@ -17,7 +17,10 @@
17
17
  #
18
18
  # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
19
 
20
- guard 'livereload' do
21
- watch(%r{lib/roku_builder/.+\.rb})
22
- watch(%r{lib/roku_builder.rb})
20
+
21
+ guard :minitest do
22
+ # with Minitest::Unit
23
+ watch(%r{^test/roku_builder/(.*)\/?test_(.*)\.rb$})
24
+ watch(%r{^lib/roku_builder/(.*/)?([^/]+)\.rb$}) { |m| "test/roku_builder/#{m[1]}test_#{m[2]}.rb" }
25
+ watch(%r{^test/roku_builder/test_helper\.rb$}) { 'test/roku_builder' }
23
26
  end
data/README.md CHANGED
@@ -55,91 +55,176 @@ This will create the file '~/.roku_config.json' with a default configuration.
55
55
  Edit this file to add appropriate values. The following are default
56
56
  configuration options:
57
57
 
58
+ ##### Top Level Configuration
59
+
58
60
  * devices: information for accessing devices
59
- * devices -> default: id of the default device
60
61
  * projects: this is a hash of project objects
61
- * projects -> default: the key for the default project
62
+ * keys: contains keys that will be used for signing packages
63
+ * input_mapping: allows you to change key mappings for the intractive navigator
64
+
65
+ ##### Device Configuration
66
+
67
+ * devices.default: id of the default device
68
+ * devices.<device_id>.ip: ip address of the device
69
+ * devices.<device_id>.user: dev username for the roku device
70
+ * devices.<device_id>.password: dev password for the roku device
71
+
72
+ ##### Project Configuration
73
+
74
+ * projects.default: the key for the default project
75
+ * projects.parent_dir: optional directory path that all projects are relative
76
+ to
77
+ * projects.<project_id>.parent: optional id of parent project to copy configs
78
+ from
79
+ * projects.<project_id>.directory: full path of the git repository the houses
80
+ the roku app
81
+ * projects.<project_id>.app_name: Name used when packaging the app
82
+ * projects.<project_id>.stage_method: Which method to use for switching app
83
+ stages (git or script)
84
+ * projects.<project_id>.stages: a hash of stage objects
85
+ * projects.<project_id>.stages.<stage_id>.branch: name of the branch for the
86
+ given stage (if stage_method = git). If using stage_method = stage then
87
+ this can be removed.
88
+ * projects.<project_id>.stages.<stage_id>.script: scripts to use to stage the
89
+ app (if stage_method = script). If using stage_method = git this can be
90
+ removed.
91
+ * projects.<project_id>.stages.<stage_id>.script.stage: script run form the
92
+ app root directory to stage app
93
+ * projects.<project_id>.stages.<stage_id>.script -> unstage: script run form
94
+ the app root directory to unstage app
95
+ * projects.<project_id>.stages.<stage_id>.key: this can be a string referencing
96
+ a key in the keys section or a hash of options
97
+ * projects.<project_id>.stages.<stage_id>.key.keyed_pkg: path to a pkg file
98
+ that has been signed
99
+ * projects.<project_id>.stages.<stage_id>.key.password: password for the signed pkg
100
+
101
+ ##### Key Configuration
102
+
103
+ * keys.key_dir: optional directory that all keys are relative to
104
+ * keys.<key_id>.keyed_pkg: path to a pkg file that has been signed
105
+ * keys.<key_id>.password: password for the signed pkg
106
+
107
+ The "input_mappings" section is optional but will allow you to override
108
+ the default input mappings. In the section each key is a key press code. The
109
+ value is a array with the desired command to run and a human readable key name.
110
+ To see the key press code for a specific key the --navigate command can be run
111
+ with the --debug option on to see a print out of all the keys pressed.
62
112
 
63
- Each Device has the following options:
113
+ #### Basic steps for creating a Roku channel/application package
64
114
 
65
- * ip: ip address of the device
66
- * user: dev username for the roku device
67
- * password: dev password for the roku device
115
+ Official docs for packaging an application can be found [in the sdk](https://sdkdocs.roku.com/display/sdkdoc/Packaging+Your+Application), however the basic steps are:
68
116
 
69
- Each project has the following options:
117
+ 1. Side-load your application onto a Roku device for testing.
118
+ 1. Run the genkey utility to generate a key. This key will sign packages. This step only needs to be done once.
119
+ 1. Run the package utility to generate the package.
120
+ 1. Download the package from the Roku device to your computer.
70
121
 
71
- * directory: full path of the git repository the houses the roku app
72
- * app_name: Name used when packaging the app
73
- * stage_method: Which method to use for switching app stages (git or script)
74
- * stages: a hash of stage objects
122
+ RokuBuilder makes running each of these steps easy, without needing to use the Roku device web interface or telnet.
75
123
 
76
- Each stage has the following options:
124
+ #### Projects and Stages
77
125
 
78
- * branch: name of the branch for the given stage (if stage_method = git). If
79
- using stage_method = stage then this can be removed.
80
- * script: scripts to use to stage the app (if stage_method = script). If using
81
- stage_method = git this can be removed.
82
- * script -> stage: script run form the app root directory to stage app
83
- * script -> unstage: script run form the app root directory to unstage app
84
- * key: has of key options for signing a package
85
- * key -> keyed_pkg: path to a pkg file that has been signed
86
- * key -> password: password for the signed pkg
126
+ The configuration for this gem allows you to define any number of project and
127
+ any number of stages for each project. It is intended that each app be defined
128
+ as a project and then the stages for that project would allow you to define
129
+ production/staging/etc. stages.
87
130
 
88
- There is an optional "input_mappings" section that will allow you to override
89
- the default input mappings. In the section each key is a key press code. The
90
- value is a array with the desired command to run and a human readable key name.
91
- To see the key press code for a specific key the --navigate command can be run
92
- with the --debug option on to see a print out of all the keys pressed.
131
+ There are two different ways that stages can be defined. You can use a script
132
+ to define your stage. This gives you the greatest amount of freedom allowing
133
+ you to setup your stage anyway you want. The other option is to use git
134
+ staging. To do this you must have one branch for eash stage.
93
135
 
136
+ The project used in the examples below is a smart default. If you are in a
137
+ project directory then it will use that project. If you are not then it will
138
+ use the defualt that you have defined in your config. You can define what
139
+ project you want the command to be run on using the --project option:
94
140
 
95
- #### Sideloading
141
+ $ roku -lw --project project1
96
142
 
97
- There are several ways to side load an app. You can sideload based on a stage,
98
- an arbitrary git referance or the working directory.
143
+ or:
99
144
 
100
- To sideload a stage you can run the following command:
145
+ $ roku -lw -P project1
101
146
 
102
- $ roku --sideload --stage production
147
+ #### Commands and Sources
148
+
149
+ There are several commands that require a source option to run properly. These
150
+ include:
151
+
152
+ * Sideload
153
+ * Build
154
+ * Package
155
+ * Test
156
+ * Key
157
+
158
+ There are several source options that can be supplied to these commands. Which
159
+ options you use will depend on the type of staging you are using and the app
160
+ you are trying to run the command. The options are as follows:
161
+
162
+ * --ref or -r
163
+ * This option only works with git type staging. It will allow you to run a
164
+ command on a specific git branch, tag, or referance.
165
+ * --stage or -s
166
+ * This option will work with either git or script staging. It allows you to
167
+ sideload a specific stage. If using script staging then it will run the
168
+ configured stage script before sideloading and then run the unstage
169
+ script after. If using git staging it will stach any local changes,
170
+ switch to the configured branch, sideload, switch back to the previous
171
+ branch, and unstach changes. This is the only source option that you can
172
+ use when packaging.
173
+ * --working or -w
174
+ * This option will work with git or script staging. It will use the project
175
+ configs to determine the directory to use but will not run any staging
176
+ method.
177
+ * --current or -c
178
+ * This option will ignore any project configurattion and just us the entire
179
+ current directory.
180
+ * --in or -I
181
+ * This option allows you to pass in a zip file of an already built app.
103
182
 
104
- This will sideload the production stage. By default the production stage is
105
- used. So the above is equivalent to the following:
106
183
 
107
- $ roku --sideload
184
+ #### Sideloading
108
185
 
109
- and:
186
+ You can sideload an app directly to the device using this gem. The gem will
187
+ zip all of the configured files and upload it to the device and the remove the
188
+ zip. You can do so with the following commands:
110
189
 
111
- $ roku -l
190
+ $ roku --sideload --stage production
112
191
 
113
- To sideload via a git referance you can run the following command
192
+ or:
114
193
 
115
- $ roku --sideload --ref master
194
+ $ roku -ls production
116
195
 
117
- This will sideload the master branch. The following is equivalent:
196
+ When sideoading you can use any of the source options approiate to your staging
197
+ method.
118
198
 
119
- $ roku -lr master
199
+ #### Building
120
200
 
121
- To sideload the current working directory you can run the following:
201
+ You can build an app to be sideloaded later or by someone else by using the
202
+ following command:
122
203
 
123
- $ roku --sideload --working
204
+ $ roku --build --working
124
205
 
125
206
  or:
126
207
 
127
- $ roku -lw
208
+ $ roku -bw
128
209
 
129
- If you choose to sideload via stage or git referance then the roku tool with
130
- stash any changes in the working directory and then apply the stash after. From
131
- time to time there may be an issue with this and you will have to clear the
132
- stash manually.
210
+ When bulding you can use any of the source options approiate to your staging
211
+ method except the --in option.
133
212
 
134
- You can also sideload the current directory even if it is not setup as a
135
- project. If the directory has a manifest file then you can run the following
136
- command:
213
+ #### Generating a key
137
214
 
138
- $ roku --sideload --current
215
+ Before you can package a channel, you must [generate a key](https://sdkdocs.roku.com/display/sdkdoc/Packaging+Your+Application#PackagingYourApplication-RunthegenkeyUtility)
216
+ that is used to sign the package. This key is used to sign a new package and is
217
+ also needed to sign a package when updating a channel.
139
218
 
140
- or:
219
+ You can create a key by running the genkey command:
141
220
 
142
- $ roku -lc
221
+ $ roku --genkey --debug
222
+
223
+ This will output the following data, all of which need to put in the `keys` section of `~/.roku_config.json`:
224
+
225
+ * `Keyed PKG`: This is the signing key, used to sign new and updated packages
226
+ * `Password`: Key's password
227
+ * `DevID`: The developer ID associated with the key. Don't need to save this, but it is best practice to include this string in the signing keys filename
143
228
 
144
229
  #### Packaging
145
230
 
@@ -153,17 +238,8 @@ or:
153
238
 
154
239
  $ roku -ps production
155
240
 
156
- #### Building
157
-
158
- You can build an app to be sideloaded later or by someone else by using the
159
- following command:
160
-
161
- $ roku --build --stage production
162
-
163
- or:
164
-
165
- $ roku -bw
166
-
241
+ The package command will automatically [Rekey](https://github.com/rokudev/docs/blob/master/develop/guides/packaging.md#rekeying)
242
+ your roku device before packaging the channel
167
243
 
168
244
  #### Monitoring Logs
169
245
 
@@ -177,20 +253,40 @@ brightscript log:
177
253
  or:
178
254
  $ roku -m main
179
255
 
256
+ or
257
+
258
+ $ roku --monitor
259
+
180
260
  The following are the options to be passed in as type:
181
261
 
182
262
  * main
183
- * sg
184
- * task1
185
- * task2
186
- * task3
187
- * taskX
263
+ * sg (depricated)
264
+ * task1 (depricated)
265
+ * task2 (depricated)
266
+ * task3 (depricated)
267
+ * taskX (depricated)
188
268
  * profile
189
269
 
270
+ If no option is passed in then main log is monitored.
271
+
190
272
  The tool connects to the roku via telnet and prints everything that it
191
273
  recieves. It will continue indefinatly unless it is stopped via Ctrl-c or
192
274
  entering "q".
193
275
 
276
+ The monitor tool also includes command history and some tab completeion.
277
+
278
+ #### Interactive Navigation
279
+
280
+ The gem has the ability to capture keyboard input and send it to the roku as
281
+ remote inputs. This can be done by running the following command:
282
+
283
+ $ roku --navigate
284
+
285
+ Running in verbose mode will print out all of the key mappings avaiable. If you
286
+ want to change these mappings you can do so via the input_mapping config values
287
+ . To determine the codes needed to enter in the input_mapping config you can
288
+ run the navigator in debug mode.
289
+
194
290
  #### Profiling Scene Graph
195
291
 
196
292
  The tool will help a little with profiling scenegraph applications. Running the
@@ -222,7 +318,7 @@ are run otherwise it will just grab the test run from last time.
222
318
  Another tool for testing is the navigate command. You can use this to script
223
319
  navigation on the roku console. The command is used as follows:
224
320
 
225
- $ roku --navigate <command>
321
+ $ roku --nav <command>
226
322
 
227
323
  The possible commands are as follows:
228
324
 
@@ -267,46 +363,13 @@ You can use a differnt configuration file useing the following option:
267
363
 
268
364
  This path will be expanded so you do not have to use the full path
269
365
 
270
- You can use your keyboard to control the roku by running the following command:
271
-
272
- $ roku --navigate
273
-
274
- To see the key mapings you can run the following command:
275
-
276
- $ roku --navigate -V
277
-
278
- ## Projects
279
-
280
- The project used in the above examples is a smart default. If you are in a
281
- project directory then it will use that project. If you are not then it will
282
- use the defualt that you have defined in your config. You can define what
283
- project you want the command to be run on using the --project option:
284
-
285
- $ roku -lw --project project1
286
-
287
- or:
288
-
289
- $ roku -lw -P project1
290
-
291
- ## Stages
292
-
293
- Each project can have any number of stages. stages can be defined in a number
294
- of ways. The default is to use git branches to define stages. You can setup a
295
- branch for each stage and the gem will automatically switch between them as
296
- needed. If using git stages then the gem will ensure to stash any change you
297
- currently have before checking out the required branch. When done it will
298
- switch back and unstash the changes. You can use the -w or --working options
299
- to avoid this.
300
-
301
- The other method of staging is script staging. This will run a script you
302
- define before and after performing any actions. This will let you stage your
303
- app anyway you like as long as it can be done via script.
304
-
305
366
  ## Devices
306
367
 
307
- In the examples above the default device is used. If you have multiple devices
308
- defined in your config then you can select a different one using the following
309
- option:
368
+ In the examples above the device used is a smart default. It will use the
369
+ default device defined in the configuration file. If that device is not online
370
+ it will look start at the top and try each device until it findes an avaiable
371
+ device. If you have multiple devices defined in your config then you can select
372
+ a different one using the following option:
310
373
 
311
374
  $ roku -lw --device device2
312
375
 
@@ -325,10 +388,6 @@ directory:
325
388
 
326
389
  ## Improvements
327
390
 
328
- * Increase testing
329
- * Config Unit Tests
330
- * Intergration Tests
331
- * Move RokuBuilder::Controller to RokuBuilder?
332
391
  * Allow start and end delimiter for tests to be configured
333
392
  * Fix file naming when building from a referance
334
393
  * Extend profiling
data/bin/roku CHANGED
@@ -104,8 +104,8 @@ parser = OptionParser.new do |opts|
104
104
  options[:screens] = true
105
105
  end
106
106
 
107
- opts.on("-m", "--monitor TYPE", "Command: run telnet to monitor roku log") do |m|
108
- options[:monitor] = m
107
+ opts.on("-m", "--monitor [TYPE]", "Command: run telnet to monitor roku log") do |m|
108
+ options[:monitor] = m || "main"
109
109
  end
110
110
 
111
111
  opts.on("-u", "--update-manifest", "Command: update the manifest file") do
data/config.json.example CHANGED
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "projects": {
11
11
  "default": "<project id>",
12
+ "project_dir": "<optional parent directory for all projects>",
12
13
  "<project id>": {
13
14
  "directory": "<path/to/repo>",
14
15
  "folders": ["resources","source"],
@@ -26,6 +27,7 @@
26
27
  }
27
28
  },
28
29
  "keys": {
30
+ "key_dir": "<optional parent directory for all keys>",
29
31
  "key1": {
30
32
  "keyed_pkg": "<path/to/signed/package>",
31
33
  "password": "<password>"
@@ -46,17 +46,29 @@ module RokuBuilder
46
46
  # @return [Hash] roku config object
47
47
  def self.get_config(config:, logger:)
48
48
  begin
49
- config = JSON.parse(File.open(config).read, {symbolize_names: true})
49
+ config = {parent_config: config}
50
+ depth = 1
51
+ while config[:parent_config]
52
+ config_parent = JSON.parse(File.open(config[:parent_config]).read, {symbolize_names: true})
53
+ config.delete(:parent_config)
54
+ config.merge!(config_parent) {|key, v1, v2| v1}
55
+ depth += 1
56
+ if depth > 10
57
+ logger.fatal "Parent configs too deep."
58
+ return nil
59
+ end
60
+ end
50
61
  config[:devices][:default] = config[:devices][:default].to_sym
51
62
  config[:projects][:default] = config[:projects][:default].to_sym
52
63
  config[:projects].each_pair do |key,value|
53
64
  next if key == :default
65
+ next if key == :project_dir
54
66
  if value[:stage_method]
55
67
  value[:stage_method] = value[:stage_method].to_sym
56
68
  end
57
69
  end
58
70
  config[:projects].each_pair do |key, value|
59
- unless key == :default
71
+ unless key == :default or key == :project_dir
60
72
  if value[:parent] and config[:projects][value[:parent].to_sym]
61
73
  new_value = config[:projects][value[:parent].to_sym]
62
74
  new_value = new_value.deep_merge value
@@ -107,6 +107,9 @@ module RokuBuilder
107
107
  else
108
108
  project_config = config[:projects][options[:project].to_sym]
109
109
  return UNKNOWN_PROJECT unless project_config
110
+ if config[:projects][:project_dir]
111
+ project_config[:directory] = File.join(config[:projects][:project_dir], project_config[:directory])
112
+ end
110
113
  project_config[:stage_method] = :working if options[:working]
111
114
  end
112
115
  project_config
@@ -188,6 +191,9 @@ module RokuBuilder
188
191
  configs[:key] = configs[:project_config][:stages][stage][:key]
189
192
  if configs[:key].class == String
190
193
  configs[:key] = config[:keys][configs[:key].to_sym]
194
+ if config[:keys][:key_dir]
195
+ configs[:key][:keyed_pkg] = File.join(config[:keys][:key_dir], configs[:key][:keyed_pkg])
196
+ end
191
197
  end
192
198
  end
193
199
  if options[:package]
@@ -44,7 +44,7 @@ module RokuBuilder
44
44
  end
45
45
  if config[:projects]
46
46
  config[:projects].each {|project,project_config|
47
- next if project == :default
47
+ next if project == :default or project == :project_dir
48
48
  validate_project(codes: codes, project: project_config)
49
49
  if project_config[:stages]
50
50
  project_config[:stages].each {|_stage, stage_config|
@@ -54,7 +54,10 @@ module RokuBuilder
54
54
  }
55
55
  end
56
56
  if config[:keys]
57
- config[:keys].each {|_key,key_config| validate_key(codes: codes, key: key_config) }
57
+ config[:keys].each {|key,key_config|
58
+ next if key == :key_dir
59
+ validate_key(codes: codes, key: key_config)
60
+ }
58
61
  end
59
62
  if config[:input_mapping]
60
63
  config[:input_mapping].each_value {|info| validate_mapping(codes: codes, mapping: info) }
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RokuBuilder
4
4
  # Version of the RokuBuilder Gem
5
- VERSION = "3.11.1"
5
+ VERSION = "3.12.0"
6
6
  end
data/rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake'
4
4
  require 'rake/testtask'
5
5
 
6
6
  Rake::TestTask.new do |t|
7
- t.test_files = Dir.glob('tests/roku_builder/*_test.rb')
7
+ t.test_files = Dir.glob('test/roku_builder/test_*.rb')
8
8
  end
9
9
 
10
10
  task(default: :test)
data/roku_builder.gemspec CHANGED
@@ -37,5 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "simplecov", "~> 0.12"
38
38
  spec.add_development_dependency "coveralls", "~> 0.8"
39
39
  spec.add_development_dependency "yard", "~> 0.9"
40
- spec.add_development_dependency "guard-livereload", "~> 2.5"
40
+ spec.add_development_dependency "guard", "~> 2.14"
41
+ spec.add_development_dependency "guard-minitest", "~> 2.4"
41
42
  end
@@ -18,6 +18,44 @@ class ConfigManagerTest < Minitest::Test
18
18
  assert_equal :project1, config[:projects][:default], :project1
19
19
  end
20
20
 
21
+ def test_config_manager_read_config_parent
22
+ logger = Logger.new("/dev/null")
23
+ config_path = "config/file/path"
24
+ io = Minitest::Mock.new
25
+ parent_config = good_config
26
+ parent_config[:projects].delete(:project1)
27
+ parent_config[:projects].delete(:project2)
28
+ child_config = good_config
29
+ child_config.delete(:devices)
30
+ child_config.delete(:keys)
31
+ child_config.delete(:input_mapping)
32
+ child_config[:parent_config] = "config/file/path"
33
+ io.expect(:read, child_config.to_json)
34
+ io.expect(:read, parent_config.to_json)
35
+ config = nil
36
+ File.stub(:open, io) do
37
+ config = RokuBuilder::ConfigManager.get_config(config: config_path, logger: logger)
38
+ end
39
+ io.verify
40
+ assert_equal "user", config[:devices][:roku][:user]
41
+ assert_equal "<app name>", config[:projects][:project1][:app_name]
42
+ end
43
+
44
+ def test_config_manager_read_config_parent_too_deep
45
+ logger = Logger.new("/dev/null")
46
+ config_path = "config/file/path"
47
+ io = Minitest::Mock.new
48
+ parent_config = good_config
49
+ parent_config[:parent_config] = "config/file/path"
50
+ 10.times {|_i| io.expect(:read, parent_config.to_json)}
51
+ config = nil
52
+ File.stub(:open, io) do
53
+ config = RokuBuilder::ConfigManager.get_config(config: config_path, logger: logger)
54
+ end
55
+ io.verify
56
+ assert_nil config
57
+ end
58
+
21
59
  def test_config_manger_load_config
22
60
  logger = Logger.new("/dev/null")
23
61
  target_config = File.join(File.dirname(__FILE__), "test_files", "controller_test", "configure_test.json")
@@ -76,6 +76,42 @@ class ConfigParserTest < Minitest::Test
76
76
  assert_equal "/dev/nuller", configs[:project_config][:directory]
77
77
  end
78
78
 
79
+ def test_manifest_config_project_directory
80
+ logger = Logger.new("/dev/null")
81
+ options = {}
82
+ config = good_config
83
+ config[:projects][:project_dir] = "/tmp"
84
+ config[:projects][:project1][:directory] = "project1"
85
+
86
+
87
+ code = nil
88
+ configs = nil
89
+
90
+ code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
91
+
92
+ assert_equal RokuBuilder::SUCCESS, code
93
+ assert_equal Hash, config.class
94
+ assert_equal "/tmp/project1", configs[:project_config][:directory]
95
+ end
96
+
97
+ def test_manifest_config_key_directory
98
+ logger = Logger.new("/dev/null")
99
+ options = {key: true, project: :project2}
100
+ config = good_config
101
+ config[:keys][:key_dir] = "/tmp"
102
+ config[:keys][:a][:keyed_pkg] = "a"
103
+
104
+
105
+ code = nil
106
+ configs = nil
107
+
108
+ code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
109
+
110
+ assert_equal RokuBuilder::SUCCESS, code
111
+ assert_equal Hash, config.class
112
+ assert_equal "/tmp/a", configs[:key][:keyed_pkg]
113
+ end
114
+
79
115
  def test_setup_sideload_config
80
116
  args = {
81
117
  configs: {project_config: {directory: "/tmp", folders: ["a", "b"], files: ["c", "d"], excludes: []}, init_params: {}},
@@ -171,5 +171,19 @@ class ControllerTest < Minitest::Test
171
171
  logger.verify
172
172
  end
173
173
  end
174
+
175
+ def test_controller_validate_configs
176
+ configs = {out: {folder: "/out/folder"}}
177
+ exist = lambda {|args| assert_equal "/out/folder", args; true}
178
+ Dir.stub(:exist?, exist) do
179
+ assert_equal RokuBuilder::VALID, RokuBuilder::Controller.send(:validate_configs, configs: configs)
180
+ end
181
+
182
+ configs = {out: {folder: "/out/folder"}}
183
+ exist = lambda {|args| assert_equal "/out/folder", args; false}
184
+ Dir.stub(:exist?, exist) do
185
+ assert_equal RokuBuilder::MISSING_OUT_FOLDER, RokuBuilder::Controller.send(:validate_configs, configs: configs)
186
+ end
187
+ end
174
188
  end
175
189
 
@@ -403,7 +403,6 @@ class ControllerCommandsTest < Minitest::Test
403
403
  stager = Minitest::Mock.new
404
404
 
405
405
  options = {print: 'title', config: "~/.roku_config.json"}
406
- config = good_config
407
406
  configs = {stage_config: {}}
408
407
  code = nil
409
408
  scripter_config = {attribute: :title, configs: configs}
@@ -419,4 +418,35 @@ class ControllerCommandsTest < Minitest::Test
419
418
  assert_equal RokuBuilder::SUCCESS, code
420
419
  stager.verify
421
420
  end
421
+ def test_controller_commands_dostage
422
+ logger = Logger.new("/dev/null")
423
+ stager = Minitest::Mock.new
424
+
425
+ options = {dostage: true, config: "~/.roku_config.json"}
426
+ configs = {stage_config: {}}
427
+ code = nil
428
+ stager.expect(:stage, true)
429
+
430
+ RokuBuilder::Stager.stub(:new, stager) do
431
+ code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
432
+ end
433
+ assert_equal true, code
434
+ stager.verify
435
+ end
436
+
437
+ def test_controller_commands_dounstage
438
+ logger = Logger.new("/dev/null")
439
+ stager = Minitest::Mock.new
440
+
441
+ options = {dounstage: true, config: "~/.roku_config.json"}
442
+ configs = {stage_config: {}}
443
+ code = nil
444
+ stager.expect(:unstage, true)
445
+
446
+ RokuBuilder::Stager.stub(:new, stager) do
447
+ code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
448
+ end
449
+ assert_equal true, code
450
+ stager.verify
451
+ end
422
452
  end
File without changes
@@ -156,7 +156,6 @@ class NavigatorTest < Minitest::Test
156
156
  init_params: {mappings: {}}
157
157
  }
158
158
 
159
- input = nil
160
159
  navigator = RokuBuilder::Navigator.new(**device_config)
161
160
  STDIN.stub(:echo=, nil) do
162
161
  STDIN.stub(:raw!, nil) do
@@ -187,7 +186,6 @@ class NavigatorTest < Minitest::Test
187
186
  init_params: {mappings: {}}
188
187
  }
189
188
 
190
- input = nil
191
189
  navigator = RokuBuilder::Navigator.new(**device_config)
192
190
  STDIN.stub(:echo=, nil) do
193
191
  STDIN.stub(:raw!, nil) do
@@ -0,0 +1,82 @@
1
+ # ********** Copyright Viacom, Inc. Apache 2.0 **********
2
+
3
+ require_relative "test_helper.rb"
4
+
5
+ class GitTest < Minitest::Test
6
+
7
+ def test_stashes_pop
8
+ base = Minitest::Mock.new
9
+ lib = Minitest::Mock.new
10
+
11
+ index = 1
12
+ base.expect(:lib, lib)
13
+ lib.expect(:stash_pop, nil, [index])
14
+
15
+ Dir.mktmpdir do |dir|
16
+ git = Git.init(File.join(dir, "git"))
17
+ stashes = git.branch.stashes
18
+ stashes.instance_variable_set(:@base, base)
19
+ stashes.pop(index)
20
+ end
21
+
22
+ base.verify
23
+ lib.verify
24
+ end
25
+
26
+ def test_stashes_drop
27
+ base = Minitest::Mock.new
28
+ lib = Minitest::Mock.new
29
+
30
+ index = 1
31
+ base.expect(:lib, lib)
32
+ lib.expect(:stash_drop, nil, [index])
33
+
34
+ Dir.mktmpdir do |dir|
35
+ git = Git.init(File.join(dir, "git"))
36
+ stashes = git.branch.stashes
37
+ stashes.instance_variable_set(:@base, base)
38
+ stashes.drop(index)
39
+ end
40
+
41
+ base.verify
42
+ lib.verify
43
+ end
44
+
45
+ def test_lib_pop
46
+ lib = Git::Lib.new
47
+ command = lambda{|command_sent|
48
+ assert_equal "stash pop", command_sent
49
+ }
50
+ lib.stub(:command, command) do
51
+ lib.stash_pop
52
+ end
53
+
54
+ lib = Git::Lib.new
55
+ command = lambda{|command_sent, args|
56
+ assert_equal "stash pop", command_sent
57
+ assert_equal [1], args
58
+ }
59
+ lib.stub(:command, command) do
60
+ lib.stash_pop(1)
61
+ end
62
+ end
63
+
64
+ def test_lib_drop
65
+ lib = Git::Lib.new
66
+ command = lambda{|command_sent|
67
+ assert_equal "stash drop", command_sent
68
+ }
69
+ lib.stub(:command, command) do
70
+ lib.stash_drop
71
+ end
72
+
73
+ lib = Git::Lib.new
74
+ command = lambda{|command_sent, args|
75
+ assert_equal "stash drop", command_sent
76
+ assert_equal [1], args
77
+ }
78
+ lib.stub(:command, command) do
79
+ lib.stash_drop(1)
80
+ end
81
+ end
82
+ end
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: 3.11.1
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeneca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-27 00:00:00.000000000 Z
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -235,19 +235,33 @@ dependencies:
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0.9'
237
237
  - !ruby/object:Gem::Dependency
238
- name: guard-livereload
238
+ name: guard
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
241
  - - "~>"
242
242
  - !ruby/object:Gem::Version
243
- version: '2.5'
243
+ version: '2.14'
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
- version: '2.5'
250
+ version: '2.14'
251
+ - !ruby/object:Gem::Dependency
252
+ name: guard-minitest
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '2.4'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '2.4'
251
265
  description: Allows the user to easily sideload, package, deeplink, test, roku apps.
252
266
  email:
253
267
  - charles.greene@redspace.com
@@ -289,43 +303,44 @@ files:
289
303
  - lib/roku_builder/version.rb
290
304
  - rakefile
291
305
  - roku_builder.gemspec
292
- - tests/roku_builder/config_manager_test.rb
293
- - tests/roku_builder/config_parser_test.rb
294
- - tests/roku_builder/config_validator_test.rb
295
- - tests/roku_builder/controller_commands_test.rb
296
- - tests/roku_builder/controller_test.rb
297
- - tests/roku_builder/error_handler_test.rb
298
- - tests/roku_builder/inspector_test.rb
299
- - tests/roku_builder/keyer_test.rb
300
- - tests/roku_builder/linker_test.rb
301
- - tests/roku_builder/loader_test.rb
302
- - tests/roku_builder/manifest_manager_test.rb
303
- - tests/roku_builder/monitor_test.rb
304
- - tests/roku_builder/navigator_test.rb
305
- - tests/roku_builder/packager_test.rb
306
- - tests/roku_builder/profiler_test.rb
307
- - tests/roku_builder/scripter_test.rb
308
- - tests/roku_builder/stager_test.rb
309
- - tests/roku_builder/test_files/controller_config_test/valid_config.json
310
- - tests/roku_builder/test_files/controller_test/load_config_test.json
311
- - tests/roku_builder/test_files/controller_test/parent_config.json
312
- - tests/roku_builder/test_files/controller_test/valid_config.json
313
- - tests/roku_builder/test_files/loader_test/a
314
- - tests/roku_builder/test_files/loader_test/manifest
315
- - tests/roku_builder/test_files/loader_test/source/b
316
- - tests/roku_builder/test_files/loader_test/source/c/d
317
- - tests/roku_builder/test_files/manifest_manager_test/manifest_comments
318
- - tests/roku_builder/test_files/manifest_manager_test/manifest_template
319
- - tests/roku_builder/test_files/manifest_manager_test/manifest_template_2
320
- - tests/roku_builder/test_files/manifest_manager_test/test.zip
321
- - tests/roku_builder/test_files/manifest_manager_test/updated_title_manifest
322
- - tests/roku_builder/test_files/stager_test/a
323
- - tests/roku_builder/test_files/stager_test/manifest
324
- - tests/roku_builder/test_files/stager_test/source/b
325
- - tests/roku_builder/test_files/stager_test/source/c/d
326
- - tests/roku_builder/test_helper.rb
327
- - tests/roku_builder/tester_test.rb
328
- - tests/roku_builder/util_test.rb
306
+ - test/roku_builder/test_config_manager.rb
307
+ - test/roku_builder/test_config_parser.rb
308
+ - test/roku_builder/test_config_validator.rb
309
+ - test/roku_builder/test_controller.rb
310
+ - test/roku_builder/test_controller_commands.rb
311
+ - test/roku_builder/test_error_handler.rb
312
+ - test/roku_builder/test_files/controller_config_test/valid_config.json
313
+ - test/roku_builder/test_files/controller_test/load_config_test.json
314
+ - test/roku_builder/test_files/controller_test/parent_config.json
315
+ - test/roku_builder/test_files/controller_test/valid_config.json
316
+ - test/roku_builder/test_files/loader_test/a
317
+ - test/roku_builder/test_files/loader_test/manifest
318
+ - test/roku_builder/test_files/loader_test/source/b
319
+ - test/roku_builder/test_files/loader_test/source/c/d
320
+ - test/roku_builder/test_files/manifest_manager_test/manifest_comments
321
+ - test/roku_builder/test_files/manifest_manager_test/manifest_template
322
+ - test/roku_builder/test_files/manifest_manager_test/manifest_template_2
323
+ - test/roku_builder/test_files/manifest_manager_test/test.zip
324
+ - test/roku_builder/test_files/manifest_manager_test/updated_title_manifest
325
+ - test/roku_builder/test_files/stager_test/a
326
+ - test/roku_builder/test_files/stager_test/manifest
327
+ - test/roku_builder/test_files/stager_test/source/b
328
+ - test/roku_builder/test_files/stager_test/source/c/d
329
+ - test/roku_builder/test_helper.rb
330
+ - test/roku_builder/test_inspector.rb
331
+ - test/roku_builder/test_keyer.rb
332
+ - test/roku_builder/test_linker.rb
333
+ - test/roku_builder/test_loader.rb
334
+ - test/roku_builder/test_manifest_manager.rb
335
+ - test/roku_builder/test_monitor.rb
336
+ - test/roku_builder/test_navigator.rb
337
+ - test/roku_builder/test_packager.rb
338
+ - test/roku_builder/test_profiler.rb
339
+ - test/roku_builder/test_ruby_git.rb
340
+ - test/roku_builder/test_scripter.rb
341
+ - test/roku_builder/test_stager.rb
342
+ - test/roku_builder/test_tester.rb
343
+ - test/roku_builder/test_util.rb
329
344
  homepage: ''
330
345
  licenses:
331
346
  - MIT
@@ -350,4 +365,42 @@ rubygems_version: 2.5.2
350
365
  signing_key:
351
366
  specification_version: 4
352
367
  summary: Build Tool for Roku Apps
353
- test_files: []
368
+ test_files:
369
+ - test/roku_builder/test_config_manager.rb
370
+ - test/roku_builder/test_config_parser.rb
371
+ - test/roku_builder/test_config_validator.rb
372
+ - test/roku_builder/test_controller.rb
373
+ - test/roku_builder/test_controller_commands.rb
374
+ - test/roku_builder/test_error_handler.rb
375
+ - test/roku_builder/test_files/controller_config_test/valid_config.json
376
+ - test/roku_builder/test_files/controller_test/load_config_test.json
377
+ - test/roku_builder/test_files/controller_test/parent_config.json
378
+ - test/roku_builder/test_files/controller_test/valid_config.json
379
+ - test/roku_builder/test_files/loader_test/a
380
+ - test/roku_builder/test_files/loader_test/manifest
381
+ - test/roku_builder/test_files/loader_test/source/b
382
+ - test/roku_builder/test_files/loader_test/source/c/d
383
+ - test/roku_builder/test_files/manifest_manager_test/manifest_comments
384
+ - test/roku_builder/test_files/manifest_manager_test/manifest_template
385
+ - test/roku_builder/test_files/manifest_manager_test/manifest_template_2
386
+ - test/roku_builder/test_files/manifest_manager_test/test.zip
387
+ - test/roku_builder/test_files/manifest_manager_test/updated_title_manifest
388
+ - test/roku_builder/test_files/stager_test/a
389
+ - test/roku_builder/test_files/stager_test/manifest
390
+ - test/roku_builder/test_files/stager_test/source/b
391
+ - test/roku_builder/test_files/stager_test/source/c/d
392
+ - test/roku_builder/test_helper.rb
393
+ - test/roku_builder/test_inspector.rb
394
+ - test/roku_builder/test_keyer.rb
395
+ - test/roku_builder/test_linker.rb
396
+ - test/roku_builder/test_loader.rb
397
+ - test/roku_builder/test_manifest_manager.rb
398
+ - test/roku_builder/test_monitor.rb
399
+ - test/roku_builder/test_navigator.rb
400
+ - test/roku_builder/test_packager.rb
401
+ - test/roku_builder/test_profiler.rb
402
+ - test/roku_builder/test_ruby_git.rb
403
+ - test/roku_builder/test_scripter.rb
404
+ - test/roku_builder/test_stager.rb
405
+ - test/roku_builder/test_tester.rb
406
+ - test/roku_builder/test_util.rb