quelink-mg 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a0af54e62d43bd9f96b5c7484e1d7ba16baf9ff80d059df46f2115c2881d16f
4
- data.tar.gz: 893631f6758dbbecad9d30105a4b1dc31a39a1b110a7ca964ced515150badba1
3
+ metadata.gz: 156a74e9c90ed12d937afba89ed165d4c79f655b81158352aca3138962aeab2c
4
+ data.tar.gz: 5a3ec61486354ecfd8c359a8cc651b1c94f73eceba33164dedab67abc27ede56
5
5
  SHA512:
6
- metadata.gz: b18949ccbd99be47bce8d7d09c425d5a455992e747cb4f86745ef2291e4d3c6c09c944dcc8f260e654fa9d68df4d2e73b9bca63eecc37d02700e8c19be5dc3e7
7
- data.tar.gz: 0abbc95935c06ea5de36e285f3b3bb8edae223672d593c336009affdebfb6199929c7d1a655b40a7650a2a0fdcaf8d76ae7116d85372f006049c9ce0f9f6a8ce
6
+ metadata.gz: 873fca115ba479772b24a1f9cafce41112528c8fe5847a190e67a77cfb10e73b6aa4a0e14049178bb5b811be8e9e38d6d43defa0dd41cdb9d5f0313be2202b56
7
+ data.tar.gz: 15fb64bf910ce1ac9178535af37818f9c2482877db381df655b7412046189d28bb927cde60d8ac7f5839bc4514b2e068ef1532740766886dddbf9baf19d98bad
@@ -19,13 +19,23 @@ module QuelinkMg
19
19
  private
20
20
 
21
21
  def verify_params(acceptable_values, error)
22
+ required_values.each do |rv|
23
+ raise_error(rv, error) if @params.fetch(rv, nil).nil?
24
+ end
25
+
22
26
  acceptable_values.each do |k, v|
23
- next if v.include?(@params.fetch(k, nil))
27
+ value = @params.fetch(k, nil)
28
+
29
+ next if value.blank? || v.include?(value)
24
30
 
25
31
  raise_error(k, error)
26
32
  end
27
33
  end
28
34
 
35
+ def required_values
36
+ %i[password serial_number]
37
+ end
38
+
29
39
  def raise_error(type, error)
30
40
  raise error, "Wrong #{type}: #{@params}"
31
41
  end
data/pkg/quelink-mg.gem CHANGED
Binary file
data/quelink-mg.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'quelink-mg'
5
- s.version = '0.3.0'
5
+ s.version = '0.4.0'
6
6
  s.summary = 'Quelink devices command reader and writer'
7
7
  s.description = 'Quelink devices command reader and writer'
8
8
  s.authors = ['Stanislaw Zawadzki']
@@ -34,6 +34,16 @@ RSpec.describe QuelinkMg::At::Gtcfg do
34
34
  '300,2,0,20491231235959,0,0000,0,10,,,FFFF$'
35
35
  end
36
36
 
37
+ it 'creates message if some params available' do
38
+ params =
39
+ {
40
+ password: 'gl310m',
41
+ gps_on_need: 1,
42
+ serial_number: 'FFFF'
43
+ }
44
+ expect(described_class.new(params:).message).to eq 'AT+GTCFG=gl310m,,,,,1,,,,,,,,,,,,,,,,,,,FFFF$'
45
+ end
46
+
37
47
  it 'raises error on missing params' do
38
48
  expect { described_class.new(params: {}).message }.to raise_error(InvalidATGTCFGException)
39
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quelink-mg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislaw Zawadzki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2023-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport