Skip to content

Commit

Permalink
Merge pull request #1 from theckman/add_shorter_command
Browse files Browse the repository at this point in the history
adjust route regex to allow for a shorter command (sp)
  • Loading branch information
esigler committed Apr 14, 2014
2 parents 334bb8d + 25e1bdf commit 810032f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -42,6 +42,8 @@ Lita > Lita statuspage incident list unresolved
No incidents to list
```

**Note:** This plugin also accepts `sp` as the command instead of `statuspage`

### Incidents

#### Create
Expand Down
48 changes: 24 additions & 24 deletions lib/lita/handlers/statuspage.rb
Expand Up @@ -2,90 +2,90 @@ module Lita
module Handlers
class Statuspage < Handler
route(
/^statuspage\sincident\snew\s(.+)$/,
/^(?:statuspage|sp)\sincident\snew\s(.+)$/,
:incident_new,
command: true,
help: {
'statuspage incident new name:"<name>"' => 'Create a new realtime incident',
' status:<status>' => '(Optional) One of: investigating|identified|monitoring|resolved ' \
'(default: investigating)',
' message:"<message>"' => '(Optional) The initial message',
' twitter:<state>' => '(Optional) Post the new incident to Twitter, one of: ' \
'(true|t|false|f) (default:false)',
' impact:<state>' => '(Optional) Override calculated impact value, one of: ' \
'(statuspage|sp) incident new name:"<name>"' => 'Create a new realtime incident',
' status:<status>' => '(Optional) One of: investigating|identified|monitoring' \
'|resolved (default: investigating)',
' message:"<message>"' => '(Optional) The initial message',
' twitter:<state>' => '(Optional) Post the new incident to Twitter, one of: ' \
'(true|t|false|f) (default:false)',
' impact:<state>' => '(Optional) Override calculated impact value, one of: ' \
'(minor|major|critical)'
}
)

route(
/^statuspage\sincident\supdate\s(.+)$/,
/^(?:statuspage|sp)\sincident\supdate\s(.+)$/,
:incident_update,
command: true,
help: {
'statuspage incident update id:ABC123 (...)' => 'Update an incident (takes same arguments as new)'
'(statuspage|sp) incident update id:ABC123 (...)' => 'Update an incident (takes same arguments as new)'
}
)

route(
/^statuspage\sincident\slist(\sall)?$/,
/^(?:statuspage|sp)\sincident\slist(\sall)?$/,
:incident_list_all,
command: true,
help: {
'statuspage incident list all' => 'List all incidents'
'(statuspage|sp) incident list all' => 'List all incidents'
}
)

route(
/^statuspage\sincident\slist\sscheduled$/,
/^(?:statuspage|sp)\sincident\slist\sscheduled$/,
:incident_list_scheduled,
command: true,
help: {
'statuspage incident list scheduled' => 'List scheduled incidents'
'(statuspage|sp) incident list scheduled' => 'List scheduled incidents'
}
)

route(
/^statuspage\sincident\slist\sunresolved$/,
/^(?:statuspage|sp)\sincident\slist\sunresolved$/,
:incident_list_unresolved,
command: true,
help: {
'statuspage incident list unresolved' => 'List unresolved incidents'
'(statuspage|sp) incident list unresolved' => 'List unresolved incidents'
}
)

route(
/^statuspage\sincident\sdelete\slatest$/,
/^(?:statuspage|sp)\sincident\sdelete\slatest$/,
:incident_delete_latest,
command: true,
help: {
'statuspage incident delete latest' => 'Delete latest incident'
'(statuspage|sp) incident delete latest' => 'Delete latest incident'
}
)

route(
/^statuspage\sincident\sdelete\sid:(\w+)$/,
/^(?:statuspage|sp)\sincident\sdelete\sid:(\w+)$/,
:incident_delete,
command: true,
help: {
'statuspage incident delete id:<id>' => 'Delete a specific incident'
'(statuspage|sp) incident delete id:<id>' => 'Delete a specific incident'
}
)

route(
/^statuspage\scomponent\slist(\sall)?$/,
/^(?:statuspage|sp)\scomponent\slist(\sall)?$/,
:component_list,
command: true,
help: {
'statuspage component list' => 'Lists all components'
'(statuspage|sp) component list' => 'Lists all components'
}
)

route(
/^statuspage\scomponent\supdate\s(.+)$/,
/^(?:statuspage|sp)\scomponent\supdate\s(.+)$/,
:component_update,
command: true,
help: {
'statuspage component update' => 'Updates the component'
'(statuspage|sp) component update' => 'Updates the component'
}
)

Expand Down
12 changes: 12 additions & 0 deletions spec/lita/handlers/statuspage_spec.rb
Expand Up @@ -57,6 +57,18 @@
it { routes_command('statuspage component list all').to(:component_list) }
it { routes_command('statuspage component update latest').to(:component_update) }

it { routes_command('sp incident new name:"foo"').to(:incident_new) }
it { routes_command('sp incident update latest').to(:incident_update) }
it { routes_command('sp incident list').to(:incident_list_all) }
it { routes_command('sp incident list all').to(:incident_list_all) }
it { routes_command('sp incident list scheduled').to(:incident_list_scheduled) }
it { routes_command('sp incident list unresolved').to(:incident_list_unresolved) }
it { routes_command('sp incident delete latest').to(:incident_delete_latest) }
it { routes_command('sp incident delete id:omgwtfbbq').to(:incident_delete) }
it { routes_command('sp component list').to(:component_list) }
it { routes_command('sp component list all').to(:component_list) }
it { routes_command('sp component update latest').to(:component_update) }

describe '.default_config' do
it 'sets api_key to nil' do
expect(Lita.config.handlers.statuspage.api_key).to be_nil
Expand Down

0 comments on commit 810032f

Please sign in to comment.