Skip to content

Commit

Permalink
upgrade dependencies, return valid timestamp of sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
luk4s committed Oct 20, 2024
1 parent afebe71 commit 0746349
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.2
3.3.4
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## [Unreleased]
### Added
- timestamp from atrea server
### Changed
- upgrade dependencies
- upgrade ruby version

## [2.2.0] - 2023-10-09
### Changed
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
107 changes: 49 additions & 58 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -59,69 +61,58 @@ 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)
simplecov (0.22.0)
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

Expand All @@ -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
4 changes: 2 additions & 2 deletions atrea_control.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
9 changes: 8 additions & 1 deletion lib/atrea_control/duplex/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,6 +39,10 @@ def power
current_power || values[:current_power]
end

def timestamp
@timestamp ||= values[:timestamp]
end

def preheating?
preheating || values[:preheating]
end
Expand All @@ -56,7 +62,7 @@ def power=(value)
end

def parsed
parser.values(read.body)
@parsed ||= parser.values(read.body)
end

def values
Expand All @@ -75,6 +81,7 @@ def as_json(_options = nil)
input_temperature: input_temperature,
preheating: preheating,
valid_for: valid_for,
timestamp: timestamp,
}
end

Expand Down
2 changes: 2 additions & 0 deletions lib/atrea_control/sensor_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/atrea_control/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module AtreaControl
VERSION = "2.2.0"
VERSION = "2.3.0"
end
7 changes: 7 additions & 0 deletions spec/atrea_control/duplex/unit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0746349

Please sign in to comment.