Class: Blacksmith::Config
- Inherits:
-
Object
- Object
- Blacksmith::Config
- Defined in:
- lib/blacksmith/config.rb
Constant Summary collapse
- SERVER_URL =
ENV["HIPCHAT_SERVER_URL"]
- API_TOKEN =
ENV["HIPCHAT_API_TOKEN"]
Class Method Summary collapse
- .connection ⇒ Object
- .draw(&block) ⇒ Object
- .establish_connection! ⇒ Object
- .map(pattern = nil, options = {}) ⇒ Object
- .patterns ⇒ Object
- .room ⇒ Object
- .room=(name) ⇒ Object
- .title ⇒ Object
- .title=(name) ⇒ Object
Class Method Details
.connection ⇒ Object
7 8 9 |
# File 'lib/blacksmith/config.rb', line 7 def connection @client ||= HipChat::Client.new(API_TOKEN, server_url: SERVER_URL) end |
.draw(&block) ⇒ Object
15 16 17 |
# File 'lib/blacksmith/config.rb', line 15 def draw(&block) class_eval(&block) end |
.establish_connection! ⇒ Object
11 12 13 |
# File 'lib/blacksmith/config.rb', line 11 def establish_connection! connection end |
.map(pattern = nil, options = {}) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/blacksmith/config.rb', line 19 def map(pattern = nil, = {}) raise MappingError, "No pattern is given" if pattern.nil? raise MappingError, "Pattern cannot be blank" if pattern == // raise MappingError, "Pattern should be a Regexp" unless pattern.is_a? Regexp raise MappingError, "Missing target in mapping. Use: to: 'target'" if .is_a?(Hash).! || [:to].nil? patterns[pattern] = [:to] end |
.patterns ⇒ Object
27 28 29 |
# File 'lib/blacksmith/config.rb', line 27 def patterns @patterns ||= {} end |
.room ⇒ Object
39 40 41 |
# File 'lib/blacksmith/config.rb', line 39 def room @room ||= "" end |
.room=(name) ⇒ Object
43 44 45 |
# File 'lib/blacksmith/config.rb', line 43 def room=(name) @room = name end |
.title ⇒ Object
31 32 33 |
# File 'lib/blacksmith/config.rb', line 31 def title @title ||= "" end |
.title=(name) ⇒ Object
35 36 37 |
# File 'lib/blacksmith/config.rb', line 35 def title=(name) @title = name end |