launchy 2.5.0 → 3.1.1
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/CONTRIBUTING.md +1 -0
- data/HISTORY.md +46 -20
- data/{LICENSE → LICENSE.txt} +1 -1
- data/Manifest.txt +4 -21
- data/README.md +10 -47
- data/exe/launchy +5 -0
- data/launchy.gemspec +33 -0
- data/lib/launchy/application.rb +38 -20
- data/lib/launchy/applications/browser.rb +70 -63
- data/lib/launchy/argv.rb +11 -6
- data/lib/launchy/cli.rb +29 -34
- 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 -5
- data/lib/launchy/error.rb +2 -0
- data/lib/launchy/os_family.rb +2 -0
- data/lib/launchy/runner.rb +55 -0
- data/lib/launchy/version.rb +7 -5
- data/lib/launchy.rb +76 -68
- metadata +23 -83
- data/Rakefile +0 -27
- data/bin/launchy +0 -4
- data/lib/launchy/deprecated.rb +0 -52
- data/lib/launchy/detect/ruby_engine.rb +0 -78
- data/lib/launchy/detect/runner.rb +0 -152
- data/spec/application_spec.rb +0 -43
- data/spec/applications/browser_spec.rb +0 -78
- data/spec/cli_spec.rb +0 -75
- 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/detect/ruby_engine_spec.rb +0 -37
- data/spec/detect/runner_spec.rb +0 -103
- data/spec/launchy_spec.rb +0 -119
- data/spec/mock_application.rb +0 -9
- data/spec/spec_helper.rb +0 -11
- data/spec/tattle-host-os.yaml +0 -427
- data/spec/version_spec.rb +0 -11
- data/tasks/default.rake +0 -242
- data/tasks/this.rb +0 -208
data/lib/launchy.rb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "English"
|
|
4
|
+
require "addressable/uri"
|
|
5
|
+
require "shellwords"
|
|
6
|
+
require "stringio"
|
|
2
7
|
|
|
3
8
|
#
|
|
4
9
|
# The entry point into Launchy. This is the sole supported public API.
|
|
@@ -11,113 +16,118 @@ require 'addressable/uri'
|
|
|
11
16
|
# :application Explicitly state what application class is going to be used.
|
|
12
17
|
# This must be a child class of Launchy::Application
|
|
13
18
|
# :host_os Explicitly state what host operating system to pretend to be
|
|
14
|
-
# :ruby_engine Explicitly state what ruby engine to pretend to be under
|
|
15
19
|
# :dry_run Do nothing and print the command that would be executed on $stdout
|
|
16
20
|
#
|
|
17
21
|
# Other options may be used, and those will be passed directly to the
|
|
18
22
|
# application class
|
|
19
23
|
#
|
|
20
24
|
module Launchy
|
|
21
|
-
|
|
22
25
|
class << self
|
|
23
26
|
#
|
|
24
27
|
# Launch an application for the given uri string
|
|
25
28
|
#
|
|
26
|
-
def open(uri_s, options = {}
|
|
27
|
-
leftover = extract_global_options(
|
|
28
|
-
uri = string_to_uri(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
def open(uri_s, options = {})
|
|
30
|
+
leftover = extract_global_options(options)
|
|
31
|
+
uri = string_to_uri(uri_s)
|
|
32
|
+
if (name = options[:application])
|
|
33
|
+
app = app_for_name(name)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
app = app_for_uri(uri) if app.nil?
|
|
37
|
+
|
|
38
|
+
app.new.open(uri, leftover)
|
|
39
|
+
rescue Launchy::Error => e
|
|
40
|
+
raise e
|
|
41
|
+
rescue StandardError => e
|
|
34
42
|
msg = "Failure in opening uri #{uri_s.inspect} with options #{options.inspect}: #{e}"
|
|
35
43
|
raise Launchy::Error, msg
|
|
36
44
|
ensure
|
|
37
|
-
if
|
|
38
|
-
yield
|
|
39
|
-
|
|
45
|
+
if $ERROR_INFO && block_given?
|
|
46
|
+
yield $ERROR_INFO
|
|
47
|
+
|
|
48
|
+
# explicitly return here to swallow the errors if there was an error
|
|
49
|
+
# and we yielded to the block
|
|
50
|
+
# rubocop:disable Lint/EnsureReturn
|
|
51
|
+
return
|
|
52
|
+
# rubocop:enable Lint/EnsureReturn
|
|
40
53
|
end
|
|
41
54
|
end
|
|
42
55
|
|
|
43
|
-
def app_for_uri(
|
|
44
|
-
Launchy::Application.handling(
|
|
56
|
+
def app_for_uri(uri)
|
|
57
|
+
Launchy::Application.handling(uri)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def app_for_name(name)
|
|
61
|
+
Launchy::Application.for_name(name)
|
|
62
|
+
rescue Launchy::ApplicationNotFoundError
|
|
63
|
+
nil
|
|
45
64
|
end
|
|
46
65
|
|
|
47
|
-
def app_for_uri_string(
|
|
48
|
-
app_for_uri(
|
|
66
|
+
def app_for_uri_string(str)
|
|
67
|
+
app_for_uri(string_to_uri(str))
|
|
49
68
|
end
|
|
50
69
|
|
|
51
|
-
def string_to_uri(
|
|
52
|
-
|
|
53
|
-
uri = Addressable::URI.parse(
|
|
54
|
-
Launchy.log "URI parsing pass 1 : #{
|
|
55
|
-
|
|
56
|
-
uri = Addressable::URI.heuristic_parse(
|
|
57
|
-
Launchy.log "URI parsing pass 2 : #{
|
|
70
|
+
def string_to_uri(str)
|
|
71
|
+
str = str.to_s
|
|
72
|
+
uri = Addressable::URI.parse(str)
|
|
73
|
+
Launchy.log "URI parsing pass 1 : #{str} -> #{uri.to_hash}"
|
|
74
|
+
unless uri.scheme
|
|
75
|
+
uri = Addressable::URI.heuristic_parse(str)
|
|
76
|
+
Launchy.log "URI parsing pass 2 : #{str} -> #{uri.to_hash}"
|
|
58
77
|
end
|
|
59
|
-
raise Launchy::ArgumentError, "Invalid URI given: #{
|
|
60
|
-
|
|
78
|
+
raise Launchy::ArgumentError, "Invalid URI given: #{str.inspect}" unless uri
|
|
79
|
+
|
|
80
|
+
uri
|
|
61
81
|
end
|
|
62
82
|
|
|
63
83
|
def reset_global_options
|
|
64
84
|
Launchy.debug = false
|
|
65
85
|
Launchy.application = nil
|
|
66
86
|
Launchy.host_os = nil
|
|
67
|
-
Launchy.ruby_engine = nil
|
|
68
87
|
Launchy.dry_run = false
|
|
69
|
-
Launchy.path = ENV
|
|
88
|
+
Launchy.path = ENV.fetch("PATH", nil)
|
|
70
89
|
end
|
|
71
90
|
|
|
72
|
-
def extract_global_options(
|
|
91
|
+
def extract_global_options(options)
|
|
73
92
|
leftover = options.dup
|
|
74
|
-
Launchy.debug = leftover.delete(
|
|
75
|
-
Launchy.application = leftover.delete(
|
|
76
|
-
Launchy.host_os = leftover.delete(
|
|
77
|
-
Launchy.
|
|
78
|
-
Launchy.dry_run = leftover.delete( :dry_run ) || ENV['LAUNCHY_DRY_RUN']
|
|
93
|
+
Launchy.debug = leftover.delete(:debug) || ENV.fetch("LAUNCHY_DEBUG", nil)
|
|
94
|
+
Launchy.application = leftover.delete(:application) || ENV.fetch("LAUNCHY_APPLICATION", nil)
|
|
95
|
+
Launchy.host_os = leftover.delete(:host_os) || ENV.fetch("LAUNCHY_HOST_OS", nil)
|
|
96
|
+
Launchy.dry_run = leftover.delete(:dry_run) || ENV.fetch("LAUNCHY_DRY_RUN", nil)
|
|
79
97
|
end
|
|
80
98
|
|
|
81
|
-
def debug=(
|
|
82
|
-
@debug = to_bool(
|
|
99
|
+
def debug=(enabled)
|
|
100
|
+
@debug = to_bool(enabled)
|
|
83
101
|
end
|
|
84
102
|
|
|
85
103
|
# we may do logging before a call to 'open', hence the need to check
|
|
86
104
|
# LAUNCHY_DEBUG here
|
|
87
105
|
def debug?
|
|
88
|
-
@debug || to_bool(
|
|
106
|
+
@debug || to_bool(ENV.fetch("LAUNCHY_DEBUG", nil))
|
|
89
107
|
end
|
|
90
108
|
|
|
91
|
-
def application=(
|
|
109
|
+
def application=(app)
|
|
92
110
|
@application = app
|
|
93
111
|
end
|
|
94
112
|
|
|
95
113
|
def application
|
|
96
|
-
@application || ENV
|
|
114
|
+
@application || ENV.fetch("LAUNCHY_APPLICATION", nil)
|
|
97
115
|
end
|
|
98
116
|
|
|
99
|
-
def host_os=(
|
|
117
|
+
def host_os=(host_os)
|
|
100
118
|
@host_os = host_os
|
|
101
119
|
end
|
|
102
120
|
|
|
103
121
|
def host_os
|
|
104
|
-
@host_os || ENV
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def ruby_engine=( ruby_engine )
|
|
108
|
-
@ruby_engine = ruby_engine
|
|
122
|
+
@host_os || ENV.fetch("LAUNCHY_HOST_OS", nil)
|
|
109
123
|
end
|
|
110
124
|
|
|
111
|
-
def
|
|
112
|
-
@
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def dry_run=( dry_run )
|
|
116
|
-
@dry_run = to_bool( dry_run )
|
|
125
|
+
def dry_run=(dry_run)
|
|
126
|
+
@dry_run = to_bool(dry_run)
|
|
117
127
|
end
|
|
118
128
|
|
|
119
129
|
def dry_run?
|
|
120
|
-
@dry_run || to_bool(
|
|
130
|
+
@dry_run || to_bool(ENV.fetch("LAUNCHY_DRY_RUN", nil))
|
|
121
131
|
end
|
|
122
132
|
|
|
123
133
|
def bug_report_message
|
|
@@ -136,15 +146,13 @@ module Launchy
|
|
|
136
146
|
@path = path
|
|
137
147
|
end
|
|
138
148
|
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
private
|
|
150
|
+
|
|
151
|
+
def to_bool(arg)
|
|
141
152
|
if arg.is_a? String
|
|
142
|
-
arg ==
|
|
143
|
-
elsif arg.is_a? TrueClass
|
|
144
|
-
true
|
|
153
|
+
arg == "true"
|
|
145
154
|
else
|
|
146
|
-
|
|
147
|
-
false
|
|
155
|
+
arg.is_a? TrueClass
|
|
148
156
|
end
|
|
149
157
|
end
|
|
150
158
|
end
|
|
@@ -153,11 +161,11 @@ module Launchy
|
|
|
153
161
|
Launchy.reset_global_options
|
|
154
162
|
end
|
|
155
163
|
|
|
156
|
-
require
|
|
157
|
-
require
|
|
158
|
-
require
|
|
159
|
-
require
|
|
160
|
-
require
|
|
161
|
-
require
|
|
162
|
-
require
|
|
163
|
-
require
|
|
164
|
+
require "launchy/version"
|
|
165
|
+
require "launchy/argv"
|
|
166
|
+
require "launchy/cli"
|
|
167
|
+
require "launchy/descendant_tracker"
|
|
168
|
+
require "launchy/error"
|
|
169
|
+
require "launchy/application"
|
|
170
|
+
require "launchy/detect"
|
|
171
|
+
require "launchy/runner"
|
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:
|
|
4
|
+
version: 3.1.1
|
|
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-02-21 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: addressable
|
|
@@ -16,70 +15,42 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.
|
|
18
|
+
version: '2.8'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.
|
|
25
|
+
version: '2.8'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: childprocess
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
34
|
-
type: :
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '13.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: minitest
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '5.14'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '5.14'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rdoc
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '6.2'
|
|
62
|
-
type: :development
|
|
32
|
+
version: '5.0'
|
|
33
|
+
type: :runtime
|
|
63
34
|
prerelease: false
|
|
64
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
36
|
requirements:
|
|
66
37
|
- - "~>"
|
|
67
38
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
39
|
+
version: '5.0'
|
|
69
40
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
41
|
+
name: logger
|
|
71
42
|
requirement: !ruby/object:Gem::Requirement
|
|
72
43
|
requirements:
|
|
73
44
|
- - "~>"
|
|
74
45
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
76
|
-
type: :
|
|
46
|
+
version: '1.6'
|
|
47
|
+
type: :runtime
|
|
77
48
|
prerelease: false
|
|
78
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
50
|
requirements:
|
|
80
51
|
- - "~>"
|
|
81
52
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
53
|
+
version: '1.6'
|
|
83
54
|
description: Launchy is helper class for launching cross-platform applications in
|
|
84
55
|
a fire and forget manner. There are application concepts (browser, email client,
|
|
85
56
|
etc) that are common across all platforms, and they may be launched differently
|
|
@@ -92,56 +63,39 @@ extensions: []
|
|
|
92
63
|
extra_rdoc_files:
|
|
93
64
|
- CONTRIBUTING.md
|
|
94
65
|
- HISTORY.md
|
|
66
|
+
- LICENSE.txt
|
|
95
67
|
- Manifest.txt
|
|
96
68
|
- README.md
|
|
97
69
|
files:
|
|
98
70
|
- CONTRIBUTING.md
|
|
99
71
|
- HISTORY.md
|
|
100
|
-
- LICENSE
|
|
72
|
+
- LICENSE.txt
|
|
101
73
|
- Manifest.txt
|
|
102
74
|
- README.md
|
|
103
|
-
-
|
|
104
|
-
-
|
|
75
|
+
- exe/launchy
|
|
76
|
+
- launchy.gemspec
|
|
105
77
|
- lib/launchy.rb
|
|
106
78
|
- lib/launchy/application.rb
|
|
107
79
|
- lib/launchy/applications/browser.rb
|
|
108
80
|
- lib/launchy/argv.rb
|
|
109
81
|
- lib/launchy/cli.rb
|
|
110
|
-
- lib/launchy/deprecated.rb
|
|
111
82
|
- lib/launchy/descendant_tracker.rb
|
|
112
83
|
- lib/launchy/detect.rb
|
|
113
84
|
- lib/launchy/detect/host_os.rb
|
|
114
85
|
- lib/launchy/detect/host_os_family.rb
|
|
115
86
|
- lib/launchy/detect/nix_desktop_environment.rb
|
|
116
|
-
- lib/launchy/detect/ruby_engine.rb
|
|
117
|
-
- lib/launchy/detect/runner.rb
|
|
118
87
|
- lib/launchy/error.rb
|
|
119
88
|
- lib/launchy/os_family.rb
|
|
89
|
+
- lib/launchy/runner.rb
|
|
120
90
|
- lib/launchy/version.rb
|
|
121
|
-
|
|
122
|
-
- spec/applications/browser_spec.rb
|
|
123
|
-
- spec/cli_spec.rb
|
|
124
|
-
- spec/detect/host_os_family_spec.rb
|
|
125
|
-
- spec/detect/host_os_spec.rb
|
|
126
|
-
- spec/detect/nix_desktop_environment_spec.rb
|
|
127
|
-
- spec/detect/ruby_engine_spec.rb
|
|
128
|
-
- spec/detect/runner_spec.rb
|
|
129
|
-
- spec/launchy_spec.rb
|
|
130
|
-
- spec/mock_application.rb
|
|
131
|
-
- spec/spec_helper.rb
|
|
132
|
-
- spec/tattle-host-os.yaml
|
|
133
|
-
- spec/version_spec.rb
|
|
134
|
-
- tasks/default.rake
|
|
135
|
-
- tasks/this.rb
|
|
136
|
-
homepage: http://github.com/copiousfreetime/launchy
|
|
91
|
+
homepage: https://github.com/copiousfreetime/launchy
|
|
137
92
|
licenses:
|
|
138
93
|
- ISC
|
|
139
94
|
metadata:
|
|
140
95
|
bug_tracker_uri: https://github.com/copiousfreetime/launchy/issues
|
|
141
|
-
changelog_uri: https://github.com/copiousfreetime/launchy/blob/master/
|
|
96
|
+
changelog_uri: https://github.com/copiousfreetime/launchy/blob/master/HISTORY.md
|
|
142
97
|
homepage_uri: https://github.com/copiousfreetime/launchy
|
|
143
98
|
source_code_uri: https://github.com/copiousfreetime/launchy
|
|
144
|
-
post_install_message:
|
|
145
99
|
rdoc_options:
|
|
146
100
|
- "--main"
|
|
147
101
|
- README.md
|
|
@@ -153,29 +107,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
153
107
|
requirements:
|
|
154
108
|
- - ">="
|
|
155
109
|
- !ruby/object:Gem::Version
|
|
156
|
-
version: 2.
|
|
110
|
+
version: 2.3.0
|
|
157
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
112
|
requirements:
|
|
159
113
|
- - ">="
|
|
160
114
|
- !ruby/object:Gem::Version
|
|
161
115
|
version: '0'
|
|
162
116
|
requirements: []
|
|
163
|
-
rubygems_version: 3.
|
|
164
|
-
signing_key:
|
|
117
|
+
rubygems_version: 3.6.3
|
|
165
118
|
specification_version: 4
|
|
166
119
|
summary: Launchy is helper class for launching cross-platform applications in a fire
|
|
167
120
|
and forget manner.
|
|
168
|
-
test_files:
|
|
169
|
-
- spec/application_spec.rb
|
|
170
|
-
- spec/applications/browser_spec.rb
|
|
171
|
-
- spec/cli_spec.rb
|
|
172
|
-
- spec/detect/host_os_family_spec.rb
|
|
173
|
-
- spec/detect/host_os_spec.rb
|
|
174
|
-
- spec/detect/nix_desktop_environment_spec.rb
|
|
175
|
-
- spec/detect/ruby_engine_spec.rb
|
|
176
|
-
- spec/detect/runner_spec.rb
|
|
177
|
-
- spec/launchy_spec.rb
|
|
178
|
-
- spec/mock_application.rb
|
|
179
|
-
- spec/spec_helper.rb
|
|
180
|
-
- spec/tattle-host-os.yaml
|
|
181
|
-
- spec/version_spec.rb
|
|
121
|
+
test_files: []
|
data/Rakefile
DELETED
|
@@ -1,27 +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 = "http://github.com/copiousfreetime/#{ This.name }"
|
|
8
|
-
|
|
9
|
-
This.ruby_gemspec do |spec|
|
|
10
|
-
spec.add_dependency( 'addressable', '~> 2.7')
|
|
11
|
-
|
|
12
|
-
spec.add_development_dependency( 'rake' , '~> 13.0')
|
|
13
|
-
spec.add_development_dependency( 'minitest' , '~> 5.14' )
|
|
14
|
-
spec.add_development_dependency( 'rdoc' , '~> 6.2' )
|
|
15
|
-
spec.add_development_dependency( 'simplecov', '~> 0.18' )
|
|
16
|
-
|
|
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
|
-
}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
load 'tasks/default.rake'
|
data/bin/launchy
DELETED
data/lib/launchy/deprecated.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
module Launchy
|
|
2
|
-
#
|
|
3
|
-
# This class is deprecated and will be removed
|
|
4
|
-
#
|
|
5
|
-
class Browser
|
|
6
|
-
def self.run( *args )
|
|
7
|
-
Browser.new.visit( args[0] )
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def visit( url )
|
|
11
|
-
_warn "You made a call to a deprecated Launchy API. This call should be changed to 'Launchy.open( uri )'"
|
|
12
|
-
report_caller_context( caller )
|
|
13
|
-
|
|
14
|
-
::Launchy.open( url )
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def find_caller_context( stack )
|
|
20
|
-
caller_file = stack.find do |line|
|
|
21
|
-
not line.index( __FILE__ )
|
|
22
|
-
end
|
|
23
|
-
if caller_file then
|
|
24
|
-
caller_fname, caller_line, _ = caller_file.split(":")
|
|
25
|
-
if File.readable?( caller_fname ) then
|
|
26
|
-
caller_lines = IO.readlines( caller_fname )
|
|
27
|
-
context = [ caller_file ]
|
|
28
|
-
context << caller_lines[(caller_line.to_i)-3, 5]
|
|
29
|
-
return context.flatten
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
return []
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def report_caller_context( stack )
|
|
36
|
-
context = find_caller_context( stack )
|
|
37
|
-
if context.size > 0 then
|
|
38
|
-
_warn "I think I was able to find the location that needs to be fixed. Please go look at:"
|
|
39
|
-
_warn
|
|
40
|
-
context.each do |line|
|
|
41
|
-
_warn line.rstrip
|
|
42
|
-
end
|
|
43
|
-
_warn
|
|
44
|
-
_warn "If this is not the case, please file a bug. #{Launchy.bug_report_message}"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def _warn( msg = "" )
|
|
49
|
-
warn "WARNING: #{msg}"
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
module Launchy::Detect
|
|
2
|
-
class RubyEngine
|
|
3
|
-
class NotFoundError < Launchy::Error; end
|
|
4
|
-
|
|
5
|
-
extend ::Launchy::DescendantTracker
|
|
6
|
-
|
|
7
|
-
# Detect the current ruby engine.
|
|
8
|
-
#
|
|
9
|
-
# If the current ruby engine cannot be detected, the return
|
|
10
|
-
# RubyEngine::Unknown
|
|
11
|
-
def self.detect( ruby_engine = RubyEngine.new )
|
|
12
|
-
found = find_child( :is_current_engine?, ruby_engine.to_s )
|
|
13
|
-
return found if found
|
|
14
|
-
raise NotFoundError, "#{ruby_engine_error_message( ruby_engine )} #{Launchy.bug_report_message}"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def self.ruby_engine_error_message( ruby_engine )
|
|
18
|
-
msg = "Unkonwn RUBY_ENGINE "
|
|
19
|
-
if ruby_engine then
|
|
20
|
-
msg += " '#{ruby_engine}'."
|
|
21
|
-
elsif defined?( RUBY_ENGINE ) then
|
|
22
|
-
msg += " '#{RUBY_ENGINE}'."
|
|
23
|
-
else
|
|
24
|
-
msg = "RUBY_ENGINE not defined for #{RUBY_DESCRIPTION}."
|
|
25
|
-
end
|
|
26
|
-
return msg
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.is_current_engine?( ruby_engine )
|
|
30
|
-
return ruby_engine == self.engine_name
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.mri?() self == Mri; end
|
|
34
|
-
def self.jruby?() self == Jruby; end
|
|
35
|
-
def self.rbx?() self == Rbx; end
|
|
36
|
-
def self.macruby?() self == MacRuby; end
|
|
37
|
-
|
|
38
|
-
attr_reader :ruby_engine
|
|
39
|
-
alias to_s ruby_engine
|
|
40
|
-
def initialize( ruby_engine = Launchy.ruby_engine )
|
|
41
|
-
if ruby_engine then
|
|
42
|
-
@ruby_engine = ruby_engine
|
|
43
|
-
else
|
|
44
|
-
@ruby_engine = defined?( RUBY_ENGINE ) ? RUBY_ENGINE : "ruby"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
#-------------------------------
|
|
50
|
-
# The list of known ruby engines
|
|
51
|
-
#-------------------------------
|
|
52
|
-
|
|
53
|
-
#
|
|
54
|
-
# This is the ruby engine if the RUBY_ENGINE constant is not defined
|
|
55
|
-
class Mri < RubyEngine
|
|
56
|
-
def self.engine_name() "ruby"; end
|
|
57
|
-
def self.is_current_engine?( ruby_engine )
|
|
58
|
-
if ruby_engine then
|
|
59
|
-
super( ruby_engine )
|
|
60
|
-
else
|
|
61
|
-
return true if not Launchy.ruby_engine and not defined?( RUBY_ENGINE )
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
class Jruby < RubyEngine
|
|
67
|
-
def self.engine_name() "jruby"; end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
class Rbx < RubyEngine
|
|
71
|
-
def self.engine_name() "rbx"; end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
class MacRuby < RubyEngine
|
|
75
|
-
def self.engine_name() "macruby"; end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|