Class: Lita::Handlers::SnapCi

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/snap_ci.rb

Instance Method Summary collapse

Instance Method Details

#all_projects(response) ⇒ Object



14
15
16
# File 'lib/lita/handlers/snap_ci.rb', line 14

def all_projects(response)
  response.reply ::SnapCi::ProjectList.new(config).to_message
end

#project(response) ⇒ Object

Return the first match, for an exact match use owner/repository format



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/lita/handlers/snap_ci.rb', line 23

def project(response)
  format = if response.args[1].slice("/").nil?
             :repo
           else
             :owner
           end

  project_arg = config.projects.detect do |project|
    if format == :owner
      project[:owner] == response.args[1].partition("/").first &&
        project[:repository] == response.args[1].partition("/").last
    else
      project[:repository] == response.args[1]
    end
  end

  response.reply ::SnapCi::Project.new(project_arg, config).to_message
end