sqlpostgres 1.2.4
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.
- data/Gemfile +8 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.md +23 -0
- data/README.rdoc +59 -0
- data/Rakefile +32 -0
- data/VERSION +1 -0
- data/doc/BUGS +2 -0
- data/doc/examples/README +6 -0
- data/doc/examples/connection.rb +16 -0
- data/doc/examples/connection_auto.rb +22 -0
- data/doc/examples/connection_ctor.rb +18 -0
- data/doc/examples/connection_default.rb +15 -0
- data/doc/examples/connection_exec.rb +18 -0
- data/doc/examples/connection_manual.rb +12 -0
- data/doc/examples/connection_wrapped_new.rb +13 -0
- data/doc/examples/connection_wrapped_open.rb +13 -0
- data/doc/examples/cursor.rb +38 -0
- data/doc/examples/include_module.rb +9 -0
- data/doc/examples/include_module2.rb +12 -0
- data/doc/examples/insert.rb +30 -0
- data/doc/examples/insert2.rb +36 -0
- data/doc/examples/insert_bytea.rb +16 -0
- data/doc/examples/insert_bytea_array.rb +17 -0
- data/doc/examples/insert_default_values.rb +16 -0
- data/doc/examples/insert_insert.rb +16 -0
- data/doc/examples/insert_insert_default.rb +16 -0
- data/doc/examples/insert_insert_select.rb +20 -0
- data/doc/examples/insert_select.rb +20 -0
- data/doc/examples/interval.rb +17 -0
- data/doc/examples/savepoint.rb +38 -0
- data/doc/examples/select.rb +33 -0
- data/doc/examples/select2.rb +36 -0
- data/doc/examples/select_cross_join.rb +18 -0
- data/doc/examples/select_distinct.rb +18 -0
- data/doc/examples/select_distinct_on +19 -0
- data/doc/examples/select_for_update.rb +18 -0
- data/doc/examples/select_from.rb +17 -0
- data/doc/examples/select_from_subselect.rb +20 -0
- data/doc/examples/select_group_by.rb +19 -0
- data/doc/examples/select_having.rb +20 -0
- data/doc/examples/select_join_on.rb +18 -0
- data/doc/examples/select_join_using.rb +18 -0
- data/doc/examples/select_limit.rb +19 -0
- data/doc/examples/select_natural_join.rb +18 -0
- data/doc/examples/select_offset.rb +19 -0
- data/doc/examples/select_order_by.rb +20 -0
- data/doc/examples/select_select.rb +30 -0
- data/doc/examples/select_select_alias.rb +30 -0
- data/doc/examples/select_select_expression.rb +31 -0
- data/doc/examples/select_select_literal.rb +24 -0
- data/doc/examples/select_union.rb +21 -0
- data/doc/examples/select_where_array.rb +18 -0
- data/doc/examples/select_where_in.rb +18 -0
- data/doc/examples/select_where_string.rb +18 -0
- data/doc/examples/simple.rb +34 -0
- data/doc/examples/transaction.rb +30 -0
- data/doc/examples/transaction_abort.rb +30 -0
- data/doc/examples/transaction_commit.rb +34 -0
- data/doc/examples/translate_substitute_values.rb +17 -0
- data/doc/examples/update.rb +32 -0
- data/doc/examples/update2.rb +44 -0
- data/doc/examples/update_only.rb +17 -0
- data/doc/examples/update_set.rb +17 -0
- data/doc/examples/update_set_array.rb +16 -0
- data/doc/examples/update_set_bytea.rb +16 -0
- data/doc/examples/update_set_expression.rb +16 -0
- data/doc/examples/update_set_subselect.rb +20 -0
- data/doc/examples/update_where.rb +17 -0
- data/doc/examples/use_prefix.rb +8 -0
- data/doc/examples/use_prefix2.rb +11 -0
- data/doc/index.html +31 -0
- data/doc/insertexamples.rb +9 -0
- data/doc/makemanual +4 -0
- data/doc/makerdoc +5 -0
- data/doc/manual.dbk +622 -0
- data/lib/sqlpostgres/Connection.rb +198 -0
- data/lib/sqlpostgres/Cursor.rb +157 -0
- data/lib/sqlpostgres/Delete.rb +67 -0
- data/lib/sqlpostgres/Exceptions.rb +15 -0
- data/lib/sqlpostgres/Insert.rb +279 -0
- data/lib/sqlpostgres/NullConnection.rb +22 -0
- data/lib/sqlpostgres/PgBit.rb +73 -0
- data/lib/sqlpostgres/PgBox.rb +37 -0
- data/lib/sqlpostgres/PgCidr.rb +21 -0
- data/lib/sqlpostgres/PgCircle.rb +75 -0
- data/lib/sqlpostgres/PgInet.rb +21 -0
- data/lib/sqlpostgres/PgInterval.rb +208 -0
- data/lib/sqlpostgres/PgLineSegment.rb +37 -0
- data/lib/sqlpostgres/PgMacAddr.rb +21 -0
- data/lib/sqlpostgres/PgPath.rb +64 -0
- data/lib/sqlpostgres/PgPoint.rb +65 -0
- data/lib/sqlpostgres/PgPolygon.rb +56 -0
- data/lib/sqlpostgres/PgTime.rb +77 -0
- data/lib/sqlpostgres/PgTimeWithTimeZone.rb +98 -0
- data/lib/sqlpostgres/PgTimestamp.rb +93 -0
- data/lib/sqlpostgres/PgTwoPoints.rb +54 -0
- data/lib/sqlpostgres/PgType.rb +34 -0
- data/lib/sqlpostgres/PgWrapper.rb +41 -0
- data/lib/sqlpostgres/Savepoint.rb +98 -0
- data/lib/sqlpostgres/Select.rb +855 -0
- data/lib/sqlpostgres/Transaction.rb +120 -0
- data/lib/sqlpostgres/Translate.rb +436 -0
- data/lib/sqlpostgres/Update.rb +188 -0
- data/lib/sqlpostgres.rb +67 -0
- data/test/Assert.rb +72 -0
- data/test/Connection.test.rb +246 -0
- data/test/Cursor.test.rb +190 -0
- data/test/Delete.test.rb +68 -0
- data/test/Insert.test.rb +123 -0
- data/test/MockPGconn.rb +62 -0
- data/test/NullConnection.test.rb +32 -0
- data/test/PgBit.test.rb +98 -0
- data/test/PgBox.test.rb +108 -0
- data/test/PgCidr.test.rb +61 -0
- data/test/PgCircle.test.rb +107 -0
- data/test/PgInet.test.rb +61 -0
- data/test/PgInterval.test.rb +180 -0
- data/test/PgLineSegment.test.rb +108 -0
- data/test/PgMacAddr.test.rb +61 -0
- data/test/PgPath.test.rb +106 -0
- data/test/PgPoint.test.rb +100 -0
- data/test/PgPolygon.test.rb +95 -0
- data/test/PgTime.test.rb +120 -0
- data/test/PgTimeWithTimeZone.test.rb +117 -0
- data/test/PgTimestamp.test.rb +134 -0
- data/test/RandomThings.rb +25 -0
- data/test/Savepoint.test.rb +286 -0
- data/test/Select.test.rb +930 -0
- data/test/Test.rb +62 -0
- data/test/TestConfig.rb +21 -0
- data/test/TestSetup.rb +13 -0
- data/test/TestUtil.rb +92 -0
- data/test/Transaction.test.rb +275 -0
- data/test/Translate.test.rb +354 -0
- data/test/Update.test.rb +227 -0
- data/test/roundtrip.test.rb +565 -0
- data/test/test +34 -0
- data/tools/exampleinserter/ExampleInserter.rb +177 -0
- data/tools/rdoc/ChangeLog +796 -0
- data/tools/rdoc/EXAMPLE.rb +48 -0
- data/tools/rdoc/MANIFEST +58 -0
- data/tools/rdoc/Makefile +27 -0
- data/tools/rdoc/NEW_FEATURES +226 -0
- data/tools/rdoc/README +390 -0
- data/tools/rdoc/ToDo +6 -0
- data/tools/rdoc/contrib/Index +6 -0
- data/tools/rdoc/contrib/xslfo/ChangeLog +181 -0
- data/tools/rdoc/contrib/xslfo/README +106 -0
- data/tools/rdoc/contrib/xslfo/TODO +10 -0
- data/tools/rdoc/contrib/xslfo/convert.xsl +151 -0
- data/tools/rdoc/contrib/xslfo/demo/README +21 -0
- data/tools/rdoc/contrib/xslfo/demo/rdocfo +99 -0
- data/tools/rdoc/contrib/xslfo/fcm.xsl +54 -0
- data/tools/rdoc/contrib/xslfo/files.xsl +62 -0
- data/tools/rdoc/contrib/xslfo/labeled-lists.xsl +66 -0
- data/tools/rdoc/contrib/xslfo/lists.xsl +44 -0
- data/tools/rdoc/contrib/xslfo/modules.xsl +152 -0
- data/tools/rdoc/contrib/xslfo/rdoc.xsl +75 -0
- data/tools/rdoc/contrib/xslfo/source.xsl +66 -0
- data/tools/rdoc/contrib/xslfo/styles.xsl +69 -0
- data/tools/rdoc/contrib/xslfo/tables.xsl +67 -0
- data/tools/rdoc/contrib/xslfo/utils.xsl +21 -0
- data/tools/rdoc/debian/changelog +33 -0
- data/tools/rdoc/debian/compat +1 -0
- data/tools/rdoc/debian/control +20 -0
- data/tools/rdoc/debian/copyright +10 -0
- data/tools/rdoc/debian/dirs +2 -0
- data/tools/rdoc/debian/docs +2 -0
- data/tools/rdoc/debian/rdoc.1 +252 -0
- data/tools/rdoc/debian/rdoc.manpages +1 -0
- data/tools/rdoc/debian/rdoc.pod +149 -0
- data/tools/rdoc/debian/rules +9 -0
- data/tools/rdoc/dot/dot.rb +255 -0
- data/tools/rdoc/etc/rdoc.dtd +203 -0
- data/tools/rdoc/install.rb +137 -0
- data/tools/rdoc/markup/install.rb +43 -0
- data/tools/rdoc/markup/sample/sample.rb +42 -0
- data/tools/rdoc/markup/simple_markup/fragments.rb +323 -0
- data/tools/rdoc/markup/simple_markup/inline.rb +348 -0
- data/tools/rdoc/markup/simple_markup/lines.rb +147 -0
- data/tools/rdoc/markup/simple_markup/preprocess.rb +68 -0
- data/tools/rdoc/markup/simple_markup/to_html.rb +281 -0
- data/tools/rdoc/markup/simple_markup.rb +474 -0
- data/tools/rdoc/markup/test/AllTests.rb +2 -0
- data/tools/rdoc/markup/test/TestInline.rb +151 -0
- data/tools/rdoc/markup/test/TestParse.rb +411 -0
- data/tools/rdoc/rdoc/code_objects.rb +536 -0
- data/tools/rdoc/rdoc/diagram.rb +331 -0
- data/tools/rdoc/rdoc/generators/chm_generator.rb +112 -0
- data/tools/rdoc/rdoc/generators/html_generator.rb +1268 -0
- data/tools/rdoc/rdoc/generators/template/chm/chm.rb +86 -0
- data/tools/rdoc/rdoc/generators/template/html/html.rb +705 -0
- data/tools/rdoc/rdoc/generators/template/html/kilmer.rb +377 -0
- data/tools/rdoc/rdoc/generators/template/xml/rdf.rb +110 -0
- data/tools/rdoc/rdoc/generators/template/xml/xml.rb +110 -0
- data/tools/rdoc/rdoc/generators/xml_generator.rb +130 -0
- data/tools/rdoc/rdoc/options.rb +451 -0
- data/tools/rdoc/rdoc/parsers/parse_c.rb +287 -0
- data/tools/rdoc/rdoc/parsers/parse_f95.rb +118 -0
- data/tools/rdoc/rdoc/parsers/parse_rb.rb +2311 -0
- data/tools/rdoc/rdoc/parsers/parse_simple.rb +37 -0
- data/tools/rdoc/rdoc/parsers/parserfactory.rb +75 -0
- data/tools/rdoc/rdoc/rdoc.rb +219 -0
- data/tools/rdoc/rdoc/template.rb +234 -0
- data/tools/rdoc/rdoc/tokenstream.rb +25 -0
- data/tools/rdoc/rdoc.rb +9 -0
- metadata +291 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
# We handle the parsing of options, and subsequently as a singleton
|
|
2
|
+
# object to be queried for option values
|
|
3
|
+
class Options
|
|
4
|
+
|
|
5
|
+
require 'singleton'
|
|
6
|
+
require 'getoptlong'
|
|
7
|
+
|
|
8
|
+
include Singleton
|
|
9
|
+
|
|
10
|
+
# files matching this pattern will be excluded
|
|
11
|
+
attr_accessor :exclude
|
|
12
|
+
|
|
13
|
+
# the name of the output directory
|
|
14
|
+
attr_accessor :op_dir
|
|
15
|
+
|
|
16
|
+
# the name to use for the output
|
|
17
|
+
attr_reader :op_name
|
|
18
|
+
|
|
19
|
+
# include private and protected methods in the
|
|
20
|
+
# output
|
|
21
|
+
attr_accessor :show_all
|
|
22
|
+
|
|
23
|
+
# name of the file, class or module to display in
|
|
24
|
+
# the initial index page (if not specified
|
|
25
|
+
# the first file we encounter is used)
|
|
26
|
+
attr_accessor :main_page
|
|
27
|
+
|
|
28
|
+
# Don't display progress as we process the files
|
|
29
|
+
attr_reader :quiet
|
|
30
|
+
|
|
31
|
+
# description of the output generator (set with the <tt>-fmt</tt>
|
|
32
|
+
# option
|
|
33
|
+
attr_accessor :generator
|
|
34
|
+
|
|
35
|
+
# and the list of files to be processed
|
|
36
|
+
attr_reader :files
|
|
37
|
+
|
|
38
|
+
# array of directories to search for files to satisfy an :include:
|
|
39
|
+
attr_reader :rdoc_include
|
|
40
|
+
|
|
41
|
+
# title to be used out the output
|
|
42
|
+
#attr_writer :title
|
|
43
|
+
|
|
44
|
+
# template to be used when generating output
|
|
45
|
+
attr_reader :template
|
|
46
|
+
|
|
47
|
+
# should diagrams be drawn
|
|
48
|
+
attr_reader :diagram
|
|
49
|
+
|
|
50
|
+
# should we draw fileboxes in diagrams
|
|
51
|
+
attr_reader :fileboxes
|
|
52
|
+
|
|
53
|
+
# include the '#' at the front of hyperlinked instance method names
|
|
54
|
+
attr_reader :show_hash
|
|
55
|
+
|
|
56
|
+
# image format for diagrams
|
|
57
|
+
attr_reader :image_format
|
|
58
|
+
|
|
59
|
+
# character-set
|
|
60
|
+
attr_reader :charset
|
|
61
|
+
|
|
62
|
+
# should source code be included inline, or displayed in a popup
|
|
63
|
+
attr_reader :inline_source
|
|
64
|
+
|
|
65
|
+
# should the output be placed into a single file
|
|
66
|
+
attr_reader :all_one_file
|
|
67
|
+
|
|
68
|
+
# the number of columns in a tab
|
|
69
|
+
attr_reader :tab_width
|
|
70
|
+
|
|
71
|
+
# include line numbers in the source listings
|
|
72
|
+
attr_reader :include_line_numbers
|
|
73
|
+
|
|
74
|
+
module OptionList
|
|
75
|
+
|
|
76
|
+
OPTION_LIST = [
|
|
77
|
+
[ "--all", "-a", nil,
|
|
78
|
+
"include all methods (not just public)\nin the output" ],
|
|
79
|
+
|
|
80
|
+
[ "--charset", "-c", "charset",
|
|
81
|
+
"specifies HTML character-set" ],
|
|
82
|
+
|
|
83
|
+
[ "--debug", "-D", nil,
|
|
84
|
+
"displays lots on internal stuff" ],
|
|
85
|
+
|
|
86
|
+
[ "--diagram", "-d", nil,
|
|
87
|
+
"Generate diagrams showing modules and classes.\n" +
|
|
88
|
+
"You need dot V1.8.6 or later to use the --diagram\n" +
|
|
89
|
+
"option correctly. Dot is available from\n"+
|
|
90
|
+
"http://www.research.att.com/sw/tools/graphviz/" ],
|
|
91
|
+
|
|
92
|
+
[ "--exclude", "-x", "pattern",
|
|
93
|
+
"do not process files or directories matching\n" +
|
|
94
|
+
"pattern. Files given explicitly on the command\n" +
|
|
95
|
+
"line will never be excluded." ],
|
|
96
|
+
|
|
97
|
+
[ "--fileboxes", "-F", nil,
|
|
98
|
+
"classes are put in boxes which represents\n" +
|
|
99
|
+
"files, where these classes reside. Classes\n" +
|
|
100
|
+
"shared between more than one file are\n" +
|
|
101
|
+
"shown with list of files that sharing them.\n" +
|
|
102
|
+
"Silently discarded if --diagram is not given\n" +
|
|
103
|
+
"Experimental." ],
|
|
104
|
+
|
|
105
|
+
[ "--fmt", "-f", "format name",
|
|
106
|
+
"set the output formatter (see below)" ],
|
|
107
|
+
|
|
108
|
+
[ "--help", "-h", nil,
|
|
109
|
+
"you're looking at it" ],
|
|
110
|
+
|
|
111
|
+
[ "--help-output", "-O", nil,
|
|
112
|
+
"explain the various output options" ],
|
|
113
|
+
|
|
114
|
+
[ "--image-format", "-I", "gif/png/jpg/jpeg",
|
|
115
|
+
"Sets output image format for diagrams. Can\n" +
|
|
116
|
+
"be png, gif, jpeg, jpg. If this option is\n" +
|
|
117
|
+
"omitted, png is used. Requires --diagram." ],
|
|
118
|
+
|
|
119
|
+
[ "--include", "-i", "dir[,dir...]",
|
|
120
|
+
"set (or add to) the list of directories\n" +
|
|
121
|
+
"to be searched when satisfying :include:\n" +
|
|
122
|
+
"requests. Can be used more than once." ],
|
|
123
|
+
|
|
124
|
+
[ "--inline-source", "-S", nil,
|
|
125
|
+
"Show method source code inline, rather\n" +
|
|
126
|
+
"than via a popup link" ],
|
|
127
|
+
|
|
128
|
+
[ "--line-numbers", "-N", nil,
|
|
129
|
+
"Include line numbers in the source code" ],
|
|
130
|
+
|
|
131
|
+
[ "--main", "-m", "name",
|
|
132
|
+
"'name' will be the initial page displayed" ],
|
|
133
|
+
|
|
134
|
+
[ "--one-file", "-1", nil,
|
|
135
|
+
"put all the output into a single file" ],
|
|
136
|
+
|
|
137
|
+
[ "--op", "-o", "dir",
|
|
138
|
+
"set the output directory" ],
|
|
139
|
+
|
|
140
|
+
[ "--opname", "-n", "name",
|
|
141
|
+
"Set the 'name' of the output. Has no\n" +
|
|
142
|
+
"effect for HTML." ],
|
|
143
|
+
|
|
144
|
+
[ "--quiet", "-q", nil,
|
|
145
|
+
"don't show progress as we parse" ],
|
|
146
|
+
|
|
147
|
+
[ "--show-hash", "-H", nil,
|
|
148
|
+
"A name of the form #name in a comment\n" +
|
|
149
|
+
"is a possible hyperlink to an instance\n" +
|
|
150
|
+
"method name. When displayed, the '#' is\n" +
|
|
151
|
+
"removed unless this option is specified" ],
|
|
152
|
+
|
|
153
|
+
[ "--tab-width", "-w", "n",
|
|
154
|
+
"Set the width of tab characters (default 8)"],
|
|
155
|
+
|
|
156
|
+
[ "--template", "-T", "template name",
|
|
157
|
+
"Set the template used when generating output" ],
|
|
158
|
+
|
|
159
|
+
[ "--title", "-t", "text",
|
|
160
|
+
"Set 'txt' as the title for the output" ],
|
|
161
|
+
|
|
162
|
+
[ "--version", "-v", nil,
|
|
163
|
+
"display RDoc's version" ],
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
def OptionList.options
|
|
167
|
+
OPTION_LIST.map do |long, short, arg,|
|
|
168
|
+
[ long,
|
|
169
|
+
short,
|
|
170
|
+
arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT
|
|
171
|
+
]
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def OptionList.strip_output(text)
|
|
177
|
+
text =~ /^\s+/
|
|
178
|
+
leading_spaces = $&
|
|
179
|
+
text.gsub!(/^#{leading_spaces}/, '')
|
|
180
|
+
$stdout.puts text
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
# Show an error and exit
|
|
185
|
+
|
|
186
|
+
def OptionList.error(msg)
|
|
187
|
+
$stderr.puts
|
|
188
|
+
$stderr.puts msg
|
|
189
|
+
$stderr.puts "\nFor help on options, try 'rdoc --help'\n\n"
|
|
190
|
+
exit 1
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Show usage and exit
|
|
194
|
+
|
|
195
|
+
def OptionList.usage(generator_names)
|
|
196
|
+
|
|
197
|
+
puts
|
|
198
|
+
puts(VERSION_STRING)
|
|
199
|
+
puts
|
|
200
|
+
|
|
201
|
+
name = File.basename($0)
|
|
202
|
+
OptionList.strip_output(<<-EOT)
|
|
203
|
+
Usage:
|
|
204
|
+
|
|
205
|
+
#{name} [options] [names...]
|
|
206
|
+
|
|
207
|
+
Files are parsed, and the information they contain
|
|
208
|
+
collected, before any output is produced. This allows cross
|
|
209
|
+
references between all files to be resolved. If a name is a
|
|
210
|
+
directory, it is traversed. If no names are specified, all
|
|
211
|
+
Ruby files in the current directory (and subdirectories) are
|
|
212
|
+
processed.
|
|
213
|
+
|
|
214
|
+
Options:
|
|
215
|
+
|
|
216
|
+
EOT
|
|
217
|
+
|
|
218
|
+
OPTION_LIST.each do |long, short, arg, desc|
|
|
219
|
+
opt = sprintf("%20s", "#{long}, #{short}")
|
|
220
|
+
oparg = sprintf("%-7s", arg)
|
|
221
|
+
print "#{opt} #{oparg}"
|
|
222
|
+
desc = desc.split("\n")
|
|
223
|
+
if arg.nil? || arg.length < 7
|
|
224
|
+
puts desc.shift
|
|
225
|
+
else
|
|
226
|
+
puts
|
|
227
|
+
end
|
|
228
|
+
desc.each do |line|
|
|
229
|
+
puts(" "*28 + line)
|
|
230
|
+
end
|
|
231
|
+
puts
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
puts "\nAvailable output formatters: " +
|
|
235
|
+
generator_names.sort.join(', ') + "\n\n"
|
|
236
|
+
|
|
237
|
+
puts "For information on where the output goes, use\n\n"
|
|
238
|
+
puts " rdoc --help-output\n\n"
|
|
239
|
+
|
|
240
|
+
exit 0
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def OptionList.help_output
|
|
244
|
+
OptionList.strip_output(<<-EOT)
|
|
245
|
+
How RDoc generates output depends on the output formatter being
|
|
246
|
+
used, and on the options you give.
|
|
247
|
+
|
|
248
|
+
- HTML output is normally produced into a number of separate files
|
|
249
|
+
(one per class, module, and file, along with various indices).
|
|
250
|
+
These files will appear in the directory given by the --op
|
|
251
|
+
option (doc/ by default).
|
|
252
|
+
|
|
253
|
+
- XML output by default is written to standard output. If a
|
|
254
|
+
--opname option is given, the output will instead be written
|
|
255
|
+
to a file with that name in the output directory.
|
|
256
|
+
|
|
257
|
+
- .chm files (Windows help files) are written in the --op directory.
|
|
258
|
+
If an --opname parameter is present, that name is used, otherwise
|
|
259
|
+
the file will be called rdoc.chm.
|
|
260
|
+
|
|
261
|
+
For information on other RDoc options, use "rdoc --help".
|
|
262
|
+
EOT
|
|
263
|
+
exit 0
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Parse command line options. We're passed a hash containing
|
|
268
|
+
# output generators, keyed by the generator name
|
|
269
|
+
|
|
270
|
+
def parse(argv, generators)
|
|
271
|
+
old_argv = ARGV.dup
|
|
272
|
+
begin
|
|
273
|
+
ARGV.replace(argv)
|
|
274
|
+
@op_dir = "doc"
|
|
275
|
+
@op_name = nil
|
|
276
|
+
@show_all = false
|
|
277
|
+
@main_page = nil
|
|
278
|
+
@exclude = nil
|
|
279
|
+
@quiet = false
|
|
280
|
+
@generator_name = 'html'
|
|
281
|
+
@generator = generators[@generator_name]
|
|
282
|
+
@rdoc_include = []
|
|
283
|
+
@title = nil
|
|
284
|
+
@template = nil
|
|
285
|
+
@diagram = false
|
|
286
|
+
@fileboxes = false
|
|
287
|
+
@show_hash = false
|
|
288
|
+
@image_format = 'png'
|
|
289
|
+
@inline_source = false
|
|
290
|
+
@all_one_file = false
|
|
291
|
+
@tab_width = 8
|
|
292
|
+
@include_line_numbers = false
|
|
293
|
+
|
|
294
|
+
@charset = case $KCODE
|
|
295
|
+
when /^S/i
|
|
296
|
+
'Shift_JIS'
|
|
297
|
+
when /^E/i
|
|
298
|
+
'EUC-JP'
|
|
299
|
+
else
|
|
300
|
+
'iso-8859-1'
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
go = GetoptLong.new(*OptionList.options)
|
|
304
|
+
go.quiet = true
|
|
305
|
+
|
|
306
|
+
go.each do |opt, arg|
|
|
307
|
+
case opt
|
|
308
|
+
when "--all" then @show_all = true
|
|
309
|
+
when "--debug" then $DEBUG = true
|
|
310
|
+
when "--main" then @main_page = arg
|
|
311
|
+
when "--op" then @op_dir = arg
|
|
312
|
+
when "--opname" then @op_name = arg
|
|
313
|
+
when "--quiet" then @quiet = true
|
|
314
|
+
when "--charset" then @charset = arg
|
|
315
|
+
when "--exclude" then @exclude = Regexp.new(arg)
|
|
316
|
+
when "--inline-source" then @inline_source = true
|
|
317
|
+
when "--one-file" then @all_one_file = true
|
|
318
|
+
when "--show-hash" then @show_hash = true
|
|
319
|
+
when "--template" then @template = arg
|
|
320
|
+
when "--title" then @title = arg
|
|
321
|
+
when "--line-numbers" then @include_line_numbers = true
|
|
322
|
+
|
|
323
|
+
when "--diagram"
|
|
324
|
+
check_diagram
|
|
325
|
+
@diagram = true
|
|
326
|
+
|
|
327
|
+
when "--fileboxes"
|
|
328
|
+
@fileboxes = true if @diagram
|
|
329
|
+
|
|
330
|
+
when "--fmt"
|
|
331
|
+
@generator_name = arg.downcase
|
|
332
|
+
@generator = generators[@generator_name]
|
|
333
|
+
if !@generator
|
|
334
|
+
OptionList.error("Invalid output formatter")
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
if @generator_name == "xml"
|
|
338
|
+
@all_one_file = true
|
|
339
|
+
@inline_source = true
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
when "--help"
|
|
343
|
+
OptionList.usage(generators.keys)
|
|
344
|
+
|
|
345
|
+
when "--help-output"
|
|
346
|
+
OptionList.help_output
|
|
347
|
+
|
|
348
|
+
when "--image-format"
|
|
349
|
+
if ['gif', 'png', 'jpeg', 'jpg'].include?(arg)
|
|
350
|
+
@image_format = arg
|
|
351
|
+
else
|
|
352
|
+
raise GetoptLong::InvalidOption.new("unknown image format: #{arg}")
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
when "--include"
|
|
356
|
+
@rdoc_include.concat arg.split(/\s*,\s*/)
|
|
357
|
+
|
|
358
|
+
when "--tab-width"
|
|
359
|
+
begin
|
|
360
|
+
@tab_width = Integer(arg)
|
|
361
|
+
rescue
|
|
362
|
+
$stderr.puts "Invalid tab width: '#{arg}'"
|
|
363
|
+
exit 1
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
when "--version"
|
|
367
|
+
puts VERSION_STRING
|
|
368
|
+
exit
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
@files = ARGV.dup
|
|
374
|
+
|
|
375
|
+
@rdoc_include << "." if @rdoc_include.empty?
|
|
376
|
+
|
|
377
|
+
check_files
|
|
378
|
+
|
|
379
|
+
# If no template was specified, use the default
|
|
380
|
+
# template for the output formatter
|
|
381
|
+
|
|
382
|
+
@template ||= @generator_name
|
|
383
|
+
|
|
384
|
+
rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
|
|
385
|
+
OptionList.error(error.message)
|
|
386
|
+
|
|
387
|
+
ensure
|
|
388
|
+
ARGV.replace(old_argv)
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def title
|
|
394
|
+
@title ||= "RDoc Documentation"
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
# Set the title, but only if not already set. This means that a title set from
|
|
398
|
+
# the command line trumps one set in a source file
|
|
399
|
+
|
|
400
|
+
def title=(string)
|
|
401
|
+
@title ||= string
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
private
|
|
406
|
+
|
|
407
|
+
# Check that the right version of 'dot' is available.
|
|
408
|
+
# Unfortuately this doesn't work correctly under Windows NT,
|
|
409
|
+
# so we'll bypass the test under Windows
|
|
410
|
+
|
|
411
|
+
def check_diagram
|
|
412
|
+
return if RUBY_PLATFORM =~ /win/
|
|
413
|
+
|
|
414
|
+
ok = false
|
|
415
|
+
ver = nil
|
|
416
|
+
IO.popen("dot -V 2>&1") do |io|
|
|
417
|
+
ver = io.read
|
|
418
|
+
if ver =~ /dot\s+version(?:\s+gviz)?\s+(\d+)\.(\d+)/
|
|
419
|
+
ok = ($1.to_i > 1) || ($1.to_i == 1 && $2.to_i >= 8)
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
unless ok
|
|
423
|
+
if ver =~ /^dot version/
|
|
424
|
+
$stderr.puts "Warning: You may need dot V1.8.6 or later to use\n",
|
|
425
|
+
"the --diagram option correctly. You have:\n\n ",
|
|
426
|
+
ver,
|
|
427
|
+
"\nDiagrams might have strange background colors.\n\n"
|
|
428
|
+
else
|
|
429
|
+
$stderr.puts "You need the 'dot' program to produce diagrams.",
|
|
430
|
+
"(see http://www.research.att.com/sw/tools/graphviz/)\n\n"
|
|
431
|
+
exit
|
|
432
|
+
end
|
|
433
|
+
# exit
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
# Check that the files on the command line exist
|
|
438
|
+
|
|
439
|
+
def check_files
|
|
440
|
+
@files.each do |f|
|
|
441
|
+
stat = File.stat f rescue error("File not found: #{f}")
|
|
442
|
+
error("File '#{f}' not readable") unless stat.readable?
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def error(str)
|
|
447
|
+
$stderr.puts str
|
|
448
|
+
exit(1)
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
end
|