rwdschedule 0.07 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.txt +16 -434
- data/bin/rwdschedule +0 -0
- data/code/ag1core/aa0begin.rb +18 -0
- data/code/ag1core/rwdtinkerversion.rb +15 -0
- data/code/{superant.com.schedule → gg0schedules}/deleteeventrecord.rb +18 -18
- data/code/{superant.com.schedule/viewevent.rb → gg0schedules/gg0viewevent.rb} +20 -20
- data/code/{superant.com.schedule/saveeventrecord.rb → gg0schedules/gg9saveeventchanges.rb} +18 -25
- data/code/{superant.com.schedule/listeventdates.rb → gg0schedules/gh5listdaterecords.rb} +18 -18
- data/code/gg0schedules/gl7clearscreendisplay.rb +15 -0
- data/code/gg0schedules/gm3deletecontactrecord.rb +24 -0
- data/code/{superant.com.schedule/loadicseventrecord.rb → gg0schedules/loadeventrecord.rb} +29 -29
- data/code/{superant.com.schedule → gg0schedules}/renameeventdata.rb +10 -10
- data/code/gg0schedules/rwdaddresseshelpabout.rb +14 -0
- data/code/gg0schedules/rwdschedulehelpabout.rb +14 -0
- data/code/gh9calendar/gh9calendar.rb +16 -0
- data/code/xa5rwdtinkercallable/callable.rb +13 -0
- data/code/xb1rwdtinkerbackwindow/diagnostictab.rb +21 -0
- data/code/xb1rwdtinkerbackwindow/installapplet.rb +20 -0
- data/code/xb1rwdtinkerbackwindow/listinstalledfiles.rb +11 -0
- data/code/xb1rwdtinkerbackwindow/listzips.rb +14 -0
- data/code/xb1rwdtinkerbackwindow/openappletname.rb +18 -0
- data/code/xb1rwdtinkerbackwindow/removeapplet.rb +28 -0
- data/code/xb1rwdtinkerbackwindow/rwdtinkerwin2version.rb +14 -0
- data/code/zz0applicationend/zz0end.rb +1 -2
- data/configuration/language.cnf +5 -0
- data/configuration/rwdcalendar.cnf +4 -0
- data/configuration/rwdcalendarversion.cnf +4 -0
- data/configuration/rwdschedule.cnf +2 -0
- data/configuration/rwdscheduleversion.cnf +3 -0
- data/configuration/rwdtinker.cnf +12 -0
- data/configuration/rwdtinkerversion.cnf +2 -0
- data/configuration/tinkerwin2.cnf +3 -0
- data/configuration/tinkerwin2version.cnf +3 -0
- data/{lib/rwd → ev}/browser.rb +12 -26
- data/{lib/rwd → ev}/ftools.rb +19 -23
- data/{lib/rwd → ev}/net.rb +45 -172
- data/{lib/rwd → ev}/ruby.rb +27 -97
- data/{lib/rwd → ev}/rwd.rb +668 -245
- data/{lib/rwd → ev}/sgml.rb +2 -2
- data/{lib/rwd → ev}/thread.rb +1 -1
- data/{lib/rwd → ev}/tree.rb +7 -35
- data/ev/xml.rb +4 -0
- data/{lib → extras}/cal.rb +166 -158
- data/gui/aa2core/aa0rwdtop.rwd +4 -0
- data/gui/{tinkerbackwindows/superant.com.rwdschedules → gg0schedules}/gg0viewevent.rwd +27 -27
- data/gui/gg0schedules/gl6editrecord.rwd +36 -0
- data/gui/{tinkerbackwindows/superant.com.rwdschedules → gg0schedules}/gl8contactutilities.rwd +24 -25
- data/gui/hl9calendar/hl9calendar.rwd +20 -0
- data/gui/ll1selectiontabbegin/selectiontabbegin.rwd +16 -0
- data/gui/ll5rwdtinkerwin2selectiontab/rwdwin2selectiontab.rwd +12 -0
- data/gui/{frontwindowselections/wwselectionend.rwd → lz1selectiontabend/endselectiontab.rwd} +0 -0
- data/gui/tt0documentsbegin/tt0documentbegin.rwd +6 -0
- data/gui/uu5rwddocuments/uu5documents.rwd +15 -0
- data/gui/uu6rwdtinkerwin2documents/uu5documents.rwd +6 -0
- data/gui/uu8schedule/uu8doc_rwdschedule.rwd +5 -0
- data/gui/ww0documentsend/ww0documentend.rwd +7 -0
- data/gui/{helpaboutbegin/zzzrwdlasttab.rwd → wz6finaltabs/xx0rwdfirsttab.rwd} +0 -0
- data/gui/{tinkerbackwindows/superant.com.versionwindow → xa1versionwindow}/1appname.rwd +2 -2
- data/gui/xa5rwdtinkercallablewindow/1appname.rwd +17 -0
- data/gui/{tinkerbackwindows/superant.com.tinkerhelpwindow → xa5rwdtinkercallablewindow}/9end.rwd +0 -0
- data/gui/xb1rwdtinkerbackwindow/1appname.rwd +5 -0
- data/gui/xb1rwdtinkerbackwindow/2tab1.rwd +11 -0
- data/gui/xb1rwdtinkerbackwindow/3arwddiagnostics.rwd +33 -0
- data/gui/xb1rwdtinkerbackwindow/4arwdlistapplets.rwd +44 -0
- data/gui/xb1rwdtinkerbackwindow/4arwdlistzips.rwd +35 -0
- data/gui/{tinkerbackwindows/superant.com.tinkerbackwindow → xb1rwdtinkerbackwindow}/9backend.rwd +0 -0
- data/gui/ya1helpaboutbegin/ya0helpscreenstart.rwd +3 -0
- data/gui/yg5rwdhelpabout/1appname.rwd +4 -0
- data/gui/yg5rwdhelpabout/3copyright.rwd +3 -0
- data/gui/yg5rwdhelpabout/5version.rwd +10 -0
- data/gui/yg6rwdwin2helpabout/1appname.rwd +4 -0
- data/gui/yg6rwdwin2helpabout/3copyright.rwd +3 -0
- data/gui/yg6rwdwin2helpabout/5version.rwd +10 -0
- data/gui/yh1helpschedule/1rwdschedule.rwd +6 -0
- data/gui/yh1helpschedule/5version.rwd +9 -0
- data/gui/{helpaboutzend → yy5helpaboutend}/helpscreenend.rwd +0 -0
- data/gui/{zzcoreguiend → za1applicationend}/yy9rwdend.rwd +0 -0
- data/init.rb +198 -144
- data/installed/rwdcalendar-0.5.inf +8 -0
- data/installed/rwdschedule-0.8.inf +7 -0
- data/installed/rwdtinkerwin2-0.5.inf +8 -0
- data/installed/schedulesampledata1.inf +3 -0
- data/lang/alanguagehashbegin.rb +4 -0
- data/lang/en/rwdcalendar/calendar-nl.rb +6 -0
- data/lang/en/rwdcore/languagefile.rb +16 -0
- data/lang/es/rwdcalendar/calendar-nl.rb +6 -0
- data/lang/es/rwdcore/languagefile-es.rb +14 -0
- data/lang/jp/rwdcore/languagefile.rb +9 -0
- data/lang/languagehash.rb +4 -0
- data/lang/nl/rwdcalendar/calendar-nl.rb +6 -0
- data/lang/nl/rwdcore/languagefile.rb +19 -0
- data/lang/templangfile.rb +22 -0
- data/lang/vlanguagehashend.rb +6 -0
- data/lang/wlocallangstart.rb +5 -0
- data/lang/xlocallangfile.rb +22 -0
- data/lang/zlocallangend.rb +2 -0
- data/{installed → lib}/temp.rb +0 -0
- data/rwd_files/HowTo_Schedule.txt +83 -197
- data/rwd_files/HowTo_Tinker.txt +35 -258
- data/rwd_files/rwdapplications.html +1 -23
- data/rwd_files/{RubyWebDialogs.html → rwdindex.html} +0 -0
- data/schedules/200501january23CharlotteB-Day.sch +8 -0
- data/schedules/200501january24jazzfuller.sch +8 -0
- data/tests/rwdtinkertestEN.rb +163 -0
- data/tests/test.result +32 -0
- data/zips/rwdaschedule-0.8.zip +0 -0
- data/zips/rwdhelloworld-0.4.zip +0 -0
- data/zips/rwdrefreshacpi-0.4.zip +0 -0
- data/zips/rwdwcalc-0.4.zip +0 -0
- data/zips/rwdwshell-0.92.zip +0 -0
- metadata +147 -279
- data/code/01rwdcore/01rwdcore.rb +0 -29
- data/code/01rwdcore/02helptexthashbegin.rb +0 -16
- data/code/01rwdcore/03helptexthash.rb +0 -21
- data/code/01rwdcore/jumplinkcommand.rb +0 -36
- data/code/01rwdcore/openhelpwindow.rb +0 -38
- data/code/01rwdcore/returntomain.rb +0 -10
- data/code/01rwdcore/rundocuments.rb +0 -10
- data/code/01rwdcore/runeditconfiguration.rb +0 -10
- data/code/01rwdcore/runhelpabout.rb +0 -15
- data/code/01rwdcore/runopentinkerdocument.rb +0 -7
- data/code/01rwdcore/runtab.rb +0 -15
- data/code/01rwdcore/rwdtinkerversion.rb +0 -22
- data/code/01rwdcore/rwdwindowreturn.rb +0 -9
- data/code/01rwdcore/selectiontab.rb +0 -11
- data/code/01rwdcore/setuphelpaboutoptions.rb +0 -15
- data/code/01rwdcore/setuptinkerdocuments.rb +0 -7
- data/code/01rwdcore/test_cases.rb +0 -158
- data/code/01rwdcore/test_harness.rb +0 -20
- data/code/01rwdcore/uploadreturns.rb +0 -65
- data/code/dd0viewphoto/dd0viewphoto.rb +0 -5
- data/code/superant.com.rwdcalendar/gh9calendar.rb +0 -40
- data/code/superant.com.rwdcalendar/helptexthashrwdschedule.rb +0 -14
- data/code/superant.com.rwdcalendar/openhelpwindowrwdschedule.rb +0 -17
- data/code/superant.com.rwdtinkerbackwindow/changelocale.rb +0 -84
- data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +0 -19
- data/code/superant.com.rwdtinkerbackwindow/initiateapplets.rb +0 -169
- data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +0 -38
- data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +0 -20
- data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +0 -12
- data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +0 -55
- data/code/superant.com.rwdtinkerbackwindow/listinstalledfiles.rb +0 -14
- data/code/superant.com.rwdtinkerbackwindow/listzips.rb +0 -37
- data/code/superant.com.rwdtinkerbackwindow/loadconfigurationrecord.rb +0 -24
- data/code/superant.com.rwdtinkerbackwindow/loadconfigurationvariables.rb +0 -14
- data/code/superant.com.rwdtinkerbackwindow/network.rb +0 -87
- data/code/superant.com.rwdtinkerbackwindow/openappletname.rb +0 -19
- data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +0 -40
- data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +0 -24
- data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +0 -46
- data/code/superant.com.rwdtinkerbackwindow/removeappletvariables.rb +0 -52
- data/code/superant.com.rwdtinkerbackwindow/runremoteinstall.rb +0 -11
- data/code/superant.com.rwdtinkerbackwindow/runrwdtinkerbackwindow.rb +0 -15
- data/code/superant.com.rwdtinkerbackwindow/rwdtinkerwin2version.rb +0 -13
- data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +0 -19
- data/code/superant.com.rwdtinkerbackwindow/showlocaleoptions.rb +0 -9
- data/code/superant.com.rwdtinkerbackwindow/viewappletcontents.rb +0 -23
- data/code/superant.com.rwdtinkerbackwindow/viewgemappletcontents.rb +0 -24
- data/code/superant.com.rwdtinkerbackwindow/viewlogfile.rb +0 -16
- data/code/superant.com.schedule/0uninstallapplet.rb +0 -24
- data/code/superant.com.schedule/archiveevent.rb +0 -14
- data/code/superant.com.schedule/archiveicsevent.rb +0 -14
- data/code/superant.com.schedule/cleareventscreendisplay.rb +0 -19
- data/code/superant.com.schedule/deleteicseventrecord.rb +0 -19
- data/code/superant.com.schedule/deleterwdscheduleupdatefiles.rb +0 -20
- data/code/superant.com.schedule/downloadrwdschedulefiles.rb +0 -37
- data/code/superant.com.schedule/exporticseventrecord.rb +0 -97
- data/code/superant.com.schedule/helptexthashload.rb +0 -22
- data/code/superant.com.schedule/listicseventdates.rb +0 -19
- data/code/superant.com.schedule/loadconfigurationrecord.rb +0 -22
- data/code/superant.com.schedule/loadconfigurationvariables.rb +0 -14
- data/code/superant.com.schedule/loadeventrecord.rb +0 -38
- data/code/superant.com.schedule/openhelpwindowrwdschedule.rb +0 -43
- data/code/superant.com.schedule/renameicseventdata.rb +0 -17
- data/code/superant.com.schedule/returntomain.rb +0 -10
- data/code/superant.com.schedule/runrwdscheduleicsbackwindow.rb +0 -10
- data/code/superant.com.schedule/runrwdschedulemenu1.rb +0 -34
- data/code/superant.com.schedule/runrwdschedulesyncbackwindow.rb +0 -10
- data/code/superant.com.schedule/rwdversion.rb +0 -10
- data/code/superant.com.schedule/saveconfigurationrecord.rb +0 -19
- data/code/superant.com.schedule/saveicseventrecord.rb +0 -98
- data/code/superant.com.schedule/syncrwdschedule.rb +0 -30
- data/code/superant.com.schedule/test_cases.rb +0 -45
- data/code/superant.com.schedule/uploadrwdschedulefiles.rb +0 -30
- data/code/superant.com.schedule/viewicsevent.rb +0 -20
- data/code/superant.com.schedule/viewrwdschedulesconfiguration.rb +0 -21
- data/configuration/rwdtinker.dist +0 -15
- data/configuration/rwdwschedule.dist +0 -28
- data/configuration/tinkerwin2variables.dist +0 -23
- data/gui/00coreguibegin/applicationguitop.rwd +0 -9
- data/gui/frontwindow0/cc0openphoto.rwd +0 -22
- data/gui/frontwindowselections/00selectiontabbegin.rwd +0 -11
- data/gui/frontwindowselections/jumplinkcommands.rwd +0 -15
- data/gui/frontwindowtdocuments/00documentbegin.rwd +0 -6
- data/gui/frontwindowtdocuments/tinkerdocuments.rwd +0 -14
- data/gui/frontwindowtdocuments/zzdocumentend.rwd +0 -8
- data/gui/helpaboutbegin/zzzzhelpscreenstart.rwd +0 -3
- data/gui/helpaboutbegin/zzzzzzhelpabouttab.rwd +0 -15
- data/gui/helpaboutzend/zhelpscreenstart2.rwd +0 -3
- data/gui/helpaboutzend/zzzzhelpabout2.rwd +0 -15
- data/gui/helpaboutzend/zzzzhelpscreen2end.rwd +0 -3
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/1appname.rwd +0 -5
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/20downloadftp.rwd +0 -45
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/67viewconfiguration.rwd +0 -29
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/70rwddiagnostics.rwd +0 -16
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/m01menubegin.rwd +0 -18
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/zvbackend.rwd +0 -6
- data/gui/tinkerbackwindows/superant.com.rwdschedules/1appname.rwd +0 -5
- data/gui/tinkerbackwindows/superant.com.rwdschedules/gl6editrecord.rwd +0 -56
- data/gui/tinkerbackwindows/superant.com.rwdschedules/hl9calendar.rwd +0 -27
- data/gui/tinkerbackwindows/superant.com.rwdschedules/m01menubegin.rwd +0 -18
- data/gui/tinkerbackwindows/superant.com.rwdschedules/zvbackend.rwd +0 -6
- data/gui/tinkerbackwindows/superant.com.rwdschedulesback/1appname.rwd +0 -5
- data/gui/tinkerbackwindows/superant.com.rwdschedulesback/30viewevent.rwd +0 -27
- data/gui/tinkerbackwindows/superant.com.rwdschedulesback/40editrecord.rwd +0 -49
- data/gui/tinkerbackwindows/superant.com.rwdschedulesback/60eventicsutilities.rwd +0 -25
- data/gui/tinkerbackwindows/superant.com.rwdschedulesback/m01menubegin.rwd +0 -18
- data/gui/tinkerbackwindows/superant.com.rwdschedulesback/zvbackend.rwd +0 -6
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/1appname.rwd +0 -5
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40rwdlistzips.rwd +0 -41
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/45installremotezip.rwd +0 -44
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistapplets.rwd +0 -44
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/60editconfiguration.rwd +0 -30
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +0 -29
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/75rwdlogfile.rwd +0 -20
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/80localechanger.rwd +0 -17
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/81jumplinkcommands.rwd +0 -17
- data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/1appname.rwd +0 -31
- data/gui/tinkerbackwindows/superant.com.versionwindow/helpaboutwindow.rwd +0 -17
- data/installed/rwdscheduledate2.inf +0 -6
- data/installed/rwdwschedule.inf +0 -20
- data/lang/en/rwdcalendar/en.po +0 -32
- data/lang/en/rwdcore/en.po +0 -197
- data/lang/es/rwdcalendar/es.po +0 -10
- data/lang/es/rwdcore/es.po +0 -184
- data/lang/fr/rwdcalendar/fr.po +0 -11
- data/lang/fr/rwdcore/fr.po +0 -169
- data/lang/hi/rwdcalendar/hi.po +0 -11
- data/lang/hi/rwdcore/hi.po +0 -173
- data/lang/ja/rwdcalendar/ja.po +0 -11
- data/lang/ja/rwdcore/ja.po +0 -171
- data/lang/nl/rwdcalendar/nl.po +0 -12
- data/lang/nl/rwdcore/nl.po +0 -169
- data/lib/icalendar.rb +0 -18
- data/lib/icalendar/base.rb +0 -17
- data/lib/icalendar/calendar.rb +0 -44
- data/lib/icalendar/calendar_parser.rb +0 -237
- data/lib/icalendar/component.rb +0 -91
- data/lib/icalendar/component/alarm.rb +0 -16
- data/lib/icalendar/component/event.rb +0 -25
- data/lib/icalendar/component/freebusy.rb +0 -12
- data/lib/icalendar/component/journal.rb +0 -25
- data/lib/icalendar/component/timezone.rb +0 -26
- data/lib/icalendar/component/todo.rb +0 -21
- data/lib/icalendar/helpers.rb +0 -103
- data/lib/icalendar/parameter.rb +0 -25
- data/lib/rconftool.rb +0 -387
- data/lib/rwd/mime.rb +0 -328
- data/lib/rwd/xml.rb +0 -101
- data/lib/rwdthemes/default.rwd +0 -317
- data/lib/rwdthemes/pda.rwd +0 -72
- data/lib/rwdthemes/windowslike.rwd +0 -171
- data/lib/rwdtinker/rwdcodedir.rb +0 -56
- data/lib/rwdtinker/rwdguidir.rb +0 -57
- data/lib/rwdtinker/rwdlangdir.rb +0 -60
- data/lib/rwdtinker/rwdtinkertools.rb +0 -25
- data/lib/zip/ioextras.rb +0 -155
- data/lib/zip/stdrubyext.rb +0 -111
- data/lib/zip/tempfile_bugfixed.rb +0 -195
- data/lib/zip/zip.rb +0 -1847
- data/lib/zip/zipfilesystem.rb +0 -609
- data/lib/zip/ziprequire.rb +0 -90
- data/rwd_files/Tinkerhelptexthash.txt +0 -84
- data/rwd_files/log/rwdtinker.log +0 -2
- data/rwd_files/rwdschedulehelpfiles.txt +0 -19
- data/rwd_files/schedules/20050120T09.ics +0 -9
- data/rwd_files/schedules/200505may02a.sch +0 -4
- data/rwd_files/schedules/Enterprise.ics +0 -411
- data/rwd_files/schedules/US Holidays.ics +0 -575
- data/rwd_files/schedules/archive/sample.archive +0 -1
- data/rwd_files/schedules/testics05.ics +0 -11
- data/rwd_files/tinker.png +0 -0
- data/rwdconfig.dist +0 -24
- data/rwdschedule.rb +0 -1
- data/tests/RubyGauge.rb +0 -179
- data/tests/checkdepends.sh +0 -4
- data/tests/cleancnf.sh +0 -6
- data/tests/makedist-rwdwhypernote.rb +0 -56
- data/tests/makedist.rb +0 -66
- data/tests/rdep.rb +0 -354
- data/updates/temp.rb +0 -1
- data/zips/rwdwcalc-0.63.zip +0 -0
- data/zips/rwdwfoldeditor-0.07.zip +0 -0
- data/zips/rwdwhypernote-0.16.zip +0 -0
- data/zips/rwdwmovies-0.98.zip +0 -0
- data/zips/rwdwruby-1.08.zip +0 -0
- data/zips/rwdwschedule-1.07.zip +0 -0
- data/zips/temp.rb +0 -1
- data/zips/tinkerbellw-0.04.zip +0 -0
- data/zips/wrubyslippers-1.08.zip +0 -0
data/lib/icalendar/component.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
# The body of the iCalendar object consists of a sequence of calendar
|
3
|
-
# properties and one or more calendar components. The calendar
|
4
|
-
# properties are attributes that apply to the calendar as a whole. The
|
5
|
-
# calendar components are collections of properties that express a
|
6
|
-
# particular calendar semantic. For example, the calendar component can
|
7
|
-
# specify an event, a to-do, a journal entry, time zone information, or
|
8
|
-
# free/busy time information, or an alarm.
|
9
|
-
class Component < Icalendar::Base
|
10
|
-
|
11
|
-
attr_reader :name
|
12
|
-
attr_accessor :properties, :property_params
|
13
|
-
|
14
|
-
def initialize(name)
|
15
|
-
@name = name
|
16
|
-
@properties = {}
|
17
|
-
@property_params = {}
|
18
|
-
|
19
|
-
@@logger.info("New #{@name[1,@name.size].capitalize}...")
|
20
|
-
end
|
21
|
-
|
22
|
-
def print_string
|
23
|
-
s = ""
|
24
|
-
|
25
|
-
# Begin a new component
|
26
|
-
s << "BEGIN:#{@name.upcase}\r\n"
|
27
|
-
|
28
|
-
# Then print the properties, possible parameters and potentially
|
29
|
-
# multiple parameter values for each parameter.
|
30
|
-
@properties.each do |key,value|
|
31
|
-
# Property name
|
32
|
-
s << "#{key.upcase}"
|
33
|
-
|
34
|
-
# Possible parameters
|
35
|
-
if @property_params.has_key?(key)
|
36
|
-
params = @property_params[key]
|
37
|
-
params.each do |key,val|
|
38
|
-
s << ";#{key}"
|
39
|
-
unless val.respond_to?(:to_ary)
|
40
|
-
val = [ val ]
|
41
|
-
end
|
42
|
-
|
43
|
-
# Possible parameter values
|
44
|
-
unless val.empty?
|
45
|
-
s << "="
|
46
|
-
sep = "" # First entry comes after = sign, but then we need commas
|
47
|
-
val.each do |pval|
|
48
|
-
s << sep << pval
|
49
|
-
sep = ","
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Property value
|
56
|
-
s << ":#{value}\r\n"
|
57
|
-
end
|
58
|
-
|
59
|
-
# Any custom body of the derived component
|
60
|
-
yield(s)
|
61
|
-
|
62
|
-
# End of this component
|
63
|
-
s << "END:#{@name.upcase}\r\n"
|
64
|
-
end
|
65
|
-
|
66
|
-
# Dynamically execute getters and setters for properties and
|
67
|
-
# property parameters. This lets us handle all the general text properties
|
68
|
-
# as well as custom app related properties in a natural way, but we don't
|
69
|
-
# have to write a million getters and setters for every possible thing we
|
70
|
-
# want to support.
|
71
|
-
def method_missing(method_id, *args)
|
72
|
-
method_name = method_id.id2name.upcase
|
73
|
-
|
74
|
-
if method_name =~ /\w+_PARAMS/ # Its a parameter request
|
75
|
-
hash = @property_params
|
76
|
-
val = args
|
77
|
-
else # Or its a property request
|
78
|
-
hash = @properties
|
79
|
-
val = args.first unless args.empty?
|
80
|
-
end
|
81
|
-
|
82
|
-
if method_name =~ /(.*)(=)/ # Its a setter
|
83
|
-
hash[$1] = val
|
84
|
-
@@logger.debug("Setting #{$1} => #{val}")
|
85
|
-
else # Or its a getter
|
86
|
-
@@logger.debug("Getting #{method_name} => #{hash[method_name]}")
|
87
|
-
return hash[method_name]
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
# An Alarm calendar component is a grouping of component
|
3
|
-
# properties that is a reminder or alarm for an event or a
|
4
|
-
# to-do. For example, it may be used to define a reminder for a
|
5
|
-
# pending Event or an overdue Todo.
|
6
|
-
class Alarm < Component
|
7
|
-
def initialize()
|
8
|
-
super("VALARM")
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
print_string {}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
# A Event calendar component is a grouping of component
|
3
|
-
# properties, and possibly including Alarm calendar components, that
|
4
|
-
# represents a scheduled amount of time on a calendar. For example, it
|
5
|
-
# can be an activity; such as a one-hour long, department meeting from
|
6
|
-
# 8:00 AM to 9:00 AM, tomorrow. Generally, an event will take up time
|
7
|
-
# on an individual calendar.
|
8
|
-
class Event < Component
|
9
|
-
include Dtstart
|
10
|
-
|
11
|
-
attr_accessor :alarms
|
12
|
-
|
13
|
-
def initialize()
|
14
|
-
super("VEVENT")
|
15
|
-
|
16
|
-
@alarms = []
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_s
|
20
|
-
print_string do |s|
|
21
|
-
@alarms.each { |alarm| s << alarm.to_s }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
# A Freebusy calendar component is a grouping of
|
3
|
-
# component properties that represents either a request for, a reply to
|
4
|
-
# a request for free or busy time information or a published set of
|
5
|
-
# busy time information.
|
6
|
-
class Freebusy < Component
|
7
|
-
|
8
|
-
def initialize()
|
9
|
-
super("VFREEBUSY")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
# A Journal calendar component is a grouping of
|
3
|
-
# component properties that represent one or more descriptive text
|
4
|
-
# notes associated with a particular calendar date. The "DTSTART"
|
5
|
-
# property is used to specify the calendar date that the journal entry
|
6
|
-
# is associated with. Generally, it will have a DATE value data type,
|
7
|
-
# but it can also be used to specify a DATE-TIME value data type.
|
8
|
-
# Examples of a journal entry include a daily record of a legislative
|
9
|
-
# body or a journal entry of individual telephone contacts for the day
|
10
|
-
# or an ordered list of accomplishments for the day. The Journal
|
11
|
-
# calendar component can also be used to associate a document with a
|
12
|
-
# calendar date.
|
13
|
-
class Journal < Component
|
14
|
-
|
15
|
-
def initialize()
|
16
|
-
super("VJOURNAL")
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_s
|
20
|
-
print_string { }
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
# A Timezone is unambiguously defined by the set of time
|
3
|
-
# measurement rules determined by the governing body for a given
|
4
|
-
# geographic area. These rules describe at a minimum the base offset
|
5
|
-
# from UTC for the time zone, often referred to as the Standard Time
|
6
|
-
# offset. Many locations adjust their Standard Time forward or backward
|
7
|
-
# by one hour, in order to accommodate seasonal changes in number of
|
8
|
-
# daylight hours, often referred to as Daylight Saving Time. Some
|
9
|
-
# locations adjust their time by a fraction of an hour. Standard Time
|
10
|
-
# is also known as Winter Time. Daylight Saving Time is also known as
|
11
|
-
# Advanced Time, Summer Time, or Legal Time in certain countries. The
|
12
|
-
# following table shows the changes in time zone rules in effect for
|
13
|
-
# New York City starting from 1967. Each line represents a description
|
14
|
-
# or rule for a particular observance.
|
15
|
-
class Timezone < Component
|
16
|
-
|
17
|
-
def initialize()
|
18
|
-
super("VTIMEZONE")
|
19
|
-
@components = components
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_s
|
23
|
-
super.to_s { |s| s << @components.each { |component| component.to_s } }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
# A Todo calendar component is a grouping of component
|
3
|
-
# properties and possibly Alarm calendar components that represent
|
4
|
-
# an action-item or assignment. For example, it can be used to
|
5
|
-
# represent an item of work assigned to an individual; such as "turn in
|
6
|
-
# travel expense today".
|
7
|
-
class Todo < Component
|
8
|
-
|
9
|
-
attr_reader :alarms
|
10
|
-
|
11
|
-
def initialize()
|
12
|
-
super("VTODO")
|
13
|
-
|
14
|
-
@alarms = alarms
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_s
|
18
|
-
print_string { |s| @alarms.each { |alarm| alarm.to_s } }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/icalendar/helpers.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
# date = date-fullyear date-month date-mday
|
3
|
-
# date-fullyear = 4 DIGIT
|
4
|
-
# date-month = 2 DIGIT
|
5
|
-
# date-mday = 2 DIGIT
|
6
|
-
DATE = '(\d\d\d\d)(\d\d)(\d\d)'
|
7
|
-
|
8
|
-
# time = time-hour [":"] time-minute [":"] time-second [time-secfrac] [time-zone]
|
9
|
-
# time-hour = 2 DIGIT
|
10
|
-
# time-minute = 2 DIGIT
|
11
|
-
# time-second = 2 DIGIT
|
12
|
-
# time-secfrac = "," 1*DIGIT
|
13
|
-
# time-zone = "Z" / time-numzone
|
14
|
-
# time-numzome = sign time-hour [":"] time-minute
|
15
|
-
TIME = '(\d\d)(\d\d)(\d\d)(Z)?'
|
16
|
-
|
17
|
-
|
18
|
-
# Maps to dtstart property
|
19
|
-
# TODO: Look into having the DateTime library do more of the work...
|
20
|
-
module Dtstart
|
21
|
-
|
22
|
-
# Set the starting DateTime of an Event, Todo,
|
23
|
-
# Freebusy or Timezone component. If utc is set to true
|
24
|
-
# then this time represents absolute time without regard for
|
25
|
-
# timezone information.
|
26
|
-
def setStart(start, utc = false)
|
27
|
-
if start.respond_to?(:year) # Date format
|
28
|
-
s = ""
|
29
|
-
|
30
|
-
# 4 digit year
|
31
|
-
s << start.year.to_s
|
32
|
-
|
33
|
-
# Double digit month
|
34
|
-
s << "0" unless start.month > 9
|
35
|
-
s << start.month.to_s
|
36
|
-
|
37
|
-
# Double digit day
|
38
|
-
s << "0" unless start.day > 9
|
39
|
-
s << start.day.to_s
|
40
|
-
else
|
41
|
-
raise InvalidPropertyValue, "Cannot access year on start argument object!"
|
42
|
-
end
|
43
|
-
|
44
|
-
if start.respond_to?(:hour) # include Time format if possible
|
45
|
-
s << "T"
|
46
|
-
|
47
|
-
# Double digit hour
|
48
|
-
s << "0" unless start.hour > 9
|
49
|
-
s << start.hour.to_s
|
50
|
-
|
51
|
-
# Double digit minute
|
52
|
-
s << "0" unless start.min > 9
|
53
|
-
s << start.min.to_s
|
54
|
-
|
55
|
-
# Double digit second
|
56
|
-
s << "0" unless start.sec > 9
|
57
|
-
s << start.sec.to_s
|
58
|
-
end
|
59
|
-
|
60
|
-
# UTC time gets a Z suffix
|
61
|
-
if utc
|
62
|
-
s << "Z"
|
63
|
-
end
|
64
|
-
|
65
|
-
@properties["DTSTART"] = s
|
66
|
-
end
|
67
|
-
|
68
|
-
# Returns the starting DateTime of an Event, Todo, Freebusy or
|
69
|
-
# Timezone component.
|
70
|
-
def getStart
|
71
|
-
# If we don't have a start time then return nil.
|
72
|
-
unless @properties.has_key?("DTSTART")
|
73
|
-
return nil
|
74
|
-
end
|
75
|
-
s = @properties["DTSTART"]
|
76
|
-
|
77
|
-
# If we can't parse the start time figure its bad and return nil.
|
78
|
-
unless s =~ %r{#{DATE}}i
|
79
|
-
return nil
|
80
|
-
end
|
81
|
-
|
82
|
-
# We can at least create a Date object
|
83
|
-
year = $1
|
84
|
-
month = $2
|
85
|
-
day = $3
|
86
|
-
|
87
|
-
puts "s: #{s}"
|
88
|
-
puts "#{DATE}T#{TIME}"
|
89
|
-
# We might be able to get the time too
|
90
|
-
if s =~ %r{"#{DATE}T#{TIME}"}i
|
91
|
-
hour = $5
|
92
|
-
min = $6
|
93
|
-
sec = $7
|
94
|
-
|
95
|
-
puts "Hour: #{hour.to_s}"
|
96
|
-
|
97
|
-
return DateTime.new(year, month, day, hour, min, sec)
|
98
|
-
else
|
99
|
-
return Date.new(year.to_i, month.to_i, day.to_i)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
data/lib/icalendar/parameter.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Icalendar
|
2
|
-
|
3
|
-
# A property can have attributes associated with it. These "property
|
4
|
-
# parameters" contain meta-information about the property or the
|
5
|
-
# property value. Property parameters are provided to specify such
|
6
|
-
# information as the location of an alternate text representation for a
|
7
|
-
# property value, the language of a text property value, the data type
|
8
|
-
# of the property value and other attributes.
|
9
|
-
class Parameter < Icalendar::Content
|
10
|
-
|
11
|
-
def to_s
|
12
|
-
s = ""
|
13
|
-
|
14
|
-
s << "#{@name}="
|
15
|
-
if is_escapable?
|
16
|
-
s << escape(print_value())
|
17
|
-
else
|
18
|
-
s << print_value
|
19
|
-
end
|
20
|
-
|
21
|
-
s
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
data/lib/rconftool.rb
DELETED
@@ -1,387 +0,0 @@
|
|
1
|
-
#!/usr/local/bin/ruby -w
|
2
|
-
|
3
|
-
# Copyright (c) 2005 Brian Candler
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to
|
7
|
-
# deal in the Software without restriction, including without limitation the
|
8
|
-
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
9
|
-
# sell copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
21
|
-
# IN THE SOFTWARE.
|
22
|
-
|
23
|
-
##########################################################################
|
24
|
-
# rconftool is a reimplementation of Sam Varshavchik's sysconftool in Ruby.
|
25
|
-
# See http://www.courier-mta.org/sysconftool/ for details of the original.
|
26
|
-
# Its purpose is to keep configuration files "fresh" when upgrading an
|
27
|
-
# application from one version to another, ensuring that all necessary
|
28
|
-
# settings are present and obsolete ones removed.
|
29
|
-
#
|
30
|
-
# rconftool can be called as a library function or from the command line. It
|
31
|
-
# can also install groups of files recursively from one directory tree into
|
32
|
-
# another.
|
33
|
-
##########################################################################
|
34
|
-
|
35
|
-
require 'fileutils'
|
36
|
-
|
37
|
-
module Rconftool
|
38
|
-
VERSION = "0.1"
|
39
|
-
class NoVersionLine < RuntimeError; end
|
40
|
-
|
41
|
-
# This module function installs a single source (.dist) file to a target
|
42
|
-
# location, having first merged in any compatible settings from the
|
43
|
-
# target file if it existed previously [if it does not exist, any settings
|
44
|
-
# from 'oldfile' are used instead]
|
45
|
-
#
|
46
|
-
# If the distfile is not in sysconftool format (i.e. doesn't have a
|
47
|
-
# ##VERSION: header within the first 20 lines), then for safety it is only
|
48
|
-
# installed if the target file does not already exist. No attempt at data
|
49
|
-
# merging is made in that case.
|
50
|
-
|
51
|
-
def self.install(distfile, targetfile=nil, oldfile=nil, opt={})
|
52
|
-
debug = opt[:debug] || $stdout
|
53
|
-
|
54
|
-
targetfile ||= distfile
|
55
|
-
if opt[:strip_regexp]
|
56
|
-
targetfile = targetfile.sub(opt[:strip_regexp], '')
|
57
|
-
oldfile = oldfile.sub(opt[:strip_regexp], '') if oldfile
|
58
|
-
end
|
59
|
-
if opt[:add_suffix]
|
60
|
-
targetfile = targetfile + opt[:add_suffix]
|
61
|
-
oldfile = oldfile + opt[:add_suffix] if oldfile
|
62
|
-
end
|
63
|
-
raise Errno::EEXIST, "#{distfile}: dist and target filenames are the same" if distfile == targetfile
|
64
|
-
|
65
|
-
# Read in the source (.dist) file
|
66
|
-
begin
|
67
|
-
src = ConfigFile.new(distfile)
|
68
|
-
rescue NoVersionLine
|
69
|
-
# Fallback behaviour when installing a file which is not in sysconftool
|
70
|
-
# format: we install the file only if it doesn't already exist
|
71
|
-
if File.exist?(targetfile)
|
72
|
-
debug << "#{targetfile}: already exists, skipping\n"
|
73
|
-
return
|
74
|
-
end
|
75
|
-
return if opt[:noclobber]
|
76
|
-
copyfrom = (oldfile and File.exist?(oldfile)) ? oldfile : distfile
|
77
|
-
if File.symlink?(copyfrom)
|
78
|
-
File.symlink(File.readlink(copyfrom), targetfile)
|
79
|
-
debug << "#{targetfile}: symlink copied from #{copyfrom}\n"
|
80
|
-
else
|
81
|
-
FileUtils.cp copyfrom, targetfile, :preserve=>true
|
82
|
-
debug << "#{targetfile}: copied from #{copyfrom}\n"
|
83
|
-
end
|
84
|
-
return
|
85
|
-
end
|
86
|
-
|
87
|
-
# OK, so we have a sysconftool file to install. Read in the existing
|
88
|
-
# target file, or if that does not exist, the oldfile
|
89
|
-
begin
|
90
|
-
old = ConfigFile.new
|
91
|
-
old.read(targetfile)
|
92
|
-
rescue NoVersionLine
|
93
|
-
# That's OK; the old target will be renamed to .bak
|
94
|
-
rescue Errno::ENOENT
|
95
|
-
begin
|
96
|
-
target_missing = true
|
97
|
-
old.read(oldfile) if oldfile
|
98
|
-
rescue Errno::ENOENT, NoVersionLine
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# Same VERSION? No merge is required
|
103
|
-
if src.version == old.version and not opt[:force]
|
104
|
-
if target_missing
|
105
|
-
FileUtils.cp oldfile, targetfile, :preserve=>true
|
106
|
-
debug << "#{targetfile}: same VERSION, copied from #{oldfile}\n"
|
107
|
-
return
|
108
|
-
end
|
109
|
-
debug << "#{targetfile}: same VERSION, no change\n"
|
110
|
-
return
|
111
|
-
end
|
112
|
-
|
113
|
-
# Merge in old settings (note: any settings which are in targetfile but
|
114
|
-
# not in distfile will be silently dropped)
|
115
|
-
debug << "#{targetfile}:\n"
|
116
|
-
src.settings[1..-1].each do |src_setting|
|
117
|
-
name = src_setting.name
|
118
|
-
old_setting = old[name]
|
119
|
-
unless old_setting
|
120
|
-
debug << " #{name}: new\n"
|
121
|
-
next
|
122
|
-
end
|
123
|
-
if old_setting.version == src_setting.version
|
124
|
-
if $DEBUG
|
125
|
-
$stderr.puts "old setting: #{old_setting.version}"
|
126
|
-
$stderr.puts "src setting: #{src_setting.version}"
|
127
|
-
end
|
128
|
-
debug << " #{name}: unchanged\n"
|
129
|
-
src_setting.add_comment("\n DEFAULT SETTING from #{distfile}:\n")
|
130
|
-
src_setting.add_comment(src_setting.content)
|
131
|
-
src_setting.content = old_setting.content
|
132
|
-
next
|
133
|
-
end
|
134
|
-
# Otherwise, must install updated setting and comment out
|
135
|
-
# the current setting for reference
|
136
|
-
debug << " #{name}: UPDATED\n"
|
137
|
-
src_setting.add_comment("\n Previous setting (inserted by rconftool):\n\n")
|
138
|
-
src_setting.add_comment(old_setting.content)
|
139
|
-
end
|
140
|
-
|
141
|
-
return if opt[:noclobber]
|
142
|
-
|
143
|
-
# Write out the new file and carry forward permissions
|
144
|
-
begin
|
145
|
-
tempfile = targetfile+".new#{$$}"
|
146
|
-
src.write(tempfile)
|
147
|
-
st = File.stat(distfile)
|
148
|
-
begin
|
149
|
-
File.chown(st.uid, st.gid, tempfile)
|
150
|
-
rescue Errno::EPERM
|
151
|
-
end
|
152
|
-
File.chmod(st.mode, tempfile)
|
153
|
-
File.rename(targetfile, targetfile+".bak") unless target_missing
|
154
|
-
File.rename(tempfile, targetfile)
|
155
|
-
rescue
|
156
|
-
File.delete(tempfile) rescue nil
|
157
|
-
raise
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
HEADER_ID = '__header__'
|
162
|
-
|
163
|
-
# Object to represent a single setting
|
164
|
-
|
165
|
-
class Setting
|
166
|
-
attr_reader :name, :version
|
167
|
-
attr_accessor :content
|
168
|
-
|
169
|
-
def initialize(name, version)
|
170
|
-
@name = name.gsub(/\s+/,'')
|
171
|
-
@version = version.gsub(/s+/,'')
|
172
|
-
@comment = ""
|
173
|
-
@content = ""
|
174
|
-
@in_content = false
|
175
|
-
end
|
176
|
-
def <<(str)
|
177
|
-
@in_content = true unless /\A#/ =~ str
|
178
|
-
if @in_content
|
179
|
-
@content << str
|
180
|
-
else
|
181
|
-
@comment << str
|
182
|
-
end
|
183
|
-
end
|
184
|
-
# Add text to 'comment' portion of setting, prefixing each line with '#'
|
185
|
-
def add_comment(str)
|
186
|
-
@comment << str.gsub(/^/,'#')
|
187
|
-
end
|
188
|
-
def to_s
|
189
|
-
return "#{@comment}#{@content}" if @name == HEADER_ID
|
190
|
-
return "##NAME: #{@name}:#{@version}\n#{@comment}#{@content}"
|
191
|
-
end
|
192
|
-
end # class Setting
|
193
|
-
|
194
|
-
# Object to represent an entire configuration file. It consists of
|
195
|
-
# an array of Setting objects, with the first one having a special name
|
196
|
-
# (__header__). We also keep a hash of setting name => setting object
|
197
|
-
# to enable us to find a particular setting quickly.
|
198
|
-
|
199
|
-
class ConfigFile
|
200
|
-
attr_reader :version, :settings
|
201
|
-
|
202
|
-
def initialize(filename=nil)
|
203
|
-
read(filename) if filename
|
204
|
-
end
|
205
|
-
|
206
|
-
# fetch a setting by name
|
207
|
-
def [](item)
|
208
|
-
@settings_hash[item]
|
209
|
-
end
|
210
|
-
|
211
|
-
def read(filename)
|
212
|
-
@version = nil
|
213
|
-
curr_setting = Setting.new(HEADER_ID,'')
|
214
|
-
@settings = [curr_setting]
|
215
|
-
@settings_hash = {}
|
216
|
-
|
217
|
-
File.open(filename) do |f|
|
218
|
-
# VERSION header must occur within first 20 lines
|
219
|
-
20.times do
|
220
|
-
line = f.gets
|
221
|
-
break unless line
|
222
|
-
linetmp = line.chop + "\r\n"
|
223
|
-
curr_setting << linetmp
|
224
|
-
if line =~ /\A##VERSION:/
|
225
|
-
@version = line.chop
|
226
|
-
break
|
227
|
-
end
|
228
|
-
end
|
229
|
-
raise NoVersionLine, "#{filename}: No VERSION line found" unless @version
|
230
|
-
|
231
|
-
while line = f.gets
|
232
|
-
unless line =~ /\A##NAME:(.*):(.*)/
|
233
|
-
linetmp = line.chop + "\r\n"
|
234
|
-
curr_setting << linetmp
|
235
|
-
next
|
236
|
-
end
|
237
|
-
curr_setting = Setting.new($1,$2)
|
238
|
-
@settings << curr_setting
|
239
|
-
@settings_hash[curr_setting.name] = curr_setting
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
def write(filename)
|
245
|
-
File.open(filename,"w") do |f|
|
246
|
-
@settings.each do |s|
|
247
|
-
stmp = s.to_s.chop + "\r\n"
|
248
|
-
f << stmp
|
249
|
-
end
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end # class ConfigFile
|
253
|
-
|
254
|
-
# Yield directory contents recursively, without doing chdir(). Note
|
255
|
-
# that yielded pathnames are relative to the base directory given;
|
256
|
-
# so that, for example, you can simulate 'cp -r /foo/bar/ /baz/' by
|
257
|
-
# recurse_dir("/foo/bar") { |n| copy("/foo/bar/"+n,"/baz/"+n) unless
|
258
|
-
# File.directory?("/foo/bar/"+n) }
|
259
|
-
# Current behaviour is that if a directory is a symlink, we follow it.
|
260
|
-
# (Perhaps the block we yield should return true/false?)
|
261
|
-
|
262
|
-
def self.recurse_dir(base)
|
263
|
-
base = base+File::SEPARATOR unless base[-1,1] == File::SEPARATOR
|
264
|
-
dirs = ['']
|
265
|
-
while dir = dirs.pop
|
266
|
-
yield dir unless dir == ''
|
267
|
-
Dir.foreach(base+dir) do |n|
|
268
|
-
next if n == '.' || n == '..'
|
269
|
-
target = dir + n
|
270
|
-
if File.directory?(base+target)
|
271
|
-
dirs << target+File::SEPARATOR
|
272
|
-
next
|
273
|
-
end
|
274
|
-
yield target
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
class Processor
|
280
|
-
attr_reader :o
|
281
|
-
|
282
|
-
# Parse command-line options and set the @o options hash
|
283
|
-
|
284
|
-
def initialize(argv=nil)
|
285
|
-
require 'optparse'
|
286
|
-
|
287
|
-
@o = { :strip_regexp => /\.dist\z/ }
|
288
|
-
return unless argv
|
289
|
-
opts = OptionParser.new do |opts|
|
290
|
-
opts.banner = "rconftool version #{VERSION}"
|
291
|
-
opts.separator "Usage: #{$0} [options]"
|
292
|
-
opts.separator ""
|
293
|
-
opts.separator "Specific options:"
|
294
|
-
|
295
|
-
opts.on("-n", "--noclobber", "Dummy run") do
|
296
|
-
@o[:noclobber] = true
|
297
|
-
end
|
298
|
-
opts.on("-f", "--force", "Update files even if VERSION is same") do
|
299
|
-
@o[:force] = true
|
300
|
-
end
|
301
|
-
opts.on("-q", "--quiet", "No progress reporting") do
|
302
|
-
@o[:debug] = ""
|
303
|
-
end
|
304
|
-
opts.on("--targetdir DIR", "Where to write merged config files") do |dir|
|
305
|
-
@o[:targetdir] = dir
|
306
|
-
end
|
307
|
-
opts.on("--olddir DIR", "If file does not exist in targetdir,",
|
308
|
-
"try to merge from here") do |dir|
|
309
|
-
@o[:olddir] = dir
|
310
|
-
end
|
311
|
-
opts.on("--[no-]recursive", "Traverse directories recursively") do |v|
|
312
|
-
@o[:recursive] = v
|
313
|
-
end
|
314
|
-
opts.on("--strip-suffix FOO", "Remove suffix FOO from target filenames",
|
315
|
-
"(default .dist)") do |suffix|
|
316
|
-
@o[:strip_regexp] = /#{Regexp.escape(suffix)}\z/
|
317
|
-
end
|
318
|
-
opts.on("-a", "--add-suffix FOO", "Add suffix FOO to target filenames") do |suffix|
|
319
|
-
@o[:add_suffix] = suffix
|
320
|
-
end
|
321
|
-
|
322
|
-
opts.on_tail("-?", "--help", "Show this message") do
|
323
|
-
puts opts
|
324
|
-
exit
|
325
|
-
end
|
326
|
-
end
|
327
|
-
opts.parse!(argv)
|
328
|
-
end
|
329
|
-
|
330
|
-
# Process a list of files, [src1,src2,...]. If recursive mode has been
|
331
|
-
# enabled, then subdirectories of destdir are created as necessary
|
332
|
-
# when 'src' is a directory, and the mode/ownership of these newly
|
333
|
-
# created directories is copied from the original.
|
334
|
-
|
335
|
-
def run(files)
|
336
|
-
done_work = false
|
337
|
-
files.each do |f|
|
338
|
-
if not File.directory?(f)
|
339
|
-
dst = old = nil
|
340
|
-
dst = @o[:targetdir] + File::SEPARATOR + File.basename(f) if @o[:targetdir]
|
341
|
-
old = @o[:olddir] + File::SEPARATOR + File.basename(f) if @o[:olddir]
|
342
|
-
Rconftool::install(f, dst, old, @o)
|
343
|
-
elsif not @o[:recursive]
|
344
|
-
raise Errno::EISDIR, "#{f} (not copied). Need --recursive?"
|
345
|
-
else
|
346
|
-
Rconftool::recurse_dir(f) do |nf|
|
347
|
-
src = f + File::SEPARATOR + nf
|
348
|
-
dst = old = nil
|
349
|
-
dst = @o[:targetdir] + File::SEPARATOR + nf if @o[:targetdir]
|
350
|
-
old = @o[:olddir] + File::SEPARATOR + nf if @o[:olddir]
|
351
|
-
if File.directory?(src)
|
352
|
-
if dst and not File.directory?(dst)
|
353
|
-
orig = File.stat(src)
|
354
|
-
Dir.mkdir(dst, orig.mode)
|
355
|
-
begin
|
356
|
-
File.chown(orig.uid, orig.gid, dst)
|
357
|
-
rescue Errno::EPERM
|
358
|
-
end
|
359
|
-
end
|
360
|
-
else
|
361
|
-
Rconftool::install(src, dst, old, @o)
|
362
|
-
end
|
363
|
-
end
|
364
|
-
end
|
365
|
-
done_work = true
|
366
|
-
end
|
367
|
-
unless done_work
|
368
|
-
$stderr.puts "Usage: #{$0} [options] src1 src2 ...\n"+
|
369
|
-
"Try #{$0} --help for more information\n"
|
370
|
-
exit 1
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end # class Processor
|
374
|
-
|
375
|
-
end # module Rconftool
|
376
|
-
|
377
|
-
# Run from command line?
|
378
|
-
if __FILE__ == $0
|
379
|
-
|
380
|
-
begin
|
381
|
-
s = Rconftool::Processor.new(ARGV)
|
382
|
-
s.run(ARGV)
|
383
|
-
rescue Exception => e
|
384
|
-
$stderr.puts "#{$0}: #{e}"
|
385
|
-
end
|
386
|
-
|
387
|
-
end
|