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
data/lib/open/last/last.rb
CHANGED
@@ -21,11 +21,6 @@ class Last < Base # === Open::Last
|
|
21
21
|
|
22
22
|
require 'open/in_editor/in_editor.rb'
|
23
23
|
|
24
|
-
# ========================================================================= #
|
25
|
-
# === NAMESPACE
|
26
|
-
# ========================================================================= #
|
27
|
-
NAMESPACE = inspect
|
28
|
-
|
29
24
|
# ========================================================================= #
|
30
25
|
# === BY_DEFAULT_OPEN_N_FILES
|
31
26
|
# ========================================================================= #
|
@@ -48,10 +43,7 @@ class Last < Base # === Open::Last
|
|
48
43
|
# ========================================================================= #
|
49
44
|
def reset
|
50
45
|
super()
|
51
|
-
|
52
|
-
# === @namespace
|
53
|
-
# ======================================================================= #
|
54
|
-
@namespace = NAMESPACE
|
46
|
+
infer_the_namespace
|
55
47
|
end
|
56
48
|
|
57
49
|
# ========================================================================= #
|
@@ -84,12 +76,12 @@ class Last < Base # === Open::Last
|
|
84
76
|
# === open_these_target_files
|
85
77
|
# ========================================================================= #
|
86
78
|
def open_these_target_files(
|
87
|
-
i =
|
79
|
+
i = target_files?
|
88
80
|
)
|
89
81
|
if i.is_a? Array
|
90
82
|
i.each {|entry| open_these_target_files(entry) }
|
91
83
|
else
|
92
|
-
|
84
|
+
opne "Now opening `#{sfile(i)}`."
|
93
85
|
Open.in_editor(i)
|
94
86
|
end
|
95
87
|
end
|
@@ -102,7 +94,7 @@ class Last < Base # === Open::Last
|
|
102
94
|
# Sort by date next. Could also use a pure ruby implementation there.
|
103
95
|
# ======================================================================= #
|
104
96
|
result = `ls -tl --quoting-style=literal`.split("\n")
|
105
|
-
result.reject! {|entry| entry.include? 'total' }
|
97
|
+
result.reject! {|entry| entry.include? 'total ' } # This skips the first row really.
|
106
98
|
result.map! {|entry|
|
107
99
|
if entry.include? ' '
|
108
100
|
splitted = entry.split(' ')
|
@@ -115,11 +107,21 @@ class Last < Base # === Open::Last
|
|
115
107
|
entry
|
116
108
|
}
|
117
109
|
result.select! {|entry| File.file? entry }
|
110
|
+
# ======================================================================= #
|
111
|
+
# Grab the first entry next - this is our most recently modified file:
|
112
|
+
# ======================================================================= #
|
118
113
|
open_these_entries = result[0 .. (open_n_files?.to_i - 1) ]
|
119
114
|
@target_files = open_these_entries
|
120
115
|
open_these_target_files(@target_files)
|
121
116
|
end
|
122
117
|
|
118
|
+
# ========================================================================= #
|
119
|
+
# === target_files?
|
120
|
+
# ========================================================================= #
|
121
|
+
def target_files?
|
122
|
+
@target_files
|
123
|
+
end
|
124
|
+
|
123
125
|
# ========================================================================= #
|
124
126
|
# === Open::Last[]
|
125
127
|
# ========================================================================= #
|
@@ -71,11 +71,12 @@ class LastUrl < Base # === Open::LastUrl
|
|
71
71
|
# ========================================================================= #
|
72
72
|
# === determine_xorg_buffer
|
73
73
|
#
|
74
|
-
# This method depends on the binary called "xsel".
|
74
|
+
# This method depends on the binary called "xsel". We must be careful
|
75
|
+
# when using this, as "xsel" may not be installed.
|
75
76
|
# ========================================================================= #
|
76
77
|
def determine_xorg_buffer
|
77
|
-
# @xorg_buffer = `xclip -o` # Get the content of the Xorg Buffer here.
|
78
|
-
@xorg_buffer = `xsel -o` # Get the content of the Xorg Buffer here.
|
78
|
+
# @xorg_buffer = `xclip -o 2>&1` # Get the content of the Xorg Buffer here.
|
79
|
+
@xorg_buffer = `xsel -o 2>&1` # Get the content of the Xorg Buffer here.
|
79
80
|
sanitize_xorg_buffer
|
80
81
|
end
|
81
82
|
|
@@ -47,15 +47,40 @@ class NanoOpen < Base # === Open::NanoOpen
|
|
47
47
|
def run
|
48
48
|
_ = first_argument?
|
49
49
|
if is_on_roebe?
|
50
|
-
|
50
|
+
# ===================================================================== #
|
51
|
+
# First check via BeautifulUrl, since as of January 2024:
|
52
|
+
# ===================================================================== #
|
53
|
+
if BeautifulUrl.is_a_local_link?(_)
|
54
|
+
assumed_target_via_beautiful_url = BeautifulUrl.find(_)
|
55
|
+
if File.exist?(assumed_target_via_beautiful_url)
|
56
|
+
_ = assumed_target_via_beautiful_url
|
57
|
+
do_open_this_file_via_that_editor_now(_, :nano)
|
58
|
+
return
|
59
|
+
end
|
60
|
+
end
|
61
|
+
# ===================================================================== #
|
62
|
+
# Next check via the studium-gem:
|
63
|
+
# ===================================================================== #
|
64
|
+
require 'studium/toplevel_methods/find_exam_topic_and_exam_title.rb'
|
51
65
|
new_target = Studium.find_corresponding_exam_topic(_)
|
52
|
-
|
53
|
-
|
66
|
+
possible_new_target = "#{Studium.directory_to_the_exam_topics}#{new_target}"
|
67
|
+
if File.exist?(possible_new_target)
|
68
|
+
_ = possible_new_target
|
54
69
|
end
|
55
70
|
end
|
71
|
+
do_open_this_file_via_that_editor_now(_, :nano)
|
72
|
+
end
|
73
|
+
|
74
|
+
# ========================================================================= #
|
75
|
+
# === do_open_this_file_via_that_editor_now
|
76
|
+
# ========================================================================= #
|
77
|
+
def do_open_this_file_via_that_editor_now(
|
78
|
+
this_is_the_file,
|
79
|
+
that_is_the_editor = :nano
|
80
|
+
)
|
56
81
|
::Open.in_editor {{
|
57
|
-
this_file:
|
58
|
-
use_this_editor:
|
82
|
+
this_file: this_is_the_file,
|
83
|
+
use_this_editor: that_is_the_editor
|
59
84
|
}}
|
60
85
|
end
|
61
86
|
|