lib/ayadn/set.rb in ayadn-1.7.1 vs lib/ayadn/set.rb in ayadn-1.7.2

- old
+ new

@@ -4,12 +4,11 @@ desc "scroll ITEM VALUE", "Set the waiting time (in seconds, min 0.7) between two requests when scrolling" def scroll(*args) scroll_config = SetScroll.new if args[0] - param = scroll_config.validate(args[1]) - scroll_config.send(args[0], param) + scroll_config.send(args[0], args[1]) else abort(Status.error_missing_parameters) end scroll_config.log(args) scroll_config.save @@ -58,12 +57,11 @@ long_desc Descriptions.set_timeline def timeline(*args) timeline_config = SetTimeline.new if args[0] begin - param = timeline_config.validate(args[1]) - timeline_config.send(args[0], param) + timeline_config.send(args[0], args[1]) rescue NoMethodError, ArgumentError puts Status.error_missing_parameters exit rescue => e raise e @@ -80,12 +78,11 @@ map "counts" => :count def count(*args) counts_config = SetCounts.new if args[0] begin - param = counts_config.validate(args[1]) - counts_config.send(args[0], param) + counts_config.send(args[0], args[1]) rescue NoMethodError, ArgumentError puts Status.error_missing_parameters exit rescue => e raise e @@ -104,11 +101,10 @@ map "colours" => :color def color(*args) color_config = SetColor.new if args[0] begin - color_config.validate(args[1]) color_config.send(args[0], args[1]) rescue NoMethodError, ArgumentError puts Status.error_missing_parameters exit rescue => e @@ -125,12 +121,11 @@ long_desc Descriptions.set_backup def backup(*args) backup_config = SetBackup.new if args[0] begin - param = backup_config.validate(args[1]) - backup_config.send(args[0], param) + backup_config.send(args[0], args[1]) rescue NoMethodError, ArgumentError puts Status.error_missing_parameters exit rescue => e raise e @@ -188,13 +183,15 @@ t = t.to_i t >= 1 ? t : 3 end def self.color(color) colors_list = %w{red green magenta cyan yellow blue white black} - unless colors_list.include?(color) + unless colors_list.include?(color.to_s) puts Status.error_missing_parameters abort(Status.valid_colors(colors_list)) + else + return color end end end class SetScroll @@ -214,11 +211,11 @@ end def validate(t) Validators.timer(t) end def timer(t) - Settings.options[:scroll][:timer] = t + Settings.options[:scroll][:timer] = validate(t) end end class SetMovie def initialize @@ -308,11 +305,11 @@ Validators.boolean(value) end def method_missing(meth, options) case meth.to_s when 'auto_save_sent_posts', 'auto_save_sent_messages', 'auto_save_lists' - Settings.options[:backup][meth.to_sym] = options + Settings.options[:backup][meth.to_sym] = validate(options) else super end end end @@ -336,11 +333,11 @@ Validators.index_range(1, 200, value) end def method_missing(meth, options) case meth.to_s when 'default', 'unified', 'checkins', 'conversations', 'global', 'photos', 'trending', 'mentions', 'convo', 'posts', 'messages', 'search', 'whoreposted', 'whostarred', 'whatstarred', 'files' - Settings.options[:counts][meth.to_sym] = options.to_i + Settings.options[:counts][meth.to_sym] = validate(options.to_i) else super end end end @@ -364,11 +361,11 @@ Settings.save_config end def method_missing(meth, options) case meth.to_s when 'directed', 'html', 'show_source', 'show_symbols', 'show_real_name', 'show_date', 'show_spinner', 'show_debug' - Settings.options[:timeline][meth.to_sym] = options + Settings.options[:timeline][meth.to_sym] = validate(options) when 'deleted', 'annotations' abort(Status.not_mutable) else super end @@ -398,14 +395,14 @@ end def method_missing(meth, options) case meth.to_s when 'id', 'index', 'username', 'name', 'date', 'link', 'dots', 'hashtags', 'mentions', 'source', 'symbols', 'debug' - Settings.options[:colors][meth.to_sym] = options.to_sym + Settings.options[:colors][meth.to_sym] = validate(options.to_sym) when 'hashtag', 'mention', 'symbol' - Settings.options[:colors]["#{meth}s".to_sym] = options.to_sym + Settings.options[:colors]["#{meth}s".to_sym] = validate(options.to_sym) when 'client' - Settings.options[:colors][:source] = options.to_sym + Settings.options[:colors][:source] = validate(options.to_sym) else super end end end