3
3
4
4
VERSION = '3.1.1' # processing version
5
5
6
+ # Abstract Installer class
6
7
class Installer
7
8
attr_reader :os , :sketch , :gem_root , :home
8
- def initialize ( os : :linux , root : )
9
+ def initialize ( root , os )
9
10
@os = os
10
11
@gem_root = root
11
12
@home = ENV [ 'HOME' ]
12
13
@sketch = "#{ home } /sketchbook" if os == :linux
13
14
@sketch = "#{ home } /My Documents/Processing" if os == :windows
14
15
@sketch = "#{ home } /Documents/Processing" if os == :mac
15
16
end
16
-
17
- def install
18
- system "cd #{ gem_root } /vendors && rake"
19
- return if root_exist?
20
- set_processing_root
21
- warn 'PROCESSING_ROOT set optimistically, run check to confirm'
22
- end
23
-
24
- def install_examples
25
- system "cd #{ gem_root } /vendors && rake unpack_samples"
26
- end
27
-
17
+
28
18
# Optimistically set processing root
29
19
def set_processing_root
30
20
require 'psych'
@@ -40,22 +30,36 @@ def set_processing_root
40
30
'sketchbook_path' => sketch ,
41
31
'MAX_WATCH' => '20'
42
32
}
43
- open ( path , 'w:UTF-8' ) { |f | f . write ( data . to_yaml ) }
33
+ open ( path , 'w:UTF-8' ) { |file | file . write ( data . to_yaml ) }
44
34
end
45
-
35
+
46
36
def root_exist?
47
37
return false if config . nil?
48
38
File . exist? config [ 'PROCESSING_ROOT' ]
49
39
end
50
-
40
+
51
41
def config
52
42
k9config = File . expand_path ( "#{ home } /.jruby_art/config.yml" )
53
43
return nil unless File . exist? k9config
54
44
YAML . load_file ( k9config )
55
45
end
46
+
47
+ # in place of default installer class
48
+ def install
49
+ puts 'Usage: k9 setup [check | install | unpack_samples]'
50
+ end
51
+
52
+ # Display the current version of JRubyArt.
53
+ def show_version
54
+ puts format ( 'JRubyArt version %s' , JRubyArt ::VERSION )
55
+ end
56
+ end
56
57
57
- def check
58
+ # Configuration checker
59
+ class Check < Installer
60
+ def install
58
61
show_version
62
+ return super unless config
59
63
installed = File . exist? File . join ( gem_root , 'lib/ruby/jruby-complete.jar' )
60
64
proot = ' PROCESSING_ROOT = Not Set!!!' unless root_exist?
61
65
proot ||= " PROCESSING_ROOT = #{ config [ 'PROCESSING_ROOT' ] } "
@@ -68,9 +72,21 @@ def check
68
72
puts sketchbook
69
73
puts max_watch
70
74
end
75
+ end
71
76
72
- # Display the current version of JRubyArt.
73
- def show_version
74
- puts format ( 'JRubyArt version %s' , JRubyArt ::VERSION )
77
+ # Examples Installer
78
+ class UnpackSamples < Installer
79
+ def install
80
+ system "cd #{ gem_root } /vendors && rake unpack_samples"
81
+ end
82
+ end
83
+
84
+ # JRuby-Complete installer
85
+ class JRubyComplete < Installer
86
+ def install
87
+ system "cd #{ gem_root } /vendors && rake"
88
+ return if root_exist?
89
+ set_processing_root
90
+ warn 'PROCESSING_ROOT set optimistically, run check to confirm'
75
91
end
76
92
end
0 commit comments