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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 66b12180b0871631d3aa748d769096169a861e1c
4
- data.tar.gz: 35d1ef716439e10dd806131a99254cfd40f98765
2
+ SHA256:
3
+ metadata.gz: e6f3d03a0f590162030b45af40b62bc06cf43070b39329e128ecc8019a4dd493
4
+ data.tar.gz: 7464ef1b358eabf26b9acbf981c0521839ac2ab0188b4b5e684faedeedfacf23
5
5
  SHA512:
6
- metadata.gz: ed049d5b08476af111e543f13771d91b96584b29732bfa8ea6376a1bfd4dd1a4e6c6b248a17c9d4761e37ca73fa053413d6c51d2d5174c8f59c27ace3b445720
7
- data.tar.gz: b1ec8619fedbab171426d8fb4ec929cccd77bc6e1492a965da00b9905ac79b555cbc70522842a4a2c514300970043deab9e4e61db00d98fb21a8e8b652430a86
6
+ metadata.gz: ecb48e82f04873abc00679c6527e0e00f629e8e654747969a3f69eb0939730eca1272de3710f4e5308cd65b563483f599cafa5c15543a7b470aa4ba065713b14
7
+ data.tar.gz: 03fc9650d0d19bb1bb46c871f16becb722afdc65e061405e60e54c38e858ac74f91e8df5e83a453970473ba1d15c18c80614984c439a41c9e56ff7ae6da4d71b
@@ -13,7 +13,7 @@ Style/CollectionMethods:
13
13
  find: detect
14
14
  find_all: select
15
15
  reduce: inject
16
- Style/DotPosition:
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
- Style/FileName:
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
- Style/PredicateName:
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/TrailingComma:
118
- Description: Checks for trailing comma in parameter lists and literals.
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
- Enabled: false
121
- EnforcedStyleForMultiline: no_comma
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
- - comma
124
- - no_comma
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
- Style/AccessorMethodName:
180
+ Naming/AccessorMethodName:
171
181
  Description: Check the naming of accessor methods for get_/set_.
172
182
  Enabled: false
173
183
  Style/Alias:
@@ -0,0 +1 @@
1
+ 2.5.0
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
3
+ - 2.3
4
+ - 2.4
5
+ - 2.5
4
6
  script: "bundle exec rake spec"
5
7
  gemfile:
6
- - gemfiles/rails3.gemfile
7
8
  - gemfiles/rails4.gemfile
8
9
  - gemfiles/rails5.gemfile
9
10
  notifications:
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 (Removes Rails3 Support)
4
+
5
+ * [TT-3778] Store the cacheable attributes in memory for the duration of the request
6
+
3
7
  ## 0.3.0
4
8
 
5
9
  * Use coverage kit to enforce maximum coverage
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 3:
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 = "#{self.name}.attribute_cache"
19
- cache.read(cache_key) || self.generate_cache(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(self.cache_attributes_by), o.attributes] }]
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
- if (cache_value = generate_attributes_hash)
30
- cache.write(cache_key, cache_value)
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
@@ -1,3 +1,3 @@
1
1
  module RailsCoreExtensions
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  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', ['>= 2.3.0']
23
- spec.add_dependency 'actionpack', ['>= 2.3.0']
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'
@@ -1,4 +1,4 @@
1
1
  require 'simplecov-rcov'
2
2
  require 'coveralls'
3
3
  require 'coverage/kit'
4
- Coverage::Kit.setup(minimum_coverage: 81)
4
+ Coverage::Kit.setup(minimum_coverage: 81.3)
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.3.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: 2017-09-27 00:00:00.000000000 Z
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: 2.3.0
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: 2.3.0
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: 2.3.0
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: 2.3.0
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.6.8
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.
@@ -1,6 +0,0 @@
1
- source :rubygems
2
- gemspec :path => '../'
3
-
4
- group :development, :test do
5
- gem 'activerecord', '~> 3.2.0'
6
- end