jruby_art 1.1.2 → 1.1.3

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: 7dc367d2baeead82e8b4017a333879cc81ad5a2a
4
- data.tar.gz: b901245c19d4c67b6f80e406ab211e0e98420ee3
3
+ metadata.gz: 9b2efc2b922f7fc4f2deaa35f08f4eff1b76f866
4
+ data.tar.gz: 3d1c58ba7d1b7fdaad54f60c3cc7db530b9aa192
5
5
  SHA512:
6
- metadata.gz: acbfbaae7b7df8296c0decb9ac2907bc839409311538e47903e850bdd4fe6b4db59ba6f47d3378ed821abe41872753302397176d265b870bebbef4e88b891a90
7
- data.tar.gz: 387499d644a78e6a176383d43f5cc54402575b96cc07e61b0f92063ad89a584788130bb20e9a1a7aae93482be69620e202d6c3e2c9f3b229e38b6cacd15ece24
6
+ metadata.gz: 4ac06b256d5e9cb69c25c49a2f2aafe4cd8027ce04407f1b6c3dc5549938e0e41d48a3e8e4c36ec9b5a1f237e6b2e611ae3758d70faebbb07ad95a56e48d5900
7
+ data.tar.gz: fbe51822b4bb75092c909d57ea1a477ccd4ad2e41270745523a6d389f159b77162e219a24b5609814f55ad2f39ef2b12b604744ad13ea68ff1dee51f298f3b11
@@ -2,7 +2,7 @@
2
2
 
3
3
  BASIC = <<-CODE
4
4
  def setup
5
- sketch_title '%s'
5
+ sketch_title '%s'
6
6
  end
7
7
 
8
8
  def draw
@@ -10,16 +10,16 @@ def draw
10
10
  end
11
11
 
12
12
  def settings
13
- size %s, %s
14
- # pixel_density(2) # here for hi-dpi displays only
15
- # smooth # here
13
+ size %s, %s
14
+ # pixel_density(2) # here for hi-dpi displays only
15
+ # smooth # here
16
16
  end
17
17
 
18
18
  CODE
19
19
 
20
20
  BASIC_MODE = <<-CODE
21
21
  def setup
22
- sketch_title '%s'
22
+ sketch_title '%s'
23
23
  end
24
24
 
25
25
  def draw
@@ -27,8 +27,8 @@ def draw
27
27
  end
28
28
 
29
29
  def settings
30
- size %s, %s, %s
31
- # smooth # here
30
+ size %s, %s, %s
31
+ # smooth # here
32
32
  end
33
33
 
34
34
  CODE
@@ -37,19 +37,19 @@ CLASS_BASIC = <<-CODE
37
37
  # encoding: utf-8
38
38
  # frozen_string_literal: false
39
39
  class %s < Processing::App
40
- def setup
41
- sketch_title '%s'
42
- end
40
+ def setup
41
+ sketch_title '%s'
42
+ end
43
43
 
44
- def draw
44
+ def draw
45
45
 
46
- end
46
+ end
47
47
 
48
- def settings
49
- size %s, %s
50
- # pixel_density(2) # here for hi-dpi displays only
51
- # smooth # here
52
- end
48
+ def settings
49
+ size %s, %s
50
+ # pixel_density(2) # here for hi-dpi displays only
51
+ # smooth # here
52
+ end
53
53
  end
54
54
  CODE
55
55
 
@@ -59,21 +59,21 @@ EMACS_BASIC = <<-CODE
59
59
  require 'jruby_art'
60
60
  require 'jruby_art/app'
61
61
 
62
- Processing::App::SKETCH_PATH = __FILE__
62
+ Processing::App::SKETCH_PATH = __FILE__.freeze
63
63
 
64
64
  class %s < Processing::App
65
- def setup
66
- sketch_title '%s'
67
- end
65
+ def setup
66
+ sketch_title '%s'
67
+ end
68
68
 
69
- def draw
69
+ def draw
70
70
 
71
- end
71
+ end
72
72
 
73
- def settings
74
- size %s, %s
75
- # smooth # here
76
- end
73
+ def settings
74
+ size %s, %s
75
+ # smooth # here
76
+ end
77
77
  end
78
78
 
79
79
  %s.new unless defined? $app
@@ -83,18 +83,18 @@ CLASS_MODE = <<-CODE
83
83
  # encoding: utf-8
84
84
  # frozen_string_literal: false
85
85
  class %s < Processing::App
86
- def setup
87
- sketch_title '%s'
88
- end
86
+ def setup
87
+ sketch_title '%s'
88
+ end
89
89
 
90
- def draw
90
+ def draw
91
91
 
92
- end
92
+ end
93
93
 
94
- def settings
95
- size %s, %s, %s
96
- # smooth # here
97
- end
94
+ def settings
95
+ size %s, %s, %s
96
+ # smooth # here
97
+ end
98
98
  end
99
99
  CODE
100
100
 
@@ -104,21 +104,21 @@ EMACS_MODE = <<-CODE
104
104
  require 'jruby_art'
105
105
  require 'jruby_art/app'
106
106
 
107
- Processing::App::SKETCH_PATH = __FILE__
107
+ Processing::App::SKETCH_PATH = __FILE__.freeze
108
108
 
109
109
  class %s < Processing::App
110
- def setup
111
- sketch_title '%s'
112
- end
110
+ def setup
111
+ sketch_title '%s'
112
+ end
113
113
 
114
- def draw
114
+ def draw
115
115
 
116
- end
116
+ end
117
117
 
118
- def settings
119
- size %s, %s, %s
120
- # smooth # here
121
- end
118
+ def settings
119
+ size %s, %s, %s
120
+ # smooth # here
121
+ end
122
122
  end
123
123
 
124
124
  %s.new unless defined? $app
@@ -128,7 +128,7 @@ INNER = <<-CODE
128
128
  # encoding: utf-8
129
129
  # frozen_string_literal: false
130
130
  class %s
131
- include Processing::Proxy
131
+ include Processing::Proxy
132
132
 
133
133
  end
134
134
  CODE
@@ -136,13 +136,12 @@ CODE
136
136
  # creator wrapper module using StringExtra
137
137
  module Creator
138
138
  require_relative '../helpers/string_extra'
139
- using StringExtra
140
139
  # Write file to disk
141
140
  class SketchWriter
142
141
  attr_reader :file
143
142
 
144
143
  def initialize(path)
145
- underscore = path.underscore
144
+ underscore = StringExtra.new(path).underscore
146
145
  @file = "#{File.dirname(path)}/#{underscore}.rb"
147
146
  end
148
147
 
@@ -157,7 +156,7 @@ module Creator
157
156
  class Base
158
157
  ALL_DIGITS = /\A\d+\Z/
159
158
  def already_exist(path)
160
- underscore = path.underscore
159
+ underscore = StringExtra.new(path).underscore
161
160
  new_file = "#{File.dirname(path)}/#{underscore}.rb"
162
161
  return if !FileTest.exist?(path) && !FileTest.exist?(new_file)
163
162
  puts 'That file already exists!'
@@ -197,12 +196,12 @@ module Creator
197
196
  already_exist(path)
198
197
  main_file = File.basename(path, '.rb') # allow uneeded extension input
199
198
  writer = SketchWriter.new(main_file)
200
- @title = main_file.titleize
199
+ @title = StringExtra.new(main_file).titleize
201
200
  @width = args[0]
202
201
  @height = args[1]
203
- @mode = args[2].upcase unless args[2].nil?
204
- template = @mode.nil? ? basic_template : basic_template_mode
205
- writer.save(template)
202
+ return writer.save(basic_template) if args[2].nil?
203
+ @mode = args[2].upcase
204
+ writer.save(basic_template_mode)
206
205
  end
207
206
  end
208
207
 
@@ -222,9 +221,9 @@ module Creator
222
221
  main_file = File.basename(path, '.rb') # allow uneeded extension input
223
222
  # Check to make sure that the main file doesn't exist already
224
223
  already_exist(path)
225
- @name = main_file.camelize
224
+ @name = StringExtra.new(main_file).camelize
226
225
  writer = SketchWriter.new(main_file)
227
- @title = main_file.titleize
226
+ @title = StringExtra.new(main_file).titleize
228
227
  @width, @height = args[0], args[1]
229
228
  @mode = args[2].upcase unless args[2].nil?
230
229
  template = @mode.nil? ? class_template : class_template_mode
@@ -247,9 +246,9 @@ module Creator
247
246
  main_file = File.basename(path, '.rb') # allow uneeded extension input
248
247
  # Check to make sure that the main file doesn't exist already
249
248
  already_exist(path)
250
- @name = main_file.camelize
249
+ @name = StringExtra.new(main_file).camelize
251
250
  writer = SketchWriter.new(main_file)
252
- @title = main_file.titleize
251
+ @title = StringExtra.new(main_file).titleize
253
252
  @width, @height = args[0], args[1]
254
253
  @mode = args[2].upcase unless args[2].nil?
255
254
  template = @mode.nil? ? emacs_template : emacs_template_mode
@@ -1,28 +1,33 @@
1
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
2
+ require 'forwardable'
3
+ # reverting to StringExtra class, from a module with String refinements
4
+ class StringExtra
5
+ extend Forwardable
6
+ def_delegators(:@str, :upcase, :capitalize, :length, :downcase, :gsub)
7
+ def initialize(str)
8
+ @str = str
9
+ end
10
10
 
11
- def humanize
12
- gsub(/_id$/, '').tr('_', ' ').capitalize
13
- end
11
+ def titleize
12
+ underscore
13
+ .gsub(/_id$/, '').tr('_', ' ').capitalize
14
+ .gsub(/\b([a-z])/) { Regexp.last_match[1].capitalize }
15
+ end
14
16
 
15
- def camelize
16
- gsub(%r{/\/(.?)/}) { '::' + Regexp.last_match[1].upcase }
17
- .gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
18
- end
17
+ def humanize
18
+ gsub(/_id$/, '').tr('_', ' ').capitalize
19
+ end
20
+
21
+ def camelize
22
+ gsub(%r{/\/(.?)/}) { '::' + Regexp.last_match[1].upcase }
23
+ .gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
24
+ end
19
25
 
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
26
- end
26
+ def underscore
27
+ gsub(/::/, '/')
28
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
29
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
30
+ .tr('-', '_')
31
+ .downcase
27
32
  end
28
33
  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 JavaOpts
4
+ attr_reader :opts
5
+
6
+ def initialize(sketch_root)
7
+ arg_file = File.join(sketch_root, 'data/java_args.txt')
8
+ @opts = []
9
+ @opts += File.read(arg_file).split(/\s+/) if FileTest.exist?(arg_file)
10
+ if opts.empty? && Processing::RP_CONFIG.fetch('java_args', false)
11
+ @opts += Processing::RP_CONFIG['java_args'].split(/\s+/)
12
+ end
13
+ end
14
+ end
15
+
16
+ # wrap args to pass through to jvm from jruby
17
+ class JRubyOpts < JavaOpts
18
+ def opts
19
+ super.map { |arg| "-J#{arg}" }
20
+ end
21
+ end
@@ -6,7 +6,7 @@ require 'rbconfig'
6
6
  require_relative '../jruby_art/config'
7
7
  require_relative '../jruby_art/version'
8
8
  require_relative '../jruby_art/installer'
9
- require_relative '../jruby_art/java_args'
9
+ require_relative '../jruby_art/java_opts'
10
10
 
11
11
  # processing wrapper module
12
12
  module Processing
@@ -118,13 +118,13 @@ module Processing
118
118
  def watch(sketch, args)
119
119
  ensure_exists(sketch)
120
120
  spin_up('watch.rb', sketch, args)
121
- end
121
+ end
122
122
 
123
- def setup(choice)
123
+ def setup(choice)
124
124
  return Check.new(K9_ROOT, host_os).install if choice =~ /check/
125
125
  return JRubyComplete.new(K9_ROOT, host_os).install if choice =~ /install/
126
126
  return UnpackSamples.new(K9_ROOT, host_os).install if choice =~ /unpack_sample/
127
- Installer.new(K9_ROOT, host_os).install
127
+ Installer.new(K9_ROOT, host_os).install
128
128
  end
129
129
 
130
130
  # Show the standard help/usage message.
@@ -132,6 +132,10 @@ module Processing
132
132
  puts HELP_MESSAGE
133
133
  end
134
134
 
135
+ def show_version
136
+ puts format('JRubyArt version %s', JRubyArt::VERSION)
137
+ end
138
+
135
139
  private
136
140
 
137
141
  # Trade in this Ruby instance for a JRuby instance, loading in a starter
@@ -142,10 +146,10 @@ module Processing
142
146
  def spin_up(starter_script, sketch, args)
143
147
  runner = "#{K9_ROOT}/lib/jruby_art/runners/#{starter_script}"
144
148
  @options.nojruby = true if Processing::RP_CONFIG['JRUBY'] == 'false'
145
- java_args = JavaArgs.new(SKETCH_ROOT)
146
149
  if @options.nojruby
150
+ opts = JavaOpts.new(SKETCH_ROOT).opts
147
151
  command = ['java',
148
- java_args.java,
152
+ opts,
149
153
  '-cp',
150
154
  jruby_complete,
151
155
  'org.jruby.Main',
@@ -153,8 +157,9 @@ module Processing
153
157
  sketch,
154
158
  args].flatten
155
159
  else
160
+ opts = JRubyOpts.new(SKETCH_ROOT).opts
156
161
  command = ['jruby',
157
- java_args.jruby,
162
+ opts,
158
163
  runner,
159
164
  sketch,
160
165
  args].flatten
@@ -164,7 +169,7 @@ module Processing
164
169
  # exec replaces the Ruby process with the JRuby one.
165
170
  rescue Java::JavaLang::ClassNotFoundException
166
171
  end
167
- end
172
+ end
168
173
 
169
174
  # NB: We really do mean to use 'and' not '&&' for flow control purposes
170
175
 
@@ -69,7 +69,7 @@ module Processing
69
69
  @files = Dir.glob(File.join(SKETCH_ROOT, '**/*.{rb,glsl}'))
70
70
  count = @files.length
71
71
  max_watch = RP_CONFIG.fetch('MAX_WATCH', 20)
72
- return unless count > max_watch
72
+ return unless count > max_watch.to_i
73
73
  warn format(WATCH_MESSAGE, max_watch, count)
74
74
  abort
75
75
  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.2'
5
+ VERSION = '1.1.3'
6
6
  end
data/lib/rpextras.jar CHANGED
Binary file
@@ -1,4 +1,6 @@
1
1
  ### Using the LibraryProxy in your sketches
2
+ LibraryProxy is a [abstract java class](https://github.com/ruby-processing/JRubyArt/blob/master/src/monkstone/core/LibraryProxy.java) so that you can acccess vanilla processing library reflection methods in you sketches using ruby.
3
+
2
4
  In the sketch you should `load_library :library_proxy` and your library class should inherit
3
5
  from LibraryProxy and implement pre(), draw() and post() methods (can be empty method if not
4
6
  required). For simplicity initialize your `processing library` in the sketch `setup`.
@@ -94,4 +96,4 @@ end
94
96
  # does nothing here see custom_array.rb
95
97
  def draw
96
98
  end
97
- ```
99
+ ```
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.2
4
+ version: 1.1.3
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-06-14 00:00:00.000000000 Z
13
+ date: 2016-07-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -64,7 +64,7 @@ files:
64
64
  - lib/jruby_art/helpers/numeric.rb
65
65
  - lib/jruby_art/helpers/string_extra.rb
66
66
  - lib/jruby_art/installer.rb
67
- - lib/jruby_art/java_args.rb
67
+ - lib/jruby_art/java_opts.rb
68
68
  - lib/jruby_art/library_loader.rb
69
69
  - lib/jruby_art/runner.rb
70
70
  - lib/jruby_art/runners/base.rb
@@ -1,21 +0,0 @@
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