Skip to content

Commit f5c5bee

Browse files
committed
fix config install
1 parent c4287a2 commit f5c5bee

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

lib/jruby_art/installer.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@
55

66
# Abstract Installer class
77
class Installer
8-
attr_reader :os, :sketch, :gem_root, :home
8+
attr_reader :os, :sketch, :gem_root, :confd
99
def initialize(root, os)
1010
@os = os
1111
@gem_root = root
12-
@home = ENV['HOME']
13-
@sketch = "#{home}/sketchbook" if os == :linux
14-
@sketch = "#{home}/My Documents/Processing" if os == :windows
15-
@sketch = "#{home}/Documents/Processing" if os == :mac
12+
@sketch = "#{ENV['HOME']}/sketchbook" if os == :linux
13+
@sketch = "#{ENV['HOME']}/My Documents/Processing" if os == :windows
14+
@sketch = "#{ENV['HOME']}/Documents/Processing" if os == :mac
15+
@confd = "#{ENV['HOME']}/.jruby_art"
1616
end
1717

1818
# Optimistically set processing root
1919
def set_processing_root
20-
require 'psych'
21-
folder = File.expand_path("#{home}/.jruby_art")
20+
folder = "#{ENV['HOME']}/.jruby_art"
2221
Dir.mkdir(folder) unless File.exist? folder
2322
path = File.join(folder, 'config.yml')
24-
proot = "#{home}/processing-#{VERSION}"
23+
proot = "#{ENV['HOME']}/processing-#{VERSION}"
2524
proot = "/Java/Processing-#{VERSION}" if os == :windows
2625
proot = "/Applications/Processing.app/Contents/Java" if os == :mac
2726
settings = %w(PROCESSING_ROOT JRUBY sketchbook_path template MAX_WATCH sketch_title width height)
2827
values = [proot, true, sketch, 'bare', 32, 'JRubyArt Static Sketch', 600, 600]
2928
data = settings.zip(values).to_h
3029
open(path, 'w:UTF-8') { |file| file.write(data.to_yaml) }
30+
warn 'PROCESSING_ROOT set optimistically, run check to confirm'
3131
end
3232

3333
def root_exist?
3434
Core.check?(config['PROCESSING_ROOT'])
3535
end
3636

3737
def config
38-
k9config = File.expand_path("#{home}/.jruby_art/config.yml")
38+
k9config = File.join(confd, 'config.yml')
3939
return '' unless File.exist? k9config
4040
YAML.load_file(k9config)
4141
end
@@ -54,7 +54,7 @@ def show_version
5454

5555
# Configuration checker
5656
class Check < Installer
57-
require_relative 'core'
57+
require_relative './core'
5858
def install
5959
show_version
6060
return super unless config
@@ -86,9 +86,7 @@ def install
8686
# JRuby-Complete installer
8787
class JRubyCompleteInstall < Installer
8888
def install
89+
set_processing_root unless File.exist? File.join(confd, 'config.yml')
8990
system "cd #{gem_root}/vendors && rake"
90-
return if root_exist?
91-
set_processing_root
92-
warn 'PROCESSING_ROOT set optimistically, run check to confirm'
9391
end
9492
end

0 commit comments

Comments
 (0)