Class: AutoResp::AutoResponder
- Inherits:
-
Object
- Object
- AutoResp::AutoResponder
- Defined in:
- lib/auto_response.rb
Constant Summary collapse
- ARHOME =
"#{ENV["HOME"]}/.auto_response"
- RULES =
"#{ARHOME}/rules"
Instance Method Summary collapse
- #add_rule(*args, &block) ⇒ Object
- #clear_rules ⇒ Object
-
#initialize(config = {}) ⇒ AutoResponder
constructor
A new instance of AutoResponder.
- #rules ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #stop_and_exit ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ AutoResponder
Returns a new instance of AutoResponder.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/auto_response.rb', line 23 def initialize(config = {}) @config = config @rule_manager = RuleManager.new @logger = init_logger @logger.debug { "Starting AutoResp v#{VERSION}" } @logger.debug { "Listening at " << "#{ip_address}:#{proxy_port}".yellow } init_autoresponse_home load_rules monitor_rules_change end |
Instance Method Details
#add_rule(*args, &block) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/auto_response.rb', line 109 def add_rule(*args, &block) case args.first when Hash rules.merge! args.first when String rules[args[0]] = args[1] when Regexp if block_given? rules[args[0]] = block else rules[args[0]] = args[1] end end end |
#clear_rules ⇒ Object
128 129 130 |
# File 'lib/auto_response.rb', line 128 def clear_rules rules.clear end |
#rules ⇒ Object
124 125 126 |
# File 'lib/auto_response.rb', line 124 def rules @rule_manager.rules end |
#start ⇒ Object
92 93 94 95 96 |
# File 'lib/auto_response.rb', line 92 def start log_rules start_proxy start_viewer end |
#stop ⇒ Object
103 104 105 106 107 |
# File 'lib/auto_response.rb', line 103 def stop @server.shutdown @viewer_thread.kill @proxy_thread.kill end |
#stop_and_exit ⇒ Object
98 99 100 101 |
# File 'lib/auto_response.rb', line 98 def stop_and_exit stop exit end |