Class: Blacksmith::Config
- Inherits:
-
Object
- Object
- Blacksmith::Config
- Defined in:
- lib/blacksmith/config.rb
Class Attribute Summary collapse
-
.api_token ⇒ Object
Returns the value of attribute api_token.
-
.patterns ⇒ Object
Returns the value of attribute patterns.
-
.room ⇒ Object
Returns the value of attribute room.
-
.server_url ⇒ Object
Returns the value of attribute server_url.
-
.title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .connection ⇒ Object
- .draw(&block) ⇒ Object
- .establish_connection! ⇒ Object
- .map(pattern = nil, options = {}) ⇒ Object
Class Attribute Details
.api_token ⇒ Object
Returns the value of attribute api_token.
5 6 7 |
# File 'lib/blacksmith/config.rb', line 5 def api_token @api_token end |
.patterns ⇒ Object
Returns the value of attribute patterns.
5 6 7 |
# File 'lib/blacksmith/config.rb', line 5 def patterns @patterns end |
.room ⇒ Object
Returns the value of attribute room.
5 6 7 |
# File 'lib/blacksmith/config.rb', line 5 def room @room end |
.server_url ⇒ Object
Returns the value of attribute server_url.
5 6 7 |
# File 'lib/blacksmith/config.rb', line 5 def server_url @server_url end |
.title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/blacksmith/config.rb', line 5 def title @title end |
Class Method Details
.connection ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/blacksmith/config.rb', line 7 def connection return @client if @client ["room", "api_token"].each do |attr| if eval(attr).nil? raise ConfigError, "Missing configuration: #{attr}. Check README to setup." end end @client = if server_url HipChat::Client.new(api_token, server_url: server_url) else HipChat::Client.new(api_token) end end |
.draw(&block) ⇒ Object
27 28 29 |
# File 'lib/blacksmith/config.rb', line 27 def draw(&block) class_eval(&block) end |
.establish_connection! ⇒ Object
23 24 25 |
# File 'lib/blacksmith/config.rb', line 23 def establish_connection! connection end |
.map(pattern = nil, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/blacksmith/config.rb', line 31 def map(pattern = nil, = {}) self.patterns ||= {} raise MappingError, "Pattern can only be a Regexp" unless pattern.is_a? Regexp raise MappingError, "Pattern cannot be blank" if pattern == // raise MappingError, "Missing target in mapping. Use: to: 'image_url'" if .is_a?(Hash).! || [:to].nil? self.patterns[pattern] = [:to] end |