pliny 0.6.2 → 0.6.3
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/lib/pliny/helpers/params.rb +1 -1
- data/lib/pliny/middleware/request_id.rb +23 -7
- data/lib/pliny/templates/endpoint.erb +2 -2
- data/lib/pliny/version.rb +1 -1
- data/lib/template/Gemfile +1 -2
- data/lib/template/config/config.rb +1 -1
- data/lib/template/lib/endpoints/base.rb +1 -1
- data/lib/template/spec/support/auto_define_rack_app.rb +1 -1
- data/spec/commands/generator_spec.rb +10 -3
- data/spec/middleware/request_id_spec.rb +7 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 004648bb41bd9b42b488da08c6bfb88c511cb9e9
|
4
|
+
data.tar.gz: 028e79c785b698a736c844f55b7d6b893c981fc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8f55bc31871bd47ad2097ef2ab00810d117c9a3b132099e78177749fa7dfcd6103d8c71aacd0f42e8872facd17659e8779901d3a7eea590c237d308a0903477
|
7
|
+
data.tar.gz: b5320ef0938d9ace02977eb8639e70be0957ac2df3bc1d66f463143a95449555fd2011c1dd65b5693331f06cf27c29052ed18707c1ae45f60a6434b79a6f6d75
|
data/lib/pliny/helpers/params.rb
CHANGED
@@ -2,8 +2,14 @@
|
|
2
2
|
|
3
3
|
module Pliny::Middleware
|
4
4
|
class RequestID
|
5
|
+
# note that this pattern supports either a full UUID, or a "squashed" UUID
|
6
|
+
# like the kind Hermes sends:
|
7
|
+
#
|
8
|
+
# full: 01234567-89ab-cdef-0123-456789abcdef
|
9
|
+
# squashed: 0123456789abcdef0123456789abcdef
|
10
|
+
#
|
5
11
|
UUID_PATTERN =
|
6
|
-
/\A[a-f0-9]{8}
|
12
|
+
/\A[a-f0-9]{8}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{12}\Z/
|
7
13
|
|
8
14
|
def initialize(app)
|
9
15
|
@app = app
|
@@ -30,13 +36,23 @@ module Pliny::Middleware
|
|
30
36
|
private
|
31
37
|
|
32
38
|
def extract_request_ids(env)
|
33
|
-
request_ids =
|
34
|
-
|
35
|
-
|
36
|
-
request_ids.map! { |id| id.strip }
|
37
|
-
request_ids.select! { |id| id =~ UUID_PATTERN }
|
38
|
-
end
|
39
|
+
request_ids = raw_request_ids(env)
|
40
|
+
request_ids.map! { |id| id.strip }
|
41
|
+
request_ids.select! { |id| id =~ UUID_PATTERN }
|
39
42
|
request_ids
|
40
43
|
end
|
44
|
+
|
45
|
+
def raw_request_ids(env)
|
46
|
+
# We had a little disagreement around the inception of the Request-Id
|
47
|
+
# field as to whether it should be prefixed with `X-` or not. API went
|
48
|
+
# with no prefix, but Hermes went with one. Support both formats on
|
49
|
+
# input.
|
50
|
+
%w(HTTP_REQUEST_ID HTTP_X_REQUEST_ID).inject([]) do |request_ids, key|
|
51
|
+
if ids = env[key]
|
52
|
+
request_ids += ids.split(",")
|
53
|
+
end
|
54
|
+
request_ids
|
55
|
+
end
|
56
|
+
end
|
41
57
|
end
|
42
58
|
end
|
data/lib/pliny/version.rb
CHANGED
data/lib/template/Gemfile
CHANGED
@@ -27,7 +27,7 @@ module Config
|
|
27
27
|
override :rack_env, 'development', string
|
28
28
|
override :raise_errors, false, bool
|
29
29
|
override :root, File.expand_path("../../", __FILE__), string
|
30
|
-
override :timeout,
|
30
|
+
override :timeout, 10, int
|
31
31
|
override :force_ssl, true, bool
|
32
32
|
override :versioning, false, bool
|
33
33
|
override :pretty_json, false, bool
|
@@ -1,7 +1,7 @@
|
|
1
1
|
RSpec.configure do |config|
|
2
2
|
config.before(:context) do |spec|
|
3
3
|
# weird ruby syntax, but test if the described_class inherits Sinatra::Base:
|
4
|
-
if !@rack_app && spec.described_class < Sinatra::Base
|
4
|
+
if !@rack_app && spec.described_class && spec.described_class < Sinatra::Base
|
5
5
|
@rack_app = spec.described_class
|
6
6
|
end
|
7
7
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pliny/commands/creator'
|
1
2
|
require 'pliny/commands/generator'
|
2
3
|
require 'pliny/commands/generator/base'
|
3
4
|
require 'spec_helper'
|
@@ -6,8 +7,6 @@ describe Pliny::Commands::Generator do
|
|
6
7
|
subject { Pliny::Commands::Generator.new }
|
7
8
|
|
8
9
|
before do
|
9
|
-
FileUtils.mkdir_p('/tmp/plinytest')
|
10
|
-
Dir.chdir('/tmp/plinytest')
|
11
10
|
Timecop.freeze(@t = Time.now)
|
12
11
|
|
13
12
|
any_instance_of(Pliny::Commands::Generator::Base) do |klass|
|
@@ -15,8 +14,16 @@ subject { Pliny::Commands::Generator.new }
|
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
17
|
+
around do |example|
|
18
|
+
Dir.mktmpdir do |dir|
|
19
|
+
app_dir = File.join(dir, "app")
|
20
|
+
# some generators depend on files seeded by the template
|
21
|
+
Pliny::Commands::Creator.run([app_dir], {}, StringIO.new)
|
22
|
+
Dir.chdir(app_dir, &example)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
18
26
|
after do
|
19
|
-
FileUtils.rmdir('/tmp/plinytest')
|
20
27
|
Timecop.return
|
21
28
|
end
|
22
29
|
|
@@ -25,4 +25,11 @@ describe Pliny::Middleware::RequestID do
|
|
25
25
|
get "/"
|
26
26
|
assert_includes last_response.body, id
|
27
27
|
end
|
28
|
+
|
29
|
+
it "accepts incoming request IDs with an `X-` prefix" do
|
30
|
+
id = SecureRandom.uuid
|
31
|
+
header "X-Request-Id", id
|
32
|
+
get "/"
|
33
|
+
assert_includes last_response.body, id
|
34
|
+
end
|
28
35
|
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.6.
|
4
|
+
version: 0.6.3
|
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: 2015-
|
12
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -75,16 +75,16 @@ dependencies:
|
|
75
75
|
name: prmd
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: 0.
|
80
|
+
version: 0.7.0
|
81
81
|
type: :runtime
|
82
82
|
prerelease: false
|
83
83
|
version_requirements: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: 0.
|
87
|
+
version: 0.7.0
|
88
88
|
- !ruby/object:Gem::Dependency
|
89
89
|
name: sequel
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|