adequate_serialization 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
  SHA256:
3
- metadata.gz: a78d88a2501cf72c9d7b2752de13d260fbe6e2b3aae542dded2e7f7a8f61f037
4
- data.tar.gz: 5242b799a239f6224461bc00ffdd60f2d182edf9f28e405228321bf382871672
3
+ metadata.gz: 5c44c471509c73b1edc5a18d3ccfdf9e05643ce234b10be8a5a2e3eadaa89ab4
4
+ data.tar.gz: 290271ba291a48c85f7e4cc5691d32056f2c3215cf6a5af069f26a5b63a7e4ad
5
5
  SHA512:
6
- metadata.gz: d5d4071ea9064f3f54ae6f375f767d61f7417e4da907422526cfa83a7e6af572ae4b2963277f2dfb497a57e408343c6f4c0a0a265c0cfa6064dfd318beecba68
7
- data.tar.gz: c16e33d20c2b7000d3a0601b9f1fd353b1149314ce2f238d74e3515482b0330a12ac89aaa0e983bb0c08ba975e00ecf1409d3a81f099a94518ea8be78c243434
6
+ metadata.gz: 81aaf4709e2f4d6e0546f8212ee01ebf3fcf0b55d66d8f54c2f16e763eb4853d36154fada8e2f1f311a49cf15aa8cae6f094e2f90861e5aeb3ffc4fe7fff12ad
7
+ data.tar.gz: 9e510a610e415d090c0ee430d3add1b3ddd4d08a8e762d35f5f8d8bd8f6580a3039eba0bd7bfd3d766b4680e5bb3e2261701ae3dbbc3637ef3da936a6c71e9a5
@@ -7,6 +7,4 @@ branches:
7
7
  before_install:
8
8
  - gem update --system
9
9
  - gem install bundler
10
- script:
11
- - bundle exec rake
12
- - bundle exec rubocop --parallel
10
+ script: bundle exec rake && bundle exec rubocop --parallel
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.1] - 2018-08-30
10
+ ### Changed
11
+ - No longer trigger another query when the `ActiveRecord` relation being serialized isn't loaded.
12
+
13
+ [Unreleased]: https://github.com/CultureHQ/client/compare/v0.1.1...HEAD
14
+ [0.1.1]: https://github.com/CultureHQ/client/compare/v0.1.0...v0.1.1
@@ -1,48 +1,48 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adequate_serialization (0.1.0)
4
+ adequate_serialization (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (5.2.0)
10
- actionpack (= 5.2.0)
9
+ actioncable (5.2.1)
10
+ actionpack (= 5.2.1)
11
11
  nio4r (~> 2.0)
12
12
  websocket-driver (>= 0.6.1)
13
- actionmailer (5.2.0)
14
- actionpack (= 5.2.0)
15
- actionview (= 5.2.0)
16
- activejob (= 5.2.0)
13
+ actionmailer (5.2.1)
14
+ actionpack (= 5.2.1)
15
+ actionview (= 5.2.1)
16
+ activejob (= 5.2.1)
17
17
  mail (~> 2.5, >= 2.5.4)
18
18
  rails-dom-testing (~> 2.0)
19
- actionpack (5.2.0)
20
- actionview (= 5.2.0)
21
- activesupport (= 5.2.0)
19
+ actionpack (5.2.1)
20
+ actionview (= 5.2.1)
21
+ activesupport (= 5.2.1)
22
22
  rack (~> 2.0)
23
23
  rack-test (>= 0.6.3)
24
24
  rails-dom-testing (~> 2.0)
25
25
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
- actionview (5.2.0)
27
- activesupport (= 5.2.0)
26
+ actionview (5.2.1)
27
+ activesupport (= 5.2.1)
28
28
  builder (~> 3.1)
29
29
  erubi (~> 1.4)
30
30
  rails-dom-testing (~> 2.0)
31
31
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
- activejob (5.2.0)
33
- activesupport (= 5.2.0)
32
+ activejob (5.2.1)
33
+ activesupport (= 5.2.1)
34
34
  globalid (>= 0.3.6)
35
- activemodel (5.2.0)
36
- activesupport (= 5.2.0)
37
- activerecord (5.2.0)
38
- activemodel (= 5.2.0)
39
- activesupport (= 5.2.0)
35
+ activemodel (5.2.1)
36
+ activesupport (= 5.2.1)
37
+ activerecord (5.2.1)
38
+ activemodel (= 5.2.1)
39
+ activesupport (= 5.2.1)
40
40
  arel (>= 9.0)
41
- activestorage (5.2.0)
42
- actionpack (= 5.2.0)
43
- activerecord (= 5.2.0)
41
+ activestorage (5.2.1)
42
+ actionpack (= 5.2.1)
43
+ activerecord (= 5.2.1)
44
44
  marcel (~> 0.3.1)
45
- activesupport (5.2.0)
45
+ activesupport (5.2.1)
46
46
  concurrent-ruby (~> 1.0, >= 1.0.2)
47
47
  i18n (>= 0.7, < 2)
48
48
  minitest (~> 5.1)
@@ -52,12 +52,13 @@ GEM
52
52
  builder (3.2.3)
53
53
  concurrent-ruby (1.0.5)
54
54
  crass (1.0.4)
55
- docile (1.3.0)
55
+ docile (1.3.1)
56
56
  erubi (1.7.1)
57
57
  globalid (0.4.1)
58
58
  activesupport (>= 4.2.0)
59
- i18n (1.0.1)
59
+ i18n (1.1.0)
60
60
  concurrent-ruby (~> 1.0)
61
+ jaro_winkler (1.5.1)
61
62
  json (2.1.0)
62
63
  loofah (2.2.2)
63
64
  crass (~> 1.0.2)
@@ -68,59 +69,60 @@ GEM
68
69
  mimemagic (~> 0.3.2)
69
70
  method_source (0.9.0)
70
71
  mimemagic (0.3.2)
71
- mini_mime (1.0.0)
72
+ mini_mime (1.0.1)
72
73
  mini_portile2 (2.3.0)
73
74
  minitest (5.11.3)
74
75
  nio4r (2.3.1)
75
- nokogiri (1.8.2)
76
+ nokogiri (1.8.4)
76
77
  mini_portile2 (~> 2.3.0)
77
78
  parallel (1.12.1)
78
- parser (2.5.1.0)
79
+ parser (2.5.1.2)
79
80
  ast (~> 2.4.0)
80
- powerpack (0.1.1)
81
+ powerpack (0.1.2)
81
82
  rack (2.0.5)
82
- rack-test (1.0.0)
83
+ rack-test (1.1.0)
83
84
  rack (>= 1.0, < 3)
84
- rails (5.2.0)
85
- actioncable (= 5.2.0)
86
- actionmailer (= 5.2.0)
87
- actionpack (= 5.2.0)
88
- actionview (= 5.2.0)
89
- activejob (= 5.2.0)
90
- activemodel (= 5.2.0)
91
- activerecord (= 5.2.0)
92
- activestorage (= 5.2.0)
93
- activesupport (= 5.2.0)
85
+ rails (5.2.1)
86
+ actioncable (= 5.2.1)
87
+ actionmailer (= 5.2.1)
88
+ actionpack (= 5.2.1)
89
+ actionview (= 5.2.1)
90
+ activejob (= 5.2.1)
91
+ activemodel (= 5.2.1)
92
+ activerecord (= 5.2.1)
93
+ activestorage (= 5.2.1)
94
+ activesupport (= 5.2.1)
94
95
  bundler (>= 1.3.0)
95
- railties (= 5.2.0)
96
+ railties (= 5.2.1)
96
97
  sprockets-rails (>= 2.0.0)
97
98
  rails-dom-testing (2.0.3)
98
99
  activesupport (>= 4.2.0)
99
100
  nokogiri (>= 1.6)
100
101
  rails-html-sanitizer (1.0.4)
101
102
  loofah (~> 2.2, >= 2.2.2)
102
- railties (5.2.0)
103
- actionpack (= 5.2.0)
104
- activesupport (= 5.2.0)
103
+ railties (5.2.1)
104
+ actionpack (= 5.2.1)
105
+ activesupport (= 5.2.1)
105
106
  method_source
106
107
  rake (>= 0.8.7)
107
- thor (>= 0.18.1, < 2.0)
108
+ thor (>= 0.19.0, < 2.0)
108
109
  rainbow (3.0.0)
109
110
  rake (12.3.1)
110
- rubocop (0.56.0)
111
+ rubocop (0.58.2)
112
+ jaro_winkler (~> 1.5.1)
111
113
  parallel (~> 1.10)
112
- parser (>= 2.5)
114
+ parser (>= 2.5, != 2.5.1.1)
113
115
  powerpack (~> 0.1)
114
116
  rainbow (>= 2.2.2, < 4.0)
115
117
  ruby-progressbar (~> 1.7)
116
118
  unicode-display_width (~> 1.0, >= 1.0.1)
117
- ruby-progressbar (1.9.0)
119
+ ruby-progressbar (1.10.0)
118
120
  simplecov (0.16.1)
119
121
  docile (~> 1.1)
120
122
  json (>= 1.8, < 3)
121
123
  simplecov-html (~> 0.10.0)
122
124
  simplecov-html (0.10.2)
123
- sprockets (3.7.1)
125
+ sprockets (3.7.2)
124
126
  concurrent-ruby (~> 1.0)
125
127
  rack (> 1, < 3)
126
128
  sprockets-rails (3.2.1)
@@ -132,7 +134,7 @@ GEM
132
134
  thread_safe (0.3.6)
133
135
  tzinfo (1.2.5)
134
136
  thread_safe (~> 0.1)
135
- unicode-display_width (1.3.2)
137
+ unicode-display_width (1.4.0)
136
138
  websocket-driver (0.7.0)
137
139
  websocket-extensions (>= 0.1.0)
138
140
  websocket-extensions (0.1.3)
@@ -146,7 +148,7 @@ DEPENDENCIES
146
148
  minitest (~> 5)
147
149
  rails (~> 5, >= 5.2)
148
150
  rake (~> 12)
149
- rubocop (~> 0.52)
151
+ rubocop (~> 0.58)
150
152
  simplecov (~> 0.16)
151
153
  sqlite3
152
154
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Kevin Deisz
3
+ Copyright (c) 2018 CultureHQ
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # AdequateSerialization
2
2
 
3
- [![Build Status](https://travis-ci.org/kddeisz/adequate_serialization.svg?branch=master)](https://travis-ci.org/kddeisz/adequate_serialization)
3
+ [![Build Status](https://travis-ci.org/CultureHQ/adequate_serialization.svg?branch=master)](https://travis-ci.org/CultureHQ/adequate_serialization)
4
+ [![Gem Version](https://img.shields.io/gem/v/adequate_serialization.svg)](https://github.com/CultureHQ/adeqaute_serialization)
4
5
 
5
6
  Serializes objects adequately. `AdequateSerialization` allows you to define serializers that will convert your objects into simple hashes that are suitable for variable purposes such as caching or using in an HTTP response. It stems from the simple idea of giving slightly more control over the `as_json` method that gets called when objects are serialized using Rails' default controller serialization.
6
7
 
@@ -183,7 +184,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
183
184
 
184
185
  ## Contributing
185
186
 
186
- Bug reports and pull requests are welcome on GitHub at https://github.com/kddeisz/adequate_serialization.
187
+ Bug reports and pull requests are welcome on GitHub at https://github.com/CultureHQ/adequate_serialization.
187
188
 
188
189
  ## License
189
190
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['kevin.deisz@gmail.com']
12
12
 
13
13
  spec.summary = 'Serializes objects adequately'
14
- spec.homepage = 'https://github.com/kddeisz/adequate_serialization'
14
+ spec.homepage = 'https://github.com/CultureHQ/adequate_serialization'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'bundler', '~> 1'
25
25
  spec.add_development_dependency 'minitest', '~> 5'
26
26
  spec.add_development_dependency 'rake', '~> 12'
27
- spec.add_development_dependency 'rubocop', '~> 0.52'
27
+ spec.add_development_dependency 'rubocop', '~> 0.58'
28
28
  spec.add_development_dependency 'simplecov', '~> 0.16'
29
29
  end
@@ -10,7 +10,12 @@ module AdequateSerialization
10
10
  end
11
11
 
12
12
  def as_json(*options)
13
- return [] if relation.empty?
13
+ # Very purposefully using #length here. If you use #empty? or #count and
14
+ # the relation isn't yet loaded, it's going to trigger another query.
15
+ # Since we're going to need to map over each of the results in order to
16
+ # serialize it anyway, it's better just to load it now and avoid the
17
+ # extra query.
18
+ return [] if relation.length.zero?
14
19
 
15
20
  opts = Options.from(*options, multi_caching: true)
16
21
  decorator = Decorator.from(opts.attachments)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdequateSerialization
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adequate_serialization
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
  - Kevin Deisz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-30 00:00:00.000000000 Z
11
+ date: 2018-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.52'
61
+ version: '0.58'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.52'
68
+ version: '0.58'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +90,7 @@ files:
90
90
  - ".gitignore"
91
91
  - ".rubocop.yml"
92
92
  - ".travis.yml"
93
+ - CHANGELOG.md
93
94
  - Gemfile
94
95
  - Gemfile.lock
95
96
  - LICENSE
@@ -112,7 +113,7 @@ files:
112
113
  - lib/adequate_serialization/steps/passthrough_step.rb
113
114
  - lib/adequate_serialization/steps/serialize_step.rb
114
115
  - lib/adequate_serialization/version.rb
115
- homepage: https://github.com/kddeisz/adequate_serialization
116
+ homepage: https://github.com/CultureHQ/adequate_serialization
116
117
  licenses:
117
118
  - MIT
118
119
  metadata: {}