class Lita::Handlers::JenkinsClient::Action

Protected Class Methods

commands() click to toggle source
# File lib/lita/handlers/jenkins_client/action.rb, line 21
def commands
  {}
end
method_added(name) click to toggle source
# File lib/lita/handlers/jenkins_client/action.rb, line 25
def method_added(name)
  if self == Lita::Handlers::JenkinsClient::Action
    return
  end
  if cmd = commands[name]
    route(route_matcher(cmd.matcher), name, :help => {
      "#{name_prefix} #{cmd.name}" => "#{cmd.help} Usage: #{name_prefix} #{cmd.usage}"
    })
  end
end
name_prefix() click to toggle source
# File lib/lita/handlers/jenkins_client/action.rb, line 17
def name_prefix
  route_prefix.join(' ')
end
route_matcher(actions) click to toggle source
# File lib/lita/handlers/jenkins_client/action.rb, line 13
def route_matcher(actions)
  Regexp.new('^'+(route_prefix + [actions].flatten).join(' ').strip + '\b', 'i')
end
route_prefix() click to toggle source
# File lib/lita/handlers/jenkins_client/action.rb, line 9
def route_prefix
  ["jenkins"]
end

Protected Instance Methods

api_exec(usage = nil) { || ... } click to toggle source
# File lib/lita/handlers/jenkins_client/action.rb, line 40
def api_exec(usage = nil) 
  if block_given?
    begin 
      yield
    rescue Exception => e
      "Error: #{e.message}" + (usage ? " Usage: #{usage}" : '') 
    end
  end
end
usage(name) click to toggle source
# File lib/lita/handlers/jenkins_client/action.rb, line 50
def usage(name)
  self.class.commands[name].usage
end