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 ]
Instance Attribute Summary collapse
-
#os ⇒ Object
readonly
Returns the value of attribute os.
Class Method Summary collapse
-
.execute ⇒ Object
Start running a jruby_art sketch from the passed-in arguments.
Instance Method Summary collapse
- #check(root_exist, installed) ⇒ Object
-
#create(sketch, args) ⇒ Object
Create a fresh JRubyArt sketch, with the necessary boilerplate filled out.
-
#execute! ⇒ Object
Dispatch central.
- #install(root_exist) ⇒ Object
-
#live(sketch, args) ⇒ Object
Just simply run a JRubyArt sketch.
-
#parse_options(args) ⇒ Object
Parse the command-line options.
-
#run(sketch, args) ⇒ Object
Just simply run a JRubyArt sketch.
- #setup(choice) ⇒ Object
-
#show_help ⇒ Object
Show the standard help/usage message.
-
#show_version ⇒ Object
Display the current version of JRubyArt.
-
#watch(sketch, args) ⇒ Object
Run a sketch, keeping an eye on it’s file, and reloading whenever it changes.
Instance Attribute Details
#os ⇒ Object (readonly)
Returns the value of attribute os.
56 57 58 |
# File 'lib/jruby_art/runner.rb', line 56 def os @os end |
Class Method Details
.execute ⇒ Object
Start running a jruby_art sketch from the passed-in arguments
59 60 61 62 63 |
# File 'lib/jruby_art/runner.rb', line 59 def self.execute runner = new runner.(ARGV) runner.execute! end |
Instance Method Details
#check(root_exist, installed) ⇒ Object
143 144 145 146 147 148 149 150 151 |
# File 'lib/jruby_art/runner.rb', line 143 def check(root_exist, installed) show_version root = ' PROCESSING_ROOT = Not Set!!!' unless root_exist root ||= " PROCESSING_ROOT = #{Processing::RP_CONFIG['PROCESSING_ROOT']}" jruby = Processing::RP_CONFIG['JRUBY'] puts root puts " JRUBY = #{jruby}" unless jruby.nil? puts " jruby-complete installed = #{installed}" end |
#create(sketch, args) ⇒ Object
Create a fresh JRubyArt sketch, with the necessary boilerplate filled out.
95 96 97 98 99 100 101 |
# File 'lib/jruby_art/runner.rb', line 95 def create(sketch, args) require_relative '../jruby_art/creators/creator' return Processing::Inner.new.create!(sketch, args) if .inner return Processing::ClassSketch.new.create!(sketch, args) if .wrap return Processing::EmacsSketch.new.create!(sketch, args) if .emacs Processing::BasicSketch.new.create!(sketch, args) end |
#execute! ⇒ Object
Dispatch central.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/jruby_art/runner.rb', line 66 def execute! case .action when 'run' then run(.path, .args) when 'live' then live(.path, .args) when 'watch' then watch(.path, .args) when 'create' then create(.path, .args) when 'setup' then setup(.path) when /-v/ then show_version when /-h/ then show_help else show_help end end |
#install(root_exist) ⇒ Object
136 137 138 139 140 141 |
# File 'lib/jruby_art/runner.rb', line 136 def install(root_exist) system "cd #{K9_ROOT}/vendors && rake" return if root_exist set_processing_root warn 'PROCESSING_ROOT set optimistically, run check to confirm' end |
#live(sketch, args) ⇒ Object
Just simply run a JRubyArt sketch.
110 111 112 113 |
# File 'lib/jruby_art/runner.rb', line 110 def live(sketch, args) ensure_exists(sketch) spin_up('live.rb', sketch, args) end |
#parse_options(args) ⇒ Object
Parse the command-line options. Keep it simple.
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/jruby_art/runner.rb', line 81 def (args) = OpenStruct.new .emacs = !args.delete('--emacs').nil? .wrap = !args.delete('--wrap').nil? .inner = !args.delete('--inner').nil? .jruby = !args.delete('--jruby').nil? .nojruby = !args.delete('--nojruby').nil? .action = args[0] || nil .path = args[1] || File.basename(Dir.pwd + '.rb') .args = args[2..-1] || [] end |
#run(sketch, args) ⇒ Object
Just simply run a JRubyArt sketch.
104 105 106 107 |
# File 'lib/jruby_art/runner.rb', line 104 def run(sketch, args) ensure_exists(sketch) spin_up('run.rb', sketch, args) end |
#setup(choice) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/jruby_art/runner.rb', line 122 def setup(choice) proc_root = FileTest.exist?("#{ENV['HOME']}/.jruby_art/config.yml") case choice when /check/ check(proc_root, FileTest.exist?("#{K9_ROOT}/lib/ruby/jruby-complete.jar")) when /install/ install(proc_root) when /unpack_samples/ system "cd #{K9_ROOT}/vendors && rake unpack_samples" else puts 'Usage: k9 setup [check | install | unpack_samples]' end end |
#show_help ⇒ Object
Show the standard help/usage message.
159 160 161 |
# File 'lib/jruby_art/runner.rb', line 159 def show_help puts HELP_MESSAGE end |
#show_version ⇒ Object
Display the current version of JRubyArt.
154 155 156 |
# File 'lib/jruby_art/runner.rb', line 154 def show_version puts format('JRubyArt version %s', JRubyArt::VERSION) end |
#watch(sketch, args) ⇒ Object
Run a sketch, keeping an eye on it’s file, and reloading whenever it changes.
117 118 119 120 |
# File 'lib/jruby_art/runner.rb', line 117 def watch(sketch, args) ensure_exists(sketch) spin_up('watch.rb', sketch, args) end |