pliny 0.0.4 → 0.1.0
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/README.md +1 -1
- data/lib/pliny/commands/generator.rb +2 -2
- data/lib/pliny/errors.rb +3 -0
- data/lib/pliny/middleware/rescue_errors.rb +7 -1
- data/lib/pliny/tasks/schema.rake +3 -6
- data/lib/pliny/templates/endpoint_scaffold_acceptance_test.erb +1 -0
- data/lib/pliny/templates/mediator.erb +1 -1
- data/lib/pliny/templates/mediator_test.erb +1 -1
- data/lib/pliny/version.rb +1 -1
- data/test/extensions/instruments_test.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7fbff3373db889d7b52ffa893a452c05253aa06
|
4
|
+
data.tar.gz: b370bc0af3c5b543bbc64a8410628ec8300e0caa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c1c3f22d6b9bd3ee954ab6812ea47234d7a1330b174cf11d0ce4fc8b11c814f37e9868113076940e651652e8532175357e59a224db5946f3023303f177460d
|
7
|
+
data.tar.gz: 123dc25a74c7d1ea2df8a61dc33c28a9d60c64c6938a31166715e029ad8aec6bdacbf5e6ea61452c02b92631ead20bacf999579363320dbefcf451df1849e2c6
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ And gems/helpers to tie these together and support operations:
|
|
19
19
|
- [Log helper](test/log_test.rb) that logs in [data format](https://www.youtube.com/watch?v=rpmc-wHFUBs) [to stdout](https://adam.heroku.com/past/2011/4/1/logs_are_streams_not_files)
|
20
20
|
- [Mediators](http://brandur.org/mediator) to help encapsulate more complex interactions
|
21
21
|
- [Rspec](https://github.com/rspec/rspec) for lean and fast testing
|
22
|
-
- [Puma](http://puma.io/) as the web server, [configured for optimal performance on Heroku](config/puma.rb)
|
22
|
+
- [Puma](http://puma.io/) as the web server, [configured for optimal performance on Heroku](https://github.com/interagent/pliny-template/blob/master/config/puma.rb)
|
23
23
|
- [Rack-test](https://github.com/brynary/rack-test) to test the API endpoints
|
24
24
|
- [Request IDs](lib/pliny/middleware/request_id.rb)
|
25
25
|
- [RequestStore](http://brandur.org/antipatterns), thread safe option to store data with the current request
|
@@ -133,13 +133,13 @@ module Pliny::Commands
|
|
133
133
|
|
134
134
|
def create_mediator
|
135
135
|
mediator = "./lib/mediators/#{field_name}.rb"
|
136
|
-
render_template("mediator.erb", mediator,
|
136
|
+
render_template("mediator.erb", mediator, singular_class_name: singular_class_name)
|
137
137
|
display "created mediator file #{mediator}"
|
138
138
|
end
|
139
139
|
|
140
140
|
def create_mediator_test
|
141
141
|
test = "./spec/mediators/#{field_name}_spec.rb"
|
142
|
-
render_template("mediator_test.erb", test,
|
142
|
+
render_template("mediator_test.erb", test, singular_class_name: singular_class_name)
|
143
143
|
display "created test #{test}"
|
144
144
|
end
|
145
145
|
|
data/lib/pliny/errors.rb
CHANGED
@@ -12,6 +12,9 @@ module Pliny
|
|
12
12
|
class HTTPStatusError < Error
|
13
13
|
attr_reader :status
|
14
14
|
|
15
|
+
# so that Sinatra respects are status code when catching an exception
|
16
|
+
alias :http_status :status
|
17
|
+
|
15
18
|
def initialize(message = nil, id = nil, status = nil)
|
16
19
|
meta = Pliny::Errors::META[self.class]
|
17
20
|
message = message || meta[1] + "."
|
@@ -13,13 +13,19 @@ module Pliny::Middleware
|
|
13
13
|
if @raise
|
14
14
|
raise
|
15
15
|
else
|
16
|
-
|
16
|
+
dump_error(e, env)
|
17
17
|
render(Pliny::Errors::InternalServerError.new, env)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
# pulled from Sinatra
|
24
|
+
def dump_error(e, env)
|
25
|
+
message = ["#{e.class} - #{e.message}:", *e.backtrace].join("\n\t")
|
26
|
+
env['rack.errors'].puts(message)
|
27
|
+
end
|
28
|
+
|
23
29
|
def render(e, env)
|
24
30
|
headers = { "Content-Type" => "application/json; charset=utf-8" }
|
25
31
|
error = { id: e.id, message: e.message, status: e.status }
|
data/lib/pliny/tasks/schema.rake
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
+
desc "Rebuild schema.json"
|
1
2
|
task :schema do
|
2
|
-
require
|
3
|
-
|
4
|
-
File.open(schemata, "w") do |f|
|
5
|
-
f.puts Prmd.combine("./docs/schema/schemata", meta: "./docs/schema/meta.json")
|
6
|
-
end
|
7
|
-
puts "rebuilt #{schemata}"
|
3
|
+
require 'pliny'
|
4
|
+
Pliny::Commands::Generator.new.rebuild_schema
|
8
5
|
end
|
data/lib/pliny/version.rb
CHANGED
@@ -10,6 +10,10 @@ describe Pliny::Extensions::Instruments do
|
|
10
10
|
status 201
|
11
11
|
"hi"
|
12
12
|
end
|
13
|
+
|
14
|
+
get "/error" do
|
15
|
+
raise Pliny::Errors::NotFound
|
16
|
+
end
|
13
17
|
}
|
14
18
|
end
|
15
19
|
end
|
@@ -31,4 +35,12 @@ describe Pliny::Extensions::Instruments do
|
|
31
35
|
))
|
32
36
|
get "/apps/123"
|
33
37
|
end
|
38
|
+
|
39
|
+
it "respects Pliny error status codes" do
|
40
|
+
mock(Pliny).log.with_any_args
|
41
|
+
mock(Pliny).log(hash_including(
|
42
|
+
status: 404
|
43
|
+
))
|
44
|
+
get "/error"
|
45
|
+
end
|
34
46
|
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.0
|
4
|
+
version: 0.1.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: 2014-06-
|
12
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|