jruby_art 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 156368f2d21f79e9d00113b288ee2bda05b4723d
4
- data.tar.gz: b76ca6ad8149bd1a09cd0a41205a5fcb8a5dcf67
3
+ metadata.gz: 7dc367d2baeead82e8b4017a333879cc81ad5a2a
4
+ data.tar.gz: b901245c19d4c67b6f80e406ab211e0e98420ee3
5
5
  SHA512:
6
- metadata.gz: b81109b04bb38e983b1565e9156400260c713f73e2b121aa348f3f105c5fb29694a54dd0abc9367764b0ef7935c31cf3175e28b09dbd840bca37dde77d0ad924
7
- data.tar.gz: 55b53e0a771e374db7acf218c47f82594b67150ce23a4dc328a4a397280f6f9401ca6ba1943af011f5b00a8b63ced0472f41ee2190ef033669921f3e1195373a
6
+ metadata.gz: acbfbaae7b7df8296c0decb9ac2907bc839409311538e47903e850bdd4fe6b4db59ba6f47d3378ed821abe41872753302397176d265b870bebbef4e88b891a90
7
+ data.tar.gz: 387499d644a78e6a176383d43f5cc54402575b96cc07e61b0f92063ad89a584788130bb20e9a1a7aae93482be69620e202d6c3e2c9f3b229e38b6cacd15ece24
data/lib/jruby_art/app.rb CHANGED
@@ -2,11 +2,9 @@
2
2
  # frozen_string_literal: false
3
3
 
4
4
  require 'java'
5
- # require 'jruby/core_ext'
6
5
  require_relative '../rpextras'
7
6
  require_relative '../jruby_art/helper_methods'
8
7
  require_relative '../jruby_art/helpers/aabb'
9
- require_relative '../jruby_art/helpers/string_extra'
10
8
  require_relative '../jruby_art/library_loader'
11
9
  require_relative '../jruby_art/config'
12
10
 
@@ -188,7 +186,6 @@ module Processing
188
186
  java_import format('processing.opengl.%s', klass)
189
187
  end
190
188
  end
191
- # become_java!
192
189
  end # Processing::App
193
190
 
194
191
  # @HACK purists may prefer 'forwardable' to the use of Proxy
@@ -1,9 +1,8 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: false
3
2
 
4
3
  BASIC = <<-CODE
5
4
  def setup
6
- sketch_title '%s'
5
+ sketch_title '%s'
7
6
  end
8
7
 
9
8
  def draw
@@ -11,16 +10,16 @@ def draw
11
10
  end
12
11
 
13
12
  def settings
14
- size %s, %s
15
- # pixel_density(2) # here for hi-dpi displays only
16
- # smooth # here
13
+ size %s, %s
14
+ # pixel_density(2) # here for hi-dpi displays only
15
+ # smooth # here
17
16
  end
18
17
 
19
18
  CODE
20
19
 
21
20
  BASIC_MODE = <<-CODE
22
21
  def setup
23
- sketch_title '%s'
22
+ sketch_title '%s'
24
23
  end
25
24
 
26
25
  def draw
@@ -28,8 +27,8 @@ def draw
28
27
  end
29
28
 
30
29
  def settings
31
- size %s, %s, %s
32
- # smooth # here
30
+ size %s, %s, %s
31
+ # smooth # here
33
32
  end
34
33
 
35
34
  CODE
@@ -38,19 +37,19 @@ CLASS_BASIC = <<-CODE
38
37
  # encoding: utf-8
39
38
  # frozen_string_literal: false
40
39
  class %s < Processing::App
41
- def setup
42
- sketch_title '%s'
43
- end
40
+ def setup
41
+ sketch_title '%s'
42
+ end
44
43
 
45
- def draw
44
+ def draw
46
45
 
47
- end
46
+ end
48
47
 
49
- def settings
50
- size %s, %s
51
- # pixel_density(2) # here for hi-dpi displays only
52
- # smooth # here
53
- end
48
+ def settings
49
+ size %s, %s
50
+ # pixel_density(2) # here for hi-dpi displays only
51
+ # smooth # here
52
+ end
54
53
  end
55
54
  CODE
56
55
 
@@ -63,18 +62,18 @@ require 'jruby_art/app'
63
62
  Processing::App::SKETCH_PATH = __FILE__
64
63
 
65
64
  class %s < Processing::App
66
- def setup
67
- sketch_title '%s'
68
- end
65
+ def setup
66
+ sketch_title '%s'
67
+ end
69
68
 
70
- def draw
69
+ def draw
71
70
 
72
- end
71
+ end
73
72
 
74
- def settings
75
- size %s, %s
76
- # smooth # here
77
- end
73
+ def settings
74
+ size %s, %s
75
+ # smooth # here
76
+ end
78
77
  end
79
78
 
80
79
  %s.new unless defined? $app
@@ -84,18 +83,18 @@ CLASS_MODE = <<-CODE
84
83
  # encoding: utf-8
85
84
  # frozen_string_literal: false
86
85
  class %s < Processing::App
87
- def setup
88
- sketch_title '%s'
89
- end
86
+ def setup
87
+ sketch_title '%s'
88
+ end
90
89
 
91
- def draw
90
+ def draw
92
91
 
93
- end
92
+ end
94
93
 
95
- def settings
96
- size %s, %s, %s
97
- # smooth # here
98
- end
94
+ def settings
95
+ size %s, %s, %s
96
+ # smooth # here
97
+ end
99
98
  end
100
99
  CODE
101
100
 
@@ -108,18 +107,18 @@ require 'jruby_art/app'
108
107
  Processing::App::SKETCH_PATH = __FILE__
109
108
 
110
109
  class %s < Processing::App
111
- def setup
112
- sketch_title '%s'
113
- end
110
+ def setup
111
+ sketch_title '%s'
112
+ end
114
113
 
115
- def draw
114
+ def draw
116
115
 
117
- end
116
+ end
118
117
 
119
- def settings
120
- size %s, %s, %s
121
- # smooth # here
122
- end
118
+ def settings
119
+ size %s, %s, %s
120
+ # smooth # here
121
+ end
123
122
  end
124
123
 
125
124
  %s.new unless defined? $app
@@ -129,19 +128,21 @@ INNER = <<-CODE
129
128
  # encoding: utf-8
130
129
  # frozen_string_literal: false
131
130
  class %s
132
- include Processing::Proxy
131
+ include Processing::Proxy
133
132
 
134
133
  end
135
134
  CODE
136
135
 
137
- # processing wrapper module
138
- module Processing
136
+ # creator wrapper module using StringExtra
137
+ module Creator
139
138
  require_relative '../helpers/string_extra'
139
+ using StringExtra
140
140
  # Write file to disk
141
141
  class SketchWriter
142
142
  attr_reader :file
143
+
143
144
  def initialize(path)
144
- underscore = StringExtra.new(path).underscore
145
+ underscore = path.underscore
145
146
  @file = "#{File.dirname(path)}/#{underscore}.rb"
146
147
  end
147
148
 
@@ -153,11 +154,10 @@ module Processing
153
154
  end
154
155
 
155
156
  # An abstract class providing common methods for real creators
156
- class Creator
157
+ class Base
157
158
  ALL_DIGITS = /\A\d+\Z/
158
-
159
159
  def already_exist(path)
160
- underscore = StringExtra.new(path).underscore
160
+ underscore = path.underscore
161
161
  new_file = "#{File.dirname(path)}/#{underscore}.rb"
162
162
  return if !FileTest.exist?(path) && !FileTest.exist?(new_file)
163
163
  puts 'That file already exists!'
@@ -181,7 +181,7 @@ module Processing
181
181
  end
182
182
 
183
183
  # This class creates bare sketches, with an optional render mode
184
- class BasicSketch < Creator
184
+ class BasicSketch < Base
185
185
  # Create a blank sketch, given a path.
186
186
  def basic_template
187
187
  format(BASIC, @title, @width, @height)
@@ -197,7 +197,7 @@ module Processing
197
197
  already_exist(path)
198
198
  main_file = File.basename(path, '.rb') # allow uneeded extension input
199
199
  writer = SketchWriter.new(main_file)
200
- @title = StringExtra.new(main_file).titleize
200
+ @title = main_file.titleize
201
201
  @width = args[0]
202
202
  @height = args[1]
203
203
  @mode = args[2].upcase unless args[2].nil?
@@ -207,7 +207,7 @@ module Processing
207
207
  end
208
208
 
209
209
  # This class creates class wrapped sketches, with an optional render mode
210
- class ClassSketch < Creator
210
+ class ClassSketch < Base
211
211
  def class_template
212
212
  format(CLASS_BASIC, @name, @title, @width, @height)
213
213
  end
@@ -215,15 +215,16 @@ module Processing
215
215
  def class_template_mode
216
216
  format(CLASS_MODE, @name, @title, @width, @height, @mode)
217
217
  end
218
+
218
219
  # Create a class wrapped sketch, given a path.
219
220
  def create!(path, args)
220
221
  return usage if /\?/ =~ path || /--help/ =~ path
221
222
  main_file = File.basename(path, '.rb') # allow uneeded extension input
222
223
  # Check to make sure that the main file doesn't exist already
223
224
  already_exist(path)
224
- @name = StringExtra.new(main_file).camelize
225
+ @name = main_file.camelize
225
226
  writer = SketchWriter.new(main_file)
226
- @title = StringExtra.new(main_file).titleize
227
+ @title = main_file.titleize
227
228
  @width, @height = args[0], args[1]
228
229
  @mode = args[2].upcase unless args[2].nil?
229
230
  template = @mode.nil? ? class_template : class_template_mode
@@ -232,7 +233,7 @@ module Processing
232
233
  end
233
234
 
234
235
  # This class creates class wrapped sketches, with an optional render mode
235
- class EmacsSketch < Creator
236
+ class EmacsSketch < Base
236
237
  def emacs_template
237
238
  format(EMACS_BASIC, @name, @title, @width, @height, @name)
238
239
  end
@@ -246,9 +247,9 @@ module Processing
246
247
  main_file = File.basename(path, '.rb') # allow uneeded extension input
247
248
  # Check to make sure that the main file doesn't exist already
248
249
  already_exist(path)
249
- @name = StringExtra.new(main_file).camelize
250
+ @name = main_file.camelize
250
251
  writer = SketchWriter.new(main_file)
251
- @title = StringExtra.new(main_file).titleize
252
+ @title = main_file.titleize
252
253
  @width, @height = args[0], args[1]
253
254
  @mode = args[2].upcase unless args[2].nil?
254
255
  template = @mode.nil? ? emacs_template : emacs_template_mode
@@ -257,10 +258,11 @@ module Processing
257
258
  end
258
259
 
259
260
  # This class creates a pseudo 'java inner class' of the sketch
260
- class Inner < Creator
261
+ class InnerSketch < Base
261
262
  def inner_class_template
262
263
  format(INNER, @name)
263
264
  end
265
+
264
266
  # Create a pseudo inner class, given a path.
265
267
  def create!(path, _args_)
266
268
  return usage if /\?/ =~ path || /--help/ =~ path
@@ -1,12 +1,14 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: false
3
+ # Re-open Numeric so that we can do simple degree and radian conversions
4
+ # conversion factors are 180 / Math::PI and Math::PI / 180
3
5
 
4
6
  class Numeric #:nodoc:
5
7
  def degrees
6
- self * 180 / Math::PI
8
+ self * 57.29577951308232
7
9
  end
8
10
 
9
11
  def radians
10
- self * Math::PI / 180
12
+ self * 0.017453292519943295
11
13
  end
12
14
  end
@@ -1,45 +1,28 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: false
2
+ # String refinement for sketch creator
3
+ module StringExtra
4
+ refine String do
5
+ def titleize
6
+ underscore
7
+ .humanize
8
+ .gsub(/\b([a-z])/) { Regexp.last_match[1].capitalize }
9
+ end
3
10
 
4
- require 'forwardable'
5
-
6
- # String utility for creating titles and class-names
7
- class StringExtra
8
- extend Forwardable
9
- def_delegators :@str, :upcase, :capitalize, :length, :downcase, :gsub, :tr
10
- def initialize(str)
11
- @str = str
12
- end
13
-
14
- def titleize
15
- gsub(/::/, '/')
16
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
17
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
18
- .tr('-', '_')
19
- .downcase
20
- .gsub(/_id$/, '')
21
- .tr('_', ' ').capitalize
22
- .gsub(/\b([a-z])/) { Regexp.last_match[1].capitalize }
23
- end
24
-
25
- def humanize
26
- gsub(/_id$/, '').tr(/_/, ' ').capitalize
27
- end
11
+ def humanize
12
+ gsub(/_id$/, '').tr('_', ' ').capitalize
13
+ end
28
14
 
29
- def underscore
30
- gsub(/::/, '/')
31
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
32
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
33
- .sub('-', '_')
34
- .downcase
35
- end
15
+ def camelize
16
+ gsub(%r{/\/(.?)/}) { '::' + Regexp.last_match[1].upcase }
17
+ .gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
18
+ end
36
19
 
37
- def camelize(first_letter_in_uppercase = true)
38
- if first_letter_in_uppercase
39
- @str.gsub(%r{/(.?)}) { '::' + Regexp.last_match[1].upcase }
40
- .gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
41
- else
42
- @str[0] + camelize[1..-1]
20
+ def underscore
21
+ gsub(/::/, '/')
22
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
23
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
24
+ .tr('-', '_')
25
+ .downcase
43
26
  end
44
27
  end
45
28
  end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: false
2
+ require 'yaml'
3
+
4
+ VERSION = '3.1.1' # processing version
5
+
6
+ # Abstract Installer class
7
+ class Installer
8
+ attr_reader :os, :sketch, :gem_root, :home
9
+ def initialize(root, os)
10
+ @os = os
11
+ @gem_root = root
12
+ @home = ENV['HOME']
13
+ @sketch = "#{home}/sketchbook" if os == :linux
14
+ @sketch = "#{home}/My Documents/Processing" if os == :windows
15
+ @sketch = "#{home}/Documents/Processing" if os == :mac
16
+ end
17
+
18
+ # Optimistically set processing root
19
+ def set_processing_root
20
+ require 'psych'
21
+ folder = File.expand_path("#{home}/.jruby_art")
22
+ Dir.mkdir(folder) unless File.exist? folder
23
+ path = File.join(folder, 'config.yml')
24
+ proot = "#{home}/processing-#{VERSION}"
25
+ proot = "/Java/Processing-#{VERSION}" if os == :windows
26
+ proot = "/Applications/Processing.app/Contents/Java" if os == :mac
27
+ data = {
28
+ 'PROCESSING_ROOT' => proot,
29
+ 'JRUBY' => true.to_s,
30
+ 'sketchbook_path' => sketch,
31
+ 'MAX_WATCH' => '20'
32
+ }
33
+ open(path, 'w:UTF-8') { |file| file.write(data.to_yaml) }
34
+ end
35
+
36
+ def root_exist?
37
+ return false if config.nil?
38
+ File.exist? config['PROCESSING_ROOT']
39
+ end
40
+
41
+ def config
42
+ k9config = File.expand_path("#{home}/.jruby_art/config.yml")
43
+ return nil unless File.exist? k9config
44
+ YAML.load_file(k9config)
45
+ end
46
+
47
+ # in place of default installer class
48
+ def install
49
+ puts 'Usage: k9 setup [check | install | unpack_samples]'
50
+ end
51
+
52
+ # Display the current version of JRubyArt.
53
+ def show_version
54
+ puts format('JRubyArt version %s', JRubyArt::VERSION)
55
+ end
56
+ end
57
+
58
+ # Configuration checker
59
+ class Check < Installer
60
+ def install
61
+ show_version
62
+ return super unless config
63
+ installed = File.exist? File.join(gem_root, 'lib/ruby/jruby-complete.jar')
64
+ proot = ' PROCESSING_ROOT = Not Set!!!' unless root_exist?
65
+ proot ||= " PROCESSING_ROOT = #{config['PROCESSING_ROOT']}"
66
+ sketchbook = " sketchbook_path = #{config['sketchbook_path']}"
67
+ max_watch = " MAX_WATCH = #{config['MAX_WATCH']}"
68
+ jruby = config['JRUBY']
69
+ puts proot
70
+ puts " JRUBY = #{jruby}" unless jruby.nil?
71
+ puts " jruby-complete installed = #{installed}"
72
+ puts sketchbook
73
+ puts max_watch
74
+ end
75
+ end
76
+
77
+ # Examples Installer
78
+ class UnpackSamples < Installer
79
+ def install
80
+ system "cd #{gem_root}/vendors && rake unpack_samples"
81
+ end
82
+ end
83
+
84
+ # JRuby-Complete installer
85
+ class JRubyComplete < Installer
86
+ def install
87
+ system "cd #{gem_root}/vendors && rake"
88
+ return if root_exist?
89
+ set_processing_root
90
+ warn 'PROCESSING_ROOT set optimistically, run check to confirm'
91
+ end
92
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: false
2
+ # class to parse java_args.txt or java_args in config.yml
3
+ class JavaArgs
4
+ attr_reader :java
5
+
6
+ def initialize(sketch_root)
7
+ arg_file = File.join(sketch_root, 'data/java_args.txt')
8
+ @java = []
9
+ if FileTest.exist?(arg_file)
10
+ @java += File.read(arg_file).split(/\s+/)
11
+ elsif Processing::RP_CONFIG['java_args']
12
+ @java += Processing::RP_CONFIG['java_args'].split(/\s+/)
13
+ end
14
+ end
15
+
16
+ # wrap java args for jruby
17
+ def jruby
18
+ return [] if java.length == 0
19
+ java.map { |arg| "-J#{arg}" }
20
+ end
21
+ end
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: false
3
3
 
4
4
  require_relative '../jruby_art'
5
-
5
+ require_relative 'sketchbook'
6
6
  # The processing wrapper module
7
7
  module Processing
8
8
  # Encapsulate library loader functionality as a class
@@ -10,7 +10,7 @@ module Processing
10
10
  attr_reader :sketchbook_library_path
11
11
 
12
12
  def initialize
13
- @sketchbook_library_path = File.join(find_sketchbook_path, 'libraries')
13
+ @sketchbook_library_path = File.join(Sketchbook.find_path, 'libraries')
14
14
  @loaded_libraries = Hash.new(false)
15
15
  end
16
16
 
@@ -117,27 +117,6 @@ module Processing
117
117
  end
118
118
  end
119
119
  nil
120
- end
121
-
122
- def find_sketchbook_path
123
- preferences_paths = []
124
- sketchbook_paths = []
125
- sketchbook_path = Processing::RP_CONFIG.fetch('sketchbook_path', false)
126
- return sketchbook_path if sketchbook_path
127
- [
128
- "'Application Data/Processing'", 'AppData/Roaming/Processing',
129
- 'Library/Processing', 'Documents/Processing',
130
- '.processing', 'sketchbook'
131
- ].each do |prefix|
132
- spath = format('%s/%s', ENV['HOME'], prefix)
133
- pref_path = format('%s/preferences.txt', spath)
134
- preferences_paths << pref_path if FileTest.file?(pref_path)
135
- sketchbook_paths << spath if FileTest.directory?(spath)
136
- end
137
- return sketchbook_paths.first if preferences_paths.empty?
138
- lines = IO.readlines(preferences_paths.first)
139
- matchedline = lines.grep(/^sketchbook/).first
140
- matchedline[/=(.+)/].delete('=')
141
- end
120
+ end
142
121
  end
143
122
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: false
3
2
 
4
3
  require 'ostruct'
@@ -6,6 +5,8 @@ require 'fileutils'
6
5
  require 'rbconfig'
7
6
  require_relative '../jruby_art/config'
8
7
  require_relative '../jruby_art/version'
8
+ require_relative '../jruby_art/installer'
9
+ require_relative '../jruby_art/java_args'
9
10
 
10
11
  # processing wrapper module
11
12
  module Processing
@@ -94,10 +95,10 @@ module Processing
94
95
  # boilerplate filled out.
95
96
  def create(sketch, args)
96
97
  require_relative '../jruby_art/creators/creator'
97
- return Processing::Inner.new.create!(sketch, args) if @options.inner
98
- return Processing::ClassSketch.new.create!(sketch, args) if @options.wrap
99
- return Processing::EmacsSketch.new.create!(sketch, args) if @options.emacs
100
- Processing::BasicSketch.new.create!(sketch, args)
98
+ return Creator::Inner.new.create!(sketch, args) if @options.inner
99
+ return Creator::ClassSketch.new.create!(sketch, args) if @options.wrap
100
+ return Creator::EmacsSketch.new.create!(sketch, args) if @options.emacs
101
+ Creator::BasicSketch.new.create!(sketch, args)
101
102
  end
102
103
 
103
104
  # Just simply run a JRubyArt sketch.
@@ -117,42 +118,13 @@ module Processing
117
118
  def watch(sketch, args)
118
119
  ensure_exists(sketch)
119
120
  spin_up('watch.rb', sketch, args)
120
- end
121
-
122
- def setup(choice)
123
- proc_root = FileTest.exist?("#{ENV['HOME']}/.jruby_art/config.yml")
124
- case choice
125
- when /check/
126
- check(proc_root, FileTest.exist?("#{K9_ROOT}/lib/ruby/jruby-complete.jar"))
127
- when /install/
128
- install(proc_root)
129
- when /unpack_samples/
130
- system "cd #{K9_ROOT}/vendors && rake unpack_samples"
131
- else
132
- puts 'Usage: k9 setup [check | install | unpack_samples]'
133
- end
134
- end
135
-
136
- def install(root_exist)
137
- system "cd #{K9_ROOT}/vendors && rake"
138
- return if root_exist
139
- set_processing_root
140
- warn 'PROCESSING_ROOT set optimistically, run check to confirm'
141
- end
142
-
143
- def check(root_exist, installed)
144
- show_version
145
- root = ' PROCESSING_ROOT = Not Set!!!' unless root_exist
146
- root ||= " PROCESSING_ROOT = #{Processing::RP_CONFIG['PROCESSING_ROOT']}"
147
- jruby = Processing::RP_CONFIG['JRUBY']
148
- puts root
149
- puts " JRUBY = #{jruby}" unless jruby.nil?
150
- puts " jruby-complete installed = #{installed}"
151
- end
121
+ end
152
122
 
153
- # Display the current version of JRubyArt.
154
- def show_version
155
- puts format('JRubyArt version %s', JRubyArt::VERSION)
123
+ def setup(choice)
124
+ return Check.new(K9_ROOT, host_os).install if choice =~ /check/
125
+ return JRubyComplete.new(K9_ROOT, host_os).install if choice =~ /install/
126
+ return UnpackSamples.new(K9_ROOT, host_os).install if choice =~ /unpack_sample/
127
+ Installer.new(K9_ROOT, host_os).install
156
128
  end
157
129
 
158
130
  # Show the standard help/usage message.
@@ -170,10 +142,10 @@ module Processing
170
142
  def spin_up(starter_script, sketch, args)
171
143
  runner = "#{K9_ROOT}/lib/jruby_art/runners/#{starter_script}"
172
144
  @options.nojruby = true if Processing::RP_CONFIG['JRUBY'] == 'false'
173
- java_args = discover_java_args(sketch)
145
+ java_args = JavaArgs.new(SKETCH_ROOT)
174
146
  if @options.nojruby
175
147
  command = ['java',
176
- java_args,
148
+ java_args.java,
177
149
  '-cp',
178
150
  jruby_complete,
179
151
  'org.jruby.Main',
@@ -182,7 +154,7 @@ module Processing
182
154
  args].flatten
183
155
  else
184
156
  command = ['jruby',
185
- java_args,
157
+ java_args.jruby,
186
158
  runner,
187
159
  sketch,
188
160
  args].flatten
@@ -192,22 +164,7 @@ module Processing
192
164
  # exec replaces the Ruby process with the JRuby one.
193
165
  rescue Java::JavaLang::ClassNotFoundException
194
166
  end
195
- end
196
-
197
- # If you need to pass in arguments to Java, such as the ones on this page:
198
- # http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/java.html
199
- # add them to a java_args.txt in your data directory next to your sketch.
200
- def discover_java_args(sketch)
201
- arg_file = "#{File.dirname(sketch)}/data/java_args.txt"
202
- args = []
203
- if FileTest.exist?(arg_file)
204
- args += File.read(arg_file).split(/\s+/)
205
- elsif Processing::RP_CONFIG['java_args']
206
- args += Processing::RP_CONFIG['java_args'].split(/\s+/)
207
- end
208
- args.map! { |arg| "-J#{arg}" } unless @options.nojruby
209
- args
210
- end
167
+ end
211
168
 
212
169
  # NB: We really do mean to use 'and' not '&&' for flow control purposes
213
170
 
@@ -238,25 +195,9 @@ module Processing
238
195
  when /solaris|bsd/ then :unix
239
196
  else
240
197
  WIN_PATTERNS.find { |r| detect_os =~ r }
241
- fail "unknown os: #{detect_os.inspect}" if Regexp.last_match.nil?
198
+ raise "unknown os: #{detect_os.inspect}" if Regexp.last_match.nil?
242
199
  :windows
243
200
  end
244
201
  end
245
-
246
- # Optimistically set processing root
247
- def set_processing_root
248
- require 'psych'
249
- @os ||= host_os
250
- data = {}
251
- path = File.expand_path("#{ENV['HOME']}/.jruby_art/config.yml")
252
- if os == :mac
253
- data['PROCESSING_ROOT'] = '/Applications/Processing.app/Contents/Java'
254
- else
255
- root = "#{ENV['HOME']}/processing-3.1.1"
256
- data['PROCESSING_ROOT'] = root
257
- end
258
- data['JRUBY'] = 'true'
259
- open(path, 'w:UTF-8') { |f| f.write(data.to_yaml) }
260
- end
261
202
  end # class Runner
262
203
  end # module Processing
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: false
3
+
3
4
  SKETCH_PATH ||= ARGV.shift
4
5
  SKETCH_ROOT ||= File.absolute_path(File.dirname(SKETCH_PATH))
5
6
 
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: false
2
+ # Utility to find sketchbook and hence java libraries
3
+ module Sketchbook
4
+ def self.find_path
5
+ preferences_paths = []
6
+ sketchbook_paths = []
7
+ sketchbook_path = Processing::RP_CONFIG.fetch('sketchbook_path', false)
8
+ return sketchbook_path if sketchbook_path
9
+ [
10
+ "'Application Data/Processing'", 'AppData/Roaming/Processing',
11
+ 'Library/Processing', 'Documents/Processing',
12
+ '.processing', 'sketchbook'
13
+ ].each do |prefix|
14
+ spath = format('%s/%s', ENV['HOME'], prefix)
15
+ pref_path = format('%s/preferences.txt', spath)
16
+ preferences_paths << pref_path if FileTest.file?(pref_path)
17
+ sketchbook_paths << spath if FileTest.directory?(spath)
18
+ end
19
+ return sketchbook_paths.first if preferences_paths.empty?
20
+ lines = IO.readlines(preferences_paths.first)
21
+ matchedline = lines.grep(/^sketchbook/).first
22
+ matchedline[/=(.+)/].delete('=')
23
+ end
24
+ end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
  # A wrapper for version
4
4
  module JRubyArt
5
- VERSION = '1.1.1'
5
+ VERSION = '1.1.2'
6
6
  end
data/lib/rpextras.jar CHANGED
Binary file
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ # Usage: :wq
3
+ # load_library :chooser
4
+ #
5
+ # def setup
6
+ # java_signature 'void selectInput(String, String)'
7
+ # selectInput('Select a file to process:', 'fileSelected')
8
+ # end
9
+ #
10
+ # def fileSelected(selection)
11
+ # if selection.nil?
12
+ # puts 'Window was closed or the user hit cancel.'
13
+ # else
14
+ # puts format('User selected %s', selection.get_absolute_path)
15
+ # end
16
+ # end
17
+ class Processing::App
18
+ include Java::MonkstoneFilechooser::Chooser
19
+ end
data/vendors/Rakefile CHANGED
@@ -9,7 +9,7 @@ WARNING = <<-EOS
9
9
  EOS
10
10
 
11
11
  JRUBYC_VERSION = '9.1.2.0'
12
- EXAMPLES = '1.1'
12
+ EXAMPLES = '1.2'
13
13
  HOME_DIR = ENV['HOME']
14
14
  MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby_art
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-05-27 00:00:00.000000000 Z
13
+ date: 2016-06-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -48,7 +48,7 @@ description: " JRubyArt is a ruby wrapper for the processing art framework.\n
48
48
  so that you can easily create sliders, buttons,\n checkboxes and drop-down menus,
49
49
  and hook them into your sketch's instance\n variables and hundreds of worked examples
50
50
  to get you started...\n"
51
- email: martin_p@lineone.net
51
+ email: mamba2928@yahoo.co.uk
52
52
  executables:
53
53
  - k9
54
54
  extensions: []
@@ -63,15 +63,19 @@ files:
63
63
  - lib/jruby_art/helpers/aabb.rb
64
64
  - lib/jruby_art/helpers/numeric.rb
65
65
  - lib/jruby_art/helpers/string_extra.rb
66
+ - lib/jruby_art/installer.rb
67
+ - lib/jruby_art/java_args.rb
66
68
  - lib/jruby_art/library_loader.rb
67
69
  - lib/jruby_art/runner.rb
68
70
  - lib/jruby_art/runners/base.rb
69
71
  - lib/jruby_art/runners/live.rb
70
72
  - lib/jruby_art/runners/run.rb
71
73
  - lib/jruby_art/runners/watch.rb
74
+ - lib/jruby_art/sketchbook.rb
72
75
  - lib/jruby_art/version.rb
73
76
  - lib/rpextras.jar
74
77
  - library/boids/boids.rb
78
+ - library/chooser/chooser.rb
75
79
  - library/control_panel/control_panel.rb
76
80
  - library/library_proxy/README.md
77
81
  - library/library_proxy/library_proxy.rb