Class: WatchmonkeyCli::Application::Configuration
- Inherits:
-
Object
- Object
- WatchmonkeyCli::Application::Configuration
- Defined in:
- lib/watchmonkey_cli/application/configuration.rb
Defined Under Namespace
Modules: AppHelper
Instance Method Summary collapse
-
#initialize(app, file) ⇒ Configuration
constructor
A new instance of Configuration.
- #method_missing(meth, *args, &block) ⇒ Object
- #ssh_connection(name, opts = {}, &b) ⇒ Object
- #tag_all!(*tags) ⇒ Object
Constructor Details
#initialize(app, file) ⇒ Configuration
Returns a new instance of Configuration.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/watchmonkey_cli/application/configuration.rb', line 62 def initialize app, file @app = app @file = file = [] begin eval File.read(file, encoding: "utf-8"), binding, file rescue app.error "Invalid config file #{file}" raise end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/watchmonkey_cli/application/configuration.rb', line 82 def method_missing meth, *args, &block if c = @app.checkers[meth.to_s] opts = args. only = @app.opts[:tag_only] except = @app.opts[:tag_except] = ( + (opts[:tags] || []).map(&:to_sym)).uniq if only.any? if .any?{|t| only.include?(t) } if .any?{|t| except.include?(t) } return @app.debug "Skipping #{meth} with #{args} and #{opts} due to tag_except filter..." end else return @app.debug "Skipping #{meth} with #{args} and #{opts} due to tag_only filter..." end elsif .any?{|t| except.include?(t) } return @app.debug "Skipping #{meth} with #{args} and #{opts} due to tag_except filter..." end c.enqueue(*args, opts.merge(tags: )) else super end end |
Instance Method Details
#ssh_connection(name, opts = {}, &b) ⇒ Object
74 75 76 |
# File 'lib/watchmonkey_cli/application/configuration.rb', line 74 def ssh_connection name, opts = {}, &b @app.fetch_connection(:ssh, name, opts, &b) end |
#tag_all!(*tags) ⇒ Object
78 79 80 |
# File 'lib/watchmonkey_cli/application/configuration.rb', line 78 def tag_all! * = .map(&:to_sym) end |