Class: Sh::Global
Constant Summary collapse
- SUPPORTED_EXTENSIONS =
['.mp3', '.m4a', '.ogg', '.flac', '.wma', '.wav']
- GLADE =
{}
Class Method Summary collapse
- .init ⇒ Object
- .load_plugins ⇒ Object
- .load_prefs ⇒ Object
- .locate(file) ⇒ Object
- .prefs ⇒ Object
- .save_prefs ⇒ Object
Class Method Details
.init ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sh_global.rb', line 17 def self.init # Won't work on Windows $home = ENV['HOME'] $config_dir = "#{$home}/.shroom" FileUtils.mkdir $config_dir unless File.exists? $config_dir $cover_dir = "#{$config_dir}/covers" FileUtils.mkdir $cover_dir unless File.exists? $cover_dir @@prefs_file = "#{$config_dir}/preferences.yml" @@prefs = { :library_dir => "#{$home}/Music", :cover_art => true, :lyrics => true, :lastfm => false, :lastfm_user => nil, :lastfm_password => nil, } add_toplevel_glade('dlg_preferences') add_toplevel_glade('dlg_song') add_toplevel_glade('dlg_plugins') GLADE.freeze load_prefs load_plugins end |
.load_plugins ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/sh_global.rb', line 67 def self.load_plugins plugin_dirs = ["#{self.locate("plugins")}", "#{$config_dir}/.plugins"] plugin_dirs.each do |dir| Dir["#{dir}/*.rb"].each do |rb_file| begin require rb_file rescue Exception puts "Error loading plugin: #{rb_file}" puts $! end end end end |
.load_prefs ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/sh_global.rb', line 52 def self.load_prefs if File.exists?(@@prefs_file) prefs = YAML::load(File.read(@@prefs_file)) prefs.each do |k, v| @@prefs[k] = v end end end |
.locate(file) ⇒ Object
44 45 46 |
# File 'lib/sh_global.rb', line 44 def self.locate(file) find_in_load_path("shroom-res/#{file}") || "shroom-res/#{file}" end |
.prefs ⇒ Object
48 49 50 |
# File 'lib/sh_global.rb', line 48 def self.prefs return @@prefs end |