padrino-cache 0.12.8.1 → 0.12.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/Rakefile +1 -5
- data/lib/padrino-cache/helpers/cache_object.rb +2 -1
- data/lib/padrino-cache/helpers/fragment.rb +3 -2
- data/lib/padrino-cache/helpers/page.rb +1 -1
- data/test/helper.rb +20 -2
- data/test/test_padrino_cache.rb +42 -0
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZThkZjA2ZTMyOWI1MWZkMTgwMDdiNTU1Mzk2MDhiMmViZTY0YTFjNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTgzNTJiNDRiNTA2MDdhZjk1OGY4MTg0NzRlZDU0ZTVmZmUwNjE3YQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmUyZmM1NzI5NTU3MTIzZmQxMDJjNjEzZTM3MjU5YjRhOGQ1MjY1OTBmMDFm
|
10
|
+
NDkwMjExMzBjMGQwODhlZjFkM2NkZjkxYWMxZmI3MTk5NDFiOWU0YTFjMDM1
|
11
|
+
YTE0MzFlNTIxYTgyZDBjODViZGIxMmJiYzYyYjAzYjRiZGU1MDk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTU0MTQ0NzdmYTU0Mzg1Y2YyZWFmMTEwMmE1MTZmY2M5NDdkOTRjZGRiMTY0
|
14
|
+
YmFiZGE0MzNjNjhhYjAwMDMyMjQ3NDMwYmZjNmNjNWUyZWY4NmVjMGQ2ZDg2
|
15
|
+
ZWI4Y2RhZmFhZTdlNWNmMDAyOGNkMWFkYjliNDg3MWUyMmE4Mzk=
|
data/Rakefile
CHANGED
@@ -5,7 +5,8 @@ module Padrino
|
|
5
5
|
def cache_object(key, opts = {})
|
6
6
|
if settings.caching?
|
7
7
|
began_at = Time.now
|
8
|
-
if
|
8
|
+
if settings.cache.key?(key.to_s)
|
9
|
+
value = settings.cache[key.to_s]
|
9
10
|
logger.debug "GET Object", began_at, key.to_s if defined?(logger)
|
10
11
|
else
|
11
12
|
value = yield
|
@@ -51,9 +51,10 @@ module Padrino
|
|
51
51
|
def cache(key, opts = {}, &block)
|
52
52
|
if settings.caching?
|
53
53
|
began_at = Time.now
|
54
|
-
if
|
54
|
+
if settings.cache.key?(key.to_s)
|
55
|
+
value = settings.cache[key.to_s]
|
55
56
|
logger.debug "GET Fragment", began_at, key.to_s if defined?(logger)
|
56
|
-
concat_content(value.html_safe)
|
57
|
+
concat_content(value.to_s.html_safe)
|
57
58
|
else
|
58
59
|
value = capture_html(&block)
|
59
60
|
settings.cache.store(key.to_s, value, opts)
|
data/test/helper.rb
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
ENV['RACK_ENV'] = 'test'
|
2
2
|
PADRINO_ROOT = File.dirname(__FILE__) unless defined?(PADRINO_ROOT)
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'minitest/pride'
|
6
|
+
require 'rack/test'
|
6
7
|
require 'padrino-cache'
|
8
|
+
|
9
|
+
require 'ext/rack-test-methods'
|
10
|
+
|
11
|
+
class MiniTest::Spec
|
12
|
+
include Rack::Test::Methods
|
13
|
+
|
14
|
+
# Sets up a Sinatra::Base subclass defined with the block
|
15
|
+
# given. Used in setup or individual spec methods to establish
|
16
|
+
# the application.
|
17
|
+
def mock_app(base=Padrino::Application, &block)
|
18
|
+
@app = Sinatra.new(base, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def app
|
22
|
+
Rack::Lint.new(@app)
|
23
|
+
end
|
24
|
+
end
|
data/test/test_padrino_cache.rb
CHANGED
@@ -479,4 +479,46 @@ describe "PadrinoCache" do
|
|
479
479
|
end
|
480
480
|
assert_kind_of Moneta::Adapters::Memory, adapter
|
481
481
|
end
|
482
|
+
|
483
|
+
it "should check key existence" do
|
484
|
+
count1, count2 = 0, 0
|
485
|
+
mock_app do
|
486
|
+
register Padrino::Cache
|
487
|
+
enable :caching
|
488
|
+
get "/" do
|
489
|
+
cache(:foo) do
|
490
|
+
count1 += 1
|
491
|
+
nil
|
492
|
+
end
|
493
|
+
count1.inspect
|
494
|
+
end
|
495
|
+
|
496
|
+
get "/object" do
|
497
|
+
cache_object(:bar) do
|
498
|
+
count2 += 1
|
499
|
+
nil
|
500
|
+
end
|
501
|
+
count2.inspect
|
502
|
+
end
|
503
|
+
end
|
504
|
+
2.times { get "/" }
|
505
|
+
assert_equal "1", body
|
506
|
+
2.times { get "/object" }
|
507
|
+
assert_equal "1", body
|
508
|
+
end
|
509
|
+
|
510
|
+
it 'should cache full mime type of content_type' do
|
511
|
+
mock_app do
|
512
|
+
register Padrino::Cache
|
513
|
+
enable :caching
|
514
|
+
get '/foo', :cache => true do
|
515
|
+
content_type :json, :charset => 'utf-8'
|
516
|
+
'{}'
|
517
|
+
end
|
518
|
+
end
|
519
|
+
get "/foo"
|
520
|
+
assert_equal 'application/json;charset=utf-8', last_response.content_type
|
521
|
+
get "/foo"
|
522
|
+
assert_equal 'application/json;charset=utf-8', last_response.content_type
|
523
|
+
end
|
482
524
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2018-02-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-core
|
@@ -19,42 +19,44 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.12.
|
22
|
+
version: 0.12.9
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.12.
|
29
|
+
version: 0.12.9
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: padrino-helpers
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - '='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.12.
|
36
|
+
version: 0.12.9
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - '='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.12.
|
43
|
+
version: 0.12.9
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: moneta
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - ~>
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: !binary |-
|
51
|
+
MC43LjA=
|
51
52
|
type: :runtime
|
52
53
|
prerelease: false
|
53
54
|
version_requirements: !ruby/object:Gem::Requirement
|
54
55
|
requirements:
|
55
|
-
- -
|
56
|
+
- - ~>
|
56
57
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
+
version: !binary |-
|
59
|
+
MC43LjA=
|
58
60
|
description: Caching support for memcached, page and fragment
|
59
61
|
email: padrinorb@gmail.com
|
60
62
|
executables: []
|
@@ -62,9 +64,9 @@ extensions: []
|
|
62
64
|
extra_rdoc_files:
|
63
65
|
- README.rdoc
|
64
66
|
files:
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
67
|
+
- .document
|
68
|
+
- .gitignore
|
69
|
+
- .yardopts
|
68
70
|
- LICENSE.txt
|
69
71
|
- README.rdoc
|
70
72
|
- Rakefile
|
@@ -85,22 +87,22 @@ licenses:
|
|
85
87
|
metadata: {}
|
86
88
|
post_install_message:
|
87
89
|
rdoc_options:
|
88
|
-
-
|
90
|
+
- --charset=UTF-8
|
89
91
|
require_paths:
|
90
92
|
- lib
|
91
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
94
|
requirements:
|
93
|
-
- -
|
95
|
+
- - ! '>='
|
94
96
|
- !ruby/object:Gem::Version
|
95
97
|
version: '0'
|
96
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
99
|
requirements:
|
98
|
-
- -
|
100
|
+
- - ! '>='
|
99
101
|
- !ruby/object:Gem::Version
|
100
102
|
version: 1.3.6
|
101
103
|
requirements: []
|
102
104
|
rubyforge_project: padrino-cache
|
103
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.6.14
|
104
106
|
signing_key:
|
105
107
|
specification_version: 4
|
106
108
|
summary: Page and fragment caching for Padrino
|