gatekeeper_api_client 1.0.0 → 1.1.0

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: 9bbeca19cfee61257aa8fa4dea9cc09e371da8240c97821723ccda148e552ddc
4
- data.tar.gz: d9782808bedfa188148d7d44e0d53d53bb365cba3d33387a3dbe84bca5d92ccf
3
+ metadata.gz: 1d9b20bd2b992c579069eb699d9d7c40a83799c9739e912e9f43055a78c0e67a
4
+ data.tar.gz: 2ddf2106753c80d179f485272410975df40b902b6cd2bf75a78a47f2c9c9fb0c
5
5
  SHA512:
6
- metadata.gz: c545e300c3b2d004897be956516f2077d4593a5b68c0a8469269e509430037a5d701d5c7cbe5b930d31ff78ff7dd06631d49670f88c74f2b0bdf499a4b4a1f76
7
- data.tar.gz: d63eed0e59cfcb27d32579522a1585b3e6c47e36205810b7973eef8e85d844b94199550290e3f93cf7b30d9df9e9742e02d00f46ca08fe56f374f566e10a18fc
6
+ metadata.gz: 2816c70a73798ce585ce70de29f7ad31f069f8a6eaccbef60a1183d0eff2693834a9e3aa085efeee772bbabe21c85d4a2d6a240194292c65428e104f653b1167
7
+ data.tar.gz: 909b70b4b0ba0551ca8c39aae6e941ab8b3ba5405e392ba56876772d8b1b7deda780ecd189dde1d2505c17d0fc15125adc338c68ca0772a85dde7775cb8f96b2
@@ -11,7 +11,6 @@ jobs:
11
11
  build:
12
12
  # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
13
13
  runs-on: ubuntu-22.04
14
- if: "! contains(github.event.head_commit.message, 'skip ci')"
15
14
 
16
15
  steps:
17
16
  - uses: actions/checkout@v3
data/.gitignore CHANGED
@@ -8,4 +8,7 @@
8
8
  /tmp/
9
9
 
10
10
  # rspec failure tracking
11
- .rspec_status
11
+ .rspec_status
12
+
13
+ # Gem files
14
+ *.gem
data/GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gatekeeper_api_client (1.0.0)
4
+ gatekeeper_api_client (1.1.0)
5
5
  rollbar (~> 3.6)
6
6
  tzinfo (~> 2.0)
7
7
  tzinfo-data (~> 1.2025)
data/README.md CHANGED
@@ -3,17 +3,13 @@ Common logic for consuming the GateKeeper API.
3
3
 
4
4
  ## Installation
5
5
  Add this line to your application's Gemfile:
6
- ```
7
- source "https://rubygems.pkg.github.com/inforlife" do
8
- gem "gatekeeper_api_client", "1.0.0"
9
- end
6
+ ```gem "gatekeeper_api_client", "1.1.0"
10
7
  ```
11
8
 
12
9
  ## Usage
13
- The application using this gem must have defined the following environemnt variables:
14
- - `GATEKEEPER_API_KEY`
15
- - `GATEKEEPER_TIMEZONE`
16
- - `GATEKEEPER_URL`
10
+ The application using this gem must have defined the following environment variables:
11
+ - `GATEKEEPER_API_KEY`: The authentication key.
12
+ - `GATEKEEPER_URL`: The URL to post data.
17
13
 
18
14
  ### Transit
19
15
  To post a `transit`, build an object with a record and send the `post` message to it.
@@ -23,12 +19,11 @@ Transit.new(record).post
23
19
  ```
24
20
 
25
21
  The record must respond to:
26
- - `authorized`
27
- - `badge_number`
28
- - `date`
29
- - `sensor_code`
30
- - `time`
31
- - `valid?`
22
+ - `authorized` returns a string.
23
+ - `badge_number` returns a string.
24
+ - `sensor_code` returns a string.
25
+ - `time` returns a Time (with Timezone) object.
26
+ - `valid?` returns a boolean,
32
27
 
33
28
  ### Employee
34
29
  To post an `employee`, build an object with a record and send the `post` message to it.
@@ -38,7 +33,7 @@ Employee.new(record).post
38
33
  ```
39
34
 
40
35
  The record must respond to:
41
- - `employee_name`
42
- - `badge_number`
43
- - `department_name`
44
- - `valid?`
36
+ - `employee_name` returns a string.
37
+ - `badge_number` returns a string.
38
+ - `department_name` returns a string.
39
+ - `valid?` returns a boolean.
@@ -1,2 +1,5 @@
1
1
  class ClientError < StandardError
2
+ def initialize(code, body)
3
+ super([Net::HTTPResponse::CODE_TO_OBJ[code], body].join(" | "))
4
+ end
2
5
  end
@@ -18,6 +18,6 @@ class Gateway
18
18
 
19
19
  response = http.request(request)
20
20
 
21
- raise ClientError, response.body if Integer(response.code) != 201
21
+ raise ClientError.new(response.code, response.body) if Integer(response.code) != 201
22
22
  end
23
23
  end
@@ -6,7 +6,7 @@ class Transit < Resource
6
6
  def to_json
7
7
  {"transit":
8
8
  {
9
- "occurred_at": UtcTime.parse(@record.date, @record.time),
9
+ "occurred_at": @record.time.utc,
10
10
  "badge_number": @record.badge_number,
11
11
  "sensor_code": @record.sensor_code,
12
12
  "authorized": @record.authorized == "1"
@@ -11,6 +11,7 @@ class RetryingGateway < DelegateClass(Gateway)
11
11
  retry
12
12
  else
13
13
  @error_handler.call(error)
14
+ raise
14
15
  end
15
16
  end
16
17
  end
@@ -7,7 +7,6 @@ require "gatekeeper_api_client/client_error"
7
7
  require "gatekeeper_api_client/error_handler"
8
8
  require "gatekeeper_api_client/gateway"
9
9
  require "gatekeeper_api_client/retrying_gateway"
10
- require "gatekeeper_api_client/utc_time"
11
10
 
12
11
  require "gatekeeper_api_client/resources/resource"
13
12
  require "gatekeeper_api_client/resources/employee"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gatekeeper_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sigfrid Dusci
@@ -119,7 +119,6 @@ files:
119
119
  - lib/gatekeeper_api_client/resources/resource.rb
120
120
  - lib/gatekeeper_api_client/resources/transit.rb
121
121
  - lib/gatekeeper_api_client/retrying_gateway.rb
122
- - lib/gatekeeper_api_client/utc_time.rb
123
122
  homepage: https://github.com/inforlife/gatekeeper-api-client
124
123
  licenses:
125
124
  - MIT
@@ -1,12 +0,0 @@
1
- class UtcTime
2
- def self.parse(record_date, record_time)
3
- date = record_date.tr('.', '-')
4
- time = record_time.tr('.', ':')
5
-
6
- timezone.local_to_utc(Time.parse([date, time].join(" ")))
7
- end
8
-
9
- def self.timezone
10
- TZInfo::Timezone.get(ENV["GATEKEEPER_TIMEZONE"])
11
- end
12
- end