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.
data/tdiary/io/default.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8; -*-
2
2
  #
3
- # defaultio.rb: tDiary IO class for tDiary 2.x format. $Revision: 1.44 $
3
+ # defaultio.rb: tDiary IO class for tDiary 2.x - 4.x format.
4
4
  #
5
5
  # Copyright (C) 2001-2005, TADA Tadashi <t@tdtds.jp>
6
6
  # You can redistribute it and/or modify it under GPL2.
@@ -13,278 +13,280 @@ module TDiary
13
13
  TDIARY_MAGIC_MINOR = '01.00'
14
14
  TDIARY_MAGIC = "#{TDIARY_MAGIC_MAJOR}.#{TDIARY_MAGIC_MINOR}"
15
15
 
16
- module CommentIO
17
- def comment_file( data_path, date )
18
- date.strftime( "#{data_path}%Y/%Y%m.tdc" )
19
- end
16
+ module IO
17
+ module Comment
18
+ def comment_file( data_path, date )
19
+ date.strftime( "#{data_path}%Y/%Y%m.tdc" )
20
+ end
20
21
 
21
- def restore_comment( file, diaries )
22
- minor = ''
23
- begin
24
- File::open( file ) do |fh|
25
- fh.flock( File::LOCK_SH )
22
+ def restore_comment( file, diaries )
23
+ minor = ''
24
+ begin
25
+ File::open( file ) do |fh|
26
+ fh.flock( File::LOCK_SH )
26
27
 
27
- major, minor = fh.gets.chomp.split( /\./, 2 )
28
- unless TDIARY_MAGIC_MAJOR == major then
29
- raise StandardError, 'bad file format.'
30
- end
28
+ major, minor = fh.gets.chomp.split( /\./, 2 )
29
+ unless TDIARY_MAGIC_MAJOR == major then
30
+ raise StandardError, 'bad file format.'
31
+ end
31
32
 
32
- s = fh.read
33
- s = migrate_to_01( s ) if minor == '00.00' and !@tdiary.conf['stop_migrate_01']
34
- s.split( /\r?\n\.\r?\n/ ).each do |l|
35
- headers, body = DefaultIO.parse_tdiary( l )
36
- next unless body
37
- comment = Comment::new(
33
+ s = fh.read
34
+ s = migrate_to_01( s ) if minor == '00.00' and !@tdiary.conf['stop_migrate_01']
35
+ s.split( /\r?\n\.\r?\n/ ).each do |l|
36
+ headers, body = Default.parse_tdiary( l )
37
+ next unless body
38
+ comment = Comment::new(
38
39
  headers['Name'],
39
40
  headers['Mail'],
40
41
  body,
41
42
  Time::at( headers['Last-Modified'].to_i ) )
42
- comment.show = false if headers['Visible'] == 'false'
43
- diaries[headers['Date']].add_comment( comment ) if headers['Date']
43
+ comment.show = false if headers['Visible'] == 'false'
44
+ diaries[headers['Date']].add_comment( comment ) if headers['Date']
45
+ end
44
46
  end
47
+ rescue Errno::ENOENT
45
48
  end
46
- rescue Errno::ENOENT
49
+ return minor == '00.00' ? TDiaryBase::DIRTY_COMMENT : TDiaryBase::DIRTY_NONE
47
50
  end
48
- return minor == '00.00' ? TDiaryBase::DIRTY_COMMENT : TDiaryBase::DIRTY_NONE
49
- end
50
51
 
51
- def store_comment( file, diaries )
52
- File::open( file, File::WRONLY | File::CREAT ) do |fhc|
53
- fhc.flock( File::LOCK_EX )
54
- fhc.rewind
55
- fhc.truncate( 0 )
56
- fhc.puts( TDIARY_MAGIC )
57
- diaries.each do |date,diary|
58
- diary.each_comment( diary.count_comments( true ) ) do |com|
59
- fhc.puts( "Date: #{date}" )
60
- fhc.puts( "Name: #{com.name}" )
61
- fhc.puts( "Mail: #{com.mail}" )
62
- fhc.puts( "Last-Modified: #{com.date.to_i}" )
63
- fhc.puts( "Visible: #{com.visible? ? 'true' : 'false'}" )
64
- fhc.puts
65
- fhc.puts( com.body.gsub( /\r/, '' ).sub( /\n+\Z/, '' ).gsub( /\n\./, "\n.." ) )
66
- fhc.puts( '.' )
52
+ def store_comment( file, diaries )
53
+ File::open( file, File::WRONLY | File::CREAT ) do |fhc|
54
+ fhc.flock( File::LOCK_EX )
55
+ fhc.rewind
56
+ fhc.truncate( 0 )
57
+ fhc.puts( TDIARY_MAGIC )
58
+ diaries.each do |date,diary|
59
+ diary.each_comment( diary.count_comments( true ) ) do |com|
60
+ fhc.puts( "Date: #{date}" )
61
+ fhc.puts( "Name: #{com.name}" )
62
+ fhc.puts( "Mail: #{com.mail}" )
63
+ fhc.puts( "Last-Modified: #{com.date.to_i}" )
64
+ fhc.puts( "Visible: #{com.visible? ? 'true' : 'false'}" )
65
+ fhc.puts
66
+ fhc.puts( com.body.gsub( /\r/, '' ).sub( /\n+\Z/, '' ).gsub( /\n\./, "\n.." ) )
67
+ fhc.puts( '.' )
68
+ end
67
69
  end
68
70
  end
69
71
  end
70
72
  end
71
- end
72
73
 
73
- module RefererIO
74
- def referer_file( data_path, date )
75
- date.strftime( "#{data_path}%Y/%Y%m.tdr" )
76
- end
74
+ module Referer
75
+ def referer_file( data_path, date )
76
+ date.strftime( "#{data_path}%Y/%Y%m.tdr" )
77
+ end
77
78
 
78
- def restore_referer( file, diaries )
79
- begin
80
- File::open( file ) do |fh|
81
- fh.flock( File::LOCK_SH )
82
- fh.read.split( /\r?\n\.\r?\n/ ).each do |l|
83
- headers, body = DefaultIO.parse_tdiary( l )
84
- next unless body
85
- body.each do |r|
86
- count, ref = r.chomp.split( / /, 2 )
87
- next unless ref
88
- diaries[headers['Date']].add_referer( ref.chomp, count.to_i )
79
+ def restore_referer( file, diaries )
80
+ begin
81
+ File::open( file ) do |fh|
82
+ fh.flock( File::LOCK_SH )
83
+ fh.read.split( /\r?\n\.\r?\n/ ).each do |l|
84
+ headers, body = Default.parse_tdiary( l )
85
+ next unless body
86
+ body.each do |r|
87
+ count, ref = r.chomp.split( / /, 2 )
88
+ next unless ref
89
+ diaries[headers['Date']].add_referer( ref.chomp, count.to_i )
90
+ end
89
91
  end
90
- end
91
92
 
92
- # convert to referer plugin format
93
- diaries.each do |date,diary|
94
- fname = file.sub( /\.tdr$/, "#{date[6,2]}.tdr".untaint )
95
- File::open( fname, File::WRONLY | File::CREAT ) do |fhr|
96
- fhr.flock( File::LOCK_EX )
97
- fhr.rewind
98
- fhr.truncate( 0 )
99
- fhr.puts( TDiary::TDIARY_MAGIC )
100
- fhr.puts( "Date: #{date}" )
101
- fhr.puts
102
- diary.each_referer( diary.count_referers ) do |count,ref|
103
- fhr.puts( "#{count} #{ref}" )
93
+ # convert to referer plugin format
94
+ diaries.each do |date,diary|
95
+ fname = file.sub( /\.tdr$/, "#{date[6,2]}.tdr".untaint )
96
+ File::open( fname, File::WRONLY | File::CREAT ) do |fhr|
97
+ fhr.flock( File::LOCK_EX )
98
+ fhr.rewind
99
+ fhr.truncate( 0 )
100
+ fhr.puts( TDiary::TDIARY_MAGIC )
101
+ fhr.puts( "Date: #{date}" )
102
+ fhr.puts
103
+ diary.each_referer( diary.count_referers ) do |count,ref|
104
+ fhr.puts( "#{count} #{ref}" )
105
+ end
106
+ fhr.puts( '.' )
104
107
  end
105
- fhr.puts( '.' )
106
108
  end
107
109
  end
110
+ File::rename( file, file.sub( /\.tdr$/, '.tdr~' ) )
111
+ rescue Errno::ENOENT
108
112
  end
109
- File::rename( file, file.sub( /\.tdr$/, '.tdr~' ) )
110
- rescue Errno::ENOENT
113
+ return TDiaryBase::DIRTY_NONE
111
114
  end
112
- return TDiaryBase::DIRTY_NONE
113
- end
114
115
 
115
- def store_referer( file, diaries )
116
- return
116
+ def store_referer( file, diaries )
117
+ return
118
+ end
117
119
  end
118
- end
119
120
 
120
- class DefaultIO < BaseIO
121
- include CommentIO
122
- include RefererIO
123
- include CacheIO
121
+ class Default < Base
122
+ include Comment
123
+ include Referer
124
+ include Cache
124
125
 
125
- class << self
126
- def parse_tdiary( data )
127
- header, body = data.split( /\r?\n\r?\n/, 2 )
128
- headers = {}
129
- if header then
130
- header.lines.each do |l|
131
- l.chomp!
132
- key, val = l.scan( /([^:]*):\s*(.*)/ )[0]
133
- headers[key] = val ? val.chomp : nil
126
+ class << self
127
+ def parse_tdiary( data )
128
+ header, body = data.split( /\r?\n\r?\n/, 2 )
129
+ headers = {}
130
+ if header then
131
+ header.lines.each do |l|
132
+ l.chomp!
133
+ key, val = l.scan( /([^:]*):\s*(.*)/ )[0]
134
+ headers[key] = val ? val.chomp : nil
135
+ end
134
136
  end
137
+ if body then
138
+ body.gsub!( /^\./, '' )
139
+ else
140
+ body = ''
141
+ end
142
+ [headers, body]
135
143
  end
136
- if body then
137
- body.gsub!( /^\./, '' )
138
- else
139
- body = ''
140
- end
141
- [headers, body]
142
- end
143
144
 
144
- def load_cgi_conf(conf)
145
- conf.class.class_eval { attr_accessor :data_path }
146
- raise TDiaryError, 'No @data_path variable.' unless conf.data_path
145
+ def load_cgi_conf(conf)
146
+ conf.class.class_eval { attr_accessor :data_path }
147
+ raise TDiaryError, 'No @data_path variable.' unless conf.data_path
147
148
 
148
- conf.data_path += '/' if /\/$/ !~ conf.data_path
149
- raise TDiaryError, 'Do not set @data_path as same as tDiary system directory.' if conf.data_path == "#{TDiary::PATH}/"
149
+ conf.data_path += '/' if /\/$/ !~ conf.data_path
150
+ raise TDiaryError, 'Do not set @data_path as same as tDiary system directory.' if conf.data_path == "#{TDiary::PATH}/"
150
151
 
151
- File::open( "#{conf.data_path.untaint}tdiary.conf" ){|f| f.read }
152
- rescue IOError, Errno::ENOENT
153
- end
152
+ File::open( "#{conf.data_path.untaint}tdiary.conf" ){|f| f.read }
153
+ rescue IOError, Errno::ENOENT
154
+ end
154
155
 
155
- def save_cgi_conf(conf, result)
156
- File::open( "#{conf.data_path.untaint}tdiary.conf", 'w' ) {|o| o.print result }
157
- rescue IOError, Errno::ENOENT
156
+ def save_cgi_conf(conf, result)
157
+ File::open( "#{conf.data_path.untaint}tdiary.conf", 'w' ) {|o| o.print result }
158
+ rescue IOError, Errno::ENOENT
159
+ end
158
160
  end
159
- end
160
161
 
161
- #
162
- # block must be return boolean which dirty diaries.
163
- #
164
- def transaction( date )
165
- diaries = {}
166
- dir = date.strftime( "#{@data_path}%Y" )
167
- @dfile = date.strftime( "#{@data_path}%Y/%Y%m.td2" )
168
- cfile = comment_file( @data_path, date )
169
- rfile = referer_file( @data_path, date )
170
- begin
171
- FileUtils.mkdir_p(dir)
162
+ #
163
+ # block must be return boolean which dirty diaries.
164
+ #
165
+ def transaction( date )
166
+ diaries = {}
167
+ dir = date.strftime( "#{@data_path}%Y" )
168
+ @dfile = date.strftime( "#{@data_path}%Y/%Y%m.td2" )
169
+ cfile = comment_file( @data_path, date )
170
+ rfile = referer_file( @data_path, date )
172
171
  begin
173
- fh = File::open( @dfile, 'r+' )
174
- rescue
175
- fh = File::open( @dfile, 'w+' )
176
- end
177
- fh.flock( File::LOCK_EX )
172
+ FileUtils.mkdir_p(dir)
173
+ begin
174
+ fh = File::open( @dfile, 'r+' )
175
+ rescue
176
+ fh = File::open( @dfile, 'w+' )
177
+ end
178
+ fh.flock( File::LOCK_EX )
178
179
 
179
- cache = restore_parser_cache( date, 'default' )
180
- force_save = TDiaryBase::DIRTY_NONE
181
- unless cache then
182
- force_save |= restore( fh, diaries )
183
- force_save |= restore_comment( cfile, diaries )
184
- force_save |= restore_referer( rfile, diaries )
185
- else
186
- diaries.update( cache )
187
- end
188
- dirty = yield( diaries ) if iterator?
189
- store( fh, diaries ) if ((dirty | force_save) & TDiaryBase::DIRTY_DIARY) != 0
190
- store_comment( cfile, diaries ) if ((dirty | force_save) & TDiaryBase::DIRTY_COMMENT) != 0
191
- store_referer( rfile, diaries ) if ((dirty | force_save) & TDiaryBase::DIRTY_REFERER) != 0
192
- if dirty != TDiaryBase::DIRTY_NONE or not cache then
193
- store_parser_cache(date, diaries, 'default')
194
- end
180
+ cache = restore_parser_cache( date, 'default' )
181
+ force_save = TDiaryBase::DIRTY_NONE
182
+ unless cache then
183
+ force_save |= restore( fh, diaries )
184
+ force_save |= restore_comment( cfile, diaries )
185
+ force_save |= restore_referer( rfile, diaries )
186
+ else
187
+ diaries.update( cache )
188
+ end
189
+ dirty = yield( diaries ) if iterator?
190
+ store( fh, diaries ) if ((dirty | force_save) & TDiaryBase::DIRTY_DIARY) != 0
191
+ store_comment( cfile, diaries ) if ((dirty | force_save) & TDiaryBase::DIRTY_COMMENT) != 0
192
+ store_referer( rfile, diaries ) if ((dirty | force_save) & TDiaryBase::DIRTY_REFERER) != 0
193
+ if dirty != TDiaryBase::DIRTY_NONE or not cache then
194
+ store_parser_cache(date, diaries, 'default')
195
+ end
195
196
 
196
- if diaries.empty?
197
- begin
198
- if fh then
199
- fh.close
200
- fh = nil
197
+ if diaries.empty?
198
+ begin
199
+ if fh then
200
+ fh.close
201
+ fh = nil
202
+ end
203
+ File::delete( @dfile )
204
+ rescue Errno::ENOENT
205
+ end
206
+ begin
207
+ store_parser_cache(date, nil, nil)
208
+ rescue Errno::ENOENT
201
209
  end
202
- File::delete( @dfile )
203
- rescue Errno::ENOENT
204
210
  end
211
+ # delete dispensable data directory
205
212
  begin
206
- store_parser_cache(date, nil, nil)
213
+ Dir.delete( dir ) if Dir.new( dir ).entries.reject {|f| "." == f or ".." == f}.empty?
207
214
  rescue Errno::ENOENT
208
215
  end
216
+ ensure
217
+ fh.close if fh
209
218
  end
210
- # delete dispensable data directory
211
- begin
212
- Dir.delete( dir ) if Dir.new( dir ).entries.reject {|f| "." == f or ".." == f}.empty?
213
- rescue Errno::ENOENT
214
- end
215
- ensure
216
- fh.close if fh
217
219
  end
218
- end
219
220
 
220
- def calendar
221
- calendar = {}
222
- Dir["#{@data_path}????"].sort.each do |dir|
223
- next unless %r[/\d{4}$] =~ dir
224
- Dir["#{dir.untaint}/??????.td2"].sort.each do |file|
225
- year, month = file.scan( %r[/(\d{4})(\d\d)\.td2$] )[0]
226
- next unless year
227
- calendar[year] = [] unless calendar[year]
228
- calendar[year] << month
221
+ def calendar
222
+ calendar = {}
223
+ Dir["#{@data_path}????"].sort.each do |dir|
224
+ next unless %r[/\d{4}$] =~ dir
225
+ Dir["#{dir.untaint}/??????.td2"].sort.each do |file|
226
+ year, month = file.scan( %r[/(\d{4})(\d\d)\.td2$] )[0]
227
+ next unless year
228
+ calendar[year] = [] unless calendar[year]
229
+ calendar[year] << month
230
+ end
229
231
  end
232
+ calendar
230
233
  end
231
- calendar
232
- end
233
234
 
234
- def cache_dir
235
- @tdiary.conf.cache_path || "#{@data_path}/cache"
236
- end
235
+ def cache_dir
236
+ @tdiary.conf.cache_path || "#{@data_path}/cache"
237
+ end
237
238
 
238
- private
239
+ private
239
240
 
240
- def restore( fh, diaries )
241
- begin
242
- fh.seek( 0 )
241
+ def restore( fh, diaries )
243
242
  begin
244
- major, minor = fh.gets.chomp.split( /\./, 2 )
245
- unless TDIARY_MAGIC_MAJOR == major then
246
- raise StandardError, 'bad file format.'
247
- end
243
+ fh.seek( 0 )
244
+ begin
245
+ major, minor = fh.gets.chomp.split( /\./, 2 )
246
+ unless TDIARY_MAGIC_MAJOR == major then
247
+ raise StandardError, 'bad file format.'
248
+ end
248
249
 
249
- # read and parse diary
250
- style_name = ''
251
- s = fh.read
252
- s = migrate_to_01( s ) if minor == '00.00' and !@tdiary.conf['stop_migrate_01']
253
- s.split( /\r?\n\.\r?\n/ ).each do |l|
254
- headers, body = DefaultIO.parse_tdiary( l )
255
- style_name = headers['Format'] || 'tDiary'
256
- diary = style( style_name )::new( headers['Date'], headers['Title'], body, Time::at( headers['Last-Modified'].to_i ) )
257
- diary.show( headers['Visible'] == 'true' ? true : false )
258
- diaries[headers['Date']] = diary
250
+ # read and parse diary
251
+ style_name = ''
252
+ s = fh.read
253
+ s = migrate_to_01( s ) if minor == '00.00' and !@tdiary.conf['stop_migrate_01']
254
+ s.split( /\r?\n\.\r?\n/ ).each do |l|
255
+ headers, body = Default.parse_tdiary( l )
256
+ style_name = headers['Format'] || 'tDiary'
257
+ diary = style( style_name )::new( headers['Date'], headers['Title'], body, Time::at( headers['Last-Modified'].to_i ) )
258
+ diary.show( headers['Visible'] == 'true' ? true : false )
259
+ diaries[headers['Date']] = diary
260
+ end
261
+ rescue NameError
262
+ # no magic number when it is new file.
259
263
  end
260
- rescue NameError
261
- # no magic number when it is new file.
262
264
  end
265
+ return minor == '00.00' ? TDiaryBase::DIRTY_DIARY : TDiaryBase::DIRTY_NONE
263
266
  end
264
- return minor == '00.00' ? TDiaryBase::DIRTY_DIARY : TDiaryBase::DIRTY_NONE
265
- end
266
267
 
267
- def store( fh, diaries )
268
- begin
269
- fh.seek( 0 )
270
- fh.puts( TDIARY_MAGIC )
271
- diaries.sort_by {|date, diary| date}.each do |date,diary|
272
- # save diaries
273
- fh.puts( "Date: #{date}" )
274
- fh.puts( "Title: #{diary.title}" )
275
- fh.puts( "Last-Modified: #{diary.last_modified.to_i}" )
276
- fh.puts( "Visible: #{diary.visible? ? 'true' : 'false'}" )
277
- fh.puts( "Format: #{diary.style}" )
278
- fh.puts
279
- fh.puts( diary.to_src.gsub( /\r/, '' ).gsub( /\n\./, "\n.." ) )
280
- fh.puts( '.' )
268
+ def store( fh, diaries )
269
+ begin
270
+ fh.seek( 0 )
271
+ fh.puts( TDIARY_MAGIC )
272
+ diaries.sort_by {|date, diary| date}.each do |date,diary|
273
+ # save diaries
274
+ fh.puts( "Date: #{date}" )
275
+ fh.puts( "Title: #{diary.title}" )
276
+ fh.puts( "Last-Modified: #{diary.last_modified.to_i}" )
277
+ fh.puts( "Visible: #{diary.visible? ? 'true' : 'false'}" )
278
+ fh.puts( "Format: #{diary.style}" )
279
+ fh.puts
280
+ fh.puts( diary.to_src.gsub( /\r/, '' ).gsub( /\n\./, "\n.." ) )
281
+ fh.puts( '.' )
282
+ end
283
+ fh.truncate( fh.tell )
281
284
  end
282
- fh.truncate( fh.tell )
283
285
  end
284
- end
285
286
 
286
- def migrate_to_01( day )
287
- @tdiary.conf.migrate_to_utf8( day )
287
+ def migrate_to_01( day )
288
+ @tdiary.conf.migrate_to_utf8( day )
289
+ end
288
290
  end
289
291
  end
290
292
  end
data/tdiary/io/pstore.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8; -*-
2
2
  #
3
- # pstoreio.rb: tDiary IO class of tdiary 1.x format. $Revision: 1.25 $
3
+ # pstoreio.rb: tDiary IO class of tdiary 1.x format.
4
4
  #
5
5
  # Copyright (C) 2001-2005, TADA Tadashi <t@tdtds.jp>
6
6
  # You can redistribute it and/or modify it under GPL2.
@@ -8,53 +8,55 @@
8
8
  require 'pstore'
9
9
 
10
10
  module TDiary
11
- class PStoreIO
12
- def initialize( tdiary )
13
- @data_path = tdiary.conf.data_path
14
- end
11
+ module IO
12
+ class PStore
13
+ def initialize( tdiary )
14
+ @data_path = tdiary.conf.data_path
15
+ end
15
16
 
16
- #
17
- # block must be return boolean which dirty diaries.
18
- #
19
- def transaction( date )
20
- diaries = {}
21
- filename = date.strftime( "#{@data_path}%Y%m" )
22
- begin
23
- PStore::new( filename ).transaction do |db|
24
- dirty = false
25
- if db.root?( 'diary' ) then
26
- diaries.update( db['diary'] )
27
- end
28
- dirty = yield( diaries ) if iterator?
29
- if dirty != TDiary::TDiaryBase::DIRTY_NONE then
30
- db['diary'] = diaries
31
- else
32
- db.abort
17
+ #
18
+ # block must be return boolean which dirty diaries.
19
+ #
20
+ def transaction( date )
21
+ diaries = {}
22
+ filename = date.strftime( "#{@data_path}%Y%m" )
23
+ begin
24
+ PStore::new( filename ).transaction do |db|
25
+ dirty = false
26
+ if db.root?( 'diary' ) then
27
+ diaries.update( db['diary'] )
28
+ end
29
+ dirty = yield( diaries ) if iterator?
30
+ if dirty != TDiary::TDiaryBase::DIRTY_NONE then
31
+ db['diary'] = diaries
32
+ else
33
+ db.abort
34
+ end
33
35
  end
36
+ rescue PStore::Error, NameError, Errno::EACCES
37
+ raise PermissionError::new( "make your @data_path to writable via httpd. #$!" )
34
38
  end
35
- rescue PStore::Error, NameError, Errno::EACCES
36
- raise PermissionError::new( "make your @data_path to writable via httpd. #$!" )
37
- end
38
- begin
39
- File::delete( filename ) if diaries.empty?
40
- rescue Errno::ENOENT
39
+ begin
40
+ File::delete( filename ) if diaries.empty?
41
+ rescue Errno::ENOENT
42
+ end
43
+ return diaries
41
44
  end
42
- return diaries
43
- end
44
45
 
45
- def calendar
46
- calendar = {}
47
- Dir["#{@data_path}??????"].sort.each do |file|
48
- year, month = file.scan( %r[/(\d{4})(\d\d)$] )[0]
49
- next unless year
50
- calendar[year] = [] unless calendar[year]
51
- calendar[year] << month
46
+ def calendar
47
+ calendar = {}
48
+ Dir["#{@data_path}??????"].sort.each do |file|
49
+ year, month = file.scan( %r[/(\d{4})(\d\d)$] )[0]
50
+ next unless year
51
+ calendar[year] = [] unless calendar[year]
52
+ calendar[year] << month
53
+ end
54
+ calendar
52
55
  end
53
- calendar
54
- end
55
56
 
56
- def diary_factory( date, title, body, style = nil )
57
- Diary::new( date, title, body )
57
+ def diary_factory( date, title, body, style = nil )
58
+ Diary::new( date, title, body )
59
+ end
58
60
  end
59
61
  end
60
62
  end
@@ -34,7 +34,7 @@ def make_tarball( repo, version = nil )
34
34
  sh "chmod +x index.rb index.fcgi update.rb update.fcgi"
35
35
  sh 'rake doc'
36
36
  Bundler.with_clean_env do
37
- sh "bundle --path .bundle --without coffee:memcached:redis:gfm:server:development:test"
37
+ sh "bundle --path .bundle --without coffee:server:development:test"
38
38
  end
39
39
  Dir.chdir '.bundle/ruby' do
40
40
  v = `ls`.chomp
@@ -26,12 +26,6 @@ if defined? RSpec
26
26
  ENV['TEST_MODE'] = 'secure'
27
27
  Rake::Task["spec:acceptance"].invoke
28
28
  end
29
-
30
- desc 'Run the code examples in spec/acceptance with RdbIO mode'
31
- task :rdb do
32
- ENV['TEST_MODE'] = 'rdb'
33
- Rake::Task["spec:acceptance"].invoke
34
- end
35
29
  end
36
30
 
37
31
  desc 'Displayed code coverage with SimpleCov'
data/tdiary/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TDiary
2
- VERSION = '4.0.1.20130929'
2
+ VERSION = '4.0.1.20131102'
3
3
  end
@@ -31,7 +31,7 @@ module TDiary
31
31
  class TDiaryLatest
32
32
  end
33
33
 
34
- class DefaultIO
34
+ class IO::Default
35
35
  end
36
36
  end
37
37