rwdaddresses 1.04 → 1.05
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.txt +380 -179
- data/code/01rwdcore/01rwdcore.rb +7 -0
- data/code/01rwdcore/02helptexthashbegin.rb +0 -0
- data/code/01rwdcore/03helptexthash.rb +13 -21
- data/code/01rwdcore/04helptextend.rb +0 -0
- data/code/01rwdcore/jumplinkcommand.rb +1 -1
- data/code/01rwdcore/openhelpwindow.rb +1 -1
- data/code/01rwdcore/returntomain.rb +0 -0
- data/code/01rwdcore/rundocuments.rb +0 -0
- data/code/01rwdcore/runeditconfiguration.rb +0 -0
- data/code/01rwdcore/runhelpabout.rb +0 -0
- data/code/01rwdcore/runopentinkerdocument.rb +7 -0
- data/code/01rwdcore/rwdtinkerversion.rb +11 -3
- data/code/01rwdcore/rwdwindowreturn.rb +0 -0
- data/code/01rwdcore/selectiontab.rb +0 -0
- data/code/01rwdcore/setuphelpaboutoptions.rb +13 -0
- data/code/01rwdcore/setuptinkerdocuments.rb +6 -0
- data/code/01rwdcore/test_cases.rb +0 -0
- data/code/01rwdcore/test_harness.rb +0 -0
- data/code/01rwdcore/uploadreturns.rb +0 -0
- data/code/dd0viewphoto/dd0viewphoto.rb +3 -0
- data/code/superant.com.bigtinker/rwdtinkerversion.rb +10 -0
- data/code/superant.com.rwdaddresses/0uninstallapplet.rb +14 -0
- data/code/superant.com.rwdaddresses/attachtmpcontactphoto.rb +0 -0
- data/code/superant.com.rwdaddresses/clearscreendisplay.rb +0 -0
- data/code/superant.com.rwdaddresses/createnewnamerecord.rb +0 -0
- data/code/superant.com.rwdaddresses/deletecontactrecord.rb +0 -0
- data/code/superant.com.rwdaddresses/deleterwdaddressesupdatefiles.rb +0 -0
- data/code/superant.com.rwdaddresses/downloadrwdaddressfiles.rb +0 -0
- data/code/superant.com.rwdaddresses/helptexthashrwdaddresses.rb +0 -0
- data/code/superant.com.rwdaddresses/listnamerecord.rb +0 -0
- data/code/superant.com.rwdaddresses/listvcardrecord.rb +0 -0
- data/code/superant.com.rwdaddresses/loadconfigurationrecord.rb +22 -45
- data/code/superant.com.rwdaddresses/loadconfigurationvariables.rb +2 -1
- data/code/superant.com.rwdaddresses/loadnamerecord.rb +0 -0
- data/code/superant.com.rwdaddresses/openhelpwindowrwdaddresses.rb +0 -0
- data/code/superant.com.rwdaddresses/renamecontact.rb +0 -0
- data/code/superant.com.rwdaddresses/runaddresseswindow.rb +1 -1
- data/code/superant.com.rwdaddresses/runrwdaddressesmenu1.rb +4 -4
- data/code/superant.com.rwdaddresses/runrwdaddresssyncbackwindow.rb +0 -0
- data/code/superant.com.rwdaddresses/rwdaddressesbackwindow.rb +2 -2
- data/code/superant.com.rwdaddresses/rwdaddresseshelpabout.rb +2 -5
- data/code/superant.com.rwdaddresses/saveconfigurationrecord.rb +1 -1
- data/code/superant.com.rwdaddresses/savevcardrecord.rb +0 -0
- data/code/superant.com.rwdaddresses/syncrwdaddress.rb +0 -0
- data/code/superant.com.rwdaddresses/test_cases.rb +1 -2
- data/code/superant.com.rwdaddresses/uploadrwdaddressfiles.rb +0 -0
- data/code/superant.com.rwdaddresses/viewaddressconfiguration.rb +0 -0
- data/code/superant.com.rwdaddresses/viewnamedata.rb +0 -0
- data/code/superant.com.rwdaddresses/viewphoto.rb +0 -0
- data/code/superant.com.rwdaddresses/viewrwdaddressesconfiguration.rb +0 -0
- data/code/superant.com.rwdaddresses/viewtmpcontactphoto.rb +0 -0
- data/code/superant.com.rwdaddresses/viewvcarddata.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/helptexthashtinkerwin2.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/initiateapplets.rb +240 -0
- data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +18 -5
- data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +1 -1
- data/code/superant.com.rwdtinkerbackwindow/listinstalledfiles.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/listzips.rb +1 -1
- data/code/superant.com.rwdtinkerbackwindow/loadconfigurationrecord.rb +1 -12
- data/code/superant.com.rwdtinkerbackwindow/loadconfigurationvariables.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/network.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/openappletname.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +1 -5
- data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +19 -6
- data/code/superant.com.rwdtinkerbackwindow/removeappletvariables.rb +52 -0
- data/code/superant.com.rwdtinkerbackwindow/runremoteinstall.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/runrwdtinkerbackwindow.rb +4 -0
- data/code/superant.com.rwdtinkerbackwindow/rwdtinkerwin2version.rb +0 -0
- data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +2 -2
- data/code/superant.com.rwdtinkerbackwindow/viewappletcontents.rb +1 -1
- data/code/superant.com.rwdtinkerbackwindow/viewgemappletcontents.rb +1 -1
- data/code/zz0applicationend/zz0end.rb +0 -0
- data/configuration/language.dist +2 -1
- data/configuration/rwdapplicationidentity.dist +2 -2
- data/configuration/rwdtinker.dist +6 -3
- data/configuration/{rwdaddresses.dist → rwdwaddresses-1.05.dist} +6 -2
- data/configuration/tinkerwin2variables.dist +1 -1
- data/gui/00coreguibegin/applicationguitop.rwd +1 -1
- data/gui/frontwindow0/cc0openphoto.rwd +22 -0
- data/gui/{frontwindowselectionbegin/selectiontabbegin/selectiontabbegin.rwd → frontwindowselections/00selectiontabbegin.rwd} +1 -1
- data/gui/frontwindowselections/jumplinkcommands.rwd +15 -0
- data/gui/{frontwindowselectionzend/viewselectionzend/viewselectionend.rwd → frontwindowselections/wwselectionend.rwd} +0 -0
- data/gui/{frontwindowtdocumentbegin/superant.com.documentsbegin/tt0documentbegin.rwd → frontwindowtdocuments/00documentbegin.rwd} +0 -0
- data/gui/frontwindowtdocuments/tinkerdocuments.rwd +14 -0
- data/gui/frontwindowtdocuments/zzdocumentend.rwd +8 -0
- data/gui/{frontwindowz1end/frontwindowend/xx0rwdfirsttab.rwd → helpaboutbegin/zzzrwdlasttab.rwd} +0 -0
- data/gui/helpaboutbegin/zzzzhelpscreenstart.rwd +3 -0
- data/gui/helpaboutbegin/zzzzzzhelpabouttab.rwd +15 -0
- data/gui/helpaboutzend/{superant.com.helpaboutend/helpscreenend.rwd → helpscreenend.rwd} +0 -0
- data/gui/helpaboutzend/zhelpscreenstart2.rwd +3 -0
- data/gui/helpaboutzend/zzzzhelpabout2.rwd +15 -0
- data/gui/helpaboutzend/zzzzhelpscreen2end.rwd +3 -0
- data/gui/tinkerbackwindows/superant.com.addressesphotowindow/yy7addressesphoto.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddresses/10appletbegin.rwd +4 -0
- data/gui/{frontwindow0 → tinkerbackwindows}/superant.com.rwdaddresses/11viewnamedata.rwd +0 -0
- data/gui/{frontwindow0 → tinkerbackwindows}/superant.com.rwdaddresses/13listnamerecordfiles.rwd +0 -0
- data/gui/{frontwindow0 → tinkerbackwindows}/superant.com.rwdaddresses/16editrecord.rwd +0 -0
- data/gui/{frontwindow0 → tinkerbackwindows}/superant.com.rwdaddresses/17viewvcardrecord.rwd +0 -0
- data/gui/{frontwindow0 → tinkerbackwindows}/superant.com.rwdaddresses/18contactutilities.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddresses/81jumplinkcommands.rwd +17 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddresses/9end.rwd +6 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/1appname.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/20downloadftp.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/70rwddiagnostics.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/87viewconfiguration.rwd +34 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/94selectiontab.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/95jumplink.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/97selectionend.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/zvbackend.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/1appname.rwd +5 -0
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/20downloadftp.rwd +45 -0
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/67viewconfiguration.rwd +29 -0
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/70rwddiagnostics.rwd +16 -0
- data/gui/{frontwindowselections/superant.com.rwdtinkerwin2selectiontab/jumplinkcommands.rwd → tinkerbackwindows/superant.com.rwdschedulebackwindow/m01menubegin.rwd} +5 -2
- data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/zvbackend.rwd +6 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/1appname.rwd +1 -1
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40rwdlistzips.rwd +9 -10
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/45installremotezip.rwd +5 -5
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistapplets.rwd +9 -9
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/60editconfiguration.rwd +4 -12
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +1 -1
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/81jumplinkcommands.rwd +4 -4
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/9backend.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/1appname.rwd +1 -1
- data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/9end.rwd +0 -0
- data/gui/tinkerbackwindows/superant.com.versionwindow/1appname.rwd +2 -2
- data/gui/tinkerbackwindows/superant.com.versionwindow/helpaboutwindow.rwd +17 -0
- data/gui/zzcoreguiend/{tinkerapplicationguiend/yy9rwdend.rwd → yy9rwdend.rwd} +0 -0
- data/init.rb +7 -7
- data/installed/rwdaddressesdata2.inf +7 -0
- data/installed/rwdwaddresses-1.05.inf +12 -0
- data/{lib → installed}/temp.rb +0 -0
- data/lang/en/rwdcore/languagefile.rb +57 -15
- data/lang/es/rwdcore/languagefile-es.rb +61 -13
- data/lang/fr/rwdcore/languagefile.rb +64 -0
- data/lang/jp/rwdcore/languagefile.rb +69 -6
- data/lang/nl/rwdcore/languagefile.rb +56 -0
- data/{extras → lib}/rconftool.rb +0 -0
- data/{ev → lib/rwd}/browser.rb +2 -2
- data/{ev → lib/rwd}/ftools.rb +0 -0
- data/{ev → lib/rwd}/mime.rb +0 -0
- data/{ev → lib/rwd}/net.rb +5 -5
- data/{ev → lib/rwd}/ruby.rb +0 -0
- data/{ev → lib/rwd}/rwd.rb +37 -17
- data/{ev → lib/rwd}/sgml.rb +1 -1
- data/{ev → lib/rwd}/thread.rb +1 -1
- data/{ev → lib/rwd}/tree.rb +2 -2
- data/{ev → lib/rwd}/xml.rb +1 -1
- data/{extras → lib}/zip/ioextras.rb +0 -0
- data/{extras → lib}/zip/stdrubyext.rb +0 -0
- data/{extras → lib}/zip/tempfile_bugfixed.rb +0 -0
- data/{extras → lib}/zip/zip.rb +5 -4
- data/{extras → lib}/zip/zipfilesystem.rb +0 -0
- data/{extras → lib}/zip/ziprequire.rb +0 -0
- data/names/Angelina Jolie.jpg b/data/names/Angelina → Jolie.jpg +0 -0
- data/names/Angelina Jolie.nam b/data/names/Angelina → Jolie.nam +0 -0
- data/names/Angelina Jolie.vcf b/data/names/Angelina → Jolie.vcf +0 -0
- data/names/Steven Gibson.jpg b/data/names/Steven → Gibson.jpg +0 -0
- data/names/Steven Gibson.nam b/data/names/Steven → Gibson.nam +0 -0
- data/names/elektra.jpg +0 -0
- data/names/elektra.nam +0 -0
- data/names/nophoto.jpg +0 -0
- data/rwd_files/HowTo_Addresses.txt +8 -0
- data/rwd_files/HowTo_BigTinker.txt +146 -0
- data/rwd_files/HowTo_Tinker.txt +52 -0
- data/rwd_files/HowTo_TinkerWin2.txt +0 -0
- data/rwd_files/Readme.txt +0 -0
- data/rwd_files/{rwdindex.html → RubyWebDialogs.html} +0 -0
- data/rwd_files/contacttmp.jpg +0 -0
- data/rwd_files/favicon.ico +0 -0
- data/rwd_files/rdoc-style.css +0 -0
- data/rwd_files/rwdapplications.html +0 -0
- data/rwd_files/tinker.png +0 -0
- data/rwdaddresses.rb +1 -0
- data/rwdconfig.dist +11 -2
- data/tests/checkdepends.sh +0 -0
- data/tests/cleancnf.sh +2 -1
- data/tests/makedist-rwdwaddesses.rb +56 -0
- data/tests/makedist.rb +12 -5
- data/tests/rdep.rb +0 -0
- data/tests/totranslate.lang +0 -0
- data/updates/temp.rb +1 -0
- data/zips/rwdwaddresses-1.05.zip +0 -0
- data/zips/rwdwcalc-0.61.zip +0 -0
- data/zips/rwdwgutenberg-0.09.zip +0 -0
- data/zips/rwdwschedule-1.04.zip +0 -0
- data/zips/rwdwshell-1.04.zip +0 -0
- data/zips/temp.rb +1 -0
- data/zips/wrubyslippers-1.06.zip +0 -0
- metadata +78 -77
- data/code/superant.com.rwdaddresses/jumplinkupdate.rb +0 -11
- data/code/superant.com.rwdaddresses/returntomain.rb +0 -10
- data/code/superant.com.rwdtinkerbackwindow/controlclient.rb +0 -96
- data/code/superant.com.rwdtinkerbackwindow/installapplet.rb +0 -25
- data/extras/vpim/date.rb +0 -198
- data/extras/vpim/dirinfo.rb +0 -229
- data/extras/vpim/enumerator.rb +0 -29
- data/extras/vpim/field.rb +0 -497
- data/extras/vpim/maker/vcard.rb +0 -312
- data/extras/vpim/rfc2425.rb +0 -244
- data/extras/vpim/rrule.rb +0 -482
- data/extras/vpim/time.rb +0 -42
- data/extras/vpim/vcard.rb +0 -151
- data/extras/vpim/vpim.rb +0 -94
- data/gui/frontwindowtdocuments/superant.com.addressesdocuments/uu8doc_rwdschedule.rwd +0 -5
- data/gui/frontwindowtdocuments/superant.com.documents/uu5documents.rwd +0 -15
- data/gui/frontwindowtdocuments/superant.com.tinkerwin2documents/uu5documents.rwd +0 -6
- data/gui/frontwindowtdocumentzend/superant.com.documentsend/ww0documentend.rwd +0 -12
- data/gui/helpaboutbegin/superant.com.helpaboutbegin/ya0helpscreenstart.rwd +0 -3
- data/gui/helpaboutinstalled/superant.com.rwdaddresseshelpabout/1appname.rwd +0 -4
- data/gui/helpaboutinstalled/superant.com.rwdaddresseshelpabout/3copyright.rwd +0 -3
- data/gui/helpaboutinstalled/superant.com.rwdaddresseshelpabout/5version.rwd +0 -9
- data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/1appname.rwd +0 -4
- data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/3copyright.rwd +0 -3
- data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/5version.rwd +0 -10
- data/gui/tinkerbackwindows/superant.com.rwdaddressessyncbackwindow/88viewconfiguration.rwd +0 -47
- data/installed/rwdviewlogo-0.4.inf +0 -4
- data/zips/rwdahelloworld-0.5.zip +0 -0
@@ -1,96 +0,0 @@
|
|
1
|
-
# Bind message passing socket to rwdtinker application
|
2
|
-
def runcontrolcommand
|
3
|
-
require 'socket'
|
4
|
-
|
5
|
-
# Change this line...
|
6
|
-
ip = '127.0.0.1'
|
7
|
-
# And this one...
|
8
|
-
port = $rwdcontrolport1
|
9
|
-
if @a_remoteportinput
|
10
|
-
port = @a_remoteportinput.to_i
|
11
|
-
end
|
12
|
-
|
13
|
-
commandtext = @a_remotecommandinput.to_s
|
14
|
-
remotehostnotfound = true
|
15
|
-
if (commandtext == "stop")
|
16
|
-
begin
|
17
|
-
client = UDPSocket::new()
|
18
|
-
client.send(commandtext, 0, ip, port)
|
19
|
-
@socket = UDPSocket::new()
|
20
|
-
@socket.bind(ip, port)
|
21
|
-
# Rescue the "Address in use" error
|
22
|
-
rescue Errno::EADDRINUSE
|
23
|
-
|
24
|
-
databack, info = client.recv(128)
|
25
|
-
@remotecommandresult = databack
|
26
|
-
@lastremotecommand = "rwdtinker remote:: Port #{port} on host #{ip} ."
|
27
|
-
remotehostnotfound = false
|
28
|
-
|
29
|
-
# Rescue the "Address not available" error
|
30
|
-
rescue Errno::EADDRNOTAVAIL
|
31
|
-
puts "Network plugin: Address #{host} is not available to bind."
|
32
|
-
|
33
|
-
# Rescue "permission denied errors
|
34
|
-
rescue Errno::EACCES
|
35
|
-
puts "Network plugin: Access denied when binding interface addresses. Did you try to bind a port under 1024 as a regular user?"
|
36
|
-
|
37
|
-
# Rescue all other errors
|
38
|
-
rescue
|
39
|
-
puts "Network plugin: An error occured."
|
40
|
-
|
41
|
-
# Rescue all other errors
|
42
|
-
end
|
43
|
-
if remotehostnotfound
|
44
|
-
@remotecommandresult = "Remote Host not running"
|
45
|
-
end
|
46
|
-
@socket.close
|
47
|
-
# Close the socket after use
|
48
|
-
client.close()
|
49
|
-
end
|
50
|
-
|
51
|
-
remotehostnotfound = true
|
52
|
-
if (commandtext == "query")
|
53
|
-
begin
|
54
|
-
client = UDPSocket::new()
|
55
|
-
client.send(commandtext, 0, ip, port)
|
56
|
-
@socket = UDPSocket::new()
|
57
|
-
@socket.bind(ip, port)
|
58
|
-
# Rescue the "Address in use" error
|
59
|
-
rescue Errno::EADDRINUSE
|
60
|
-
|
61
|
-
databack, info = client.recv(128)
|
62
|
-
@remotecommandresult = databack
|
63
|
-
@lastremotecommand = "rwdtinker remote: Port #{port} on host #{ip} "
|
64
|
-
remotehostnotfound = false
|
65
|
-
|
66
|
-
# Rescue the "Address not available' error
|
67
|
-
rescue Errno::EADDRNOTAVAIL
|
68
|
-
puts "Network plugin: Address #{host} is not available to bind."
|
69
|
-
|
70
|
-
# Rescue "permission denied errors
|
71
|
-
rescue Errno::EACCES
|
72
|
-
puts "Network plugin: Access denied when binding interface addresses. Did you try to bind a port under 1024 as a regular user?"
|
73
|
-
|
74
|
-
# Rescue all other errors
|
75
|
-
rescue
|
76
|
-
puts "Network plugin: An error occured."
|
77
|
-
|
78
|
-
# Rescue all other errors
|
79
|
-
end
|
80
|
-
@socket.close
|
81
|
-
|
82
|
-
# Close the socket after use
|
83
|
-
client.close()
|
84
|
-
end
|
85
|
-
|
86
|
-
if remotehostnotfound
|
87
|
-
@remotecommandresult = "Remote Host not running"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# list the remote control options on the screen
|
92
|
-
def showremoteportoptions
|
93
|
-
|
94
|
-
@remoteportoptions = $rwdcontrolports.rwd_options
|
95
|
-
@remotecommandoptions = ["query","stop"].rwd_options
|
96
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# code in install rwdtinker applets - now uses ruby.zip module
|
2
|
-
def installapplet
|
3
|
-
|
4
|
-
nametext = "%s" % [@a_installapplet]
|
5
|
-
|
6
|
-
begin # exception trapped block
|
7
|
-
|
8
|
-
|
9
|
-
require 'extras/zip/zip'
|
10
|
-
fullname = nametext + ".zip"
|
11
|
-
fileName = File.join($zipslocation,fullname)
|
12
|
-
|
13
|
-
zf = Zip::ZipFile.new(fileName)
|
14
|
-
zf.sort.each {
|
15
|
-
|entry|
|
16
|
-
zf.extract(entry.to_s, entry.to_s)
|
17
|
-
}
|
18
|
-
@installapplettext = Message[:applet_installed]
|
19
|
-
|
20
|
-
rescue
|
21
|
-
@installapplettext = "unzip error - applet may not be installed correctly"
|
22
|
-
end # exception rescue
|
23
|
-
|
24
|
-
end
|
25
|
-
|
data/extras/vpim/date.rb
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
$Id: date.rb,v 1.8 2004/11/17 05:06:27 sam Exp $
|
3
|
-
|
4
|
-
Copyright (C) 2005 Sam Roberts
|
5
|
-
|
6
|
-
This library is free software; you can redistribute it and/or modify it
|
7
|
-
under the same terms as the ruby language itself, see the file COPYING for
|
8
|
-
details.
|
9
|
-
=end
|
10
|
-
|
11
|
-
require 'date'
|
12
|
-
|
13
|
-
# Extensions to the standard library Date.
|
14
|
-
class Date
|
15
|
-
|
16
|
-
TIME_START = Date.new(1970, 1, 1)
|
17
|
-
SECS_PER_DAY = 24 * 60 * 60
|
18
|
-
|
19
|
-
# Converts this object to a Time object, or throws an ArgumentError if
|
20
|
-
# conversion is not possible because it is before the start of epoch.
|
21
|
-
def to_time
|
22
|
-
raise ArgumentError, 'date is before the start of system time' if self < TIME_START
|
23
|
-
days = self - TIME_START
|
24
|
-
|
25
|
-
Time.at((days * SECS_PER_DAY).to_i)
|
26
|
-
end
|
27
|
-
|
28
|
-
# If wday responds to to_str, convert it to the wday number by searching for
|
29
|
-
# a wday that matches, using as many characters as are in wday to do the
|
30
|
-
# comparison. wday must be 2 or more characters long in order to be a unique
|
31
|
-
# match, other than that, "mo", "Mon", and "MonDay" are all valid strings
|
32
|
-
# for wday 1.
|
33
|
-
#
|
34
|
-
# This method can be called on a valid wday, and it will return it. Perhaps
|
35
|
-
# it should be called by default inside the Date#new*() methods so that
|
36
|
-
# non-integer wday arguments can be used? Perhaps a similar method should
|
37
|
-
# exist for months? But with months, we all know January is 1, who can
|
38
|
-
# remember where Date chooses to start its wday count!
|
39
|
-
#
|
40
|
-
# Examples:
|
41
|
-
# Date.bywday(2004, 2, Date.str2wday('TU')) => the first Tuesday in
|
42
|
-
# February
|
43
|
-
# Date.bywday(2004, 2, Date.str2wday(2)) => the same day, but notice
|
44
|
-
# that a valid wday integer can be passed right through.
|
45
|
-
#
|
46
|
-
def Date.str2wday(wdaystr)
|
47
|
-
return wdaystr unless wdaystr.respond_to? :to_str
|
48
|
-
|
49
|
-
str = wdaystr.to_str.upcase
|
50
|
-
if str.length < 2
|
51
|
-
raise ArgumentError, 'wday #{wday} is not long enough to be a unique weekday name'
|
52
|
-
end
|
53
|
-
|
54
|
-
wday = Date::DAYNAMES.map { |n| n.slice(0, str.length).upcase }.index(str)
|
55
|
-
|
56
|
-
return wday if wday
|
57
|
-
|
58
|
-
raise ArgumentError, 'wday #{wdaystr} was not a recognizable weekday name'
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
# Create a new Date object for the date specified by year +year+, month
|
63
|
-
# +mon+, and day-of-the-week +wday+.
|
64
|
-
#
|
65
|
-
# The nth, +n+, occurrence of +wday+ within the period will be generated
|
66
|
-
# (+n+ defaults to 1). If +n+ is positive, the nth occurence from the
|
67
|
-
# beginning of the period will be returned, if negative, the nth occurrence
|
68
|
-
# from the end of the period will be returned.
|
69
|
-
#
|
70
|
-
# The period is a year, unless +month+ is non-nil, in which case it is just
|
71
|
-
# that month.
|
72
|
-
#
|
73
|
-
# Examples:
|
74
|
-
# - Date.bywday(2004, nil, 1, 9) => the ninth Sunday of 2004
|
75
|
-
# - Date.bywday(2004, nil, 1) => the first Sunday of 2004
|
76
|
-
# - Date.bywday(2004, nil, 1, -2) => the second last Sunday of 2004
|
77
|
-
# - Date.bywday(2004, 12, 1) => the first sunday in the 12th month of 2004
|
78
|
-
# - Date.bywday(2004, 2, 2, -1) => last Tuesday in the 2nd month in 2004
|
79
|
-
# - Date.bywday(2004, -2, 3, -2) => second last Wednesday in the second last month of 2004
|
80
|
-
#
|
81
|
-
# Compare this to Date.new, which allows a Date to be created by
|
82
|
-
# day-of-the-month, mday, to Date.new2, which allows a Date to be created by
|
83
|
-
# day-of-the-year, yday, and to Date.neww, which allows a Date to be created
|
84
|
-
# by day-of-the-week, but within a specific week.
|
85
|
-
def Date.bywday(year, mon, wday, n = 1, sg=Date::ITALY)
|
86
|
-
# Normalize mon to 1-12.
|
87
|
-
if mon
|
88
|
-
if mon > 12 || mon == 0 || mon < -12
|
89
|
-
raise ArgumentError, "mon #{mon} must be 1-12 or negative 1-12"
|
90
|
-
end
|
91
|
-
if mon < 0
|
92
|
-
mon = 13 + mon
|
93
|
-
end
|
94
|
-
end
|
95
|
-
if wday < 0 || wday > 6
|
96
|
-
raise ArgumentError, 'wday must be in range 0-6, or a weekday name'
|
97
|
-
end
|
98
|
-
|
99
|
-
# Determine direction of indexing.
|
100
|
-
inc = n <=> 0
|
101
|
-
if inc == 0
|
102
|
-
raise ArgumentError, 'n must be greater or less than zero'
|
103
|
-
end
|
104
|
-
|
105
|
-
# if !mon, n is index into year, but direction of search is determined by
|
106
|
-
# sign of n
|
107
|
-
d = Date.new(year, mon ? mon : inc, inc, sg)
|
108
|
-
|
109
|
-
while d.wday != wday
|
110
|
-
d += inc
|
111
|
-
end
|
112
|
-
|
113
|
-
# Now we have found the first/last day with the correct wday, search
|
114
|
-
# for nth occurrence, by jumping by n.abs-1 weeks forward or backward.
|
115
|
-
d += 7 * (n.abs - 1) * inc
|
116
|
-
|
117
|
-
if d.year != year
|
118
|
-
raise ArgumentError, 'n is out of bounds of year'
|
119
|
-
end
|
120
|
-
if mon && d.mon != mon
|
121
|
-
raise ArgumentError, 'n is out of bounds of month'
|
122
|
-
end
|
123
|
-
d
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
# DateGen generates arrays of dates matching simple criteria.
|
128
|
-
class DateGen
|
129
|
-
# Generate an array of dates on +wday+ (the day-of-week,
|
130
|
-
# 0-6, where 0 is Sunday).
|
131
|
-
#
|
132
|
-
# If +n+ is specified, only the nth occurrence of +wday+ within the period
|
133
|
-
# will be generated. If +n+ is positive, the nth occurence from the
|
134
|
-
# beginning of the period will be returned, if negative, the nth occurrence
|
135
|
-
# from the end of the period will be returned.
|
136
|
-
#
|
137
|
-
# The period is a year, unless +month+ is non-nil, in which case it is just
|
138
|
-
# that month.
|
139
|
-
#
|
140
|
-
# Examples:
|
141
|
-
# - DateGen.bywday(2004, nil, 1, 9) => the ninth Sunday in 2004
|
142
|
-
# - DateGen.bywday(2004, nil, 1) => all Sundays in 2004
|
143
|
-
# - DateGen.bywday(2004, nil, 1, -2) => second last Sunday in 2004
|
144
|
-
# - DateGen.bywday(2004, 12, 1) => all sundays in December 2004
|
145
|
-
# - DateGen.bywday(2004, 2, 2, -1) => last Tuesday in February in 2004
|
146
|
-
# - DateGen.bywday(2004, -2, 3, -2) => second last Wednesday in November of 2004
|
147
|
-
#
|
148
|
-
# Compare to Date.bywday(), which allows a single Date to be created with
|
149
|
-
# similar criteria.
|
150
|
-
def DateGen.bywday(year, month, wday, n = nil)
|
151
|
-
seed = Date.bywday(year, month, wday, n ? n : 1)
|
152
|
-
|
153
|
-
dates = [ seed ]
|
154
|
-
|
155
|
-
return dates if n
|
156
|
-
|
157
|
-
succ = seed.clone
|
158
|
-
|
159
|
-
# Collect all matches until we're out of the year (or month, if specified)
|
160
|
-
loop do
|
161
|
-
succ += 7
|
162
|
-
|
163
|
-
break if succ.year != year
|
164
|
-
break if month && succ.month != seed.month
|
165
|
-
|
166
|
-
dates.push succ
|
167
|
-
end
|
168
|
-
dates.sort!
|
169
|
-
dates
|
170
|
-
end
|
171
|
-
|
172
|
-
# Generate an array of dates on +mday+ (the day-of-month, 1-31). For months
|
173
|
-
# in which the +mday+ is not present, no date will be generated.
|
174
|
-
#
|
175
|
-
# The period is a year, unless +month+ is non-nil, in which case it is just
|
176
|
-
# that month.
|
177
|
-
#
|
178
|
-
# Compare to Date.new(), which allows a single Date to be created with
|
179
|
-
# similar criteria.
|
180
|
-
def DateGen.bymonthday(year, month, mday)
|
181
|
-
months = month ? [ month ] : 1..12
|
182
|
-
dates = [ ]
|
183
|
-
|
184
|
-
months.each do |m|
|
185
|
-
begin
|
186
|
-
dates << Date.new(year, m, mday)
|
187
|
-
rescue ArgumentError
|
188
|
-
# Don't generate dates for invalid combinations (Feb 29, when it's not
|
189
|
-
# a leap year, for example).
|
190
|
-
#
|
191
|
-
# TODO - should we raise when month is out of range, or mday can never
|
192
|
-
# be in range (32)?
|
193
|
-
end
|
194
|
-
end
|
195
|
-
dates
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
data/extras/vpim/dirinfo.rb
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
$Id: dirinfo.rb,v 1.19 2004/11/17 05:06:27 sam Exp $
|
3
|
-
|
4
|
-
Copyright (C) 2005 Sam Roberts
|
5
|
-
|
6
|
-
This library is free software; you can redistribute it and/or modify it
|
7
|
-
under the same terms as the ruby language itself, see the file COPYING for
|
8
|
-
details.
|
9
|
-
=end
|
10
|
-
|
11
|
-
require 'extras/vpim/enumerator'
|
12
|
-
require 'extras/vpim/field'
|
13
|
-
require 'extras/vpim/rfc2425'
|
14
|
-
require 'extras/vpim/vpim'
|
15
|
-
|
16
|
-
module Vpim
|
17
|
-
# An RFC 2425 directory info object.
|
18
|
-
#
|
19
|
-
# A directory information object is a sequence of fields. The basic
|
20
|
-
# structure of the object, and the way in which it is broken into fields
|
21
|
-
# is common to all profiles of the directory info type.
|
22
|
-
#
|
23
|
-
# A vCard, for example, is a specialization of a directory info object.
|
24
|
-
#
|
25
|
-
# [RFC2425] the directory information framework (ftp://ftp.ietf.org/rfc/rfc2425.txt)
|
26
|
-
class DirectoryInfo
|
27
|
-
include Enumerable
|
28
|
-
|
29
|
-
private_class_method :new
|
30
|
-
|
31
|
-
# Initialize a DirectoryInfo object from +fields+. If +profile+ is
|
32
|
-
# specified, check the BEGIN/END fields.
|
33
|
-
def initialize(fields, profile = nil) #:nodoc:
|
34
|
-
if fields.detect { |f| ! f.kind_of? DirectoryInfo::Field }
|
35
|
-
raise ArgumentError, 'fields must be an array of DirectoryInfo::Field objects'
|
36
|
-
end
|
37
|
-
|
38
|
-
@string = nil # this is used as a flag to indicate that recoding will be necessary
|
39
|
-
@fields = fields
|
40
|
-
|
41
|
-
check_begin_end(profile) if profile
|
42
|
-
end
|
43
|
-
|
44
|
-
# Decode +card+ into a DirectoryInfo object.
|
45
|
-
#
|
46
|
-
# +card+ may either be a something that is convertible to a string using
|
47
|
-
# #to_str or an array of objects that can be joined into a string using
|
48
|
-
# #join("\n"), or an IO object (which will be read to end-of-file).
|
49
|
-
#
|
50
|
-
# The lines in the string may be delimited using IETF (CRLF) or Unix (LF) conventions.
|
51
|
-
#
|
52
|
-
# A DirectoryInfo is mutable, you can add new fields to it, see
|
53
|
-
# Vpim::DirectoryInfo::Field#create() for how to create a new Field.
|
54
|
-
#
|
55
|
-
# TODO: I don't believe this is ever used, maybe I can remove it.
|
56
|
-
def DirectoryInfo.decode(card) #:nodoc:
|
57
|
-
if card.respond_to? :to_str
|
58
|
-
string = card.to_str
|
59
|
-
elsif card.kind_of? Array
|
60
|
-
string = card.join("\n")
|
61
|
-
elsif card.kind_of? IO
|
62
|
-
string = card.read(nil)
|
63
|
-
else
|
64
|
-
raise ArgumentError, "DirectoryInfo cannot be created from a #{card.type}"
|
65
|
-
end
|
66
|
-
|
67
|
-
fields = Vpim.decode(string)
|
68
|
-
|
69
|
-
new(fields)
|
70
|
-
end
|
71
|
-
|
72
|
-
# Create a new DirectoryInfo object. The +fields+ are an optional array of
|
73
|
-
# DirectoryInfo::Field objects to add to the new object, between the
|
74
|
-
# BEGIN/END. If the +profile+ string is not nil, then it is the name of
|
75
|
-
# the directory info profile, and the BEGIN:+profile+/END:+profile+ fields
|
76
|
-
# will be added.
|
77
|
-
#
|
78
|
-
# A DirectoryInfo is mutable, you can add new fields to it using #push(),
|
79
|
-
# and see Field#create().
|
80
|
-
def DirectoryInfo.create(fields = [], profile = nil)
|
81
|
-
|
82
|
-
if profile
|
83
|
-
p = profile.to_str
|
84
|
-
f = [ Field.create('BEGIN', p) ]
|
85
|
-
f.concat fields
|
86
|
-
f.push Field.create('END', p)
|
87
|
-
fields = f
|
88
|
-
end
|
89
|
-
|
90
|
-
new(fields, profile)
|
91
|
-
end
|
92
|
-
|
93
|
-
# The first field named +name+, or nil if no
|
94
|
-
# match is found.
|
95
|
-
def field(name)
|
96
|
-
enum_by_name(name).each { |f| return f }
|
97
|
-
nil
|
98
|
-
end
|
99
|
-
|
100
|
-
# The value of the first field named +name+, or nil if no
|
101
|
-
# match is found.
|
102
|
-
def [](name)
|
103
|
-
enum_by_name(name).each { |f| return f.value }
|
104
|
-
nil
|
105
|
-
end
|
106
|
-
|
107
|
-
# An array of all the values of fields named +name+, converted to text
|
108
|
-
# (using Field#to_text()).
|
109
|
-
#
|
110
|
-
# TODO - call this #texts(), as in the plural?
|
111
|
-
def text(name)
|
112
|
-
enum_by_name(name).map { |f| f.to_text }
|
113
|
-
end
|
114
|
-
|
115
|
-
# Array of all the Field#group()s.
|
116
|
-
def groups
|
117
|
-
@fields.collect { |f| f.group } .compact.uniq
|
118
|
-
end
|
119
|
-
|
120
|
-
# All fields, frozen.
|
121
|
-
def fields #:nodoc:
|
122
|
-
@fields.dup.freeze
|
123
|
-
end
|
124
|
-
|
125
|
-
# Yields for each Field for which +cond+.call(field) is true. The
|
126
|
-
# (default) +cond+ of nil is considered true for all fields, so
|
127
|
-
# this acts like a normal #each() when called with no arguments.
|
128
|
-
def each(cond = nil) # :yields: Field
|
129
|
-
@fields.each do |field|
|
130
|
-
if(cond == nil || cond.call(field))
|
131
|
-
yield field
|
132
|
-
end
|
133
|
-
end
|
134
|
-
self
|
135
|
-
end
|
136
|
-
|
137
|
-
# Returns an Enumerator for each Field for which #name?(+name+) is true.
|
138
|
-
#
|
139
|
-
# For example, to get an Array of all the email addresses in the card, you
|
140
|
-
# could do:
|
141
|
-
#
|
142
|
-
# card.enum_by_name('email').collect { |f| f.value }
|
143
|
-
def enum_by_name(name)
|
144
|
-
Enumerator.new(self, Proc.new { |field| field.name?(name) })
|
145
|
-
end
|
146
|
-
|
147
|
-
# Returns an Enumerator for each Field for which #group?(+group+) is true.
|
148
|
-
#
|
149
|
-
# For example, to print all the fields, sorted by group, you could do:
|
150
|
-
#
|
151
|
-
# card.groups.sort.each do |group|
|
152
|
-
# card.enum_by_group(group).each do |field|
|
153
|
-
# puts "#{group} -> #{field.name}"
|
154
|
-
# end
|
155
|
-
# end
|
156
|
-
#
|
157
|
-
# or to get an array of all the fields in group 'agroup', you could do:
|
158
|
-
#
|
159
|
-
# card.enum_by_group('agroup').to_a
|
160
|
-
def enum_by_group(group)
|
161
|
-
Enumerator.new(self, Proc.new { |field| field.group?(group) })
|
162
|
-
end
|
163
|
-
|
164
|
-
# Returns an Enumerator for each Field for which +cond+.call(field) is true.
|
165
|
-
def enum_by_cond(cond)
|
166
|
-
Enumerator.new(self, cond )
|
167
|
-
end
|
168
|
-
|
169
|
-
# Append +field+ to the fields. Note that it won't be literally appended
|
170
|
-
# to the fields, it will be inserted before the closing END field.
|
171
|
-
def push(field)
|
172
|
-
@fields[-1,0] = field
|
173
|
-
self
|
174
|
-
end
|
175
|
-
|
176
|
-
alias << push
|
177
|
-
|
178
|
-
# Push +field+ onto the fields, unless there is already a field
|
179
|
-
# with this name.
|
180
|
-
def push_unique(field)
|
181
|
-
push(field) unless @fields.detect { |f| f.name? field.name }
|
182
|
-
self
|
183
|
-
end
|
184
|
-
|
185
|
-
# Append +field+ to the end of all the fields. This isn't usually what you
|
186
|
-
# want to do, usually a DirectoryInfo's first and last fields are a
|
187
|
-
# BEGIN/END pair, see #push().
|
188
|
-
def push_end(field)
|
189
|
-
@fields << field
|
190
|
-
self
|
191
|
-
end
|
192
|
-
|
193
|
-
# The string encoding of the DirectoryInfo. See Field#encode for information
|
194
|
-
# about the width parameter.
|
195
|
-
def encode(width=nil)
|
196
|
-
unless @string
|
197
|
-
@string = @fields.collect { |f| f.encode(width) } . join ""
|
198
|
-
end
|
199
|
-
@string
|
200
|
-
end
|
201
|
-
|
202
|
-
alias to_s encode
|
203
|
-
|
204
|
-
# Check that the DirectoryInfo object is correctly delimited by a BEGIN
|
205
|
-
# and END, that their profile values match, and if +profile+ is specified, that
|
206
|
-
# they are the specified profile.
|
207
|
-
def check_begin_end(profile=nil) #:nodoc:
|
208
|
-
unless @fields.first
|
209
|
-
raise "No fields to check"
|
210
|
-
end
|
211
|
-
unless @fields.first.name? "begin"
|
212
|
-
raise "Needs BEGIN, found: #{@fields.first.encode nil}"
|
213
|
-
end
|
214
|
-
unless @fields.last.name? "end"
|
215
|
-
raise "Needs END, found: #{@fields.last.encode nil}"
|
216
|
-
end
|
217
|
-
unless @fields.last.value? @fields.first.value
|
218
|
-
raise "BEGIN/END mismatch: (#{@fields.first.value.downcase} != #{@fields.last.value.downcase}"
|
219
|
-
end
|
220
|
-
if profile
|
221
|
-
if ! @fields.first.value? profile
|
222
|
-
raise "Mismatched profile"
|
223
|
-
end
|
224
|
-
end
|
225
|
-
true
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|