pliny 0.6.2 → 0.6.3

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: 80f7798798dae08063fe4342597451263c19d327
4
- data.tar.gz: 311315ca6d6dc5490edbdb0db1be00e2b871f76f
3
+ metadata.gz: 004648bb41bd9b42b488da08c6bfb88c511cb9e9
4
+ data.tar.gz: 028e79c785b698a736c844f55b7d6b893c981fc8
5
5
  SHA512:
6
- metadata.gz: e191efaa8f571017d1be9a75ce8204264cedf3222e7ecb48ccb41f436aad6c8f61830e50d6c06853de35c37a25b6bb6844ce149921cc813cfbc5f72aabb1562e
7
- data.tar.gz: 9e893cca95172aabfdfa2860873c529685c896bc9a0bad477ac08928c2bd009b7ba9b16e10e7a181351187c59ae20f944a71f0c2544bb97fc9d1e791408e220a
6
+ metadata.gz: c8f55bc31871bd47ad2097ef2ab00810d117c9a3b132099e78177749fa7dfcd6103d8c71aacd0f42e8872facd17659e8779901d3a7eea590c237d308a0903477
7
+ data.tar.gz: b5320ef0938d9ace02977eb8639e70be0957ac2df3bc1d66f463143a95449555fd2011c1dd65b5693331f06cf27c29052ed18707c1ae45f60a6434b79a6f6d75
@@ -7,7 +7,7 @@ module Pliny::Helpers
7
7
  private
8
8
 
9
9
  def parse_body_params
10
- if request.content_type == "application/json"
10
+ if request.media_type == "application/json"
11
11
  p = indifferent_params(MultiJson.decode(request.body.read))
12
12
  request.body.rewind
13
13
  p
@@ -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}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\Z/
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
- if env["HTTP_REQUEST_ID"]
35
- request_ids = env["HTTP_REQUEST_ID"].split(",")
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
@@ -18,11 +18,11 @@ module Endpoints
18
18
  encode Hash.new
19
19
  end
20
20
 
21
- patch "/:id" do |id|
21
+ patch "/:id" do
22
22
  encode Hash.new
23
23
  end
24
24
 
25
- delete "/:id" do |id|
25
+ delete "/:id" do
26
26
  encode Hash.new
27
27
  end
28
28
  end
data/lib/pliny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
data/lib/template/Gemfile CHANGED
@@ -4,9 +4,8 @@ ruby "2.2.0"
4
4
  gem "multi_json"
5
5
  gem "oj"
6
6
  gem "pg"
7
- gem "pliny", "~> 0.5"
7
+ gem "pliny", "~> 0.6"
8
8
  gem "pry"
9
- gem "pry-doc"
10
9
  gem "puma", "~> 2.10"
11
10
  gem "rack-ssl"
12
11
  gem "rake"
@@ -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, 45, int
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
@@ -16,7 +16,7 @@ module Endpoints
16
16
  also_reload '../**/*.rb'
17
17
  end
18
18
 
19
- not_found do
19
+ error Sinatra::NotFound do
20
20
  content_type :json
21
21
  status 404
22
22
  "{}"
@@ -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.2
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-01-19 00:00:00.000000000 Z
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.6.1
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.6.1
87
+ version: 0.7.0
88
88
  - !ruby/object:Gem::Dependency
89
89
  name: sequel
90
90
  requirement: !ruby/object:Gem::Requirement