Class: CIJoe::Campfire

Inherits:
Object
  • Object
show all
Defined in:
lib/cijoe/campfire.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_path) ⇒ Campfire

Returns a new instance of Campfire.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cijoe/campfire.rb', line 5

def initialize(project_path)
  @project_path = project_path
  if valid?
    require 'tinder'
    puts "Loaded Campfire notifier for #{project_path}."
  elsif ENV['RACK_ENV'] != 'test'
    puts "Can't load Campfire notifier for #{project_path}."
    puts "Please add the following to your project's .git/config:"
    puts "[campfire]"
    puts "\ttoken = abcd1234"
    puts "\tsubdomain = whatever"
    puts "\troom = Awesomeness"
    puts "\tssl = false"
  end
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



3
4
5
# File 'lib/cijoe/campfire.rb', line 3

def build
  @build
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



3
4
5
# File 'lib/cijoe/campfire.rb', line 3

def project_path
  @project_path
end

Instance Method Details

#campfire_configObject



21
22
23
24
25
26
27
28
29
# File 'lib/cijoe/campfire.rb', line 21

def campfire_config
  campfire_config = Config.new('campfire', project_path)
  @config = {
    :subdomain => campfire_config.subdomain.to_s,
    :token     => campfire_config.token.to_s,
    :room      => campfire_config.room.to_s,
    :ssl       => campfire_config.ssl.to_s.strip == 'true'
  }
end

#notify(build) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/cijoe/campfire.rb', line 37

def notify(build)
  begin
    @build = build
    room.speak "#{short_message}. #{build.commit.url}"
    room.paste full_message if build.failed?
    room.leave
  rescue
    puts "Please check your campfire config for #{project_path}."
  end
end

#valid?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/cijoe/campfire.rb', line 31

def valid?
  %w( subdomain token room ).all? do |key|
    !campfire_config[key.intern].empty?
  end
end