Skip to content

Commit 23c82f9

Browse files
committed
Prepare for CI
1 parent c280bc9 commit 23c82f9

File tree

8 files changed

+31
-24
lines changed

8 files changed

+31
-24
lines changed

.rubocop.yml

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
AllCops:
3-
TargetRubyVersion: 2.4
3+
TargetRubyVersion: 2.5
44
Exclude:
55
- '*.spec'
66
- 'Rakefile'
77
- 'vendor/**/*'
8+
NewCops: enable
89

910
# Don't enforce documentation
1011
Style/Documentation:
@@ -16,9 +17,6 @@ Style/FrozenStringLiteralComment:
1617
Style/MultilineBlockChain:
1718
Enabled: false
1819

19-
Layout/IndentHeredoc:
20-
Enabled: false
21-
2220
Metrics/PerceivedComplexity:
2321
Enabled: false
2422

@@ -31,17 +29,11 @@ Style/RescueModifier:
3129
Metrics/MethodLength:
3230
Max: 40
3331

34-
Metrics/LineLength:
35-
Max: 190
36-
3732
Metrics/AbcSize:
3833
Enabled: false
3934

40-
Performance/FixedSize:
41-
Exclude:
42-
- 'test/**/*'
43-
4435
Metrics/BlockLength:
36+
Max: 40
4537
Exclude:
4638
- 'test/**/*'
4739

@@ -50,8 +42,8 @@ Metrics/ClassLength:
5042
Exclude:
5143
- 'test/**/*'
5244

53-
Lint/AmbiguousBlockAssociation:
54-
Enabled: false
45+
Layout/LineLength:
46+
Max: 190
5547

5648
Style/ClassAndModuleChildren:
5749
Exclude:

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
44

55
# Specify your gem's dependencies in grafana_matrix.gemspec
66
gemspec
7+
8+
gem 'json'
9+
gem 'rubocop'

config.ru

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'grafana_matrix'
22

33
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?
55

66
Signal.trap('HUP') do
77
warn "[#{Time.now}] SIGHUP received, reloading configuration"

grafana_matrix.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
2121

2222
spec.add_development_dependency 'bundler'
2323
spec.add_development_dependency 'minitest'
24+
spec.add_development_dependency 'rake'
2425
end

lib/grafana_matrix/config.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
module GrafanaMatrix
55
class Config
6-
# rubocop:disable Metrics/BlockLength
76
Rule = Struct.new(:config, :data) do
87
def name
98
data.fetch(:name)
@@ -64,7 +63,6 @@ def client
6463
@client ||= config.client(matrix)
6564
end
6665
end
67-
# rubocop:enable Metrics/BlockLength
6866

6967
def initialize(config = {})
7068
if config.is_a? String
@@ -115,7 +113,7 @@ def client(client_name = nil)
115113
client_data = client_data.dup
116114

117115
# Symbolize keys
118-
client_data.keys.each do |key|
116+
client_data.each_key do |key|
119117
client_data[(key.to_sym rescue key)] = client_data.delete key
120118
end
121119

@@ -131,7 +129,7 @@ def rules(rule_name)
131129
rule_data = rule_data.dup
132130

133131
# Symbolize keys
134-
rule_data.keys.each do |key|
132+
rule_data.each_key do |key|
135133
rule_data[(key.to_sym rescue key)] = rule_data.delete key
136134
end
137135

lib/grafana_matrix/server.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def authorized(user, pass)
3939
halt 404, 'No such rule configured' if rules.empty?
4040

4141
data = request.body.read
42-
halt 400, 'No notification body provided' if data.empty?
42+
halt 400, 'No notification body provided' if data.empty?
4343

4444
data = JSON.parse(data) rescue nil
4545
halt 400, 'Unable to parse notification body' unless data
@@ -83,7 +83,7 @@ def authorized(user, pass)
8383
format: 'org.matrix.custom.html')
8484
end
8585

86-
''
86+
{ result: :success }.to_json
8787
end
8888
end
8989
end

test/grafana_matrix_test.rb

-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@ class GrafanaMatrixTest < Minitest::Test
44
def test_that_it_has_a_version_number
55
refute_nil ::GrafanaMatrix::VERSION
66
end
7-
8-
def test_it_does_something_useful
9-
assert false
10-
end
117
end

0 commit comments

Comments
 (0)