granola 0.13.0 → 1.0.0

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: 5e69b46c3904138a9b629c06935167c86d96e121
4
- data.tar.gz: 869dc7ae697f696c5f65ede168e87b435320e472
3
+ metadata.gz: ae11f60f7f98dcce1d3267fefc60a449442efeb3
4
+ data.tar.gz: 3a28d97cca22f6b52a049c33475b2b66d0d62453
5
5
  SHA512:
6
- metadata.gz: 00b2b5b36f45cc56c884b9eaabc02aa8aef1b65cfb30480f54cf9568d3f12d992170b5961226c1b368ad60fd20e1ee30de68866a588149c1015954b74ccd884e
7
- data.tar.gz: 3ad2e3746539fc912d747ed414d5aaca1498e4ff0fe35f35c3913ee75afe61edfe5659e65648999b4a62283b0ee1f7f1d004b37df8699a11f78370b7b786ccd4
6
+ metadata.gz: ac11eb33406283d7eff4230605334d1575a41fbabfe0be3a70ea9de4fed6fe14dc3639e29153ded07c1bc84c512b06e5313826e9332baad568268da27bc459e2
7
+ data.tar.gz: 73bb6a0c6eba2098343e51d76dabea0623de3864431fa971f9a546790e255efd7f11b3cfbf709d58fca13c8900d4024645763bdcfaab9c6513d1ac41bda01774
data/README.md CHANGED
@@ -78,7 +78,12 @@ end
78
78
 
79
79
  [Cuba]: http://cuba.is
80
80
 
81
- ## Caching
81
+ ## Rails Support
82
+
83
+ The companion [Granola::Rails](https://github.com/foca/granola-rails) gem takes
84
+ care of support for Rails.
85
+
86
+ ## HTTP Caching
82
87
 
83
88
  `Granola::Serializer` gives you two methods that you can implement in your
84
89
  serializers: `last_modified` and `cache_key`.
@@ -122,6 +127,12 @@ appropriate `If-Modified-Since` or `If-None-Match` headers.
122
127
 
123
128
  [cg]: http://www.rubydoc.info/github/rack/rack/Rack/ConditionalGet
124
129
 
130
+ ## Caching of serialized bodies
131
+
132
+ If you are generating responses that are particularly expensive to serialize,
133
+ you can use the [Granola::Cache](https://github.com/foca/granola-cache) gem to
134
+ store their representations once generated in an external cache.
135
+
125
136
  ## Different Formats
126
137
 
127
138
  Although Granola out of the box only ships with JSON serialization support, it's
@@ -59,7 +59,7 @@ module Granola
59
59
  RENDERERS.keys
60
60
  end
61
61
 
62
- # Internal: Map of renderers available to this serializer.
62
+ # Internal: Map of renderers available to all serializers.
63
63
  RENDERERS = {}
64
64
 
65
65
  # Renderer objects just wrap the callable used to render an object and keep a
@@ -106,47 +106,4 @@ module Granola
106
106
  end
107
107
 
108
108
  render :json, via: JSON.method(:generate), content_type: "application/json"
109
-
110
- # Deprecated: The old way of registering a JSON renderer. This will be gone in
111
- # 1.0.
112
- #
113
- # callable - A callable. See the format in `Granola.render`
114
- #
115
- # Returns nothing.
116
- def self.json=(callable)
117
- warn "Granola.json= has been deprecated. Use Granola.render now."
118
- render(:json, via: callable, content_type: "application/json")
119
- end
120
-
121
- class Serializer
122
- # Deprecated: Use Granola.renderer and a Renderer's render method directly.
123
- # This method will be removed in 1.0.
124
- #
125
- # type - A Symbol with the expected rendering format.
126
- # **options - An options Hash or set of keyword arguments that will be
127
- # passed to the renderer.
128
- #
129
- # Raises KeyError if there's no Renderer registered for the given `type`.
130
- # Returns a String (in the encoding approrpriate to the rendering format.)
131
- def render(type = :json, **options, &block)
132
- warn "Granola::Serializer#render has been deprecated. Use Granola.renderer(type).render."
133
- Granola.renderer(type).render(self, **options, &block)
134
- rescue NoSuchRendererError => err
135
- fail KeyError, err.message
136
- end
137
-
138
- # Deprecated: Use Granola.renderer and the Renderer's content_type method
139
- # directly. This method will be removed in 1.0.
140
- #
141
- # type - A Symbol describing the expected rendering format.
142
- #
143
- # Raises KeyError if there's no Renderer registered for the given `type`.
144
- # Returns a String.
145
- def mime_type(type = :json)
146
- warn "Granola::Serializer#mime_type has been deprecated. Use Granola.renderer(type).content_type."
147
- Granola.renderer(type).content_type
148
- rescue NoSuchRendererError => err
149
- fail KeyError, err.message
150
- end
151
- end
152
109
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Granola
3
- VERSION = "0.13.0"
3
+ VERSION = "1.0.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: granola
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Sanguinetti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-14 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cutest