Class: Reina::GitHubController

Inherits:
Object
  • Object
show all
Defined in:
lib/reina/github_controller.rb

Constant Summary collapse

DEPLOY_TRIGGER =
'reina: d '.freeze
SINGLE_DEPLOY_TRIGGER =
'reina: r '.freeze
EVENTS =
%w(issues issue_comment).freeze

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GitHubController

Returns a new instance of GitHubController.


15
16
17
# File 'lib/reina/github_controller.rb', line 15

def initialize(config)
  @config = config
end

Instance Method Details

#deployed_urlObject


35
36
37
38
39
# File 'lib/reina/github_controller.rb', line 35

def deployed_url
  [
    'https://', CONFIG[:app_name_prefix], repo_name, '-', issue_number, '.herokuapp.com'
  ].join
end

#dispatch(request) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/reina/github_controller.rb', line 19

def dispatch(request)
  @request = request

  raise UnsupportedEventError unless EVENTS.include?(event)

  authenticate!

  if deploy_requested?
    deploy!
  elsif single_deploy_requested?
    deploy!(true)
  elsif issue_closed?
    destroy!
  end
end