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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91060765e2db9b3bda7305d9e35365c019402fdc
4
- data.tar.gz: f69a1dffa54c696d0d6e29990b15c57dde489fa3
3
+ metadata.gz: 786d218c02c6f8d91065e156d7b6d1f417870fb6
4
+ data.tar.gz: 3f9fb43095603359294a611e5ceda12214a39a55
5
5
  SHA512:
6
- metadata.gz: 021d3256f1411a92381614f8e9e00d3eae892b6336e5c5e81ac8c0a54262d333a92c94fd63df9f24809e89d2940ffdd5c9573d2b2bbf3adf654e66534b5466c8
7
- data.tar.gz: cc65834d3daebe8fc759971de1e440e013b572d2aa0152f8ac31c0a86f939f1af0c8e9557b97aa55885b5e1877c34a958ed900370878cd6aad52c09c0c091803
6
+ metadata.gz: e5dbe147241c25a0e2f55a6abbb6ec320d0f0e0f7146a6adec0c40ad474d4c4fd0ec528e0bfbfc4dab9fbc5cb6abe3ef081152f219cd7cee05bbeee95c9b54bf
7
+ data.tar.gz: 28d1dae5fc3242317d06a335a961718439aa28b54ba4b2f7f0980f03ff250d006c5ea6b9f85a3309cd2fb347a5cb27db4965fb6873b5f1a7f21e66ab638bbba9
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.2.0
7
+ - ruby-head
data/README.md CHANGED
@@ -1,10 +1,15 @@
1
1
  # Loginator
2
2
 
3
+ [![Code Climate](https://codeclimate.com/github/gray-industries/loginator/badges/gpa.svg)](https://codeclimate.com/github/gray-industries/loginator)
4
+ [![Build Status](https://travis-ci.org/gray-industries/loginator.svg)](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'
@@ -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] (SecureRandom.uuid) Unique identifier for the request
16
- # @param timestamp [Integer] (Time.now.utc.to_i) Time of the request
17
- # @param path [String] (nil) Path associated with the request
18
- # @param params [String] ({}) Parameters of the request
19
- def initialize(request_id = SecureRandom.uuid, timestamp = Time.now.utc.to_i, path = nil, params = {})
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
@@ -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] request_id (SecureRandom.uuid) Unique identifier for the request
17
- # @param [Integer] timestamp (Time.now.utc.to_i) Time of the request
18
- # @param [String] path (nil) Path associated with the request
19
- # @param [Integer] status (0) Status returned to the requester
20
- # @param [String] body ({}) Parameters of the request
21
- def initialize(request_id = SecureRandom.uuid, timestamp = Time.now.utc.to_i, path = nil, status = 0, body = '')
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
@@ -1,4 +1,4 @@
1
1
  # Increment when releasing.
2
2
  module Loginator
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
@@ -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(Integer)
14
- expect(subject.timestamp).to be <= Time.now.utc.to_i
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.3
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-12 00:00:00.000000000 Z
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