Class: Processing::Runner
- Inherits:
-
Object
- Object
- Processing::Runner
- Defined in:
- lib/jruby_art/runner.rb
Overview
Utility class to handle the different commands that the ‘k9’ command offers. Able to run, watch, live, create, app, and unpack
Constant Summary collapse
- WIN_PATTERNS =
[ /bccwin/i, /cygwin/i, /djgpp/i, /ming/i, /mswin/i, /wince/i ].freeze
Instance Attribute Summary collapse
-
#argc ⇒ Object
readonly
Returns the value of attribute argc.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
Class Method Summary collapse
-
.execute ⇒ Object
Start running a jruby_art filename from the passed-in arguments.
Instance Method Summary collapse
- #check ⇒ Object
- #create ⇒ Object
-
#execute! ⇒ Object
Dispatch central.
-
#export ⇒ Object
Export as app not implemented.
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #install ⇒ Object
-
#live ⇒ Object
Just simply run a JRubyArt filename.
-
#parse_options(args) ⇒ Object
Parse the command-line options.
-
#run_sketch ⇒ Object
Just simply run a JRubyArt filename.
-
#show_help ⇒ Object
Show the standard help/usage message.
- #show_version ⇒ Object
-
#watch_sketch ⇒ Object
Run a filename, keeping an eye on it’s file, and reloading whenever it changes.
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
26 27 28 |
# File 'lib/jruby_art/runner.rb', line 26 def initialize @options = {} end |
Instance Attribute Details
#argc ⇒ Object (readonly)
Returns the value of attribute argc.
24 25 26 |
# File 'lib/jruby_art/runner.rb', line 24 def argc @argc end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
24 25 26 |
# File 'lib/jruby_art/runner.rb', line 24 def filename @filename end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
24 25 26 |
# File 'lib/jruby_art/runner.rb', line 24 def @options end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
24 25 26 |
# File 'lib/jruby_art/runner.rb', line 24 def os @os end |
Class Method Details
.execute ⇒ Object
Start running a jruby_art filename from the passed-in arguments
31 32 33 34 35 |
# File 'lib/jruby_art/runner.rb', line 31 def self.execute runner = new runner.(ARGV) runner.execute! end |
Instance Method Details
#check ⇒ Object
143 144 145 146 |
# File 'lib/jruby_art/runner.rb', line 143 def check require_relative '../jruby_art/installer' Check.new(K9_ROOT, OS).install end |
#create ⇒ Object
107 108 109 110 |
# File 'lib/jruby_art/runner.rb', line 107 def create require_relative '../jruby_art/creators/sketch_writer' SketchWriter.new(File.basename(filename, '.rb'), argc).write end |
#execute! ⇒ Object
Dispatch central.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jruby_art/runner.rb', line 38 def execute! show_help if .empty? show_version if [:version] run_sketch if [:run] watch_sketch if [:watch] live if [:live] create if [:create] check if [:check] install if [:install] end |
#export ⇒ Object
Export as app not implemented
113 114 115 116 |
# File 'lib/jruby_art/runner.rb', line 113 def export ensure_exists(filename) puts 'Not implemented yet' end |
#install ⇒ Object
137 138 139 140 141 |
# File 'lib/jruby_art/runner.rb', line 137 def install require_relative '../jruby_art/installer' JRubyCompleteInstall.new(K9_ROOT, OS).install UnpackSamples.new(K9_ROOT, OS).install end |
#live ⇒ Object
Just simply run a JRubyArt filename.
125 126 127 128 |
# File 'lib/jruby_art/runner.rb', line 125 def live ensure_exists(filename) spin_up('live.rb', filename, argc) end |
#parse_options(args) ⇒ Object
Parse the command-line options.
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 102 103 104 105 |
# File 'lib/jruby_art/runner.rb', line 50 def (args) opt_parser = OptionParser.new do |opts| # Set a banner, displayed at the top # of the help screen. opts. = 'Usage: k9 [options] [<filename.rb>]' # Define the options, and what they do [:version] = false opts.on('-v', '--version', 'JRubyArt Version') do [:version] = true end [:install] = false opts.on('-i', '--install', 'Installs jruby-complete and examples') do [:install] = true end [:check] = false opts.on('-?', '--check', 'Prints configuration') do [:check] = true end [:app] = false opts.on('-a', '--app', 'Export as app NOT IMPLEMENTED YET') do [:export] = true end [:watch] = false opts.on('-w', '--watch', 'Watch/run the sketch') do [:watch] = true end [:run] = false opts.on('-r', '--run', 'Run the sketch') do [:run] = true end [:live] = false opts.on('-l', '--live', 'As above, with pry console bound to Processing.app') do [:live] = true end [:create] = false opts.on('-c', '--create', 'Create new outline sketch') do [:create] = true end # This displays the help screen, all programs are # assumed to have this option. opts.on('-h', '--help', 'Display this screen') do puts opts exit end end @argc = opt_parser.parse(args) @filename = argc.shift end |
#run_sketch ⇒ Object
Just simply run a JRubyArt filename.
119 120 121 122 |
# File 'lib/jruby_art/runner.rb', line 119 def run_sketch ensure_exists(filename) spin_up('run.rb', filename, argc) end |
#show_help ⇒ Object
Show the standard help/usage message.
149 150 151 |
# File 'lib/jruby_art/runner.rb', line 149 def show_help puts HELP_MESSAGE end |
#show_version ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/jruby_art/runner.rb', line 153 def show_version require 'erb' warning = 'WARNING: JDK8 is preferred'.freeze if RUBY_PLATFORM == 'java' warn warning unless ENV_JAVA['java.specification.version'] == '1.8' end template = ERB.new <<-EOF JRubyArt version <%= JRubyArt::VERSION %> Ruby version <%= RUBY_VERSION %> EOF puts template.result(binding) end |
#watch_sketch ⇒ Object
Run a filename, keeping an eye on it’s file, and reloading whenever it changes.
132 133 134 135 |
# File 'lib/jruby_art/runner.rb', line 132 def watch_sketch ensure_exists(filename) spin_up('watch.rb', filename, argc) end |