Class: CampfireService

Inherits:
Service
  • Object
show all
Defined in:
app/models/project_services/campfire_service.rb

Overview

Schema Information

Table name: services

id                    :integer          not null, primary key
type                  :string
title                 :string
project_id            :integer
created_at            :datetime         not null
updated_at            :datetime         not null
active                :boolean          not null
properties            :text
template              :boolean          default(FALSE)
push_events           :boolean          default(TRUE)
issues_events         :boolean          default(TRUE)
merge_requests_events :boolean          default(TRUE)
tag_push_events       :boolean          default(TRUE)
note_events           :boolean          default(TRUE), not null
build_events          :boolean          default(FALSE), not null
category              :string           default("common"), not null
default               :boolean          default(FALSE)
wiki_page_events      :boolean          default(TRUE)

Instance Method Summary collapse

Methods inherited from Service

#activated?, #async_execute, available_services_names, boolean_accessor, #can_test?, #category, create_from_template, #help, #initialize_properties, #issue_tracker?, prop_accessor, #reset_updated_properties, #template?, #test, #updated_properties

Instance Method Details

#descriptionObject


33
34
35
# File 'app/models/project_services/campfire_service.rb', line 33

def description
  'Simple web-based real-time group chat'
end

#execute(data) ⇒ Object


53
54
55
56
57
58
59
60
61
62
# File 'app/models/project_services/campfire_service.rb', line 53

def execute(data)
  return unless supported_events.include?(data[:object_kind])

  room = gate.find_room_by_name(self.room)
  return true unless room

  message = build_message(data)

  room.speak(message)
end

#fieldsObject


41
42
43
44
45
46
47
# File 'app/models/project_services/campfire_service.rb', line 41

def fields
  [
    { type: 'text', name: 'token',     placeholder: '' },
    { type: 'text', name: 'subdomain', placeholder: '' },
    { type: 'text', name: 'room',      placeholder: '' }
  ]
end

#supported_eventsObject


49
50
51
# File 'app/models/project_services/campfire_service.rb', line 49

def supported_events
  %w(push)
end

#titleObject


29
30
31
# File 'app/models/project_services/campfire_service.rb', line 29

def title
  'Campfire'
end

#to_paramObject


37
38
39
# File 'app/models/project_services/campfire_service.rb', line 37

def to_param
  'campfire'
end