lib/callisto/configuration.rb in callisto-0.9 vs lib/callisto/configuration.rb in callisto-0.9.1

- old
+ new

@@ -1,5 +1,7 @@ +require "delegate" + module Callisto class Configuration module Defaults @@ -8,35 +10,46 @@ :identifier => proc { |task| task.command }, :callback => proc { |task| task.run }, :max_workers => 4 } + THUMBNAIL = { + :quality => 90 + } + + SHELL = {} + end attr_accessor :thumbnail_defaults def initialize - self.thumbnail_defaults = {} - load_defaults + reset end - def load_defaults - Pool.settings = Defaults::POOL + def reset + self.thumbnail_defaults = Defaults::THUMBNAIL.clone + Pool.settings = Defaults::POOL.clone + Shell.bin_path = Defaults::SHELL.clone[:bin_path] end def max_workers=(val) Pool.settings.max_workers = val end + def bin_path=(val) + Shell.bin_path = val + end + def method_missing(method, *args, &block) if /^thumbnail_(?<name>[a-z\_]+)(?<setter>=)?/ =~ method if setter - self.thumbnail_defaults[name] = args.first + self.thumbnail_defaults[name.to_sym] = args.first else - thumbnail_defaults[name] + thumbnail_defaults[name.to_sym] end else - super + super(method, *args, &block) end end end