1
+ # frozen_string_literal: false
1
2
require 'yaml'
2
3
3
4
VERSION = '3.1.1' # processing version
@@ -8,51 +9,51 @@ def initialize(os: :linux, jruby: true, root:)
8
9
@os = os
9
10
@jruby = jruby
10
11
@gem_root = root
11
- @sketch = "#{ ENV [ 'HOME' ] } /sketchbook" if os == :linux
12
+ @sketch = "#{ ENV [ 'HOME' ] } /sketchbook" if os == :linux
12
13
@sketch = "#{ ENV [ 'HOME' ] } /My Documents/Processing" if os == :windows
13
14
@sketch = "#{ ENV [ 'HOME' ] } /Documents/Processing" if os == :mac
14
15
end
15
-
16
+
16
17
def install
17
18
system "cd #{ gem_root } /vendors && rake"
18
19
return if root_exist?
19
20
set_processing_root
20
21
warn 'PROCESSING_ROOT set optimistically, run check to confirm'
21
22
end
22
-
23
+
23
24
def install_examples
24
25
system "cd #{ gem_root } /vendors && rake unpack_samples"
25
26
end
26
-
27
+
27
28
# Optimistically set processing root
28
29
def set_processing_root
29
30
require 'psych'
30
31
folder = File . expand_path ( "#{ ENV [ 'HOME' ] } /.jruby_art" )
31
- Dir . mkdir ( folder ) unless File . exists ? folder
32
+ Dir . mkdir ( folder ) unless File . exist ? folder
32
33
path = File . join ( folder , 'config.yml' )
33
34
proot = "#{ ENV [ 'HOME' ] } /processing-#{ VERSION } "
34
35
proot = "/Java/Processing-#{ VERSION } " if os == :windows
35
36
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 ,
39
40
'sketchbook_path' => sketch ,
40
41
'MAX_WATCH' => '20'
41
42
}
42
43
open ( path , 'w:UTF-8' ) { |f | f . write ( data . to_yaml ) }
43
44
end
44
-
45
- def root_exist?
45
+
46
+ def root_exist?
46
47
return false if config . nil?
47
- return File . exists ? config [ 'PROCESSING_ROOT' ]
48
+ File . exist ? config [ 'PROCESSING_ROOT' ]
48
49
end
49
-
50
+
50
51
def config
51
52
k9config = File . expand_path ( "#{ ENV [ 'HOME' ] } /.jruby_art/config.yml" )
52
- return nil unless File . exists ? k9config
53
+ return nil unless File . exist ? k9config
53
54
YAML . load_file ( k9config )
54
55
end
55
-
56
+
56
57
def check
57
58
show_version
58
59
installed = File . exist? File . join ( gem_root , 'lib/ruby/jruby-complete.jar' )
@@ -66,10 +67,10 @@ def check
66
67
puts " jruby-complete installed = #{ installed } "
67
68
puts sketchbook
68
69
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
75
76
end
0 commit comments