open 0.1.23

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of open might be problematic. Click here for more details.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7d84236c8e1837bae948dac7ee02728bdfb254611c10e12b0740fbbddc157218
4
+ data.tar.gz: 8973f1fc1d08d800c5677b85dbbd2868f9fcdce6a8074440f1c3534f3215a789
5
+ SHA512:
6
+ metadata.gz: 0bd62d4771dfa54d3ebbf4f73380b3935563615e453a6f9860b28dd1e1017319bc82a78916c31b8dbbe4a196a51ea2e52001620dc650f07b1f60c1b522402123
7
+ data.tar.gz: d40200694a30546b614f0869db89357839d3bc07fe5decd07e4fa966b5d9f94ea788d361577ac73e4645de82a0f3f4f8d0da727877891596dabf674f1048817e
data/README.md ADDED
@@ -0,0 +1,292 @@
1
+ [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/open.svg)](https://badge.fury.io/rb/open)
4
+
5
+ This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">03.10.2022</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">21:09:16</span> o'clock.
6
+
7
+ ## History of this project
8
+
9
+ In the past I used separate projects / gems, such as **OpenInEditor** or
10
+ **OpenInBrowser**, to open files via my favourite editor, or to open
11
+ remote URLs via my favourite browser.
12
+
13
+ Additionally I also had more code aggregated in **roebe/classes/open/**.
14
+
15
+ This slightly confusing situation accrued over the years, from 2010 to 2021
16
+ or so.
17
+
18
+ In early **September 2021** I reconsidered the old approach.
19
+
20
+ I wanted to not only clean up the old code base, making it more flexible
21
+ as well in the process, but **add a new API** such as:
22
+
23
+ Open.in_editor('/home/foobar.md')
24
+ Open.in_editor(this_file: '/home/foobar.md')
25
+
26
+ As well as:
27
+
28
+ Open.in_browser(url: 'google.de', browser: 'firefox')
29
+
30
+ That way we can 'think' of "Open" first, and then simply call
31
+ the method name that we want to use. On the commandline we can
32
+ still do:
33
+
34
+ open_in_editor foobar.rb
35
+ open_in_browser google.de
36
+
37
+ ## Layout of the project's structure
38
+
39
+ This subsection will not include all details, but may serve as a slight
40
+ introduction to how the project is layout.
41
+
42
+ Most of the constants will reside under **open/constants/constants.rb**.
43
+
44
+ Toplevel-methods can be found under **open/toplevel_code/** for the
45
+ most part. This may be ignored by some classes if they add
46
+ toplevel-methods; in that case the toplevel may be modified by such
47
+ a class, and **can subsequently be found in that .rb file where the
48
+ class is defined** (or the directory, if this class is split up
49
+ into several different .rb files).
50
+
51
+ So, for instance, **class Open::Browser** may define a toplevel
52
+ method called **Open.in_browser()**. You can also **grep** (on Linux)
53
+ for where the source code resides specifically, of course.
54
+
55
+ ## Optional dependencies in this project
56
+
57
+ Officially there are no hardcoded dependencies in this project.
58
+
59
+ However had, you are encouraged to install various gems, such as:
60
+
61
+ - colours
62
+ - convert_global_env
63
+ - beautiful_url
64
+ - opn
65
+
66
+ These may enhance the ruby code used in this project.
67
+
68
+ I highly recommend to install the **colours** gem, but ultimately
69
+ the code in this project is written deliberately in a manner to
70
+ make all these add-ons optional, so this is entirely up to you
71
+ in the end.
72
+
73
+ ## class Open::InEditor
74
+
75
+ This class can be used for **opening a (local) file via the editor**.
76
+
77
+ To open a local file via the open-gem, do:
78
+
79
+ require 'open'
80
+
81
+ Open.in_editor('FILE_PATH_GOES_IN_HERE')
82
+ Open.in_editor('/home/x/programming/ruby/src/open/open.gemspec')
83
+
84
+ ## class Open::InBrowser
85
+
86
+ This class can be used for opening a remote URL via your
87
+ favourite **browser**.
88
+
89
+ Upon requiring the main class, the method called:
90
+
91
+ open_in_browser()
92
+
93
+ will be defined as well, to simplify working with the
94
+ class.
95
+
96
+ To specify a particular **port**, use this variant:
97
+
98
+ Open.open_in_browser(port: 8080)
99
+
100
+ This is equivalent to this variant here:
101
+
102
+ PORT_TO_USE = 8080
103
+ Open.in_browser(with_localhost: PORT_TO_USE)
104
+
105
+ So **different keywords** can be used, however your brain prefers
106
+ this or that variant.
107
+
108
+ In **February 2022** I discovered the **launchy** gem. This gem
109
+ can be used to open a remote URL via your favourite browser
110
+ too. Since that is a rather neat functionality to have, I
111
+ decided to integrate this as an optional API into the
112
+ **open** gem as well.
113
+
114
+ Open.open_in_browser(port: 8080, use_launchy: true)
115
+ # or this variant
116
+ Open.open_in_browser(port: 8080) { :use_launchy }
117
+
118
+ Note that in order for this to work, e. g. to use **:use_launchy**
119
+ such as shown by the last example, you need to have the launchy
120
+ gem installed, logically.
121
+
122
+ On windows you can open a remote URL via firefox in the following
123
+ manner:
124
+
125
+ start firefox website_here
126
+ start firefox blog.fefe.de
127
+ start firefox www.howtogeek.com
128
+ start firefox -new-tab www.howtogeek.com
129
+
130
+ In particular the latter variant can be used as-is via
131
+ cmd.exe. You can also pass the **/k** flag to spawn a
132
+ new cmd.exe, on windows. Before knowing that I used
133
+ the system() approach passing the path to firefox.exe,
134
+ but that did not work. Via **start**, though, it does
135
+ indeed work.
136
+
137
+ ## class Open::LastUrl
138
+
139
+ This small class can be used to specifically open the content
140
+ of the xorg-buffer via the browser.
141
+
142
+ ## class Open::WithDelay
143
+
144
+ You can open files via a <b>delay</b>, through class **Open::WithDelay**.
145
+
146
+ You can specify a delay via:
147
+
148
+ openwithdelay 3
149
+
150
+ Or via the method:
151
+
152
+ .set_use_this_delay()
153
+ .set_use_this_delay(3)
154
+ .set_use_this_delay(0.5)
155
+
156
+ Why may this be necessary? My old editor (called bluefish) has had
157
+ problems batch-opening many files, so I needed a delay. With a delay
158
+ in place the problem I saw went away. So this was mostly 'workaround'
159
+ code.
160
+
161
+ ## Changing to a different default editor and browser
162
+
163
+ In **November 2021** I realized that we need a way to more
164
+ easily switch between the default main editor and the
165
+ default main browser. For instance, I abandoned palemoon,
166
+ so I needed to use firefox quickly.
167
+
168
+ The old code had hardcoded calls to **palemoon**, which was
169
+ not very elegant, and made changes to the code harder
170
+ naturally.
171
+
172
+ Thus <b>two new yaml files</b> were added to the gem:
173
+
174
+ use_this_browser.yml
175
+ use_this_editor.yml
176
+
177
+ Now you can modify these yaml files and use a different
178
+ browser or editor. You can even specify the full path
179
+ to these browsers and it should work fine.
180
+
181
+ In July 2022 I decided to extend this functionality.
182
+
183
+ First, you can now <b>automatically</b> set a new
184
+ browser via the toplevel method
185
+ <b>Open.permanently_use_this_browser()</b>.
186
+
187
+ Simply pass the new browser as name to the method,
188
+ such as:
189
+
190
+ Open.permanently_use_this_browser('thorium') # if you want to use the thorium browser
191
+
192
+ The second argument is optional and allows the user to
193
+ specify another .yml file to use. The default value
194
+ should be fine for most users, though, in perhaps
195
+ 99.9% of the use cases.
196
+
197
+ Note that the **save_file** gem is required for this
198
+ functionality.
199
+
200
+ Note that you can also place a file called
201
+ <b>use_this_browser.yml</b> in your home directory -
202
+ the home directory can be queried via <b>Dir.home</b>.
203
+ This .yml file, should it exist, will be checked
204
+ first. That way you can simply assign a new default
205
+ value without having to modify the internal .yml
206
+ files of this project.
207
+
208
+ ## Finding out the current editor and browser in use
209
+
210
+ Use the following two methods if you wish to find out which
211
+ is the current main editor and the current main browser in use.
212
+
213
+ puts Open.use_which_editor?
214
+ puts Open.use_which_browser? # Or the shorter alias: Open.browser?
215
+
216
+ Both values can be changed for your own use case. For instance,
217
+ if you would like to change the browser to be used, use either
218
+ of the following two methods:
219
+
220
+ Open.set_use_this_browser
221
+ Open.use_this_browser=
222
+
223
+ Currently, as of <b>July 2022</b>, the following browsers have
224
+ been tested and "integrated":
225
+
226
+ firefox
227
+ palemoon
228
+ chromium
229
+ thorium
230
+
231
+ More may be added in the future. Note that "integrated" mostly
232
+ means tested on my home system. Each of these may use a
233
+ slightly different way to open a remote URL in a tab, so
234
+ the syntax has to be adjusted to each browser differently.
235
+
236
+ ## class Open::Base
237
+
238
+ This subsection contains just a few pointers to the class
239
+ called **Open::Base**.
240
+
241
+ The method **.this_file_was_not_found()** can be used to
242
+ designate that a certain file (the input argument to
243
+ that method) could <b>not</b> be found.
244
+
245
+ ## Determining which browser is in use
246
+
247
+ You can use this method to query which browser has been
248
+ assigned to be used for Open:
249
+
250
+ Open.use_which_browser?
251
+
252
+
253
+ ## Contact information and mandatory 2FA coming up in 2022
254
+
255
+ If your creative mind has ideas and specific suggestions to make this gem
256
+ more useful in general, feel free to drop me an email at any time, via:
257
+
258
+ shevy@inbox.lt
259
+
260
+ Before that email I used an email account at Google gmail, but in **2021** I
261
+ decided to slowly abandon gmail for various reasons. In order to limit this
262
+ explanation here, allow me to just briefly state that I do not feel as if I
263
+ want to promote any Google service anymore, for various reasons.
264
+
265
+ Do keep in mind that responding to emails may take some time, depending on
266
+ the amount of work I may have at that moment.
267
+
268
+ In 2022 rubygems.org decided to make 2FA mandatory for every gem owner:
269
+ see https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
270
+
271
+ As I can not use 2FA, for reasons I will skip explaining here (see
272
+ various github issue discussions in the past), this effectively means that
273
+ Betty Li and others who run the show at rubygems.org will perma-ban me
274
+ from using rubygems as a developer.
275
+
276
+ As I disagree with that decision completely, this will mean that all my
277
+ gems will be removed from rubygems.org prior to that sunset date, e. g.
278
+ before they permanently lock me out from the code that I used
279
+ to maintain. It is pointless to want to discuss this with them anymore -
280
+ they have made up their minds and decided that you can only use
281
+ the code if 2FA is in place, even though the code itself works just
282
+ fine. If you don't use 2FA you are effectively locked out from your
283
+ own code; I consider this a malicious attack. See also how they limited
284
+ discussions to people with mandatory 2FA on the ruby-bugtracker, thus
285
+ banning everyone permanently without 2FA:
286
+
287
+ https://bugs.ruby-lang.org/issues/18800
288
+
289
+ Guess it may indeed be time to finally abandon ruby - not because
290
+ ruby is a bad language, but there are people now in charge who
291
+ really should not be part of ruby in the first place.
292
+
data/bin/nano_open ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'open/nano_open/nano_open.rb'
6
+
7
+ Open::NanoOpen.new(ARGV)
data/bin/open ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'open/open.rb' # Only require the minimal code for this.
6
+
7
+ Open::Open.new(ARGV)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'open/in_browser/in_browser.rb'
6
+
7
+ open_in_browser(ARGV)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'open/these_files/these_files.rb'
6
+
7
+ Open.these_files(STDIN.read)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'open/with_delay/with_delay.rb'
6
+
7
+ Open::WithDelay.new(ARGV)
data/doc/README.gen ADDED
@@ -0,0 +1,248 @@
1
+ ADD_DEFAULT_HEADER
2
+
3
+ ## History of this project
4
+
5
+ In the past I used separate projects / gems, such as **OpenInEditor** or
6
+ **OpenInBrowser**, to open files via my favourite editor, or to open
7
+ remote URLs via my favourite browser.
8
+
9
+ Additionally I also had more code aggregated in **roebe/classes/open/**.
10
+
11
+ This slightly confusing situation accrued over the years, from 2010 to 2021
12
+ or so.
13
+
14
+ In early **September 2021** I reconsidered the old approach.
15
+
16
+ I wanted to not only clean up the old code base, making it more flexible
17
+ as well in the process, but **add a new API** such as:
18
+
19
+ Open.in_editor('/home/foobar.md')
20
+ Open.in_editor(this_file: '/home/foobar.md')
21
+
22
+ As well as:
23
+
24
+ Open.in_browser(url: 'google.de', browser: 'firefox')
25
+
26
+ That way we can 'think' of "Open" first, and then simply call
27
+ the method name that we want to use. On the commandline we can
28
+ still do:
29
+
30
+ open_in_editor foobar.rb
31
+ open_in_browser google.de
32
+
33
+ ## Layout of the project's structure
34
+
35
+ This subsection will not include all details, but may serve as a slight
36
+ introduction to how the project is layout.
37
+
38
+ Most of the constants will reside under **open/constants/constants.rb**.
39
+
40
+ Toplevel-methods can be found under **open/toplevel_code/** for the
41
+ most part. This may be ignored by some classes if they add
42
+ toplevel-methods; in that case the toplevel may be modified by such
43
+ a class, and **can subsequently be found in that .rb file where the
44
+ class is defined** (or the directory, if this class is split up
45
+ into several different .rb files).
46
+
47
+ So, for instance, **class Open::Browser** may define a toplevel
48
+ method called **Open.in_browser()**. You can also **grep** (on Linux)
49
+ for where the source code resides specifically, of course.
50
+
51
+ ## Optional dependencies in this project
52
+
53
+ Officially there are no hardcoded dependencies in this project.
54
+
55
+ However had, you are encouraged to install various gems, such as:
56
+
57
+ - colours
58
+ - convert_global_env
59
+ - beautiful_url
60
+ - opn
61
+
62
+ These may enhance the ruby code used in this project.
63
+
64
+ I highly recommend to install the **colours** gem, but ultimately
65
+ the code in this project is written deliberately in a manner to
66
+ make all these add-ons optional, so this is entirely up to you
67
+ in the end.
68
+
69
+ ## class Open::InEditor
70
+
71
+ This class can be used for **opening a (local) file via the editor**.
72
+
73
+ To open a local file via the open-gem, do:
74
+
75
+ require 'open'
76
+
77
+ Open.in_editor('FILE_PATH_GOES_IN_HERE')
78
+ Open.in_editor('/home/x/programming/ruby/src/open/open.gemspec')
79
+
80
+ ## class Open::InBrowser
81
+
82
+ This class can be used for opening a remote URL via your
83
+ favourite **browser**.
84
+
85
+ Upon requiring the main class, the method called:
86
+
87
+ open_in_browser()
88
+
89
+ will be defined as well, to simplify working with the
90
+ class.
91
+
92
+ To specify a particular **port**, use this variant:
93
+
94
+ Open.open_in_browser(port: 8080)
95
+
96
+ This is equivalent to this variant here:
97
+
98
+ PORT_TO_USE = 8080
99
+ Open.in_browser(with_localhost: PORT_TO_USE)
100
+
101
+ So **different keywords** can be used, however your brain prefers
102
+ this or that variant.
103
+
104
+ In **February 2022** I discovered the **launchy** gem. This gem
105
+ can be used to open a remote URL via your favourite browser
106
+ too. Since that is a rather neat functionality to have, I
107
+ decided to integrate this as an optional API into the
108
+ **open** gem as well.
109
+
110
+ Open.open_in_browser(port: 8080, use_launchy: true)
111
+ # or this variant
112
+ Open.open_in_browser(port: 8080) { :use_launchy }
113
+
114
+ Note that in order for this to work, e. g. to use **:use_launchy**
115
+ such as shown by the last example, you need to have the launchy
116
+ gem installed, logically.
117
+
118
+ On windows you can open a remote URL via firefox in the following
119
+ manner:
120
+
121
+ start firefox website_here
122
+ start firefox blog.fefe.de
123
+ start firefox www.howtogeek.com
124
+ start firefox -new-tab www.howtogeek.com
125
+
126
+ In particular the latter variant can be used as-is via
127
+ cmd.exe. You can also pass the **/k** flag to spawn a
128
+ new cmd.exe, on windows. Before knowing that I used
129
+ the system() approach passing the path to firefox.exe,
130
+ but that did not work. Via **start**, though, it does
131
+ indeed work.
132
+
133
+ ## class Open::LastUrl
134
+
135
+ This small class can be used to specifically open the content
136
+ of the xorg-buffer via the browser.
137
+
138
+ ## class Open::WithDelay
139
+
140
+ You can open files via a <b>delay</b>, through class **Open::WithDelay**.
141
+
142
+ You can specify a delay via:
143
+
144
+ openwithdelay 3
145
+
146
+ Or via the method:
147
+
148
+ .set_use_this_delay()
149
+ .set_use_this_delay(3)
150
+ .set_use_this_delay(0.5)
151
+
152
+ Why may this be necessary? My old editor (called bluefish) has had
153
+ problems batch-opening many files, so I needed a delay. With a delay
154
+ in place the problem I saw went away. So this was mostly 'workaround'
155
+ code.
156
+
157
+ ## Changing to a different default editor and browser
158
+
159
+ In **November 2021** I realized that we need a way to more
160
+ easily switch between the default main editor and the
161
+ default main browser. For instance, I abandoned palemoon,
162
+ so I needed to use firefox quickly.
163
+
164
+ The old code had hardcoded calls to **palemoon**, which was
165
+ not very elegant, and made changes to the code harder
166
+ naturally.
167
+
168
+ Thus <b>two new yaml files</b> were added to the gem:
169
+
170
+ use_this_browser.yml
171
+ use_this_editor.yml
172
+
173
+ Now you can modify these yaml files and use a different
174
+ browser or editor. You can even specify the full path
175
+ to these browsers and it should work fine.
176
+
177
+ In July 2022 I decided to extend this functionality.
178
+
179
+ First, you can now <b>automatically</b> set a new
180
+ browser via the toplevel method
181
+ <b>Open.permanently_use_this_browser()</b>.
182
+
183
+ Simply pass the new browser as name to the method,
184
+ such as:
185
+
186
+ Open.permanently_use_this_browser('thorium') # if you want to use the thorium browser
187
+
188
+ The second argument is optional and allows the user to
189
+ specify another .yml file to use. The default value
190
+ should be fine for most users, though, in perhaps
191
+ 99.9% of the use cases.
192
+
193
+ Note that the **save_file** gem is required for this
194
+ functionality.
195
+
196
+ Note that you can also place a file called
197
+ <b>use_this_browser.yml</b> in your home directory -
198
+ the home directory can be queried via <b>Dir.home</b>.
199
+ This .yml file, should it exist, will be checked
200
+ first. That way you can simply assign a new default
201
+ value without having to modify the internal .yml
202
+ files of this project.
203
+
204
+ ## Finding out the current editor and browser in use
205
+
206
+ Use the following two methods if you wish to find out which
207
+ is the current main editor and the current main browser in use.
208
+
209
+ puts Open.use_which_editor?
210
+ puts Open.use_which_browser? # Or the shorter alias: Open.browser?
211
+
212
+ Both values can be changed for your own use case. For instance,
213
+ if you would like to change the browser to be used, use either
214
+ of the following two methods:
215
+
216
+ Open.set_use_this_browser
217
+ Open.use_this_browser=
218
+
219
+ Currently, as of <b>July 2022</b>, the following browsers have
220
+ been tested and "integrated":
221
+
222
+ firefox
223
+ palemoon
224
+ chromium
225
+ thorium
226
+
227
+ More may be added in the future. Note that "integrated" mostly
228
+ means tested on my home system. Each of these may use a
229
+ slightly different way to open a remote URL in a tab, so
230
+ the syntax has to be adjusted to each browser differently.
231
+
232
+ ## class Open::Base
233
+
234
+ This subsection contains just a few pointers to the class
235
+ called **Open::Base**.
236
+
237
+ The method **.this_file_was_not_found()** can be used to
238
+ designate that a certain file (the input argument to
239
+ that method) could <b>not</b> be found.
240
+
241
+ ## Determining which browser is in use
242
+
243
+ You can use this method to query which browser has been
244
+ assigned to be used for Open:
245
+
246
+ Open.use_which_browser?
247
+
248
+ ADD_CONTACT_INFORMATION