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 +4 -4
- data/lib/pliny.rb +2 -1
- data/lib/pliny/middleware/instruments.rb +0 -3
- data/lib/pliny/middleware/request_store/clear.rb +13 -0
- data/lib/pliny/middleware/{request_store.rb → request_store/seed.rb} +2 -3
- data/lib/pliny/version.rb +1 -1
- data/lib/template/Gemfile +1 -1
- data/lib/template/lib/routes.rb +2 -1
- data/spec/error_reporters_spec.rb +4 -0
- data/spec/metrics_spec.rb +5 -0
- data/spec/middleware/{request_store_spec.rb → request_store/clear_spec.rb} +2 -7
- data/spec/middleware/request_store/seed_spec.rb +20 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d42dcfb555d6af54e5e87035c53d5fbb9de11cfe
|
4
|
+
data.tar.gz: 9b498dbf53638dbc04770f93df95614fffa59591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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"]
|
@@ -1,12 +1,11 @@
|
|
1
|
-
module Pliny::Middleware
|
2
|
-
class
|
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
data/lib/template/Gemfile
CHANGED
data/lib/template/lib/routes.rb
CHANGED
@@ -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,
|
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.
|
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-
|
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/
|
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
|