open 0.1.30 → 0.2.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +110 -31
- data/bin/open +1 -1
- data/bin/open_in_browser +1 -1
- data/doc/README.gen +72 -8
- data/doc/deprecated_code/deprecated_code.md +26 -0
- data/img/open_logo.png +0 -0
- data/lib/open/base/base.rb +265 -128
- data/lib/open/books/README.md +8 -0
- data/lib/open/books/books.rb +100 -0
- data/lib/open/constants/constants.rb +86 -8
- data/lib/open/in_browser/in_browser.rb +501 -319
- data/lib/open/in_editor/in_editor.rb +367 -162
- data/lib/open/last/last.rb +14 -12
- data/lib/open/last_url/last_url.rb +4 -3
- data/lib/open/nano_open/nano_open.rb +30 -5
- data/lib/open/{open.rb → open/open.rb} +596 -654
- data/lib/open/project/project.rb +3 -2
- data/lib/open/requires/failsafe_require_of_beautiful_url.rb +9 -0
- data/lib/open/requires/require_the_project.rb +2 -2
- data/lib/open/requires/require_yaml.rb +13 -0
- data/lib/open/these_files/these_files.rb +1 -1
- data/lib/open/toplevel_methods/browser.rb +71 -0
- data/lib/open/toplevel_methods/delay.rb +23 -0
- data/lib/open/toplevel_methods/e.rb +14 -0
- data/lib/open/toplevel_methods/editor.rb +41 -0
- data/lib/open/toplevel_methods/host_os.rb +25 -0
- data/lib/open/toplevel_methods/is_on_roebe.rb +16 -0
- data/lib/open/toplevel_methods/is_on_windows.rb +26 -0
- data/lib/open/toplevel_methods/misc.rb +50 -0
- data/lib/open/version/version.rb +2 -2
- data/lib/open/with_delay/with_delay.rb +10 -11
- data/open.gemspec +3 -3
- data/test/testing_open.rb +1 -1
- data/test/testing_open_in_browser.rb +16 -0
- data/test/testing_open_via_launchy.rb +3 -0
- data/test/testing_shortcuts.rb +3 -0
- metadata +25 -9
- data/lib/open/toplevel_code/toplevel_code.rb +0 -189
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46f99c41258eff76c7e6d43b1c53e78f2d9d503e59ac8387abe831ea4c159206
|
4
|
+
data.tar.gz: 765ac4f8073bbc3c68f919eda72cd6e9a3fa469adcfd462ac9c17763eb1d6fe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10621d3c4b9879013bca469b93e524972969b5fbfeee7895d9a68bc9f3a4d65a2ad384a934a931b56aa4b16f9eb4ebf92b8e491d3a41214e7540156dbd84ee57
|
7
|
+
data.tar.gz: 6e6377846dc2eb9d970b240f7bf6352076622436a1db54ba4c5e24d666081ac99e963cc5c6f180c032e9456ec38302e3c3b1db8008470474d90f805e824428b5
|
data/README.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
[![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/open.svg)](https://badge.fury.io/rb/open)
|
4
4
|
|
5
|
-
This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">
|
5
|
+
This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">30.01.2024</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">16:21:47</span> o'clock.
|
6
|
+
|
7
|
+
<img src="https://i.imgur.com/JFJ1PGz.png" style="margin: 0.5em">
|
6
8
|
|
7
9
|
## History of this project
|
8
10
|
|
@@ -41,22 +43,24 @@ introduction to how the project is layout.
|
|
41
43
|
|
42
44
|
Most of the constants will reside under **open/constants/constants.rb**.
|
43
45
|
|
44
|
-
Toplevel-methods can be found under **open/
|
46
|
+
Toplevel-methods can be found under **open/toplevel_methods/** for the
|
45
47
|
most part. This may be ignored by some classes if they add
|
46
|
-
toplevel-methods; in that case the toplevel may be modified by
|
47
|
-
a class, and **can subsequently be found in that .rb file where
|
48
|
-
class is defined** (or the directory, if this class is split up
|
48
|
+
toplevel-methods directly; in that case the toplevel may be modified by
|
49
|
+
such a class, and **can subsequently be found in that .rb file where
|
50
|
+
the class is defined** (or the directory, if this class is split up
|
49
51
|
into several different .rb files).
|
50
52
|
|
51
53
|
So, for instance, **class Open::Browser** may define a toplevel
|
52
|
-
method called **Open.in_browser()**.
|
53
|
-
|
54
|
+
method called **Open.in_browser()**.
|
55
|
+
|
56
|
+
You can also **grep** (on Linux) for where the source code resides
|
57
|
+
specifically, of course.
|
54
58
|
|
55
59
|
## Optional dependencies in this project
|
56
60
|
|
57
61
|
Officially there are no hardcoded dependencies in this project.
|
58
62
|
|
59
|
-
However had, you are encouraged to install various gems, such as:
|
63
|
+
However had, you are <b>encouraged</b> to install various gems, such as:
|
60
64
|
|
61
65
|
- colours
|
62
66
|
- convert_global_env
|
@@ -68,7 +72,49 @@ These may enhance the ruby code used in this project.
|
|
68
72
|
I highly recommend to install the **colours** gem, but ultimately
|
69
73
|
the code in this project is written deliberately in a manner to
|
70
74
|
make all these add-ons optional, so this is entirely up to you
|
71
|
-
in the end.
|
75
|
+
in the end. (If you find some part of the project that makes
|
76
|
+
any of these external dependencies mandatory rather than optional,
|
77
|
+
consider it a bug. Feel free to report it, to see it changed -
|
78
|
+
but I should have covered all these cases already, so it should
|
79
|
+
be highly unlikely that you can find **external** dependencies
|
80
|
+
that are not guarded via a begin/rescue clause.)
|
81
|
+
|
82
|
+
## The various open-related activities in this gem
|
83
|
+
|
84
|
+
You can "open" many different things: a local file or a remote
|
85
|
+
URL (in the browser). When it comes to opening local files we
|
86
|
+
can also distinguish whether you want to open in your primary
|
87
|
+
editor, open in a a video-player, open a .pdf file in a pdf-viewer
|
88
|
+
and so on and so forth, so we want to be able to distinguish
|
89
|
+
between these <b>different use cases</b>.
|
90
|
+
|
91
|
+
The primary activity for this gem is to open a remote URL. In
|
92
|
+
fact: this was the reason why this gem was initially created.
|
93
|
+
I wanted to be able to open all registered URLs from another
|
94
|
+
gem, called BeautifulUrl, in the web browser. Then I can, for
|
95
|
+
instance, do this:
|
96
|
+
|
97
|
+
rf local_sitemap
|
98
|
+
|
99
|
+
And the local sitemap (a .cgi or .sinatra fila) will be
|
100
|
+
opened in my browser (thorium usually), on the commandline.
|
101
|
+
|
102
|
+
This allows me to quickly navigate to all my local web-pages
|
103
|
+
and I can use them as-is. For instance, I had in the past
|
104
|
+
used one webpage that would inform me about upcoming
|
105
|
+
exams at universities. It is quite convenient to view this
|
106
|
+
in the browser. So, this is the functionality covered by
|
107
|
+
Open.in_browser() specifically.
|
108
|
+
|
109
|
+
The next use case, the secondary use case, is Open.in_editor().
|
110
|
+
Here I wanted to be able to open a local file in my favourite
|
111
|
+
editor - a modified variant of the <b>bluefish</b> editor.
|
112
|
+
|
113
|
+
<b>Every other open-related functionality</b>, such as opening a
|
114
|
+
local .pdf file, is bundled into the "<b>remaining</b>" use cases
|
115
|
+
herein. In other words: these other use cases are not as relevant
|
116
|
+
and important as the two other use cases described above
|
117
|
+
this paragraph.
|
72
118
|
|
73
119
|
## class Open::InEditor
|
74
120
|
|
@@ -139,6 +185,14 @@ is, simply issue <b>the following command</b>:
|
|
139
185
|
|
140
186
|
open --browser?
|
141
187
|
|
188
|
+
At the least on my home system, if a certain environment
|
189
|
+
variable is set to 1, class Open::InBrowser will
|
190
|
+
prepend a localhost string. If this is unwanted
|
191
|
+
then <b>--do-not-use-localhost</b> can be used to
|
192
|
+
avoid that. For most users of this project this is
|
193
|
+
irrelevant, as there is a check anyway for that
|
194
|
+
environment variable.
|
195
|
+
|
142
196
|
## class Open::LastUrl
|
143
197
|
|
144
198
|
This small class can be used to specifically open the content
|
@@ -266,8 +320,18 @@ own use cases. I needed this functionality to batch-open a
|
|
266
320
|
"project", based on individual files, so this functionality
|
267
321
|
was added in <b>March 2023</b>.
|
268
322
|
|
323
|
+
## Handling .pdf files
|
324
|
+
|
325
|
+
You can call this method to find out which PDF viewer will be
|
326
|
+
used:
|
327
|
+
|
328
|
+
Open.pdf_viewer?
|
329
|
+
|
330
|
+
I recommend to install the gem <b>pdf_paradise</b> - it handles
|
331
|
+
all my .pdf related needs.
|
269
332
|
|
270
|
-
|
333
|
+
|
334
|
+
## Contact information and mandatory 2FA (no longer) coming up in 2022 / 2023
|
271
335
|
|
272
336
|
If your creative mind has ideas and specific suggestions to make this gem
|
273
337
|
more useful in general, feel free to drop me an email at any time, via:
|
@@ -277,36 +341,51 @@ more useful in general, feel free to drop me an email at any time, via:
|
|
277
341
|
Before that email I used an email account at Google gmail, but in **2021** I
|
278
342
|
decided to slowly abandon gmail, for various reasons. In order to limit the
|
279
343
|
explanation here, allow me to just briefly state that I do not feel as if I
|
280
|
-
want to promote any Google service anymore when the user becomes the
|
281
|
-
product (such as via data collection by upstream services
|
282
|
-
a hugely flawed business model
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
In
|
288
|
-
|
289
|
-
|
344
|
+
want to promote any Google service anymore when the user becomes the end
|
345
|
+
product (such as via data collection by upstream services, including other
|
346
|
+
proxy-services). My feeling is that this is a hugely flawed business model
|
347
|
+
to begin with, and I no longer wish to support this in any way, even if
|
348
|
+
only indirectly so, such as by using services of companies that try to
|
349
|
+
promote this flawed model.
|
350
|
+
|
351
|
+
In regards to responding to emails: please keep in mind that responding
|
352
|
+
may take some time, depending on the amount of work I may have at that
|
353
|
+
moment. So it is not that emails are ignored; it is more that I have not
|
354
|
+
(yet) found the time to read and reply. This means there may be a delay
|
355
|
+
of days, weeks and in some instances also months. There is, unfortunately,
|
356
|
+
not much I can do when I need to prioritise my time investment, but I try
|
357
|
+
to consider <b>all</b> feedback as an opportunity to improve my projects
|
358
|
+
nonetheless.
|
359
|
+
|
360
|
+
In <b>2022</b> rubygems.org decided to make 2FA mandatory for every
|
361
|
+
gem owner eventually:
|
362
|
+
|
363
|
+
see
|
290
364
|
https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
|
291
365
|
|
292
366
|
Mandatory 2FA will eventually be extended to all rubygems.org developers and
|
293
367
|
maintainers. As I can not use 2FA, for reasons I will skip explaining here,
|
294
|
-
this means that my projects will eventually be
|
295
|
-
|
368
|
+
this means that my projects will eventually be removed, as I no longer
|
369
|
+
have any control over my projects hosted on rubygems.org (because I
|
370
|
+
can not use 2FA).
|
371
|
+
|
296
372
|
At that point, I no longer have any control what is done to my projects
|
297
|
-
since
|
298
|
-
|
299
|
-
that was not the case several years ago
|
373
|
+
since whoever is controlling the gems ecosystem took away our control
|
374
|
+
here. I am not sure at which point ruby became corporate-controlled -
|
375
|
+
that was not the case several years ago, so something has
|
376
|
+
changed.
|
300
377
|
|
301
378
|
Ruby also only allows 2FA users to participate on the issue tracker these
|
302
379
|
days:
|
303
380
|
|
304
381
|
https://bugs.ruby-lang.org/issues/18800
|
305
382
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
383
|
+
But this has been reverted some months ago, so it is no longer applicable.
|
384
|
+
Suffice to say that I do not think that we should only be allowed to
|
385
|
+
interact on the world wide web when some 'authority' authenticated us,
|
386
|
+
such as via mandatory 2FA, so I hope this won't come back again.
|
387
|
+
|
388
|
+
Fighting spam is a noble goal, but when it also means you lock out
|
389
|
+
real human people then this is definitely NOT a good situation
|
390
|
+
to be had.
|
312
391
|
|
data/bin/open
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
# Encoding: UTF-8
|
3
3
|
# frozen_string_literal: true
|
4
4
|
# =========================================================================== #
|
5
|
-
require 'open/open.rb' # Only require the minimal code for this.
|
5
|
+
require 'open/open/open.rb' # Only require the minimal code for this.
|
6
6
|
|
7
7
|
Open::Open.new(ARGV)
|
data/bin/open_in_browser
CHANGED
data/doc/README.gen
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
DEFAULT_HEADER
|
2
2
|
|
3
|
+
<img src="https://i.imgur.com/JFJ1PGz.png" style="margin: 0.5em">
|
4
|
+
|
3
5
|
## History of this project
|
4
6
|
|
5
7
|
In the past I used separate projects / gems, such as **OpenInEditor** or
|
@@ -37,22 +39,24 @@ introduction to how the project is layout.
|
|
37
39
|
|
38
40
|
Most of the constants will reside under **open/constants/constants.rb**.
|
39
41
|
|
40
|
-
Toplevel-methods can be found under **open/
|
42
|
+
Toplevel-methods can be found under **open/toplevel_methods/** for the
|
41
43
|
most part. This may be ignored by some classes if they add
|
42
|
-
toplevel-methods; in that case the toplevel may be modified by
|
43
|
-
a class, and **can subsequently be found in that .rb file where
|
44
|
-
class is defined** (or the directory, if this class is split up
|
44
|
+
toplevel-methods directly; in that case the toplevel may be modified by
|
45
|
+
such a class, and **can subsequently be found in that .rb file where
|
46
|
+
the class is defined** (or the directory, if this class is split up
|
45
47
|
into several different .rb files).
|
46
48
|
|
47
49
|
So, for instance, **class Open::Browser** may define a toplevel
|
48
|
-
method called **Open.in_browser()**.
|
49
|
-
|
50
|
+
method called **Open.in_browser()**.
|
51
|
+
|
52
|
+
You can also **grep** (on Linux) for where the source code resides
|
53
|
+
specifically, of course.
|
50
54
|
|
51
55
|
## Optional dependencies in this project
|
52
56
|
|
53
57
|
Officially there are no hardcoded dependencies in this project.
|
54
58
|
|
55
|
-
However had, you are encouraged to install various gems, such as:
|
59
|
+
However had, you are <b>encouraged</b> to install various gems, such as:
|
56
60
|
|
57
61
|
- colours
|
58
62
|
- convert_global_env
|
@@ -64,7 +68,49 @@ These may enhance the ruby code used in this project.
|
|
64
68
|
I highly recommend to install the **colours** gem, but ultimately
|
65
69
|
the code in this project is written deliberately in a manner to
|
66
70
|
make all these add-ons optional, so this is entirely up to you
|
67
|
-
in the end.
|
71
|
+
in the end. (If you find some part of the project that makes
|
72
|
+
any of these external dependencies mandatory rather than optional,
|
73
|
+
consider it a bug. Feel free to report it, to see it changed -
|
74
|
+
but I should have covered all these cases already, so it should
|
75
|
+
be highly unlikely that you can find **external** dependencies
|
76
|
+
that are not guarded via a begin/rescue clause.)
|
77
|
+
|
78
|
+
## The various open-related activities in this gem
|
79
|
+
|
80
|
+
You can "open" many different things: a local file or a remote
|
81
|
+
URL (in the browser). When it comes to opening local files we
|
82
|
+
can also distinguish whether you want to open in your primary
|
83
|
+
editor, open in a a video-player, open a .pdf file in a pdf-viewer
|
84
|
+
and so on and so forth, so we want to be able to distinguish
|
85
|
+
between these <b>different use cases</b>.
|
86
|
+
|
87
|
+
The primary activity for this gem is to open a remote URL. In
|
88
|
+
fact: this was the reason why this gem was initially created.
|
89
|
+
I wanted to be able to open all registered URLs from another
|
90
|
+
gem, called BeautifulUrl, in the web browser. Then I can, for
|
91
|
+
instance, do this:
|
92
|
+
|
93
|
+
rf local_sitemap
|
94
|
+
|
95
|
+
And the local sitemap (a .cgi or .sinatra fila) will be
|
96
|
+
opened in my browser (thorium usually), on the commandline.
|
97
|
+
|
98
|
+
This allows me to quickly navigate to all my local web-pages
|
99
|
+
and I can use them as-is. For instance, I had in the past
|
100
|
+
used one webpage that would inform me about upcoming
|
101
|
+
exams at universities. It is quite convenient to view this
|
102
|
+
in the browser. So, this is the functionality covered by
|
103
|
+
Open.in_browser() specifically.
|
104
|
+
|
105
|
+
The next use case, the secondary use case, is Open.in_editor().
|
106
|
+
Here I wanted to be able to open a local file in my favourite
|
107
|
+
editor - a modified variant of the <b>bluefish</b> editor.
|
108
|
+
|
109
|
+
<b>Every other open-related functionality</b>, such as opening a
|
110
|
+
local .pdf file, is bundled into the "<b>remaining</b>" use cases
|
111
|
+
herein. In other words: these other use cases are not as relevant
|
112
|
+
and important as the two other use cases described above
|
113
|
+
this paragraph.
|
68
114
|
|
69
115
|
## class Open::InEditor
|
70
116
|
|
@@ -135,6 +181,14 @@ is, simply issue <b>the following command</b>:
|
|
135
181
|
|
136
182
|
open --browser?
|
137
183
|
|
184
|
+
At the least on my home system, if a certain environment
|
185
|
+
variable is set to 1, class Open::InBrowser will
|
186
|
+
prepend a localhost string. If this is unwanted
|
187
|
+
then <b>--do-not-use-localhost</b> can be used to
|
188
|
+
avoid that. For most users of this project this is
|
189
|
+
irrelevant, as there is a check anyway for that
|
190
|
+
environment variable.
|
191
|
+
|
138
192
|
## class Open::LastUrl
|
139
193
|
|
140
194
|
This small class can be used to specifically open the content
|
@@ -262,4 +316,14 @@ own use cases. I needed this functionality to batch-open a
|
|
262
316
|
"project", based on individual files, so this functionality
|
263
317
|
was added in <b>March 2023</b>.
|
264
318
|
|
319
|
+
## Handling .pdf files
|
320
|
+
|
321
|
+
You can call this method to find out which PDF viewer will be
|
322
|
+
used:
|
323
|
+
|
324
|
+
Open.pdf_viewer?
|
325
|
+
|
326
|
+
I recommend to install the gem <b>pdf_paradise</b> - it handles
|
327
|
+
all my .pdf related needs.
|
328
|
+
|
265
329
|
ADD_CONTACT_INFORMATION
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Since as of June 2023, class Open::InBrowser
|
2
|
+
contained this code chunk:
|
3
|
+
|
4
|
+
if File.exist?(real_filename) and
|
5
|
+
!real_filename.start_with?('file://') and
|
6
|
+
!entry.include?('http://localhost/')
|
7
|
+
entry = entry.dup
|
8
|
+
entry.prepend('file://')
|
9
|
+
end
|
10
|
+
|
11
|
+
So we just prepended 'file://'. I do not think we need
|
12
|
+
this anymore, though.
|
13
|
+
|
14
|
+
Since as of June 2023, the following code was removed
|
15
|
+
as well:
|
16
|
+
|
17
|
+
if Object.const_defined? :Studium
|
18
|
+
possible_link = Studium.return_remote_homepage_of_this_lecture(entry)
|
19
|
+
if possible_link == entry
|
20
|
+
else
|
21
|
+
entry = possible_link
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
I believe we already handle this case, without needing
|
26
|
+
to re-check it again.
|
data/img/open_logo.png
ADDED
Binary file
|