jsonapi-serializers 0.1.0 → 0.1.1

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: 035748d359ee3c492b7867f9dd5548960df3cb78
4
- data.tar.gz: 2d6e4b038d482c9de6b9d3972778082c74b36ba9
3
+ metadata.gz: c5be9e7db5c661af3677e1ddc65deccbf2e9aa53
4
+ data.tar.gz: 27457e4e784106807993d0374de6e131dd890a07
5
5
  SHA512:
6
- metadata.gz: 79ac938adcc1fdcc64a43c7237c4b6d1fed837f4d8325312f9a901bd0faf3b06296425e4c2c83b3da518b7813d148f2532c234687f39ceba5e8ab824836993ab
7
- data.tar.gz: 167c5d8970366dce05af73431498cc5d5a3d0a0dc585437bc5a4e4e3f126106fec046e03578593031d5976f0cd4bfda7204d9658dc01688b992251c511253f21
6
+ metadata.gz: 5a936a8f8d1b73c1aca370a7db10440a9ce9fe854828eecf69b7cb98c6b623f5e573e06638e5efee9f471117a38869b5678ef531262fed69d451e28cc882989b
7
+ data.tar.gz: f35e15687ce5b6038c47f721cbb4e242b57d34bcf7b338b422b46420f685e52bcb1d3fdf56aea399e8dc5815d208984ac8ab58acc8daef14013d67298b48f470
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # JSONAPI::Serializers
2
2
 
3
+ [![Build Status](https://travis-ci.org/fotinakis/jsonapi-serializers.svg?branch=master)](https://travis-ci.org/fotinakis/jsonapi-serializers)
4
+ [![Gem Version](https://badge.fury.io/rb/jsonapi-serializers.svg)](http://badge.fury.io/rb/jsonapi-serializers)
5
+
6
+
3
7
  JSONAPI::Serializers is a simple library for serializing Ruby objects and their relationships into the [JSON:API format](http://jsonapi.org/format/).
4
8
 
5
9
  As of writing, the JSON:API spec is approaching v1 and still undergoing changes. This library supports RC3+ and aims to keep up with the continuing development changes.
@@ -161,55 +165,55 @@ The block is evaluated within the serializer instance, so it has access to the `
161
165
  Many other formatting and customizations are possible by overriding any of the following instance methods on your serializers.
162
166
 
163
167
  ```ruby
164
- # Override this to customize the JSON:API "id" for this object.
165
- # Always return a string from this method to conform with the JSON:API spec.
166
- def id
167
- object.id.to_s
168
- end
168
+ # Override this to customize the JSON:API "id" for this object.
169
+ # Always return a string from this method to conform with the JSON:API spec.
170
+ def id
171
+ object.id.to_s
172
+ end
169
173
  ```
170
174
  ```ruby
171
- # Override this to customize the JSON:API "type" for this object.
172
- # By default, the type is the object's class name lowercased, pluralized, and dasherized,
173
- # per the spec naming recommendations: http://jsonapi.org/recommendations/#naming
174
- # For example, 'MyApp::LongCommment' will become the 'long-comments' type.
175
- def type
176
- object.class.name.demodulize.tableize.dasherize
177
- end
175
+ # Override this to customize the JSON:API "type" for this object.
176
+ # By default, the type is the object's class name lowercased, pluralized, and dasherized,
177
+ # per the spec naming recommendations: http://jsonapi.org/recommendations/#naming
178
+ # For example, 'MyApp::LongCommment' will become the 'long-comments' type.
179
+ def type
180
+ object.class.name.demodulize.tableize.dasherize
181
+ end
178
182
  ```
179
183
  ```ruby
180
- # Override this to customize how attribute names are formatted.
181
- # By default, attribute names are dasherized per the spec naming recommendations:
182
- # http://jsonapi.org/recommendations/#naming
183
- def format_name(attribute_name)
184
- attribute_name.to_s.dasherize
185
- end
184
+ # Override this to customize how attribute names are formatted.
185
+ # By default, attribute names are dasherized per the spec naming recommendations:
186
+ # http://jsonapi.org/recommendations/#naming
187
+ def format_name(attribute_name)
188
+ attribute_name.to_s.dasherize
189
+ end
186
190
  ```
187
191
  ```ruby
188
- # The opposite of format_name. Override this if you override format_name.
189
- def unformat_name(attribute_name)
190
- attribute_name.to_s.underscore
191
- end
192
+ # The opposite of format_name. Override this if you override format_name.
193
+ def unformat_name(attribute_name)
194
+ attribute_name.to_s.underscore
195
+ end
192
196
  ```
193
197
  ```ruby
194
- # Override this to provide resource-object metadata.
195
- # http://jsonapi.org/format/#document-structure-resource-objects
196
- def meta
197
- end
198
+ # Override this to provide resource-object metadata.
199
+ # http://jsonapi.org/format/#document-structure-resource-objects
200
+ def meta
201
+ end
198
202
  ```
199
203
  ```ruby
200
- def self_link
201
- "/#{type}/#{id}"
202
- end
204
+ def self_link
205
+ "/#{type}/#{id}"
206
+ end
203
207
  ```
204
208
  ```ruby
205
- def relationship_self_link(attribute_name)
206
- "#{self_link}/links/#{format_name(attribute_name)}"
207
- end
209
+ def relationship_self_link(attribute_name)
210
+ "#{self_link}/links/#{format_name(attribute_name)}"
211
+ end
208
212
  ```
209
213
  ```ruby
210
- def relationship_related_link(attribute_name)
211
- "#{self_link}/#{format_name(attribute_name)}"
212
- end
214
+ def relationship_related_link(attribute_name)
215
+ "#{self_link}/#{format_name(attribute_name)}"
216
+ end
213
217
  ```
214
218
 
215
219
  ## Relationships
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = JSONAPI::Serializer::VERSION
9
9
  spec.authors = ["Mike Fotinakis"]
10
10
  spec.email = ["mike@fotinakis.com"]
11
- spec.summary = %q{Pure Ruby serializers conforming to the JSON:API spec.}
11
+ spec.summary = %q{Pure Ruby readonly serializers for the JSON:API spec.}
12
12
  spec.description = %q{}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
@@ -17,12 +17,12 @@ module JSONAPI
17
17
  add_attribute(name, options, &block)
18
18
  end
19
19
 
20
- def has_one(name, options = {})
21
- add_to_one_association(name, options)
20
+ def has_one(name, options = {}, &block)
21
+ add_to_one_association(name, options, &block)
22
22
  end
23
23
 
24
- def has_many(name, options = {})
25
- add_to_many_association(name, options)
24
+ def has_many(name, options = {}, &block)
25
+ add_to_many_association(name, options, &block)
26
26
  end
27
27
 
28
28
  def add_attribute(name, options = {}, &block)
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Serializer
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Fotinakis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -126,7 +126,7 @@ rubyforge_project:
126
126
  rubygems_version: 2.2.2
127
127
  signing_key:
128
128
  specification_version: 4
129
- summary: Pure Ruby serializers conforming to the JSON:API spec.
129
+ summary: Pure Ruby readonly serializers for the JSON:API spec.
130
130
  test_files:
131
131
  - spec/serializer_spec.rb
132
132
  - spec/spec_helper.rb