infopark_component_cache 3.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.rubocop.yml +25 -0
  4. data/.rubocop_todo.yml +115 -0
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +24 -0
  7. data/Gemfile +3 -1
  8. data/Gemfile.lock +206 -0
  9. data/Gemfile.rails51 +6 -0
  10. data/Gemfile.rails51.lock +206 -0
  11. data/README.md +8 -0
  12. data/Rakefile +7 -7
  13. data/app/helpers/infopark_component_cache_helper.rb +2 -2
  14. data/infopark_component_cache.gemspec +16 -13
  15. data/lib/engine.rb +6 -7
  16. data/lib/infopark_component_cache.rb +1 -2
  17. data/lib/infopark_component_cache/abstract_cache_storage.rb +4 -3
  18. data/lib/infopark_component_cache/cache_storage.rb +1 -0
  19. data/lib/infopark_component_cache/component.rb +14 -6
  20. data/lib/infopark_component_cache/component_cache.rb +35 -31
  21. data/lib/infopark_component_cache/consistency_guard.rb +1 -1
  22. data/lib/infopark_component_cache/delayed_guard.rb +7 -7
  23. data/lib/infopark_component_cache/guards/cms_state_guard.rb +6 -5
  24. data/lib/infopark_component_cache/guards/last_changed.rb +5 -2
  25. data/lib/infopark_component_cache/guards/obj_count.rb +3 -3
  26. data/lib/infopark_component_cache/guards/valid_from.rb +7 -10
  27. data/lib/infopark_component_cache/guards/valid_until.rb +7 -9
  28. data/lib/infopark_component_cache/key_generator.rb +3 -3
  29. data/lib/infopark_component_cache/version.rb +1 -1
  30. data/lib/infopark_component_cache/volatile_cache.rb +1 -1
  31. data/lib/infopark_component_cache/volatile_cache_storage.rb +1 -0
  32. data/spec/dummy/Rakefile +1 -1
  33. data/spec/dummy/config.ru +1 -1
  34. data/spec/dummy/config/application.rb +1 -2
  35. data/spec/dummy/config/boot.rb +5 -5
  36. data/spec/dummy/config/environment.rb +1 -1
  37. data/spec/dummy/config/environments/development.rb +1 -0
  38. data/spec/dummy/config/environments/test.rb +2 -0
  39. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  40. data/spec/dummy/config/initializers/session_store.rb +1 -1
  41. data/spec/dummy/db/schema.rb +1 -2
  42. data/spec/lib/infopark_component_cache/component_cache_spec.rb +118 -0
  43. data/spec/lib/{delayed_guard_spec.rb → infopark_component_cache/delayed_guard_spec.rb} +3 -3
  44. data/spec/lib/{guards → infopark_component_cache/guards}/always_consistent_spec.rb +7 -6
  45. data/spec/lib/{guards → infopark_component_cache/guards}/last_changed_spec.rb +20 -12
  46. data/spec/lib/{guards → infopark_component_cache/guards}/never_consistent_spec.rb +7 -6
  47. data/spec/lib/{guards → infopark_component_cache/guards}/obj_count_spec.rb +20 -12
  48. data/spec/lib/{guards → infopark_component_cache/guards}/valid_from_spec.rb +20 -12
  49. data/spec/lib/{guards → infopark_component_cache/guards}/valid_until_spec.rb +23 -14
  50. data/spec/spec_helper.rb +10 -7
  51. data/spec/support/cache_switching_macros.rb +4 -4
  52. metadata +95 -38
@@ -1,6 +1,8 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe InfoparkComponentCache::Guards::ValidFrom do
4
+ subject(:guard) { described_class.new(cache_component_stub) }
5
+
4
6
  let(:cache_component_stub) do
5
7
  double.tap do |cache_component_stub|
6
8
  cache_component_stub.stub(:cache_key) do |input|
@@ -9,7 +11,7 @@ describe InfoparkComponentCache::Guards::ValidFrom do
9
11
  end
10
12
  end
11
13
 
12
- let(:minimum_valid_from) { 10.minutes.since.to_iso }
14
+ let(:minimum_valid_from) { 10.minutes.since }
13
15
 
14
16
  let(:obj_stub) do
15
17
  double.tap do |obj_stub|
@@ -23,8 +25,6 @@ describe InfoparkComponentCache::Guards::ValidFrom do
23
25
 
24
26
  before { InfoparkComponentCache::CmsStateGuard.obj_root_class = obj_stub }
25
27
 
26
- subject { described_class.new(cache_component_stub) }
27
-
28
28
  context "with cache disabled" do
29
29
  disable_cache
30
30
 
@@ -33,7 +33,8 @@ describe InfoparkComponentCache::Guards::ValidFrom do
33
33
  end
34
34
 
35
35
  context "with a call to guard!" do
36
- before { subject.guard! }
36
+ before { guard.guard! }
37
+
37
38
  it { is_expected.not_to be_consistent }
38
39
  end
39
40
  end
@@ -47,19 +48,26 @@ describe InfoparkComponentCache::Guards::ValidFrom do
47
48
  end
48
49
 
49
50
  context "with a call to guard!" do
50
- before { subject.guard! }
51
+ before { guard.guard! }
52
+
51
53
  it { is_expected.to be_consistent }
52
54
  end
53
55
 
54
- context "after minimum valid from changes to a present date" do
55
- before { subject.guard! }
56
- before { obj_stub.stub(:minimum).and_return(Time.now.to_iso) }
56
+ context "when after minimum valid from changes to a present date" do
57
+ before do
58
+ guard.guard!
59
+ obj_stub.stub(:minimum).and_return(Time.now.to_iso)
60
+ end
61
+
57
62
  it { is_expected.not_to be_consistent }
58
63
  end
59
64
 
60
- context "after minimum valid from changes to a past date" do
61
- before { subject.guard! }
62
- before { obj_stub.stub(:minimum).and_return(1.month.ago.to_iso) }
65
+ context "when after minimum valid from changes to a past date" do
66
+ before do
67
+ guard.guard!
68
+ obj_stub.stub(:minimum).and_return(1.month.ago.to_iso)
69
+ end
70
+
63
71
  it { is_expected.not_to be_consistent }
64
72
  end
65
73
  end
@@ -1,6 +1,8 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe InfoparkComponentCache::Guards::ValidUntil do
4
+ subject(:guard) { described_class.new(cache_component_stub) }
5
+
4
6
  let(:cache_component_stub) do
5
7
  double.tap do |cache_component_stub|
6
8
  cache_component_stub.stub(:cache_key) do |input|
@@ -9,7 +11,7 @@ describe InfoparkComponentCache::Guards::ValidUntil do
9
11
  end
10
12
  end
11
13
 
12
- let(:minimum_valid_until) { 10.minutes.since.to_iso }
14
+ let(:minimum_valid_until) { 10.minutes.since }
13
15
 
14
16
  let(:obj_stub) do
15
17
  double.tap do |obj_stub|
@@ -23,8 +25,6 @@ describe InfoparkComponentCache::Guards::ValidUntil do
23
25
 
24
26
  before { InfoparkComponentCache::CmsStateGuard.obj_root_class = obj_stub }
25
27
 
26
- subject { described_class.new(cache_component_stub) }
27
-
28
28
  context "with cache disabled" do
29
29
  disable_cache
30
30
 
@@ -33,7 +33,8 @@ describe InfoparkComponentCache::Guards::ValidUntil do
33
33
  end
34
34
 
35
35
  context "with a call to guard!" do
36
- before { subject.guard! }
36
+ before { guard.guard! }
37
+
37
38
  it { is_expected.not_to be_consistent }
38
39
  end
39
40
  end
@@ -47,26 +48,34 @@ describe InfoparkComponentCache::Guards::ValidUntil do
47
48
  end
48
49
 
49
50
  context "with a call to guard!" do
50
- before { subject.guard! }
51
+ before { guard.guard! }
52
+
51
53
  it { is_expected.to be_consistent }
52
54
  end
53
55
 
54
- context "after minimum valid until changes to a present date" do
55
- before { subject.guard! }
56
- before { obj_stub.stub(:minimum).and_return(Time.now.to_iso) }
56
+ context "when after minimum valid until changes to a present date" do
57
+ before do
58
+ guard.guard!
59
+ obj_stub.stub(:minimum).and_return(Time.now.to_iso)
60
+ end
61
+
57
62
  it { is_expected.not_to be_consistent }
58
63
  end
59
64
 
60
- context "after minimum valid until changes to a past date" do
61
- before { subject.guard! }
62
- before { obj_stub.stub(:minimum).and_return(1.month.ago.to_iso) }
65
+ context "when after minimum valid until changes to a past date" do
66
+ before do
67
+ guard.guard!
68
+ obj_stub.stub(:minimum).and_return(1.month.ago.to_iso)
69
+ end
70
+
63
71
  it { is_expected.not_to be_consistent }
64
72
  end
65
73
 
66
- context "nil valid until" do
74
+ context "when nil valid until" do
67
75
  let(:minimum_valid_until) { nil }
68
76
 
69
- before { subject.guard! }
77
+ before { guard.guard! }
78
+
70
79
  it { is_expected.to be_consistent }
71
80
  end
72
81
  end
@@ -1,13 +1,13 @@
1
- ENV['RAILS_ENV'] ||= 'test'
1
+ ENV["RAILS_ENV"] ||= "test"
2
2
  # Load dummy app
3
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
3
+ require File.expand_path("dummy/config/environment.rb", __dir__)
4
4
  # Load rspec components
5
- require 'rspec/rails'
6
- require 'byebug'
5
+ require "rspec/rails"
6
+ require "byebug"
7
7
  # Nice backtraces
8
8
  Rails.backtrace_cleaner.remove_silencers!
9
9
  # Load support files
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
11
11
 
12
12
  # configure rspec
13
13
  RSpec.configure do |config|
@@ -17,9 +17,12 @@ RSpec.configure do |config|
17
17
  config.order = "random"
18
18
  config.extend CacheSwitchingMacros
19
19
  config.expect_with :rspec do |c|
20
- c.syntax = [:should, :expect]
20
+ c.syntax = %i(should expect)
21
21
  end
22
22
  config.mock_with :rspec do |c|
23
- c.syntax = [:should, :expect]
23
+ c.syntax = %i(should expect)
24
+ end
25
+ config.before do
26
+ Rails.cache.clear
24
27
  end
25
28
  end
@@ -1,5 +1,5 @@
1
1
  module CacheSwitchingMacros
2
- def enable_cache(trigger=:all)
2
+ def enable_cache(trigger = :all)
3
3
  before(trigger) do
4
4
  @__perform_caching_before ||= []
5
5
  @__perform_caching_before.push Rails.application.config.action_controller.perform_caching
@@ -7,13 +7,13 @@ module CacheSwitchingMacros
7
7
  end
8
8
 
9
9
  after(trigger) do
10
- @__perform_caching_before ||=[]
10
+ @__perform_caching_before ||= []
11
11
  previous_setting = @__perform_caching_before.pop || false
12
12
  Rails.application.config.action_controller.perform_caching = previous_setting
13
13
  end
14
14
  end
15
15
 
16
- def disable_cache(trigger=:all)
16
+ def disable_cache(trigger = :all)
17
17
  before(trigger) do
18
18
  @__perform_caching_before ||= []
19
19
  @__perform_caching_before.push Rails.application.config.action_controller.perform_caching
@@ -21,7 +21,7 @@ module CacheSwitchingMacros
21
21
  end
22
22
 
23
23
  after(trigger) do
24
- @__perform_caching_before ||=[]
24
+ @__perform_caching_before ||= []
25
25
  previous_setting = @__perform_caching_before.pop || false
26
26
  Rails.application.config.action_controller.perform_caching = previous_setting
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_component_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - Tomasz Przedmojski
7
+ - Tomasz Przedmojski, sveninfo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2020-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,70 +16,118 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.6
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.6
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: infopark_fiona_connector
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 7.0.1.5.2.3.rc5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 7.0.1.5.2.3.rc5
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: '3.9'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec-rails
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ">="
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '0'
61
+ version: '3.5'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ">="
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: '3.5'
55
69
  - !ruby/object:Gem::Dependency
56
- name: sqlite3
70
+ name: rubocop
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ">="
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: 0.87.1
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
82
+ version: 0.87.1
69
83
  - !ruby/object:Gem::Dependency
70
- name: byebug
84
+ name: rubocop-performance
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.30'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.30'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.3'
73
118
  - - ">="
74
119
  - !ruby/object:Gem::Version
75
- version: '0'
120
+ version: 1.3.6
76
121
  type: :development
77
122
  prerelease: false
78
123
  version_requirements: !ruby/object:Gem::Requirement
79
124
  requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '1.3'
80
128
  - - ">="
81
129
  - !ruby/object:Gem::Version
82
- version: '0'
130
+ version: 1.3.6
83
131
  description: Easy and intelligent fragment caching for RailsConnector projects
84
132
  email:
85
133
  - tomasz.przedmojski@infopark.de
@@ -89,8 +137,14 @@ extra_rdoc_files: []
89
137
  files:
90
138
  - ".gitignore"
91
139
  - ".rspec"
140
+ - ".rubocop.yml"
141
+ - ".rubocop_todo.yml"
92
142
  - ".ruby-version"
143
+ - ".travis.yml"
93
144
  - Gemfile
145
+ - Gemfile.lock
146
+ - Gemfile.rails51
147
+ - Gemfile.rails51.lock
94
148
  - LICENSE.txt
95
149
  - README.md
96
150
  - Rakefile
@@ -137,17 +191,19 @@ files:
137
191
  - spec/dummy/db/development.sqlite3
138
192
  - spec/dummy/db/schema.rb
139
193
  - spec/dummy/log/.gitkeep
140
- - spec/lib/delayed_guard_spec.rb
141
- - spec/lib/guards/always_consistent_spec.rb
142
- - spec/lib/guards/last_changed_spec.rb
143
- - spec/lib/guards/never_consistent_spec.rb
144
- - spec/lib/guards/obj_count_spec.rb
145
- - spec/lib/guards/valid_from_spec.rb
146
- - spec/lib/guards/valid_until_spec.rb
194
+ - spec/lib/infopark_component_cache/component_cache_spec.rb
195
+ - spec/lib/infopark_component_cache/delayed_guard_spec.rb
196
+ - spec/lib/infopark_component_cache/guards/always_consistent_spec.rb
197
+ - spec/lib/infopark_component_cache/guards/last_changed_spec.rb
198
+ - spec/lib/infopark_component_cache/guards/never_consistent_spec.rb
199
+ - spec/lib/infopark_component_cache/guards/obj_count_spec.rb
200
+ - spec/lib/infopark_component_cache/guards/valid_from_spec.rb
201
+ - spec/lib/infopark_component_cache/guards/valid_until_spec.rb
147
202
  - spec/spec_helper.rb
148
203
  - spec/support/cache_switching_macros.rb
149
- homepage: ''
150
- licenses: []
204
+ homepage: http://infopark.com
205
+ licenses:
206
+ - LGPL-3.0
151
207
  metadata: {}
152
208
  post_install_message:
153
209
  rdoc_options: []
@@ -165,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
221
  version: '0'
166
222
  requirements: []
167
223
  rubyforge_project:
168
- rubygems_version: 2.4.5.1
224
+ rubygems_version: 2.6.13
169
225
  signing_key:
170
226
  specification_version: 4
171
227
  summary: Fragment caching with automatic dependency resolution and cache invalidation.
@@ -187,12 +243,13 @@ test_files:
187
243
  - spec/dummy/db/development.sqlite3
188
244
  - spec/dummy/db/schema.rb
189
245
  - spec/dummy/log/.gitkeep
190
- - spec/lib/delayed_guard_spec.rb
191
- - spec/lib/guards/always_consistent_spec.rb
192
- - spec/lib/guards/last_changed_spec.rb
193
- - spec/lib/guards/never_consistent_spec.rb
194
- - spec/lib/guards/obj_count_spec.rb
195
- - spec/lib/guards/valid_from_spec.rb
196
- - spec/lib/guards/valid_until_spec.rb
246
+ - spec/lib/infopark_component_cache/component_cache_spec.rb
247
+ - spec/lib/infopark_component_cache/delayed_guard_spec.rb
248
+ - spec/lib/infopark_component_cache/guards/always_consistent_spec.rb
249
+ - spec/lib/infopark_component_cache/guards/last_changed_spec.rb
250
+ - spec/lib/infopark_component_cache/guards/never_consistent_spec.rb
251
+ - spec/lib/infopark_component_cache/guards/obj_count_spec.rb
252
+ - spec/lib/infopark_component_cache/guards/valid_from_spec.rb
253
+ - spec/lib/infopark_component_cache/guards/valid_until_spec.rb
197
254
  - spec/spec_helper.rb
198
255
  - spec/support/cache_switching_macros.rb