Class: RokuBuilder::Core
- Inherits:
-
Object
- Object
- RokuBuilder::Core
- Extended by:
- Plugin
- Defined in:
- lib/roku_builder/plugins/core.rb
Class Method Summary collapse
- .commands ⇒ Object
- .get_help_text(parser:, options:, plugin_name:) ⇒ Object
- .get_plugin_by_name(name) ⇒ Object
- .parse_options(parser:, options:) ⇒ Object
Instance Method Summary collapse
- #configure(options:) ⇒ Object
- #dostage(options:) ⇒ Object
- #dounstage(options:) ⇒ Object
- #increment(options:) ⇒ Object
-
#initialize(config:) ⇒ Core
constructor
A new instance of Core.
- #release_all_devices(options:) ⇒ Object
- #validate(options:) ⇒ Object
Methods included from Plugin
commands, dependencies, parse_options
Constructor Details
#initialize(config:) ⇒ Core
Returns a new instance of Core.
103 104 105 |
# File 'lib/roku_builder/plugins/core.rb', line 103 def initialize(config:) @config = config end |
Class Method Details
.commands ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/roku_builder/plugins/core.rb', line 8 def self.commands { configure: {}, validate: {keyed: true}, increment: {source: true, stage: true}, dostage: {source: true}, dounstage: {source: true}, release_all_devices: {}, } end |
.get_help_text(parser:, options:, plugin_name:) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/roku_builder/plugins/core.rb', line 136 def self.get_help_text(parser:, options:, plugin_name:) plugin = self.get_plugin_by_name(plugin_name) if nil == plugin return parser.to_s else pluginParser = OptionParser.new pluginParser.separator "" pluginParser.separator "Options for #{plugin}:" plugin.(parser: pluginParser, options: ) return pluginParser.to_s end end |
.get_plugin_by_name(name) ⇒ Object
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/roku_builder/plugins/core.rb', line 149 def self.get_plugin_by_name(name) if name.nil? return nil end pluginIndex = RokuBuilder.plugins.map{|pluginClass| pluginClass.name.split('::').last().downcase}.index(name.downcase) if !pluginIndex.nil? plugin = RokuBuilder.plugins[pluginIndex] return plugin end end |
.parse_options(parser:, options:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/roku_builder/plugins/core.rb', line 19 def self.(parser:, options:) parser.separator "Commands:" parser.on("--configure", "Copy base configuration file to the --config location. Default: '~/.roku_config.json'") do [:configure] = true end parser.on("--validate", "Validate configuration") do [:validate] = true end parser.on("-u", "--update-manifest", "Increment manifest build version") do [:increment] = true end parser.on("--do-stage", "Run the stager. Used for scripting. Always run --do-unstage after") do [:dostage] = true end parser.on("--do-unstage", "Run the unstager. Used for scripting. Always run --do-script first") do [:dounstage] = true end parser.on("--release-all-devices", "Releases all devices, deleting lock files") do [:release_all_devices] = true end parser.separator "" parser.separator "Config Options:" parser.on("-e", "--edit PARAMS", "Edit config params when configuring. (eg. a:b, c:d,e:f)") do |p| [:edit_params] = p end parser.on("--config CONFIG", "Set a custom config file. Default: '~/.roku_config.json'") do |c| [:config] = c end parser.separator "" parser.separator "Source Options:" parser.on("-r", "--ref REF", "Git referance to use for sideloading") do |r| [:ref] = r end parser.on("-w", "--working", "Use working directory to sideload or test") do [:working] = true end parser.on("-c", "--current", "Use current directory to sideload or test. Overrides any project config") do [:current] = true end parser.on("-s", "--stage STAGE", "Set the stage to use. Default: 'production'") do |b| [:stage] = b end parser.on("-P", "--project ID", "Use a different project") do |p| [:project] = p end parser.separator "" parser.separator "Other Options:" parser.on("-L", "--console_log [FILE]", "Save monitor logs in file") do |l| [:logfile] = l || "config" [:logging] = true end parser.on("-C", "--clear_log [FILE]", "Clear saved monitor logs in file") do |l| [:logfile] = l || "config" [:clearfile] = true end parser.on("-O", "--out PATH", "Output file/folder. If PATH ends in .pkg/.zip/.jpg, file is assumed, otherwise folder is assumed") do |o| [:out] = o end parser.on("-I", "--in PATH", "Input file for sideloading") do |i| [:in] = i end parser.on("-D", "--device ID", "Use a different device corresponding to the given ID") do |d| [:device] = d end parser.on("--device-blocking", "Block and wait for a device if none is ready. Does not work with --device") do [:device_blocking] = true end parser.on("-V", "--verbose", "Print Info message") do [:verbose] = true end parser.on("--debug", "Print Debug messages") do [:debug] = true end parser.on("-h", "--help [PLUGIN]", "Show help") do |h| help_text = self.get_help_text(parser: parser, options: , plugin_name: h) puts help_text exit end parser.on("-v", "--version", "Show version") do puts RokuBuilder::VERSION exit end end |
Instance Method Details
#configure(options:) ⇒ Object
107 108 109 110 111 |
# File 'lib/roku_builder/plugins/core.rb', line 107 def configure(options:) # Stub command # Handled in the config class Logger.instance.unknown "Configured" end |
#dostage(options:) ⇒ Object
124 125 126 |
# File 'lib/roku_builder/plugins/core.rb', line 124 def dostage(options:) Stager.new(config: @config, options: ).stage end |
#dounstage(options:) ⇒ Object
127 128 129 |
# File 'lib/roku_builder/plugins/core.rb', line 127 def dounstage(options:) Stager.new(config: @config, options: ).unstage end |
#increment(options:) ⇒ Object
117 118 119 120 121 122 123 |
# File 'lib/roku_builder/plugins/core.rb', line 117 def increment(options:) manifest = Manifest.new(config: @config) old = manifest.build_version manifest.increment_build_version new = manifest.build_version Logger.instance.info "Update build version from:\n#{old}\nto:\n#{new}" end |
#release_all_devices(options:) ⇒ Object
130 131 132 133 134 |
# File 'lib/roku_builder/plugins/core.rb', line 130 def release_all_devices(options:) manager = DeviceManager.new(config: @config, options: @options) manager.release_all Logger.instance.info "All devices unlocked" end |