Class: Blacksmith::Config

Inherits:
Object
  • Object
show all
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

Class Method Details

.connectionObject



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

Raises:



19
20
21
22
23
24
25
# File 'lib/blacksmith/config.rb', line 19

def map(pattern = nil, options = {})
  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 options.is_a?(Hash).! || options[:to].nil?
  patterns[pattern] = options[:to]
end

.patternsObject



27
28
29
# File 'lib/blacksmith/config.rb', line 27

def patterns
  @patterns ||= {}
end

.roomObject



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

.titleObject



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