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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 337f0a1c9784e2c41009e2aa6001ff6e79b4d5be
4
- data.tar.gz: 9d67fc07db66c537931d4ce40c1a072077a49bdd
3
+ metadata.gz: d7fbff3373db889d7b52ffa893a452c05253aa06
4
+ data.tar.gz: b370bc0af3c5b543bbc64a8410628ec8300e0caa
5
5
  SHA512:
6
- metadata.gz: 92788bde19907756871bb04f9205c2221be2dcaf557aa72ea323910790712fa5e9cec12fa5fba6503bd6ba243a9ef0f338bae7a35ffbdbdf21dfa2d939571d7b
7
- data.tar.gz: ceaea90eaeb893e0ed855a2607b19c535234b24b9cb1877468359037f05b511d173ad423e6a1557a4ea646d01872327a8daa2496eafbb250fe8ec41504ab8a34
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, plural_class_name: plural_class_name)
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, plural_class_name: plural_class_name)
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
- # Pliny.log_exception(e)
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 }
@@ -1,8 +1,5 @@
1
+ desc "Rebuild schema.json"
1
2
  task :schema do
2
- require "prmd"
3
- schemata = "./docs/schema.json"
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
@@ -28,6 +28,7 @@ describe Endpoints::<%= plural_class_name %> do
28
28
 
29
29
  =begin
30
30
  it "POST <%= url_path %>" do
31
+ header "Content-Type", "application/json"
31
32
  post "<%= url_path %>", MultiJson.encode({})
32
33
  last_response.status.should eq(201)
33
34
  assert_schema_conform
@@ -1,5 +1,5 @@
1
1
  <%
2
- modules = plural_class_name.split("::")
2
+ modules = singular_class_name.split("::")
3
3
  modules[0] = "Mediators::#{modules[0]}"
4
4
  ident = ""
5
5
  %>
@@ -1,5 +1,5 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Mediators::<%= plural_class_name %> do
3
+ describe Mediators::<%= singular_class_name %> do
4
4
 
5
5
  end
data/lib/pliny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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
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-13 00:00:00.000000000 Z
12
+ date: 2014-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport