loginator 0.0.3 → 0.0.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 +4 -4
- data/.travis.yml +7 -0
- data/README.md +5 -0
- data/lib/loginator/request.rb +7 -5
- data/lib/loginator/response.rb +8 -6
- data/lib/loginator/transaction.rb +14 -0
- data/lib/loginator/version.rb +1 -1
- data/spec/support/shared/lib/loginator/struct_with_defaults_spec.rb +3 -3
- metadata +4 -3
- data/loginator.reek +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 786d218c02c6f8d91065e156d7b6d1f417870fb6
|
4
|
+
data.tar.gz: 3f9fb43095603359294a611e5ceda12214a39a55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5dbe147241c25a0e2f55a6abbb6ec320d0f0e0f7146a6adec0c40ad474d4c4fd0ec528e0bfbfc4dab9fbc5cb6abe3ef081152f219cd7cee05bbeee95c9b54bf
|
7
|
+
data.tar.gz: 28d1dae5fc3242317d06a335a961718439aa28b54ba4b2f7f0980f03ff250d006c5ea6b9f85a3309cd2fb347a5cb27db4965fb6873b5f1a7f21e66ab638bbba9
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# Loginator
|
2
2
|
|
3
|
+
[](https://codeclimate.com/github/gray-industries/loginator)
|
4
|
+
[](https://travis-ci.org/gray-industries/loginator)
|
5
|
+
|
3
6
|
Loginator is a gem for standardizing the logging of requests and responses for
|
4
7
|
remote APIs.
|
5
8
|
|
6
9
|
## Installation
|
7
10
|
|
11
|
+
Requires Ruby >= 2.0
|
12
|
+
|
8
13
|
Add this line to your application's Gemfile:
|
9
14
|
|
10
15
|
gem 'loginator'
|
data/lib/loginator/request.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'multi_json'
|
2
2
|
require 'loginator/jsonable_struct'
|
3
|
+
require 'loginator/transaction'
|
3
4
|
|
4
5
|
# Loginator::Request
|
5
6
|
module Loginator
|
@@ -10,13 +11,14 @@ module Loginator
|
|
10
11
|
#
|
11
12
|
Request = Struct.new(:request_id, :timestamp, :path, :params) do
|
12
13
|
include Loginator::JsonableStruct
|
14
|
+
include Loginator::Transaction
|
13
15
|
|
14
16
|
# Create a new Loginator::Request
|
15
|
-
# @param request_id [String]
|
16
|
-
# @param timestamp [
|
17
|
-
# @param path [String]
|
18
|
-
# @param params [String]
|
19
|
-
def initialize(request_id =
|
17
|
+
# @param request_id [String] (SecureRandom.uuid) Unique identifier for the request
|
18
|
+
# @param timestamp [Float] (Time.now.utc.to_f) Time of the request
|
19
|
+
# @param path [String] (nil) Path associated with the request
|
20
|
+
# @param params [String] ({}) Parameters of the request
|
21
|
+
def initialize(request_id = uuid, timestamp = format_time, path = nil, params = {})
|
20
22
|
super
|
21
23
|
end
|
22
24
|
end
|
data/lib/loginator/response.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'multi_json'
|
2
2
|
require 'loginator/jsonable_struct'
|
3
|
+
require 'loginator/transaction'
|
3
4
|
|
4
5
|
# Loginator::Response
|
5
6
|
module Loginator
|
@@ -11,14 +12,15 @@ module Loginator
|
|
11
12
|
#
|
12
13
|
Response = Struct.new(:request_id, :timestamp, :path, :status, :body) do
|
13
14
|
include Loginator::JsonableStruct
|
15
|
+
include Loginator::Transaction
|
14
16
|
|
15
17
|
# Create a new Loginator::Response
|
16
|
-
# @param [String]
|
17
|
-
# @param [
|
18
|
-
# @param [String]
|
19
|
-
# @param [Integer]
|
20
|
-
# @param [String]
|
21
|
-
def initialize(request_id =
|
18
|
+
# @param request_id [String] (SecureRandom.uuid) Unique identifier for the request
|
19
|
+
# @param timestamp [Float] (Time.now.utc.to_f) Time of the request
|
20
|
+
# @param path [String] (nil) Path associated with the request
|
21
|
+
# @param status [Integer] (0) Status returned to the requester
|
22
|
+
# @param body [String] ({}) Parameters of the request
|
23
|
+
def initialize(request_id = uuid, timestamp = format_time, path = nil, status = 0, body = '')
|
22
24
|
super
|
23
25
|
end
|
24
26
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Loginator
|
2
|
+
# Methods for generating transactional metadata.
|
3
|
+
module Transaction
|
4
|
+
# Generate a UUID for this transaction.
|
5
|
+
def uuid
|
6
|
+
SecureRandom.uuid
|
7
|
+
end
|
8
|
+
|
9
|
+
# Format the time as a float.
|
10
|
+
def format_time
|
11
|
+
Time.now.utc.to_f
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/loginator/version.rb
CHANGED
@@ -10,9 +10,9 @@ shared_examples_for 'struct_with_defaults' do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'sets default timestamp' do
|
13
|
-
expect(subject.timestamp).to be_a_kind_of(
|
14
|
-
expect(subject.timestamp).to be <= Time.now.utc.
|
15
|
-
expect(subject.timestamp).to be > 0
|
13
|
+
expect(subject.timestamp).to be_a_kind_of(Float)
|
14
|
+
expect(subject.timestamp).to be <= Time.now.utc.to_f
|
15
|
+
expect(subject.timestamp).to be > 0.0
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loginator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Poirier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -259,6 +259,7 @@ files:
|
|
259
259
|
- ".metrics"
|
260
260
|
- ".rspec"
|
261
261
|
- ".rubocop.yml"
|
262
|
+
- ".travis.yml"
|
262
263
|
- Gemfile
|
263
264
|
- Guardfile
|
264
265
|
- README.md
|
@@ -269,9 +270,9 @@ files:
|
|
269
270
|
- lib/loginator/jsonable_struct.rb
|
270
271
|
- lib/loginator/request.rb
|
271
272
|
- lib/loginator/response.rb
|
273
|
+
- lib/loginator/transaction.rb
|
272
274
|
- lib/loginator/version.rb
|
273
275
|
- loginator.gemspec
|
274
|
-
- loginator.reek
|
275
276
|
- spec/acceptance/lib/loginator/.gitignore
|
276
277
|
- spec/fixtures.rb
|
277
278
|
- spec/fixtures/.gitignore
|
data/loginator.reek
DELETED
File without changes
|