jruby_art 1.1.3 → 1.2.0.pre
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 +4 -4
- data/lib/jruby_art/app.rb +1 -0
- data/lib/jruby_art/creators/sketch_writer.rb +128 -0
- data/lib/jruby_art/installer.rb +15 -14
- data/lib/jruby_art/runner.rb +119 -101
- data/lib/jruby_art/runners/watch.rb +1 -1
- data/lib/jruby_art/version.rb +1 -1
- data/lib/rpextras.jar +0 -0
- data/library/library_proxy/README.md +1 -1
- data/vendors/Rakefile +1 -1
- metadata +14 -14
- data/lib/jruby_art/creators/creator.rb +0 -277
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a22fcab2a6f604989c8b1a899df3c1abc6ab5552
|
4
|
+
data.tar.gz: 3acdaf5f9012264b75cd228018fd1ea65f90cdf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33dcf72c40eb1a639470dd6c6cd1174554ace2a913f012204a0591de5b3ae923294290cb37f41779d5d35d6c6a5096b49156dbe8e81b6d6280d450f4dc039227
|
7
|
+
data.tar.gz: 2e86f479093a3cbc783176c764d32697637625cc64aac8905293e753b7a586b5a40f391a07611d2c2538d54994799e7c6baf4fc920081c6d6e0b5aade06eec14
|
data/lib/jruby_art/app.rb
CHANGED
@@ -0,0 +1,128 @@
|
|
1
|
+
EMACS = <<-CODE
|
2
|
+
# frozen_string_literal: false
|
3
|
+
require 'jruby_art'
|
4
|
+
require 'jruby_art/app'
|
5
|
+
|
6
|
+
Processing::App::SKETCH_PATH = __FILE__.freeze
|
7
|
+
|
8
|
+
class %s < Processing::App
|
9
|
+
def settings
|
10
|
+
%s
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup
|
14
|
+
%s
|
15
|
+
end
|
16
|
+
|
17
|
+
def draw
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
%s.new unless defined? $app
|
22
|
+
|
23
|
+
CODE
|
24
|
+
|
25
|
+
CLASS = <<-CODE
|
26
|
+
class %s < Processing::App
|
27
|
+
def settings
|
28
|
+
%s
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup
|
32
|
+
%s
|
33
|
+
end
|
34
|
+
|
35
|
+
def draw
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
CODE
|
40
|
+
|
41
|
+
METHOD = <<-CODE
|
42
|
+
def %s
|
43
|
+
%s
|
44
|
+
end
|
45
|
+
|
46
|
+
CODE
|
47
|
+
|
48
|
+
require_relative '../helpers/string_extra'
|
49
|
+
|
50
|
+
# Sketch writer class
|
51
|
+
class SketchWriter
|
52
|
+
attr_reader :file, :args, :sketch, :name
|
53
|
+
|
54
|
+
def initialize(path, args)
|
55
|
+
@args = args
|
56
|
+
@name = path
|
57
|
+
underscore = StringExtra.new(path).underscore
|
58
|
+
@file = format('%s/%s.rb', File.dirname(path), underscore)
|
59
|
+
end
|
60
|
+
|
61
|
+
def create!(type)
|
62
|
+
case type
|
63
|
+
when /bare/
|
64
|
+
@sketch = Sketch.new.bare(name, args)
|
65
|
+
when /class/
|
66
|
+
@sketch = Sketch.new.class_wrapped(name, args)
|
67
|
+
when /emacs/
|
68
|
+
@sketch = Sketch.new.emacs(name, args)
|
69
|
+
end
|
70
|
+
save(sketch)
|
71
|
+
end
|
72
|
+
|
73
|
+
def save(sketch)
|
74
|
+
File.open(file, 'w+') do |f|
|
75
|
+
f.write(sketch)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Sketch class
|
81
|
+
class Sketch
|
82
|
+
def bare(name = 'sketch', args = [])
|
83
|
+
[settings(args), setup(name), draw].join
|
84
|
+
end
|
85
|
+
|
86
|
+
def class_wrapped(name = 'sketch', args = [])
|
87
|
+
class_name = StringExtra.new(name).camelize
|
88
|
+
format(CLASS, class_name, size(args[0], args[1], args[2]), name(name))
|
89
|
+
end
|
90
|
+
|
91
|
+
def emacs(name = 'sketch', args = [])
|
92
|
+
class_name = StringExtra.new(name).camelize
|
93
|
+
format(
|
94
|
+
EMACS,
|
95
|
+
class_name,
|
96
|
+
size(args[0], args[1], args[2]),
|
97
|
+
name(name),
|
98
|
+
class_name
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def size(width = 200, height = 200, mode = nil)
|
103
|
+
return format('size %s, %s', width, height) if mode.nil?
|
104
|
+
format('size %s, %s, %s', width, height, mode.upcase)
|
105
|
+
end
|
106
|
+
|
107
|
+
def settings(args = [])
|
108
|
+
return format(METHOD, 'settings', size) if args.empty?
|
109
|
+
return format(
|
110
|
+
METHOD,
|
111
|
+
'settings',
|
112
|
+
size(args[0], args[1])
|
113
|
+
) if args.length == 2
|
114
|
+
format(METHOD, 'settings', size(args[0], args[1], args[2]))
|
115
|
+
end
|
116
|
+
|
117
|
+
def name(title = 'Sketch')
|
118
|
+
format("sketch_title '%s'", StringExtra.new(title).humanize)
|
119
|
+
end
|
120
|
+
|
121
|
+
def setup(title)
|
122
|
+
format(METHOD, 'setup', name(title))
|
123
|
+
end
|
124
|
+
|
125
|
+
def draw
|
126
|
+
format(METHOD, 'draw', '')
|
127
|
+
end
|
128
|
+
end
|
data/lib/jruby_art/installer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
require 'yaml'
|
3
3
|
|
4
|
-
VERSION = '3.1.1' # processing version
|
4
|
+
VERSION = '3.1.1'.freeze # processing version
|
5
5
|
|
6
6
|
# Abstract Installer class
|
7
7
|
class Installer
|
@@ -14,7 +14,7 @@ class Installer
|
|
14
14
|
@sketch = "#{home}/My Documents/Processing" if os == :windows
|
15
15
|
@sketch = "#{home}/Documents/Processing" if os == :mac
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# Optimistically set processing root
|
19
19
|
def set_processing_root
|
20
20
|
require 'psych'
|
@@ -24,31 +24,28 @@ class Installer
|
|
24
24
|
proot = "#{home}/processing-#{VERSION}"
|
25
25
|
proot = "/Java/Processing-#{VERSION}" if os == :windows
|
26
26
|
proot = "/Applications/Processing.app/Contents/Java" if os == :mac
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
'sketchbook_path' => sketch,
|
31
|
-
'MAX_WATCH' => '20'
|
32
|
-
}
|
27
|
+
settings = %w(PROCESSING_ROOT JRUBY sketchbook_path template MAX_WATCH)
|
28
|
+
values = [proot, true, sketch, 'bare', 32]
|
29
|
+
data = settings.zip(values).to_h
|
33
30
|
open(path, 'w:UTF-8') { |file| file.write(data.to_yaml) }
|
34
31
|
end
|
35
|
-
|
32
|
+
|
36
33
|
def root_exist?
|
37
34
|
return false if config.nil?
|
38
35
|
File.exist? config['PROCESSING_ROOT']
|
39
36
|
end
|
40
|
-
|
37
|
+
|
41
38
|
def config
|
42
39
|
k9config = File.expand_path("#{home}/.jruby_art/config.yml")
|
43
40
|
return nil unless File.exist? k9config
|
44
41
|
YAML.load_file(k9config)
|
45
42
|
end
|
46
|
-
|
43
|
+
|
47
44
|
# in place of default installer class
|
48
45
|
def install
|
49
46
|
puts 'Usage: k9 setup [check | install | unpack_samples]'
|
50
47
|
end
|
51
|
-
|
48
|
+
|
52
49
|
# Display the current version of JRubyArt.
|
53
50
|
def show_version
|
54
51
|
puts format('JRubyArt version %s', JRubyArt::VERSION)
|
@@ -56,7 +53,7 @@ class Installer
|
|
56
53
|
end
|
57
54
|
|
58
55
|
# Configuration checker
|
59
|
-
class Check < Installer
|
56
|
+
class Check < Installer
|
60
57
|
def install
|
61
58
|
show_version
|
62
59
|
return super unless config
|
@@ -64,12 +61,16 @@ class Check < Installer
|
|
64
61
|
proot = ' PROCESSING_ROOT = Not Set!!!' unless root_exist?
|
65
62
|
proot ||= " PROCESSING_ROOT = #{config['PROCESSING_ROOT']}"
|
66
63
|
sketchbook = " sketchbook_path = #{config['sketchbook_path']}"
|
64
|
+
template = " template = #{config['template']}"
|
65
|
+
java_args = " java_args = #{config['java_args']}"
|
67
66
|
max_watch = " MAX_WATCH = #{config['MAX_WATCH']}"
|
68
|
-
jruby = config
|
67
|
+
jruby = config.fetch('JRUBY', true)
|
69
68
|
puts proot
|
70
69
|
puts " JRUBY = #{jruby}" unless jruby.nil?
|
71
70
|
puts " jruby-complete installed = #{installed}"
|
72
71
|
puts sketchbook
|
72
|
+
puts template
|
73
|
+
puts java_args
|
73
74
|
puts max_watch
|
74
75
|
end
|
75
76
|
end
|
data/lib/jruby_art/runner.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'optparse'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'rbconfig'
|
6
6
|
require_relative '../jruby_art/config'
|
7
7
|
require_relative '../jruby_art/version'
|
8
|
-
require_relative '../jruby_art/installer'
|
9
8
|
require_relative '../jruby_art/java_opts'
|
10
9
|
|
11
10
|
# processing wrapper module
|
@@ -13,38 +12,6 @@ module Processing
|
|
13
12
|
# Utility class to handle the different commands that the 'k9' command
|
14
13
|
# offers. Able to run, watch, live, create, app, and unpack
|
15
14
|
class Runner
|
16
|
-
HELP_MESSAGE ||= <<-EOS
|
17
|
-
Version: #{JRubyArt::VERSION}
|
18
|
-
|
19
|
-
JRubyArt is a little shim between Processing and JRuby that helps
|
20
|
-
you create sketches of code art.
|
21
|
-
|
22
|
-
Usage:
|
23
|
-
k9 [choice] sketch
|
24
|
-
|
25
|
-
choice:-
|
26
|
-
run: run sketch once
|
27
|
-
watch: watch for changes on the file and relaunch it on the fly
|
28
|
-
live: run sketch and open a pry console bound to $app
|
29
|
-
create [width height][mode][flag]: create a new sketch.
|
30
|
-
setup: check / install / unpack_samples
|
31
|
-
|
32
|
-
Common options:
|
33
|
-
--nojruby: use jruby-complete in place of an installed version of jruby
|
34
|
-
(Set [JRUBY: 'false'] in .jruby_art/config.yml to make using jruby-complete default)
|
35
|
-
|
36
|
-
Examples:
|
37
|
-
k9 setup unpack_samples
|
38
|
-
k9 run rp_samples/samples/contributed/jwishy.rb
|
39
|
-
k9 create some_new_sketch 640 480 p3d (P3D mode example)
|
40
|
-
k9 create some_new_sketch 640 480 --wrap (a class wrapped default sketch)
|
41
|
-
k9 watch some_new_sketch.rb
|
42
|
-
|
43
|
-
Everything Else:
|
44
|
-
https://ruby-processing.github.io/
|
45
|
-
|
46
|
-
EOS
|
47
|
-
|
48
15
|
WIN_PATTERNS = [
|
49
16
|
/bccwin/i,
|
50
17
|
/cygwin/i,
|
@@ -52,11 +19,15 @@ module Processing
|
|
52
19
|
/ming/i,
|
53
20
|
/mswin/i,
|
54
21
|
/wince/i
|
55
|
-
]
|
22
|
+
].freeze
|
23
|
+
|
24
|
+
attr_reader :options, :argc, :filename, :os
|
56
25
|
|
57
|
-
|
26
|
+
def initialize
|
27
|
+
@options = {}
|
28
|
+
end
|
58
29
|
|
59
|
-
# Start running a jruby_art
|
30
|
+
# Start running a jruby_art filename from the passed-in arguments
|
60
31
|
def self.execute
|
61
32
|
runner = new
|
62
33
|
runner.parse_options(ARGV)
|
@@ -65,66 +36,114 @@ module Processing
|
|
65
36
|
|
66
37
|
# Dispatch central.
|
67
38
|
def execute!
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
else
|
77
|
-
show_help
|
78
|
-
end
|
39
|
+
show_help if options.empty?
|
40
|
+
show_version if options[:version]
|
41
|
+
run_sketch if options[:run]
|
42
|
+
watch_sketch if options[:watch]
|
43
|
+
live if options[:live]
|
44
|
+
create if options[:create]
|
45
|
+
check if options[:check]
|
46
|
+
install if options[:install]
|
79
47
|
end
|
80
48
|
|
81
|
-
# Parse the command-line options.
|
49
|
+
# Parse the command-line options.
|
82
50
|
def parse_options(args)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
51
|
+
opt_parser = OptionParser.new do |opts|
|
52
|
+
# Set a banner, displayed at the top
|
53
|
+
# of the help screen.
|
54
|
+
opts.banner = 'Usage: k9 [options] [<filename.rb>]'
|
55
|
+
# Define the options, and what they do
|
56
|
+
options[:version] = false
|
57
|
+
opts.on('-v', '--version', 'JRubyArt Version') do
|
58
|
+
options[:version] = true
|
59
|
+
end
|
60
|
+
|
61
|
+
options[:install] = false
|
62
|
+
opts.on('-i', '--install', 'Installs jruby-complete and examples') do
|
63
|
+
options[:install] = true
|
64
|
+
end
|
65
|
+
|
66
|
+
options[:check] = false
|
67
|
+
opts.on('-?', '--check', 'Prints configuration') do
|
68
|
+
options[:check] = true
|
69
|
+
end
|
70
|
+
|
71
|
+
options[:app] = false
|
72
|
+
opts.on('-a', '--app', 'Export as app NOT IMPLEMENTED YET') do
|
73
|
+
options[:export] = true
|
74
|
+
end
|
75
|
+
|
76
|
+
options[:watch] = false
|
77
|
+
opts.on('-w', '--watch', 'Watch/run the sketch') do
|
78
|
+
options[:watch] = true
|
79
|
+
end
|
80
|
+
|
81
|
+
options[:run] = false
|
82
|
+
opts.on('-r', '--run', 'Run the sketch') do
|
83
|
+
options[:run] = true
|
84
|
+
end
|
85
|
+
|
86
|
+
options[:live] = false
|
87
|
+
opts.on('-l', '--live', 'As above, with pry console bound to $app') do
|
88
|
+
options[:live] = true
|
89
|
+
end
|
90
|
+
|
91
|
+
options[:create] = false
|
92
|
+
opts.on('-c', '--create', 'Create new outline sketch') do
|
93
|
+
options[:create] = true
|
94
|
+
end
|
95
|
+
|
96
|
+
# This displays the help screen, all programs are
|
97
|
+
# assumed to have this option.
|
98
|
+
opts.on('-h', '--help', 'Display this screen') do
|
99
|
+
puts opts
|
100
|
+
exit
|
101
|
+
end
|
102
|
+
end
|
103
|
+
@argc = opt_parser.parse(args)
|
104
|
+
@filename = argc.shift
|
92
105
|
end
|
93
106
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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)
|
107
|
+
def create
|
108
|
+
require_relative '../jruby_art/creators/sketch_writer'
|
109
|
+
config = Processing::RP_CONFIG.fetch('template', 'bare')
|
110
|
+
SketchWriter.new(filename, argc).create!(config)
|
102
111
|
end
|
103
112
|
|
104
|
-
#
|
105
|
-
def
|
106
|
-
ensure_exists(
|
107
|
-
|
113
|
+
# Export as app not implemented
|
114
|
+
def export
|
115
|
+
ensure_exists(filename)
|
116
|
+
puts 'Not implemented yet'
|
108
117
|
end
|
109
118
|
|
110
|
-
# Just simply run a JRubyArt
|
111
|
-
def
|
112
|
-
ensure_exists(
|
113
|
-
spin_up('
|
119
|
+
# Just simply run a JRubyArt filename.
|
120
|
+
def run_sketch
|
121
|
+
ensure_exists(filename)
|
122
|
+
spin_up('run.rb', filename, argc)
|
114
123
|
end
|
115
124
|
|
116
|
-
#
|
125
|
+
# Just simply run a JRubyArt filename.
|
126
|
+
def live
|
127
|
+
ensure_exists(filename)
|
128
|
+
spin_up('live.rb', filename, argc)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Run a filename, keeping an eye on it's file, and reloading
|
117
132
|
# whenever it changes.
|
118
|
-
def
|
119
|
-
ensure_exists(
|
120
|
-
spin_up('watch.rb',
|
133
|
+
def watch_sketch
|
134
|
+
ensure_exists(filename)
|
135
|
+
spin_up('watch.rb', filename, argc)
|
136
|
+
end
|
137
|
+
|
138
|
+
def install
|
139
|
+
require_relative '../jruby_art/installer'
|
140
|
+
JRubyComplete.new(K9_ROOT, host_os).install
|
141
|
+
UnpackSamples.new(K9_ROOT, host_os).install
|
121
142
|
end
|
122
143
|
|
123
|
-
def
|
124
|
-
|
125
|
-
|
126
|
-
return UnpackSamples.new(K9_ROOT, host_os).install if choice =~ /unpack_sample/
|
127
|
-
Installer.new(K9_ROOT, host_os).install
|
144
|
+
def check
|
145
|
+
require_relative '../jruby_art/installer'
|
146
|
+
Check.new(K9_ROOT, host_os).install
|
128
147
|
end
|
129
148
|
|
130
149
|
# Show the standard help/usage message.
|
@@ -139,14 +158,20 @@ module Processing
|
|
139
158
|
private
|
140
159
|
|
141
160
|
# Trade in this Ruby instance for a JRuby instance, loading in a starter
|
142
|
-
# script and passing it some arguments. Unless
|
143
|
-
# installed version of jruby is used instead
|
144
|
-
#
|
145
|
-
#
|
146
|
-
def spin_up(starter_script,
|
161
|
+
# script and passing it some arguments. Unless you set JRUBY: false in
|
162
|
+
# ~/.jruby_art/config.yml, an installed version of jruby is used instead
|
163
|
+
# of our vendored one. Note the use of jruby-complete might make using
|
164
|
+
# other gems in your sketches hard (but not impossible)....
|
165
|
+
def spin_up(starter_script, filename, argc)
|
147
166
|
runner = "#{K9_ROOT}/lib/jruby_art/runners/#{starter_script}"
|
148
|
-
|
149
|
-
|
167
|
+
if Processing::RP_CONFIG.fetch('JRUBY', true)
|
168
|
+
opts = JRubyOpts.new(SKETCH_ROOT).opts
|
169
|
+
command = ['jruby',
|
170
|
+
opts,
|
171
|
+
runner,
|
172
|
+
filename,
|
173
|
+
argc].flatten
|
174
|
+
else
|
150
175
|
opts = JavaOpts.new(SKETCH_ROOT).opts
|
151
176
|
command = ['java',
|
152
177
|
opts,
|
@@ -154,15 +179,8 @@ module Processing
|
|
154
179
|
jruby_complete,
|
155
180
|
'org.jruby.Main',
|
156
181
|
runner,
|
157
|
-
|
158
|
-
|
159
|
-
else
|
160
|
-
opts = JRubyOpts.new(SKETCH_ROOT).opts
|
161
|
-
command = ['jruby',
|
162
|
-
opts,
|
163
|
-
runner,
|
164
|
-
sketch,
|
165
|
-
args].flatten
|
182
|
+
filename,
|
183
|
+
argc].flatten
|
166
184
|
end
|
167
185
|
begin
|
168
186
|
exec(*command)
|
@@ -173,8 +191,8 @@ module Processing
|
|
173
191
|
|
174
192
|
# NB: We really do mean to use 'and' not '&&' for flow control purposes
|
175
193
|
|
176
|
-
def ensure_exists(
|
177
|
-
puts "Couldn't find: #{
|
194
|
+
def ensure_exists(filename)
|
195
|
+
puts "Couldn't find: #{filename}" and exit unless FileTest.exist?(filename)
|
178
196
|
end
|
179
197
|
|
180
198
|
def jruby_complete
|
@@ -68,7 +68,7 @@ module Processing
|
|
68
68
|
def reload_files_to_watch
|
69
69
|
@files = Dir.glob(File.join(SKETCH_ROOT, '**/*.{rb,glsl}'))
|
70
70
|
count = @files.length
|
71
|
-
max_watch = RP_CONFIG.fetch('MAX_WATCH',
|
71
|
+
max_watch = RP_CONFIG.fetch('MAX_WATCH', 32)
|
72
72
|
return unless count > max_watch.to_i
|
73
73
|
warn format(WATCH_MESSAGE, max_watch, count)
|
74
74
|
abort
|
data/lib/jruby_art/version.rb
CHANGED
data/lib/rpextras.jar
CHANGED
Binary file
|
@@ -1,5 +1,5 @@
|
|
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
|
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 your sketches using ruby.
|
3
3
|
|
4
4
|
In the sketch you should `load_library :library_proxy` and your library class should inherit
|
5
5
|
from LibraryProxy and implement pre(), draw() and post() methods (can be empty method if not
|
data/vendors/Rakefile
CHANGED
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.2.0.pre
|
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-07-
|
13
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -41,13 +41,13 @@ dependencies:
|
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '5.8'
|
43
43
|
description: " JRubyArt is a ruby wrapper for the processing art framework.\n This
|
44
|
-
version
|
45
|
-
|
46
|
-
Features create/run/watch/live modes. The \"watch\" mode,\n provides
|
47
|
-
way to work on your processing sketches. Includes:-\n A \"Control
|
48
|
-
so that you can easily create sliders, buttons,\n checkboxes and
|
49
|
-
and hook them into your sketch's instance\n variables and hundreds
|
50
|
-
to get you started...\n"
|
44
|
+
version uses 'optparse', run becomes --run (or -r) and 'setup install' \n becomes
|
45
|
+
'--install' or (-i) etc. Use both processing libraries and ruby gems \n in your
|
46
|
+
sketches. Features create/run/watch/live modes. The \"--watch\" mode,\n provides
|
47
|
+
a nice REPL-ish way to work on your processing sketches. Includes:-\n A \"Control
|
48
|
+
Panel\" library, so that you can easily create sliders, buttons,\n checkboxes and
|
49
|
+
drop-down menus, and hook them into your sketch's instance\n variables and hundreds
|
50
|
+
of worked examples to get you started...\n"
|
51
51
|
email: mamba2928@yahoo.co.uk
|
52
52
|
executables:
|
53
53
|
- k9
|
@@ -58,7 +58,7 @@ files:
|
|
58
58
|
- lib/jruby_art.rb
|
59
59
|
- lib/jruby_art/app.rb
|
60
60
|
- lib/jruby_art/config.rb
|
61
|
-
- lib/jruby_art/creators/
|
61
|
+
- lib/jruby_art/creators/sketch_writer.rb
|
62
62
|
- lib/jruby_art/helper_methods.rb
|
63
63
|
- lib/jruby_art/helpers/aabb.rb
|
64
64
|
- lib/jruby_art/helpers/numeric.rb
|
@@ -86,8 +86,8 @@ homepage: https://ruby-processing.github.io/
|
|
86
86
|
licenses:
|
87
87
|
- MIT
|
88
88
|
metadata: {}
|
89
|
-
post_install_message: Use 'k9
|
90
|
-
|
89
|
+
post_install_message: Use 'k9 --install' to install jruby-complete, and 'k9 --check'
|
90
|
+
to check config.
|
91
91
|
rdoc_options: []
|
92
92
|
require_paths:
|
93
93
|
- lib
|
@@ -98,9 +98,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '2.2'
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 1.3.1
|
104
104
|
requirements:
|
105
105
|
- A decent graphics card
|
106
106
|
- java runtime >= 1.8.0_92+
|
@@ -1,277 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
|
3
|
-
BASIC = <<-CODE
|
4
|
-
def setup
|
5
|
-
sketch_title '%s'
|
6
|
-
end
|
7
|
-
|
8
|
-
def draw
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def settings
|
13
|
-
size %s, %s
|
14
|
-
# pixel_density(2) # here for hi-dpi displays only
|
15
|
-
# smooth # here
|
16
|
-
end
|
17
|
-
|
18
|
-
CODE
|
19
|
-
|
20
|
-
BASIC_MODE = <<-CODE
|
21
|
-
def setup
|
22
|
-
sketch_title '%s'
|
23
|
-
end
|
24
|
-
|
25
|
-
def draw
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def settings
|
30
|
-
size %s, %s, %s
|
31
|
-
# smooth # here
|
32
|
-
end
|
33
|
-
|
34
|
-
CODE
|
35
|
-
|
36
|
-
CLASS_BASIC = <<-CODE
|
37
|
-
# encoding: utf-8
|
38
|
-
# frozen_string_literal: false
|
39
|
-
class %s < Processing::App
|
40
|
-
def setup
|
41
|
-
sketch_title '%s'
|
42
|
-
end
|
43
|
-
|
44
|
-
def draw
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
def settings
|
49
|
-
size %s, %s
|
50
|
-
# pixel_density(2) # here for hi-dpi displays only
|
51
|
-
# smooth # here
|
52
|
-
end
|
53
|
-
end
|
54
|
-
CODE
|
55
|
-
|
56
|
-
EMACS_BASIC = <<-CODE
|
57
|
-
# encoding: utf-8
|
58
|
-
# frozen_string_literal: false
|
59
|
-
require 'jruby_art'
|
60
|
-
require 'jruby_art/app'
|
61
|
-
|
62
|
-
Processing::App::SKETCH_PATH = __FILE__.freeze
|
63
|
-
|
64
|
-
class %s < Processing::App
|
65
|
-
def setup
|
66
|
-
sketch_title '%s'
|
67
|
-
end
|
68
|
-
|
69
|
-
def draw
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
def settings
|
74
|
-
size %s, %s
|
75
|
-
# smooth # here
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
%s.new unless defined? $app
|
80
|
-
CODE
|
81
|
-
|
82
|
-
CLASS_MODE = <<-CODE
|
83
|
-
# encoding: utf-8
|
84
|
-
# frozen_string_literal: false
|
85
|
-
class %s < Processing::App
|
86
|
-
def setup
|
87
|
-
sketch_title '%s'
|
88
|
-
end
|
89
|
-
|
90
|
-
def draw
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
def settings
|
95
|
-
size %s, %s, %s
|
96
|
-
# smooth # here
|
97
|
-
end
|
98
|
-
end
|
99
|
-
CODE
|
100
|
-
|
101
|
-
EMACS_MODE = <<-CODE
|
102
|
-
# encoding: utf-8
|
103
|
-
# frozen_string_literal: false
|
104
|
-
require 'jruby_art'
|
105
|
-
require 'jruby_art/app'
|
106
|
-
|
107
|
-
Processing::App::SKETCH_PATH = __FILE__.freeze
|
108
|
-
|
109
|
-
class %s < Processing::App
|
110
|
-
def setup
|
111
|
-
sketch_title '%s'
|
112
|
-
end
|
113
|
-
|
114
|
-
def draw
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
def settings
|
119
|
-
size %s, %s, %s
|
120
|
-
# smooth # here
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
%s.new unless defined? $app
|
125
|
-
CODE
|
126
|
-
|
127
|
-
INNER = <<-CODE
|
128
|
-
# encoding: utf-8
|
129
|
-
# frozen_string_literal: false
|
130
|
-
class %s
|
131
|
-
include Processing::Proxy
|
132
|
-
|
133
|
-
end
|
134
|
-
CODE
|
135
|
-
|
136
|
-
# creator wrapper module using StringExtra
|
137
|
-
module Creator
|
138
|
-
require_relative '../helpers/string_extra'
|
139
|
-
# Write file to disk
|
140
|
-
class SketchWriter
|
141
|
-
attr_reader :file
|
142
|
-
|
143
|
-
def initialize(path)
|
144
|
-
underscore = StringExtra.new(path).underscore
|
145
|
-
@file = "#{File.dirname(path)}/#{underscore}.rb"
|
146
|
-
end
|
147
|
-
|
148
|
-
def save(template)
|
149
|
-
File.open(file, 'w+') do |f|
|
150
|
-
f.write(template)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
# An abstract class providing common methods for real creators
|
156
|
-
class Base
|
157
|
-
ALL_DIGITS = /\A\d+\Z/
|
158
|
-
def already_exist(path)
|
159
|
-
underscore = StringExtra.new(path).underscore
|
160
|
-
new_file = "#{File.dirname(path)}/#{underscore}.rb"
|
161
|
-
return if !FileTest.exist?(path) && !FileTest.exist?(new_file)
|
162
|
-
puts 'That file already exists!'
|
163
|
-
exit
|
164
|
-
end
|
165
|
-
|
166
|
-
# Show the help/usage message for create.
|
167
|
-
def usage
|
168
|
-
puts <<-USAGE
|
169
|
-
|
170
|
-
Usage: k9 create <sketch_to_generate> <width> <height> <mode>
|
171
|
-
mode can be P2D / P3D.
|
172
|
-
Use --wrap for a sketch wrapped as a class
|
173
|
-
Use --inner to generated a ruby version of 'java' Inner class
|
174
|
-
Examples: k9 create app 800 600
|
175
|
-
k9 create app 800 600 p3d --wrap
|
176
|
-
k9 create inner_class --inner
|
177
|
-
|
178
|
-
USAGE
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
# This class creates bare sketches, with an optional render mode
|
183
|
-
class BasicSketch < Base
|
184
|
-
# Create a blank sketch, given a path.
|
185
|
-
def basic_template
|
186
|
-
format(BASIC, @title, @width, @height)
|
187
|
-
end
|
188
|
-
|
189
|
-
def basic_template_mode
|
190
|
-
format(BASIC_MODE, @title, @width, @height, @mode)
|
191
|
-
end
|
192
|
-
|
193
|
-
def create!(path, args)
|
194
|
-
return usage if /\?/ =~ path || /--help/ =~ path
|
195
|
-
# Check to make sure that the main file doesn't exist already
|
196
|
-
already_exist(path)
|
197
|
-
main_file = File.basename(path, '.rb') # allow uneeded extension input
|
198
|
-
writer = SketchWriter.new(main_file)
|
199
|
-
@title = StringExtra.new(main_file).titleize
|
200
|
-
@width = args[0]
|
201
|
-
@height = args[1]
|
202
|
-
return writer.save(basic_template) if args[2].nil?
|
203
|
-
@mode = args[2].upcase
|
204
|
-
writer.save(basic_template_mode)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
# This class creates class wrapped sketches, with an optional render mode
|
209
|
-
class ClassSketch < Base
|
210
|
-
def class_template
|
211
|
-
format(CLASS_BASIC, @name, @title, @width, @height)
|
212
|
-
end
|
213
|
-
|
214
|
-
def class_template_mode
|
215
|
-
format(CLASS_MODE, @name, @title, @width, @height, @mode)
|
216
|
-
end
|
217
|
-
|
218
|
-
# Create a class wrapped sketch, given a path.
|
219
|
-
def create!(path, args)
|
220
|
-
return usage if /\?/ =~ path || /--help/ =~ path
|
221
|
-
main_file = File.basename(path, '.rb') # allow uneeded extension input
|
222
|
-
# Check to make sure that the main file doesn't exist already
|
223
|
-
already_exist(path)
|
224
|
-
@name = StringExtra.new(main_file).camelize
|
225
|
-
writer = SketchWriter.new(main_file)
|
226
|
-
@title = StringExtra.new(main_file).titleize
|
227
|
-
@width, @height = args[0], args[1]
|
228
|
-
@mode = args[2].upcase unless args[2].nil?
|
229
|
-
template = @mode.nil? ? class_template : class_template_mode
|
230
|
-
writer.save(template)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
# This class creates class wrapped sketches, with an optional render mode
|
235
|
-
class EmacsSketch < Base
|
236
|
-
def emacs_template
|
237
|
-
format(EMACS_BASIC, @name, @title, @width, @height, @name)
|
238
|
-
end
|
239
|
-
|
240
|
-
def emacs_template_mode
|
241
|
-
format(EMACS_MODE, @name, @title, @width, @height, @mode, @name)
|
242
|
-
end
|
243
|
-
# Create a class wrapped sketch, given a path.
|
244
|
-
def create!(path, args)
|
245
|
-
return usage if /\?/ =~ path || /--help/ =~ path
|
246
|
-
main_file = File.basename(path, '.rb') # allow uneeded extension input
|
247
|
-
# Check to make sure that the main file doesn't exist already
|
248
|
-
already_exist(path)
|
249
|
-
@name = StringExtra.new(main_file).camelize
|
250
|
-
writer = SketchWriter.new(main_file)
|
251
|
-
@title = StringExtra.new(main_file).titleize
|
252
|
-
@width, @height = args[0], args[1]
|
253
|
-
@mode = args[2].upcase unless args[2].nil?
|
254
|
-
template = @mode.nil? ? emacs_template : emacs_template_mode
|
255
|
-
writer.save(template)
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
# This class creates a pseudo 'java inner class' of the sketch
|
260
|
-
class InnerSketch < Base
|
261
|
-
def inner_class_template
|
262
|
-
format(INNER, @name)
|
263
|
-
end
|
264
|
-
|
265
|
-
# Create a pseudo inner class, given a path.
|
266
|
-
def create!(path, _args_)
|
267
|
-
return usage if /\?/ =~ path || /--help/ =~ path
|
268
|
-
main_file = File.basename(path, '.rb') # allow uneeded extension input
|
269
|
-
# Check to make sure that the main file doesn't exist already
|
270
|
-
already_exist(path)
|
271
|
-
@name = main_file.camelize
|
272
|
-
writer = SketchWriter.new(main_file)
|
273
|
-
template = inner_class_template
|
274
|
-
writer.save(template)
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|