webri 1.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c4bc8110feecac22d65e1e47e5fda7dc5315ea7dd4f1d4ab67c62d30af6bb8cb
4
+ data.tar.gz: 9574bb0c08d78ffd32a6627d0c19ecf0f81e7f7ba0303d64c0b6e92e93f2395f
5
+ SHA512:
6
+ metadata.gz: c7b52fa6deb5b9b2029d70ff7ea2b226b2734aa39a2cd6aeb8dce1e7ee2f3e6a687321997beea7b9d958a11cf3b8017d149bcd8dee82a5a98e645619be50db48
7
+ data.tar.gz: 1942e35d5aca012c2c8843cdf222502e787226ee5834b10d88409d0a4ccde8178c874a79a52d38c0bf36325a01ca5dcfec4ff6188360493ba2d2f3b5cd42e9f6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-11-28
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ https://github.com/BurdetteLamar/webri/issues.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 BurdetteLamar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,456 @@
1
+ # WebRI
2
+
3
+ WebRI has a command-line utility, `webri`, for displaying Ruby online documentation.
4
+
5
+ It is in some ways similar to [Ruby's RI utility](https://ruby.github.io/rdoc/RI_md.html),
6
+ but differs mainly in that:
7
+
8
+ - **RI:** displays text-only documentation the the user's command window.
9
+ - **WebRI:** opens documentation web pages
10
+ from [Ruby official on-line documentation](https://docs.ruby-lang.org/en)
11
+ in the user's default web browser.
12
+
13
+ WebRI displays documentation for:
14
+
15
+ - A **class** or **module**: opens its web page.
16
+ - A **method**: opens the web page for its class/module _scrolled to the method's documentation_.
17
+ - A Ruby **file**: opens a free-standing web page.
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ webri [options]
23
+ ```
24
+
25
+ `webri` is an interactive program;
26
+ when invoked, it prints its prompt:
27
+
28
+ ```
29
+ $ webri
30
+ webri>
31
+ ```
32
+
33
+ To exit, type `exit`:
34
+
35
+ ```bash
36
+ $ webri
37
+ webri> exit
38
+ $
39
+ ```
40
+
41
+ At the prompt, you can type:
42
+
43
+ - The name of a [class or module][1].
44
+ - The name of a [singleton method][2].
45
+ - The name of an [instance method][3].
46
+ - The name of a [Ruby file][4].
47
+ - An abbreviation of any of the above.
48
+ - One of the [special names][5] `@help` or `@readme`.
49
+
50
+ ### Class or Module
51
+
52
+ For a `name` beginning with a capital letter,
53
+ WebRI finds the names of classes and modules beginning with that name.
54
+
55
+ When exactly one such class/module name is found:
56
+
57
+ - If `name` is the exact name of a class/module, opens its page:
58
+
59
+ ```
60
+ webri> Array
61
+ Found one class/module name starting with 'Array'
62
+ Array (Array.html)
63
+ Opening web page https://docs.ruby-lang.org/en/3.4/Array.html.
64
+ ```
65
+
66
+ - If `name` is the start of one class/module, offers to open its page:
67
+
68
+ ```
69
+ webri> Arr
70
+ Found one class/module name starting with 'Arr'
71
+ Array (Array.html)
72
+ Open page Array.html? (y or n): y
73
+ Opening web page https://docs.ruby-lang.org/en/3.4/Array.html.
74
+ ```
75
+
76
+ When multiple such class/module names are found, offers to list the found names:
77
+
78
+ ```
79
+ webri> Ar
80
+ Found 2 class/module names starting with 'Ar'.
81
+ Show 2 class/module names?' (y or n): y
82
+ 0: ArgumentError (ArgumentError.html)
83
+ 1: Array (Array.html)
84
+ Type a number to choose, or Return to skip: 0
85
+ Opening web page https://docs.ruby-lang.org/en/3.4/ArgumentError.html.
86
+ ```
87
+
88
+
89
+ When no such class/module name is found, offers to list all class/module names:
90
+
91
+ ```
92
+ webri> Nosuch
93
+ Found no class/module name starting with 'Nosuch'.
94
+ Show 1364 class/module names? (y or n): n
95
+ ```
96
+
97
+ ### Singleton Method
98
+
99
+ For a `name` beginning with `::`,
100
+ WebRI finds the names of singleton methods beginning
101
+ with that name.
102
+
103
+ When exactly one such singleton method name is found:
104
+
105
+ - If `name` is the exact name of one singleton method, opens its class/module page at that method:
106
+
107
+ ```
108
+ webri> ::zcat
109
+ Found one singleton method name starting with '::zcat'
110
+ ::zcat
111
+ Opening web page https://docs.ruby-lang.org/en/3.4/Zlib/GzipReader.html at method ::zcat.
112
+
113
+ ```
114
+
115
+ - If `name` is the start of the found name, offers to open its page:
116
+
117
+ ```
118
+ webri> ::zca
119
+ Found one singleton method name starting with '::zca'
120
+ ::zcat
121
+ Open page Zlib/GzipReader.html at method ::zcat? (y or n): y
122
+ Opening web page https://docs.ruby-lang.org/en/3.4/Zlib/GzipReader.html at method ::zcat.
123
+ ```
124
+
125
+ When multiple such singleton method names are found offer to list the found names:
126
+
127
+ ```
128
+ webri> ::z
129
+ Found 5 singleton method names starting with '::z'.
130
+ Show 5 names?' (y or n): y
131
+ 0: ::zcat (in Zlib::GzipReader)
132
+ 1: ::zero? (in File)
133
+ 2: ::zip? (in RDoc::Parser)
134
+ 3: ::zlib_version (in Zlib)
135
+ 4: ::zone_offset (in Time)
136
+ Type a number to choose, or Return to skip: 3
137
+ Opening web page https://docs.ruby-lang.org/en/3.4/Zlib.html at method ::zlib_version.
138
+
139
+ ```
140
+
141
+ When no such singleton method name is found, offers to list all singleton method names:
142
+
143
+ ```
144
+ webri> ::nosuch
145
+ Found no singleton method name starting with '::nosuch'.
146
+ Show names of all 2288 singleton methods? (y or n): n
147
+ ```
148
+
149
+ ### Instance Method
150
+
151
+ For a `name` beginning with `#`,
152
+ WebRI finds the names of instance methods beginning
153
+ with that name.
154
+
155
+ When exactly one such instance method name is found:
156
+
157
+ - If `name` is the exact name of one instance method, opens its class/module page at that method:
158
+
159
+ ```
160
+ webri> #yield_self
161
+ Found one instance method name starting with '#yield_self'
162
+ #yield_self
163
+ Opening web page https://docs.ruby-lang.org/en/3.4/Kernel.html at method #yield_self.
164
+ ```
165
+
166
+ - If `name` is the start of the found name, offers to open its page:
167
+
168
+ ```
169
+ webri> #yield_s
170
+ Found one instance method name starting with '#yield_s'
171
+ #yield_self
172
+ Open page Kernel.html at method #yield_self? (y or n): y
173
+ Opening web page https://docs.ruby-lang.org/en/3.4/Kernel.html at method #yield_self.
174
+ ```
175
+
176
+ When multiple such instance method names are found offer to list the found names:
177
+
178
+ ```
179
+ webri> #yield
180
+ Found 4 instance method names starting with '#yield'.
181
+ Show 4 names?' (y or n): y
182
+ 0: #yield (in Proc)
183
+ 1: #yield_node (in Prism::DSL)
184
+ 2: #yield_self (in Kernel)
185
+ 3: #yields_directive (in RDoc::MarkupReference)
186
+ Type a number to choose, or Return to skip: 0
187
+ Opening web page https://docs.ruby-lang.org/en/3.4/Proc.html at method #yield.
188
+ ```
189
+
190
+ When no such instance method name is found, offers to list all instance method names:
191
+
192
+ ```
193
+ webri>
194
+ webri> #nosuch
195
+ Found no instance method name starting with '#nosuch'.
196
+ Show names of all 10370 instance methods? (y or n): n
197
+ ```
198
+
199
+ ### Ruby 'File'
200
+
201
+ For a name beginning with `ruby:`,
202
+ finds the names of ruby files beginning
203
+ with that name.
204
+
205
+ When exactly one such file name is found:
206
+
207
+ - If the name is the exact name of the found name, opens its page:
208
+
209
+ ```
210
+ webri> ruby:operators
211
+ Found one file name starting with 'operators'
212
+ operators (syntax/operators_rdoc.html)
213
+ ```
214
+
215
+ - If `name` is the start of the found name, offers to open its page:
216
+
217
+ ```
218
+ webri> ruby:opera
219
+ Found one file name starting with 'opera'
220
+ operators (syntax/operators_rdoc.html)
221
+ Open page syntax/operators_rdoc.html? (y or n): y
222
+ Opening web page https://docs.ruby-lang.org/en/3.4/syntax/operators_rdoc.html.
223
+
224
+ ```
225
+
226
+ When multiple such file names are found offer to list the found names:
227
+
228
+ ```
229
+ webri> ruby:o
230
+ Found 4 file names starting with 'o'.
231
+ Show 4 names?' (y or n): y
232
+ 0: operators (syntax/operators_rdoc.html)
233
+ 1: option_dump (ruby/option_dump_md.html)
234
+ 2: option_params (optparse/option_params_rdoc.html)
235
+ 3: options (ruby/options_md.html)
236
+ Type a number to choose, or Return to skip: 2
237
+
238
+ ```
239
+
240
+ When no such file name is found, offers to list all file names:
241
+
242
+ ```
243
+ webri> ruby:nosuch
244
+ Found no file name starting with 'nosuch'.
245
+ Show names of all 83 files? (y or n): y
246
+ 0: COPYING (COPYING.html)
247
+ 1: COPYING.ja (COPYING_ja.html)
248
+ 2: LEGAL (LEGAL.html)
249
+ 3: NEWS (NEWS_md.html)
250
+ 4: NEWS-1.8.7 (NEWS/NEWS-1_8_7.html)
251
+ 5: NEWS-1.9.1 (NEWS/NEWS-1_9_1.html)
252
+ 6: NEWS-1.9.2 (NEWS/NEWS-1_9_2.html)
253
+ 7: NEWS-1.9.3 (NEWS/NEWS-1_9_3.html)
254
+ 8: NEWS-2.0.0 (NEWS/NEWS-2_0_0.html)
255
+ 9: NEWS-2.1.0 (NEWS/NEWS-2_1_0.html)
256
+ 10: NEWS-2.2.0 (NEWS/NEWS-2_2_0.html)
257
+ 11: NEWS-2.3.0 (NEWS/NEWS-2_3_0.html)
258
+ 12: NEWS-2.4.0 (NEWS/NEWS-2_4_0.html)
259
+ 13: NEWS-2.5.0 (NEWS/NEWS-2_5_0.html)
260
+ 14: NEWS-2.6.0 (NEWS/NEWS-2_6_0.html)
261
+ 15: NEWS-2.7.0 (NEWS/NEWS-2_7_0.html)
262
+ 16: NEWS-3.0.0 (NEWS/NEWS-3_0_0_md.html)
263
+ 17: NEWS-3.1.0 (NEWS/NEWS-3_1_0_md.html)
264
+ 18: NEWS-3.2.0 (NEWS/NEWS-3_2_0_md.html)
265
+ 19: NEWS-3.3.0 (NEWS/NEWS-3_3_0_md.html)
266
+ 20: README (README_md.html)
267
+ 21: README.ja (README_ja_md.html)
268
+ 22: argument_converters (optparse/argument_converters_rdoc.html)
269
+ 23: assignment (syntax/assignment_rdoc.html)
270
+ 24: bsearch (bsearch_rdoc.html)
271
+ 25: bug_triaging (bug_triaging_rdoc.html)
272
+ 26: building_ruby (contributing/building_ruby_md.html)
273
+ 27: calendars (date/calendars_rdoc.html)
274
+ 28: calling_methods (syntax/calling_methods_rdoc.html)
275
+ 29: case_mapping (case_mapping_rdoc.html)
276
+ 30: character_selectors (character_selectors_rdoc.html)
277
+ 31: command_injection (command_injection_rdoc.html)
278
+ 32: comments (syntax/comments_rdoc.html)
279
+ 33: contributing (contributing_md.html)
280
+ 34: control_expressions (syntax/control_expressions_rdoc.html)
281
+ 35: creates_option (optparse/creates_option_rdoc.html)
282
+ 36: dig_methods (dig_methods_rdoc.html)
283
+ 37: distribution (distribution_md.html)
284
+ 38: documentation_guide (contributing/documentation_guide_md.html)
285
+ 39: dtrace_probes (dtrace_probes_rdoc.html)
286
+ 40: encodings (encodings_rdoc.html)
287
+ 41: exceptions (exceptions_md.html)
288
+ 42: exceptions (syntax/exceptions_rdoc.html)
289
+ 43: extension (extension_rdoc.html)
290
+ 44: extension.ja (extension_ja_rdoc.html)
291
+ 45: fiber (fiber_md.html)
292
+ 46: format_specifications (format_specifications_rdoc.html)
293
+ 47: globals (globals_rdoc.html)
294
+ 48: glossary (contributing/glossary_md.html)
295
+ 49: implicit_conversion (implicit_conversion_rdoc.html)
296
+ 50: index (index_md.html)
297
+ 51: keywords (syntax/keywords_rdoc.html)
298
+ 52: literals (syntax/literals_rdoc.html)
299
+ 53: maintainers (maintainers_md.html)
300
+ 54: making_changes_to_ruby (contributing/making_changes_to_ruby_md.html)
301
+ 55: making_changes_to_stdlibs (contributing/making_changes_to_stdlibs_md.html)
302
+ 56: marshal (marshal_rdoc.html)
303
+ 57: memory_view (memory_view_md.html)
304
+ 58: methods (regexp/methods_rdoc.html)
305
+ 59: methods (syntax/methods_rdoc.html)
306
+ 60: miscellaneous (syntax/miscellaneous_rdoc.html)
307
+ 61: modules_and_classes (syntax/modules_and_classes_rdoc.html)
308
+ 62: operators (syntax/operators_rdoc.html)
309
+ 63: option_dump (ruby/option_dump_md.html)
310
+ 64: option_params (optparse/option_params_rdoc.html)
311
+ 65: options (ruby/options_md.html)
312
+ 66: packed_data (packed_data_rdoc.html)
313
+ 67: pattern_matching (syntax/pattern_matching_rdoc.html)
314
+ 68: precedence (syntax/precedence_rdoc.html)
315
+ 69: ractor (ractor_md.html)
316
+ 70: refinements (syntax/refinements_rdoc.html)
317
+ 71: reporting_issues (contributing/reporting_issues_md.html)
318
+ 72: rjit (rjit/rjit_md.html)
319
+ 73: security (security_rdoc.html)
320
+ 74: signals (signals_rdoc.html)
321
+ 75: standard_library (standard_library_md.html)
322
+ 76: strftime_formatting (strftime_formatting_rdoc.html)
323
+ 77: syntax (syntax_rdoc.html)
324
+ 78: testing_ruby (contributing/testing_ruby_md.html)
325
+ 79: tutorial (optparse/tutorial_rdoc.html)
326
+ 80: unicode_properties (regexp/unicode_properties_rdoc.html)
327
+ 81: windows (windows_md.html)
328
+ 82: yjit (yjit/yjit_md.html)
329
+ Type a number to choose, or Return to skip: 80
330
+ Opening web page https://docs.ruby-lang.org/en/3.4/regexp/unicode_properties_rdoc.html.
331
+ ```
332
+
333
+ ### Special Names
334
+
335
+ To display the WebRI help text, use the special name `@help`:
336
+
337
+ ```
338
+ webri> @help
339
+ Showing help.
340
+ webri is a console application for displaying Ruby online HTML documentation.
341
+ Documentation pages are opened in the default web browser.
342
+
343
+ Usage: webri [options]
344
+
345
+ For more information, see https://github.com/BurdetteLamar/webri/blob/main/README.md.
346
+
347
+ Options:
348
+ -i, --info Prints information about webri.
349
+ -r, --release=RELEASE Sets the Ruby release to document.
350
+ -n, --noop Does not actually open web pages.
351
+ -h, --help Prints this help.
352
+ -v, --version Prints the version of webri.
353
+ ```
354
+
355
+ To open the WebRI README page, use the special name `@readme`:
356
+
357
+ ```
358
+ webri> @readme
359
+ Opening web page https://github.com/BurdetteLamar/webri/blob/main/README.md.
360
+ ```
361
+
362
+ ### Options
363
+
364
+ Option `--info` prints information about WebRI,
365
+ including the documentation release to be used (`3.4` in this example),
366
+ then exits:
367
+
368
+ ```
369
+ $ webri --info
370
+ Ruby documentation release: '3.4'
371
+ Ruby documentation URL: 'https://docs.ruby-lang.org/en/3.4/table_of_contents.html'
372
+ Executable to open page: 'start'
373
+ Names:
374
+ 1364 class names
375
+ 1175 singleton_method names
376
+ 4407 instance_method names
377
+ 81 file names
378
+ ```
379
+
380
+ Option `--release` sets the release of the documentation to be used.
381
+ The collections of names will vary among releases:
382
+
383
+ ```
384
+ $ webri --release=3.2 --info
385
+ Ruby documentation release: '3.2'
386
+ Ruby documentation URL: 'https://docs.ruby-lang.org/en/3.2/table_of_contents.html'
387
+ Executable to open page: 'start'
388
+ Names:
389
+ 1262 class names
390
+ 1301 singleton_method names
391
+ 4397 instance_method names
392
+ 73 file names
393
+ $ webri --release=3.3 --info
394
+ Ruby documentation release: '3.3'
395
+ Ruby documentation URL: 'https://docs.ruby-lang.org/en/3.3/table_of_contents.html'
396
+ Executable to open page: 'start'
397
+ Names:
398
+ 1469 class names
399
+ 1270 singleton_method names
400
+ 4638 instance_method names
401
+ 77 file names
402
+ ```
403
+
404
+ Issues a message if the given release is unknown:
405
+
406
+ ```
407
+ $ webri --release foo
408
+ Unknown documentation release: foo
409
+ Master release: master
410
+ Supported releases: 3.4, 3.3, 3.2
411
+ Unsupported releases: 3.1, 3.0
412
+ ```
413
+
414
+ Option `--noop` suppresses the actual opening of a web page,
415
+ instead reporting the relevant command:
416
+
417
+ ```
418
+ $ webri --noop Array
419
+ Found one class/module name starting with 'Array'
420
+ Array (Array.html)
421
+ Opening web page https://docs.ruby-lang.org/en/3.4/Array.html.
422
+ Command: 'start https://docs.ruby-lang.org/en/3.4/Array.html'
423
+ ```
424
+
425
+ Option `--help` prints the WebRI help text.
426
+
427
+ Option `--version` prints the WebRI version.
428
+
429
+ ## Installation
430
+
431
+ To install the gem:
432
+
433
+ ```
434
+ $ gem install webri
435
+ ```
436
+
437
+ ## Bugs and Issues
438
+
439
+ Bug reports and comments are welcome at https://github.com/BurdetteLamar/webri/issues.
440
+
441
+ ## License
442
+
443
+ The gem is available as open source under the terms
444
+ of the [MIT License](https://opensource.org/licenses/MIT).
445
+
446
+ ## Code of Conduct
447
+
448
+ Everyone interacting in the Webri project's codebases,
449
+ issue trackers, chat rooms and mailing lists is expected
450
+ to follow the [code of conduct](https://github.com/BurdetteLamar/webri/blob/master/CODE_OF_CONDUCT.md).
451
+
452
+ [1]: rdoc-ref:README.md@Class+or+Module
453
+ [2]: rdoc-ref:README.md@Singleton+Method
454
+ [3]: rdoc-ref:README.md@Instance+Method
455
+ [4]: rdoc-ref:README.md@Ruby+File
456
+ [5]: rdoc-ref:README.md@Special+Names
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ task default: :test
data/bin/webri ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # A console application to display Ruby HTML documentation.
4
+
5
+ require 'optparse'
6
+ require_relative '../lib/webri/version'
7
+ require_relative '../lib/webri'
8
+
9
+ options = {}
10
+
11
+ parser = OptionParser.new
12
+
13
+ parser.version = WebRI::VERSION
14
+ parser.banner = <<-BANNER
15
+ webri is a console application for displaying Ruby online HTML documentation.
16
+ Documentation pages are opened in the default web browser.
17
+
18
+ Usage: #{parser.program_name} [options]
19
+
20
+ For more information, see https://github.com/BurdetteLamar/webri/blob/main/README.md.
21
+
22
+ BANNER
23
+
24
+ parser.separator('Options:')
25
+ parser.on('-i', '--info', 'Prints information about webri.') do
26
+ options[:info] = true
27
+ end
28
+ parser.on('-r=RELEASE', '--release=RELEASE', 'Sets the Ruby release to document.') do |value|
29
+ options[:release] = value
30
+ end
31
+ parser.on('-n', '--noop', 'Does not actually open web pages.') do |value|
32
+ options[:noop] = true
33
+ end
34
+ parser.on('-h', '--help', 'Prints this help.') do
35
+ puts parser
36
+ exit
37
+ end
38
+ parser.on('-v', '--version', 'Prints the version of webri.') do
39
+ puts WebRI::VERSION
40
+ exit
41
+ end
42
+
43
+ parser.parse!
44
+
45
+ unless ARGV.empty?
46
+ $stderr.puts "Argument error: No arguments allowed."
47
+ $stderr.puts ''
48
+ $stdout.puts parser.help
49
+ exit
50
+ end
51
+
52
+ WebRI.new(options)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class WebRI
4
+ VERSION = "1.0.1"
5
+ end
data/lib/webri.rb ADDED
@@ -0,0 +1,589 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rbconfig'
4
+ require 'open-uri'
5
+ require 'rexml'
6
+ require 'cgi'
7
+
8
+ # TODO: Use reline.
9
+ #
10
+ # TODO: Subroutinize.
11
+ # TODO: Make initialization faster.
12
+
13
+ # TODO: Build test names from ruby-lang.org (not webri).
14
+ #
15
+ # TODO: Choose dynamically the test names (rather than fixed)?
16
+ # TODO: Test methods with trailing special chars, and with all special chars
17
+ # TODO: Test on Linux.
18
+ # TODO: Test all releases.
19
+ # TODO: Test all pages(?).
20
+
21
+ # TODO: Make it work for naked method ('parse') or dotted method ('.parse').
22
+
23
+ # TODO: Support pager.
24
+
25
+ # TODO: Support .webrirc.
26
+ # TODO: Make it save options to .webrirc.
27
+ # TODO: Make it show .webrirc.
28
+
29
+ # A class to display Ruby online HTML documentation.
30
+ class WebRI
31
+
32
+ # Site of the official documentation.
33
+ DocSite = 'https://docs.ruby-lang.org/en/'
34
+
35
+ # Get the info from the Ruby doc site's table of contents
36
+ # and build our @index_for_type.
37
+ def initialize(options = {})
38
+ capture_options(options)
39
+ set_doc_release
40
+ get_toc_html
41
+ build_indexes
42
+ print_info if @info
43
+ while true
44
+ $stdout.write('webri> ')
45
+ $stdout.flush
46
+ response = $stdin.gets.chomp
47
+ exit if response == 'exit'
48
+ next if response.empty?
49
+ if response.split(' ').size > 1
50
+ puts "One name at a time, please."
51
+ next
52
+ end
53
+ show(response)
54
+ end
55
+ end
56
+
57
+ def set_doc_release
58
+ supported_releases = []
59
+ unsupported_releases = []
60
+ master_release = nil
61
+ io = URI.open('https://docs.ruby-lang.org/en/')
62
+ lines = io.readlines
63
+ lines.each do |line|
64
+ next unless line.match(/<a/)
65
+ doc = REXML::Document.new(line)
66
+ _, release, end_of_support = doc.root.text.split(' ')
67
+ break if release.start_with?('2')
68
+ if end_of_support
69
+ unsupported_releases.push(release)
70
+ elsif release == 'master'
71
+ master_release = release
72
+ else
73
+ supported_releases.push(release)
74
+ end
75
+ end
76
+ all_releases = [master_release] + supported_releases + unsupported_releases
77
+ if @doc_release
78
+ unless all_releases.include?(@doc_release)
79
+ puts "Unknown documentation release: #{@doc_release}"
80
+ puts "Available releases: #{all_releases.join(' ')}"
81
+ exit
82
+ end
83
+ else
84
+ a = RUBY_VERSION.split('.')
85
+ @doc_release ||= a[0..1].join('.')
86
+ end
87
+ end
88
+
89
+ def print_info
90
+ puts "Ruby documentation release: #{@doc_release}"
91
+ puts "Ruby documentation URL: #{@toc_url}"
92
+ puts "Executable to open page: #{opener_name}"
93
+ puts "Names:"
94
+ @index_for_type.each_pair do |type, items|
95
+ puts format(" %5d %s names", items.count, type)
96
+ end
97
+ exit
98
+ end
99
+
100
+ def build_indexes
101
+ # Index for each type of entry.
102
+ # Each index has a hash; key is name, value is array of URIs.
103
+ @index_for_type = {
104
+ class: {}, # Has both classes and modules.
105
+ singleton_method: {},
106
+ instance_method: {},
107
+ file: {},
108
+ }
109
+ # Iterate over the lines of the TOC page.
110
+ lines = @toc_html.split("\n")
111
+ i = 0
112
+ while i < lines.count
113
+ item_line = lines[i]
114
+ i += 1
115
+ next unless item_line.match('<li class="(\w+)"')
116
+ class_attr_value = $1 # Save for later.
117
+ # We have a pair of lines such as:
118
+ # <li class="file">
119
+ # <a href="COPYING.html">COPYING</a>
120
+ anchor_line = lines[i] # Second line of pair.
121
+ # Consume anchor_line.
122
+ i += 1
123
+ # We capture variables thus:
124
+ # - +type+ is the value of attribute 'class'.
125
+ # - +path+ is the value of attribute 'href'.
126
+ # - +full_name+ is the HTML text.
127
+ type = class_attr_value
128
+ _, path, rest = anchor_line.split('"')
129
+ full_name = rest.split(/<|>/)[1]
130
+ full_name = CGI.unescapeHTML(full_name)
131
+ case type
132
+ when 'class', 'module'
133
+ index = @index_for_type[:class]
134
+ if index.include?(full_name)
135
+ entry = index[full_name]
136
+ else
137
+ entry = ClassEntry.new(full_name)
138
+ index[full_name] = entry
139
+ end
140
+ entry.paths.push(path) unless entry.paths.include?(path)
141
+ when 'file'
142
+ index = @index_for_type[:file]
143
+ if index.include?(full_name)
144
+ entry = index[full_name]
145
+ else
146
+ entry = FileEntry.new(full_name)
147
+ index[full_name] = entry
148
+ end
149
+ entry.paths.push(path) unless entry.paths.include?(path)
150
+ when 'method'
151
+ case anchor_line
152
+ when /method-c-/
153
+ index = @index_for_type[:singleton_method]
154
+ if index.include?(full_name)
155
+ entry = index[full_name]
156
+ else
157
+ entry = SingletonMethodEntry.new(full_name)
158
+ index[full_name] = entry
159
+ end
160
+ entry.paths.push(path) unless entry.paths.include?(path)
161
+ when /method-i-/
162
+ index = @index_for_type[:instance_method]
163
+ if index.include?(full_name)
164
+ entry = index[full_name]
165
+ else
166
+ entry = InstanceMethodEntry.new(full_name)
167
+ index[full_name] = entry
168
+ end
169
+ entry.paths.push(path) unless entry.paths.include?(path)
170
+ else
171
+ fail anchor_line
172
+ end
173
+ else
174
+ fail class_attr_val
175
+ end
176
+ end
177
+ end
178
+
179
+ def capture_options(options)
180
+ @noop = options[:noop]
181
+ @info = options[:info]
182
+ @doc_release = options[:release]
183
+ end
184
+
185
+ def get_toc_html
186
+ # Construct the doc release; e.g., '3.4'.
187
+ # Get the doc table of contents as a temp file.
188
+ @toc_url = DocSite + @doc_release + '/table_of_contents.html'
189
+ begin
190
+ toc_file = URI.open(@toc_url)
191
+ @toc_html = toc_file.read
192
+ rescue Socket::ResolutionError => x
193
+ message = "#{x.class}: #{x.message}\nPossibly not connected to internet."
194
+ $stderr.puts(message)
195
+ exit
196
+ end
197
+ end
198
+
199
+ class Entry
200
+
201
+ attr_accessor :full_name, :paths
202
+
203
+ def initialize(full_name)
204
+ self.full_name = full_name
205
+ self.paths = []
206
+ end
207
+
208
+ # Return hash of choice strings for entries.
209
+ def self.choices(entries)
210
+ choices = {}
211
+ entries.each_pair do |name, entry|
212
+ entry.paths.each do |path|
213
+ choice = self.choice(name, path)
214
+ choices[choice] = path
215
+ end
216
+ end
217
+ Hash[choices.sort]
218
+ end
219
+
220
+ def self.uri(path)
221
+ URI.parse(path)
222
+ end
223
+
224
+ # Return the full name from a choice string.
225
+ def self.full_name_for_choice(choice)
226
+ choice.split(' ').first.sub(/:$/, '')
227
+ end
228
+
229
+ end
230
+
231
+ class ClassEntry < Entry
232
+
233
+ # Return a choice for a path.
234
+ def self.choice(name, path)
235
+ "#{name} (#{path})"
236
+ end
237
+
238
+ end
239
+
240
+ class FileEntry < Entry
241
+
242
+ # Return a choice for a path.
243
+ def self.choice(name, path)
244
+ "#{name} (#{path})"
245
+ end
246
+
247
+ end
248
+
249
+ class SingletonMethodEntry < Entry
250
+
251
+ # Return a choice string for a path.
252
+ def self.choice(full_name, path)
253
+ class_name, _ = path.split('.html#method-c-')
254
+ class_name.gsub!('/', '::')
255
+ "#{full_name} (in #{class_name})"
256
+ end
257
+
258
+ end
259
+
260
+ class InstanceMethodEntry < Entry
261
+
262
+ # Return a choice string for a path.
263
+ def self.choice(full_name, path)
264
+ class_name, _ = path.split('.html#method-i-')
265
+ class_name.gsub!('/', '::')
266
+ "#{full_name} (in #{class_name})"
267
+ end
268
+
269
+ end
270
+
271
+ # Show a page of Ruby documentation.
272
+ def show(name)
273
+ # Figure out what's asked for.
274
+ case
275
+ when name.match(/^[A-Z]/)
276
+ show_class(name, @index_for_type[:class])
277
+ when %w[fatal fata fat fa f].include?(name)
278
+ show_class(name, @index_for_type[:class])
279
+ when name.start_with?('ruby:')
280
+ show_file(name, @index_for_type[:file])
281
+ when name.start_with?('::')
282
+ show_singleton_method(name, @index_for_type[:singleton_method])
283
+ when name.start_with?('#')
284
+ show_instance_method(name, @index_for_type[:instance_method])
285
+ when name == '@help'
286
+ show_help
287
+ when name == '@readme'
288
+ open_readme
289
+ # when name.start_with?('.')
290
+ # show_method(name, @index_for_type[:singleton_method], @index_for_type[:instance_method])
291
+ # when name.match(/^[a-z]/)
292
+ # show_method(name, @index_for_type[:singleton_method], @index_for_type[:instance_method])
293
+ else
294
+ puts "No documentation available for name '#{name}'."
295
+ end
296
+ end
297
+
298
+ # Show class.
299
+ def show_class(name, class_index)
300
+ all_entries = @index_for_type[:class]
301
+ all_choices = ClassEntry.choices(all_entries)
302
+ # Find entries whose names that start with name.
303
+ selected_entries = all_entries.select do |key, value|
304
+ key.start_with?(name)
305
+ end
306
+ # Find paths for selected_choices
307
+ selected_paths = []
308
+ selected_entries.each_pair do |name, entry|
309
+ entry.paths.each do |path|
310
+ selected_paths.push(path)
311
+ end
312
+ end
313
+ case selected_paths.size
314
+ when 1
315
+ selected_choices = ClassEntry.choices(selected_entries)
316
+ choice = selected_choices.keys.first
317
+ path = selected_choices.values.first
318
+ puts "Found one class/module name starting with '#{name}'\n #{choice}"
319
+ full_name = ClassEntry.full_name_for_choice(choice)
320
+ if name != full_name
321
+ message = "Open page #{path}?"
322
+ return unless get_boolean_answer(message)
323
+ end
324
+ path
325
+ when 0
326
+ puts "Found no class/module name starting with '#{name}'."
327
+ message = "Show #{all_choices.size} class/module names?"
328
+ return unless get_boolean_answer(message)
329
+ choice_index = get_choice(all_choices.keys)
330
+ return if choice_index.nil?
331
+ path = all_choices[choice_index]
332
+ else
333
+ selected_choices = ClassEntry.choices(selected_entries)
334
+ puts "Found #{selected_choices.size} class/module names starting with '#{name}'."
335
+ message = "Show #{selected_choices.size} class/module names?'"
336
+ return unless get_boolean_answer(message)
337
+ key = get_choice(selected_choices.keys)
338
+ return if key.nil?
339
+ path = selected_choices[key]
340
+ end
341
+ uri = Entry.uri(path)
342
+ open_page(name, uri)
343
+ end
344
+
345
+ # Show file.
346
+ def show_file(name, file_index)
347
+ # Target page is a free-standing page such as 'COPYING'.
348
+ name = name.sub(/^ruby:/, '') # Discard leading 'ruby:'
349
+ all_entries = @index_for_type[:file]
350
+ all_choices = FileEntry.choices(all_entries)
351
+ # Find entries whose names that start with name.
352
+ selected_entries = all_entries.select do |key, value|
353
+ key.start_with?(name)
354
+ end
355
+ # Find paths for selected_choices
356
+ selected_paths = []
357
+ selected_entries.each_pair do |name, entry|
358
+ entry.paths.each do |path|
359
+ selected_paths.push(path)
360
+ end
361
+ end
362
+ case selected_paths.size
363
+ when 1
364
+ selected_choices = FileEntry.choices(selected_entries)
365
+ choice = selected_choices.keys.first
366
+ path = selected_choices.values.first
367
+ puts "Found one file name starting with '#{name}'\n #{choice}"
368
+ full_name = FileEntry.full_name_for_choice(choice)
369
+ if name != full_name
370
+ message = "Open page #{path}?"
371
+ return unless get_boolean_answer(message)
372
+ end
373
+ path
374
+ when 0
375
+ puts "Found no file name starting with '#{name}'."
376
+ message = "Show names of all #{all_choices.size} files?"
377
+ return unless get_boolean_answer(message)
378
+ key = get_choice(all_choices.keys)
379
+ return if key.nil?
380
+ path = all_choices[key]
381
+ else
382
+ selected_choices = FileEntry.choices(selected_entries)
383
+ puts "Found #{selected_choices.size} file names starting with '#{name}'."
384
+ message = "Show #{selected_choices.size} names?'"
385
+ return unless get_boolean_answer(message)
386
+ key = get_choice(selected_choices.keys)
387
+ return if key.nil?
388
+ path = selected_choices[key]
389
+ end
390
+ uri = Entry.uri(path)
391
+ open_page(name, uri)
392
+ end
393
+
394
+ # Show singleton method.
395
+ def show_singleton_method(name, singleton_method_index)
396
+ # Target page is a singleton method such as ::new.
397
+ all_entries = @index_for_type[:singleton_method]
398
+ all_choices = SingletonMethodEntry.choices(all_entries)
399
+ # Find entries whose names that start with name.
400
+ selected_entries = all_entries.select do |key, value|
401
+ key.start_with?(name)
402
+ end
403
+ # Find paths for selected_choices
404
+ selected_paths = []
405
+ selected_entries.each_pair do |name, entry|
406
+ entry.paths.each do |path|
407
+ selected_paths.push(path)
408
+ end
409
+ end
410
+ selected_choices = SingletonMethodEntry.choices(selected_entries)
411
+ case selected_paths.size
412
+ when 1
413
+ full_name = selected_entries.keys.first
414
+ path = selected_choices.values.first
415
+ puts "Found one singleton method name starting with '#{name}'\n #{full_name}"
416
+ if name != full_name
417
+ uri = URI.parse(path)
418
+ message = "Open page #{uri.path} at method #{full_name}?"
419
+ return unless get_boolean_answer(message)
420
+ end
421
+ path
422
+ when 0
423
+ puts "Found no singleton method name starting with '#{name}'."
424
+ message = "Show names of all #{all_choices.size} singleton methods?"
425
+ return unless get_boolean_answer(message)
426
+ choice = get_choice(all_choices.keys)
427
+ return if choice.nil?
428
+ full_name = SingletonMethodEntry.full_name_for_choice(choice)
429
+ path = all_choices[choice]
430
+ else
431
+ puts "Found #{selected_paths.size} singleton method names starting with '#{name}'."
432
+ message = "Show #{selected_paths.size} names?'"
433
+ return unless get_boolean_answer(message)
434
+ choice = get_choice(selected_choices.keys)
435
+ return if choice.nil?
436
+ full_name = SingletonMethodEntry.full_name_for_choice(choice)
437
+ path = all_choices[choice]
438
+ end
439
+ uri = Entry.uri(path)
440
+ open_page(full_name, uri)
441
+ end
442
+
443
+ # Show instance method.
444
+ def show_instance_method(name, instance_method_index)
445
+ # Target page is an instance method such as #to_s.
446
+ all_entries = @index_for_type[:instance_method]
447
+ all_choices = InstanceMethodEntry.choices(all_entries)
448
+ # Find entries whose names that start with name.
449
+ selected_entries = all_entries.select do |key, value|
450
+ key.start_with?(name)
451
+ end
452
+ # Find paths for selected_choices
453
+ selected_paths = []
454
+ selected_entries.each_pair do |name, entry|
455
+ entry.paths.each do |path|
456
+ selected_paths.push(path)
457
+ end
458
+ end
459
+ selected_choices = InstanceMethodEntry.choices(selected_entries)
460
+ case selected_paths.size
461
+ when 1
462
+ full_name = selected_entries.keys.first
463
+ path = selected_choices.values.first
464
+ puts "Found one instance method name starting with '#{name}'\n #{full_name}"
465
+ if name != full_name
466
+ uri = URI.parse(path)
467
+ message = "Open page #{uri.path} at method #{full_name}?"
468
+ return unless get_boolean_answer(message)
469
+ end
470
+ path
471
+ when 0
472
+ puts "Found no instance method name starting with '#{name}'."
473
+ message = "Show names of all #{all_choices.size} instance methods?"
474
+ return unless get_boolean_answer(message)
475
+ choice = get_choice(all_choices.keys)
476
+ return if choice.nil?
477
+ path = all_choices[choice]
478
+ full_name = InstanceMethodEntry.full_name_for_choice(choice)
479
+ else
480
+ puts "Found #{selected_paths.size} instance method names starting with '#{name}'."
481
+ message = "Show #{selected_paths.size} names?'"
482
+ return unless get_boolean_answer(message)
483
+ choice = get_choice(selected_choices.keys)
484
+ return if choice.nil?
485
+ path = all_choices[choice]
486
+ full_name = InstanceMethodEntry.full_name_for_choice(choice)
487
+ end
488
+ uri = Entry.uri(path)
489
+ open_page(full_name, uri)
490
+ end
491
+
492
+ def show_help
493
+ puts 'Showing help.'
494
+ puts `ruby bin/webri --help`
495
+ end
496
+
497
+ def show_readme
498
+ open_readme
499
+ end
500
+
501
+ # Present choices; return choice.
502
+ def get_choice(choices)
503
+ index = nil
504
+ range = (0..choices.size - 1)
505
+ until range.include?(index)
506
+ choices.each_with_index do |choice, i|
507
+ s = "%6d" % i
508
+ puts " #{s}: #{choice}"
509
+ end
510
+ while true
511
+ print "Type a number to choose, or Return to skip: "
512
+ $stdout.flush
513
+ response = $stdin.gets
514
+ case response
515
+ when /(\d+)/
516
+ return choices[$1.to_i]
517
+ when "\n"
518
+ return nil
519
+ else
520
+
521
+ end
522
+ end
523
+ end
524
+ end
525
+
526
+ # Present question; return answer.
527
+ def get_boolean_answer(question)
528
+ print "#{question} (y or n): "
529
+ $stdout.flush
530
+ $stdin.gets.match(/y/i) ? true : false
531
+ end
532
+
533
+ def open_readme
534
+ url = 'https://github.com/BurdetteLamar/webri/blob/main/README.md'
535
+ uri = URI.parse(url)
536
+ open_uri('README',uri)
537
+ end
538
+
539
+ # Open URL in browser.
540
+ def open_page(name, target_uri)
541
+ uri = URI.parse(File.join(DocSite, @doc_release, target_uri.to_s))
542
+ open_uri(name, uri)
543
+ end
544
+
545
+ def os_type
546
+ case RbConfig::CONFIG['host_os']
547
+ when /linux|bsd|arch/
548
+ :linux
549
+ when /darwin/
550
+ :macos
551
+ when /mswin|windows|32/
552
+ :windows
553
+ else
554
+ :unknown
555
+ end
556
+ end
557
+
558
+ def opener_name
559
+ case os_type
560
+ when :linux
561
+ 'xdg-open'
562
+ when :windows
563
+ 'start'
564
+ when :macos
565
+ 'open'
566
+ else
567
+ message = "No opener name for #{os_type}"
568
+ raise RuntimeError(message)
569
+ end
570
+ end
571
+
572
+ def open_uri(name, target_uri)
573
+ full_url = target_uri.to_s
574
+ url, fragment = full_url.split('#')
575
+ message = "Opening web page #{url}"
576
+ if fragment
577
+ message += " at method #{name}"
578
+ end
579
+ message += '.'
580
+ puts message
581
+ command = "#{opener_name} #{full_url}"
582
+ if @noop
583
+ puts "Command: '#{command}'"
584
+ else
585
+ system(command)
586
+ end
587
+ end
588
+
589
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webri
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - BurdetteLamar
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-06-13 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Command-line utility for displaying Ruby online documentation
13
+ email:
14
+ - burdettelamar@yahoo.com
15
+ executables:
16
+ - webri
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - CODE_OF_CONDUCT.md
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - bin/webri
26
+ - lib/webri.rb
27
+ - lib/webri/version.rb
28
+ homepage: https://github.com/BurdetteLamar/webri
29
+ licenses:
30
+ - MIT
31
+ metadata:
32
+ homepage_uri: https://github.com/BurdetteLamar/webri
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.6.2
48
+ specification_version: 4
49
+ summary: RI for web pages
50
+ test_files: []