Skip to content

Commit 5d07d75

Browse files
author
Ben Lavender
committed
Rename from ChatOps to Chatops
1 parent ac27ac1 commit 5d07d75

8 files changed

Lines changed: 23 additions & 27 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Rails helpers for easy, JSON-RPC based chatops.
55
A minimal controller example:
66

77
```ruby
8-
class ChatOpsController < ApplicationController
9-
include ::ChatOps::Controller
8+
class ChatopsController < ApplicationController
9+
include ::Chatops::Controller
1010

1111
chatops_namespace :echo
1212

@@ -79,7 +79,7 @@ You can return `jsonrpc_success` with a string to return text to chat. If you
7979
have an input validation or other handle-able error, you can use
8080
`jsonrpc_failure` to send a helpful error message.
8181

82-
ChatOps are regular old rails controller actions, and you can use niceties like
82+
Chatops are regular old rails controller actions, and you can use niceties like
8383
`before_action` and friends. `before_action :echo, :load_user` for the above
8484
case would call `load_user` before running `echo`.
8585

lib/chatops.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module ChatOps
1+
module Chatops
22
def self.public_key
33
ENV[public_key_env_var_name]
44
end

lib/chatops/controller.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "chatops"
22

3-
module ChatOps
3+
module Chatops
44
module Controller
55
class ConfigurationError < StandardError ; end
66
extend ActiveSupport::Concern
@@ -103,22 +103,22 @@ def ensure_chatops_authenticated
103103
signature_string = [@chatops_url, @chatops_nonce, @chatops_timestamp, body].join("\n")
104104
# We return this just to aid client debugging.
105105
response.headers["Chatops-Signature-String"] = signature_string
106-
raise ConfigurationError.new("You need to add a client's public key in .pem format via #{ChatOps.public_key_env_var_name}") unless ChatOps.public_key.present?
107-
if signature_valid?(ChatOps.public_key, @chatops_signature, signature_string) ||
108-
signature_valid?(ChatOps.alt_public_key, @chatops_signature, signature_string)
106+
raise ConfigurationError.new("You need to add a client's public key in .pem format via #{Chatops.public_key_env_var_name}") unless Chatops.public_key.present?
107+
if signature_valid?(Chatops.public_key, @chatops_signature, signature_string) ||
108+
signature_valid?(Chatops.alt_public_key, @chatops_signature, signature_string)
109109
return true
110110
end
111111
return render :status => :forbidden, :plain => "Not authorized"
112112
end
113113

114114
def ensure_valid_chatops_url
115-
unless ChatOps.auth_base_url.present?
116-
raise ConfigurationError.new("You need to set the server's base URL to authenticate chatops RPC via #{ChatOps.auth_base_url_env_var_name}")
115+
unless Chatops.auth_base_url.present?
116+
raise ConfigurationError.new("You need to set the server's base URL to authenticate chatops RPC via #{Chatops.auth_base_url_env_var_name}")
117117
end
118-
if ChatOps.auth_base_url[-1] == "/"
119-
raise ConfigurationError.new("Don't include a trailing slash in #{ChatOps.auth_base_url_env_var_name}; the rails path will be appended and it must match exactly.")
118+
if Chatops.auth_base_url[-1] == "/"
119+
raise ConfigurationError.new("Don't include a trailing slash in #{Chatops.auth_base_url_env_var_name}; the rails path will be appended and it must match exactly.")
120120
end
121-
@chatops_url = ChatOps.auth_base_url + request.path
121+
@chatops_url = Chatops.auth_base_url + request.path
122122
end
123123

124124
def ensure_valid_chatops_nonce

lib/chatops/controller/rspec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "chatops/controller/test_case"
22

33
RSpec.configure do |config|
4-
config.include ChatOps::Controller::TestCaseHelpers
4+
config.include Chatops::Controller::TestCaseHelpers
55
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "chatops/controller/test_case_helpers"
22

3-
class ChatOps::Controller::TestCase < ActionController::TestCase
4-
include ChatOps::Controller::TestCaseHelpers
3+
class Chatops::Controller::TestCase < ActionController::TestCase
4+
include Chatops::Controller::TestCaseHelpers
55
end

lib/chatops/controller/test_case_helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module ChatOps::Controller::TestCaseHelpers
1+
module Chatops::Controller::TestCaseHelpers
22

33
class NoMatchingCommandRegex < StandardError ; end
44

lib/chatops_controller.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
require "chatops_controller/version"
22
require "chatops/controller"
3-
4-
::ActiveSupport::Inflector.inflections(:en) do |inflect|
5-
inflect.acronym("ChatOps")
6-
end

spec/lib/chatops/controller_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
describe ActionController::Base, type: :controller do
66
controller do
7-
include ChatOps::Controller
7+
include Chatops::Controller
88
chatops_namespace :test
9-
chatops_help "ChatOps of and relating to testing"
9+
chatops_help "Chatops of and relating to testing"
1010
chatops_error_response "Try checking haystack?"
1111

1212
before_action :ensure_app_given, :only => [:wcid]
@@ -137,7 +137,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
137137
ENV.delete "CHATOPS_AUTH_BASE_URL"
138138
expect {
139139
get :list
140-
}.to raise_error(ChatOps::Controller::ConfigurationError)
140+
}.to raise_error(Chatops::Controller::ConfigurationError)
141141
end
142142

143143
it "raises an error trying to auth without a public key" do
@@ -152,7 +152,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
152152
ENV.delete "CHATOPS_AUTH_PUBLIC_KEY"
153153
expect {
154154
get :list
155-
}.to raise_error(ChatOps::Controller::ConfigurationError)
155+
}.to raise_error(Chatops::Controller::ConfigurationError)
156156
end
157157

158158
it "doesn't authenticate with the wrong public key'" do
@@ -214,7 +214,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
214214
expect(response.status).to eq 200
215215
expect(json_response).to eq({
216216
"namespace" => "test",
217-
"help" => "ChatOps of and relating to testing",
217+
"help" => "Chatops of and relating to testing",
218218
"error_response" => "Try checking haystack?",
219219
"methods" => {
220220
"wcid" => {
@@ -363,7 +363,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
363363
it "anchors regexes" do
364364
expect {
365365
chat "too bad that this message doesn't start with where can i deploy foobar", "bhuga"
366-
}.to raise_error(ChatOps::Controller::TestCaseHelpers::NoMatchingCommandRegex)
366+
}.to raise_error(Chatops::Controller::TestCaseHelpers::NoMatchingCommandRegex)
367367
end
368368
end
369369
end

0 commit comments

Comments
 (0)