Skip to content

Commit a51e617

Browse files
authored
Merge pull request #22 from ruby-processing/refactor_create
update to jruby-complete-9.0.4.0
2 parents 1258fad + cd12008 commit a51e617

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

lib/jruby_art/creators/sketch_writer.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def initialize(path, args)
3232
@file = format('%s/%s.rb', File.dirname(path), path)
3333
end
3434

35-
def write(creator)
36-
sketch = creator.code(param)
35+
def write
36+
template = SketchTemplate.template
37+
sketch = template.code(param)
3738
File.open(file, 'w+') { |f| f.write sketch.join("\n") }
3839
end
3940
end
@@ -68,6 +69,20 @@ def method_lines(name, content, indent)
6869
end
6970
end
7071

72+
# Switch templates on config
73+
class SketchTemplate
74+
def self.template
75+
case Processing::RP_CONFIG.fetch('template', 'bare')
76+
when /bare/
77+
return BareSketch.new
78+
when /class/
79+
return ClassSketch.new
80+
when /emacs/
81+
return EmacsSketch.new
82+
end
83+
end
84+
end
85+
7186
# The sketch class creates an array of formatted sketch lines
7287
class BareSketch < Sketch
7388
def code(param)

lib/jruby_art/runner.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ def parse_options(args)
106106

107107
def create
108108
require_relative '../jruby_art/creators/sketch_writer'
109-
config = Processing::RP_CONFIG.fetch('template', 'bare')
110-
sketch = BareSketch.new if /bare/ =~ config
111-
sketch = ClassSketch.new if /class/ =~ config
112-
sketch = EmacsSketch.new if /emacs/ =~ config
113-
SketchWriter.new(File.basename(filename, '.rb'), argc).write(sketch)
109+
SketchWriter.new(File.basename(filename, '.rb'), argc).write
114110
end
115111

116112
# Export as app not implemented

lib/jruby_art/runners/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
# More processing module
1111
module Processing
1212
# For use with "bare" sketches that don't want to define a class or methods
13-
BARE_WRAP = <<~EOS
13+
BARE_WRAP = <<-EOS
1414
class Sketch < Processing::App
1515
%s
1616
end
1717
EOS
1818

19-
NAKED_WRAP = <<~EOS
19+
NAKED_WRAP = <<-EOS
2020
class Sketch < Processing::App
2121
def setup
2222
sketch_title 'Nude Sketch'

lib/jruby_art/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22
# A wrapper for version
33
module JRubyArt
4-
VERSION = '1.2.2'.freeze
4+
VERSION = '1.2.3'.freeze
55
end

vendors/Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ WARNING = <<-EOS
88
99
EOS
1010

11-
JRUBYC_VERSION = '9.1.3.0'
11+
JRUBYC_VERSION = '9.1.4.0'
1212
EXAMPLES = '1.4'
1313
HOME_DIR = ENV['HOME']
1414
MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
@@ -27,7 +27,7 @@ file "jruby-complete-#{JRUBYC_VERSION}.jar" do
2727
rescue
2828
warn(WARNING)
2929
end
30-
check_sha256("jruby-complete-#{JRUBYC_VERSION}.jar", "99cae715f87b9829b44a5a7295f200fc7295114f0887b160a3cf613bf93544a0")
30+
check_sha256("jruby-complete-#{JRUBYC_VERSION}.jar", "a042931f5088dca7007985d6a2178af31cbc26aadb64ee10c3fa25f432c68505")
3131
end
3232

3333
directory "../lib/ruby"

0 commit comments

Comments
 (0)