From 0746349e21d098a961690e4758ff0d132a2e8d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Pokorn=C3=BD?= Date: Sun, 20 Oct 2024 21:03:51 +0200 Subject: [PATCH] upgrade dependencies, return valid timestamp of sessions --- .ruby-version | 2 +- CHANGELOG.md | 5 ++ Gemfile | 2 +- Gemfile.lock | 107 +++++++++++-------------- atrea_control.gemspec | 4 +- lib/atrea_control/duplex/unit.rb | 9 ++- lib/atrea_control/sensor_parser.rb | 2 + lib/atrea_control/version.rb | 2 +- spec/atrea_control/duplex/unit_spec.rb | 7 ++ 9 files changed, 76 insertions(+), 64 deletions(-) diff --git a/.ruby-version b/.ruby-version index be94e6f..a0891f5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.2 +3.3.4 diff --git a/CHANGELOG.md b/CHANGELOG.md index e20c0f3..5b37cd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ ## [Unreleased] +### Added +- timestamp from atrea server +### Changed +- upgrade dependencies +- upgrade ruby version ## [2.2.0] - 2023-10-09 ### Changed diff --git a/Gemfile b/Gemfile index fcb7dc2..5c879bf 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem "pry" gem "rake", "~> 13.0" gem "rspec", "~> 3.10" gem "rubocop", "~> 1.7", require: false -gem "rubocop-rspec", "~> 2.4", require: false +gem "rubocop-rspec", "~> 3.1", require: false group :test do gem "simplecov", require: false gem "webmock", "~> 3.14" diff --git a/Gemfile.lock b/Gemfile.lock index d5c9c14..1f51565 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,55 +1,57 @@ PATH remote: . specs: - atrea_control (2.2.0) + atrea_control (2.3.0) i18n (~> 1.14) nokogiri (~> 1.15) rest-client (~> 2.1) - selenium-webdriver (~> 4.13.1) + selenium-webdriver (~> 4.25.0) GEM remote: https://rubygems.org/ specs: - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) + base64 (0.2.0) bigdecimal (3.1.8) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) crack (1.0.0) bigdecimal rexml - diff-lcs (1.5.0) - docile (1.4.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) - hashdiff (1.1.0) + diff-lcs (1.5.1) + docile (1.4.1) + domain_name (0.6.20240107) + hashdiff (1.1.1) http-accept (1.7.0) - http-cookie (1.0.5) + http-cookie (1.0.7) domain_name (~> 0.5) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) json (2.7.2) language_server-protocol (3.17.0.3) - method_source (1.0.0) - mime-types (3.5.1) + logger (1.6.1) + method_source (1.1.0) + mime-types (3.6.0) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2023.1003) + mime-types-data (3.2024.1001) netrc (0.11.0) - nokogiri (1.16.5-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-darwin) + nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) parallel (1.26.3) - parser (3.3.4.2) + parser (3.3.5.0) ast (~> 2.4.1) racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (5.0.5) + public_suffix (6.0.1) racc (1.8.1) rainbow (3.1.1) rake (13.2.1) @@ -59,47 +61,39 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.3.6) - strscan - rspec (3.12.0) - rspec-core (~> 3.12.0) - rspec-expectations (~> 3.12.0) - rspec-mocks (~> 3.12.0) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + rexml (3.3.8) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.6) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-support (3.12.1) - rubocop (1.66.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rubocop (1.67.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.4, < 3.0) - rubocop-ast (>= 1.32.1, < 2.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.1) + rubocop-ast (1.32.3) parser (>= 3.3.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) - rubocop-rspec (2.29.2) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) - rubocop-rspec_rails (~> 2.28) - rubocop-rspec_rails (2.28.3) - rubocop (~> 1.40) + rubocop-rspec (3.1.0) + rubocop (~> 1.61) ruby-progressbar (1.13.0) rubyzip (2.3.2) - selenium-webdriver (4.13.1) + selenium-webdriver (4.25.0) + base64 (~> 0.2) + logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -107,21 +101,18 @@ GEM docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) - strscan (3.1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) - unicode-display_width (2.5.0) - webmock (3.23.1) + unicode-display_width (2.6.0) + webmock (3.24.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket (1.2.10) + websocket (1.2.11) PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-20 x86_64-linux @@ -131,9 +122,9 @@ DEPENDENCIES rake (~> 13.0) rspec (~> 3.10) rubocop (~> 1.7) - rubocop-rspec (~> 2.4) + rubocop-rspec (~> 3.1) simplecov webmock (~> 3.14) BUNDLED WITH - 2.4.16 + 2.5.17 diff --git a/atrea_control.gemspec b/atrea_control.gemspec index 895a9b9..36d2d54 100644 --- a/atrea_control.gemspec +++ b/atrea_control.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| spec.summary = "Get data control.atrea.eu" spec.description = "Read data from web controller of RD5 duplex by Atrea." spec.homepage = "https://github.com/luk4s/atrea_control" - spec.required_ruby_version = Gem::Requirement.new("~> 3.2.2") + spec.required_ruby_version = Gem::Requirement.new("~> 3.2") spec.metadata["allowed_push_host"] = "https://rubygems.org" @@ -39,5 +39,5 @@ Gem::Specification.new do |spec| spec.add_dependency "i18n", "~> 1.14" spec.add_dependency "nokogiri", "~> 1.15" spec.add_dependency "rest-client", "~> 2.1" - spec.add_dependency "selenium-webdriver", "~> 4.13.1" + spec.add_dependency "selenium-webdriver", "~> 4.25.0" end diff --git a/lib/atrea_control/duplex/unit.rb b/lib/atrea_control/duplex/unit.rb index 7a37dae..1be8da5 100644 --- a/lib/atrea_control/duplex/unit.rb +++ b/lib/atrea_control/duplex/unit.rb @@ -13,6 +13,8 @@ class Unit attr_reader :valid_for # @return [UserCtrl] attr_reader :user_ctrl + # @return [Time, DateTime] + attr_writer :timestamp # @param [String, Integer] user_id # @param [String, Integer] unit_id @@ -37,6 +39,10 @@ def power current_power || values[:current_power] end + def timestamp + @timestamp ||= values[:timestamp] + end + def preheating? preheating || values[:preheating] end @@ -56,7 +62,7 @@ def power=(value) end def parsed - parser.values(read.body) + @parsed ||= parser.values(read.body) end def values @@ -75,6 +81,7 @@ def as_json(_options = nil) input_temperature: input_temperature, preheating: preheating, valid_for: valid_for, + timestamp: timestamp, } end diff --git a/lib/atrea_control/sensor_parser.rb b/lib/atrea_control/sensor_parser.rb index df63a1c..1259fc8 100644 --- a/lib/atrea_control/sensor_parser.rb +++ b/lib/atrea_control/sensor_parser.rb @@ -43,6 +43,7 @@ def parse(xml) preheating = %w[C10200 C10202 C10215 C10217].any? do |i| xml.xpath("//O[@I=\"#{i}\"]/@V").last&.value == "1" end + parsed["timestamp"] = xml.xpath("//RD5WEB").attribute("t").to_s parsed["preheating"] = preheating parsed end @@ -57,6 +58,7 @@ def format_data(values) "preheat_temperature" => values["preheat_temperature"].to_f / 10.0, "input_temperature" => values["input_temperature"].to_f / 10.0, "preheating" => values["preheating"], + "timestamp" => DateTime.parse(values["timestamp"]), "valid_for" => Time.now, } end diff --git a/lib/atrea_control/version.rb b/lib/atrea_control/version.rb index 3deedab..168e411 100644 --- a/lib/atrea_control/version.rb +++ b/lib/atrea_control/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module AtreaControl - VERSION = "2.2.0" + VERSION = "2.3.0" end diff --git a/spec/atrea_control/duplex/unit_spec.rb b/spec/atrea_control/duplex/unit_spec.rb index 28caeeb..e560f07 100644 --- a/spec/atrea_control/duplex/unit_spec.rb +++ b/spec/atrea_control/duplex/unit_spec.rb @@ -50,6 +50,13 @@ it "preheating?" do expect(unit.preheating?).to be true end + + describe "#timestamp" do + subject(:timestamp) { unit.timestamp } + + it { is_expected.to be_a DateTime } + it { is_expected.to eq DateTime.parse("2021-10-26 21:45:51") } + end end describe "#power=" do