Class: TxghServer::Webhooks::Github::PushHandler

Inherits:
Object
  • Object
show all
Includes:
ResponseHelpers
Defined in:
lib/txgh-server/webhooks/github/push_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, repo, logger, attributes) ⇒ PushHandler

Returns a new instance of PushHandler.



13
14
15
16
17
18
# File 'lib/txgh-server/webhooks/github/push_handler.rb', line 13

def initialize(project, repo, logger, attributes)
  @project = project
  @repo = repo
  @logger = logger
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



11
12
13
# File 'lib/txgh-server/webhooks/github/push_handler.rb', line 11

def attributes
  @attributes
end

#loggerObject (readonly)

Returns the value of attribute logger.



11
12
13
# File 'lib/txgh-server/webhooks/github/push_handler.rb', line 11

def logger
  @logger
end

#projectObject (readonly)

Returns the value of attribute project.



11
12
13
# File 'lib/txgh-server/webhooks/github/push_handler.rb', line 11

def project
  @project
end

#repoObject (readonly)

Returns the value of attribute repo.



11
12
13
# File 'lib/txgh-server/webhooks/github/push_handler.rb', line 11

def repo
  @repo
end

Instance Method Details

#executeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/txgh-server/webhooks/github/push_handler.rb', line 20

def execute
  # Check if the branch in the hook data is the configured branch we want
  logger.info("request github branch: #{branch}")
  logger.info("config github branch: #{repo.github_config_branch}")

  if should_process?
    logger.info('found branch in github request')

    pusher.push_resources(added_and_modified_resources) do |tx_resource|
      # block should return categories for the passed-in resource
      { 'author' => attributes.author }
    end

    update_github_status
  end

  respond_with(200, true)
end