infopark_component_cache 2.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
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 +2 -4
  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 +15 -12
  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 +7 -6
  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 -4
  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 -35
  38. data/spec/dummy/config/environments/test.rb +2 -8
  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 +81 -30
@@ -1,6 +1,8 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe InfoparkComponentCache::Guards::ObjCount 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::ObjCount do
9
11
  end
10
12
  end
11
13
 
12
- let(:count) { 12314 }
14
+ let(:count) { 12_314 }
13
15
 
14
16
  let(:obj_stub) do
15
17
  double.tap do |obj_stub|
@@ -21,8 +23,6 @@ describe InfoparkComponentCache::Guards::ObjCount do
21
23
 
22
24
  before { InfoparkComponentCache::CmsStateGuard.obj_root_class = obj_stub }
23
25
 
24
- subject { described_class.new(cache_component_stub) }
25
-
26
26
  context "with cache disabled" do
27
27
  disable_cache
28
28
 
@@ -31,7 +31,8 @@ describe InfoparkComponentCache::Guards::ObjCount do
31
31
  end
32
32
 
33
33
  context "with a call to guard!" do
34
- before { subject.guard! }
34
+ before { guard.guard! }
35
+
35
36
  it { is_expected.not_to be_consistent }
36
37
  end
37
38
  end
@@ -45,19 +46,26 @@ describe InfoparkComponentCache::Guards::ObjCount do
45
46
  end
46
47
 
47
48
  context "with a call to guard!" do
48
- before { subject.guard! }
49
+ before { guard.guard! }
50
+
49
51
  it { is_expected.to be_consistent }
50
52
  end
51
53
 
52
- context "after obj count increases" do
53
- before { subject.guard! }
54
- before { obj_stub.stub(:count).and_return(55555) }
54
+ context "when after obj count increases" do
55
+ before do
56
+ guard.guard!
57
+ obj_stub.stub(:count).and_return(55_555)
58
+ end
59
+
55
60
  it { is_expected.not_to be_consistent }
56
61
  end
57
62
 
58
- context "after obj count decreases" do
59
- before { subject.guard! }
60
- before { obj_stub.stub(:count).and_return(500) }
63
+ context "when after obj count decreases" do
64
+ before do
65
+ guard.guard!
66
+ obj_stub.stub(:count).and_return(500)
67
+ end
68
+
61
69
  it { is_expected.not_to be_consistent }
62
70
  end
63
71
  end
@@ -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,45 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_component_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 4.0.0
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: 2015-07-08 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
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
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: 3.0.0
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
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 7.0.1.5.2.3.rc5
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec-rails
42
+ name: pry-byebug
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,35 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: sqlite3
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.87.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.87.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-performance
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - ">="
@@ -67,7 +95,7 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
- name: byebug
98
+ name: rubocop-rspec
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -80,6 +108,20 @@ dependencies:
80
108
  - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
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.6
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.3.6
83
125
  description: Easy and intelligent fragment caching for RailsConnector projects
84
126
  email:
85
127
  - tomasz.przedmojski@infopark.de
@@ -89,8 +131,14 @@ extra_rdoc_files: []
89
131
  files:
90
132
  - ".gitignore"
91
133
  - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".rubocop_todo.yml"
92
136
  - ".ruby-version"
137
+ - ".travis.yml"
93
138
  - Gemfile
139
+ - Gemfile.lock
140
+ - Gemfile.rails51
141
+ - Gemfile.rails51.lock
94
142
  - LICENSE.txt
95
143
  - README.md
96
144
  - Rakefile
@@ -137,17 +185,19 @@ files:
137
185
  - spec/dummy/db/development.sqlite3
138
186
  - spec/dummy/db/schema.rb
139
187
  - 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
188
+ - spec/lib/infopark_component_cache/component_cache_spec.rb
189
+ - spec/lib/infopark_component_cache/delayed_guard_spec.rb
190
+ - spec/lib/infopark_component_cache/guards/always_consistent_spec.rb
191
+ - spec/lib/infopark_component_cache/guards/last_changed_spec.rb
192
+ - spec/lib/infopark_component_cache/guards/never_consistent_spec.rb
193
+ - spec/lib/infopark_component_cache/guards/obj_count_spec.rb
194
+ - spec/lib/infopark_component_cache/guards/valid_from_spec.rb
195
+ - spec/lib/infopark_component_cache/guards/valid_until_spec.rb
147
196
  - spec/spec_helper.rb
148
197
  - spec/support/cache_switching_macros.rb
149
198
  homepage: ''
150
- licenses: []
199
+ licenses:
200
+ - Nonstandard
151
201
  metadata: {}
152
202
  post_install_message:
153
203
  rdoc_options: []
@@ -165,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
215
  version: '0'
166
216
  requirements: []
167
217
  rubyforge_project:
168
- rubygems_version: 2.2.3
218
+ rubygems_version: 2.6.13
169
219
  signing_key:
170
220
  specification_version: 4
171
221
  summary: Fragment caching with automatic dependency resolution and cache invalidation.
@@ -187,12 +237,13 @@ test_files:
187
237
  - spec/dummy/db/development.sqlite3
188
238
  - spec/dummy/db/schema.rb
189
239
  - 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
240
+ - spec/lib/infopark_component_cache/component_cache_spec.rb
241
+ - spec/lib/infopark_component_cache/delayed_guard_spec.rb
242
+ - spec/lib/infopark_component_cache/guards/always_consistent_spec.rb
243
+ - spec/lib/infopark_component_cache/guards/last_changed_spec.rb
244
+ - spec/lib/infopark_component_cache/guards/never_consistent_spec.rb
245
+ - spec/lib/infopark_component_cache/guards/obj_count_spec.rb
246
+ - spec/lib/infopark_component_cache/guards/valid_from_spec.rb
247
+ - spec/lib/infopark_component_cache/guards/valid_until_spec.rb
197
248
  - spec/spec_helper.rb
198
249
  - spec/support/cache_switching_macros.rb