rails_core_extensions 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-style.yml +20 -10
- data/.ruby-version +1 -0
- data/.travis.yml +3 -2
- data/CHANGELOG.md +4 -0
- data/README.md +2 -5
- data/lib/rails_core_extensions/active_record_cache_all_attributes.rb +10 -6
- data/lib/rails_core_extensions/version.rb +1 -1
- data/rails_core_extensions.gemspec +2 -2
- data/spec/support/coverage_loader.rb +1 -1
- metadata +8 -8
- data/gemfiles/rails3.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e6f3d03a0f590162030b45af40b62bc06cf43070b39329e128ecc8019a4dd493
|
4
|
+
data.tar.gz: 7464ef1b358eabf26b9acbf981c0521839ac2ab0188b4b5e684faedeedfacf23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecb48e82f04873abc00679c6527e0e00f629e8e654747969a3f69eb0939730eca1272de3710f4e5308cd65b563483f599cafa5c15543a7b470aa4ba065713b14
|
7
|
+
data.tar.gz: 03fc9650d0d19bb1bb46c871f16becb722afdc65e061405e60e54c38e858ac74f91e8df5e83a453970473ba1d15c18c80614984c439a41c9e56ff7ae6da4d71b
|
data/.ruby-style.yml
CHANGED
@@ -13,7 +13,7 @@ Style/CollectionMethods:
|
|
13
13
|
find: detect
|
14
14
|
find_all: select
|
15
15
|
reduce: inject
|
16
|
-
|
16
|
+
Layout/DotPosition:
|
17
17
|
Description: Checks the position of the dot in multi-line method calls.
|
18
18
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
19
19
|
Enabled: true
|
@@ -21,7 +21,7 @@ Style/DotPosition:
|
|
21
21
|
SupportedStyles:
|
22
22
|
- leading
|
23
23
|
- trailing
|
24
|
-
|
24
|
+
Naming/FileName:
|
25
25
|
Description: Use snake_case for source file names.
|
26
26
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
27
27
|
Enabled: false
|
@@ -53,7 +53,7 @@ Style/PercentLiteralDelimiters:
|
|
53
53
|
"%w": "()"
|
54
54
|
"%W": "()"
|
55
55
|
"%x": "()"
|
56
|
-
|
56
|
+
Naming/PredicateName:
|
57
57
|
Description: Check the names of predicate methods.
|
58
58
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
59
59
|
Enabled: true
|
@@ -114,14 +114,24 @@ Style/StringLiteralsInInterpolation:
|
|
114
114
|
SupportedStyles:
|
115
115
|
- single_quotes
|
116
116
|
- double_quotes
|
117
|
-
Style/
|
118
|
-
Description: Checks for trailing comma in
|
117
|
+
Style/TrailingCommaInArguments:
|
118
|
+
Description: Checks for trailing comma in argument lists.
|
119
119
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
|
120
|
-
|
121
|
-
|
120
|
+
EnforcedStyleForMultiline: comma
|
121
|
+
SupportedStyles:
|
122
|
+
- comma
|
123
|
+
- consistent_comma
|
124
|
+
- no_comma
|
125
|
+
Enabled: true
|
126
|
+
Style/TrailingCommaInLiteral:
|
127
|
+
Description: Checks for trailing comma in array and hash literals.
|
128
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
|
129
|
+
EnforcedStyleForMultiline: comma
|
122
130
|
SupportedStyles:
|
123
|
-
|
124
|
-
|
131
|
+
- comma
|
132
|
+
- consistent_comma
|
133
|
+
- no_comma
|
134
|
+
Enabled: true
|
125
135
|
Metrics/AbcSize:
|
126
136
|
Description: A calculated magnitude based on number of assignments, branches, and
|
127
137
|
conditions.
|
@@ -167,7 +177,7 @@ Lint/AssignmentInCondition:
|
|
167
177
|
Style/InlineComment:
|
168
178
|
Description: Avoid inline comments.
|
169
179
|
Enabled: false
|
170
|
-
|
180
|
+
Naming/AccessorMethodName:
|
171
181
|
Description: Check the naming of accessor methods for get_/set_.
|
172
182
|
Enabled: false
|
173
183
|
Style/Alias:
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Rails Core Extensions
|
1
|
+
Rails Core Extensions
|
2
2
|
====================
|
3
3
|
|
4
4
|
[![Build Status](https://travis-ci.org/sealink/rails_core_extensions.png?branch=master)](https://travis-ci.org/sealink/rails_core_extensions)
|
@@ -30,15 +30,12 @@ end
|
|
30
30
|
|
31
31
|
config/routes.rb
|
32
32
|
|
33
|
-
In Rails
|
33
|
+
In Rails 4/5:
|
34
34
|
resources :types do
|
35
35
|
collection
|
36
36
|
post :sort
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
40
|
-
In Rails 2:
|
41
|
-
map.resources :types, collection: {sort: :post}
|
42
39
|
```
|
43
40
|
|
44
41
|
You need to submit a collection of objects named the same as the controller.
|
@@ -6,6 +6,7 @@ module ActiveRecordCacheAllAttributes
|
|
6
6
|
module InstanceMethods
|
7
7
|
def clear_attribute_cache
|
8
8
|
self.class.cache.delete("#{self.class.name}.attribute_cache")
|
9
|
+
self.class.clear_request_cache
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -14,21 +15,24 @@ module ActiveRecordCacheAllAttributes
|
|
14
15
|
Rails.cache
|
15
16
|
end
|
16
17
|
|
18
|
+
def clear_request_cache
|
19
|
+
@request_cache = nil
|
20
|
+
end
|
21
|
+
|
17
22
|
def attribute_cache
|
18
|
-
cache_key = "#{
|
19
|
-
cache.read(cache_key) ||
|
23
|
+
cache_key = "#{name}.attribute_cache"
|
24
|
+
@request_cache ||= cache.read(cache_key) || generate_cache(cache_key)
|
20
25
|
end
|
21
26
|
|
22
27
|
def generate_attributes_hash
|
23
28
|
scope = self
|
24
29
|
scope = scope.ordered if respond_to?(:ordered)
|
25
|
-
Hash[scope.all.map { |o| [o.send(
|
30
|
+
Hash[scope.all.map { |o| [o.send(cache_attributes_by), o.attributes] }]
|
26
31
|
end
|
27
32
|
|
28
33
|
def generate_cache(cache_key)
|
29
|
-
|
30
|
-
|
31
|
-
end
|
34
|
+
cache_value = generate_attributes_hash
|
35
|
+
cache.write(cache_key, cache_value)
|
32
36
|
cache_value
|
33
37
|
end
|
34
38
|
end
|
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_dependency 'activerecord', ['>=
|
23
|
-
spec.add_dependency 'actionpack', ['>=
|
22
|
+
spec.add_dependency 'activerecord', ['>= 4.0.0']
|
23
|
+
spec.add_dependency 'actionpack', ['>= 4.0.0']
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
26
|
spec.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_core_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 4.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 4.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: actionpack
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 4.0.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 4.0.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,13 +204,13 @@ files:
|
|
204
204
|
- ".hound.yml"
|
205
205
|
- ".rspec"
|
206
206
|
- ".ruby-style.yml"
|
207
|
+
- ".ruby-version"
|
207
208
|
- ".travis.yml"
|
208
209
|
- CHANGELOG.md
|
209
210
|
- Gemfile
|
210
211
|
- LICENSE.txt
|
211
212
|
- README.md
|
212
213
|
- Rakefile
|
213
|
-
- gemfiles/rails3.gemfile
|
214
214
|
- gemfiles/rails4.gemfile
|
215
215
|
- gemfiles/rails5.gemfile
|
216
216
|
- lib/rails_core_extensions.rb
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
requirements: []
|
274
274
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.
|
275
|
+
rubygems_version: 2.7.3
|
276
276
|
signing_key:
|
277
277
|
specification_version: 4
|
278
278
|
summary: Set of extensions to core rails libraries.
|