launchy 3.0.0 → 3.1.0
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.
- checksums.yaml +4 -4
- data/HISTORY.md +13 -1
- data/Manifest.txt +3 -16
- data/exe/launchy +5 -0
- data/launchy.gemspec +33 -0
- data/lib/launchy/application.rb +24 -21
- data/lib/launchy/applications/browser.rb +68 -63
- data/lib/launchy/argv.rb +11 -6
- data/lib/launchy/cli.rb +29 -29
- data/lib/launchy/descendant_tracker.rb +14 -12
- data/lib/launchy/detect/host_os.rb +21 -18
- data/lib/launchy/detect/host_os_family.rb +94 -53
- data/lib/launchy/detect/nix_desktop_environment.rb +74 -69
- data/lib/launchy/detect.rb +7 -3
- data/lib/launchy/error.rb +2 -0
- data/lib/launchy/os_family.rb +2 -0
- data/lib/launchy/runner.rb +26 -17
- data/lib/launchy/version.rb +7 -5
- data/lib/launchy.rb +69 -65
- metadata +14 -96
- data/Rakefile +0 -29
- data/bin/launchy +0 -4
- data/spec/application_spec.rb +0 -43
- data/spec/applications/browser_spec.rb +0 -73
- data/spec/cli_spec.rb +0 -74
- data/spec/detect/host_os_family_spec.rb +0 -42
- data/spec/detect/host_os_spec.rb +0 -19
- data/spec/detect/nix_desktop_environment_spec.rb +0 -27
- data/spec/launchy_spec.rb +0 -142
- data/spec/mock_application.rb +0 -13
- data/spec/spec_helper.rb +0 -8
- data/spec/tattle-host-os.yaml +0 -427
- data/spec/version_spec.rb +0 -11
- data/tasks/default.rake +0 -250
- data/tasks/this.rb +0 -208
- /data/{LICENSE → LICENSE.txt} +0 -0
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: launchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Hinegardner
|
8
|
-
|
9
|
-
bindir: bin
|
8
|
+
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-24 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: addressable
|
@@ -39,75 +38,19 @@ dependencies:
|
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '5.0'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
41
|
+
name: logger
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '13.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.21'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.21'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest-junit
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rdoc
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '6.6'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '6.6'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: simplecov
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0.22'
|
104
|
-
type: :development
|
46
|
+
version: '1.6'
|
47
|
+
type: :runtime
|
105
48
|
prerelease: false
|
106
49
|
version_requirements: !ruby/object:Gem::Requirement
|
107
50
|
requirements:
|
108
51
|
- - "~>"
|
109
52
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
53
|
+
version: '1.6'
|
111
54
|
description: Launchy is helper class for launching cross-platform applications in
|
112
55
|
a fire and forget manner. There are application concepts (browser, email client,
|
113
56
|
etc) that are common across all platforms, and they may be launched differently
|
@@ -120,16 +63,17 @@ extensions: []
|
|
120
63
|
extra_rdoc_files:
|
121
64
|
- CONTRIBUTING.md
|
122
65
|
- HISTORY.md
|
66
|
+
- LICENSE.txt
|
123
67
|
- Manifest.txt
|
124
68
|
- README.md
|
125
69
|
files:
|
126
70
|
- CONTRIBUTING.md
|
127
71
|
- HISTORY.md
|
128
|
-
- LICENSE
|
72
|
+
- LICENSE.txt
|
129
73
|
- Manifest.txt
|
130
74
|
- README.md
|
131
|
-
-
|
132
|
-
-
|
75
|
+
- exe/launchy
|
76
|
+
- launchy.gemspec
|
133
77
|
- lib/launchy.rb
|
134
78
|
- lib/launchy/application.rb
|
135
79
|
- lib/launchy/applications/browser.rb
|
@@ -144,28 +88,14 @@ files:
|
|
144
88
|
- lib/launchy/os_family.rb
|
145
89
|
- lib/launchy/runner.rb
|
146
90
|
- lib/launchy/version.rb
|
147
|
-
- spec/application_spec.rb
|
148
|
-
- spec/applications/browser_spec.rb
|
149
|
-
- spec/cli_spec.rb
|
150
|
-
- spec/detect/host_os_family_spec.rb
|
151
|
-
- spec/detect/host_os_spec.rb
|
152
|
-
- spec/detect/nix_desktop_environment_spec.rb
|
153
|
-
- spec/launchy_spec.rb
|
154
|
-
- spec/mock_application.rb
|
155
|
-
- spec/spec_helper.rb
|
156
|
-
- spec/tattle-host-os.yaml
|
157
|
-
- spec/version_spec.rb
|
158
|
-
- tasks/default.rake
|
159
|
-
- tasks/this.rb
|
160
91
|
homepage: https://github.com/copiousfreetime/launchy
|
161
92
|
licenses:
|
162
93
|
- ISC
|
163
94
|
metadata:
|
164
95
|
bug_tracker_uri: https://github.com/copiousfreetime/launchy/issues
|
165
|
-
changelog_uri: https://github.com/copiousfreetime/launchy/blob/master/
|
96
|
+
changelog_uri: https://github.com/copiousfreetime/launchy/blob/master/HISTORY.md
|
166
97
|
homepage_uri: https://github.com/copiousfreetime/launchy
|
167
98
|
source_code_uri: https://github.com/copiousfreetime/launchy
|
168
|
-
post_install_message:
|
169
99
|
rdoc_options:
|
170
100
|
- "--main"
|
171
101
|
- README.md
|
@@ -184,20 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
114
|
- !ruby/object:Gem::Version
|
185
115
|
version: '0'
|
186
116
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
188
|
-
signing_key:
|
117
|
+
rubygems_version: 3.6.3
|
189
118
|
specification_version: 4
|
190
119
|
summary: Launchy is helper class for launching cross-platform applications in a fire
|
191
120
|
and forget manner.
|
192
|
-
test_files:
|
193
|
-
- spec/application_spec.rb
|
194
|
-
- spec/applications/browser_spec.rb
|
195
|
-
- spec/cli_spec.rb
|
196
|
-
- spec/detect/host_os_family_spec.rb
|
197
|
-
- spec/detect/host_os_spec.rb
|
198
|
-
- spec/detect/nix_desktop_environment_spec.rb
|
199
|
-
- spec/launchy_spec.rb
|
200
|
-
- spec/mock_application.rb
|
201
|
-
- spec/spec_helper.rb
|
202
|
-
- spec/tattle-host-os.yaml
|
203
|
-
- spec/version_spec.rb
|
121
|
+
test_files: []
|
data/Rakefile
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# vim: syntax=ruby
|
2
|
-
load 'tasks/this.rb'
|
3
|
-
|
4
|
-
This.name = "launchy"
|
5
|
-
This.author = "Jeremy Hinegardner"
|
6
|
-
This.email = "jeremy@copiousfreetime.org"
|
7
|
-
This.homepage = "https://github.com/copiousfreetime/#{ This.name }"
|
8
|
-
|
9
|
-
This.ruby_gemspec do |spec|
|
10
|
-
spec.add_dependency( 'addressable', '~> 2.8')
|
11
|
-
spec.add_dependency( 'childprocess', '~> 5.0')
|
12
|
-
|
13
|
-
spec.add_development_dependency( 'rake' , '~> 13.0')
|
14
|
-
spec.add_development_dependency( 'minitest' , '~> 5.21' )
|
15
|
-
spec.add_development_dependency( 'minitest-junit' , '~> 1.0' )
|
16
|
-
spec.add_development_dependency( 'rdoc' , '~> 6.6' )
|
17
|
-
spec.add_development_dependency( 'simplecov', '~> 0.22' )
|
18
|
-
|
19
|
-
spec.licenses = ['ISC']
|
20
|
-
|
21
|
-
spec.metadata = {
|
22
|
-
"bug_tracker_uri" => "https://github.com/copiousfreetime/launchy/issues",
|
23
|
-
"changelog_uri" => "https://github.com/copiousfreetime/launchy/blob/master/README.md",
|
24
|
-
"homepage_uri" => "https://github.com/copiousfreetime/launchy",
|
25
|
-
"source_code_uri" => "https://github.com/copiousfreetime/launchy",
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
load 'tasks/default.rake'
|
data/bin/launchy
DELETED
data/spec/application_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'mock_application'
|
3
|
-
|
4
|
-
class JunkApp < Launchy::Application
|
5
|
-
def self.handles?( uri )
|
6
|
-
uri.scheme == "junk"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe Launchy::Application do
|
11
|
-
it 'registers inherited classes' do
|
12
|
-
class Junk2App < Launchy::Application
|
13
|
-
def self.handles?( uri )
|
14
|
-
uri.scheme == "junk2"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
_(Launchy::Application.children).must_include( Junk2App )
|
18
|
-
Launchy::Application.children.delete( Junk2App )
|
19
|
-
end
|
20
|
-
|
21
|
-
it "can find an app" do
|
22
|
-
_(Launchy::Application.children).must_include( JunkApp )
|
23
|
-
_(Launchy::Application.children.size).must_equal 3
|
24
|
-
uri = Addressable::URI.parse( "junk:///foo" )
|
25
|
-
_(Launchy::Application.handling( uri )).must_equal( JunkApp )
|
26
|
-
end
|
27
|
-
|
28
|
-
it "raises an error if an application cannot be found for the given scheme" do
|
29
|
-
uri = Addressable::URI.parse( "foo:///bar" )
|
30
|
-
_(lambda { Launchy::Application.handling( uri ) }).must_raise( Launchy::ApplicationNotFoundError )
|
31
|
-
end
|
32
|
-
|
33
|
-
it "can find open or curl or xdg-open" do
|
34
|
-
found = %w[ open curl xdg-open ].any? do |app|
|
35
|
-
Launchy::Application.find_executable( app )
|
36
|
-
end
|
37
|
-
_(found).must_equal true
|
38
|
-
end
|
39
|
-
|
40
|
-
it "does not find xyzzy" do
|
41
|
-
_(Launchy::Application.find_executable( "xyzzy" )).must_be_nil
|
42
|
-
end
|
43
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Launchy::Application::Browser do
|
4
|
-
before do
|
5
|
-
Launchy.reset_global_options
|
6
|
-
ENV['KDE_FULL_SESSION'] = "launchy"
|
7
|
-
@test_url = "http://example.com/"
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
Launchy.reset_global_options
|
12
|
-
ENV.delete( 'KDE_FULL_SESSION' )
|
13
|
-
ENV.delete( 'BROWSER' )
|
14
|
-
end
|
15
|
-
|
16
|
-
{ 'windows' => 'windows_app_list',
|
17
|
-
'darwin' => 'darwin_app_list',
|
18
|
-
'cygwin' => 'cygwin_app_list',
|
19
|
-
'linux' => 'nix_app_list',
|
20
|
-
}.each do |host_os, called_method|
|
21
|
-
it "when host_os is '#{host_os}' the '#{called_method}' method is called" do
|
22
|
-
Launchy.host_os = host_os
|
23
|
-
browser = Launchy::Application::Browser.new
|
24
|
-
browser.stub(called_method, [:called_me]) do
|
25
|
-
item = browser.app_list.first
|
26
|
-
_(item).must_equal :called_me
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
%w[ linux windows darwin cygwin ].each do |host_os|
|
32
|
-
it "the BROWSER environment variable overrides any host defaults on '#{host_os}'" do
|
33
|
-
ENV['BROWSER'] = "my_special_browser --new-tab '%s'"
|
34
|
-
Launchy.host_os = host_os
|
35
|
-
browser = Launchy::Application::Browser.new
|
36
|
-
cmd, args = browser.cmd_and_args( @test_url )
|
37
|
-
_(cmd).must_equal "my_special_browser --new-tab 'http://example.com/'"
|
38
|
-
_(args).must_equal []
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it "handles a file on the file system when there is no file:// scheme" do
|
43
|
-
uri = Addressable::URI.parse( __FILE__ )
|
44
|
-
_(Launchy::Application::Browser.handles?( uri )).must_equal true
|
45
|
-
end
|
46
|
-
|
47
|
-
it "handles the case where $BROWSER is set and no *nix desktop environment is found" do
|
48
|
-
ENV.delete( "KDE_FULL_SESSION" )
|
49
|
-
ENV.delete( "GNOME_DESKTOP_SESSION_ID" )
|
50
|
-
ENV['BROWSER'] = "do-this-instead"
|
51
|
-
Launchy.host_os = 'linux'
|
52
|
-
browser = Launchy::Application::Browser.new
|
53
|
-
_(browser.browser_cmdline).must_equal "do-this-instead"
|
54
|
-
end
|
55
|
-
|
56
|
-
# NOTE: Unable to figure out how capture the stderr from the child which has
|
57
|
-
# moved it at least once. This test just serves the purpose of noting why
|
58
|
-
# something happens, and the problem we are attempting to fix.
|
59
|
-
#it "When BROWSER is set to something that is not executable, error still appears on stderr" do
|
60
|
-
# ENV['BROWSER'] = "not-an-app"
|
61
|
-
# url = "http://example.com/"
|
62
|
-
|
63
|
-
# _, err = capture_subprocess_io do
|
64
|
-
# begin
|
65
|
-
# Launchy.open( url )
|
66
|
-
# rescue => nil
|
67
|
-
# end
|
68
|
-
# end
|
69
|
-
# #_(err).must_match( /wibble/m )
|
70
|
-
# err # something
|
71
|
-
#end
|
72
|
-
end
|
73
|
-
|
data/spec/cli_spec.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Launchy::Cli do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@old_stderr = $stderr
|
7
|
-
$stderr = StringIO.new
|
8
|
-
|
9
|
-
@old_stdout = $stdout
|
10
|
-
$stdout = StringIO.new
|
11
|
-
Launchy.reset_global_options
|
12
|
-
end
|
13
|
-
|
14
|
-
after do
|
15
|
-
Launchy.reset_global_options
|
16
|
-
$stderr = @old_stderr
|
17
|
-
$stdout = @old_stdout
|
18
|
-
end
|
19
|
-
|
20
|
-
def cli_test( argv, env, exit_val, stderr_regex, stdout_regex )
|
21
|
-
begin
|
22
|
-
Launchy::Cli.new.run( argv, env )
|
23
|
-
rescue SystemExit => se
|
24
|
-
_(se.status).must_equal exit_val
|
25
|
-
_($stderr.string).must_match stderr_regex if stderr_regex
|
26
|
-
_($stdout.string).must_match stdout_regex if stdout_regex
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "exits 1 when invalid options are given" do
|
31
|
-
cli_test( %w[ -z foo ], {}, 1, /invalid option/, nil )
|
32
|
-
end
|
33
|
-
|
34
|
-
%w[ -h --help ].each do |opt|
|
35
|
-
it "output help and exits 0 when using #{opt}" do
|
36
|
-
cli_test( [ opt ], {}, 0, nil, /Print this message/m )
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
%w[ -v --version ].each do |opt|
|
41
|
-
it "outputs version and exits 0 when using #{opt}" do
|
42
|
-
cli_test( [ opt ], {}, 0, nil, /Launchy version/ )
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "leaves the url on argv after parsing" do
|
47
|
-
l = Launchy::Cli.new
|
48
|
-
argv = %w[ --debug --dry-run https://github.com/copiousfreetime/launchy ]
|
49
|
-
l.parse( argv , {} )
|
50
|
-
_(argv.size).must_equal 1
|
51
|
-
_(argv[0]).must_equal "https://github.com/copiousfreetime/launchy"
|
52
|
-
end
|
53
|
-
|
54
|
-
it "prints the command on stdout when using --dry-run" do
|
55
|
-
argv = %w[ --debug --dry-run https://github.com/copiousfreetime/launchy ]
|
56
|
-
Launchy::Cli.new.good_run( argv, {} )
|
57
|
-
_($stdout.string).must_match %r[github.com]
|
58
|
-
end
|
59
|
-
|
60
|
-
{
|
61
|
-
'--application' => [ :application, 'Browser'],
|
62
|
-
'--host-os' => [ :host_os, 'cygwin'] }.each_pair do |opt, val|
|
63
|
-
it "the commandline option #{opt} sets the program option #{val[0]}" do
|
64
|
-
argv = [ opt, val[1], "https://github.com/copiousfreetime/launchy" ]
|
65
|
-
l = Launchy::Cli.new
|
66
|
-
rc = l.parse( argv, {} )
|
67
|
-
_(rc).must_equal true
|
68
|
-
_(argv.size).must_equal 1
|
69
|
-
_(argv[0]).must_equal "https://github.com/copiousfreetime/launchy"
|
70
|
-
_(l.options[val[0]]).must_equal val[1]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
describe Launchy::Detect::HostOsFamily do
|
5
|
-
|
6
|
-
before do
|
7
|
-
Launchy.reset_global_options
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
Launchy.reset_global_options
|
12
|
-
end
|
13
|
-
|
14
|
-
YAML::load( IO.read( File.expand_path( "../../tattle-host-os.yaml", __FILE__ ) ) )['host_os'].keys.sort.each do |os|
|
15
|
-
it "OS family of #{os} is detected" do
|
16
|
-
os_family = Launchy::Detect::HostOsFamily.detect( os )
|
17
|
-
_(os_family).must_be_kind_of Launchy::Detect::HostOsFamily
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
{ 'mswin' => :windows?,
|
22
|
-
'darwin' => :darwin?,
|
23
|
-
'linux' => :nix?,
|
24
|
-
'cygwin' => :cygwin? }.each_pair do |os, method|
|
25
|
-
it "#{method} returns true for #{os} " do
|
26
|
-
r = Launchy::Detect::HostOsFamily.detect( os ).send( method )
|
27
|
-
_(r).must_equal true
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
it "uses the global host_os overrides" do
|
32
|
-
ENV['LAUNCHY_HOST_OS'] = "fake-os-2"
|
33
|
-
_(lambda { Launchy::Detect::HostOsFamily.detect }).must_raise Launchy::Detect::HostOsFamily::NotFoundError
|
34
|
-
ENV.delete('LAUNCHY_HOST_OS')
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
it "does not find an os of 'dos'" do
|
39
|
-
_(lambda { Launchy::Detect::HostOsFamily.detect( 'dos' ) }).must_raise Launchy::Detect::HostOsFamily::NotFoundError
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
data/spec/detect/host_os_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Launchy::Detect::HostOs do
|
4
|
-
|
5
|
-
it "uses the defult host os from ruby's config" do
|
6
|
-
_(Launchy::Detect::HostOs.new.host_os).must_equal RbConfig::CONFIG['host_os']
|
7
|
-
end
|
8
|
-
|
9
|
-
it "uses the passed in value as the host os" do
|
10
|
-
_(Launchy::Detect::HostOs.new( "fake-os-1").host_os).must_equal "fake-os-1"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "uses the environment variable LAUNCHY_HOST_OS to override ruby's config" do
|
14
|
-
ENV['LAUNCHY_HOST_OS'] = "fake-os-2"
|
15
|
-
_(Launchy::Detect::HostOs.new.host_os).must_equal "fake-os-2"
|
16
|
-
ENV.delete('LAUNCHY_HOST_OS')
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Launchy::Detect::NixDesktopEnvironment do
|
4
|
-
|
5
|
-
before do
|
6
|
-
Launchy.reset_global_options
|
7
|
-
end
|
8
|
-
|
9
|
-
after do
|
10
|
-
Launchy.reset_global_options
|
11
|
-
end
|
12
|
-
|
13
|
-
it "returns false for XFCE if xprop is not found" do
|
14
|
-
Launchy.host_os = "linux"
|
15
|
-
_(Launchy::Detect::NixDesktopEnvironment::Xfce.is_current_desktop_environment?).must_equal( false )
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns NotFound if it cannot determine the *nix desktop environment" do
|
19
|
-
Launchy.host_os = "linux"
|
20
|
-
ENV.delete( "KDE_FULL_SESSION" )
|
21
|
-
ENV.delete( "GNOME_DESKTOP_SESSION_ID" )
|
22
|
-
Launchy.path = %w[ / /tmp ].join(File::PATH_SEPARATOR)
|
23
|
-
not_found = Launchy::Detect::NixDesktopEnvironment.detect
|
24
|
-
_(not_found).must_equal( Launchy::Detect::NixDesktopEnvironment::NotFound )
|
25
|
-
_(not_found.browser).must_equal( Launchy::Argv.new )
|
26
|
-
end
|
27
|
-
end
|
data/spec/launchy_spec.rb
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'pathname'
|
3
|
-
require 'mock_application'
|
4
|
-
|
5
|
-
describe Launchy do
|
6
|
-
|
7
|
-
before do
|
8
|
-
Launchy.reset_global_options
|
9
|
-
@stderr = $stderr
|
10
|
-
$stderr = StringIO.new
|
11
|
-
@stdout = $stdout
|
12
|
-
$stdout = StringIO.new
|
13
|
-
@invalid_url = 'blah://example.com/invalid'
|
14
|
-
end
|
15
|
-
|
16
|
-
after do
|
17
|
-
Launchy.reset_global_options
|
18
|
-
$stderr = @stderr
|
19
|
-
$stdout = @stdout
|
20
|
-
end
|
21
|
-
|
22
|
-
it "logs to stderr when LAUNCHY_DEBUG environment variable is set" do
|
23
|
-
ENV["LAUNCHY_DEBUG"] = 'true'
|
24
|
-
old_stderr = $stderr
|
25
|
-
$stderr = StringIO.new
|
26
|
-
Launchy.log "This is a test log message"
|
27
|
-
_($stderr.string.strip).must_equal "LAUNCHY_DEBUG: This is a test log message"
|
28
|
-
$stderr = old_stderr
|
29
|
-
ENV["LAUNCHY_DEBUG"] = nil
|
30
|
-
end
|
31
|
-
|
32
|
-
it "sets the global option :dry_run to true if LAUNCHY_DRY_RUN environment variable is 'true'" do
|
33
|
-
ENV['LAUNCHY_DRY_RUN'] = 'true'
|
34
|
-
Launchy.extract_global_options({})
|
35
|
-
_(Launchy.dry_run?).must_equal true
|
36
|
-
ENV['LAUNCHY_DRY_RUN'] = nil
|
37
|
-
end
|
38
|
-
|
39
|
-
it "sets the global option :debug to true if LAUNCHY_DEBUG environment variable is 'true'" do
|
40
|
-
ENV['LAUNCHY_DEBUG'] = 'true'
|
41
|
-
Launchy.extract_global_options({})
|
42
|
-
_(Launchy.debug?).must_equal true
|
43
|
-
ENV['LAUNCHY_DEBUG'] = nil
|
44
|
-
end
|
45
|
-
|
46
|
-
it "has the global option :debug" do
|
47
|
-
Launchy.extract_global_options( { :debug => 'true' } )
|
48
|
-
_(Launchy.debug?).must_equal true
|
49
|
-
Launchy.extract_global_options( { :debug => true } )
|
50
|
-
_(Launchy.debug?).must_equal true
|
51
|
-
end
|
52
|
-
|
53
|
-
it "has the global option :dry_run" do
|
54
|
-
Launchy.extract_global_options( { :dry_run => 'true' } )
|
55
|
-
_(Launchy.dry_run?).must_equal true
|
56
|
-
Launchy.extract_global_options( { :dry_run => true } )
|
57
|
-
_(Launchy.dry_run?).must_equal true
|
58
|
-
end
|
59
|
-
|
60
|
-
it "has the global option :application" do
|
61
|
-
Launchy.extract_global_options( { :application => "wibble" } )
|
62
|
-
_(Launchy.application).must_equal 'wibble'
|
63
|
-
end
|
64
|
-
|
65
|
-
it "has the global option :host_os" do
|
66
|
-
Launchy.extract_global_options( { :host_os => "my-special-os-v2" } )
|
67
|
-
_(Launchy.host_os).must_equal 'my-special-os-v2'
|
68
|
-
end
|
69
|
-
|
70
|
-
it "raises an exception if no scheme is found for the given uri" do
|
71
|
-
_(lambda { Launchy.open( @invalid_url ) }).must_raise Launchy::ApplicationNotFoundError
|
72
|
-
end
|
73
|
-
|
74
|
-
it "raises an exepction if the browser failed to launch" do
|
75
|
-
skip("because headless CI") if ENV["CI"] == "true"
|
76
|
-
caught = nil
|
77
|
-
Launchy.open( @invalid_url, application: "browser") do |exception|
|
78
|
-
caught = exception
|
79
|
-
end
|
80
|
-
_(caught).must_be_kind_of Launchy::Error
|
81
|
-
end
|
82
|
-
|
83
|
-
it "asssumes we open a local file if we have an exception if we have an invalid scheme and a valid path" do
|
84
|
-
uri = "blah://example.com/#{__FILE__}"
|
85
|
-
Launchy.open( uri , :dry_run => true )
|
86
|
-
parts = $stdout.string.strip.split
|
87
|
-
_(parts.size).must_be :>, 1
|
88
|
-
_(parts.last).must_equal uri
|
89
|
-
end
|
90
|
-
|
91
|
-
it "opens a local file if we have a drive letter and a valid path on windows" do
|
92
|
-
uri = "C:#{__FILE__}"
|
93
|
-
Launchy.open( uri, :dry_run => true, :host_os => 'windows' )
|
94
|
-
_($stdout.string.strip).must_equal 'start launchy /b ' + uri
|
95
|
-
end
|
96
|
-
|
97
|
-
it "opens a data url with a forced browser application" do
|
98
|
-
uri = "data:text/html,hello%20world"
|
99
|
-
Launchy.open( uri, :dry_run => true, :application => "browser" )
|
100
|
-
_($stdout.string.strip).must_match(/open/) # /usr/bin/open or xdg-open
|
101
|
-
end
|
102
|
-
|
103
|
-
it "calls the block if instead of raising an exception if there is an error" do
|
104
|
-
Launchy.open( @invalid_url ) { $stderr.puts "oops had an error opening #{@invalid_url}" }
|
105
|
-
_($stderr.string.strip).must_equal "oops had an error opening #{@invalid_url}"
|
106
|
-
end
|
107
|
-
|
108
|
-
it "calls the block with the values passed to launchy and the error" do
|
109
|
-
options = { :dry_run => true }
|
110
|
-
Launchy.open( @invalid_url, :dry_run => true ) { |e| $stderr.puts "had an error opening #{@invalid_url} with options #{options}: #{e}" }
|
111
|
-
_($stderr.string.strip).must_equal "had an error opening #{@invalid_url} with options #{options}: No application found to handle '#{@invalid_url}'"
|
112
|
-
end
|
113
|
-
|
114
|
-
it "raises the error in the called block" do
|
115
|
-
_(lambda { Launchy.open( @invalid_url ) { raise StandardError, "KABOOM!" } }).must_raise StandardError
|
116
|
-
end
|
117
|
-
|
118
|
-
it "can force a specific application to be used" do
|
119
|
-
result = Launchy.open( "http://example.com", :application => "mockapplication" )
|
120
|
-
_(result).must_equal "MockApplication opened http://example.com"
|
121
|
-
end
|
122
|
-
|
123
|
-
[ 'www.example.com', 'www.example.com/foo/bar', "C:#{__FILE__}" ].each do |x|
|
124
|
-
it "picks a Browser for #{x}" do
|
125
|
-
app = Launchy.app_for_uri_string( x )
|
126
|
-
_(app).must_equal( Launchy::Application::Browser )
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
it "can use a Pathname as the URI" do
|
131
|
-
path = Pathname.new( Dir.pwd )
|
132
|
-
app = Launchy.app_for_uri_string( path )
|
133
|
-
_(app).must_equal( Launchy::Application::Browser )
|
134
|
-
end
|
135
|
-
|
136
|
-
[ "BROWSER", "bRoWsEr", "browser", "Browser" ].each do |x|
|
137
|
-
it "can find the browser by name #{x}" do
|
138
|
-
app = Launchy.app_for_name( x )
|
139
|
-
_(app).must_equal( Launchy::Application::Browser )
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
data/spec/mock_application.rb
DELETED