jruby_art 1.1.3 → 1.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b2efc2b922f7fc4f2deaa35f08f4eff1b76f866
4
- data.tar.gz: 3d1c58ba7d1b7fdaad54f60c3cc7db530b9aa192
3
+ metadata.gz: a22fcab2a6f604989c8b1a899df3c1abc6ab5552
4
+ data.tar.gz: 3acdaf5f9012264b75cd228018fd1ea65f90cdf2
5
5
  SHA512:
6
- metadata.gz: 4ac06b256d5e9cb69c25c49a2f2aafe4cd8027ce04407f1b6c3dc5549938e0e41d48a3e8e4c36ec9b5a1f237e6b2e611ae3758d70faebbb07ad95a56e48d5900
7
- data.tar.gz: fbe51822b4bb75092c909d57ea1a477ccd4ad2e41270745523a6d389f159b77162e219a24b5609814f55ad2f39ef2b12b604744ad13ea68ff1dee51f298f3b11
6
+ metadata.gz: 33dcf72c40eb1a639470dd6c6cd1174554ace2a913f012204a0591de5b3ae923294290cb37f41779d5d35d6c6a5096b49156dbe8e81b6d6280d450f4dc039227
7
+ data.tar.gz: 2e86f479093a3cbc783176c764d32697637625cc64aac8905293e753b7a586b5a40f391a07611d2c2538d54994799e7c6baf4fc920081c6d6e0b5aade06eec14
data/lib/jruby_art/app.rb CHANGED
@@ -158,6 +158,7 @@ module Processing
158
158
  surface.stopThread
159
159
  surface.setVisible(false) if surface.isStopped
160
160
  dispose
161
+ $app = nil
161
162
  end
162
163
 
163
164
  def exit
@@ -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
@@ -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
- data = {
28
- 'PROCESSING_ROOT' => proot,
29
- 'JRUBY' => true.to_s,
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['JRUBY']
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
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- require 'ostruct'
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
- attr_reader :os
26
+ def initialize
27
+ @options = {}
28
+ end
58
29
 
59
- # Start running a jruby_art sketch from the passed-in arguments
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
- case @options.action
69
- when 'run' then run(@options.path, @options.args)
70
- when 'live' then live(@options.path, @options.args)
71
- when 'watch' then watch(@options.path, @options.args)
72
- when 'create' then create(@options.path, @options.args)
73
- when 'setup' then setup(@options.path)
74
- when /-v/ then show_version
75
- when /-h/ then show_help
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. Keep it simple.
49
+ # Parse the command-line options.
82
50
  def parse_options(args)
83
- @options = OpenStruct.new
84
- @options.emacs = !args.delete('--emacs').nil?
85
- @options.wrap = !args.delete('--wrap').nil?
86
- @options.inner = !args.delete('--inner').nil?
87
- @options.jruby = !args.delete('--jruby').nil?
88
- @options.nojruby = !args.delete('--nojruby').nil?
89
- @options.action = args[0] || nil
90
- @options.path = args[1] || File.basename(Dir.pwd + '.rb')
91
- @options.args = args[2..-1] || []
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
- # Create a fresh JRubyArt sketch, with the necessary
95
- # boilerplate filled out.
96
- def create(sketch, args)
97
- require_relative '../jruby_art/creators/creator'
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
- # Just simply run a JRubyArt sketch.
105
- def run(sketch, args)
106
- ensure_exists(sketch)
107
- spin_up('run.rb', sketch, args)
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 sketch.
111
- def live(sketch, args)
112
- ensure_exists(sketch)
113
- spin_up('live.rb', sketch, args)
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
- # Run a sketch, keeping an eye on it's file, and reloading
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 watch(sketch, args)
119
- ensure_exists(sketch)
120
- spin_up('watch.rb', sketch, args)
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 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
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 '--nojruby' is passed, the
143
- # installed version of jruby is used instead of our vendored one. To use
144
- # jruby-complete by default set JRUBY: false in ~/.jruby_art/config.yml
145
- # (however that might make using other gems in your sketches hard....)
146
- def spin_up(starter_script, sketch, args)
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
- @options.nojruby = true if Processing::RP_CONFIG['JRUBY'] == 'false'
149
- if @options.nojruby
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
- sketch,
158
- args].flatten
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(sketch)
177
- puts "Couldn't find: #{sketch}" and exit unless FileTest.exist?(sketch)
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', 20)
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
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
  # A wrapper for version
4
4
  module JRubyArt
5
- VERSION = '1.1.3'
5
+ VERSION = '1.2.0.pre'.freeze
6
6
  end
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 you sketches using ruby.
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
@@ -9,7 +9,7 @@ WARNING = <<-EOS
9
9
  EOS
10
10
 
11
11
  JRUBYC_VERSION = '9.1.2.0'
12
- EXAMPLES = '1.2'
12
+ EXAMPLES = '1.3'
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.3
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-01 00:00:00.000000000 Z
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 supports processing-3.1.1, and uses jruby-9.1.2.0 as the glue \n between
45
- ruby and java. You can use both processing libraries and ruby gems \n in your sketches.
46
- Features create/run/watch/live modes. The \"watch\" mode,\n provides a nice REPL-ish
47
- way to work on your processing sketches. Includes:-\n A \"Control Panel\" library,
48
- so that you can easily create sliders, buttons,\n checkboxes and drop-down menus,
49
- and hook them into your sketch's instance\n variables and hundreds of worked examples
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/creator.rb
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 setup install' to install jruby-complete, and 'k9 setup
90
- check' to check config.
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: '0'
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