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
@@ -1,189 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'open/toplevel_code/toplevel_code.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Open
|
8
|
-
|
9
|
-
require 'open/project/project.rb'
|
10
|
-
|
11
|
-
begin
|
12
|
-
require 'yaml'
|
13
|
-
rescue LoadError; end
|
14
|
-
|
15
|
-
require 'open/constants/constants.rb'
|
16
|
-
|
17
|
-
# ========================================================================= #
|
18
|
-
# === Open.use_which_delay?
|
19
|
-
# ========================================================================= #
|
20
|
-
def self.use_which_delay?
|
21
|
-
_ = "#{project_base_directory?}yaml/use_this_delay.yml"
|
22
|
-
if File.exist? _
|
23
|
-
YAML.load_file(_)
|
24
|
-
else
|
25
|
-
'1.0'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# ========================================================================= #
|
30
|
-
# === Open.e
|
31
|
-
# ========================================================================= #
|
32
|
-
def self.e(i = '')
|
33
|
-
puts i
|
34
|
-
end
|
35
|
-
|
36
|
-
# ========================================================================= #
|
37
|
-
# === Open.host_os?
|
38
|
-
#
|
39
|
-
# Return the host-operating system via this method.
|
40
|
-
# ========================================================================= #
|
41
|
-
def self.host_os?
|
42
|
-
::RbConfig::CONFIG['host_os']
|
43
|
-
end
|
44
|
-
|
45
|
-
# ========================================================================= #
|
46
|
-
# === Open.is_on_windows?
|
47
|
-
# ========================================================================= #
|
48
|
-
def self.is_on_windows?(i = host_os?)
|
49
|
-
case i # or: RUBY_PLATFORM
|
50
|
-
when /win/,
|
51
|
-
/mingw/
|
52
|
-
true
|
53
|
-
else
|
54
|
-
false
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# ========================================================================= #
|
59
|
-
# === @use_this_editor
|
60
|
-
# ========================================================================= #
|
61
|
-
@use_this_editor = nil
|
62
|
-
|
63
|
-
# ========================================================================= #
|
64
|
-
# === Open.set_use_this_editor
|
65
|
-
#
|
66
|
-
# Modify the toplevel variable @use_this_editor through this method.
|
67
|
-
# ========================================================================= #
|
68
|
-
def self.set_use_this_editor(
|
69
|
-
i = USE_THIS_EDITOR
|
70
|
-
)
|
71
|
-
@use_this_editor = i
|
72
|
-
end
|
73
|
-
|
74
|
-
set_use_this_editor # Initialize it at once.
|
75
|
-
|
76
|
-
# ========================================================================= #
|
77
|
-
# === Open.use_which_editor?
|
78
|
-
# ========================================================================= #
|
79
|
-
def self.use_which_editor?
|
80
|
-
@use_this_editor
|
81
|
-
end
|
82
|
-
|
83
|
-
# ========================================================================= #
|
84
|
-
# === @use_this_browser
|
85
|
-
# ========================================================================= #
|
86
|
-
@use_this_browser = nil
|
87
|
-
|
88
|
-
# ========================================================================= #
|
89
|
-
# === Open.set_use_this_browser
|
90
|
-
#
|
91
|
-
# This method can be used to assign a different browser.
|
92
|
-
# ========================================================================= #
|
93
|
-
def self.set_use_this_browser(
|
94
|
-
i = USE_THIS_BROWSER
|
95
|
-
)
|
96
|
-
@use_this_browser = i
|
97
|
-
end; self.instance_eval { alias use_this_browser= set_use_this_browser } # === Open.use_this_browser=
|
98
|
-
|
99
|
-
set_use_this_browser # Initialize it at once.
|
100
|
-
|
101
|
-
# ========================================================================= #
|
102
|
-
# === Open.use_which_browser?
|
103
|
-
#
|
104
|
-
# Query-method to determine which browser is currently designated to be
|
105
|
-
# the main browser, as far as the open-gem is concerned.
|
106
|
-
# ========================================================================= #
|
107
|
-
def self.use_which_browser?
|
108
|
-
@use_this_browser
|
109
|
-
end; self.instance_eval { alias browser? use_which_browser? } # === Open.browser?
|
110
|
-
|
111
|
-
# ========================================================================= #
|
112
|
-
# === Open.write_what_into
|
113
|
-
#
|
114
|
-
# Delegate towards SaveFile.
|
115
|
-
# ========================================================================= #
|
116
|
-
def self.write_what_into(what, into)
|
117
|
-
::SaveFile.write_what_into(what, into)
|
118
|
-
end
|
119
|
-
|
120
|
-
# ========================================================================= #
|
121
|
-
# === Open[]
|
122
|
-
#
|
123
|
-
# This method defaults to Open.in_editor(), but if the input starts
|
124
|
-
# with "http" then we will use Open.in_browser() instead.
|
125
|
-
#
|
126
|
-
# In January 2023 this was deprecated. It now resides in another file.
|
127
|
-
#
|
128
|
-
# Usage example:
|
129
|
-
#
|
130
|
-
# Open[TEST_THIS_FILE]
|
131
|
-
#
|
132
|
-
# ========================================================================= #
|
133
|
-
# def self.[](i = ARGV, &block)
|
134
|
-
# unless Open.respond_to? :in_browser
|
135
|
-
# require 'open/in_browser/in_browser.rb'
|
136
|
-
# end
|
137
|
-
# unless Open.respond_to? :in_editor
|
138
|
-
# require 'open/in_editor/in_editor.rb'
|
139
|
-
# end
|
140
|
-
# if i.is_a? Array
|
141
|
-
# i = i.join(' ').strip
|
142
|
-
# end
|
143
|
-
# if i.start_with? 'http'
|
144
|
-
# ::Open.in_browser(i, &block)
|
145
|
-
# else # this is the default
|
146
|
-
# ::Open.in_editor(i, &block)
|
147
|
-
# end
|
148
|
-
# end
|
149
|
-
|
150
|
-
# ========================================================================= #
|
151
|
-
# === Roebe.is_on_roebe?
|
152
|
-
# ========================================================================= #
|
153
|
-
def self.is_on_roebe?
|
154
|
-
ENV['IS_ROEBE'].to_s == '1'
|
155
|
-
end
|
156
|
-
|
157
|
-
# ========================================================================= #
|
158
|
-
# === Open.permanently_use_this_browser
|
159
|
-
#
|
160
|
-
# This method can be used to permanently store a new browser, for the
|
161
|
-
# open gem.
|
162
|
-
# ========================================================================= #
|
163
|
-
def self.permanently_use_this_browser(
|
164
|
-
this_browser = 'thorium',
|
165
|
-
store_into_this_file = ::Open::LOCATION_OF_BROWSER_YAML_FILE
|
166
|
-
)
|
167
|
-
case this_browser # Symbols are treated a bit differently here.
|
168
|
-
# ======================================================================= #
|
169
|
-
# === :firefox
|
170
|
-
# ======================================================================= #
|
171
|
-
when :firefox
|
172
|
-
this_browser = '/usr/bin/firefox'
|
173
|
-
end
|
174
|
-
this_browser = this_browser.to_s # We need a String.
|
175
|
-
e "Storing into `#{store_into_this_file}`."
|
176
|
-
write_what_into(this_browser, store_into_this_file)
|
177
|
-
if is_on_roebe?
|
178
|
-
store_into_this_file = '/home/x/programming/ruby/src/open/lib/open/yaml/use_this_browser.yml'
|
179
|
-
e "Storing into `#{store_into_this_file}`."
|
180
|
-
write_what_into(this_browser, store_into_this_file)
|
181
|
-
end
|
182
|
-
end; self.instance_eval { alias permanently_use_this_browser= permanently_use_this_browser } # === Open.permanently_use_this_browser=
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
if __FILE__ == $PROGRAM_NAME
|
187
|
-
puts Open.use_which_editor?
|
188
|
-
puts Open.use_which_browser?
|
189
|
-
end
|