Class: Installer
- Inherits:
-
Object
- Object
- Installer
- Defined in:
- lib/jruby_art/installer.rb
Overview
Abstract Installer class
Direct Known Subclasses
Instance Attribute Summary collapse
-
#gem_root ⇒ Object
readonly
Returns the value of attribute gem_root.
-
#home ⇒ Object
readonly
Returns the value of attribute home.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#sketch ⇒ Object
readonly
Returns the value of attribute sketch.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(root, os) ⇒ Installer
constructor
A new instance of Installer.
-
#install ⇒ Object
in place of default installer class.
- #root_exist? ⇒ Boolean
-
#set_processing_root ⇒ Object
Optimistically set processing root.
-
#show_version ⇒ Object
Display the current version of JRubyArt.
Constructor Details
#initialize(root, os) ⇒ 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 @home = ENV['HOME'] @sketch = "#{home}/sketchbook" if os == :linux @sketch = "#{home}/My Documents/Processing" if os == :windows @sketch = "#{home}/Documents/Processing" if os == :mac end |
Instance Attribute Details
#gem_root ⇒ Object (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 |
#home ⇒ Object (readonly)
Returns the value of attribute home.
8 9 10 |
# File 'lib/jruby_art/installer.rb', line 8 def home @home end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
8 9 10 |
# File 'lib/jruby_art/installer.rb', line 8 def os @os end |
#sketch ⇒ Object (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
#config ⇒ Object
38 39 40 41 42 |
# File 'lib/jruby_art/installer.rb', line 38 def config k9config = File.("#{home}/.jruby_art/config.yml") return nil unless File.exist? k9config YAML.load_file(k9config) end |
#install ⇒ Object
in place of default installer class
45 46 47 |
# File 'lib/jruby_art/installer.rb', line 45 def install puts 'Usage: k9 setup [check | install | unpack_samples]' end |
#root_exist? ⇒ Boolean
33 34 35 36 |
# File 'lib/jruby_art/installer.rb', line 33 def root_exist? return false if config.nil? File.exist? config['PROCESSING_ROOT'] end |
#set_processing_root ⇒ Object
Optimistically set processing root
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jruby_art/installer.rb', line 19 def set_processing_root require 'psych' folder = File.("#{home}/.jruby_art") Dir.mkdir(folder) unless File.exist? folder path = File.join(folder, 'config.yml') proot = "#{home}/processing-#{VERSION}" proot = "/Java/Processing-#{VERSION}" if os == :windows proot = "/Applications/Processing.app/Contents/Java" if os == :mac settings = %w(PROCESSING_ROOT JRUBY sketchbook_path template MAX_WATCH) values = [proot, true, sketch, 'bare', 32] data = settings.zip(values).to_h open(path, 'w:UTF-8') { |file| file.write(data.to_yaml) } end |
#show_version ⇒ Object
Display the current version of JRubyArt.
50 51 52 53 |
# File 'lib/jruby_art/installer.rb', line 50 def show_version puts format('JRubyArt version %s', JRubyArt::VERSION) puts format('Expected Processing version %s', VERSION) end |