pliny 0.18.0 → 0.19.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
  SHA1:
3
- metadata.gz: 50ee2327594f7a24b91de1931315b9d56857a6db
4
- data.tar.gz: 19764f159ec7799e68d4d704ff679b2101eddf43
3
+ metadata.gz: d42dcfb555d6af54e5e87035c53d5fbb9de11cfe
4
+ data.tar.gz: 9b498dbf53638dbc04770f93df95614fffa59591
5
5
  SHA512:
6
- metadata.gz: 9c20a3261666622c51f92614f2c4c49bd3d169b34fed20f8359ba6647a45ed4fc5bdbde260127ea9f4d6dae66a909a80bf2cc756d28845900afed16449bc5838
7
- data.tar.gz: d29a0d1bf16fd8cc623b7ee302113cf61b131bab0d171fc41e96cef1703d6bc4c3b097b352b3b4c4b6ddb6f0a3ea88ba2fcb8fb5c4946da23f0d4e4fd4db3a4c
6
+ metadata.gz: 9d85fa248efc6f4e4de6d93107a312c9a67200033f633133985246e43603a1e749eefc1175185ea4d4ea1df8ec516d14ce554ea952513192e61190b29615d1fb
7
+ data.tar.gz: 0f96306f19f94bff354d95b0e4adf8f512aff8577a29fadb786fee3fc31e9462fe6c4f46b0285d27c952e9df78f7a7256d0a24eb83bfdb1422e98ab85ea26982
data/lib/pliny.rb CHANGED
@@ -16,7 +16,8 @@ require_relative "pliny/utils"
16
16
  require_relative "pliny/middleware/cors"
17
17
  require_relative "pliny/middleware/instruments"
18
18
  require_relative "pliny/middleware/request_id"
19
- require_relative "pliny/middleware/request_store"
19
+ require_relative "pliny/middleware/request_store/clear"
20
+ require_relative "pliny/middleware/request_store/seed"
20
21
  require_relative "pliny/middleware/rescue_errors"
21
22
  require_relative "pliny/middleware/versioning"
22
23
 
@@ -7,10 +7,7 @@ module Pliny::Middleware
7
7
  def call(env)
8
8
  start = Time.now
9
9
 
10
- request_ids = env["REQUEST_IDS"] ? env["REQUEST_IDS"].join(",") : nil
11
-
12
10
  data = {
13
- request_id: request_ids,
14
11
  instrumentation: true,
15
12
  method: env["REQUEST_METHOD"],
16
13
  path: env["PATH_INFO"]
@@ -0,0 +1,13 @@
1
+ module Pliny::Middleware::RequestStore
2
+ class Clear
3
+ def initialize(app, options={})
4
+ @app = app
5
+ @store = options[:store] || Pliny::RequestStore
6
+ end
7
+
8
+ def call(env)
9
+ @store.clear!
10
+ @app.call(env)
11
+ end
12
+ end
13
+ end
@@ -1,12 +1,11 @@
1
- module Pliny::Middleware
2
- class RequestStore
1
+ module Pliny::Middleware::RequestStore
2
+ class Seed
3
3
  def initialize(app, options={})
4
4
  @app = app
5
5
  @store = options[:store] || Pliny::RequestStore
6
6
  end
7
7
 
8
8
  def call(env)
9
- @store.clear!
10
9
  @store.seed(env)
11
10
  @app.call(env)
12
11
  end
data/lib/pliny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.18.0"
2
+ VERSION = "0.19.0"
3
3
  end
data/lib/template/Gemfile CHANGED
@@ -4,7 +4,7 @@ ruby "2.3.1"
4
4
  gem "multi_json"
5
5
  gem "oj"
6
6
  gem "pg"
7
- gem "pliny", "~> 0.18"
7
+ gem "pliny", "~> 0.19"
8
8
  gem "pry"
9
9
  gem "puma", "~> 2.16"
10
10
  gem "rack-ssl"
@@ -1,9 +1,10 @@
1
1
  Routes = Rack::Builder.new do
2
+ use Pliny::Middleware::RequestStore::Clear, store: Pliny::RequestStore
2
3
  use Pliny::Middleware::CORS
3
4
  use Pliny::Middleware::RequestID
5
+ use Pliny::Middleware::RequestStore::Seed, store: Pliny::RequestStore
4
6
  use Pliny::Middleware::Instruments
5
7
  use Pliny::Middleware::RescueErrors, raise: Config.raise_errors?
6
- use Pliny::Middleware::RequestStore, store: Pliny::RequestStore
7
8
  use Rack::Timeout,
8
9
  service_timeout: Config.timeout if Config.timeout > 0
9
10
  use Pliny::Middleware::Versioning,
@@ -20,6 +20,10 @@ describe Pliny::ErrorReporters do
20
20
  allow(reporter_double).to receive(:notify)
21
21
  end
22
22
 
23
+ after do
24
+ Pliny::ErrorReporters.error_reporters = []
25
+ end
26
+
23
27
  it "notifies rollbar" do
24
28
  notify_reporter
25
29
 
data/spec/metrics_spec.rb CHANGED
@@ -6,12 +6,17 @@ describe Pliny::Metrics do
6
6
  subject(:metrics) { Pliny::Metrics }
7
7
 
8
8
  before do
9
+ @stdout = Pliny.stdout
9
10
  Pliny.stdout = io
10
11
 
11
12
  allow(io).to receive(:print)
12
13
  allow(Config).to receive(:app_name).and_return('pliny')
13
14
  end
14
15
 
16
+ after do
17
+ Pliny.stdout = @stdout
18
+ end
19
+
15
20
  context "#count" do
16
21
  it "counts a single key with a default value" do
17
22
  metrics.count(:foo)
@@ -1,10 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Pliny::Middleware::RequestStore do
3
+ describe Pliny::Middleware::RequestStore::Clear do
4
4
  def app
5
5
  Rack::Builder.new do
6
6
  use Rack::Lint
7
- use Pliny::Middleware::RequestStore, store: Pliny::RequestStore
7
+ use Pliny::Middleware::RequestStore::Clear, store: Pliny::RequestStore
8
8
  run Sinatra.new {
9
9
  get "/" do
10
10
  "hi"
@@ -17,9 +17,4 @@ describe Pliny::Middleware::RequestStore do
17
17
  expect(Pliny::RequestStore).to receive(:clear!)
18
18
  get "/"
19
19
  end
20
-
21
- it "seeds the store" do
22
- expect(Pliny::RequestStore).to receive(:seed)
23
- get "/"
24
- end
25
20
  end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ describe Pliny::Middleware::RequestStore::Seed do
4
+ def app
5
+ Rack::Builder.new do
6
+ use Rack::Lint
7
+ use Pliny::Middleware::RequestStore::Seed, store: Pliny::RequestStore
8
+ run Sinatra.new {
9
+ get "/" do
10
+ "hi"
11
+ end
12
+ }
13
+ end
14
+ end
15
+
16
+ it "seeds the store" do
17
+ expect(Pliny::RequestStore).to receive(:seed)
18
+ get "/"
19
+ end
20
+ 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.18.0
4
+ version: 0.19.0
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: 2016-08-01 00:00:00.000000000 Z
12
+ date: 2016-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -365,7 +365,8 @@ files:
365
365
  - lib/pliny/middleware/cors.rb
366
366
  - lib/pliny/middleware/instruments.rb
367
367
  - lib/pliny/middleware/request_id.rb
368
- - lib/pliny/middleware/request_store.rb
368
+ - lib/pliny/middleware/request_store/clear.rb
369
+ - lib/pliny/middleware/request_store/seed.rb
369
370
  - lib/pliny/middleware/rescue_errors.rb
370
371
  - lib/pliny/middleware/versioning.rb
371
372
  - lib/pliny/request_store.rb
@@ -451,7 +452,8 @@ files:
451
452
  - spec/middleware/cors_spec.rb
452
453
  - spec/middleware/instruments_spec.rb
453
454
  - spec/middleware/request_id_spec.rb
454
- - spec/middleware/request_store_spec.rb
455
+ - spec/middleware/request_store/clear_spec.rb
456
+ - spec/middleware/request_store/seed_spec.rb
455
457
  - spec/middleware/rescue_errors_spec.rb
456
458
  - spec/middleware/versioning_spec.rb
457
459
  - spec/request_store_spec.rb