Class: Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby_art/installer.rb

Overview

Abstract Installer class

Direct Known Subclasses

Check, JRubyCompleteInstall, UnpackSamples

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, os) ⇒ Installer

Returns a new instance of Installer.



9
10
11
12
13
14
15
16
# File 'lib/jruby_art/installer.rb', line 9

def initialize(root, os)
  @os = os
  @gem_root = root
  @sketch = "#{HOME}/sketchbook" if os == :linux
  @sketch = "#{HOME}/My Documents/Processing" if os == :windows
  @sketch = "#{HOME}/Documents/Processing" if os == :mac
  @confd = "#{HOME}/.jruby_art"
end

Instance Attribute Details

#confdObject (readonly)

Returns the value of attribute confd.



8
9
10
# File 'lib/jruby_art/installer.rb', line 8

def confd
  @confd
end

#gem_rootObject (readonly)

Returns the value of attribute gem_root.



8
9
10
# File 'lib/jruby_art/installer.rb', line 8

def gem_root
  @gem_root
end

#osObject (readonly)

Returns the value of attribute os.



8
9
10
# File 'lib/jruby_art/installer.rb', line 8

def os
  @os
end

#sketchObject (readonly)

Returns the value of attribute sketch.



8
9
10
# File 'lib/jruby_art/installer.rb', line 8

def sketch
  @sketch
end

Instance Method Details

#configObject



44
45
46
47
48
# File 'lib/jruby_art/installer.rb', line 44

def config
  k9config = File.join(confd, 'config.yml')
  return '' unless File.exist? k9config
  YAML.load_file(k9config)
end

#installObject

in place of default installer class



51
52
53
# File 'lib/jruby_art/installer.rb', line 51

def install
  puts 'Usage: k9 [--check | --install | --help]'
end

#root_exist?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/jruby_art/installer.rb', line 40

def root_exist?
  Core.check?(config['PROCESSING_ROOT'])
end

#set_processing_rootObject

Optimistically set processing root



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/jruby_art/installer.rb', line 19

def set_processing_root
  folder = "#{HOME}/.jruby_art"
  Dir.mkdir(folder) unless File.exist? folder
  path = File.join(folder, 'config.yml')
  proot = "#{HOME}/processing-#{VERSION}"
  proot = "/usr/local/lib/processing-#{VERSION}" if os == :arm
  proot = "/Java/Processing-#{VERSION}" if os == :windows
  proot = '/Applications/Processing.app/Contents/Java' if os == :mac
  jruby = true
  jruby = false if os == :arm
  settings = %w[
    PROCESSING_ROOT JRUBY sketchbook_path template MAX_WATCH sketch_title width height
  ]
  values = [
    proot, true, sketch, 'bare', 32, 'JRubyArt Static Sketch', 600, 600
  ]
  data = settings.zip(values).to_h
  open(path, 'w:UTF-8') { |file| file.write(data.to_yaml) }
  warn 'PROCESSING_ROOT set optimistically, run check to confirm'
end

#show_versionObject

Display the current version of JRubyArt.



56
57
58
59
# File 'lib/jruby_art/installer.rb', line 56

def show_version
  puts format('JRubyArt version %s', JRubyArt::VERSION)
  puts format('Expected Processing version %s', VERSION)
end