open 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +312 -0
- data/bin/nano_open +7 -0
- data/bin/open +7 -0
- data/bin/open_in_browser +7 -0
- data/bin/open_these_files +7 -0
- data/bin/open_with_delay +7 -0
- data/doc/README.gen +265 -0
- data/lib/open/base/base.rb +329 -0
- data/lib/open/constants/constants.rb +123 -0
- data/lib/open/in_browser/in_browser.rb +614 -0
- data/lib/open/in_editor/in_editor.rb +341 -0
- data/lib/open/last/last.rb +143 -0
- data/lib/open/last_url/last_url.rb +151 -0
- data/lib/open/nano_open/nano_open.rb +73 -0
- data/lib/open/open.rb +1057 -0
- data/lib/open/project/project.rb +46 -0
- data/lib/open/requires/require_the_project.rb +15 -0
- data/lib/open/these_files/these_files.rb +120 -0
- data/lib/open/toplevel_code/toplevel_code.rb +189 -0
- data/lib/open/version/version.rb +19 -0
- data/lib/open/with_delay/with_delay.rb +260 -0
- data/lib/open/yaml/shortcuts.yml +22 -0
- data/lib/open/yaml/use_this_browser.yml +1 -0
- data/lib/open/yaml/use_this_delay.yml +1 -0
- data/lib/open/yaml/use_this_editor.yml +1 -0
- data/lib/open.rb +5 -0
- data/open.gemspec +36 -0
- data/test/testing_open.rb +35 -0
- metadata +81 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'open/project/project.rb'
|
6
|
+
# Open.project_base_directory?
|
7
|
+
# =========================================================================== #
|
8
|
+
module Open
|
9
|
+
|
10
|
+
# ========================================================================= #
|
11
|
+
# === Open::PROJECT_BASE_DIRECTORY
|
12
|
+
# ========================================================================= #
|
13
|
+
PROJECT_BASE_DIRECTORY =
|
14
|
+
File.absolute_path("#{__dir__}/..")+'/'
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === Open.project_base_directory?
|
18
|
+
# ========================================================================= #
|
19
|
+
def self.project_base_directory?
|
20
|
+
PROJECT_BASE_DIRECTORY
|
21
|
+
end; self.instance_eval { alias project_base_dir? project_base_directory? } # === Open.project_base_dir?
|
22
|
+
self.instance_eval { alias project_dir? project_base_directory? } # === Open.project_dir?
|
23
|
+
self.instance_eval { alias base_dir? project_base_directory? } # === Open.base_dir?
|
24
|
+
self.instance_eval { alias base_directory? project_base_directory? } # === Open.base_directory?
|
25
|
+
|
26
|
+
# ========================================================================= #
|
27
|
+
# === Open::PROJECT_YAML_DIRECTORY
|
28
|
+
# ========================================================================= #
|
29
|
+
PROJECT_YAML_DIRECTORY = "#{Open.project_base_dir?}yaml/"
|
30
|
+
|
31
|
+
# ========================================================================= #
|
32
|
+
# === Open.project_yaml_dir?
|
33
|
+
#
|
34
|
+
# This is a query-method for the constant PROJECT_YAML_DIRECTORY.
|
35
|
+
# ========================================================================= #
|
36
|
+
def self.project_yaml_dir?
|
37
|
+
PROJECT_YAML_DIRECTORY
|
38
|
+
end; self.instance_eval { alias yaml_directory? project_yaml_dir? } # === Open.yaml_directory?
|
39
|
+
self.instance_eval { alias project_yaml_directory? project_yaml_dir? } # === Open.project_yaml_directory?
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
if __FILE__ == $PROGRAM_NAME
|
44
|
+
puts Open.project_base_dir?
|
45
|
+
puts Open.project_yaml_dir?
|
46
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
require 'open/constants/constants.rb'
|
6
|
+
require 'open/toplevel_code/toplevel_code.rb'
|
7
|
+
require 'open/version/version.rb'
|
8
|
+
require 'open/in_browser/in_browser.rb'
|
9
|
+
require 'open/in_editor/in_editor.rb'
|
10
|
+
require 'open/last/last.rb'
|
11
|
+
require 'open/last_url/last_url.rb'
|
12
|
+
require 'open/with_delay/with_delay.rb'
|
13
|
+
require 'open/open.rb'
|
14
|
+
require 'open/nano_open/nano_open.rb'
|
15
|
+
require 'open/these_files/these_files.rb'
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === Open::TheseFiles
|
6
|
+
#
|
7
|
+
# Usage example:
|
8
|
+
#
|
9
|
+
# require 'open/these_files/these_files.rb'
|
10
|
+
# Open.these_files(ARGV)
|
11
|
+
#
|
12
|
+
# =========================================================================== #
|
13
|
+
# require 'open/these_files/these_files.rb'
|
14
|
+
# =========================================================================== #
|
15
|
+
require 'open/base/base.rb'
|
16
|
+
|
17
|
+
module Open
|
18
|
+
|
19
|
+
class TheseFiles < Base # === Open::TheseFiles
|
20
|
+
|
21
|
+
require 'open/in_editor/in_editor.rb'
|
22
|
+
|
23
|
+
# ========================================================================= #
|
24
|
+
# === initialize
|
25
|
+
#
|
26
|
+
# The first argument should be the name of the file that we wish to open.
|
27
|
+
# ========================================================================= #
|
28
|
+
def initialize(
|
29
|
+
i = nil,
|
30
|
+
run_already = true
|
31
|
+
)
|
32
|
+
register_sigint
|
33
|
+
reset
|
34
|
+
set_input(i)
|
35
|
+
run if run_already
|
36
|
+
end
|
37
|
+
|
38
|
+
# ========================================================================= #
|
39
|
+
# === reset (reset tag)
|
40
|
+
# ========================================================================= #
|
41
|
+
def reset
|
42
|
+
super()
|
43
|
+
# ========================================================================= #
|
44
|
+
# === @use_this_delay
|
45
|
+
# ========================================================================= #
|
46
|
+
@use_this_delay = ::Open.use_which_delay?.to_f
|
47
|
+
end
|
48
|
+
|
49
|
+
# ========================================================================= #
|
50
|
+
# === set_input
|
51
|
+
# ========================================================================= #
|
52
|
+
def set_input(i = '')
|
53
|
+
if i and i.is_a?(String) and i.include?("\n")
|
54
|
+
i = i.split("\n")
|
55
|
+
end
|
56
|
+
i = [i].flatten.compact.map {|entry|
|
57
|
+
if entry.include? ':'
|
58
|
+
entry = entry.split(':').first.strip
|
59
|
+
end
|
60
|
+
entry
|
61
|
+
}
|
62
|
+
@input = i # Must be an Array.
|
63
|
+
end
|
64
|
+
|
65
|
+
# ========================================================================= #
|
66
|
+
# === input?
|
67
|
+
# ========================================================================= #
|
68
|
+
def input?
|
69
|
+
@input
|
70
|
+
end
|
71
|
+
|
72
|
+
# ========================================================================= #
|
73
|
+
# === consider_opening_these_files
|
74
|
+
# ========================================================================= #
|
75
|
+
def consider_opening_these_files(
|
76
|
+
i = input?
|
77
|
+
)
|
78
|
+
i.each {|entry|
|
79
|
+
Open.in_editor(i)
|
80
|
+
sleep(@use_this_delay)
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
# ========================================================================= #
|
85
|
+
# === run (run tag)
|
86
|
+
# ========================================================================= #
|
87
|
+
def run
|
88
|
+
consider_opening_these_files
|
89
|
+
end
|
90
|
+
|
91
|
+
# ========================================================================= #
|
92
|
+
# === Open::TheseFiles[]
|
93
|
+
# ========================================================================= #
|
94
|
+
def self.[](i, &block)
|
95
|
+
new(i, &block)
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
# =========================================================================== #
|
101
|
+
# === Open.these_files
|
102
|
+
# =========================================================================== #
|
103
|
+
def self.these_files(
|
104
|
+
i = ARGV, &block
|
105
|
+
)
|
106
|
+
::Open::TheseFiles.new(i, &block)
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
# =========================================================================== #
|
112
|
+
# === open_these_files
|
113
|
+
# =========================================================================== #
|
114
|
+
def open_these_files(i = ARGV, &block)
|
115
|
+
Open.these_files(i, &block)
|
116
|
+
end
|
117
|
+
|
118
|
+
if __FILE__ == $PROGRAM_NAME
|
119
|
+
Open::TheseFiles.new(ARGV)
|
120
|
+
end # openthesefiles
|
@@ -0,0 +1,189 @@
|
|
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
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'open/version/version.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Open
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === VERSION
|
11
|
+
# ========================================================================= #
|
12
|
+
VERSION = '0.1.30'
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === LAST_UPDATE
|
16
|
+
# ========================================================================= #
|
17
|
+
LAST_UPDATE = '16.05.2023'
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,260 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === Open::WithDelay
|
6
|
+
#
|
7
|
+
# This class will open files in the current working directory, with a
|
8
|
+
# small delay. The idea behind this is that some editors, such as
|
9
|
+
# the old bluefish editor, had difficulties opening many large files
|
10
|
+
# rapidly.
|
11
|
+
#
|
12
|
+
# Usage example:
|
13
|
+
#
|
14
|
+
# Open::WithDelay.new(ARGV)
|
15
|
+
#
|
16
|
+
# =========================================================================== #
|
17
|
+
# require 'open/with_delay/_with_delay.rb'
|
18
|
+
# Open::WithDelay.new(ARGV)
|
19
|
+
# =========================================================================== #
|
20
|
+
require 'open/base/base.rb'
|
21
|
+
|
22
|
+
module Open
|
23
|
+
|
24
|
+
class WithDelay < Base # === Open::WithDelay
|
25
|
+
|
26
|
+
require 'open/in_editor/in_editor'
|
27
|
+
|
28
|
+
# ========================================================================= #
|
29
|
+
# === NAMESPACE
|
30
|
+
# ========================================================================= #
|
31
|
+
NAMESPACE = inspect
|
32
|
+
|
33
|
+
# ========================================================================= #
|
34
|
+
# === DEFAULT_DELAY
|
35
|
+
# ========================================================================= #
|
36
|
+
DEFAULT_DELAY = ::Open.use_which_delay?.to_f
|
37
|
+
|
38
|
+
# ========================================================================= #
|
39
|
+
# === initialize
|
40
|
+
# ========================================================================= #
|
41
|
+
def initialize(
|
42
|
+
commandline_arguments = DEFAULT_DELAY,
|
43
|
+
run_already = true
|
44
|
+
)
|
45
|
+
reset
|
46
|
+
set_commandline_arguments(
|
47
|
+
commandline_arguments
|
48
|
+
)
|
49
|
+
run if run_already
|
50
|
+
end
|
51
|
+
|
52
|
+
# ========================================================================= #
|
53
|
+
# === reset
|
54
|
+
# ========================================================================= #
|
55
|
+
def reset
|
56
|
+
super()
|
57
|
+
set_default_delay # We need a default value for the delay to be set.
|
58
|
+
determine_which_files_to_open
|
59
|
+
# ======================================================================= #
|
60
|
+
# === @namespace
|
61
|
+
# ======================================================================= #
|
62
|
+
@namespace = NAMESPACE
|
63
|
+
# ======================================================================= #
|
64
|
+
# === @pattern
|
65
|
+
# ======================================================================= #
|
66
|
+
@pattern = nil
|
67
|
+
end
|
68
|
+
|
69
|
+
# ========================================================================= #
|
70
|
+
# === search_for_this_pattern
|
71
|
+
# ========================================================================= #
|
72
|
+
def search_for_this_pattern(i)
|
73
|
+
@pattern = i
|
74
|
+
end; alias set_pattern search_for_this_pattern # === set_pattern
|
75
|
+
|
76
|
+
# ========================================================================= #
|
77
|
+
# === determine_which_files_to_open
|
78
|
+
# ========================================================================= #
|
79
|
+
def determine_which_files_to_open(
|
80
|
+
i = '*'
|
81
|
+
)
|
82
|
+
i = i.to_s.dup.delete('-')
|
83
|
+
case i
|
84
|
+
# ======================================================================= #
|
85
|
+
# === everything
|
86
|
+
# ======================================================================= #
|
87
|
+
when 'everything',
|
88
|
+
/^really(_|-)?everything$/i
|
89
|
+
@all_files = Dir['**/**'].select {|entry| File.file? entry }
|
90
|
+
else # This is the default entry-clause.
|
91
|
+
@all_files = Dir[i].select {|entry| File.file? entry }
|
92
|
+
end unless File.exist?('everything')
|
93
|
+
# ======================================================================= #
|
94
|
+
# And sort it next:
|
95
|
+
# ======================================================================= #
|
96
|
+
@all_files = @all_files.sort_by {|inner_entry|
|
97
|
+
# ===================================================================== #
|
98
|
+
# Must sort the files by last filename next.
|
99
|
+
# ===================================================================== #
|
100
|
+
File.basename(inner_entry)
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
# ========================================================================= #
|
105
|
+
# === set_use_this_delay
|
106
|
+
#
|
107
|
+
# Determine which delay to use before file-opening - in n seconds.
|
108
|
+
# ========================================================================= #
|
109
|
+
def set_use_this_delay(
|
110
|
+
i = DEFAULT_DELAY
|
111
|
+
)
|
112
|
+
i = i.first if i.is_a? Array
|
113
|
+
case i
|
114
|
+
# ======================================================================= #
|
115
|
+
# === :default_delay
|
116
|
+
# ======================================================================= #
|
117
|
+
when :default_delay, nil
|
118
|
+
i = DEFAULT_DELAY
|
119
|
+
end
|
120
|
+
i = i.to_f
|
121
|
+
@use_this_delay = i
|
122
|
+
end
|
123
|
+
|
124
|
+
# ========================================================================= #
|
125
|
+
# === set_default_delay
|
126
|
+
# ========================================================================= #
|
127
|
+
def set_default_delay
|
128
|
+
set_use_this_delay(:default_delay)
|
129
|
+
end
|
130
|
+
|
131
|
+
# ========================================================================= #
|
132
|
+
# === use_this_delay?
|
133
|
+
# ========================================================================= #
|
134
|
+
def use_this_delay?
|
135
|
+
@use_this_delay
|
136
|
+
end; alias delay? use_this_delay? # === delay?
|
137
|
+
|
138
|
+
# ========================================================================= #
|
139
|
+
# === report_the_delay_in_use
|
140
|
+
# ========================================================================= #
|
141
|
+
def report_the_delay_in_use
|
142
|
+
opnn; e "The delay is `#{simp(delay?.to_s)}` seconds."
|
143
|
+
end
|
144
|
+
|
145
|
+
# ========================================================================= #
|
146
|
+
# === menu (menu tag)
|
147
|
+
# ========================================================================= #
|
148
|
+
def menu(
|
149
|
+
i = @commandline_arguments
|
150
|
+
)
|
151
|
+
if i.is_a? Array
|
152
|
+
i.each {|entry| menu(entry) }
|
153
|
+
else
|
154
|
+
case i
|
155
|
+
# ===================================================================== #
|
156
|
+
# === odelay --pattern=input
|
157
|
+
# ===================================================================== #
|
158
|
+
when /^-?-?pattern=(.+)$/i
|
159
|
+
search_for_this_pattern($1.to_s.dup)
|
160
|
+
# ===================================================================== #
|
161
|
+
# === odelay --help
|
162
|
+
# ===================================================================== #
|
163
|
+
when /^-?-?help$/i
|
164
|
+
show_help
|
165
|
+
exit
|
166
|
+
# ===================================================================== #
|
167
|
+
# === odelay --everything
|
168
|
+
#
|
169
|
+
# This entry point allows us to open every file in all subdirectories
|
170
|
+
# found, under the current working directory (pwd, cwd).
|
171
|
+
# ===================================================================== #
|
172
|
+
when /^-?-?everything$/i
|
173
|
+
determine_which_files_to_open(i)
|
174
|
+
else # we assume this to be the default entry point.
|
175
|
+
if i.include?('.') and !File.exist?(i) and
|
176
|
+
is_there_a_file_with_that_file_end_in_this_directory?(i)
|
177
|
+
set_pattern(i)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# ========================================================================= #
|
184
|
+
# === show_help (help tag)
|
185
|
+
# ========================================================================= #
|
186
|
+
def show_help
|
187
|
+
e
|
188
|
+
eparse ' --everything # Open all files in the current working '\
|
189
|
+
'directory and all subdirectories, via the default delay'
|
190
|
+
eparse ' --pattern=criterium # Search for only files that match the '\
|
191
|
+
'given criterium'
|
192
|
+
e
|
193
|
+
end
|
194
|
+
|
195
|
+
# ========================================================================= #
|
196
|
+
# === is_there_a_file_with_that_file_end_in_this_directory?
|
197
|
+
# ========================================================================= #
|
198
|
+
def is_there_a_file_with_that_file_end_in_this_directory?(i)
|
199
|
+
!Dir['*'].select {|file|
|
200
|
+
file.end_with? file
|
201
|
+
}.empty?
|
202
|
+
end
|
203
|
+
|
204
|
+
# ========================================================================= #
|
205
|
+
# === consider_applying_the_pattern_filter
|
206
|
+
#
|
207
|
+
# The filter is a positive-filter, aka we keep only those files that
|
208
|
+
# fulfil our criterium.
|
209
|
+
# ========================================================================= #
|
210
|
+
def consider_applying_the_pattern_filter
|
211
|
+
if @pattern
|
212
|
+
@all_files.select! {|this_file|
|
213
|
+
this_file.include? @pattern
|
214
|
+
}
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# ========================================================================= #
|
219
|
+
# === do_process_all_files
|
220
|
+
# ========================================================================= #
|
221
|
+
def do_process_all_files(
|
222
|
+
i = @all_files
|
223
|
+
)
|
224
|
+
using_this_editor = use_which_editor?
|
225
|
+
delay = delay?.to_s
|
226
|
+
opnn; e "We will open all #{sfancy(i.size.to_s)} files "\
|
227
|
+
"in this directory."
|
228
|
+
i.each {|this_file|
|
229
|
+
opnn; e 'Next opening the file `'+sfile(this_file)+
|
230
|
+
'` via the editor '+sfancy(using_this_editor)+','
|
231
|
+
opnn; e "then sleeping for #{simp(delay)} seconds."
|
232
|
+
Open.in_editor(this_file)
|
233
|
+
sleep(delay.to_f) # Must be treated as a Float.
|
234
|
+
}
|
235
|
+
end
|
236
|
+
|
237
|
+
# ========================================================================= #
|
238
|
+
# === run
|
239
|
+
# ========================================================================= #
|
240
|
+
def run
|
241
|
+
menu
|
242
|
+
report_the_delay_in_use
|
243
|
+
consider_applying_the_pattern_filter
|
244
|
+
do_process_all_files
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
|
249
|
+
# =========================================================================== #
|
250
|
+
# === Open.with_delay
|
251
|
+
# =========================================================================== #
|
252
|
+
def self.with_delay(i = ARGV)
|
253
|
+
Open::WithDelay.new(i)
|
254
|
+
end; self.instance_eval { alias open_with_delay with_delay } # === Open.open_with_delay
|
255
|
+
|
256
|
+
end
|
257
|
+
|
258
|
+
if __FILE__ == $PROGRAM_NAME
|
259
|
+
Open::WithDelay.new(ARGV)
|
260
|
+
end # openwithdelay 3
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# === shortcuts.yml
|
3
|
+
#
|
4
|
+
# This file can be used if you want to open several files, such as in
|
5
|
+
# a specific project.
|
6
|
+
#
|
7
|
+
# For instance, if I do this on the commandline:
|
8
|
+
#
|
9
|
+
# open :gamebooks
|
10
|
+
#
|
11
|
+
# Then the open-gem will open all local files that belong to the
|
12
|
+
# gamebooks (or are useful pertaining to that project).
|
13
|
+
#
|
14
|
+
# In the past this functionality was, in part, stored in the gem called
|
15
|
+
# beautiful_url, but I think it is easier to keep this a bit separate
|
16
|
+
# from beautiful-url. At a later point in time this may change, though.
|
17
|
+
# =========================================================================== #
|
18
|
+
gamebooks:
|
19
|
+
- $RUBY_SRC/rpg_paradise/lib/rpg_paradise/gamebooks/lone_wolf/character.rb
|
20
|
+
- $RUBY_SRC/rpg_paradise/lib/rpg_paradise/gamebooks/lone_wolf/statistics.rb
|
21
|
+
- $RUBY_SRC/rpg_paradise/lib/rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb
|
22
|
+
- $RUBY_SRC/rpg_paradise/lib/rpg_paradise/gui/gtk3/gamebook/gamebook.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
thorium # chrome # firefox
|
@@ -0,0 +1 @@
|
|
1
|
+
0.8 # seconds
|
@@ -0,0 +1 @@
|
|
1
|
+
bluefish
|