jruby_art 1.2.9 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jruby_art/core.rb +15 -0
- data/lib/jruby_art/creators/sketch_writer.rb +23 -17
- data/lib/jruby_art/helper_methods.rb +6 -3
- data/lib/jruby_art/installer.rb +4 -4
- data/lib/jruby_art/java_opts.rb +4 -5
- data/lib/jruby_art/launcher.rb +34 -16
- data/lib/jruby_art/runner.rb +1 -1
- data/lib/jruby_art/version.rb +1 -1
- data/lib/rpextras.jar +0 -0
- data/vendors/Rakefile +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 292fae4f648b4f0327554d767cdd4640402a16c8
|
4
|
+
data.tar.gz: 8110acac7375c71c172b7874fa1de38ac107bfc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b722c4cc150a52923b144b3dbc6397bc79a66fdeaf3233c51f991d4e61a6308202aa16a0f28cc907edb35e6e4c3f5982a64f430e9a7d921cd0a1481344607427
|
7
|
+
data.tar.gz: 74a19e1bd0f7495b176073a9e5d857c56b0b2aae464e8d46180f69d9e2a6f60ac5e334f591d4bb4896becf9c423b81cbc5f343a99bf9619f9dd31b17ce2fe1e3
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# module encapsulates a check that the PROCESSING_ROOT exists
|
3
|
+
module Core
|
4
|
+
def self.check?(path)
|
5
|
+
if File.directory?(path)
|
6
|
+
core_path = File.join(path, 'core/library/core.jar')
|
7
|
+
return true if File.exist?(core_path)
|
8
|
+
warn format('%s jar does not exist', core_path)
|
9
|
+
else warn format('%s directory does not exist', path)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Provided processing distributions have the same nested structure ie:-
|
15
|
+
# "core/library/core.jar" we can find "core.jar" when PROCESSING_ROOT exists
|
@@ -33,8 +33,7 @@ class SketchWriter
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def write
|
36
|
-
|
37
|
-
sketch = template.code(param)
|
36
|
+
sketch = SketchFactory.create(param)
|
38
37
|
File.open(file, 'w+') { |f| f.write sketch.join("\n") }
|
39
38
|
end
|
40
39
|
end
|
@@ -42,19 +41,26 @@ end
|
|
42
41
|
# Implements methods and class_methods omits blank line after draw
|
43
42
|
# uses private method_lines to format method lines
|
44
43
|
class Sketch
|
44
|
+
attr_reader :param
|
45
|
+
|
46
|
+
def initialize(param)
|
47
|
+
@param = param
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
45
51
|
BLANK ||= ''.freeze
|
46
52
|
INDENT ||= ' '.freeze
|
47
53
|
|
48
|
-
def methods(
|
54
|
+
def methods(indent)
|
49
55
|
lines = []
|
50
56
|
lines.concat method_lines('settings', param.sketch_size, indent)
|
51
57
|
lines.concat method_lines('setup', param.sketch_title, indent)
|
52
58
|
lines.concat method_lines('draw', BLANK, indent)
|
53
59
|
end
|
54
60
|
|
55
|
-
def class_methods
|
61
|
+
def class_methods
|
56
62
|
lines = [format('class %s < Processing::App', param.class_name)]
|
57
|
-
lines.concat methods(
|
63
|
+
lines.concat methods(INDENT)
|
58
64
|
lines << 'end'
|
59
65
|
end
|
60
66
|
|
@@ -70,37 +76,37 @@ class Sketch
|
|
70
76
|
end
|
71
77
|
|
72
78
|
# Switch templates on config
|
73
|
-
class
|
74
|
-
def self.
|
79
|
+
class SketchFactory
|
80
|
+
def self.create(param)
|
75
81
|
case Processing::RP_CONFIG.fetch('template', 'bare')
|
76
82
|
when /bare/
|
77
|
-
|
83
|
+
BareSketch
|
78
84
|
when /class/
|
79
|
-
|
85
|
+
ClassSketch
|
80
86
|
when /emacs/
|
81
|
-
|
82
|
-
end
|
87
|
+
EmacsSketch
|
88
|
+
end.new(param).code
|
83
89
|
end
|
84
90
|
end
|
85
91
|
|
86
92
|
# The sketch class creates an array of formatted sketch lines
|
87
93
|
class BareSketch < Sketch
|
88
|
-
def code
|
89
|
-
methods(
|
94
|
+
def code
|
95
|
+
methods(BLANK)
|
90
96
|
end
|
91
97
|
end
|
92
98
|
|
93
99
|
# A simple class wrapped sketch
|
94
100
|
class ClassSketch < Sketch
|
95
|
-
def code
|
101
|
+
def code
|
96
102
|
lines = ['# frozen_string_literal: false', BLANK]
|
97
|
-
lines.concat class_methods
|
103
|
+
lines.concat class_methods
|
98
104
|
end
|
99
105
|
end
|
100
106
|
|
101
107
|
# A sketch that will run with jruby, for emacs etc
|
102
108
|
class EmacsSketch < Sketch
|
103
|
-
def code
|
109
|
+
def code
|
104
110
|
lines = [
|
105
111
|
'# frozen_string_literal: false',
|
106
112
|
"require 'jruby_art'",
|
@@ -109,7 +115,7 @@ class EmacsSketch < Sketch
|
|
109
115
|
'Processing::App::SKETCH_PATH = __FILE__.freeze',
|
110
116
|
BLANK
|
111
117
|
]
|
112
|
-
lines.concat class_methods
|
118
|
+
lines.concat class_methods
|
113
119
|
lines << BLANK
|
114
120
|
lines << format('%s.new unless defined? $app', param.class_name)
|
115
121
|
end
|
@@ -76,16 +76,19 @@ module Processing
|
|
76
76
|
|
77
77
|
# explicitly provide 'processing.org' min instance method
|
78
78
|
# to return a float:- a, b and c need to be floats
|
79
|
+
# you might choose to use ruby method directly and then
|
80
|
+
# provide a block to alter comparator eg
|
81
|
+
# args.min(&block) # { |a, b| a.value <=> b.value }
|
79
82
|
|
80
83
|
def min(*args)
|
81
|
-
args.min
|
84
|
+
args.min
|
82
85
|
end
|
83
86
|
|
84
87
|
# explicitly provide 'processing.org' max instance method
|
85
|
-
# to return a float:- a, b and c need to be floats
|
88
|
+
# to return a float:- a, b and c need to be floats see above
|
86
89
|
|
87
90
|
def max(*args)
|
88
|
-
args.max
|
91
|
+
args.max
|
89
92
|
end
|
90
93
|
|
91
94
|
# explicitly provide 'processing.org' dist instance method
|
data/lib/jruby_art/installer.rb
CHANGED
@@ -31,8 +31,7 @@ class Installer
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def root_exist?
|
34
|
-
|
35
|
-
File.exist? config['PROCESSING_ROOT']
|
34
|
+
Core.check?(config['PROCESSING_ROOT'])
|
36
35
|
end
|
37
36
|
|
38
37
|
def config
|
@@ -55,12 +54,13 @@ end
|
|
55
54
|
|
56
55
|
# Configuration checker
|
57
56
|
class Check < Installer
|
57
|
+
require_relative 'core'
|
58
58
|
def install
|
59
59
|
show_version
|
60
60
|
return super unless config
|
61
61
|
installed = File.exist? File.join(gem_root, 'lib/ruby/jruby-complete.jar')
|
62
|
-
proot = ' PROCESSING_ROOT = Not Set!!!' unless root_exist?
|
63
|
-
proot ||= " PROCESSING_ROOT = #{config['PROCESSING_ROOT']}"
|
62
|
+
proot = ' PROCESSING_ROOT = Not Set Correctly!!!' unless root_exist?
|
63
|
+
proot ||= " PROCESSING_ROOT = #{config['PROCESSING_ROOT']}"
|
64
64
|
sketchbook = " sketchbook_path = #{config['sketchbook_path']}"
|
65
65
|
template = " template = #{config['template']}"
|
66
66
|
java_args = " java_args = #{config['java_args']}"
|
data/lib/jruby_art/java_opts.rb
CHANGED
@@ -3,13 +3,12 @@
|
|
3
3
|
class JavaOpts
|
4
4
|
attr_reader :opts
|
5
5
|
|
6
|
-
def initialize
|
7
|
-
arg_file = File.join(
|
6
|
+
def initialize
|
7
|
+
arg_file = File.join(SKETCH_ROOT, 'data/java_args.txt')
|
8
8
|
@opts = []
|
9
9
|
@opts += File.read(arg_file).split(/\s+/) if FileTest.exist?(arg_file)
|
10
|
-
|
11
|
-
|
12
|
-
end
|
10
|
+
return unless opts.empty? && Processing::RP_CONFIG.fetch('java_args', false)
|
11
|
+
@opts += Processing::RP_CONFIG['java_args'].split(/\s+/)
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
data/lib/jruby_art/launcher.rb
CHANGED
@@ -5,11 +5,13 @@ module Processing
|
|
5
5
|
# The command class check for configuration and options, before creating and
|
6
6
|
# executing the jruby (or java) command to run the sketch
|
7
7
|
class Launcher
|
8
|
-
attr_reader :
|
8
|
+
attr_reader :command
|
9
9
|
def initialize(runner:, args:, filename:)
|
10
|
-
@
|
11
|
-
|
12
|
-
|
10
|
+
@command = if Processing::RP_CONFIG.fetch('JRUBY', true)
|
11
|
+
JRubyCommand.new(runner, filename, args)
|
12
|
+
else
|
13
|
+
JavaCommand.new(runner, filename, args)
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
# Trade in this Ruby instance for a JRuby instance, loading in a starter
|
@@ -17,25 +19,41 @@ module Processing
|
|
17
19
|
# ~/.jruby_art/config.yml, an installed version of jruby is used instead
|
18
20
|
# of our vendored one. Note the use of jruby-complete might make using
|
19
21
|
# other gems in your sketches hard (but not impossible)....
|
20
|
-
def cmd
|
21
|
-
cmda =
|
22
|
+
def cmd
|
23
|
+
cmda = command.cmd
|
22
24
|
begin
|
23
25
|
exec(*cmda)
|
24
26
|
# exec replaces the Ruby process with the JRuby one.
|
25
27
|
rescue Java::JavaLang::ClassNotFoundException
|
26
28
|
end
|
27
29
|
end
|
30
|
+
end
|
31
|
+
end
|
28
32
|
|
29
|
-
|
33
|
+
# Wrap creation of java command string as a class
|
34
|
+
class JavaCommand
|
35
|
+
MAIN = 'org.jruby.Main'.freeze
|
36
|
+
attr_reader :runner, :args, :filename, :opts, :complete
|
37
|
+
def initialize(runner, args, filename)
|
38
|
+
@runner, @args, @filename = runner, args, filename
|
39
|
+
@complete = JRubyComplete.complete
|
40
|
+
@opts = JavaOpts.new.opts
|
41
|
+
end
|
30
42
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
43
|
+
def cmd
|
44
|
+
['java', opts, '-cp', complete, MAIN, runner, filename, args].flatten
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Wrap creation of jruby command string as a class
|
49
|
+
class JRubyCommand
|
50
|
+
attr_reader :runner, :args, :filename, :opts
|
51
|
+
def initialize(runner, args, filename)
|
52
|
+
@runner, @args, @filename = runner, args, filename
|
53
|
+
@opts = JRubyOpts.new.opts
|
54
|
+
end
|
55
|
+
|
56
|
+
def cmd
|
57
|
+
['jruby', opts, runner, filename, args].flatten
|
40
58
|
end
|
41
59
|
end
|
data/lib/jruby_art/runner.rb
CHANGED
data/lib/jruby_art/version.rb
CHANGED
data/lib/rpextras.jar
CHANGED
Binary file
|
data/vendors/Rakefile
CHANGED
@@ -8,8 +8,8 @@ WARNING = <<-EOS.freeze
|
|
8
8
|
|
9
9
|
EOS
|
10
10
|
|
11
|
-
JRUBYC_VERSION = '9.1.
|
12
|
-
EXAMPLES = '2.
|
11
|
+
JRUBYC_VERSION = '9.1.8.0'
|
12
|
+
EXAMPLES = '2.1'
|
13
13
|
HOME_DIR = ENV['HOME']
|
14
14
|
MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
|
15
15
|
|
@@ -27,7 +27,7 @@ file "jruby-complete-#{JRUBYC_VERSION}.jar" do
|
|
27
27
|
rescue
|
28
28
|
warn(WARNING)
|
29
29
|
end
|
30
|
-
check_sha256("jruby-complete-#{JRUBYC_VERSION}.jar", "
|
30
|
+
check_sha256("jruby-complete-#{JRUBYC_VERSION}.jar", "f4552ce55ac6700ad51dc1dce8a3a0b8153cbe9b885006e039a98b558f77e551")
|
31
31
|
end
|
32
32
|
|
33
33
|
directory "../lib/ruby"
|
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.
|
4
|
+
version: 1.3.0
|
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: 2017-
|
13
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/jruby_art.rb
|
54
54
|
- lib/jruby_art/app.rb
|
55
55
|
- lib/jruby_art/config.rb
|
56
|
+
- lib/jruby_art/core.rb
|
56
57
|
- lib/jruby_art/creators/sketch_writer.rb
|
57
58
|
- lib/jruby_art/helper_methods.rb
|
58
59
|
- lib/jruby_art/helpers/aabb.rb
|