Skip to content

Commit 3c448da

Browse files
committed
tidy up
1 parent ec40a45 commit 3c448da

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed

lib/jruby_art/installer.rb

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: false
12
require 'yaml'
23

34
VERSION = '3.1.1' # processing version
@@ -8,51 +9,51 @@ def initialize(os: :linux, jruby: true, root:)
89
@os = os
910
@jruby = jruby
1011
@gem_root = root
11-
@sketch = "#{ENV['HOME']}/sketchbook" if os == :linux
12+
@sketch = "#{ENV['HOME']}/sketchbook" if os == :linux
1213
@sketch = "#{ENV['HOME']}/My Documents/Processing" if os == :windows
1314
@sketch = "#{ENV['HOME']}/Documents/Processing" if os == :mac
1415
end
15-
16+
1617
def install
1718
system "cd #{gem_root}/vendors && rake"
1819
return if root_exist?
1920
set_processing_root
2021
warn 'PROCESSING_ROOT set optimistically, run check to confirm'
2122
end
22-
23+
2324
def install_examples
2425
system "cd #{gem_root}/vendors && rake unpack_samples"
2526
end
26-
27+
2728
# Optimistically set processing root
2829
def set_processing_root
2930
require 'psych'
3031
folder = File.expand_path("#{ENV['HOME']}/.jruby_art")
31-
Dir.mkdir(folder) unless File.exists? folder
32+
Dir.mkdir(folder) unless File.exist? folder
3233
path = File.join(folder, 'config.yml')
3334
proot = "#{ENV['HOME']}/processing-#{VERSION}"
3435
proot = "/Java/Processing-#{VERSION}" if os == :windows
3536
proot = "/Applications/Processing.app/Contents/Java" if os == :mac
36-
data = {
37-
'PROCESSING_ROOT' => proot,
38-
'JRUBY' => "#{jruby}",
37+
data = {
38+
'PROCESSING_ROOT' => proot,
39+
'JRUBY' => jruby.to_s,
3940
'sketchbook_path' => sketch,
4041
'MAX_WATCH' => '20'
4142
}
4243
open(path, 'w:UTF-8') { |f| f.write(data.to_yaml) }
4344
end
44-
45-
def root_exist?
45+
46+
def root_exist?
4647
return false if config.nil?
47-
return File.exists? config['PROCESSING_ROOT']
48+
File.exist? config['PROCESSING_ROOT']
4849
end
49-
50+
5051
def config
5152
k9config = File.expand_path("#{ENV['HOME']}/.jruby_art/config.yml")
52-
return nil unless File.exists? k9config
53+
return nil unless File.exist? k9config
5354
YAML.load_file(k9config)
5455
end
55-
56+
5657
def check
5758
show_version
5859
installed = File.exist? File.join(gem_root, 'lib/ruby/jruby-complete.jar')
@@ -66,10 +67,10 @@ def check
6667
puts " jruby-complete installed = #{installed}"
6768
puts sketchbook
6869
puts max_watch
69-
end
70-
71-
# Display the current version of JRubyArt.
72-
def show_version
73-
puts format('JRubyArt version %s', JRubyArt::VERSION)
74-
end
70+
end
71+
72+
# Display the current version of JRubyArt.
73+
def show_version
74+
puts format('JRubyArt version %s', JRubyArt::VERSION)
75+
end
7576
end

lib/jruby_art/runner.rb

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# encoding: utf-8
21
# frozen_string_literal: false
32

43
require 'ostruct'
@@ -121,7 +120,6 @@ def watch(sketch, args)
121120
end
122121

123122
def setup(choice)
124-
# proc_root = FileTest.exist?("#{ENV['HOME']}/.jruby_art/config.yml")
125123
installer = Installer.new(root: K9_ROOT, os: host_os, jruby: true)
126124
case choice
127125
when /check/
@@ -133,7 +131,7 @@ def setup(choice)
133131
else
134132
puts 'Usage: k9 setup [check | install | unpack_samples]'
135133
end
136-
end
134+
end
137135

138136
# Show the standard help/usage message.
139137
def show_help
@@ -222,21 +220,5 @@ def host_os
222220
:windows
223221
end
224222
end
225-
226-
# Optimistically set processing root
227-
def set_processing_root
228-
require 'psych'
229-
@os ||= host_os
230-
data = {}
231-
path = File.expand_path("#{ENV['HOME']}/.jruby_art/config.yml")
232-
if os == :mac
233-
data['PROCESSING_ROOT'] = '/Applications/Processing.app/Contents/Java'
234-
else
235-
root = "#{ENV['HOME']}/processing-3.1.1"
236-
data['PROCESSING_ROOT'] = root
237-
end
238-
data['JRUBY'] = 'true'
239-
open(path, 'w:UTF-8') { |f| f.write(data.to_yaml) }
240-
end
241223
end # class Runner
242224
end # module Processing

0 commit comments

Comments
 (0)