timex_datalink_client 0.12.2 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04efc1048bf18dfffcca9859dc88248f834dad97074ca4e9c3f74ef3cc55d86a
4
- data.tar.gz: b8722c9865c6a148a38f0f041d26c1fbfbfb729984500f3e8354693c4213b85e
3
+ metadata.gz: 6e16031b6fb7be30fcf5e298caff20e113ecd967a50e1e17ea91c4b2481024df
4
+ data.tar.gz: ba659cd2a69837466c6d7941dd8f7e8a9f9fecd9b0cd9cdfafebcc05b4e8bc93
5
5
  SHA512:
6
- metadata.gz: 6345d5eab984a5898f0b0630cbac1149e0ccabc01f26df7533d90ff0b477c27cfaed51274c421f11f6867e070d72fa39530971d4703cf3d2afb83bd79b9439b1
7
- data.tar.gz: e8f1f6773e5b3d0fef20da0ec0fd695510f93d902c37e5bf8bf9ce1efd03e822cde0fe69224dc5881e4d33d812ab210db841df829c90be8c1eebe31c3f7630d4
6
+ metadata.gz: e0f3d7c37ded477f631813a1f09f0c069ca55c54432b292a5a60bd73a6cd37c3f0983b6236ac062215445ba34583d3ac31aa5c779cd66572f422bd0f99bc6942
7
+ data.tar.gz: be703b74bc4fa90993fcf8bcc81ec978b6022b9e6846a347c491d8750de36269e42d4fbf4994150ec59ec9ef7e0d805086459a1d07263bde82e5afab1e6419be
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "serialport"
3
+ require "uart"
4
4
 
5
5
  class TimexDatalinkClient
6
6
  class NotebookAdapter
@@ -28,25 +28,21 @@ class TimexDatalinkClient
28
28
  # @param packets [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
29
29
  # @return [void]
30
30
  def write(packets)
31
- packets.each do |packet|
32
- packet.each do |byte|
33
- printf("%.2X ", byte) if verbose
31
+ UART.open(serial_device) do |serial_port|
32
+ packets.each do |packet|
33
+ packet.each do |byte|
34
+ printf("%.2X ", byte) if verbose
34
35
 
35
- serial_port.write(byte.chr)
36
+ serial_port.write(byte.chr)
36
37
 
37
- sleep(byte_sleep)
38
- end
38
+ sleep(byte_sleep)
39
+ end
39
40
 
40
- sleep(packet_sleep)
41
+ sleep(packet_sleep)
41
42
 
42
- puts if verbose
43
+ puts if verbose
44
+ end
43
45
  end
44
46
  end
45
-
46
- private
47
-
48
- def serial_port
49
- @serial_port ||= SerialPort.new(serial_device)
50
- end
51
47
  end
52
48
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_model"
4
+
3
5
  require "timex_datalink_client/helpers/lsb_msb_formatter"
4
6
 
5
7
  class TimexDatalinkClient
@@ -7,16 +9,23 @@ class TimexDatalinkClient
7
9
  class Eeprom
8
10
  class Calendar
9
11
  class Event
12
+ include ActiveModel::Validations
10
13
  include Helpers::LsbMsbFormatter
11
14
 
12
15
  FIVE_MINUTES_SECONDS = 300
13
16
 
14
- attr_accessor :time, :phrase
17
+ validates :time, comparison: {
18
+ greater_than_or_equal_to: :device_time,
19
+ message: "%{value} must be greater or equal to device time!"
20
+ }
21
+
22
+ attr_accessor :time, :phrase, :device_time
15
23
 
16
24
  # Create an Event instance.
17
25
  #
18
26
  # @param time [::Time] Time of event.
19
27
  # @param phrase [Array<Integer>] Phrase for event.
28
+ # @raise [ActiveModel::ValidationError] One or more model values are invalid.
20
29
  # @return [Event] Event instance.
21
30
  def initialize(time:, phrase:)
22
31
  @time = time
@@ -24,6 +33,10 @@ class TimexDatalinkClient
24
33
  end
25
34
 
26
35
  def time_formatted(device_time)
36
+ @device_time = device_time
37
+
38
+ validate!
39
+
27
40
  device_time_midnight = Time.new(device_time.year, device_time.month, device_time.day)
28
41
  seconds = (time - device_time_midnight).to_i
29
42
  five_minutes = seconds / FIVE_MINUTES_SECONDS
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TimexDatalinkClient
4
- VERSION = "0.12.2"
4
+ VERSION = "0.12.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timex_datalink_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxwell Pray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-27 00:00:00.000000000 Z
11
+ date: 2025-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.5.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: serialport
56
+ name: uart
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.3.2
61
+ version: 1.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3.2
68
+ version: 1.0.0
69
69
  description:
70
70
  email: synthead@gmail.com
71
71
  executables: []
@@ -150,7 +150,7 @@ files:
150
150
  - lib/timex_datalink_client/protocol_9/time_name.rb
151
151
  - lib/timex_datalink_client/protocol_9/timer.rb
152
152
  - lib/timex_datalink_client/version.rb
153
- homepage: https://github.com/synthead/timex_datalink_client/tree/v0.12.2
153
+ homepage: https://github.com/synthead/timex_datalink_client/tree/v0.12.4
154
154
  licenses:
155
155
  - MIT
156
156
  metadata: {}
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: '0'
165
+ version: 3.1.0
166
166
  required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  requirements:
168
168
  - - ">="