File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,9 +93,10 @@ def library_loaded?(library_name)
9393 # Options are no longer relevant, define post_initialize method to use
9494 # custom options (see Sandi Metz POODR)
9595
96- def initialize
96+ def initialize ( options = { } )
9797 super ( )
9898 $app = self
99+ post_initialize ( options )
99100 proxy_java_fields
100101 mix_proxy_into_inner_classes
101102 java . lang . Thread . default_uncaught_exception_handler = proc do |_thread_ , exception |
Original file line number Diff line number Diff line change @@ -13,4 +13,42 @@ module Processing
1313 warn ( format ( 'WARN: you need to set PROCESSING_ROOT in %s' , config_path ) )
1414 end
1515 end
16+
17+ WIN_PATTERNS = [
18+ /bccwin/i ,
19+ /cygwin/i ,
20+ /djgpp/i ,
21+ /ming/i ,
22+ /mswin/i ,
23+ /wince/i
24+ ] . freeze
25+
26+ # This class knows about supported JRubyArt operating systems
27+ class HostOS
28+ def self . os
29+ detect_os = RbConfig ::CONFIG [ 'host_os' ]
30+ case detect_os
31+ when /mac|darwin/ then :mac
32+ when /linux/ then :linux
33+ when /solaris|bsd/ then :unix
34+ else
35+ WIN_PATTERNS . find { |reg | detect_os =~ reg }
36+ raise "unsupported os: #{ detect_os . inspect } " if Regexp . last_match . nil?
37+ :windows
38+ end
39+ end
40+ end
41+
42+ OS ||= HostOS . os
43+ end
44+
45+ # This class encapulates knowledge of processing sketchbook structure
46+ class Sketchbook
47+ def self . path
48+ File . join ( Processing ::RP_CONFIG [ 'sketchbook_path' ] , 'libraries' )
49+ end
50+
51+ def self . library ( name )
52+ Dir [ "#{ path } /#{ name } /library/\* .jar" ]
53+ end
1654end
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ def get_library_directory_path(library_name, extension = nil)
109109 "#{ Processing ::RP_CONFIG [ 'PROCESSING_ROOT' ] } /modes/java/libraries/#{ library_name } /library" ,
110110 "#{ K9_ROOT } /library/#{ library_name } /library" ,
111111 "#{ K9_ROOT } /library/#{ library_name } " ,
112- "#{ @sketchbook_library_path } /#{ library_name } /library"
112+ "#{ Sketchbook . path } /#{ library_name } /library"
113113 ] . each do |jpath |
114114 if File . exist? ( jpath ) && !Dir . glob ( format ( '%s/*.%s' , jpath , ext ) ) . empty?
115115 return jpath
Original file line number Diff line number Diff line change @@ -136,13 +136,13 @@ def watch_sketch
136136
137137 def install
138138 require_relative '../jruby_art/installer'
139- JRubyCompleteInstall . new ( K9_ROOT , host_os ) . install
140- UnpackSamples . new ( K9_ROOT , host_os ) . install
139+ JRubyCompleteInstall . new ( K9_ROOT , OS ) . install
140+ UnpackSamples . new ( K9_ROOT , OS ) . install
141141 end
142142
143143 def check
144144 require_relative '../jruby_art/installer'
145- Check . new ( K9_ROOT , host_os ) . install
145+ Check . new ( K9_ROOT , OS ) . install
146146 end
147147
148148 # Show the standard help/usage message.
@@ -183,24 +183,7 @@ def jruby_complete
183183 end
184184
185185 def libraries
186- %w( video sound ) . map { |library | sketchbook_library ( library ) } . flatten
187- end
188-
189- def sketchbook_library ( name )
190- Dir [ "#{ Processing ::RP_CONFIG [ 'sketchbook_path' ] } /libraries/#{ name } /library/\* .jar" ]
191- end
192-
193- def host_os
194- detect_os = RbConfig ::CONFIG [ 'host_os' ]
195- case detect_os
196- when /mac|darwin/ then :mac
197- when /linux/ then :linux
198- when /solaris|bsd/ then :unix
199- else
200- WIN_PATTERNS . find { |r | detect_os =~ r }
201- raise "unknown os: #{ detect_os . inspect } " if Regexp . last_match . nil?
202- :windows
203- end
186+ %w( video sound ) . map { |library | Sketchbook . library ( library ) } . flatten
204187 end
205188 end # class Runner
206189end # module Processing
You can’t perform that action at this time.
0 commit comments