[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[mhc:00419] patch for mhc-schedule.rb
花田です。
mhc-schedule.rbをX-SC-LocaltionとX-SC-Record-Idに対応させるためのパッチです。
あと、1カ所だけbugを潰しています(↓)。
@@ -248,7 +269,7 @@
end
def time_as_string
- return @time_b .to_s + (@time_b ? '-' : '') + @time_e .to_s
+ return @time_b .to_s + (@time_e ? '-' : '') + @time_e .to_s
end
def time_b; return @time_b; end
他にも、デバッグ用らしきprint文は、
全部 if $DEBUG をつけて黙らせておきました。
--
yasunori // 久し振りにMultipartを使ったので、失敗してたら御免なさい。
diff -ur mhc-snap20000204.DIST/ruby-ext/lib/mhc-schedule.rb mhc-snap20000204/ruby-ext/lib/mhc-schedule.rb
--- mhc-snap20000204.DIST/ruby-ext/lib/mhc-schedule.rb Fri Feb 4 14:28:09 2000
+++ mhc-snap20000204/ruby-ext/lib/mhc-schedule.rb Fri Feb 25 20:00:57 2000
@@ -21,6 +21,10 @@
## get X-SC-Subject: value or ''
## set_subject(aString)
## set X-SC-Subject:
+## location
+## get X-SC-Location: value or ''
+## set_location(aString)
+## set X-SC-Location:
## day
## returns active dates exist in X-SC-Day: (means drop !yyyymmdd)
## The return value is a array of MhcDate or []
@@ -68,6 +72,12 @@
## set_alarm(aInteger)
## set alarm value in second.
## nil means 'no alarm.'
+##
+## rec_id
+## return X-SC-Record-Id: value in string
+##
+## set_rec_id
+## set record-id for schedule entry
##
################################################################
## category
@@ -161,7 +171,7 @@
WEK_REGEX = MhcDate::W_LABEL .join('|')
ORD_REGEX = MhcDate::O_LABEL .join('|')
- HDR_REGEX = '(Subject|Day|Time|Category|Cond|Duration|Alarm)'
+ HDR_REGEX = '(Subject|Location|Day|Time|Category|Cond|Duration|Alarm|Record-Id)'
ALM_UNITS = {'Minute' => 60, 'Hour' => 60 * 60, 'Day' => 60 * 60 * 24}
ALM_LABEL = ALM_UNITS .keys
@@ -195,6 +205,17 @@
return self
end
+ ## location
+ def location
+ return @location
+ end
+
+ def set_location(str)
+ @location = str .to_s
+ set_modified(true, 'set_location')
+ return self
+ end
+
## day
def day
return @day
@@ -248,7 +269,7 @@
end
def time_as_string
- return @time_b .to_s + (@time_b ? '-' : '') + @time_e .to_s
+ return @time_b .to_s + (@time_e ? '-' : '') + @time_e .to_s
end
def time_b; return @time_b; end
@@ -398,6 +419,16 @@
return self
end
+ ## record-id
+ def rec_id
+ return @rec_id .to_s
+ end
+
+ def set_rec_id(r)
+ @rec_id = r
+ return self
+ end
+
## description
def description(all = false)
if @description
@@ -483,12 +514,14 @@
def dump_header
return "X-SC-Subject: #{subject}\n" +
+ "X-SC-Location: #{location}\n" +
"X-SC-Day: #{day_as_string}\n" +
"X-SC-Time: #{time_as_string}\n" +
"X-SC-Category: #{category_as_string}\n" +
"X-SC-Cond: #{cond_as_string}\n" +
"X-SC-Duration: #{duration_as_string}\n" +
- "X-SC-Alarm: #{alarm_as_string}\n"
+ "X-SC-Alarm: #{alarm_as_string}\n" +
+ "X-SC-Record-Id: #{rec_id}\n"
## "X-SC-Debug-Path: #{path}\n"
end
@@ -723,10 +756,10 @@
@cond_mon, @cond_ord, @cond_wek, @cond_num = [], [], [], []
@day, @exception, @category, @pilot_id = [], [], [], []
- @subject, @description, @path = '', nil, nil
+ @subject, @location, @description, @path = '', nil, nil, nil
@time_b, @time_e = nil, nil
@duration_b, @duration_e = nil, nil
- @alarm = nil
+ @alarm, @rec_id = nil
@modified = false
return self
@@ -768,6 +801,9 @@
when 'subject:'
@subject = val
+ when 'location:'
+ @location = val
+
when 'time:'
@time_b, @time_e = val .split('-')
@time_b = MhcTime .new(@time_b) if @time_b
@@ -799,6 +835,10 @@
if val =~ /^(\d+)\s*(#{ALM_REGEX})$/i
@alarm = ($1 .to_i) * ALM_UNITS[$2 .capitalize]
end
+
+ when 'record-id:'
+ @rec_id = val
+
end ## case ##
}
return self
@@ -878,7 +918,7 @@
if (old_path = sch .path)
trash_path = get_new_path(@basedir + '/trash')
File .rename(old_path, trash_path)
- print "mv #{old_path} -> #{trash_path}\n"
+ print "mv #{old_path} -> #{trash_path}\n" if $DEBUG
end
sch .set_path(nil)
return self
@@ -900,7 +940,7 @@
contents = sch .dump
(File .open(new_path, "w") << contents) .close
- print "#{old_path} -> #{new_path}\n"
+ print "#{old_path} -> #{new_path}\n" if $DEBUG
File .utime2(now, now, new_slot)
sch .set_path(new_path)
@@ -909,7 +949,7 @@
if old_path && File .exists?(old_path) && old_path != new_path
File .rename(old_path, trash_path)
File .utime2(now, now, old_slot)
- print "#{old_path} -> #{trash_path}\n"
+ print "#{old_path} -> #{trash_path}\n" if $DEBUG
end
rescue
raise("#{$!}\nWrite/Move #{old_path} -> #{new_path} failed.")