Module: Sketchbook
- Defined in:
- lib/jruby_art/sketchbook.rb
Overview
Utility to find sketchbook and hence java libraries
Class Method Summary collapse
Class Method Details
.find_path ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jruby_art/sketchbook.rb', line 4 def self.find_path preferences_paths = [] sketchbook_paths = [] sketchbook_path = Processing::RP_CONFIG.fetch('sketchbook_path', false) return sketchbook_path if sketchbook_path [ "'Application Data/Processing'", 'AppData/Roaming/Processing', 'Library/Processing', 'Documents/Processing', '.processing', 'sketchbook' ].each do |prefix| spath = format('%s/%s', ENV['HOME'], prefix) pref_path = format('%s/preferences.txt', spath) preferences_paths << pref_path if FileTest.file?(pref_path) sketchbook_paths << spath if FileTest.directory?(spath) end return sketchbook_paths.first if preferences_paths.empty? lines = IO.readlines(preferences_paths.first) matchedline = lines.grep(/^sketchbook/).first matchedline[/=(.+)/].delete('=') end |