rwdlanguage 0.01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. data/Readme.txt +475 -0
  2. data/bin/rwdlanguage +19 -0
  3. data/code/01rwdcore/01rwdcore.rb +29 -0
  4. data/code/01rwdcore/02helptexthashbegin.rb +16 -0
  5. data/code/01rwdcore/03helptexthash.rb +21 -0
  6. data/code/01rwdcore/jumplinkcommand.rb +36 -0
  7. data/code/01rwdcore/openhelpwindow.rb +38 -0
  8. data/code/01rwdcore/returntomain.rb +10 -0
  9. data/code/01rwdcore/rundocuments.rb +10 -0
  10. data/code/01rwdcore/runeditconfiguration.rb +10 -0
  11. data/code/01rwdcore/runhelpabout.rb +15 -0
  12. data/code/01rwdcore/runopentinkerdocument.rb +7 -0
  13. data/code/01rwdcore/runtab.rb +15 -0
  14. data/code/01rwdcore/rwdtinkerversion.rb +22 -0
  15. data/code/01rwdcore/rwdwindowreturn.rb +9 -0
  16. data/code/01rwdcore/selectiontab.rb +11 -0
  17. data/code/01rwdcore/setuphelpaboutoptions.rb +15 -0
  18. data/code/01rwdcore/setuptinkerdocuments.rb +7 -0
  19. data/code/01rwdcore/test_cases.rb +158 -0
  20. data/code/01rwdcore/test_harness.rb +20 -0
  21. data/code/01rwdcore/uploadreturns.rb +65 -0
  22. data/code/dd0viewphoto/dd0viewphoto.rb +5 -0
  23. data/code/superant.com.language/0uninstallapplet.rb +22 -0
  24. data/code/superant.com.language/googlelang.rb +25 -0
  25. data/code/superant.com.language/helptexthashload.rb +22 -0
  26. data/code/superant.com.language/loadconfigurationrecord.rb +22 -0
  27. data/code/superant.com.language/loadconfigurationvariables.rb +14 -0
  28. data/code/superant.com.language/openhelpwindow.rb +24 -0
  29. data/code/superant.com.language/rubySteak.rb +40 -0
  30. data/code/superant.com.language/runappletwindow.rb +12 -0
  31. data/code/superant.com.language/runrwdshellwindow.rb +12 -0
  32. data/code/superant.com.language/runrwdwordsbackwindow.rb +10 -0
  33. data/code/superant.com.language/rwdtinkerversion.rb +10 -0
  34. data/code/superant.com.language/saveconfigurationrecord.rb +20 -0
  35. data/code/superant.com.language/test_cases.rb +20 -0
  36. data/code/superant.com.rwdtinkerbackwindow/changelocale.rb +84 -0
  37. data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +19 -0
  38. data/code/superant.com.rwdtinkerbackwindow/initiateapplets.rb +169 -0
  39. data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +38 -0
  40. data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +20 -0
  41. data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +12 -0
  42. data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +55 -0
  43. data/code/superant.com.rwdtinkerbackwindow/listinstalledfiles.rb +14 -0
  44. data/code/superant.com.rwdtinkerbackwindow/listzips.rb +37 -0
  45. data/code/superant.com.rwdtinkerbackwindow/loadconfigurationrecord.rb +24 -0
  46. data/code/superant.com.rwdtinkerbackwindow/loadconfigurationvariables.rb +14 -0
  47. data/code/superant.com.rwdtinkerbackwindow/network.rb +87 -0
  48. data/code/superant.com.rwdtinkerbackwindow/openappletname.rb +19 -0
  49. data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +40 -0
  50. data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +24 -0
  51. data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +46 -0
  52. data/code/superant.com.rwdtinkerbackwindow/removeappletvariables.rb +52 -0
  53. data/code/superant.com.rwdtinkerbackwindow/runremoteinstall.rb +11 -0
  54. data/code/superant.com.rwdtinkerbackwindow/runrwdtinkerbackwindow.rb +15 -0
  55. data/code/superant.com.rwdtinkerbackwindow/rwdtinkerwin2version.rb +13 -0
  56. data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +19 -0
  57. data/code/superant.com.rwdtinkerbackwindow/showlocaleoptions.rb +9 -0
  58. data/code/superant.com.rwdtinkerbackwindow/viewappletcontents.rb +23 -0
  59. data/code/superant.com.rwdtinkerbackwindow/viewgemappletcontents.rb +24 -0
  60. data/code/superant.com.rwdtinkerbackwindow/viewlogfile.rb +16 -0
  61. data/code/superant.com.thesaurus/clearhttpview3.rb +9 -0
  62. data/code/superant.com.thesaurus/listwordlookup.rb +37 -0
  63. data/code/superant.com.thesaurus/runappletwindow.rb +12 -0
  64. data/code/superant.com.words/dictlookup.rb +20 -0
  65. data/code/superant.com.words/runrwdwordsbackwindow.rb +10 -0
  66. data/code/superant.com.words/rwdtinkerversion.rb +10 -0
  67. data/code/zz0applicationend/zz0end.rb +5 -0
  68. data/configuration/rwdtinker.dist +15 -0
  69. data/configuration/rwdwlanguage.dist +21 -0
  70. data/configuration/tinkerwin2variables.dist +23 -0
  71. data/gui/00coreguibegin/applicationguitop.rwd +9 -0
  72. data/gui/frontwindow0/cc0openphoto.rwd +22 -0
  73. data/gui/frontwindowselections/00selectiontabbegin.rwd +11 -0
  74. data/gui/frontwindowselections/jumplinkcommands.rwd +15 -0
  75. data/gui/frontwindowselections/wwselectionend.rwd +3 -0
  76. data/gui/frontwindowtdocuments/00documentbegin.rwd +6 -0
  77. data/gui/frontwindowtdocuments/tinkerdocuments.rwd +14 -0
  78. data/gui/frontwindowtdocuments/zzdocumentend.rwd +8 -0
  79. data/gui/helpaboutbegin/zzzrwdlasttab.rwd +6 -0
  80. data/gui/helpaboutbegin/zzzzhelpscreenstart.rwd +3 -0
  81. data/gui/helpaboutbegin/zzzzzzhelpabouttab.rwd +15 -0
  82. data/gui/helpaboutzend/helpscreenend.rwd +3 -0
  83. data/gui/helpaboutzend/zhelpscreenstart2.rwd +3 -0
  84. data/gui/helpaboutzend/zzzzhelpabout2.rwd +15 -0
  85. data/gui/helpaboutzend/zzzzhelpscreen2end.rwd +3 -0
  86. data/gui/tinkerbackwindows/superant.com.language/1appname.rwd +4 -0
  87. data/gui/tinkerbackwindows/superant.com.language/22google.rwd +38 -0
  88. data/gui/tinkerbackwindows/superant.com.language/44germany.rwd +19 -0
  89. data/gui/tinkerbackwindows/superant.com.language/67viewconfiguration.rwd +27 -0
  90. data/gui/tinkerbackwindows/superant.com.language/77jumplinkcommands.rwd +17 -0
  91. data/gui/tinkerbackwindows/superant.com.language/z9end.rwd +6 -0
  92. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/1appname.rwd +5 -0
  93. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40rwdlistzips.rwd +41 -0
  94. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/45installremotezip.rwd +44 -0
  95. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistapplets.rwd +44 -0
  96. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/60editconfiguration.rwd +30 -0
  97. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +29 -0
  98. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/75rwdlogfile.rwd +20 -0
  99. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/80localechanger.rwd +17 -0
  100. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/81jumplinkcommands.rwd +17 -0
  101. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/9backend.rwd +6 -0
  102. data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/1appname.rwd +31 -0
  103. data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/9end.rwd +4 -0
  104. data/gui/tinkerbackwindows/superant.com.versionwindow/1appname.rwd +19 -0
  105. data/gui/tinkerbackwindows/superant.com.versionwindow/helpaboutwindow.rwd +17 -0
  106. data/gui/tinkerbackwindows/superant.com.words/1appname.rwd +4 -0
  107. data/gui/tinkerbackwindows/superant.com.words/1dictionary.rwd +19 -0
  108. data/gui/tinkerbackwindows/superant.com.words/4thesaurus.rwd +36 -0
  109. data/gui/tinkerbackwindows/superant.com.words/77jumplinkcommands.rwd +17 -0
  110. data/gui/tinkerbackwindows/superant.com.words/z9end.rwd +6 -0
  111. data/gui/zzcoreguiend/yy9rwdend.rwd +4 -0
  112. data/init.rb +179 -0
  113. data/installed/rwdwlanguage.inf +24 -0
  114. data/installed/temp.rb +1 -0
  115. data/lang/en/rwdcore/en.po +197 -0
  116. data/lang/en/rwdlanguage/en.po +32 -0
  117. data/lang/es/rwdcore/es.po +184 -0
  118. data/lang/es/rwdlanguage/en.po +32 -0
  119. data/lang/fr/rwdcore/fr.po +169 -0
  120. data/lang/fr/rwdlanguage/en.po +32 -0
  121. data/lang/hi/rwdcore/hi.po +173 -0
  122. data/lang/hi/rwdlanguage/en.po +32 -0
  123. data/lang/ja/rwdcore/ja.po +171 -0
  124. data/lang/ja/rwdlanguage/en.po +32 -0
  125. data/lang/nl/rwdcore/nl.po +169 -0
  126. data/lang/nl/rwdlanguage/en.po +32 -0
  127. data/lib/dict.rb +438 -0
  128. data/lib/g_translate.rb +43 -0
  129. data/lib/g_translate/client.rb +84 -0
  130. data/lib/g_translate/translator.rb +57 -0
  131. data/lib/ger-eng.txt +111283 -0
  132. data/lib/oothesaurus.rb +76 -0
  133. data/lib/rconftool.rb +387 -0
  134. data/lib/rwd/browser.rb +123 -0
  135. data/lib/rwd/ftools.rb +174 -0
  136. data/lib/rwd/mime.rb +328 -0
  137. data/lib/rwd/net.rb +877 -0
  138. data/lib/rwd/ruby.rb +889 -0
  139. data/lib/rwd/rwd.rb +1425 -0
  140. data/lib/rwd/sgml.rb +236 -0
  141. data/lib/rwd/thread.rb +63 -0
  142. data/lib/rwd/tree.rb +371 -0
  143. data/lib/rwd/xml.rb +101 -0
  144. data/lib/rwdthemes/default.rwd +317 -0
  145. data/lib/rwdthemes/pda.rwd +72 -0
  146. data/lib/rwdthemes/windowslike.rwd +171 -0
  147. data/lib/rwdtinker/rwdcodedir.rb +56 -0
  148. data/lib/rwdtinker/rwdguidir.rb +57 -0
  149. data/lib/rwdtinker/rwdlangdir.rb +60 -0
  150. data/lib/rwdtinker/rwdtinkertools.rb +25 -0
  151. data/lib/zip/ioextras.rb +155 -0
  152. data/lib/zip/stdrubyext.rb +111 -0
  153. data/lib/zip/tempfile_bugfixed.rb +195 -0
  154. data/lib/zip/zip.rb +1847 -0
  155. data/lib/zip/zipfilesystem.rb +609 -0
  156. data/lib/zip/ziprequire.rb +90 -0
  157. data/rwd_files/HowTo_Language.txt +179 -0
  158. data/rwd_files/HowTo_Tinker.txt +515 -0
  159. data/rwd_files/HowTo_TinkerWin2.txt +202 -0
  160. data/rwd_files/Readme.txt +57 -0
  161. data/rwd_files/RubyWebDialogs.html +6 -0
  162. data/rwd_files/Tinkerhelptexthash.txt +84 -0
  163. data/rwd_files/favicon.ico +0 -0
  164. data/rwd_files/log/rwdtinker.log +726 -0
  165. data/rwd_files/rdoc-style.css +175 -0
  166. data/rwd_files/rwdapplications.html +76 -0
  167. data/rwd_files/rwdlanguagehelpfiles.txt +34 -0
  168. data/rwd_files/tinker.png +0 -0
  169. data/rwdconfig.dist +24 -0
  170. data/rwdlanguage.rb +1 -0
  171. data/tests/RubyGauge.rb +179 -0
  172. data/tests/checkdepends.sh +4 -0
  173. data/tests/cleancnf.sh +6 -0
  174. data/tests/makedist-rwdwlanguage.rb +56 -0
  175. data/tests/makedist.rb +66 -0
  176. data/tests/rdep.rb +354 -0
  177. data/tests/totranslate.lang +93 -0
  178. data/zips/rwdwcalc-0.63.zip +0 -0
  179. data/zips/rwdwfoldeditor-0.08.zip +0 -0
  180. data/zips/rwdwhypernote-0.16.zip +0 -0
  181. data/zips/rwdwlanguage-0.01.zip +0 -0
  182. data/zips/rwdwmovies-0.98.zip +0 -0
  183. data/zips/rwdwruby-1.08.zip +0 -0
  184. data/zips/temp.rb +1 -0
  185. data/zips/tinkerbellw-0.04.zip +0 -0
  186. data/zips/wrubyslippers-1.08.zip +0 -0
  187. metadata +246 -0
@@ -0,0 +1,32 @@
1
+ # Lang file for rwdcalendar - en
2
+
3
+ msgid "year"
4
+ msgstr "Year:"
5
+
6
+ msgid "month"
7
+ msgstr "Month:"
8
+
9
+ msgid "show_month"
10
+ msgstr '"Show Month"'
11
+
12
+ msgid "rwdschedule_calendar_generalhelp"
13
+ msgstr "Use the 'Edit Event' tab<br> The first field is the most important. It is the filename that<br> will be created. I use the event date starting with yearmonthday<br> 2005january11 <br> The following lines for entry are for you to fill in as you want.<br> When you are finished press the Save Changes button <br> You use this same screen for editing an already saved event "
14
+
15
+ msgid "rwdschedule_filelist_generalhelp"
16
+ msgstr "Click on the list events button. <br> Click on the date you want <br> Then click the 'Open' button <br> If it finds the record it will open it. It displays the record as text under the 'Open' button."
17
+
18
+ msgid "event_utilities_help"
19
+ msgstr "On the event utilities tab <br> You can rename event filenames <br> You can delete events"
20
+
21
+ msgid "rwdschedule_calendar_configuration"
22
+ msgstr "click on 'Edit Configuration' <br> You can view the configuration file <br><br> You can edit the configuration <br> Remember to reload the configuration variables if you want your changes used."
23
+
24
+ msgid "rwdschedule_calendar_sync"
25
+ msgstr "Sync for multiple computers<br> If you are like me, you have more than one system<br> I use rwdTinker at home on my Linux laptop at work I use it on XP<br> So I am adding schedule events on different machines. <br> There is a function to help sync the separate systems <p> in 'Selection Panel' click on 'Open Schedule Sync Window' <p> First you need your ftp details set in the configuration/rwdschedule.cnf file <p> you can upload your events from your local schedules directory to the ftp site<br> you can download events from the ftp site to your local updates directory<br> you can perform a sync which finds remote events and adds them to your local schedules directory<br> There is a button to delete the update directory when finished"
26
+
27
+ msgid "rwdschedule_calendar_help"
28
+ msgstr "On the 'Show Month' tab<br> You can see the current month or enter a year and month <br> for example: <br> Year: 2005 <br> Month: 2 <br> Click on 'show month' <br> It will display one month"
29
+
30
+ msgid "rwdschedule_icsfile_help"
31
+ msgstr "You can create an ics file<br> you can view a raw ics file <br> Rename ics File<br> Delete ics File<br> <br><br> format of date year = 2005<br> month = 02<br> day = 01<br> hour = 01<br> minute = 01<br>"
32
+
@@ -0,0 +1,169 @@
1
+ # Language files for RwdTinker core
2
+
3
+ msgid "error_message_id_unknown"
4
+ msgstr ""
5
+
6
+ msgid "applet_installed"
7
+ msgstr "Applet geinstalleerd"
8
+
9
+ msgid "application_version"
10
+ msgstr "Application Version"
11
+
12
+ msgid "cancel"
13
+ msgstr "Annuleren"
14
+
15
+ msgid "clickfor_version"
16
+ msgstr "Klier hier voor de Versie"
17
+
18
+ msgid "clickbelowtoviewlistof_zip"
19
+ msgstr "click below to view lists of zips"
20
+
21
+ msgid "documents"
22
+ msgstr "Documenten"
23
+
24
+ msgid "edit"
25
+ msgstr "edit"
26
+
27
+ msgid "file_name"
28
+ msgstr "File Name:"
29
+
30
+ msgid "fill_record"
31
+ msgstr "Fill Record"
32
+
33
+ msgid "help"
34
+ msgstr "Help"
35
+
36
+ msgid "help_about"
37
+ msgstr "Help About"
38
+
39
+ msgid "install_applet"
40
+ msgstr "install (rwdtinker) applet"
41
+
42
+ msgid "jumptoapplication_location"
43
+ msgstr "Jump to Application Location"
44
+
45
+ msgid "list_applets"
46
+ msgstr "Remove Applets"
47
+
48
+ msgid "listappletsinthegem_directory"
49
+ msgstr "List applets in the Gem Directory"
50
+
51
+ msgid "listappletsavailablefor_installation"
52
+ msgstr "List applets available for installation"
53
+
54
+ msgid "list_files"
55
+ msgstr "List Files"
56
+
57
+ msgid "list_installed_gems "
58
+ msgstr "List installed Gems"
59
+
60
+ msgid "list_photos"
61
+ msgstr "List Photos"
62
+
63
+ msgid "list_zips"
64
+ msgstr "List Zips"
65
+
66
+ msgid "listzipdirappletsavailable"
67
+ msgstr "List (zip directory) applets available for installation"
68
+
69
+ msgid "menu_panel"
70
+ msgstr "Menu Panel"
71
+
72
+ msgid "module_unknown"
73
+ msgstr "Module onbekend"
74
+
75
+ msgid "next"
76
+ msgstr "Volgende"
77
+
78
+ msgid "open"
79
+ msgstr "Openen"
80
+
81
+ msgid "open_document"
82
+ msgstr "Open Document"
83
+
84
+ msgid "openselectedhelp_about"
85
+ msgstr "Open selected help about"
86
+
87
+ msgid "reload_variables"
88
+ msgstr "Reload Variables"
89
+
90
+ msgid "remove_applet"
91
+ msgstr "remove applet"
92
+
93
+ msgid "return"
94
+ msgstr "Return"
95
+
96
+ msgid "rwdtinker_window_2"
97
+ msgstr "RwdTinker Window 2"
98
+
99
+ msgid "rwdtinker"
100
+ msgstr "RwdTinker"
101
+
102
+ msgid "rwdtinker_back_window"
103
+ msgstr '"RwdTinker Back Venster"'
104
+
105
+ msgid "rwdtinker_help"
106
+ msgstr "RwdTinker Help"
107
+
108
+ msgid "rwdtinker_help_window"
109
+ msgstr "RWDTinker Help Venster"
110
+
111
+ msgid "showjump_links"
112
+ msgstr "Show Jump Links"
113
+
114
+ msgid "showdocument_list"
115
+ msgstr "Show Document List"
116
+
117
+ msgid "showhelpabout_links"
118
+ msgstr "Show Help About Links"
119
+
120
+ msgid "save"
121
+ msgstr "Opslaan"
122
+
123
+ msgid "save_changes"
124
+ msgstr "Save Changes"
125
+
126
+ msgid "selection_panel"
127
+ msgstr '"Selectie Paneel"'
128
+
129
+ msgid "selection_tab"
130
+ msgstr "Menu Tab"
131
+
132
+ msgid "tinker_logo"
133
+ msgstr "Tinker Logo"
134
+
135
+ msgid "tinkerback_window"
136
+ msgstr "Tinker Back Window"
137
+
138
+ msgid "viewapplet_contents"
139
+ msgstr "View Applet Contents"
140
+
141
+ msgid "viewalreadyinstalled_applications"
142
+ msgstr "View already installed GEM applications"
143
+
144
+ msgid "viewinstalled_text"
145
+ msgstr "View Install Text"
146
+
147
+ msgid "view_platform"
148
+ msgstr "view platform"
149
+
150
+ msgid "viewplatform_information"
151
+ msgstr "View Platform Information"
152
+
153
+ msgid "viewlogger_information"
154
+ msgstr "View Logger Information"
155
+
156
+ msgid "view_event"
157
+ msgstr "View event"
158
+
159
+ msgid "viewinstall_text"
160
+ msgstr "View Install Text"
161
+
162
+ msgid "viewlistinstall_files"
163
+ msgstr "View List of Installed Files"
164
+
165
+ msgid "view_photo"
166
+ msgstr "View Photo"
167
+
168
+ msgid "window"
169
+ msgstr "Venster"
@@ -0,0 +1,32 @@
1
+ # Lang file for rwdcalendar - en
2
+
3
+ msgid "year"
4
+ msgstr "Year:"
5
+
6
+ msgid "month"
7
+ msgstr "Month:"
8
+
9
+ msgid "show_month"
10
+ msgstr '"Show Month"'
11
+
12
+ msgid "rwdschedule_calendar_generalhelp"
13
+ msgstr "Use the 'Edit Event' tab<br> The first field is the most important. It is the filename that<br> will be created. I use the event date starting with yearmonthday<br> 2005january11 <br> The following lines for entry are for you to fill in as you want.<br> When you are finished press the Save Changes button <br> You use this same screen for editing an already saved event "
14
+
15
+ msgid "rwdschedule_filelist_generalhelp"
16
+ msgstr "Click on the list events button. <br> Click on the date you want <br> Then click the 'Open' button <br> If it finds the record it will open it. It displays the record as text under the 'Open' button."
17
+
18
+ msgid "event_utilities_help"
19
+ msgstr "On the event utilities tab <br> You can rename event filenames <br> You can delete events"
20
+
21
+ msgid "rwdschedule_calendar_configuration"
22
+ msgstr "click on 'Edit Configuration' <br> You can view the configuration file <br><br> You can edit the configuration <br> Remember to reload the configuration variables if you want your changes used."
23
+
24
+ msgid "rwdschedule_calendar_sync"
25
+ msgstr "Sync for multiple computers<br> If you are like me, you have more than one system<br> I use rwdTinker at home on my Linux laptop at work I use it on XP<br> So I am adding schedule events on different machines. <br> There is a function to help sync the separate systems <p> in 'Selection Panel' click on 'Open Schedule Sync Window' <p> First you need your ftp details set in the configuration/rwdschedule.cnf file <p> you can upload your events from your local schedules directory to the ftp site<br> you can download events from the ftp site to your local updates directory<br> you can perform a sync which finds remote events and adds them to your local schedules directory<br> There is a button to delete the update directory when finished"
26
+
27
+ msgid "rwdschedule_calendar_help"
28
+ msgstr "On the 'Show Month' tab<br> You can see the current month or enter a year and month <br> for example: <br> Year: 2005 <br> Month: 2 <br> Click on 'show month' <br> It will display one month"
29
+
30
+ msgid "rwdschedule_icsfile_help"
31
+ msgstr "You can create an ics file<br> you can view a raw ics file <br> Rename ics File<br> Delete ics File<br> <br><br> format of date year = 2005<br> month = 02<br> day = 01<br> hour = 01<br> minute = 01<br>"
32
+
data/lib/dict.rb ADDED
@@ -0,0 +1,438 @@
1
+ # dict.rb - a client-side implementation of the DICT protocol (RFC 2229)
2
+ #
3
+ # $Id: dict.rb,v 1.25 2003/04/19 06:53:41 ianmacd Exp $
4
+ #
5
+ # Version : 0.9.2
6
+ # Author : Ian Macdonald <ian@caliban.org>
7
+ #
8
+ # Copyright (C) 2002-2003 Ian Macdonald
9
+ #
10
+ # This program is free software; you can redistribute it and/or modify
11
+ # it under the terms of the GNU General Public License as published by
12
+ # the Free Software Foundation; either version 2, or (at your option)
13
+ # any later version.
14
+ #
15
+ # This program is distributed in the hope that it will be useful,
16
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ # GNU General Public License for more details.
19
+ #
20
+ # You should have received a copy of the GNU General Public License
21
+ # along with this program; if not, write to the Free Software Foundation,
22
+ # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
+
24
+ =begin
25
+
26
+ = NAME
27
+ Ruby/DICT - client-side DICT protocol library
28
+ = SYNOPSIS
29
+
30
+ require 'dict'
31
+
32
+ dict = DICT.new('dict.org', DICT::DEFAULT_PORT)
33
+ dict.client('a Ruby/DICT client')
34
+ definitions = dict.define(DICT::ALL_DATABASES, 'ruby')
35
+
36
+ if definitions
37
+ definitions.each do |d|
38
+ printf("From %s [%s]:\n\n", d.description, d.database)
39
+ d.definition.each { |line| print line }
40
+ end
41
+ end
42
+
43
+ dict.disconnect
44
+
45
+ = DESCRIPTION
46
+ Ruby/DICT is a client-side library implementation of the DICT protocol,
47
+ as described in ((<RFC 2229|URL:ftp://ftp.isi.edu/in-notes/rfc2229.txt>)).
48
+ = CLASS METHODS
49
+ --- DICT.new(hosts, port = DICT::DEFAULT_PORT, debug = false, verbose = false)
50
+ This creates a new instance of the DICT class. A DICT object has four
51
+ instance variables: ((|capabilities|)), ((|code|)), ((|message|)) and
52
+ ((|msgid|)). ((|capabilities|)) is an array of Strings relating to
53
+ capabilities implemented on the server, ((|code|)) is the last status
54
+ code returned by the server, ((|message|)) is the text of the message
55
+ related to ((|code|)), and ((|msgid|)) is the message ID returned by the
56
+ server.
57
+ = INSTANCE METHODS
58
+ --- DICT#disconnect
59
+ Disconnect from the server.
60
+ --- DICT#define(database, word)
61
+ Obtain definitions for ((|word|)) from ((|database|)). A list of valid
62
+ databases can be obtained using DICT#show(DICT::DATABASES).
63
+
64
+ To show just the first definition found, use ((|DICT::FIRST_DATABASE|))
65
+ as the database name. To show definitions from all databases, use
66
+ ((|DICT::ALL_DATABASES|)).
67
+
68
+ On success, this returns an array of Struct:Definition objects.
69
+ ((*nil*)) is returned on failure.
70
+ --- DICT#match(database, strategy, word)
71
+ Obtain matches for ((|word|)) from ((|database|)) using ((|strategy|)).
72
+
73
+ On success, a hash of arrays is returned. The keys of the hash are the
74
+ database names and the values are arrays of word matches that were found
75
+ in that database. ((*nil*)) is returned on failure.
76
+ --- DICT#show_server
77
+ This method retrieves information on the server itself.
78
+
79
+ A String is returned on success, while ((*nil*)) is returned on failure.
80
+ --- DICT#show_db
81
+ This method retrieves information on the databases offered by the server.
82
+
83
+ A Hash indexed on database name and containing database descriptions
84
+ is returned on success, while ((*nil*)) is returned on failure.
85
+ --- DICT#show_info(database)
86
+ This method retrieves information on a particular database offered by
87
+ the server.
88
+
89
+ A String is returned on success, while ((*nil*)) is returned on failure.
90
+ --- DICT#show_strat
91
+ This method retrieves information on the strategies offered by the server.
92
+
93
+ A Hash indexed on strategy name and containing strategy descriptions
94
+ is returned on success, while ((*nil*)) is returned on failure.
95
+ --- DICT#status
96
+ This method returns a single line String of status information from the
97
+ server.
98
+ --- DICT#help
99
+ This method returns a String of help information from the server,
100
+ describing the commands it implements.
101
+ --- DICT#client
102
+ This method sends a single line String of information describing a client
103
+ application to the server.
104
+ --- DICT#auth(user, secret)
105
+ This method attempts to authenticate ((|user|)) to the server using
106
+ ((|secret|)). Note that ((|secret|)) is not literally passed to the server.
107
+ = CONSTANTS
108
+ Ruby/DICT uses a lot of constants, mostly for the status codes
109
+ returned by DICT servers. See the source for details.
110
+
111
+ Some of the more interesting other constants:
112
+ : DICT::FIRST_DATABASE
113
+ Define or match, stopping at first database where match is found
114
+ : DICT::ALL_DATABASES
115
+ Define or match, gathering matches from all databases
116
+ : DICT::DEFAULT_MATCH_STRATEGY
117
+ Match using a server-dependent default strategy, which should be the best
118
+ strategy available for interactive spell checking
119
+ : DICT::DEFAULT_PORT
120
+ The default port used by DICT servers, namely 2628
121
+ : DICT::ERROR
122
+ A Regex constant matching any server status code indicating an error
123
+ = EXCEPTIONS
124
+ Exception classes are subclasses of the container class DICTError, which is,
125
+ itself, a subclass of RuntimeError
126
+ --- ConnectError.new(message, code = 2)
127
+ A ConnectError is raised if DICT::new is unable to connect to the chosen
128
+ DICT server for any reason. Program execution will terminate.
129
+ --- ProtocolError.new(message, code = 3)
130
+ A ProtocolError exception can be used if a server operation returns a
131
+ status code matching DICT::ERROR. This does not happen automatically. The
132
+ code is stored in the ((|code|)) attribute of the instance of the DICT
133
+ object. Program execution will terminate.
134
+ = AUTHOR
135
+ Written by Ian Macdonald <ian@caliban.org>
136
+ = COPYRIGHT
137
+ Copyright (C) 2002-2003 Ian Macdonald
138
+
139
+ This is free software; see the source for copying conditions.
140
+ There is NO warranty; not even for MERCHANTABILITY or FITNESS
141
+ FOR A PARTICULAR PURPOSE.
142
+ = SEE ALSO
143
+ * ((<"Ruby/DICT home page - http://www.caliban.org/ruby/"|URL:http://www.caliban.org/ruby/>))
144
+ * ((<"The DICT development group - http://www.dict.org/"|URL:http://www.dict.org/>))
145
+ * ((<"RFC 2229 - ftp://ftp.isi.edu/in-notes/rfc2229.txt"|URL:ftp://ftp.isi.edu/in-notes/rfc2229.txt>))
146
+ = BUGS
147
+ Send all bug reports, enhancement requests and patches to the
148
+ author.
149
+ = HISTORY
150
+ $Id: dict.rb,v 1.25 2003/04/19 06:53:41 ianmacd Exp $
151
+
152
+ =end
153
+
154
+
155
+ require 'socket'
156
+ require 'md5'
157
+
158
+
159
+ # lines that start with .. need to be reduced to .
160
+ #
161
+ class String
162
+ def undot!
163
+ sub!(/^\.\./, '.')
164
+ end
165
+ end
166
+
167
+
168
+ # a basic exception class for DICT errors
169
+ #
170
+ class DICTError < RuntimeError
171
+ def initialize(message, code = 1)
172
+ $stderr.puts message
173
+ exit code
174
+ end
175
+ end
176
+
177
+
178
+ # deal with connection errors
179
+ #
180
+ class ConnectError < DICTError
181
+ def initialize(message, code = 2)
182
+ super
183
+ end
184
+ end
185
+
186
+
187
+ # deal with status code errors
188
+ #
189
+ class ProtocolError < DICTError
190
+ def initialize(message, code = 3)
191
+ super
192
+ end
193
+ end
194
+
195
+ # a structure for definitions
196
+ #
197
+ Definition = Struct.new('Definition', :word, :definition, :database,
198
+ :description)
199
+
200
+ class DICT
201
+ attr_reader :capabilities, :code, :message, :msgid
202
+
203
+ DATABASES_PRESENT = '110'
204
+ STRATEGIES_AVAILABLE = '111'
205
+ DATABASE_INFORMATION = '112'
206
+ HELP_TEXT = '113'
207
+ SERVER_INFORMATION = '114'
208
+ CHALLENGE_FOLLOWS = '130'
209
+ DEFINITIONS_RETRIEVED = '150'
210
+ WORD_DEFINITION = '151'
211
+ MATCHES_PRESENT = '152'
212
+ STATUS_RESPONSE = '210'
213
+ CONNECTION_ESTABLISHED = '220'
214
+ CLOSING_CONNECTION = '221'
215
+ AUTHENTICATION_SUCCESSFUL = '230'
216
+ OK = '250'
217
+ SEND_RESPONSE = '330'
218
+ TEMPORARILY_UNAVAILABLE = '420'
219
+ SHUTTING_DOWN = '421'
220
+ UNRECOGNISED_COMMAND = '500'
221
+ ILLEGAL_PARAMETERS = '501'
222
+ COMMAND_NOT_IMPLEMENTED = '502'
223
+ PARAMETER_NOT_IMPLEMENTED = '503'
224
+ ACCESS_DENIED = '530'
225
+ AUTH_DENIED = '531'
226
+ UNKNOWN_MECHANISM = '532'
227
+ INVALID_DATABASE = '550'
228
+ INVALID_STRATEGY = '551'
229
+ NO_MATCH = '552'
230
+ NO_DATABASES_PRESENT = '554'
231
+ NO_STRATEGIES_AVAILABLE = '555'
232
+
233
+ ALL_DATABASES = '*'
234
+ DEFAULT_MATCH_STRATEGY = '.'
235
+ DEFAULT_PORT = 2628
236
+ ERROR = /^[45]/
237
+ FIRST_DATABASE = '!'
238
+ MAX_LINE_LENGTH = 1024
239
+ PAIR = /^(\S+)\s"(.+)"\r$/
240
+ REPLY_CODE = /^\d\d\d/
241
+
242
+ def initialize(hosts, port = DEFAULT_PORT, debug = false, verbose = false)
243
+ hosts.each do |host|
244
+ @debug = debug
245
+ @verbose = verbose
246
+ printf("Attempting to connect to %s:%d...\n", host, port) if @verbose
247
+
248
+ begin
249
+ @sock = TCPSocket.open(host, port)
250
+ rescue
251
+ next # cycle through list of servers, if more than one
252
+ end
253
+
254
+ break # continue if connection to this host succeeded
255
+ end
256
+
257
+ # catch failure
258
+ raise ConnectError, 'Unable to connect to host' unless defined? @sock
259
+
260
+ # check status line on connect
261
+ line = get_line
262
+ raise ConnectError, line if line =~ ERROR
263
+
264
+ caps, @msgid = /<(.+?)>\s(<.+>)/.match(line)[1..2]
265
+ @capabilities = caps.split(/\./)
266
+ if @verbose
267
+ printf("Capabilities: %s\n", @capabilities.join(', '))
268
+ printf("Msgid: %s\n", @msgid)
269
+ end
270
+ end
271
+
272
+ private
273
+
274
+ # output a line to the server
275
+ #
276
+ def send_line(command)
277
+ line = command + "\r\n"
278
+ $stderr.printf("SEND: %s", line) if @debug
279
+ @sock.print(line)
280
+ end
281
+
282
+ # get a line of input from the server
283
+ #
284
+ def get_line
285
+ line = @sock.readline("\r\n")
286
+ $stderr.printf("RECV: %s", line) if @debug
287
+ line
288
+ end
289
+
290
+ # send a command and get a response
291
+ #
292
+ def exec_cmd(command)
293
+ send_line(command)
294
+ line = get_line
295
+ @code, @message = /^(\d\d\d)\s(.*)$/.match(line)[1..2]
296
+ # remember the command just executed
297
+ @command = command
298
+ end
299
+
300
+ # determine whether we're at the end of this response
301
+ #
302
+ def end_of_text?(line)
303
+ line =~ /^\.\r$/ ? true : false
304
+ end
305
+
306
+ # generic method to issue command and parse response
307
+ #
308
+ def parse_response
309
+ return nil if @code =~ ERROR
310
+
311
+ while line = get_line
312
+ # on first pass through loop, create list as either a hash
313
+ # or a string, depending # on what data looks like
314
+ list ||= line =~ PAIR ? Hash.new : ''
315
+
316
+ # check for end of data
317
+ return list if line =~ REPLY_CODE
318
+
319
+ if ! end_of_text? line
320
+ line.undot!
321
+ (list << line; next) if list.is_a?(String) # list is just text
322
+
323
+ # list is a hash of data pairings
324
+ name, desc = PAIR.match(line)[1..2]
325
+ if @command =~ /^MATCH/
326
+ list[name] = Array.new unless list[name]
327
+ list[name] << desc
328
+ else
329
+ list[name] = desc
330
+ end
331
+
332
+ end
333
+ end
334
+ end
335
+
336
+ public
337
+
338
+ # QUIT from the server
339
+ #
340
+ def disconnect
341
+ exec_cmd('QUIT')
342
+ @sock.close
343
+ end
344
+
345
+ # DEFINE a word
346
+ #
347
+ def define(db, word)
348
+ definitions = Array.new
349
+ d = Definition.new
350
+ d.word = word
351
+ d.definition = Array.new
352
+
353
+ exec_cmd('DEFINE %s "%s"' % [ db, word ])
354
+
355
+ return nil if @code =~ ERROR
356
+
357
+ while line = get_line
358
+ return definitions if line =~ /^#{OK}/
359
+
360
+ if line =~ /^#{WORD_DEFINITION}/
361
+ word, d.database, d.description =
362
+ /^\d\d\d\s"(.+?)"\s(\S+)\s"(.+)"\r$/.match(line)[1..3]
363
+ elsif end_of_text? line # finish definition and start a new one
364
+ definitions << d
365
+ d = Definition.new
366
+ d.word = word
367
+ d.definition = Array.new
368
+ else
369
+ line.undot!
370
+ d.definition << line
371
+ end
372
+
373
+ end
374
+ end
375
+
376
+ # MATCH a word
377
+ #
378
+ def match(db, strategy, word)
379
+ exec_cmd('MATCH %s %s "%s"' % [ db, strategy, word ])
380
+ parse_response
381
+ end
382
+
383
+ # get database list
384
+ #
385
+ def show_db
386
+ exec_cmd("SHOW DB")
387
+ parse_response
388
+ end
389
+
390
+ # get strategy list
391
+ #
392
+ def show_strat
393
+ exec_cmd("SHOW STRAT")
394
+ parse_response
395
+ end
396
+
397
+ # get information on database
398
+ #
399
+ def show_info(db)
400
+ exec_cmd('SHOW INFO %s' % db)
401
+ parse_response
402
+ end
403
+
404
+ # get server information
405
+ #
406
+ def show_server
407
+ exec_cmd("SHOW SERVER")
408
+ parse_response
409
+ end
410
+
411
+ # request server STATUS information
412
+ #
413
+ def status
414
+ exec_cmd('STATUS')
415
+ @message
416
+ end
417
+
418
+ # request server-side HELP
419
+ #
420
+ def help
421
+ exec_cmd('HELP')
422
+ parse_response
423
+ end
424
+
425
+ # send CLIENT information
426
+ #
427
+ def client(info)
428
+ exec_cmd('CLIENT %s' % info)
429
+ end
430
+
431
+ # AUTHorise user
432
+ #
433
+ def auth(user, secret)
434
+ auth = MD5::new(@msgid + secret).hexdigest
435
+ exec_cmd('AUTH %s %s' % [ user, auth ])
436
+ end
437
+
438
+ end