5
5
6
6
# Abstract Installer class
7
7
class Installer
8
- attr_reader :os , :sketch , :gem_root , :home
8
+ attr_reader :os , :sketch , :gem_root , :confd
9
9
def initialize ( root , os )
10
10
@os = os
11
11
@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"
16
16
end
17
17
18
18
# Optimistically set processing root
19
19
def set_processing_root
20
- require 'psych'
21
- folder = File . expand_path ( "#{ home } /.jruby_art" )
20
+ folder = "#{ ENV [ 'HOME' ] } /.jruby_art"
22
21
Dir . mkdir ( folder ) unless File . exist? folder
23
22
path = File . join ( folder , 'config.yml' )
24
- proot = "#{ home } /processing-#{ VERSION } "
23
+ proot = "#{ ENV [ 'HOME' ] } /processing-#{ VERSION } "
25
24
proot = "/Java/Processing-#{ VERSION } " if os == :windows
26
25
proot = "/Applications/Processing.app/Contents/Java" if os == :mac
27
26
settings = %w( PROCESSING_ROOT JRUBY sketchbook_path template MAX_WATCH sketch_title width height )
28
27
values = [ proot , true , sketch , 'bare' , 32 , 'JRubyArt Static Sketch' , 600 , 600 ]
29
28
data = settings . zip ( values ) . to_h
30
29
open ( path , 'w:UTF-8' ) { |file | file . write ( data . to_yaml ) }
30
+ warn 'PROCESSING_ROOT set optimistically, run check to confirm'
31
31
end
32
32
33
33
def root_exist?
34
34
Core . check? ( config [ 'PROCESSING_ROOT' ] )
35
35
end
36
36
37
37
def config
38
- k9config = File . expand_path ( " #{ home } /.jruby_art/ config.yml" )
38
+ k9config = File . join ( confd , ' config.yml' )
39
39
return '' unless File . exist? k9config
40
40
YAML . load_file ( k9config )
41
41
end
@@ -54,7 +54,7 @@ def show_version
54
54
55
55
# Configuration checker
56
56
class Check < Installer
57
- require_relative 'core'
57
+ require_relative './ core'
58
58
def install
59
59
show_version
60
60
return super unless config
@@ -86,9 +86,7 @@ def install
86
86
# JRuby-Complete installer
87
87
class JRubyCompleteInstall < Installer
88
88
def install
89
+ set_processing_root unless File . exist? File . join ( confd , 'config.yml' )
89
90
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'
93
91
end
94
92
end
0 commit comments