File tree 8 files changed +31
-24
lines changed
8 files changed +31
-24
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
AllCops :
3
- TargetRubyVersion : 2.4
3
+ TargetRubyVersion : 2.5
4
4
Exclude :
5
5
- ' *.spec'
6
6
- ' Rakefile'
7
7
- ' vendor/**/*'
8
+ NewCops : enable
8
9
9
10
# Don't enforce documentation
10
11
Style/Documentation :
@@ -16,9 +17,6 @@ Style/FrozenStringLiteralComment:
16
17
Style/MultilineBlockChain :
17
18
Enabled : false
18
19
19
- Layout/IndentHeredoc :
20
- Enabled : false
21
-
22
20
Metrics/PerceivedComplexity :
23
21
Enabled : false
24
22
@@ -31,17 +29,11 @@ Style/RescueModifier:
31
29
Metrics/MethodLength :
32
30
Max : 40
33
31
34
- Metrics/LineLength :
35
- Max : 190
36
-
37
32
Metrics/AbcSize :
38
33
Enabled : false
39
34
40
- Performance/FixedSize :
41
- Exclude :
42
- - ' test/**/*'
43
-
44
35
Metrics/BlockLength :
36
+ Max : 40
45
37
Exclude :
46
38
- ' test/**/*'
47
39
@@ -50,8 +42,8 @@ Metrics/ClassLength:
50
42
Exclude :
51
43
- ' test/**/*'
52
44
53
- Lint/AmbiguousBlockAssociation :
54
- Enabled : false
45
+ Layout/LineLength :
46
+ Max : 190
55
47
56
48
Style/ClassAndModuleChildren :
57
49
Exclude :
Original file line number Diff line number Diff line change
1
+ ---
2
+ sudo : false
3
+ language : ruby
4
+ rvm :
5
+ - 2.5
6
+ - 2.6
7
+ - 2.7
8
+ - 3.0
9
+
10
+ cache :
11
+ bundler : true
12
+ before_install :
13
+ - gem install bundler rubocop
14
+ - gem update --system
15
+ script :
16
+ - rubocop lib/
17
+ - bundle exec rake test
Original file line number Diff line number Diff line change @@ -4,3 +4,6 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
5
5
# Specify your gem's dependencies in grafana_matrix.gemspec
6
6
gemspec
7
+
8
+ gem 'json'
9
+ gem 'rubocop'
Original file line number Diff line number Diff line change 1
1
require 'grafana_matrix'
2
2
3
3
config = GrafanaMatrix ::Config . new 'config.yml'
4
- warn 'Specifying port/bind in config '
4
+ warn 'Specifying port/bind in config' if config . port? || config . bind?
5
5
6
6
Signal . trap ( 'HUP' ) do
7
7
warn "[#{ Time . now } ] SIGHUP received, reloading configuration"
Original file line number Diff line number Diff line change @@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
22
22
spec . add_development_dependency 'bundler'
23
23
spec . add_development_dependency 'minitest'
24
+ spec . add_development_dependency 'rake'
24
25
end
Original file line number Diff line number Diff line change 3
3
4
4
module GrafanaMatrix
5
5
class Config
6
- # rubocop:disable Metrics/BlockLength
7
6
Rule = Struct . new ( :config , :data ) do
8
7
def name
9
8
data . fetch ( :name )
@@ -64,7 +63,6 @@ def client
64
63
@client ||= config . client ( matrix )
65
64
end
66
65
end
67
- # rubocop:enable Metrics/BlockLength
68
66
69
67
def initialize ( config = { } )
70
68
if config . is_a? String
@@ -115,7 +113,7 @@ def client(client_name = nil)
115
113
client_data = client_data . dup
116
114
117
115
# Symbolize keys
118
- client_data . keys . each do |key |
116
+ client_data . each_key do |key |
119
117
client_data [ ( key . to_sym rescue key ) ] = client_data . delete key
120
118
end
121
119
@@ -131,7 +129,7 @@ def rules(rule_name)
131
129
rule_data = rule_data . dup
132
130
133
131
# Symbolize keys
134
- rule_data . keys . each do |key |
132
+ rule_data . each_key do |key |
135
133
rule_data [ ( key . to_sym rescue key ) ] = rule_data . delete key
136
134
end
137
135
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def authorized(user, pass)
39
39
halt 404 , 'No such rule configured' if rules . empty?
40
40
41
41
data = request . body . read
42
- halt 400 , 'No notification body provided' if data . empty?
42
+ halt 400 , 'No notification body provided' if data . empty?
43
43
44
44
data = JSON . parse ( data ) rescue nil
45
45
halt 400 , 'Unable to parse notification body' unless data
@@ -83,7 +83,7 @@ def authorized(user, pass)
83
83
format : 'org.matrix.custom.html' )
84
84
end
85
85
86
- ''
86
+ { result : :success } . to_json
87
87
end
88
88
end
89
89
end
Original file line number Diff line number Diff line change @@ -4,8 +4,4 @@ class GrafanaMatrixTest < Minitest::Test
4
4
def test_that_it_has_a_version_number
5
5
refute_nil ::GrafanaMatrix ::VERSION
6
6
end
7
-
8
- def test_it_does_something_useful
9
- assert false
10
- end
11
7
end
You can’t perform that action at this time.
0 commit comments