Class: TxghQueue::Job

Inherits:
Object
  • Object
show all
Includes:
TxghServer::ResponseHelpers
Defined in:
lib/txgh-queue/job.rb

Direct Known Subclasses

Backends::Sqs::Job

Constant Summary collapse

Github =
TxghServer::Webhooks::Github
Transifex =
TxghServer::Webhooks::Transifex

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Job

Returns a new instance of Job.



12
13
14
# File 'lib/txgh-queue/job.rb', line 12

def initialize(logger)
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



10
11
12
# File 'lib/txgh-queue/job.rb', line 10

def logger
  @logger
end

Instance Method Details

#process(payload) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/txgh-queue/job.rb', line 16

def process(payload)
  Supervisor.supervise do
    config = config_from(payload)
    project = config.transifex_project
    repo = config.github_repo

    case payload.fetch('txgh_event')
      when 'github.push'
        handle_github_push(project, repo, payload)
      when 'github.delete'
        handle_github_delete(project, repo, payload)
      when 'transifex.hook'
        handle_transifex_hook(project, repo, payload)
      else
        handle_unexpected
    end
  end
end