roku_builder 3.12.5 → 3.12.6

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: b84000d926e8db3e7fd7b8c914b52f78f1a4ce4d
4
- data.tar.gz: 40586d39402dd539138b215c31d2840e166b304e
3
+ metadata.gz: 7ef20c9d8920488e1f6102fbab02b28ccbb80673
4
+ data.tar.gz: cd1b32fbf7fb6ab5fdd115c7668011018e0f57e7
5
5
  SHA512:
6
- metadata.gz: cbcd65228f732a9c7091fe806ee37b7136bd7a05c5007ac0b252cc96cc59d5b1da65c305791a2ddb29ea254ea0a52a7a94f21478c374037408e1f9772aca11b6
7
- data.tar.gz: faf91298b57a59e4b01cd6e5a7944da703abba7be7edb4aa307e50704139e09b4ebe386bf3b9aa237ad5c3c69d66930405d76c822e09eeef4c3cf9c1089e7152
6
+ metadata.gz: 64bc408f43e49d29d271f6dc4a6d5caf455a2a66e6e14616cc1b2ee374df10bcfc31236a2a8d9baf854e9728c753a3f2255fb5916717cc21234f70c5436c4e3f
7
+ data.tar.gz: fa56cde1eaf03aa4908c8ff240f149847176a026dbe97ad556c563a354e67e3486f3e791ea1cc9c1fe4b5f1cca0aada1ac315d0ddddbd11ef925d1482499f86f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roku_builder (3.12.5)
4
+ roku_builder (3.12.6)
5
5
  faraday (~> 0.11)
6
6
  faraday-digestauth (~> 0.2)
7
7
  git (~> 1.3)
@@ -64,7 +64,7 @@ GEM
64
64
  net-http-digest_auth (1.4.1)
65
65
  net-ping (2.0.1)
66
66
  net-telnet (0.1.1)
67
- nokogiri (1.7.0.1)
67
+ nokogiri (1.7.1)
68
68
  mini_portile2 (~> 2.1.0)
69
69
  notiffany (0.1.1)
70
70
  nenv (~> 0.1)
data/README.md CHANGED
@@ -52,8 +52,9 @@ following command:
52
52
  $ roku --configure
53
53
 
54
54
  This will create the file '~/.roku_config.json' with a default configuration.
55
- Edit this file to add appropriate values. The following are default
56
- configuration options:
55
+ Edit this file to add appropriate values. A configuration example with the
56
+ minimum require fields can be found in this project called 'config.json.min'.
57
+ The following are default configuration options:
57
58
 
58
59
  ##### Top Level Configuration
59
60
 
data/config.json.example CHANGED
@@ -3,7 +3,7 @@
3
3
  "default": "<device_id>",
4
4
  "<device_id>": {
5
5
  "ip": "xxx.xxx.xxx.xxx",
6
- "user": "<username>",
6
+ "user": "rokudev",
7
7
  "password": "<password>"
8
8
  }
9
9
  },
data/config.json.min ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "devices": {
3
+ "default": "<device_id>",
4
+ "<device_id>": {
5
+ "ip": "xxx.xxx.xxx.xxx",
6
+ "user": "rokudev",
7
+ "password": "password"
8
+ }
9
+ }
10
+ }
@@ -49,20 +49,22 @@ module RokuBuilder
49
49
  config = build_config(config: config, logger: logger)
50
50
  return nil unless config
51
51
  config[:devices][:default] = config[:devices][:default].to_sym
52
- config[:projects][:default] = config[:projects][:default].to_sym
53
- config[:projects].each_pair do |key,value|
54
- next if key == :default
55
- next if key == :project_dir
56
- if value[:stage_method]
57
- value[:stage_method] = value[:stage_method].to_sym
52
+ if config[:projects]
53
+ config[:projects][:default] = config[:projects][:default].to_sym
54
+ config[:projects].each_pair do |key,value|
55
+ next if key == :default
56
+ next if key == :project_dir
57
+ if value[:stage_method]
58
+ value[:stage_method] = value[:stage_method].to_sym
59
+ end
58
60
  end
59
- end
60
- config[:projects].each_pair do |key, value|
61
- unless key == :default or key == :project_dir
62
- if value[:parent] and config[:projects][value[:parent].to_sym]
63
- new_value = config[:projects][value[:parent].to_sym]
64
- new_value = new_value.deep_merge value
65
- config[:projects][key] = new_value
61
+ config[:projects].each_pair do |key, value|
62
+ unless key == :default or key == :project_dir
63
+ if value[:parent] and config[:projects][value[:parent].to_sym]
64
+ new_value = config[:projects][value[:parent].to_sym]
65
+ new_value = new_value.deep_merge value
66
+ config[:projects][key] = new_value
67
+ end
66
68
  end
67
69
  end
68
70
  end
@@ -19,7 +19,7 @@ module RokuBuilder
19
19
  options[:device] = config[:devices][:default]
20
20
  end
21
21
  #set project
22
- setup_project(config: config, options: options)
22
+ setup_project(config: config, options: options) if project_required(options: options)
23
23
  #set outfile
24
24
  setup_outfile(options: options, configs: configs)
25
25
  # Create Device Config
@@ -30,10 +30,11 @@ module RokuBuilder
30
30
  return [project_config, nil, nil] unless project_config.class == Hash
31
31
  configs[:project_config] = project_config
32
32
  stage = setup_stage_config(configs: configs, options: options, logger: logger)[1]
33
- return [UNKNOWN_STAGE, nil, nil] unless stage
33
+ return [UNKNOWN_STAGE, nil, nil] if stage.nil? and project_required(options: options)
34
34
  setup_sideload_config(configs: configs, options: options)
35
35
  setup_package_config(config: config, configs: configs, options: options, stage: stage)
36
36
  setup_active_configs(config: config, configs: configs, options: options)
37
+ setup_manifest_configs(configs: configs, options: options)
37
38
  setup_simple_configs(config: config, configs: configs, options: options)
38
39
  return [SUCCESS, configs]
39
40
  end
@@ -109,7 +110,7 @@ module RokuBuilder
109
110
  files: nil,
110
111
  stage_method: :current
111
112
  }
112
- else
113
+ elsif project_required(options: options)
113
114
  project_config = config[:projects][options[:project].to_sym]
114
115
  return UNKNOWN_PROJECT unless project_config
115
116
  if config[:projects][:project_dir]
@@ -121,34 +122,43 @@ module RokuBuilder
121
122
  end
122
123
  private_class_method :setup_project_config
123
124
 
125
+ # Determine whether a project is required
126
+ # @param options [Hash] The options hash
127
+ # @return [Boolean] Whether a project is required or not
128
+ def self.project_required(options:)
129
+ has_source_command = (Controller.source_commands & options.keys).count > 0
130
+ non_project_source = ([:current, :in] & options.keys).count > 0
131
+ has_source_command and not non_project_source
132
+ end
133
+ private_class_method :project_required
134
+
124
135
  # Setup the project stage config
125
136
  # @param configs [Hash] The loaded config hash
126
137
  # @param options [Hash] The options hash
127
138
  # @return [Hash] The stage config hash
128
139
  def self.setup_stage_config(configs:, options:, logger:)
129
140
  stage_config = {logger: logger}
141
+ stage_config[:method] = ([:in, :current] & options.keys).first
130
142
  stage = options[:stage].to_sym if options[:stage]
131
- project_config = configs[:project_config]
132
- unless project_config[:stage_method] == :current
143
+ if project_required(options: options)
144
+ project_config = configs[:project_config]
133
145
  stage ||= project_config[:stages].keys[0].to_sym
134
- else
135
- stage = :current
136
- end
137
- options[:stage] = stage
138
- stage_config[:root_dir] = project_config[:directory]
139
- stage_config[:method] = project_config[:stage_method]
140
- stage_config[:method] ||= :git
141
- case stage_config[:method]
142
- when :git
143
- if options[:ref]
144
- stage_config[:key] = options[:ref]
145
- else
146
+ options[:stage] = stage
147
+ stage_config[:root_dir] = project_config[:directory]
148
+ stage_config[:method] = project_config[:stage_method]
149
+ stage_config[:method] ||= :git
150
+ case stage_config[:method]
151
+ when :git
152
+ if options[:ref]
153
+ stage_config[:key] = options[:ref]
154
+ else
155
+ return [nil, nil] unless project_config[:stages][stage]
156
+ stage_config[:key] = project_config[:stages][stage][:branch]
157
+ end
158
+ when :script
146
159
  return [nil, nil] unless project_config[:stages][stage]
147
- stage_config[:key] = project_config[:stages][stage][:branch]
160
+ stage_config[:key] = project_config[:stages][stage][:script]
148
161
  end
149
- when :script
150
- return [nil, nil] unless project_config[:stages][stage]
151
- stage_config[:key] = project_config[:stages][stage][:script]
152
162
  end
153
163
  configs[:stage_config] = stage_config
154
164
  configs[:stage] = stage
@@ -160,16 +170,18 @@ module RokuBuilder
160
170
  # @param options [Hash] The options hash
161
171
  # @param branch [String] the branch to sideload
162
172
  def self.setup_sideload_config(configs:, options:)
163
- root_dir = configs[:project_config][:directory]
164
- content = {
165
- folders: configs[:project_config][:folders],
166
- files: configs[:project_config][:files],
167
- }
168
- all_commands = options.keys & Controller.commands
169
- if options[:exclude] or Controller.exclude_commands.include?(all_commands.first)
170
- content[:excludes] = configs[:project_config][:excludes]
173
+ root_dir, content = nil, nil
174
+ if configs[:project_config]
175
+ root_dir = configs[:project_config][:directory]
176
+ content = {
177
+ folders: configs[:project_config][:folders],
178
+ files: configs[:project_config][:files],
179
+ }
180
+ all_commands = options.keys & Controller.commands
181
+ if options[:exclude] or Controller.exclude_commands.include?(all_commands.first)
182
+ content[:excludes] = configs[:project_config][:excludes]
183
+ end
171
184
  end
172
-
173
185
  # Create Sideload Config
174
186
  configs[:sideload_config] = {
175
187
  update_manifest: options[:update_manifest],
@@ -177,12 +189,8 @@ module RokuBuilder
177
189
  content: content
178
190
  }
179
191
  # Create Build Config
180
- configs[:build_config] = {
181
- content: content
182
- }
183
- configs[:init_params][:loader] = {
184
- root_dir: root_dir
185
- }
192
+ configs[:build_config] = { content: content }
193
+ configs[:init_params][:loader] = { root_dir: root_dir }
186
194
  end
187
195
  private_class_method :setup_sideload_config
188
196
 
@@ -249,15 +257,26 @@ module RokuBuilder
249
257
  end
250
258
  private_class_method :setup_active_configs
251
259
 
252
- # Setup other configs
260
+ # Setup manifest configs
253
261
  # @param configs [Hash] The parsed configs hash
254
262
  # @param options [Hash] The options hash
255
263
  # @param logger [Logger] System logger
256
- def self.setup_simple_configs(config:, configs:, options:)
264
+ def self.setup_manifest_configs(configs:, options:)
257
265
  # Create Manifest Config
266
+ root_dir = configs[:project_config][:directory] if configs[:project_config]
267
+ root_dir = options[:in] if options[:in]
268
+ root_dir = Pathname.pwd.to_s if options[:current]
258
269
  configs[:manifest_config] = {
259
- root_dir: configs[:project_config][:directory]
270
+ root_dir: root_dir
260
271
  }
272
+ end
273
+ private_class_method :setup_manifest_configs
274
+
275
+ # Setup other configs
276
+ # @param configs [Hash] The parsed configs hash
277
+ # @param options [Hash] The options hash
278
+ # @param logger [Logger] System logger
279
+ def self.setup_simple_configs(config:, configs:, options:)
261
280
  # Create Deeplink Config
262
281
  configs[:deeplink_config] = {options: options[:deeplink]}
263
282
  if options[:app_id]
@@ -5,7 +5,7 @@ module RokuBuilder
5
5
  MISSING_DEVICES = 1
6
6
  MISSING_DEVICES_DEFAULT = 2
7
7
  DEVICE_DEFAULT_BAD = 3
8
- MISSING_PROJECTS = 4
8
+ # = 4
9
9
  MISSING_PROJECTS_DEFAULT = 5
10
10
  PROJECTS_DEFAULT_BAD = 6
11
11
  DEVICE_MISSING_IP = 7
@@ -69,7 +69,7 @@ module RokuBuilder
69
69
  "Devices config is missing.",
70
70
  "Devices default is missing.",
71
71
  "Devices default is not a hash.",
72
- "Projects config is missing.",
72
+ "",
73
73
  "Projects default is missing.", #5
74
74
  "Projects default is not a hash.",
75
75
  "A device config is missing its IP address.",
@@ -101,7 +101,6 @@ module RokuBuilder
101
101
  [MISSING_DEVICES, !config[:devices]],
102
102
  [MISSING_DEVICES_DEFAULT, (config[:devices] and !config[:devices][:default])],
103
103
  [DEVICE_DEFAULT_BAD, (config[:devices] and config[:devices][:default] and !config[:devices][:default].is_a?(Symbol))],
104
- [MISSING_PROJECTS, (!config[:projects])],
105
104
  [MISSING_PROJECTS_DEFAULT, (config[:projects] and !config[:projects][:default])],
106
105
  [MISSING_PROJECTS_DEFAULT, (config[:projects] and config[:projects][:default] == "<project id>".to_sym)],
107
106
  [PROJECTS_DEFAULT_BAD, (config[:projects] and config[:projects][:default] and !config[:projects][:default].is_a?(Symbol))]
@@ -184,7 +184,7 @@ module RokuBuilder
184
184
  # List of depricated options
185
185
  # @return [Hash] Hash of depricated options and the warning message for each
186
186
  def self.depricated_options
187
- {deeplink_depricated: "-L and --deeplink are depricated. Use -o -r --deeplink-options." }
187
+ {deeplink_depricated: "-L and --deeplink are depricated. Use -o or --deeplink-options." }
188
188
  end
189
189
 
190
190
  # List of source options
@@ -196,7 +196,7 @@ module RokuBuilder
196
196
  # List of commands requiring a source option
197
197
  # @return [Array<Symbol>] List of command symbols that require a source in the options hash
198
198
  def self.source_commands
199
- [:sideload, :package, :test, :build, :key]
199
+ [:sideload, :package, :test, :build, :key, :update]
200
200
  end
201
201
 
202
202
  # List of commands the activate the exclude files
@@ -5,7 +5,7 @@ module RokuBuilder
5
5
  # Change stage of roku application
6
6
  class Stager
7
7
 
8
- def initialize(key: nil, method:, root_dir:, logger:)
8
+ def initialize(key: nil, method:, root_dir: nil, logger:)
9
9
  @method = method
10
10
  @key = key
11
11
  @root_dir = root_dir
@@ -25,11 +25,9 @@ module RokuBuilder
25
25
  # @return [Boolean] whether the staging was successful or not
26
26
  def stage
27
27
  @orginal_directory = Dir.pwd
28
- Dir.chdir(@root_dir) unless @root_dir == @orginal_directory
28
+ Dir.chdir(@root_dir) unless @root_dir.nil? or @root_dir == @orginal_directory
29
29
  case @method
30
- when :current
31
- # Do Nothing
32
- when :working
30
+ when :current, :in, :working
33
31
  # Do Nothing
34
32
  when :git
35
33
  begin
@@ -48,12 +46,10 @@ module RokuBuilder
48
46
  # @return [Boolean] whether the revert was successful or not
49
47
  def unstage
50
48
  @orginal_directory ||= Dir.pwd
51
- Dir.chdir(@root_dir) unless @root_dir == @orginal_directory
49
+ Dir.chdir(@root_dir) unless @root_dir.nil? or @root_dir == @orginal_directory
52
50
  unstage_success = true
53
51
  case @method
54
- when :current
55
- # Do Nothing
56
- when :working
52
+ when :current, :in, :working
57
53
  # Do Nothing
58
54
  when :git
59
55
  begin
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RokuBuilder
4
4
  # Version of the RokuBuilder Gem
5
- VERSION = "3.12.5"
5
+ VERSION = "3.12.6"
6
6
  end
@@ -96,13 +96,6 @@ class ConfigManagerTest < Minitest::Test
96
96
  assert_nil config
97
97
  assert_nil configs
98
98
 
99
- # Test Unknown Project
100
- options = {validate: true, project: :bad, config: target_config}
101
- code, config, configs = RokuBuilder::ConfigManager.load_config(options: options, logger: logger)
102
- assert_equal RokuBuilder::UNKNOWN_PROJECT, code
103
- assert_nil config
104
- assert_nil configs
105
-
106
99
  # Test Depricated Config
107
100
  options = {validate: true, stage: 'production', config: target_config}
108
101
  RokuBuilder::ConfigValidator.stub(:validate_config, [-1]) do
@@ -10,6 +10,7 @@ class ConfigParserTest < Minitest::Test
10
10
  stage: 'production',
11
11
  update_manifest: false,
12
12
  fetch: false,
13
+ sideload: true
13
14
  }
14
15
  config = good_config
15
16
  code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
@@ -19,6 +20,47 @@ class ConfigParserTest < Minitest::Test
19
20
  assert_equal "/dev/null", configs[:manifest_config][:root_dir]
20
21
  end
21
22
 
23
+ def test_manifest_config_in
24
+ logger = Logger.new("/dev/null")
25
+ options = {
26
+ config: File.expand_path(File.join(File.dirname(__FILE__), "test_files", "controller_config_test", "valid_config.json")),
27
+ in: "/dev/null/infile",
28
+ update_manifest: false,
29
+ fetch: false,
30
+ sideload: true
31
+ }
32
+ config = good_config
33
+ code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
34
+
35
+ assert_equal RokuBuilder::SUCCESS, code
36
+ assert_equal Hash, config.class
37
+ assert_equal "/dev/null/infile", configs[:manifest_config][:root_dir]
38
+ assert_equal :in, configs[:stage_config][:method]
39
+ end
40
+
41
+ def test_manifest_config_current
42
+ logger = Logger.new("/dev/null")
43
+ options = {
44
+ config: File.expand_path(File.join(File.dirname(__FILE__), "test_files", "controller_config_test", "valid_config.json")),
45
+ current: true,
46
+ update_manifest: false,
47
+ fetch: false,
48
+ sideload: true
49
+ }
50
+ code, configs = nil
51
+ config = good_config
52
+ Pathname.stub(:pwd, "/dev/null/infile") do
53
+ File.stub(:exist?, true) do
54
+ code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
55
+ end
56
+ end
57
+
58
+ assert_equal RokuBuilder::SUCCESS, code
59
+ assert_equal Hash, config.class
60
+ assert_equal "/dev/null/infile", configs[:manifest_config][:root_dir]
61
+ assert_equal :current, configs[:stage_config][:method]
62
+ end
63
+
22
64
  def test_setup_project_config_current
23
65
  args = {
24
66
  config: {},
@@ -37,7 +79,7 @@ class ConfigParserTest < Minitest::Test
37
79
  def test_setup_stage_config_script
38
80
  args = {
39
81
  configs: {project_config: {directory: "/tmp", stage_method: :script, stages: {production: {script: "script"}}}},
40
- options: {stage: "production"},
82
+ options: {stage: "production", sideload: true},
41
83
  logger: Logger.new("/dev/null")
42
84
  }
43
85
  config = RokuBuilder::ConfigParser.send(:setup_stage_config, **args)[0]
@@ -47,7 +89,7 @@ class ConfigParserTest < Minitest::Test
47
89
  def test_setup_stage_config_git_ref
48
90
  args = {
49
91
  configs: {project_config: {directory: "/tmp", stage_method: :git, }},
50
- options: {stage: "production", ref: "git-ref"},
92
+ options: {stage: "production", ref: "git-ref", sideload: true},
51
93
  logger: Logger.new("/dev/null")
52
94
  }
53
95
  config = RokuBuilder::ConfigParser.send(:setup_stage_config, **args)[0]
@@ -61,6 +103,7 @@ class ConfigParserTest < Minitest::Test
61
103
  stage: 'production',
62
104
  update_manifest: false,
63
105
  fetch: false,
106
+ sideload: true
64
107
  }
65
108
  config = good_config
66
109
 
@@ -78,7 +121,9 @@ class ConfigParserTest < Minitest::Test
78
121
 
79
122
  def test_manifest_config_project_directory
80
123
  logger = Logger.new("/dev/null")
81
- options = {}
124
+ options = {
125
+ sideload: true
126
+ }
82
127
  config = good_config
83
128
  config[:projects][:project_dir] = "/tmp"
84
129
  config[:projects][:project1][:directory] = "project1"
@@ -102,6 +147,7 @@ class ConfigParserTest < Minitest::Test
102
147
  stage: 'production',
103
148
  update_manifest: false,
104
149
  fetch: false,
150
+ sideload: true
105
151
  }
106
152
  config = good_config
107
153
  config[:projects][:project_dir] = "/tmp"
@@ -92,7 +92,7 @@ class ConfigValidatorTest < Minitest::Test
92
92
  config = good_config
93
93
  config[:projects] = nil
94
94
  codes = RokuBuilder::ConfigValidator.validate_config(config: config)
95
- assert_equal [4], codes
95
+ assert_equal [0], codes
96
96
  end
97
97
 
98
98
  def test_config_manager_validate_projects_default
@@ -39,6 +39,18 @@ class StagerTest < Minitest::Test
39
39
  assert stager.unstage
40
40
  end
41
41
 
42
+ def test_stager_stage_in
43
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
44
+ stager_config = {
45
+ method: :in,
46
+ root_dir: root_dir,
47
+ logger: nil
48
+ }
49
+ stager = RokuBuilder::Stager.new(**stager_config)
50
+ assert stager.stage
51
+ assert stager.unstage
52
+ end
53
+
42
54
  def test_stager_stage_git_stash
43
55
  root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
44
56
  branch_name = 'branch'
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.12.5
4
+ version: 3.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeneca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-23 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -295,6 +295,7 @@ files:
295
295
  - README.md
296
296
  - bin/roku
297
297
  - config.json.example
298
+ - config.json.min
298
299
  - lib/roku_builder.rb
299
300
  - lib/roku_builder/config_manager.rb
300
301
  - lib/roku_builder/config_parser.rb