Module: RokuBuilder
- Defined in:
- lib/roku_builder/util.rb,
lib/roku_builder.rb,
lib/roku_builder/config.rb,
lib/roku_builder/errors.rb,
lib/roku_builder/logger.rb,
lib/roku_builder/plugin.rb,
lib/roku_builder/stager.rb,
lib/roku_builder/options.rb,
lib/roku_builder/version.rb,
lib/roku_builder/manifest.rb,
lib/roku_builder/plugins/core.rb,
lib/roku_builder/config_parser.rb,
lib/roku_builder/device_manager.rb,
lib/roku_builder/plugins/linker.rb,
lib/roku_builder/plugins/loader.rb,
lib/roku_builder/plugins/tester.rb,
lib/roku_builder/plugins/monitor.rb,
lib/roku_builder/plugins/rokuapi.rb,
lib/roku_builder/config_validator.rb,
lib/roku_builder/plugins/analyzer.rb,
lib/roku_builder/plugins/packager.rb,
lib/roku_builder/plugins/profiler.rb,
lib/roku_builder/plugins/scripter.rb,
lib/roku_builder/plugins/inspector.rb,
lib/roku_builder/plugins/navigator.rb,
lib/roku_builder/plugins/line_inspector.rb,
lib/roku_builder/plugins/indentation_inspector.rb
Overview
********** Copyright Viacom, Inc. Apache 2.0 **********
Defined Under Namespace
Modules: Plugin
Classes: Analyzer, Config, ConfigParser, ConfigValidator, Core, Device, DeviceError, DeviceManager, ExecutionError, ImplementationError, IndentationInspector, Inspector, InvalidConfig, InvalidOptions, LineInspector, Linker, Loader, Logger, Manifest, ManifestError, Monitor, Navigator, Options, Packager, ParseError, Profiler, RokuAPI, Scripter, Stager, Tester, Util
Constant Summary
collapse
- VERSION =
Version of the RokuBuilder Gem
"4.30.0"
Class Method Summary
collapse
Class Method Details
.device_manager ⇒ Object
177
178
179
|
# File 'lib/roku_builder.rb', line 177
def self.device_manager
@@device_manager ||= DeviceManager.new(config: @@config, options: @@options)
end
|
.execute ⇒ Object
73
74
75
76
|
# File 'lib/roku_builder.rb', line 73
def self.execute
load_config
execute_command
end
|
.execute_command ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/roku_builder.rb', line 181
def self.execute_command
@@plugins.each do |plugin|
if plugin.commands.keys.include?(@@options.command)
stager = nil
if plugin.commands[@@options.command][:stage]
stager = Stager.new(config: @@config, options: @@options)
stager.stage
end
instance = plugin.new(config: @@config)
instance.send(@@options.command, **{options: @@options})
stager.unstage if stager
end
end
end
|
.initialize_logger ⇒ Object
.load_config ⇒ Object
167
168
169
170
171
172
173
174
175
|
# File 'lib/roku_builder.rb', line 167
def self.load_config
@@config = Config.new(options: @@options)
@@config.configure
unless @@options[:configure] and not @@options[:edit_params]
@@config.load
@@config.validate
@@config.parse
end
end
|
.load_dev_plugin ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/roku_builder.rb', line 113
def self.load_dev_plugin
dev_path = nil
ARGV.each_index do |i|
if ARGV[i] == "--dev-plugin"
dev_path = ARGV[i+1]
2.times {ARGV.delete_at(i)}
break
end
end
if dev_path
@@dev = true
Dir.glob(File.join(dev_path, "lib", "*.rb")).each do |path|
require path
end
Dir.glob(File.join(dev_path, "lib", "roku_builder", "plugins", "*")).each do |path|
require path
end
@@dev = false
end
end
|
.load_plugins ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/roku_builder.rb', line 95
def self.load_plugins
Dir.glob(File.join(File.dirname(__FILE__), "roku_builder", "plugins", "*.rb")).each do |path|
file = "roku_builder/plugins/"+File.basename(path, ".rb")
require file
end
gem_versions = Gem::Specification.sort_by {|g| [g.name.downcase, g.version]}.group_by {|g| g.name}
gems = []
gem_versions.each {|v| gems.push(v.last.last)}
gems.each do |gem|
unless gem.name == "roku_builder"
Dir.glob(File.join(gem.full_gem_path, "lib", "roku_builder", "plugins", "*")).each do |path|
require path
end
end
end
load_dev_plugin
end
|
.options_parse(options:) ⇒ Hash
Parses a string into and options hash
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/roku_builder.rb', line 199
def self.options_parse(options:)
parsed = {}
opts = options.split(/,\s*/)
opts.each do |opt|
opt = opt.split(":")
key = opt.shift.strip.to_sym
value = opt.join(":").strip
parsed[key] = value
end
parsed
end
|
.plugins ⇒ Object
78
79
80
|
# File 'lib/roku_builder.rb', line 78
def self.plugins
@@plugins ||= []
end
|
.process_hook(hook:, params:) ⇒ Object
211
212
213
214
215
216
217
|
# File 'lib/roku_builder.rb', line 211
def self.process_hook(hook:, params:)
@@plugins.each do |plugin|
if plugin.respond_to?("#{hook}_hook".to_sym)
plugin.send("#{hook}_hook", **params)
end
end
end
|
.process_plugins ⇒ Object
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/roku_builder.rb', line 134
def self.process_plugins
@@plugins ||= []
@@plugins.sort! {|a,b| a.to_s <=> b.to_s}
unless @@plugins.count == @@plugins.uniq.count
duplicates = @@plugins.select{ |e| @@plugins.count(e) > 1 }.uniq
raise ImplementationError, "Duplicate plugins: #{duplicates.join(", ")}"
end
@@plugins.each do |plugin|
plugin.dependencies.each do |dependency|
raise ImplementationError, "Missing dependency: #{dependency}" unless @@plugins.include?(dependency)
end
plugin.commands.keys.each do |command|
raise ImplementationError, "Missing command method '#{command}' in #{plugin}" unless plugin.instance_methods.include?(command)
end
end
end
|
.register_plugin(plugin) ⇒ Object
82
83
84
85
86
87
|
# File 'lib/roku_builder.rb', line 82
def self.register_plugin(plugin)
@@dev ||= false
@@plugins ||= []
@@plugins.delete(plugin) if @@dev
@@plugins << plugin
end
|
.run(options: nil) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/roku_builder.rb', line 43
def self.run(options: nil)
@@options = nil
@@testing ||= false
setup_plugins
setup_options(options: options)
return unless @@options
initialize_logger
if @@options[:debug]
execute
else
begin
execute
rescue StandardError => e
Logger.instance.fatal "#{e.class}: #{e.message}"
exit false unless @@testing
end
end
end
|
.set_testing ⇒ Object
226
227
228
229
|
# File 'lib/roku_builder.rb', line 226
def self.set_testing
@@testing = true
Logger.set_testing
end
|
.setup_options(options:) ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/roku_builder.rb', line 62
def self.setup_options(options:)
begin
@@options = Options.new(options: options)
@@options.validate
rescue InvalidOptions => e
Logger.instance.fatal "#{e.class}: #{e.message}"
@@options = nil
return
end
end
|
.setup_plugins ⇒ Object
89
90
91
92
93
|
# File 'lib/roku_builder.rb', line 89
def self.setup_plugins
load_plugins
process_plugins
validate_plugins
end
|
.system(command:) ⇒ String
222
223
224
|
# File 'lib/roku_builder.rb', line 222
def self.system(command:)
`#{command}`.chomp
end
|
.validate_plugins ⇒ Object
151
152
153
154
155
|
# File 'lib/roku_builder.rb', line 151
def self.validate_plugins
@@plugins.each do |plugin|
plugin.validate
end
end
|