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.

Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +73 -9
  3. data/bin/open +1 -1
  4. data/bin/open_in_browser +1 -1
  5. data/doc/README.gen +72 -8
  6. data/doc/deprecated_code/deprecated_code.md +26 -0
  7. data/img/open_logo.png +0 -0
  8. data/lib/open/base/base.rb +262 -122
  9. data/lib/open/books/README.md +8 -0
  10. data/lib/open/books/books.rb +99 -0
  11. data/lib/open/constants/constants.rb +85 -8
  12. data/lib/open/in_browser/in_browser.rb +476 -304
  13. data/lib/open/in_editor/in_editor.rb +348 -155
  14. data/lib/open/last/last.rb +14 -12
  15. data/lib/open/nano_open/nano_open.rb +4 -3
  16. data/lib/open/{open.rb → open/open.rb} +597 -653
  17. data/lib/open/project/project.rb +3 -2
  18. data/lib/open/requires/failsafe_require_of_beautiful_url.rb +9 -0
  19. data/lib/open/requires/require_the_project.rb +2 -2
  20. data/lib/open/requires/require_yaml.rb +13 -0
  21. data/lib/open/these_files/these_files.rb +1 -1
  22. data/lib/open/toplevel_methods/browser.rb +71 -0
  23. data/lib/open/toplevel_methods/delay.rb +23 -0
  24. data/lib/open/toplevel_methods/e.rb +14 -0
  25. data/lib/open/toplevel_methods/editor.rb +41 -0
  26. data/lib/open/toplevel_methods/host_os.rb +25 -0
  27. data/lib/open/toplevel_methods/is_on_roebe.rb +16 -0
  28. data/lib/open/toplevel_methods/is_on_windows.rb +26 -0
  29. data/lib/open/toplevel_methods/misc.rb +50 -0
  30. data/lib/open/version/version.rb +2 -2
  31. data/lib/open/with_delay/with_delay.rb +9 -11
  32. data/open.gemspec +1 -1
  33. data/test/testing_open.rb +1 -1
  34. data/test/testing_open_in_browser.rb +16 -0
  35. data/test/testing_open_via_launchy.rb +3 -0
  36. data/test/testing_shortcuts.rb +3 -0
  37. metadata +24 -8
  38. data/lib/open/toplevel_code/toplevel_code.rb +0 -189
@@ -41,6 +41,7 @@ module Open
41
41
  end
42
42
 
43
43
  if __FILE__ == $PROGRAM_NAME
44
- puts Open.project_base_dir?
45
- puts Open.project_yaml_dir?
44
+ alias e puts
45
+ e Open.project_base_dir?
46
+ e Open.project_yaml_dir?
46
47
  end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/requires/failsafe_require_of_beautiful_url.rb'
6
+ # =========================================================================== #
7
+ begin
8
+ require 'beautiful_url'
9
+ rescue LoadError; end
@@ -3,13 +3,13 @@
3
3
  # frozen_string_literal: true
4
4
  # =========================================================================== #
5
5
  require 'open/constants/constants.rb'
6
- require 'open/toplevel_code/toplevel_code.rb'
6
+ require 'open/toplevel_methods/misc.rb'
7
7
  require 'open/version/version.rb'
8
8
  require 'open/in_browser/in_browser.rb'
9
9
  require 'open/in_editor/in_editor.rb'
10
10
  require 'open/last/last.rb'
11
11
  require 'open/last_url/last_url.rb'
12
12
  require 'open/with_delay/with_delay.rb'
13
- require 'open/open.rb'
13
+ require 'open/open/open.rb'
14
14
  require 'open/nano_open/nano_open.rb'
15
15
  require 'open/these_files/these_files.rb'
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/requires/require_yaml.rb'
6
+ # =========================================================================== #
7
+ module Open
8
+
9
+ begin
10
+ require 'yaml'
11
+ rescue LoadError; end
12
+
13
+ end
@@ -76,7 +76,7 @@ class TheseFiles < Base # === Open::TheseFiles
76
76
  i = input?
77
77
  )
78
78
  i.each {|entry|
79
- Open.in_editor(i)
79
+ ::Open.in_editor(i)
80
80
  sleep(@use_this_delay)
81
81
  }
82
82
  end
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/toplevel_methods/browser.rb'
6
+ # =========================================================================== #
7
+ module Open
8
+
9
+ require 'open/constants/constants.rb'
10
+
11
+ # ========================================================================= #
12
+ # === @use_this_browser
13
+ # ========================================================================= #
14
+ @use_this_browser = nil
15
+
16
+ # ========================================================================= #
17
+ # === Open.set_use_this_browser
18
+ #
19
+ # This method can be used to assign a different browser.
20
+ # ========================================================================= #
21
+ def self.set_use_this_browser(
22
+ i = USE_THIS_BROWSER
23
+ )
24
+ @use_this_browser = i
25
+ end; self.instance_eval { alias use_this_browser= set_use_this_browser } # === Open.use_this_browser=
26
+
27
+ set_use_this_browser # Initialize it at once.
28
+
29
+ # ========================================================================= #
30
+ # === Open.use_which_browser?
31
+ #
32
+ # Query-method to determine which browser is currently designated to be
33
+ # the main browser, as far as the open-gem is concerned.
34
+ # ========================================================================= #
35
+ def self.use_which_browser?
36
+ @use_this_browser
37
+ end; self.instance_eval { alias browser? use_which_browser? } # === Open.browser?
38
+
39
+ # ========================================================================= #
40
+ # === Open.permanently_use_this_browser
41
+ #
42
+ # This method can be used to permanently store a new browser, for the
43
+ # open gem.
44
+ # ========================================================================= #
45
+ def self.permanently_use_this_browser(
46
+ this_browser = 'thorium',
47
+ store_into_this_file = ::Open::LOCATION_OF_BROWSER_YAML_FILE
48
+ )
49
+ case this_browser # Symbols are treated a bit differently here.
50
+ # ======================================================================= #
51
+ # === :firefox
52
+ # ======================================================================= #
53
+ when :firefox
54
+ this_browser = '/usr/bin/firefox'
55
+ end
56
+ this_browser = this_browser.to_s # We need a String.
57
+ e "Storing into `#{store_into_this_file}`."
58
+ write_what_into(this_browser, store_into_this_file)
59
+ if is_on_roebe?
60
+ store_into_this_file = "#{RUBY_SRC}open/lib/open/yaml/use_this_browser.yml"
61
+ e "Storing into `#{store_into_this_file}`."
62
+ write_what_into(this_browser, store_into_this_file)
63
+ end
64
+ end; self.instance_eval { alias permanently_use_this_browser= permanently_use_this_browser } # === Open.permanently_use_this_browser=
65
+
66
+ end
67
+
68
+ if __FILE__ == $PROGRAM_NAME
69
+ alias e puts
70
+ e Open.use_which_browser?
71
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/toplevel_methods/delay.rb'
6
+ # =========================================================================== #
7
+ module Open
8
+
9
+ # ========================================================================= #
10
+ # === Open.use_which_delay?
11
+ # ========================================================================= #
12
+ def self.use_which_delay?
13
+ require 'open/project/project.rb'
14
+ require 'open/requires/require_yaml.rb'
15
+ _ = "#{project_base_directory?}yaml/use_this_delay.yml"
16
+ if File.exist? _
17
+ YAML.load_file(_)
18
+ else
19
+ '1.0'
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module Open
6
+
7
+ # ========================================================================= #
8
+ # === Open.e
9
+ # ========================================================================= #
10
+ def self.e(i = '')
11
+ puts i
12
+ end
13
+
14
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/toplevel_methods/editor.rb'
6
+ # =========================================================================== #
7
+ module Open
8
+
9
+ require 'open/constants/constants.rb'
10
+
11
+ # ========================================================================= #
12
+ # === @use_this_editor
13
+ # ========================================================================= #
14
+ @use_this_editor = nil
15
+
16
+ # ========================================================================= #
17
+ # === Open.set_use_this_editor
18
+ #
19
+ # Modify the toplevel variable @use_this_editor through this method.
20
+ # ========================================================================= #
21
+ def self.set_use_this_editor(
22
+ i = USE_THIS_EDITOR
23
+ )
24
+ @use_this_editor = i
25
+ end
26
+
27
+ set_use_this_editor # Initialize it at once.
28
+
29
+ # ========================================================================= #
30
+ # === Open.use_which_editor?
31
+ # ========================================================================= #
32
+ def self.use_which_editor?
33
+ @use_this_editor
34
+ end; self.instance_eval { alias editor? use_which_editor? } # === Open.editor?
35
+
36
+ end
37
+
38
+ if __FILE__ == $PROGRAM_NAME
39
+ alias e puts
40
+ e Open.use_which_editor?
41
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/toplevel_methods/host_os.rb'
6
+ # =========================================================================== #
7
+ module Open
8
+
9
+ # ========================================================================= #
10
+ # === Open.host_os?
11
+ #
12
+ # Return the host-operating system via this method.
13
+ #
14
+ # On linux this method would yield the String "linux".
15
+ # ========================================================================= #
16
+ def self.host_os?
17
+ ::RbConfig::CONFIG['host_os']
18
+ end
19
+
20
+ end
21
+
22
+ if __FILE__ == $PROGRAM_NAME
23
+ alias e puts
24
+ e Open.host_os?
25
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/toplevel_methods/is_on_roebe.rb'
6
+ # =========================================================================== #
7
+ module Open
8
+
9
+ # ========================================================================= #
10
+ # === Roebe.is_on_roebe?
11
+ # ========================================================================= #
12
+ def self.is_on_roebe?
13
+ ENV['IS_ROEBE'].to_s == '1'
14
+ end
15
+
16
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/toplevel_methods/is_on_windows.rb'
6
+ # =========================================================================== #
7
+ module Open
8
+
9
+ require 'open/toplevel_methods/host_os.rb'
10
+
11
+ # ========================================================================= #
12
+ # === Open.is_on_windows?
13
+ # ========================================================================= #
14
+ def self.is_on_windows?(
15
+ i = host_os?
16
+ )
17
+ case i # or: RUBY_PLATFORM
18
+ when /win/,
19
+ /mingw/
20
+ true
21
+ else
22
+ false
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'open/toplevel_methods/misc.rb'
6
+ # =========================================================================== #
7
+ module Open
8
+
9
+ require 'open/constants/constants.rb'
10
+
11
+ # ========================================================================= #
12
+ # === Open.write_what_into
13
+ #
14
+ # Delegate towards SaveFile.
15
+ # ========================================================================= #
16
+ def self.write_what_into(what, into)
17
+ ::SaveFile.write_what_into(what, into)
18
+ end
19
+
20
+ # ========================================================================= #
21
+ # === Open[]
22
+ #
23
+ # This method defaults to Open.in_editor(), but if the input starts
24
+ # with "http" then we will use Open.in_browser() instead.
25
+ #
26
+ # In January 2023 this was deprecated. It now resides in another file.
27
+ #
28
+ # Usage example:
29
+ #
30
+ # Open[TEST_THIS_FILE]
31
+ #
32
+ # ========================================================================= #
33
+ # def self.[](i = ARGV, &block)
34
+ # unless Open.respond_to? :in_browser
35
+ # require 'open/in_browser/in_browser.rb'
36
+ # end
37
+ # unless Open.respond_to? :in_editor
38
+ # require 'open/in_editor/in_editor.rb'
39
+ # end
40
+ # if i.is_a? Array
41
+ # i = i.join(' ').strip
42
+ # end
43
+ # if i.start_with? 'http'
44
+ # ::Open.in_browser(i, &block)
45
+ # else # this is the default
46
+ # ::Open.in_editor(i, &block)
47
+ # end
48
+ # end
49
+
50
+ end
@@ -9,11 +9,11 @@ module Open
9
9
  # ========================================================================= #
10
10
  # === VERSION
11
11
  # ========================================================================= #
12
- VERSION = '0.1.30'
12
+ VERSION = '0.2.13'
13
13
 
14
14
  # ========================================================================= #
15
15
  # === LAST_UPDATE
16
16
  # ========================================================================= #
17
- LAST_UPDATE = '16.05.2023'
17
+ LAST_UPDATE = '19.07.2023'
18
18
 
19
19
  end
@@ -54,13 +54,10 @@ class WithDelay < Base # === Open::WithDelay
54
54
  # ========================================================================= #
55
55
  def reset
56
56
  super()
57
+ infer_the_namespace
57
58
  set_default_delay # We need a default value for the delay to be set.
58
59
  determine_which_files_to_open
59
60
  # ======================================================================= #
60
- # === @namespace
61
- # ======================================================================= #
62
- @namespace = NAMESPACE
63
- # ======================================================================= #
64
61
  # === @pattern
65
62
  # ======================================================================= #
66
63
  @pattern = nil
@@ -139,14 +136,15 @@ class WithDelay < Base # === Open::WithDelay
139
136
  # === report_the_delay_in_use
140
137
  # ========================================================================= #
141
138
  def report_the_delay_in_use
142
- opnn; e "The delay is `#{simp(delay?.to_s)}` seconds."
139
+ opne "#{steelblue('The delay is `')}"\
140
+ "#{simp(delay?.to_s)}#{steelblue('` seconds.')}"
143
141
  end
144
142
 
145
143
  # ========================================================================= #
146
144
  # === menu (menu tag)
147
145
  # ========================================================================= #
148
146
  def menu(
149
- i = @commandline_arguments
147
+ i = commandline_arguments?
150
148
  )
151
149
  if i.is_a? Array
152
150
  i.each {|entry| menu(entry) }
@@ -223,12 +221,12 @@ class WithDelay < Base # === Open::WithDelay
223
221
  )
224
222
  using_this_editor = use_which_editor?
225
223
  delay = delay?.to_s
226
- opnn; e "We will open all #{sfancy(i.size.to_s)} files "\
227
- "in this directory."
224
+ opne "We will open all #{sfancy(i.size.to_s)} files "\
225
+ "in this directory."
228
226
  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."
227
+ opne 'Next opening the file `'+sfile(this_file)+
228
+ '` via the editor '+sfancy(using_this_editor)+','
229
+ opne "then sleeping for #{simp(delay)} seconds."
232
230
  Open.in_editor(this_file)
233
231
  sleep(delay.to_f) # Must be treated as a Float.
234
232
  }
data/open.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new { |s|
13
13
  DESCRIPTION = <<-EOF
14
14
 
15
15
  This project can be used to open an URL in a browser, usually
16
- via a browser such as firefo, palemoon or vivaldi. It can also be used
16
+ via a browser such as firefox, palemoon or vivaldi. It can also be used
17
17
  to open a local file in an editor. The latter has been a reason
18
18
  why the API was created in the first place, via Open.in_editor()
19
19
  or Open.in_browser().
data/test/testing_open.rb CHANGED
@@ -21,7 +21,7 @@ open_in_browser 'linux', '?pdf'
21
21
  open_in_browser 'http://localhost/programming/ruby/src/chemistry_paradise/lib/chemistry_paradise/www/chemistry/chemistry.cgi',
22
22
  'Absolutkonfiguration'
23
23
  e
24
- e 'Next testing the project called '+sfancy('open')+'.'
24
+ e "Next testing the project called #{sfancy('open')}."
25
25
  e
26
26
 
27
27
  e
@@ -0,0 +1,16 @@
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
+ alias e puts
8
+
9
+ e 'Testing various aspects of Open.in_browser() next.'
10
+ e
11
+ _ = '/home/x/Temp/studium/html/timetable.html#today'
12
+ e 'First, we need to test `'+_+'`.'
13
+ e
14
+ Open.in_browser(_)
15
+ Open.in_browser(:default_sinatra_port)
16
+ Open.in_browser(port: 8080) { :use_launchy } # This one will test "launchy".
@@ -0,0 +1,3 @@
1
+ require 'open'
2
+
3
+ Open.in_browser('https://blog.fefe.de/') { :use_launchy }
@@ -0,0 +1,3 @@
1
+ require 'open'
2
+
3
+ Open::Open[:gamebooks]
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.30
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert A. Heiler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-16 00:00:00.000000000 Z
11
+ date: 2023-07-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2+
14
14
 
15
15
  This project can be used to open an URL in a browser, usually
16
- via a browser such as firefo, palemoon or vivaldi. It can also be used
16
+ via a browser such as firefox, palemoon or vivaldi. It can also be used
17
17
  to open a local file in an editor. The latter has been a reason
18
18
  why the API was created in the first place, via Open.in_editor()
19
19
  or Open.in_browser().
@@ -30,19 +30,32 @@ files:
30
30
  - bin/open_these_files
31
31
  - bin/open_with_delay
32
32
  - doc/README.gen
33
+ - doc/deprecated_code/deprecated_code.md
34
+ - img/open_logo.png
33
35
  - lib/open.rb
34
36
  - lib/open/base/base.rb
37
+ - lib/open/books/README.md
38
+ - lib/open/books/books.rb
35
39
  - lib/open/constants/constants.rb
36
40
  - lib/open/in_browser/in_browser.rb
37
41
  - lib/open/in_editor/in_editor.rb
38
42
  - lib/open/last/last.rb
39
43
  - lib/open/last_url/last_url.rb
40
44
  - lib/open/nano_open/nano_open.rb
41
- - lib/open/open.rb
45
+ - lib/open/open/open.rb
42
46
  - lib/open/project/project.rb
47
+ - lib/open/requires/failsafe_require_of_beautiful_url.rb
43
48
  - lib/open/requires/require_the_project.rb
49
+ - lib/open/requires/require_yaml.rb
44
50
  - lib/open/these_files/these_files.rb
45
- - lib/open/toplevel_code/toplevel_code.rb
51
+ - lib/open/toplevel_methods/browser.rb
52
+ - lib/open/toplevel_methods/delay.rb
53
+ - lib/open/toplevel_methods/e.rb
54
+ - lib/open/toplevel_methods/editor.rb
55
+ - lib/open/toplevel_methods/host_os.rb
56
+ - lib/open/toplevel_methods/is_on_roebe.rb
57
+ - lib/open/toplevel_methods/is_on_windows.rb
58
+ - lib/open/toplevel_methods/misc.rb
46
59
  - lib/open/version/version.rb
47
60
  - lib/open/with_delay/with_delay.rb
48
61
  - lib/open/yaml/shortcuts.yml
@@ -51,6 +64,9 @@ files:
51
64
  - lib/open/yaml/use_this_editor.yml
52
65
  - open.gemspec
53
66
  - test/testing_open.rb
67
+ - test/testing_open_in_browser.rb
68
+ - test/testing_open_via_launchy.rb
69
+ - test/testing_shortcuts.rb
54
70
  homepage: https://rubygems.org/gems/open_in_browser
55
71
  licenses:
56
72
  - MIT
@@ -68,13 +84,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
84
  requirements:
69
85
  - - ">="
70
86
  - !ruby/object:Gem::Version
71
- version: 3.4.13
87
+ version: 3.4.15
72
88
  requirements: []
73
- rubygems_version: 3.4.13
89
+ rubygems_version: 3.4.15
74
90
  signing_key:
75
91
  specification_version: 4
76
92
  summary: This project can be used to open an URL in a browser, usually via a browser
77
- such as firefo, palemoon or vivaldi. It can also be used to open a local file in
93
+ such as firefox, palemoon or vivaldi. It can also be used to open a local file in
78
94
  an editor. The latter has been a reason why the API was created in the first place,
79
95
  via Open.in_editor() or Open.in_browser().
80
96
  test_files: []