Class: RokuBuilder::Scripter
- Inherits:
-
Object
- Object
- RokuBuilder::Scripter
- Extended by:
- Plugin
- Defined in:
- lib/roku_builder/plugins/scripter.rb
Overview
Helper for extending for scripting
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config:) ⇒ Scripter
constructor
A new instance of Scripter.
- #print(options:) ⇒ Object
Methods included from Plugin
commands, dependencies, parse_options, validate
Constructor Details
#initialize(config:) ⇒ Scripter
Returns a new instance of Scripter.
20 21 22 |
# File 'lib/roku_builder/plugins/scripter.rb', line 20 def initialize(config:) @config = config end |
Class Method Details
.commands ⇒ Object
9 10 11 |
# File 'lib/roku_builder/plugins/scripter.rb', line 9 def self.commands {print: {source: true, stage: true}} end |
.parse_options(parser:, options:) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/roku_builder/plugins/scripter.rb', line 13 def self.(parser:, options:) parser.separator("Commands:") parser.on("--print ATTRIBUTE", "Print attribute for scripting") do |a| [:print] = a.to_sym end end |
Instance Method Details
#print(options:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/roku_builder/plugins/scripter.rb', line 24 def print(options:) manifest = Manifest.new(config: @config) case [:print] when :root_dir printf "%s", @config.project[:directory] when :app_name printf "%s", @config.project[:app_name] when :title printf "%s", manifest.title when :build_version printf "%s", manifest.build_version when :app_version major = manifest.major_version minor = manifest.minor_version printf "%s.%s", major, minor else if manifest.send([:print]) printf manifest.send([:print]) else raise ExecutionError, "Unknown attribute: #{[:print]}" end end end |