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
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 @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
37 38 39 40 41 |
# File 'lib/jruby_art/installer.rb', line 37 def config k9config = File.("#{home}/.jruby_art/config.yml") return '' unless File.exist? k9config YAML.load_file(k9config) end |
#install ⇒ Object
in place of default installer class
44 45 46 |
# File 'lib/jruby_art/installer.rb', line 44 def install puts 'Usage: k9 [--check | --install | --help]' end |
#root_exist? ⇒ Boolean
33 34 35 |
# File 'lib/jruby_art/installer.rb', line 33 def root_exist? Core.check?(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 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) } end |