granola-schema 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -9
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 201eb2e3105a257b28ded44d77e9cae937e36893
4
- data.tar.gz: 2444b5b3082c5c5161c72d01d365f27f84885cd0
3
+ metadata.gz: dcd59ea7f9c27652b7712bfc01142fc65a518bad
4
+ data.tar.gz: 0de079848da83488cb3cd17fd84b09e80e415528
5
5
  SHA512:
6
- metadata.gz: 2194f846f4c7cdaf6ceff6f2eefe2bc1c2d66c110f9b6b5cc2d83bb07421b825b1e282df1596ca937a6500a07159b3ad43864da75ac8dbfca1bbc17831775bed
7
- data.tar.gz: a974513f758315a4ed10df2979b0decb3197b4807fc5de03804f5b89711e51fd488d2da71d4e787dedaa8071e812965c7fd8aac24782c67b6dd87c9fe04c3f94
6
+ metadata.gz: d52b664f758cf362273190515ff825df4c4bb6d97dc81222c8de2e3d7418094260c6fa585f85e8757a059bd4efbda8e7ed36eca1322b5718bc0efb0e57c702c6
7
+ data.tar.gz: 509e314bf8c198d426f14d368301b1c9f982b8d31187ebf98a929d69ae545aa1b3f70879d7566e1b15ea75e23aa2dba7e0f06f8aead7ca94b19e4a6027d14bcd
data/README.md CHANGED
@@ -51,22 +51,33 @@ serializer.to_json #=> '[{"name":"John Doe",...},{...}]'
51
51
 
52
52
  ## Rack Helpers
53
53
 
54
- If your application is based on rack, you have a `Rack::Response` called `res`
55
- in your context, and you have an `env` method that returns the Rack env hash,
56
- you can simply `include Granola::Rack` and you get access to the following
57
- interface:
54
+ If your application is based on Rack, you can simply `include Granola::Rack` and
55
+ you get access to the following interface:
58
56
 
59
57
  ``` ruby
60
58
  json(person) #=> This will try to infer PersonSerializer from a Person instance
61
59
  json(person, with: AnotherSerializer)
62
60
  ```
63
61
 
64
- *NOTE*: This works out of the box in frameworks like [Cuba][] or [Roda][]. You
65
- might need to provide glue code to make `res` and/or `env` available in other
66
- frameworks.
62
+ *NOTE* The method relies on being an `env` method that returns the Rack
63
+ environment Hash in the same context where you call the method. See [the
64
+ documentation](./lib/granola/rack.rb) for further details.
67
65
 
68
- [Cuba]: https://github.com/soveran/cuba
69
- [Roda]: https://github.com/jeremyevans/roda
66
+ This method returns a Rack response tuple that you can use like so (this example
67
+ uses [Cuba][], but similar code will work for other frameworks):
68
+
69
+ ``` ruby
70
+ Cuba.plugin Granola::Rack
71
+
72
+ Cuba.define do
73
+ on get, "users/:id" do |id|
74
+ user = User[id]
75
+ halt json(user)
76
+ end
77
+ end
78
+ ```
79
+
80
+ [Cuba]: http://cuba.is
70
81
 
71
82
  ## Caching
72
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: granola-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Sanguinetti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-26 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: granola
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.1
19
+ version: 0.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.1
26
+ version: 0.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json-schema
29
29
  requirement: !ruby/object:Gem::Requirement