cachetastic 1.2.7.1 → 1.3.0
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.
@@ -71,15 +71,7 @@ class Cachetastic::Adapters::File < Cachetastic::Adapters::Base
|
|
71
71
|
def get_key_directoy(key, mkdir = true)
|
72
72
|
hkey = self.hashed_keys[key.to_sym]
|
73
73
|
if hkey.nil?
|
74
|
-
|
75
|
-
hkey = hkey * -1 if hkey < 0
|
76
|
-
hkey = hkey.to_s
|
77
|
-
i = 0
|
78
|
-
path = self.directory
|
79
|
-
until i == hkey.length do
|
80
|
-
path = File.join(path, hkey[i..i])
|
81
|
-
i += 1
|
82
|
-
end
|
74
|
+
path = File.join(self.directory, Cachetastic::Helpers::FileUtils.directory_from_key(key))
|
83
75
|
self.hashed_keys[key.to_sym] = path
|
84
76
|
hkey = path
|
85
77
|
end
|
@@ -74,15 +74,7 @@ class Cachetastic::Adapters::HtmlFile < Cachetastic::Adapters::Base
|
|
74
74
|
def get_key_directoy(key, mkdir = true)
|
75
75
|
hkey = self.hashed_keys[key.to_sym]
|
76
76
|
if hkey.nil?
|
77
|
-
|
78
|
-
hkey = hkey * -1 if hkey < 0
|
79
|
-
hkey = hkey.to_s
|
80
|
-
i = 0
|
81
|
-
path = self.directory
|
82
|
-
until i == hkey.length do
|
83
|
-
path = File.join(path, hkey[i..i])
|
84
|
-
i += 1
|
85
|
-
end
|
77
|
+
path = File.join(self.directory, Cachetastic::Helpers::FileUtils.directory_from_key(key))
|
86
78
|
self.hashed_keys[key.to_sym] = path
|
87
79
|
hkey = path
|
88
80
|
end
|
@@ -109,9 +101,9 @@ class Cachetastic::Adapters::HtmlFile < Cachetastic::Adapters::Base
|
|
109
101
|
end
|
110
102
|
|
111
103
|
def store_object_to_html(so)
|
112
|
-
x =
|
113
|
-
x << "<!-- cachetastic:
|
114
|
-
x << so.
|
104
|
+
x = so.value
|
105
|
+
x << "\n<!-- cachetastic: expires_at: #{so.expires_at} -->"
|
106
|
+
x << "\n<!-- cachetastic: key: #{so.key} -->"
|
115
107
|
end
|
116
108
|
|
117
109
|
STORE_FILE_NAME = "index.html"
|
data/lib/cachetastic.rb
CHANGED
@@ -31,6 +31,7 @@ require 'caches/cachetastic_caches_page_cache'
|
|
31
31
|
require 'caches/cachetastic_caches_rails_session_cache'
|
32
32
|
require 'caches/cachetastic_caches_mack_session_cache'
|
33
33
|
require 'errors/cachetastic_errors_unsupported_adapter'
|
34
|
+
require 'helpers/cachetastic_helpers_file_utils'
|
34
35
|
require 'adapters/cachetastic_adapters_base'
|
35
36
|
require 'adapters/cachetastic_adapters_store_object'
|
36
37
|
require 'adapters/cachetastic_adapters_memcache'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module Cachetastic
|
5
|
+
module Helpers
|
6
|
+
module FileUtils
|
7
|
+
|
8
|
+
def self.directory_from_key(key)
|
9
|
+
hkey = Base64.encode64(Digest::MD5.digest(key))
|
10
|
+
hkey.gsub!("==\n", "")
|
11
|
+
i = 0
|
12
|
+
path = ""
|
13
|
+
until i >= hkey.length do
|
14
|
+
path = File.join(path, hkey[i..i+2])
|
15
|
+
i += 3
|
16
|
+
end
|
17
|
+
path
|
18
|
+
end
|
19
|
+
|
20
|
+
end # FileUtils
|
21
|
+
end # Helpers
|
22
|
+
end # Cachetastic
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cachetastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markbates
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-02-
|
13
|
+
date: 2008-02-27 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/cachetastic_logger.rb
|
41
41
|
- lib/errors/cachetastic_errors_unsupported_adapter.rb
|
42
42
|
- lib/helpers/cachetastic_helpers_active_record.rb
|
43
|
+
- lib/helpers/cachetastic_helpers_file_utils.rb
|
43
44
|
- lib/rails_extensions/cachetastic_active_record_base.rb
|
44
45
|
- lib/rails_extensions/cgi_session_cachetastic_store.rb
|
45
46
|
- lib/tasks/rubyforge_config.yml
|