Class: Dotsync::Runner
- Inherits:
-
Object
- Object
- Dotsync::Runner
- Defined in:
- lib/dotsync/runner.rb
Instance Method Summary collapse
-
#initialize(logger: nil, config_path: nil) ⇒ Runner
constructor
A new instance of Runner.
-
#run(action_name, options = {}) ⇒ Object
action_name should be a symbol, e.g., :pull, :watch, :sync.
Constructor Details
Instance Method Details
#run(action_name, options = {}) ⇒ Object
action_name should be a symbol, e.g., :pull, :watch, :sync
11 12 13 14 15 16 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 |
# File 'lib/dotsync/runner.rb', line 11 def run(action_name, = {}) case action_name when :setup setup_config else begin action_class = Dotsync.const_get("#{camelize(action_name.to_s)}Action") config_class = Dotsync.const_get("#{camelize(action_name.to_s)}ActionConfig") config = config_class.new(Dotsync.config_path) Dotsync::Icons.load_custom_icons(config.to_h) Dotsync::Colors.load_custom_colors(config.to_h) action = action_class.new(config, @logger) action.execute() rescue ConfigError => e @logger.error("[#{action_name}] config error:") @logger.info(e.) rescue NameError => e @logger.error("Unknown action '#{action_name}':") @logger.info(e.) rescue => e @logger.error("Error running '#{action_name}':") @logger.info(e.) raise ensure check_for_updates end end end |