launchy 2.4.3 → 2.5.2
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 +5 -5
- data/CONTRIBUTING.md +5 -3
- data/HISTORY.md +32 -20
- data/LICENSE +2 -2
- data/README.md +45 -15
- data/Rakefile +13 -11
- data/lib/launchy/application.rb +1 -1
- data/lib/launchy/applications/browser.rb +2 -2
- data/lib/launchy/detect/nix_desktop_environment.rb +4 -3
- data/lib/launchy/detect/runner.rb +2 -2
- data/lib/launchy/version.rb +1 -1
- data/lib/launchy.rb +12 -1
- data/spec/application_spec.rb +7 -7
- data/spec/applications/browser_spec.rb +27 -22
- data/spec/cli_spec.rb +13 -13
- data/spec/detect/host_os_family_spec.rb +6 -4
- data/spec/detect/host_os_spec.rb +3 -3
- data/spec/detect/nix_desktop_environment_spec.rb +4 -13
- data/spec/detect/ruby_engine_spec.rb +4 -4
- data/spec/detect/runner_spec.rb +14 -14
- data/spec/launchy_spec.rb +26 -17
- data/spec/version_spec.rb +3 -3
- data/tasks/default.rake +28 -58
- data/tasks/this.rb +19 -20
- metadata +36 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 04d9c66ec0c8dcc2892bc46267fe37f7f1c82d14dad78d62c8adbd869a0d8a0f
|
4
|
+
data.tar.gz: ecf5f8096d6f3ef2a4d9118b18086eba83ed62f50362c1964938faba8d53d624
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4abd13c2b9c600a9e2a50d07a2a8bfbe6ae21de1972063520669f558b5b7f3eca6dc5e4a2de63d1a19c6dcdeb43a53bddc22da210556a2a6c64ba263afed92ec
|
7
|
+
data.tar.gz: 53feae60f4355edcddaa16497c5606f35eaccabd81d21f35d91ac3188314affd43f722970fe4c31249a89fbfadf7afc74579ee7d97f4740f1d339b0007a577e5
|
data/CONTRIBUTING.md
CHANGED
@@ -27,9 +27,9 @@ easiest way to contribute.
|
|
27
27
|
* Fork the [repo][].
|
28
28
|
* Create a new branch for your issue: `git checkout -b issue/my-issue`
|
29
29
|
* Lovingly craft your contribution:
|
30
|
-
* `rake develop` to get started
|
31
|
-
* `rake test` to run tests
|
32
|
-
* Make sure that `rake test` passes. It's important, I said it twice.
|
30
|
+
* `rake develop` to get started
|
31
|
+
* `bundle exec rake test` to run tests
|
32
|
+
* Make sure that `bundle exec rake test` passes. It's important, I said it twice.
|
33
33
|
* Add yourself to the contributors section below.
|
34
34
|
* Submit your [pull request][].
|
35
35
|
|
@@ -50,6 +50,8 @@ easiest way to contribute.
|
|
50
50
|
* [Cédric Félizard](https://github.com/infertux)
|
51
51
|
* [Daniel Farina](https://github.com/fdr)
|
52
52
|
* [Jack Turnbull](https://github.com/jackturnbull)
|
53
|
+
* [Jeremy Moritz](https://github.com/jeremymoritz)
|
54
|
+
* [Jamie Donnelly](https://github.com/JamieKDonnelly)
|
53
55
|
|
54
56
|
[GitHub Account]: https://github.com/signup/free "GitHub Signup"
|
55
57
|
[GitHub Issues]: https://github.com/copiousfreetime/launchy/issues "Launchy Issues"
|
data/HISTORY.md
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
# Launchy Changelog
|
2
|
+
## Version 2.5.2 - 2022-12-27
|
3
|
+
* Update Addressable - <https://github.com/copiousfreetime/launchy/pull/145> - JamieKDonnelly
|
4
|
+
* Fix deprecated usage of `Object#=~` - <https://github.com/copiousfreetime/launchy/pull/138> - marcrohloff
|
5
|
+
* Move to sempahore for matrix builds and macos tests
|
6
|
+
|
7
|
+
## Version 2.5.0 - 2020-02-27
|
8
|
+
* Update depedencies
|
9
|
+
* Update minimum ruby level
|
10
|
+
* Move to `kde-open` on KDE - <https://github.com/copiousfreetime/launchy/pull/105> - wstephenson
|
11
|
+
* Applied some grammer / spelling fixes - <https://github.com/copiousfreetime/launchy/pull/130> - jeremymoritz
|
12
|
+
* `Pathname` instances do not raise exceptions when opening local files - <https://github.com/copiousfreetime/launchy/issues/101> - dmke
|
13
|
+
* Add a fallback console browsers - <https://github.com/copiousfreetime/launchy/issues/93> - trejkaz
|
2
14
|
|
3
15
|
## Version 2.4.3 - 2014-11-03
|
4
16
|
* Update documentation - <https://github.com/copiousfreetime/launchy/pull/81> - supremebeing7
|
@@ -13,12 +25,12 @@
|
|
13
25
|
* Abstract out the argv of the commandline - <https://github.com/copiousfreetime/launchy/issues/71>
|
14
26
|
|
15
27
|
## Version 2.4.0 - 2013-11-12
|
16
|
-
* Support `Launchy.open( url, :debug => true )` - <
|
17
|
-
* Fix inconsistencies in `debug?` and `dry_run?` methods - <
|
18
|
-
* Fix detection of missing *nix desktops - <
|
19
|
-
* Fix running tests in bare Linux environment - <
|
20
|
-
* Fix mistaking windows drive as uri schema - <
|
21
|
-
* Attempt fixing windows `start` command oddities, again - <
|
28
|
+
* Support `Launchy.open( url, :debug => true )` - <https://github.com/copiousfreetime/launchy/issues/63> - schmich
|
29
|
+
* Fix inconsistencies in `debug?` and `dry_run?` methods - <https://github.com/copiousfreetime/launchy/issues/63> - schmich
|
30
|
+
* Fix detection of missing *nix desktops - <https://github.com/copiousfreetime/launchy/issues/70>
|
31
|
+
* Fix running tests in bare Linux environment - <https://github.com/copiousfreetime/launchy/issues/67> - gioele
|
32
|
+
* Fix mistaking windows drive as uri schema - <https://github.com/copiousfreetime/launchy/issues/65>
|
33
|
+
* Attempt fixing windows `start` command oddities, again - <https://github.com/copiousfreetime/launchy/issues/62>
|
22
34
|
|
23
35
|
## Version 2.3.0 - 2013-04-11
|
24
36
|
|
@@ -26,39 +38,39 @@
|
|
26
38
|
|
27
39
|
## Version 2.2.0 - 2013-02-06
|
28
40
|
|
29
|
-
* Change XFCE detection to not depend on grep <
|
30
|
-
* Suppress forked process output <
|
31
|
-
* Display help/usage if no url is given <
|
32
|
-
* Detect the fluxbox environment <
|
33
|
-
* Automatically detect `http` url's if they are missing the `http://` <
|
41
|
+
* Change XFCE detection to not depend on grep <https://github.com/copiousfreetime/launchy/issues/52> - bogdan
|
42
|
+
* Suppress forked process output <https://github.com/copiousfreetime/launchy/issues/51>
|
43
|
+
* Display help/usage if no url is given <https://github.com/copiousfreetime/launchy/issues/54>
|
44
|
+
* Detect the fluxbox environment <https://github.com/copiousfreetime/launchy/issues/53>
|
45
|
+
* Automatically detect `http` url's if they are missing the `http://` <https://github.com/copiousfreetime/launchy/issues/55>
|
34
46
|
* Update to latest project management rake tasks
|
35
47
|
|
36
48
|
## Version 2.1.2 - 2012-08-06
|
37
49
|
|
38
|
-
* Fix where HostOS would fail to convert to string on JRuby in 1.9 mode <
|
50
|
+
* Fix where HostOS would fail to convert to string on JRuby in 1.9 mode <https://github.com/copiousfreetime/launchy/issues/45>
|
39
51
|
|
40
52
|
## Version 2.1.1 - 2012-07-28
|
41
53
|
|
42
|
-
* Update addressable runtime dependency <
|
54
|
+
* Update addressable runtime dependency <https://github.com/copiousfreetime/launchy/issues/47>
|
43
55
|
* Bring minitest and ffi development dependencies up to date
|
44
56
|
|
45
57
|
## Version 2.1.0 - 2012-03-18
|
46
58
|
|
47
|
-
* Fix raising exception when no browser program found <
|
59
|
+
* Fix raising exception when no browser program found <https://github.com/copiousfreetime/launchy/issues/42>
|
48
60
|
* Add `LAUNCHY_DRY_RUN` environment variable (Mariusz Pietrzyk / wijet)
|
49
61
|
* Update dependencies
|
50
62
|
|
51
63
|
## Version 2.0.5 - 2011-07-24
|
52
64
|
|
53
|
-
* Fix the case where `$BROWSER` is set and no *nix desktop was found <
|
65
|
+
* Fix the case where `$BROWSER` is set and no *nix desktop was found <https://github.com/copiousfreetime/launchy/issues/33>
|
54
66
|
|
55
67
|
## Version 2.0.4 - 2011-07-23
|
56
68
|
|
57
|
-
* Fix windows `start` commandline <
|
58
|
-
* Add capability to open local files with no file: scheme present <
|
59
|
-
* Added `rake how_to_contribute` task <
|
60
|
-
* Make better decisions on when to do shell escaping <
|
61
|
-
* Switch to Addressable::URI so UTF-8 urls may be parsed. <
|
69
|
+
* Fix windows `start` commandline <https://github.com/copiousfreetime/launchy/issues/5>
|
70
|
+
* Add capability to open local files with no file: scheme present <https://github.com/copiousfreetime/launchy/issues/29>
|
71
|
+
* Added `rake how_to_contribute` task <https://github.com/copiousfreetime/launchy/issues/30>
|
72
|
+
* Make better decisions on when to do shell escaping <https://github.com/copiousfreetime/launchy/issues/31>
|
73
|
+
* Switch to Addressable::URI so UTF-8 urls may be parsed. <https://github.com/copiousfreetime/launchy/issues/32>
|
62
74
|
|
63
75
|
## Version 2.0.3 - 2011-07-17
|
64
76
|
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
ISC LICENSE -
|
1
|
+
ISC LICENSE - https://opensource.org/licenses/isc-license.txt
|
2
2
|
|
3
|
-
Copyright (c) 2007-
|
3
|
+
Copyright (c) 2007-2020 Jeremy Hinegardner
|
4
4
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
6
6
|
purpose with or without fee is hereby granted, provided that the above
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# launchy
|
2
2
|
|
3
|
+
[](https://copiousfreetime.semaphoreci.com/projects/launchy)
|
4
|
+
|
3
5
|
* [Homepage](https://github.com/copiousfreetime/launchy)
|
4
6
|
* [Github Project](https://github.com/copiousfreetime/launchy)
|
5
|
-
* email jeremy at hinegardner dot org
|
6
7
|
|
7
8
|
## DESCRIPTION
|
8
9
|
|
@@ -11,7 +12,7 @@ forget manner.
|
|
11
12
|
|
12
13
|
There are application concepts (browser, email client, etc) that are common
|
13
14
|
across all platforms, and they may be launched differently on each platform.
|
14
|
-
Launchy is here to make a common approach to launching external
|
15
|
+
Launchy is here to make a common approach to launching external applications from
|
15
16
|
within ruby programs.
|
16
17
|
|
17
18
|
## FEATURES
|
@@ -20,26 +21,55 @@ Currently only launching a browser is supported.
|
|
20
21
|
|
21
22
|
## SYNOPSIS
|
22
23
|
|
23
|
-
You can use launchy on the commandline, within the Capybara and Rspec-rails
|
24
|
+
You can use launchy on the commandline, within the Capybara and Rspec-rails
|
25
|
+
testing environment, or via its API.
|
24
26
|
|
25
27
|
### Commandline
|
26
28
|
|
27
|
-
% launchy
|
29
|
+
% launchy https://www.ruby-lang.org/
|
30
|
+
|
31
|
+
There are additional command line options, use `launchy --help` to see them.
|
32
|
+
|
33
|
+
### Using the `BROWSER` environment variable
|
34
|
+
|
35
|
+
Launchy has a predefined set of common browsers on each platform that it
|
36
|
+
attempts to use, and of course it is not exhaustive. As a fallback you can make
|
37
|
+
use of the somewhat standard `BROWSER` environment variable.
|
38
|
+
|
39
|
+
`BROWSER` works in a similar same way to `PATH`. It is a colon (`:`) separated
|
40
|
+
list of commands to try. You can also put in a `%s` in the command and the URL
|
41
|
+
you are attempting to open will be substituted there.
|
42
|
+
|
43
|
+
As an example if you set `BROWSER=/usr/local/bin/firefox-bin -new-tab
|
44
|
+
'%s':/usr/local/bin/google-chrome-stable` and you call
|
45
|
+
`Launchy.open("https://www.ruby-lang.org/")` then Launchy will try, in order:
|
46
|
+
|
47
|
+
* `/usr/local/bin/firefox-bin -new-tab 'https://www.ruby-lang.org'`
|
48
|
+
* `/usr/local/bin/google-chrome-stable https://www.ruby-lang.org`
|
49
|
+
|
50
|
+
Additional links on the use of `BROWSER` as an environment variable.
|
28
51
|
|
29
|
-
|
52
|
+
* http://www.catb.org/esr/BROWSER/index.html
|
53
|
+
* https://help.ubuntu.com/community/EnvironmentVariables
|
54
|
+
* https://wiki.archlinux.org/index.php/environment_variables
|
30
55
|
|
31
56
|
### Capybara Testing
|
32
57
|
|
33
|
-
First, install [Capybara](https://github.com/jnicklas/capybara) and [Rspec for
|
58
|
+
First, install [Capybara](https://github.com/jnicklas/capybara) and [Rspec for
|
59
|
+
Rails](https://github.com/rspec/rspec-rails). Capybara provides the following
|
60
|
+
method:
|
34
61
|
|
35
62
|
save_and_open_page
|
36
63
|
|
37
|
-
When inserted into your code at the place where you would like to open your
|
64
|
+
When inserted into your code at the place where you would like to open your
|
65
|
+
program, and when rspec is run, Capybara displays this message:
|
38
66
|
|
39
67
|
Page saved to /home/code/my_app_name/tmp/capybara/capybara-current-date-and-time.html with save_and_open_page.
|
40
68
|
Please install the launchy gem to open page automatically.
|
41
69
|
|
42
|
-
With Launchy installed, when rspec is run again, it will launch an unstyled
|
70
|
+
With Launchy installed, when rspec is run again, it will launch an unstyled
|
71
|
+
instance of the specific page. It can be especially useful when debugging errors
|
72
|
+
in integration tests. For example:
|
43
73
|
|
44
74
|
context "signin" do
|
45
75
|
it "lets a user sign in" do
|
@@ -52,7 +82,7 @@ With Launchy installed, when rspec is run again, it will launch an unstyled inst
|
|
52
82
|
|
53
83
|
### Public API
|
54
84
|
|
55
|
-
In the vein of [Semantic Versioning](
|
85
|
+
In the vein of [Semantic Versioning](https://semver.org), this is the sole
|
56
86
|
supported public API.
|
57
87
|
|
58
88
|
Launchy.open( uri, options = {} ) { |exception| }
|
@@ -71,11 +101,11 @@ exception that was raised.
|
|
71
101
|
|
72
102
|
### An example of using the public API:
|
73
103
|
|
74
|
-
Launchy.open( "
|
104
|
+
Launchy.open( "https://www.ruby-lang.org" )
|
75
105
|
|
76
106
|
### An example of using the public API and using the error block:
|
77
107
|
|
78
|
-
uri = "
|
108
|
+
uri = "https://www.ruby-lang.org"
|
79
109
|
Launchy.open( uri ) do |exception|
|
80
110
|
puts "Attempted to open #{uri} and failed because #{exception}"
|
81
111
|
end
|
@@ -89,11 +119,11 @@ decided to bump all the way to 2.x.y.
|
|
89
119
|
I have attempted to keep backward compatibility with the previous examples. The
|
90
120
|
previous API examples of:
|
91
121
|
|
92
|
-
Launchy::Browser.run("
|
122
|
+
Launchy::Browser.run("https://www.ruby-lang.org/")
|
93
123
|
|
94
124
|
and
|
95
125
|
|
96
|
-
Launchy::Browser.new.visit("
|
126
|
+
Launchy::Browser.new.visit("https://www.ruby-lang.org/")
|
97
127
|
|
98
128
|
will still work, and you will get a deprecation notice, along with the line
|
99
129
|
of code you should probably update. For example, this is what would print out
|
@@ -117,9 +147,9 @@ API will be the documented one.
|
|
117
147
|
|
118
148
|
## ISC LICENSE
|
119
149
|
|
120
|
-
|
150
|
+
https://opensource.org/licenses/isc-license.txt
|
121
151
|
|
122
|
-
Copyright (c) 2007-
|
152
|
+
Copyright (c) 2007-2020 Jeremy Hinegardner
|
123
153
|
|
124
154
|
Permission to use, copy, modify, and/or distribute this software for any
|
125
155
|
purpose with or without fee is hereby granted, provided that the above
|
data/Rakefile
CHANGED
@@ -4,22 +4,24 @@ load 'tasks/this.rb'
|
|
4
4
|
This.name = "launchy"
|
5
5
|
This.author = "Jeremy Hinegardner"
|
6
6
|
This.email = "jeremy@copiousfreetime.org"
|
7
|
-
This.homepage = "
|
7
|
+
This.homepage = "https://github.com/copiousfreetime/#{ This.name }"
|
8
8
|
|
9
9
|
This.ruby_gemspec do |spec|
|
10
|
-
spec.add_dependency( 'addressable', '~> 2.
|
10
|
+
spec.add_dependency( 'addressable', '~> 2.8')
|
11
11
|
|
12
|
-
spec.add_development_dependency( 'rake' , '~>
|
13
|
-
spec.add_development_dependency( 'minitest' , '~> 5.
|
14
|
-
spec.add_development_dependency( 'rdoc' , '~> 4
|
15
|
-
|
16
|
-
spec.licenses = ['ISC']
|
17
|
-
end
|
18
|
-
|
19
|
-
This.java_gemspec( This.ruby_gemspec ) do |spec|
|
20
|
-
spec.add_dependency( 'spoon', '~> 0.0.1' )
|
12
|
+
spec.add_development_dependency( 'rake' , '~> 13.0')
|
13
|
+
spec.add_development_dependency( 'minitest' , '~> 5.15' )
|
14
|
+
spec.add_development_dependency( 'rdoc' , '~> 6.4' )
|
15
|
+
spec.add_development_dependency( 'simplecov', '~> 0.21' )
|
21
16
|
|
22
17
|
spec.licenses = ['ISC']
|
18
|
+
|
19
|
+
spec.metadata = {
|
20
|
+
"bug_tracker_uri" => "https://github.com/copiousfreetime/launchy/issues",
|
21
|
+
"changelog_uri" => "https://github.com/copiousfreetime/launchy/blob/master/README.md",
|
22
|
+
"homepage_uri" => "https://github.com/copiousfreetime/launchy",
|
23
|
+
"source_code_uri" => "https://github.com/copiousfreetime/launchy",
|
24
|
+
}
|
23
25
|
end
|
24
26
|
|
25
27
|
load 'tasks/default.rake'
|
data/lib/launchy/application.rb
CHANGED
@@ -27,7 +27,7 @@ module Launchy
|
|
27
27
|
#
|
28
28
|
# Find the given executable in the available paths
|
29
29
|
def find_executable( bin, *paths )
|
30
|
-
paths =
|
30
|
+
paths = Launchy.path.split( File::PATH_SEPARATOR ) if paths.empty?
|
31
31
|
paths.each do |path|
|
32
32
|
file = File.join( path, bin )
|
33
33
|
if File.executable?( file ) then
|
@@ -64,12 +64,12 @@ class Launchy::Application
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def cmd_and_args( uri, options = {} )
|
67
|
-
cmd = browser_cmdline
|
67
|
+
cmd = browser_cmdline.to_s
|
68
68
|
args = [ uri.to_s ]
|
69
69
|
if cmd =~ /%s/ then
|
70
70
|
cmd.gsub!( /%s/, args.shift )
|
71
71
|
end
|
72
|
-
|
72
|
+
[cmd, args]
|
73
73
|
end
|
74
74
|
|
75
75
|
# final assembly of the command and do %s substitution
|
@@ -19,7 +19,7 @@ module Launchy::Detect
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.fallback_browsers
|
22
|
-
%w[ firefox iceweasel seamonkey opera mozilla netscape galeon ].map { |x| ::Launchy::Argv.new( x ) }
|
22
|
+
%w[ firefox iceweasel seamonkey opera mozilla netscape galeon links lynx ].map { |x| ::Launchy::Argv.new( x ) }
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.browsers
|
@@ -32,11 +32,12 @@ module Launchy::Detect
|
|
32
32
|
|
33
33
|
class Kde < NixDesktopEnvironment
|
34
34
|
def self.is_current_desktop_environment?
|
35
|
-
ENV['KDE_FULL_SESSION']
|
35
|
+
ENV['KDE_FULL_SESSION'] &&
|
36
|
+
Launchy::Application.find_executable( 'kde-open' )
|
36
37
|
end
|
37
38
|
|
38
39
|
def self.browser
|
39
|
-
::Launchy::Argv.new(
|
40
|
+
::Launchy::Argv.new( 'kde-open' )
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -108,8 +108,8 @@ module Launchy::Detect
|
|
108
108
|
|
109
109
|
class Jruby < Runner
|
110
110
|
def wet_run( cmd, *args )
|
111
|
-
|
112
|
-
|
111
|
+
child_pid = spawn( *shell_commands( cmd, *args ) )
|
112
|
+
Process.detach( child_pid )
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
data/lib/launchy/version.rb
CHANGED
data/lib/launchy.rb
CHANGED
@@ -8,7 +8,8 @@ require 'addressable/uri'
|
|
8
8
|
# The currently defined global options are:
|
9
9
|
#
|
10
10
|
# :debug Turn on debugging output
|
11
|
-
# :application Explicitly state what application class is going to be used
|
11
|
+
# :application Explicitly state what application class is going to be used.
|
12
|
+
# This must be a child class of Launchy::Application
|
12
13
|
# :host_os Explicitly state what host operating system to pretend to be
|
13
14
|
# :ruby_engine Explicitly state what ruby engine to pretend to be under
|
14
15
|
# :dry_run Do nothing and print the command that would be executed on $stdout
|
@@ -48,6 +49,7 @@ module Launchy
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def string_to_uri( s )
|
52
|
+
s = s.to_s
|
51
53
|
uri = Addressable::URI.parse( s )
|
52
54
|
Launchy.log "URI parsing pass 1 : #{s} -> #{uri.to_hash}"
|
53
55
|
if not uri.scheme then
|
@@ -64,6 +66,7 @@ module Launchy
|
|
64
66
|
Launchy.host_os = nil
|
65
67
|
Launchy.ruby_engine = nil
|
66
68
|
Launchy.dry_run = false
|
69
|
+
Launchy.path = ENV['PATH']
|
67
70
|
end
|
68
71
|
|
69
72
|
def extract_global_options( options )
|
@@ -125,6 +128,14 @@ module Launchy
|
|
125
128
|
$stderr.puts "LAUNCHY_DEBUG: #{msg}" if Launchy.debug?
|
126
129
|
end
|
127
130
|
|
131
|
+
def path
|
132
|
+
@path
|
133
|
+
end
|
134
|
+
|
135
|
+
def path=(path)
|
136
|
+
@path = path
|
137
|
+
end
|
138
|
+
|
128
139
|
private
|
129
140
|
def to_bool( arg )
|
130
141
|
if arg.is_a? String
|
data/spec/application_spec.rb
CHANGED
@@ -14,30 +14,30 @@ describe Launchy::Application do
|
|
14
14
|
uri.scheme == "junk2"
|
15
15
|
end
|
16
16
|
end
|
17
|
-
Launchy::Application.children.must_include( Junk2App )
|
17
|
+
_(Launchy::Application.children).must_include( Junk2App )
|
18
18
|
Launchy::Application.children.delete( Junk2App )
|
19
19
|
end
|
20
20
|
|
21
21
|
it "can find an app" do
|
22
|
-
Launchy::Application.children.must_include( JunkApp )
|
23
|
-
Launchy::Application.children.size.must_equal 3
|
22
|
+
_(Launchy::Application.children).must_include( JunkApp )
|
23
|
+
_(Launchy::Application.children.size).must_equal 3
|
24
24
|
uri = Addressable::URI.parse( "junk:///foo" )
|
25
|
-
Launchy::Application.handling( uri ).must_equal( JunkApp )
|
25
|
+
_(Launchy::Application.handling( uri )).must_equal( JunkApp )
|
26
26
|
end
|
27
27
|
|
28
28
|
it "raises an error if an application cannot be found for the given scheme" do
|
29
29
|
uri = Addressable::URI.parse( "foo:///bar" )
|
30
|
-
lambda { Launchy::Application.handling( uri ) }.must_raise( Launchy::ApplicationNotFoundError )
|
30
|
+
_(lambda { Launchy::Application.handling( uri ) }).must_raise( Launchy::ApplicationNotFoundError )
|
31
31
|
end
|
32
32
|
|
33
33
|
it "can find open or curl or xdg-open" do
|
34
34
|
found = %w[ open curl xdg-open ].any? do |app|
|
35
35
|
Launchy::Application.find_executable( app )
|
36
36
|
end
|
37
|
-
found.must_equal true
|
37
|
+
_(found).must_equal true
|
38
38
|
end
|
39
39
|
|
40
40
|
it "does not find xyzzy" do
|
41
|
-
Launchy::Application.find_executable( "xyzzy" ).
|
41
|
+
_(Launchy::Application.find_executable( "xyzzy" )).must_be_nil
|
42
42
|
end
|
43
43
|
end
|
@@ -13,16 +13,18 @@ describe Launchy::Application::Browser do
|
|
13
13
|
ENV.delete( 'BROWSER' )
|
14
14
|
end
|
15
15
|
|
16
|
-
{ 'windows' => '
|
17
|
-
'darwin' => '
|
18
|
-
'cygwin' => '
|
19
|
-
|
20
|
-
|
21
|
-
'
|
22
|
-
it "when host_os is '#{host_os}' the appropriate 'app_list' method is called" do
|
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
|
23
22
|
Launchy.host_os = host_os
|
24
23
|
browser = Launchy::Application::Browser.new
|
25
|
-
browser.
|
24
|
+
browser.stub(called_method, [:called_me]) do
|
25
|
+
item = browser.app_list.first
|
26
|
+
_(item).must_equal :called_me
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -32,14 +34,14 @@ describe Launchy::Application::Browser do
|
|
32
34
|
Launchy.host_os = host_os
|
33
35
|
browser = Launchy::Application::Browser.new
|
34
36
|
cmd, args = browser.cmd_and_args( @test_url )
|
35
|
-
cmd.must_equal "my_special_browser --new-tab 'http://example.com/'"
|
36
|
-
args.must_equal []
|
37
|
+
_(cmd).must_equal "my_special_browser --new-tab 'http://example.com/'"
|
38
|
+
_(args).must_equal []
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
it "handles a file on the file system when there is no file:// scheme" do
|
41
43
|
uri = Addressable::URI.parse( __FILE__ )
|
42
|
-
Launchy::Application::Browser.handles?( uri ).must_equal true
|
44
|
+
_(Launchy::Application::Browser.handles?( uri )).must_equal true
|
43
45
|
end
|
44
46
|
|
45
47
|
it "handles the case where $BROWSER is set and no *nix desktop environment is found" do
|
@@ -48,21 +50,24 @@ describe Launchy::Application::Browser do
|
|
48
50
|
ENV['BROWSER'] = "do-this-instead"
|
49
51
|
Launchy.host_os = 'linux'
|
50
52
|
browser = Launchy::Application::Browser.new
|
51
|
-
browser.browser_cmdline.must_equal "do-this-instead"
|
53
|
+
_(browser.browser_cmdline).must_equal "do-this-instead"
|
52
54
|
end
|
53
55
|
|
54
56
|
# NOTE: Unable to figure out how capture the stderr from the child which has
|
55
57
|
# moved it at least once. This test just serves the purpose of noting why
|
56
|
-
# something happens, and the
|
57
|
-
it "When BROWSER is set to something that is not executable, error still appears on stderr" do
|
58
|
-
|
59
|
-
|
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/"
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
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
|
67
72
|
end
|
68
73
|
|
data/spec/cli_spec.rb
CHANGED
@@ -21,9 +21,9 @@ describe Launchy::Cli do
|
|
21
21
|
begin
|
22
22
|
Launchy::Cli.new.run( argv, env )
|
23
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
|
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
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -45,16 +45,16 @@ describe Launchy::Cli do
|
|
45
45
|
|
46
46
|
it "leaves the url on argv after parsing" do
|
47
47
|
l = Launchy::Cli.new
|
48
|
-
argv = %w[ --debug --dry-run
|
48
|
+
argv = %w[ --debug --dry-run https://github.com/copiousfreetime/launchy ]
|
49
49
|
l.parse( argv , {} )
|
50
|
-
argv.size.must_equal 1
|
51
|
-
argv[0].must_equal "
|
50
|
+
_(argv.size).must_equal 1
|
51
|
+
_(argv[0]).must_equal "https://github.com/copiousfreetime/launchy"
|
52
52
|
end
|
53
53
|
|
54
54
|
it "prints the command on stdout when using --dry-run" do
|
55
|
-
argv = %w[ --debug --dry-run
|
55
|
+
argv = %w[ --debug --dry-run https://github.com/copiousfreetime/launchy ]
|
56
56
|
Launchy::Cli.new.good_run( argv, {} )
|
57
|
-
$stdout.string.must_match %r[github.com]
|
57
|
+
_($stdout.string).must_match %r[github.com]
|
58
58
|
end
|
59
59
|
|
60
60
|
{
|
@@ -62,13 +62,13 @@ describe Launchy::Cli do
|
|
62
62
|
'--engine' => [ :ruby_engine, 'rbx'],
|
63
63
|
'--host-os' => [ :host_os, 'cygwin'] }.each_pair do |opt, val|
|
64
64
|
it "the commandline option #{opt} sets the program option #{val[0]}" do
|
65
|
-
argv = [ opt, val[1], "
|
65
|
+
argv = [ opt, val[1], "https://github.com/copiousfreetime/launchy" ]
|
66
66
|
l = Launchy::Cli.new
|
67
67
|
rc = l.parse( argv, {} )
|
68
|
-
rc.must_equal true
|
69
|
-
argv.size.must_equal 1
|
70
|
-
argv[0].must_equal "
|
71
|
-
l.options[val[0]].must_equal val[1]
|
68
|
+
_(rc).must_equal true
|
69
|
+
_(argv.size).must_equal 1
|
70
|
+
_(argv[0]).must_equal "https://github.com/copiousfreetime/launchy"
|
71
|
+
_(l.options[val[0]]).must_equal val[1]
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -13,7 +13,8 @@ describe Launchy::Detect::HostOsFamily do
|
|
13
13
|
|
14
14
|
YAML::load( IO.read( File.expand_path( "../../tattle-host-os.yaml", __FILE__ ) ) )['host_os'].keys.sort.each do |os|
|
15
15
|
it "OS family of #{os} is detected" do
|
16
|
-
Launchy::Detect::HostOsFamily.detect( os )
|
16
|
+
os_family = Launchy::Detect::HostOsFamily.detect( os )
|
17
|
+
_(os_family).must_be_kind_of Launchy::Detect::HostOsFamily
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -22,19 +23,20 @@ describe Launchy::Detect::HostOsFamily do
|
|
22
23
|
'linux' => :nix?,
|
23
24
|
'cygwin' => :cygwin? }.each_pair do |os, method|
|
24
25
|
it "#{method} returns true for #{os} " do
|
25
|
-
Launchy::Detect::HostOsFamily.detect( os ).send( method )
|
26
|
+
r = Launchy::Detect::HostOsFamily.detect( os ).send( method )
|
27
|
+
_(r).must_equal true
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
31
|
it "uses the global host_os overrides" do
|
30
32
|
ENV['LAUNCHY_HOST_OS'] = "fake-os-2"
|
31
|
-
lambda { Launchy::Detect::HostOsFamily.detect }.must_raise Launchy::Detect::HostOsFamily::NotFoundError
|
33
|
+
_(lambda { Launchy::Detect::HostOsFamily.detect }).must_raise Launchy::Detect::HostOsFamily::NotFoundError
|
32
34
|
ENV.delete('LAUNCHY_HOST_OS')
|
33
35
|
end
|
34
36
|
|
35
37
|
|
36
38
|
it "does not find an os of 'dos'" do
|
37
|
-
lambda { Launchy::Detect::HostOsFamily.detect( 'dos' ) }.must_raise Launchy::Detect::HostOsFamily::NotFoundError
|
39
|
+
_(lambda { Launchy::Detect::HostOsFamily.detect( 'dos' ) }).must_raise Launchy::Detect::HostOsFamily::NotFoundError
|
38
40
|
end
|
39
41
|
|
40
42
|
end
|
data/spec/detect/host_os_spec.rb
CHANGED
@@ -3,16 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe Launchy::Detect::HostOs do
|
4
4
|
|
5
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']
|
6
|
+
_(Launchy::Detect::HostOs.new.host_os).must_equal RbConfig::CONFIG['host_os']
|
7
7
|
end
|
8
8
|
|
9
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"
|
10
|
+
_(Launchy::Detect::HostOs.new( "fake-os-1").host_os).must_equal "fake-os-1"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "uses the environment variable LAUNCHY_HOST_OS to override ruby's config" do
|
14
14
|
ENV['LAUNCHY_HOST_OS'] = "fake-os-2"
|
15
|
-
Launchy::Detect::HostOs.new.host_os.must_equal "fake-os-2"
|
15
|
+
_(Launchy::Detect::HostOs.new.host_os).must_equal "fake-os-2"
|
16
16
|
ENV.delete('LAUNCHY_HOST_OS')
|
17
17
|
end
|
18
18
|
|