Skip to content

Commit 75705c3

Browse files
committed
Merge branch 'release/0.10.0'
2 parents 3a1a31e + 79ca7f7 commit 75705c3

24 files changed

Lines changed: 1410 additions & 102 deletions

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# IP of your SENEC
22
SENEC_HOST=192.168.1.1
3-
SENEC_SCHEMA=http
3+
SENEC_SCHEMA=https
44

55
# Interval in seconds to get data from SENEC
66
SENEC_INTERVAL=5
77

8+
# Language for retrieving state names
9+
SENEC_LANGUAGE=de
10+
811
# Credentials of your InfluxDB installation
912
INFLUX_HOST=influxdb.example.com
1013
INFLUX_SCHEMA=https

.env.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Example of a SENEC host
2-
SENEC_HOST=10.0.1.123
3-
SENEC_SCHEMA=http
2+
SENEC_HOST=192.168.178.29
3+
SENEC_SCHEMA=https
44
SENEC_INTERVAL=5
5+
SENEC_LANGUAGE=de
56

67
# Example of an InfluxDB host
78
INFLUX_HOST=localhost

.github/workflows/push.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ jobs:
1818
test:
1919
runs-on: ubuntu-latest
2020

21+
env:
22+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
23+
CI: true
24+
2125
steps:
2226
- name: Checkout the code
23-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2428

2529
- name: Set up Ruby
2630
uses: ruby/setup-ruby@v1
@@ -33,20 +37,26 @@ jobs:
3337
- name: Run tests
3438
run: bundle exec rake test
3539

40+
- name: Send test coverage to CodeClimate
41+
uses: paambaati/codeclimate-action@v5.0.0
42+
if: ${{ env.CC_TEST_REPORTER_ID }}
43+
with:
44+
coverageCommand: true
45+
3646
build:
3747
runs-on: ubuntu-latest
3848
needs: test
3949
if: ${{ github.triggering_actor != 'dependabot[bot]' }}
4050

4151
steps:
4252
- name: Checkout the code
43-
uses: actions/checkout@v3
53+
uses: actions/checkout@v4
4454
with:
4555
fetch-depth: 0
4656

4757
- name: Docker meta
4858
id: meta
49-
uses: docker/metadata-action@v4
59+
uses: docker/metadata-action@v5
5060
with:
5161
# list of Docker images to use as base name for tags
5262
images: |
@@ -61,22 +71,22 @@ jobs:
6171
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
6272
6373
- name: Set up Docker Buildx
64-
uses: docker/setup-buildx-action@v2
74+
uses: docker/setup-buildx-action@v3
6575

6676
- name: Set up QEMU
67-
uses: docker/setup-qemu-action@v2
77+
uses: docker/setup-qemu-action@v3
6878
with:
6979
platforms: linux/amd64,linux/arm64,linux/arm/v7
7080

7181
- name: Login to GitHub Container Registry
72-
uses: docker/login-action@v2
82+
uses: docker/login-action@v3
7383
with:
7484
registry: ghcr.io
7585
username: ${{ github.repository_owner }}
7686
password: ${{ secrets.CR_PAT }}
7787

7888
- name: Build and push
79-
uses: docker/build-push-action@v4
89+
uses: docker/build-push-action@v5
8090
with:
8191
context: .
8292
platforms: linux/amd64,linux/arm64,linux/arm/v7

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.env
22
.env.development.local
3+
coverage/

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Style/FrozenStringLiteralComment:
1919
Metrics/MethodLength:
2020
Max: 20
2121

22+
Metrics/ClassLength:
23+
Enabled: false
24+
2225
Minitest/MultipleAssertions:
2326
Max: 10
2427

@@ -28,5 +31,8 @@ Style/TrailingCommaInArguments:
2831
Style/TrailingCommaInHashLiteral:
2932
EnforcedStyleForMultiline: consistent_comma
3033

34+
Style/TrailingCommaInArrayLiteral:
35+
EnforcedStyleForMultiline: consistent_comma
36+
3137
Layout/LineEndStringConcatenationIndentation:
3238
Enabled: false

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ group :development, :test do
3636

3737
# Library for stubbing HTTP requests in Ruby. (https://github.com/bblimke/webmock)
3838
gem 'webmock'
39+
40+
# Code coverage for Ruby (https://github.com/simplecov-ruby/simplecov)
41+
gem 'simplecov'
3942
end

Gemfile.lock

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@ GEM
55
public_suffix (>= 2.0.2, < 6.0)
66
ast (2.4.2)
77
base64 (0.1.1)
8+
connection_pool (2.4.1)
89
crack (0.4.5)
910
rexml
11+
docile (1.4.0)
1012
dotenv (2.8.1)
13+
faraday (2.7.11)
14+
base64
15+
faraday-net_http (>= 2.0, < 3.1)
16+
ruby2_keywords (>= 0.0.4)
17+
faraday-net_http (3.0.2)
18+
faraday-net_http_persistent (2.1.0)
19+
faraday (~> 2.5)
20+
net-http-persistent (~> 4.0)
21+
faraday-request-timer (0.2.0)
22+
faraday (>= 0.9.0)
1123
hashdiff (1.0.1)
12-
httparty (0.21.0)
13-
mini_mime (>= 1.0.0)
14-
multi_xml (>= 0.5.2)
1524
influxdb-client (2.9.0)
1625
json (2.6.3)
1726
language_server-protocol (3.17.0.3)
18-
mini_mime (1.1.5)
19-
minitest (5.19.0)
20-
multi_xml (0.6.0)
21-
oj (3.16.0)
27+
minitest (5.20.0)
28+
net-http-persistent (4.0.2)
29+
connection_pool (~> 2.2)
30+
oj (3.16.1)
2231
parallel (1.23.0)
2332
parser (3.2.2.3)
2433
ast (~> 2.4.1)
@@ -29,7 +38,7 @@ GEM
2938
rake (13.0.6)
3039
regexp_parser (2.8.1)
3140
rexml (3.2.6)
32-
rubocop (1.56.0)
41+
rubocop (1.56.3)
3342
base64 (~> 0.1.1)
3443
json (~> 2.3)
3544
language_server-protocol (>= 3.17.0)
@@ -43,19 +52,28 @@ GEM
4352
unicode-display_width (>= 2.4.0, < 3.0)
4453
rubocop-ast (1.29.0)
4554
parser (>= 3.2.1.0)
46-
rubocop-minitest (0.31.0)
55+
rubocop-minitest (0.32.2)
4756
rubocop (>= 1.39, < 2.0)
48-
rubocop-performance (1.19.0)
57+
rubocop-performance (1.19.1)
4958
rubocop (>= 1.7.0, < 2.0)
5059
rubocop-ast (>= 0.4.0)
5160
rubocop-rake (0.6.0)
5261
rubocop (~> 1.0)
5362
ruby-progressbar (1.13.0)
54-
senec (0.9.0)
55-
httparty
63+
ruby2_keywords (0.0.5)
64+
senec (0.12.0)
65+
faraday
66+
faraday-net_http_persistent
67+
faraday-request-timer
68+
simplecov (0.22.0)
69+
docile (~> 1.1)
70+
simplecov-html (~> 0.11)
71+
simplecov_json_formatter (~> 0.1)
72+
simplecov-html (0.12.3)
73+
simplecov_json_formatter (0.1.4)
5674
unicode-display_width (2.4.2)
5775
vcr (6.2.0)
58-
webmock (3.18.1)
76+
webmock (3.19.1)
5977
addressable (>= 2.8.0)
6078
crack (>= 0.3.2)
6179
hashdiff (>= 0.4.0, < 2.0.0)
@@ -74,8 +92,9 @@ DEPENDENCIES
7492
rubocop-performance
7593
rubocop-rake
7694
senec
95+
simplecov
7796
vcr
7897
webmock
7998

8099
BUNDLED WITH
81-
2.4.19
100+
2.4.20

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[![Continuous integration](https://github.com/solectrus/senec-collector/actions/workflows/push.yml/badge.svg)](https://github.com/solectrus/senec-collector/actions/workflows/push.yml)
2+
[![Maintainability](https://api.codeclimate.com/v1/badges/ae0d21c0c4eb9c430505/maintainability)](https://codeclimate.com/github/solectrus/senec-collector/maintainability)
23
[![wakatime](https://wakatime.com/badge/user/697af4f5-617a-446d-ba58-407e7f3e0243/project/e8426066-7e79-40d8-8d8b-583dd965720a.svg)](https://wakatime.com/badge/user/697af4f5-617a-446d-ba58-407e7f3e0243/project/e8426066-7e79-40d8-8d8b-583dd965720a)
4+
[![Test Coverage](https://api.codeclimate.com/v1/badges/ae0d21c0c4eb9c430505/test_coverage)](https://codeclimate.com/github/solectrus/senec-collector/test_coverage)
35

46
# SENEC collector
57

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require 'rubygems'
22
require 'bundler'
33
require 'rake/testtask'
44
require 'dotenv'
5-
Dotenv.load('.env', '.env.test')
5+
Dotenv.load('.env.test')
66

77
Rake::TestTask.new :test do |t|
88
t.libs << 'test' << 'app'

app/config.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
:senec_host,
44
:senec_schema,
55
:senec_interval,
6+
:senec_language,
67
:influx_schema,
78
:influx_host,
89
:influx_port,
@@ -24,20 +25,15 @@ def influx_url
2425
"#{influx_schema}://#{influx_host}:#{influx_port}"
2526
end
2627

27-
def senec_state_names
28-
@senec_state_names ||=
29-
begin
30-
puts 'Getting state names from SENEC by parsing source code...'
31-
names = Senec::State.new(host: senec_host, schema: senec_schema).names
32-
puts "OK, got #{names.length} state names"
33-
names
34-
end
35-
end
36-
3728
def senec_url
3829
"#{senec_schema}://#{senec_host}"
3930
end
4031

32+
def senec_connection
33+
@senec_connection ||=
34+
Senec::Connection.new(host: senec_host, schema: senec_schema)
35+
end
36+
4137
private
4238

4339
def validate_interval!(interval)
@@ -59,6 +55,7 @@ def self.from_env(options = {})
5955
senec_host: ENV.fetch('SENEC_HOST'),
6056
senec_schema: ENV.fetch('SENEC_SCHEMA', 'http'),
6157
senec_interval: ENV.fetch('SENEC_INTERVAL').to_i,
58+
senec_language: ENV.fetch('SENEC_LANGUAGE', 'de').to_sym,
6259
influx_host: ENV.fetch('INFLUX_HOST'),
6360
influx_schema: ENV.fetch('INFLUX_SCHEMA', 'http'),
6461
influx_port: ENV.fetch('INFLUX_PORT', '8086'),

0 commit comments

Comments
 (0)