tdiary 4.0.1.20130929 → 4.0.1.20131102
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile +0 -9
- data/Gemfile.lock +16 -22
- data/misc/convert2.rb +2 -2
- data/misc/plugin/disp_referrer.rb +1 -1
- data/plugin/05referer.rb +1 -1
- data/plugin/90migrate.rb +1 -1
- data/spec/acceptance/save_conf_referer_spec.rb +3 -3
- data/spec/acceptance_helper.rb +2 -34
- data/tdiary/{io/cache → cache}/file.rb +1 -1
- data/tdiary/configuration.rb +2 -2
- data/tdiary/io/base.rb +49 -47
- data/tdiary/io/default.rb +214 -212
- data/tdiary/io/pstore.rb +43 -41
- data/tdiary/tasks/release.rake +1 -1
- data/tdiary/tasks/rspec.rake +0 -6
- data/tdiary/version.rb +1 -1
- data/test/disp_referrer_test.rb +1 -1
- metadata +14 -19
- data/spec/fixtures/tdiary.conf.rdb +0 -227
- data/tdiary/io/cache/memcached.rb +0 -88
- data/tdiary/io/cache/redis.rb +0 -100
- data/tdiary/io/rdb.rb +0 -213
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdiary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.1.
|
4
|
+
version: 4.0.1.20131102
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
@@ -10,34 +10,34 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-11-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0.18'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0.18'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: bundler
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '1.3'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '1.3'
|
43
43
|
description: tDiary is so called Weblog.
|
@@ -48,9 +48,9 @@ executables:
|
|
48
48
|
extensions: []
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
|
-
- .coveralls.yml
|
52
|
-
- .gitignore
|
53
|
-
- .travis.yml
|
51
|
+
- ".coveralls.yml"
|
52
|
+
- ".gitignore"
|
53
|
+
- ".travis.yml"
|
54
54
|
- ChangeLog
|
55
55
|
- Gemfile
|
56
56
|
- Gemfile.lock
|
@@ -325,7 +325,6 @@ files:
|
|
325
325
|
- spec/fixtures/sample.rb
|
326
326
|
- spec/fixtures/tdiary.conf.gem
|
327
327
|
- spec/fixtures/tdiary.conf.rack
|
328
|
-
- spec/fixtures/tdiary.conf.rdb
|
329
328
|
- spec/fixtures/tdiary.conf.secure
|
330
329
|
- spec/fixtures/tdiary.conf.webrick
|
331
330
|
- spec/javascripts/00default_spec.js
|
@@ -347,6 +346,7 @@ files:
|
|
347
346
|
- tdiary/application/extensions/omniauth.rb
|
348
347
|
- tdiary/author_only_base.rb
|
349
348
|
- tdiary/base.rb
|
349
|
+
- tdiary/cache/file.rb
|
350
350
|
- tdiary/cli.rb
|
351
351
|
- tdiary/comment.rb
|
352
352
|
- tdiary/comment_manager.rb
|
@@ -361,12 +361,8 @@ files:
|
|
361
361
|
- tdiary/filter/default.rb
|
362
362
|
- tdiary/filter/spam.rb
|
363
363
|
- tdiary/io/base.rb
|
364
|
-
- tdiary/io/cache/file.rb
|
365
|
-
- tdiary/io/cache/memcached.rb
|
366
|
-
- tdiary/io/cache/redis.rb
|
367
364
|
- tdiary/io/default.rb
|
368
365
|
- tdiary/io/pstore.rb
|
369
|
-
- tdiary/io/rdb.rb
|
370
366
|
- tdiary/lang/en.rb
|
371
367
|
- tdiary/lang/ja.rb
|
372
368
|
- tdiary/plugin.rb
|
@@ -427,20 +423,20 @@ metadata: {}
|
|
427
423
|
post_install_message:
|
428
424
|
rdoc_options: []
|
429
425
|
require_paths:
|
430
|
-
- .
|
426
|
+
- "."
|
431
427
|
required_ruby_version: !ruby/object:Gem::Requirement
|
432
428
|
requirements:
|
433
|
-
- -
|
429
|
+
- - ">="
|
434
430
|
- !ruby/object:Gem::Version
|
435
431
|
version: 1.9.2
|
436
432
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
437
433
|
requirements:
|
438
|
-
- -
|
434
|
+
- - ">="
|
439
435
|
- !ruby/object:Gem::Version
|
440
436
|
version: '0'
|
441
437
|
requirements: []
|
442
438
|
rubyforge_project:
|
443
|
-
rubygems_version: 2.
|
439
|
+
rubygems_version: 2.2.0
|
444
440
|
signing_key:
|
445
441
|
specification_version: 4
|
446
442
|
summary: a TSUKKOMI-able Web-log
|
@@ -481,7 +477,6 @@ test_files:
|
|
481
477
|
- spec/fixtures/sample.rb
|
482
478
|
- spec/fixtures/tdiary.conf.gem
|
483
479
|
- spec/fixtures/tdiary.conf.rack
|
484
|
-
- spec/fixtures/tdiary.conf.rdb
|
485
480
|
- spec/fixtures/tdiary.conf.secure
|
486
481
|
- spec/fixtures/tdiary.conf.webrick
|
487
482
|
- spec/javascripts/00default_spec.js
|
@@ -1,227 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
@data_path = File.expand_path("../tmp/data", __FILE__)
|
4
|
-
@cache_path = "#{@data_path}/cache"
|
5
|
-
@database_url = 'sqlite://tmp/tdiary_test.db'
|
6
|
-
@user_name = 'test'
|
7
|
-
|
8
|
-
require 'tdiary/io/cache/memcached'
|
9
|
-
require 'tdiary/io/rdb'
|
10
|
-
@io_class = TDiary::RdbIO
|
11
|
-
|
12
|
-
@style = 'Wiki'
|
13
|
-
|
14
|
-
@index = './'
|
15
|
-
@update = 'update.rb'
|
16
|
-
|
17
|
-
@options['apply_plugin'] = true
|
18
|
-
@options['sp.path'] = [
|
19
|
-
'misc/plugin'
|
20
|
-
]
|
21
|
-
@options['style.path'] = [
|
22
|
-
'misc/style/gfm',
|
23
|
-
'tdiary/style'
|
24
|
-
]
|
25
|
-
|
26
|
-
@accesskey_enabled = false
|
27
|
-
@options['bot'] = [
|
28
|
-
'^BlogLines/',
|
29
|
-
'^blogmap',
|
30
|
-
'MI[CK]AN/',
|
31
|
-
'^NG/',
|
32
|
-
'^samidare',
|
33
|
-
'^TAMATEBAKO/'
|
34
|
-
]
|
35
|
-
|
36
|
-
@options['sp.selected'] =
|
37
|
-
"amazon.rb
|
38
|
-
append-css.rb
|
39
|
-
calendar2.rb
|
40
|
-
category.rb
|
41
|
-
comment_mail-smtp.rb
|
42
|
-
disp_referrer.rb
|
43
|
-
dropdown_calendar.rb
|
44
|
-
footnote.rb
|
45
|
-
highlight.rb
|
46
|
-
image.rb
|
47
|
-
jdate.rb
|
48
|
-
kw.rb
|
49
|
-
makerss.rb
|
50
|
-
my-ex.rb
|
51
|
-
recent_comment3.rb
|
52
|
-
recent_list.rb
|
53
|
-
"
|
54
|
-
|
55
|
-
@options['dropdown_calendar.label'] = ''
|
56
|
-
@options['makerss.file'] = 'public/index.rdf'
|
57
|
-
@options['makerss.no_comments.file'] = 'public/no_comments.rdf'
|
58
|
-
|
59
|
-
@options['spamfilter.bad_comment_patts'] = "(href=|casino|gambling|betting|fastsearch\\.eu\\.com|ganzao|poker|holdem|hold.em|roulette|drug|tramadol|viagra|fioricet|oxycontin|biaxin|aldara|business cards|home depot|slot.?machine|insurance|getblog2|video-game|Good site|internet-all\\.com|deai|tdfms|comu2|omaha)\r\n"
|
60
|
-
@options['spamfilter.bad_ip_addrs'] = ""
|
61
|
-
@options['spamfilter.bad_mail_patts'] = "(mu@alloha\\.info|mumu2004@mail\\.com|zhongleibo|dfd@12\\.com|anonimous|aol\\.|yahoo\\.|google\\.|hotmail\\.|msn\\.|leroy\\.|ablare\\.|gmx\\.|lorazepam|\\.co$)"
|
62
|
-
@options['spamfilter.bad_uri_patts'] = ""
|
63
|
-
@options['spamfilter.bad_uri_patts_for_mails'] = false
|
64
|
-
@options['spamfilter.debug_file'] = ""
|
65
|
-
@options['spamfilter.debug_mode'] = false
|
66
|
-
@options['spamfilter.filter_mode'] = true
|
67
|
-
@options['spamfilter.max_uris'] = "2"
|
68
|
-
@options['spamfilter.resolv_check'] = false
|
69
|
-
@options['spamfilter.resolv_check_mode'] = false
|
70
|
-
@options['spamlookup.domain.list'] = "bsb.spamlookup.net\r\nsc.surbl.org\r\nrbl.bulkfeeds.jp"
|
71
|
-
@options['spamlookup.safe_domain.list'] = "search.yahoo.co.jp\r\nwww.google.com\r\nwww.google.co.jp\r\nsearch.msn.co.jp"
|
72
|
-
|
73
|
-
|
74
|
-
@html_title = %Q[【日記のタイトル】(→<a href="#{@update}?conf=default">サイトの情報</a>で変更しましょう)]
|
75
|
-
|
76
|
-
@header = <<HEADER
|
77
|
-
<%= navi %>
|
78
|
-
<h1><%= @conf.html_title %></h1>
|
79
|
-
<div class="main">
|
80
|
-
HEADER
|
81
|
-
|
82
|
-
@footer = <<FOOTER
|
83
|
-
</div>
|
84
|
-
<div class="sidebar">
|
85
|
-
<div style="text-align: center">
|
86
|
-
<%=calendar2%>
|
87
|
-
<%=calendar%>
|
88
|
-
</div>
|
89
|
-
|
90
|
-
<h3>最近の日記</h3>
|
91
|
-
<%= recent_list %>
|
92
|
-
|
93
|
-
<h3>最近のツッコミ</h3>
|
94
|
-
<%= recent_comment3 %>
|
95
|
-
</div>
|
96
|
-
FOOTER
|
97
|
-
|
98
|
-
@date_format = '%Y年%m月%d日'
|
99
|
-
|
100
|
-
@section_anchor = '<span class="sanchor">_</span>'
|
101
|
-
@comment_anchor = '<span class="canchor">_</span>'
|
102
|
-
|
103
|
-
@latest_limit = 10
|
104
|
-
|
105
|
-
@theme = 'default'
|
106
|
-
|
107
|
-
@show_comment = true
|
108
|
-
@comment_limit = 3
|
109
|
-
|
110
|
-
@show_referer = true
|
111
|
-
@referer_day_only = true
|
112
|
-
|
113
|
-
@hour_offset = 0
|
114
|
-
|
115
|
-
@show_nyear = true
|
116
|
-
|
117
|
-
@no_referer = [
|
118
|
-
# Capybara の Referer を変更できないので、リンク元確認のテストのために除外する
|
119
|
-
# '^' + Regexp.quote( base_url ), # 自分の日記
|
120
|
-
'^http://localhost[:/]',
|
121
|
-
'^http://192\.168\.',
|
122
|
-
'^http://172\.1[6789]',
|
123
|
-
'^http://172\.2[0-9]',
|
124
|
-
'^http://172\.3[01]',
|
125
|
-
'^http://10\.',
|
126
|
-
'^http:/+$',
|
127
|
-
'^http://[^/]+$',
|
128
|
-
'search\\?q=cache:',
|
129
|
-
'^http://cache\.yahoofs\.jp/',
|
130
|
-
'^http://[^\.]+\.alexa\.com/',
|
131
|
-
'^http://www\.hotbot\.com/',
|
132
|
-
'^http://gw\.mobile\.goo\.ne\.jp/',
|
133
|
-
'^http://haro\.jp/rss/',
|
134
|
-
'^https?://(www.)?bloglines.com[/:]',
|
135
|
-
'^http://del\.icio\.us/',
|
136
|
-
'^http://d\.hatena\.ne\.jp/.*/\?of=\d+$',
|
137
|
-
'^http://feedbringer\.net/',
|
138
|
-
'^http://reader\.www\.infoseek\.co\.jp/',
|
139
|
-
'^http://feedpath\.jp/feedreader/',
|
140
|
-
'^http://webryreader\.biglobe\.ne\.jp/',
|
141
|
-
'^http://www\.easythumbs\.com',
|
142
|
-
'^http://www\.shinobi\.jp/',
|
143
|
-
'^http://freerss\.net/',
|
144
|
-
'^http://g\.msn\.com/',
|
145
|
-
'^http://myweb-bookmarks\.com/',
|
146
|
-
'^http://reader\.livedoor\.com/',
|
147
|
-
'^http://wrs\.search\.yahoo\.co\.jp/',
|
148
|
-
'^http://www\.google\.com/reader/',
|
149
|
-
'^http://my\.yahoo\.co\.jp/',
|
150
|
-
'^http://data\.click\.rss\.drecom\.jp/',
|
151
|
-
'^http://i-know\.jp/',
|
152
|
-
'^http://r\.hatena\.ne\.jp/',
|
153
|
-
'^http://reader\.freerss\.net/',
|
154
|
-
'^http://reader\.goo\.ne\.jp/',
|
155
|
-
'^https://enter\.nifty\.com/my/',
|
156
|
-
'/feedshow(cat|cat|all|guide)?\.php',
|
157
|
-
]
|
158
|
-
|
159
|
-
@no_referer2 = [
|
160
|
-
'(sex|pussy|porn|xxx|rape|nudity|x-pictures|x-stories|pics--movies|teen|shemale|scat|pissing|pantyhose|mature|incest|hentai|bdsm|taboo|bestiality|violence|tits|cocks|peeing|anal|lesbian|shaved|www89.com|casino|poker|gambl|diet|discount|holdem|texas|viagra|betting|insurance|pharmac|phentermin|mortgage|loan|credit-card|hotel|credit|debt|get-sport|available-sport|sport-2u|-doctor|feelor\.com|adoptingcenter|domainthriftstore|payday|rrso|novacspacetravel|pills|radcraft\.com|partyshopcentral|beach-views|alcdrugprogdesign|slot|roulette|craps-table|wsop|ahdb\.com|aahbears\.com|brynmawr|umbc|\.fed\.us|book.?make|searchmee|kasino|tinyurl|wapurl|bimba|polls|fleetairarmarchive|kwiz|viewpoints|\.edu/|adipex|cheap|blackjack|expedia|zwitech|online[a-z]+\.com/|ezboard|ordercialis|financ|craps|baccar|keno|healthcare|portal_member|car.*\.com/$|insure|tropin|pgpgk|humangrowthhormone|hgh-igf|pharma|pill|organic|doctor\.|\.doctor|weight\.|\.weight|\.generic|generic\.|omaha|rxed|cardstud|erection|assuranc|ringtone)',
|
161
|
-
]
|
162
|
-
|
163
|
-
@only_volatile = [
|
164
|
-
]
|
165
|
-
|
166
|
-
@only_volatile2 = [
|
167
|
-
'^http://(www|images|translate)\.google\.[^/]+/',
|
168
|
-
'^http://([a-z]+\.)?(search|google|websearch|srd)\.yahoo\.[^/]+/',
|
169
|
-
'^http://(\w+\.)?search\.msn\.[^/]+/',
|
170
|
-
'^http://g\.msn\.com/',
|
171
|
-
'^http://([^\.]+\.)?goo\.ne\.jp/',
|
172
|
-
'^http://(www\.)?infoseek\.[^/]+/[OI]?Titles',
|
173
|
-
'^http://search\.fresheye\.com/',
|
174
|
-
'^http://[^\.]+\.excite\.[^/]+/search',
|
175
|
-
'^http://ask\.jp/',
|
176
|
-
'^http://www\.tocc\.co\.jp/search/',
|
177
|
-
'^http://[^\.]*\.lycos\.[a-z\.]+/',
|
178
|
-
'\.search\.biglobe\.ne\.jp/',
|
179
|
-
'^https?://(search|enter)\.nifty\.com/',
|
180
|
-
'^http://search\.jp\.aol\.com/',
|
181
|
-
'^http://www\.looksmart\.com/',
|
182
|
-
'^http://[^.]*\.naver\.co\.jp/',
|
183
|
-
'^http://allabout\.co\.jp/.*?/extsearch',
|
184
|
-
'^http://www\.isao\.net/search/',
|
185
|
-
'^http://(search-intl|search)\.netscape\.com/',
|
186
|
-
'^http://www\.wisenut\.com/',
|
187
|
-
'^http://www\.search\.com/',
|
188
|
-
'^http://(www|labs)\.ceek\.jp/',
|
189
|
-
'^http://seek\.3721\.com/',
|
190
|
-
'^http://search\.jword\.jp/',
|
191
|
-
'^http://www\.alltheweb\.com/',
|
192
|
-
'searchscout\.com/',
|
193
|
-
'^http://(sf|search)\.livedoor\.com/',
|
194
|
-
'^http://www\.myblog\.jp/',
|
195
|
-
'^http://mixi\.jp/',
|
196
|
-
'^http://aolsearch\.jp\.aol\.com/',
|
197
|
-
'^http://cgi\.search\.biglobe\.ne\.jp/cgi-bin/search2-b',
|
198
|
-
'^http://excite\.co\.jp/search',
|
199
|
-
'^http://so-net\.search\.goo\.ne\.jp/',
|
200
|
-
'^http://www.altavista.com',
|
201
|
-
'^http://1470\.net/mm/',
|
202
|
-
'^http://www\.rojo\.com/',
|
203
|
-
'^http://[br]\.hatena\.ne\.jp/',
|
204
|
-
'^http://r\.zeromemory\.info/',
|
205
|
-
'^http://newsing\.jp/',
|
206
|
-
'^http://clip\.nifty\.com/',
|
207
|
-
'^http://www\.flog\.jp/',
|
208
|
-
'^http://www\.technorati\.jp/',
|
209
|
-
'^http://netnavigate\.net/',
|
210
|
-
'^http://www\.netvibes\.com/',
|
211
|
-
]
|
212
|
-
|
213
|
-
@referer_table = [
|
214
|
-
['^(.{50}).*$', '\1...'],
|
215
|
-
]
|
216
|
-
|
217
|
-
@referer_table2 = [
|
218
|
-
['^http://www\.tdiary\.net/.*', 'tDiary.Net'],
|
219
|
-
['^http://sho\.tdiary\.net/(\d{4})(\d\d)(\d\d)\.html', 'ただのにっき(\1-\2-\3)'],
|
220
|
-
['^http://sho\.tdiary\.net/(\d{4})(\d\d)\.html', 'ただのにっき(\1-\2)'],
|
221
|
-
['^http://([^\.]*)\.tdiary\.net/(\d{4})(\d\d)(\d\d)\.html', 'tDiary.Net[\1](\2-\3-\4)'],
|
222
|
-
['^http://([^\.]*)\.tdiary\.net/(\d{4})(\d\d)\.html', 'tDiary.Net[\1](\2-\3)'],
|
223
|
-
['^http://([^\.]*)\.tdiary\.net/.*', 'tDiary.Net[\1]'],
|
224
|
-
]
|
225
|
-
|
226
|
-
@secure = false
|
227
|
-
load_cgi_conf
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'dalli'
|
2
|
-
|
3
|
-
module TDiary
|
4
|
-
module CacheIO
|
5
|
-
def restore_cache(prefix)
|
6
|
-
if key = cache_key(prefix)
|
7
|
-
restore_data(key)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def store_cache(cache, prefix)
|
12
|
-
if key = cache_key(prefix)
|
13
|
-
store_data(cache, key)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def clear_cache(target = :all)
|
18
|
-
if target == :all
|
19
|
-
delete_data(:all)
|
20
|
-
else
|
21
|
-
ym = target.to_s.scan(/\d{4}\d{2}/)[0]
|
22
|
-
['latest.rb', 'i.latest.rb', "#{ym}.rb", "i.#{ym}.rb"].each do |key|
|
23
|
-
delete_data(key)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def restore_data(key)
|
31
|
-
memcache.get(key)
|
32
|
-
end
|
33
|
-
|
34
|
-
def store_data(data, key)
|
35
|
-
memcache.set(key, data)
|
36
|
-
end
|
37
|
-
|
38
|
-
def delete_data(key)
|
39
|
-
if key == :all
|
40
|
-
memcache.flush
|
41
|
-
else
|
42
|
-
memcache.delete(key)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def restore_parser_cache(date, key = nil)
|
47
|
-
restore_data(date.strftime("%Y%m.parser"))
|
48
|
-
end
|
49
|
-
|
50
|
-
def store_parser_cache(date, obj, key = nil)
|
51
|
-
store_data(obj, date.strftime("%Y%m.parser"))
|
52
|
-
end
|
53
|
-
|
54
|
-
def clear_parser_cache(*args)
|
55
|
-
delete_data(:all)
|
56
|
-
end
|
57
|
-
|
58
|
-
def cache_key(prefix)
|
59
|
-
if @tdiary.is_a?(TDiaryMonth)
|
60
|
-
"#{prefix}#{@tdiary.rhtml.sub( /month/, @tdiary.date.strftime( '%Y%m' ) ).sub( /\.rhtml$/, '.rb' )}"
|
61
|
-
elsif @tdiary.is_a?(TDiaryLatest)
|
62
|
-
if @tdiary.cgi.params['date'][0]
|
63
|
-
nil
|
64
|
-
else
|
65
|
-
"#{prefix}#{@tdiary.rhtml.sub( /\.rhtml$/, '.rb' )}"
|
66
|
-
end
|
67
|
-
else
|
68
|
-
nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def memcache
|
73
|
-
options = {}
|
74
|
-
if @tdiary.conf.user_name
|
75
|
-
options.merge!({:namespace => @tdiary.conf.user_name})
|
76
|
-
end
|
77
|
-
@_client ||= Dalli::Client.new(nil, options)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# Local Variables:
|
83
|
-
# mode: ruby
|
84
|
-
# indent-tabs-mode: t
|
85
|
-
# tab-width: 3
|
86
|
-
# ruby-indent-level: 3
|
87
|
-
# End:
|
88
|
-
# vim: ts=3
|
data/tdiary/io/cache/redis.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'redis'
|
2
|
-
require 'redis-namespace'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
module TDiary
|
6
|
-
module CacheIO
|
7
|
-
def restore_cache(prefix)
|
8
|
-
if key = cache_key(prefix)
|
9
|
-
restore_data(key)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def store_cache(cache, prefix)
|
14
|
-
if key = cache_key(prefix)
|
15
|
-
store_data(cache, key)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def clear_cache(target = :all)
|
20
|
-
if target == :all
|
21
|
-
delete_data(:all)
|
22
|
-
else
|
23
|
-
ym = target.to_s.scan(/\d{4}\d{2}/)[0]
|
24
|
-
['latest.rb', 'i.latest.rb', "#{ym}.rb", "i.#{ym}.rb"].each do |key|
|
25
|
-
delete_data(key)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def restore_data(key)
|
33
|
-
obj = redis.get(key)
|
34
|
-
if obj.nil?
|
35
|
-
nil
|
36
|
-
else
|
37
|
-
YAML.load(obj)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def store_data(data, key)
|
42
|
-
redis.set(key, YAML.dump(data))
|
43
|
-
end
|
44
|
-
|
45
|
-
def delete_data(key)
|
46
|
-
if key == :all
|
47
|
-
redis.flushdb
|
48
|
-
else
|
49
|
-
redis.del(key)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def restore_parser_cache(date, key = nil)
|
54
|
-
obj = redis.get(date.strftime("%Y%m.parser"))
|
55
|
-
if obj.nil?
|
56
|
-
nil
|
57
|
-
else
|
58
|
-
YAML.load(obj)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def store_parser_cache(date, obj, key = nil)
|
63
|
-
redis.set(date.strftime("%Y%m.parser"), YAML.dump(obj))
|
64
|
-
end
|
65
|
-
|
66
|
-
def clear_parser_cache(date)
|
67
|
-
redis.flushdb
|
68
|
-
end
|
69
|
-
|
70
|
-
def cache_key(prefix)
|
71
|
-
if @tdiary.is_a?(TDiaryMonth)
|
72
|
-
"#{prefix}#{@tdiary.rhtml.sub( /month/, @tdiary.date.strftime( '%Y%m' ) ).sub( /\.rhtml$/, '.rb' )}"
|
73
|
-
elsif @tdiary.is_a?(TDiaryLatest)
|
74
|
-
if @tdiary.cgi.params['date'][0]
|
75
|
-
nil
|
76
|
-
else
|
77
|
-
"#{prefix}#{@tdiary.rhtml.sub( /\.rhtml$/, '.rb' )}"
|
78
|
-
end
|
79
|
-
else
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def redis
|
85
|
-
@_client ||= if @tdiary.conf.user_name
|
86
|
-
Redis::Namespace.new(@tdiary.conf.user_name.to_sym, Redis.new)
|
87
|
-
else
|
88
|
-
Redis.new
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# Local Variables:
|
95
|
-
# mode: ruby
|
96
|
-
# indent-tabs-mode: t
|
97
|
-
# tab-width: 3
|
98
|
-
# ruby-indent-level: 3
|
99
|
-
# End:
|
100
|
-
# vim: ts=3
|