open 0.1.30 → 0.2.13
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.
Potentially problematic release.
This version of open might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +73 -9
- 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 +262 -122
- data/lib/open/books/README.md +8 -0
- data/lib/open/books/books.rb +99 -0
- data/lib/open/constants/constants.rb +85 -8
- data/lib/open/in_browser/in_browser.rb +476 -304
- data/lib/open/in_editor/in_editor.rb +348 -155
- data/lib/open/last/last.rb +14 -12
- data/lib/open/nano_open/nano_open.rb +4 -3
- data/lib/open/{open.rb → open/open.rb} +597 -653
- 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 +9 -11
- data/open.gemspec +1 -1
- 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 +24 -8
- 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: b1c3425ed79b565564194a1b67e534077e529212ffb2ee72110db2986863f663
|
4
|
+
data.tar.gz: 93378a5eb50713e002cc5f3487b7006349bbe0e325680b22473c4167264a09e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be20389b78324047bfe10e566e6aab2db33b8fc3aab7dea8e704702a9145c3d8ab0df78bd1a73ef2277c415cc358b5e148bb2fabb815aba08bdc0f1f46c31dd3
|
7
|
+
data.tar.gz: 6b489e0365780d7af127c287367476c9d598c87877feb034cfabe79044cbaf13627c9baf1773be61adc1129ec4de0fb8351d2bbc45dfc01e73d3e3720410f9d7
|
data/README.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
[](https://www.ruby-lang.org/en/)
|
3
3
|
[](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">19.07.2023</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">15:41:56</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,6 +320,16 @@ 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.
|
332
|
+
|
269
333
|
|
270
334
|
## Contact information and mandatory 2FA coming up in 2022
|
271
335
|
|
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
|