restpack_serializer 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZWIyZmNmYzJlMmY3NmNkMWNmZTc3ZjcxZWExMjMyNWE4N2EzNTNmOQ==
5
+ data.tar.gz: !binary |-
6
+ MDM5M2RmY2Q1Nzc0ZGJkYjVmMDBkYmZlOTcyYWZjMTg0MjRjMjEwZA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YzNlMTM4MzFjMTE5ZTY5NWVhMzEwNTQ4ZTg0MDU3MjBkNTk2MzVjZWNmNTA5
10
+ NDNjNzE2ZjE0MGI0Y2ZhMDhlZGJhOTc2NzQzNDZlZGM0MjYzNjhlYTM3NGRk
11
+ NTk1ODQ2ZDFmYTBiZmIwMWZhYjdhNjc1Y2IzYjI5ZjUyYmIwYzA=
12
+ data.tar.gz: !binary |-
13
+ ODY3ZTI0NGFkMTlkZTQ0OWZlNDZkMTBmZWYzMDQ2ZTIzYWQyYWExNTY0YjAy
14
+ NjI2ZmUwOTMzZTkwNWI3MDVhZjVlOTlhNGFlNTU3MmViNGU1ODIyMDQ4MWEy
15
+ N2ViYjNkZDE3ZDY4NjE2MWY4YmZmMGQ2OWMzZjc4NTZjNDUxZGY=
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  *.gem
2
2
  *.db
3
- tmp
3
+ tmp
4
+ /coverage
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ gem 'coveralls', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- restpack_serializer (0.2.3)
4
+ restpack_serializer (0.2.4)
5
5
  activerecord (>= 3.0)
6
6
  activesupport (>= 3.0)
7
7
  will_paginate (~> 3.0)
@@ -24,6 +24,13 @@ GEM
24
24
  builder (3.0.4)
25
25
  bump (0.4.1)
26
26
  coderay (1.0.9)
27
+ colorize (0.5.8)
28
+ coveralls (0.6.7)
29
+ colorize
30
+ multi_json (~> 1.3)
31
+ rest-client
32
+ simplecov (>= 0.7)
33
+ thor
27
34
  database_cleaner (0.9.1)
28
35
  diff-lcs (1.2.3)
29
36
  factory_girl (4.2.0)
@@ -47,6 +54,7 @@ GEM
47
54
  rb-kqueue (>= 0.2)
48
55
  lumberjack (1.0.3)
49
56
  method_source (0.8.1)
57
+ mime-types (1.23)
50
58
  multi_json (1.7.2)
51
59
  pry (0.9.12)
52
60
  coderay (~> 1.0.5)
@@ -58,6 +66,8 @@ GEM
58
66
  ffi (>= 0.5.0)
59
67
  rb-kqueue (0.2.0)
60
68
  ffi (>= 0.5.0)
69
+ rest-client (1.6.7)
70
+ mime-types (>= 1.16)
61
71
  rspec (2.13.0)
62
72
  rspec-core (~> 2.13.0)
63
73
  rspec-expectations (~> 2.13.0)
@@ -66,6 +76,10 @@ GEM
66
76
  rspec-expectations (2.13.0)
67
77
  diff-lcs (>= 1.1.3, < 2.0)
68
78
  rspec-mocks (2.13.1)
79
+ simplecov (0.7.1)
80
+ multi_json (~> 1.0)
81
+ simplecov-html (~> 0.7.1)
82
+ simplecov-html (0.7.1)
69
83
  slop (3.4.4)
70
84
  sqlite3 (1.3.7)
71
85
  thor (0.18.1)
@@ -77,6 +91,7 @@ PLATFORMS
77
91
 
78
92
  DEPENDENCIES
79
93
  bump
94
+ coveralls
80
95
  database_cleaner (~> 0.9.1)
81
96
  factory_girl (~> 4.2.0)
82
97
  growl (~> 1.0.3)
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # restpack_serializer [![Build Status](https://travis-ci.org/RestPack/restpack_serializer.png?branch=master)](https://travis-ci.org/RestPack/restpack_serializer) [![Code Climate](https://codeclimate.com/github/RestPack/restpack_serializer.png)](https://codeclimate.com/github/RestPack/restpack_serializer) [![Dependency Status](https://gemnasium.com/RestPack/restpack_serializer.png)](https://gemnasium.com/RestPack/restpack_serializer) [![Gem Version](https://badge.fury.io/rb/restpack_serializer.png)](http://badge.fury.io/rb/restpack_serializer)
1
+ # restpack_serializer
2
+ [![Build Status](https://travis-ci.org/RestPack/restpack_serializer.png?branch=master)](https://travis-ci.org/RestPack/restpack_serializer) [![Code Climate](https://codeclimate.com/github/RestPack/restpack_serializer.png)](https://codeclimate.com/github/RestPack/restpack_serializer) [![Dependency Status](https://gemnasium.com/RestPack/restpack_serializer.png)](https://gemnasium.com/RestPack/restpack_serializer) [![Gem Version](https://badge.fury.io/rb/restpack_serializer.png)](http://badge.fury.io/rb/restpack_serializer) [![Coverage Status](https://coveralls.io/repos/RestPack/restpack_serializer/badge.png?branch=coveralls)](https://coveralls.io/r/RestPack/restpack_serializer?branch=coveralls)
2
3
 
3
4
  **Model serialization, paging, side-loading and filtering**
4
5
 
@@ -130,11 +131,11 @@ http://restpack-serializer-sample.herokuapp.com/songs.json?page=2&page_size=3 yi
130
131
  }
131
132
  },
132
133
  "links": {
133
- "songs.artists": {
134
+ "songs.artist": {
134
135
  "href": "/artists/{songs.artist}.json",
135
136
  "type": "artists"
136
137
  },
137
- "songs.albums": {
138
+ "songs.album": {
138
139
  "href": "/albums/{songs.album}.json",
139
140
  "type": "albums"
140
141
  }
@@ -233,7 +234,7 @@ which yields:
233
234
  "href": "/songs.json?album_id={albums.id}",
234
235
  "type": "songs"
235
236
  },
236
- "albums.artists": {
237
+ "albums.artist": {
237
238
  "href": "/artists/{albums.artist}.json",
238
239
  "type": "artists"
239
240
  },
@@ -36,13 +36,15 @@ module RestPack::Serializer::SideLoading
36
36
 
37
37
  associations.each do |association|
38
38
  if association.macro == :belongs_to
39
- href = "/#{association.plural_name}/{#{self.key}.#{association.name}}.json"
39
+ link_key = "#{self.key}.#{association.name}"
40
+ href = "/#{association.plural_name}/{#{link_key}}.json"
40
41
  elsif association.macro == :has_many
41
42
  singular_key = self.key.to_s.singularize
43
+ link_key = "#{self.key}.#{association.plural_name}"
42
44
  href = "/#{association.plural_name}.json?#{singular_key}_id={#{key}.id}"
43
45
  end
44
46
 
45
- links["#{self.key}.#{association.plural_name}"] = {
47
+ links[link_key] = {
46
48
  :href => href,
47
49
  :type => association.plural_name.to_sym
48
50
  }
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Serializer
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.4'
4
4
  end
5
5
  end
@@ -25,8 +25,8 @@ describe RestPack::Serializer::Paging do
25
25
  end
26
26
  it "includes links" do
27
27
  page[:links].should == {
28
- 'songs.albums' => { :href => "/albums/{songs.album}.json", :type => :albums },
29
- 'songs.artists' => { :href => "/artists/{songs.artist}.json", :type => :artists }
28
+ 'songs.album' => { :href => "/albums/{songs.album}.json", :type => :albums },
29
+ 'songs.artist' => { :href => "/artists/{songs.artist}.json", :type => :artists }
30
30
  }
31
31
  end
32
32
  end
@@ -93,10 +93,10 @@ describe RestPack::Serializer::Paging do
93
93
  end
94
94
 
95
95
  it "includes links" do
96
- page[:links]['songs.albums'].should_not == nil
97
- page[:links]['songs.artists'].should_not == nil
96
+ page[:links]['songs.album'].should_not == nil
97
+ page[:links]['songs.artist'].should_not == nil
98
98
  page[:links]['albums.songs'].should_not == nil
99
- page[:links]['albums.artists'].should_not == nil
99
+ page[:links]['albums.artist'].should_not == nil
100
100
  page[:links]['artists.songs'].should_not == nil
101
101
  page[:links]['artists.albums'].should_not == nil
102
102
  end
@@ -51,7 +51,7 @@ describe RestPack::Serializer::SideLoading do
51
51
 
52
52
  describe "#links" do
53
53
  AlbumSerializer.links.should == {
54
- "albums.artists" => {
54
+ "albums.artist" => {
55
55
  :href => "/artists/{albums.artist}.json",
56
56
  :type => :artists
57
57
  },
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,8 @@ require './spec/fixtures/db'
4
4
  require './spec/fixtures/serializers'
5
5
  require './spec/support/factory'
6
6
  require 'database_cleaner'
7
-
7
+ require 'coveralls'
8
+ Coveralls.wear!
8
9
  FactoryGirl.find_definitions
9
10
 
10
11
  RSpec.configure do |config|
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
5
- prerelease:
4
+ version: 0.2.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gavin Joyce
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-18 00:00:00.000000000 Z
11
+ date: 2013-05-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activesupport
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: will_paginate
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: guard-rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: growl
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: factory_girl
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ~>
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ~>
140
123
  - !ruby/object:Gem::Version
@@ -142,7 +125,6 @@ dependencies:
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: sqlite3
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ~>
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ~>
156
137
  - !ruby/object:Gem::Version
@@ -158,7 +139,6 @@ dependencies:
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: database_cleaner
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
143
  - - ~>
164
144
  - !ruby/object:Gem::Version
@@ -166,7 +146,6 @@ dependencies:
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
150
  - - ~>
172
151
  - !ruby/object:Gem::Version
@@ -174,7 +153,6 @@ dependencies:
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: bump
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
157
  - - ! '>='
180
158
  - !ruby/object:Gem::Version
@@ -182,7 +160,6 @@ dependencies:
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
164
  - - ! '>='
188
165
  - !ruby/object:Gem::Version
@@ -228,27 +205,26 @@ files:
228
205
  - spec/support/factory.rb
229
206
  homepage: https://github.com/RestPack
230
207
  licenses: []
208
+ metadata: {}
231
209
  post_install_message:
232
210
  rdoc_options: []
233
211
  require_paths:
234
212
  - lib
235
213
  required_ruby_version: !ruby/object:Gem::Requirement
236
- none: false
237
214
  requirements:
238
215
  - - ! '>='
239
216
  - !ruby/object:Gem::Version
240
217
  version: '0'
241
218
  required_rubygems_version: !ruby/object:Gem::Requirement
242
- none: false
243
219
  requirements:
244
220
  - - ! '>='
245
221
  - !ruby/object:Gem::Version
246
222
  version: '0'
247
223
  requirements: []
248
224
  rubyforge_project:
249
- rubygems_version: 1.8.24
225
+ rubygems_version: 2.0.3
250
226
  signing_key:
251
- specification_version: 3
227
+ specification_version: 4
252
228
  summary: Model serialization, paging, side-loading and filtering
253
229
  test_files:
254
230
  - spec/factory/factory_spec.rb