pliny 0.26.1 → 0.26.2

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: e4adaaedbebc3ae5352103ddadbf1f85ee0ea368
4
- data.tar.gz: d0c837f014f54d02eb7cc28903fdec073502564b
3
+ metadata.gz: 0674c9e51c614274d0723faf5909baaf3bd30ae0
4
+ data.tar.gz: cc4c3a90ffec075c45faec036c20e7c2952c8841
5
5
  SHA512:
6
- metadata.gz: f50ff132e89a39ca8d28c9e873dd3f85a9d4fb2210fda66eaa7634af7a4a4647db0e5e158554add566dbdea69400c70332317153e45aa945315466a9b64ea58a
7
- data.tar.gz: 88082d4d62b2b4b6e59011dfa22420f942242990fe32256be729f91400b5b5ab6d92035353c710053a82977db99dfc5929eccc7f0eca4bea1fe9488e05b21ac8
6
+ metadata.gz: 96e3f87b327e5f1dde9d38ac1c650c97c2444e150d7e517f7fc8ff3969f8809f129608441b7ba4f0b7eba68e157cc3dc13699edf8a56fe10dd24d27a8d350c42
7
+ data.tar.gz: c715b6fd2f04af1869549d7999c1f2f0f79990a9f9e0eeb6de1b47b73f6895d7ebea913f5277f67988ab5c8b5a2bd58273feb6bd4fe5f919eef38854aeb98393
@@ -8,6 +8,7 @@ require_relative "pliny/errors"
8
8
  require_relative "pliny/helpers/encode"
9
9
  require_relative "pliny/helpers/params"
10
10
  require_relative "pliny/helpers/serialize"
11
+ require_relative "pliny/helpers/zulu_time"
11
12
  require_relative "pliny/log"
12
13
  require_relative "pliny/metrics/backends/logger"
13
14
  require_relative "pliny/metrics"
@@ -21,6 +21,7 @@ module Pliny
21
21
  scope = { custom: context }
22
22
  unless rack_env.empty?
23
23
  scope[:request] = proc { extract_request_data_from_rack(rack_env) }
24
+ scope[:person] = proc { extract_person_data_from_controller(rack_env) }
24
25
  end
25
26
  scope
26
27
  rescue Exception => e
@@ -0,0 +1,7 @@
1
+ module Pliny::Helpers
2
+ module ZuluTime
3
+ def zulu_time(time)
4
+ time ? time.getutc.strftime("%Y-%m-%dT%H:%M:%SZ") : nil
5
+ end
6
+ end
7
+ end
@@ -10,9 +10,9 @@
10
10
  <%= ident %>class <%= modules.last %> < Serializers::Base
11
11
  <%= ident %> structure(:default) do |arg|
12
12
  <%= ident %> {
13
- <%= ident %> created_at: arg.created_at.try(:iso8601),
13
+ <%= ident %> created_at: zulu_time(arg.created_at),
14
14
  <%= ident %> id: arg.id,
15
- <%= ident %> updated_at: arg.updated_at.try(:iso8601),
15
+ <%= ident %> updated_at: zulu_time(arg.updated_at)
16
16
  <%= ident %> }
17
17
  <%= ident %> end
18
18
  <%= ident %>end
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.26.1"
2
+ VERSION = "0.26.2"
3
3
  end
@@ -1,5 +1,7 @@
1
1
  module Serializers
2
2
  class Base
3
+ extend Pliny::Helpers::ZuluTime
4
+
3
5
  @@structures = {}
4
6
 
5
7
  def self.structure(type, &blk)
@@ -33,6 +33,24 @@ describe Pliny::ErrorReporters::Rollbar do
33
33
  ))
34
34
  end
35
35
 
36
+ context "given a rack_env with person data" do
37
+ let(:rack_env) do
38
+ { "rollbar.person_data" => {
39
+ id: SecureRandom.uuid,
40
+ email: "foo@bar.com",
41
+ username: "foo"
42
+ }}
43
+ end
44
+
45
+ it "adds person to the rollbar notification" do
46
+ scope = nil
47
+ allow(::Rollbar).to receive(:scoped) { |arg| scope = arg }
48
+ notify
49
+ assert_kind_of(Proc, scope[:person])
50
+ assert_equal(rack_env["rollbar.person_data"], scope[:person].call)
51
+ end
52
+ end
53
+
36
54
  it "delegates to #report_exception_to_rollbar" do
37
55
  notify
38
56
  expect(reporter).to have_received(:report_exception_to_rollbar)
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+ require "active_support/core_ext/numeric/time"
3
+
4
+ describe Pliny::Helpers::ZuluTime do
5
+ context "zulu_time" do
6
+ class ZuluTimeTest
7
+ extend Pliny::Helpers::ZuluTime
8
+ end
9
+
10
+ it "it formats Time instances" do
11
+ formatted = ZuluTimeTest.zulu_time(Time.parse("2017-11-28T21:49:52.123+00:00"))
12
+ assert_equal "2017-11-28T21:49:52Z", formatted
13
+ end
14
+
15
+ it "it formats DateTime instances" do
16
+ formatted = ZuluTimeTest.zulu_time(DateTime.parse("2017-11-28T21:49:52.123+00:00"))
17
+ assert_equal "2017-11-28T21:49:52Z", formatted
18
+ end
19
+
20
+ it "when called with nil" do
21
+ assert_nil ZuluTimeTest.zulu_time(nil)
22
+ end
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pliny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.1
4
+ version: 0.26.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur Leach
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-04 00:00:00.000000000 Z
12
+ date: 2017-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -395,6 +395,7 @@ files:
395
395
  - lib/pliny/helpers/encode.rb
396
396
  - lib/pliny/helpers/params.rb
397
397
  - lib/pliny/helpers/serialize.rb
398
+ - lib/pliny/helpers/zulu_time.rb
398
399
  - lib/pliny/log.rb
399
400
  - lib/pliny/metrics.rb
400
401
  - lib/pliny/metrics/backends/logger.rb
@@ -490,6 +491,7 @@ files:
490
491
  - spec/helpers/encode_spec.rb
491
492
  - spec/helpers/params_spec.rb
492
493
  - spec/helpers/serialize_spec.rb
494
+ - spec/helpers/zulu_time_spec.rb
493
495
  - spec/integration_spec.rb
494
496
  - spec/log_spec.rb
495
497
  - spec/metrics/backends/logger_spec.rb