tty-which 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -4
- data/CHANGELOG.md +7 -1
- data/README.md +1 -1
- data/lib/tty/which.rb +11 -11
- data/lib/tty/which/version.rb +1 -1
- data/spec/unit/executable_file_spec.rb +3 -3
- data/spec/unit/search_paths_spec.rb +2 -4
- data/spec/unit/which_spec.rb +18 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0564dab361818f8fe4bd139c3deeda65f415489
|
4
|
+
data.tar.gz: 5bcb87690ee5c6f434f86c296a277e476c2a389a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d898008a1993662be188d7423bf689a211c909af5e9ec8274a96e890f8af5058dadccf002fd8552327b1656c9f114db81ac21312e67ed8bcc2856b8759ddec
|
7
|
+
data.tar.gz: 0afa8540a55ff6134e8d2d1180d8f1a4815804cbbefdd34faafcce5e582f6f80803b30c3eb20eb855e5e088b4b096e9d16b7ea8bc06f367e48923f7340d298fc
|
data/.travis.yml
CHANGED
@@ -7,17 +7,18 @@ rvm:
|
|
7
7
|
- 1.9.3
|
8
8
|
- 2.0.0
|
9
9
|
- 2.1.10
|
10
|
-
- 2.2.
|
11
|
-
- 2.3.
|
10
|
+
- 2.2.6
|
11
|
+
- 2.3.3
|
12
|
+
- 2.4.0
|
12
13
|
- ruby-head
|
13
14
|
- jruby-9000
|
14
15
|
- jruby-head
|
15
|
-
- rbx-
|
16
|
+
- rbx-3
|
16
17
|
matrix:
|
17
18
|
allow_failures:
|
18
19
|
- rvm: ruby-head
|
19
20
|
- rvm: jruby-head
|
20
|
-
- rvm: rbx-
|
21
|
+
- rvm: rbx-3
|
21
22
|
fast_finish: true
|
22
23
|
branches:
|
23
24
|
only: master
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
## [v0.2.
|
3
|
+
## [v0.2.2] - 2017-02-06
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
* Fix File namespacing issue
|
7
|
+
|
8
|
+
## [v0.2.1] - 2016-12-26
|
4
9
|
|
5
10
|
### Changed
|
6
11
|
* Change to stop shadowing path var in Which#search_paths
|
@@ -22,6 +27,7 @@
|
|
22
27
|
|
23
28
|
* Initial implementation and release
|
24
29
|
|
30
|
+
[v0.2.2]: https://github.com/piotrmurach/tty-which/compare/v0.2.1...v0.2.2
|
25
31
|
[v0.2.1]: https://github.com/piotrmurach/tty-which/compare/v0.2.0...v0.2.1
|
26
32
|
[v0.2.0]: https://github.com/piotrmurach/tty-which/compare/v0.1.0...v0.2.0
|
27
33
|
[v0.1.0]: https://github.com/piotrmurach/tty-which/compare/v0.1.0
|
data/README.md
CHANGED
data/lib/tty/which.rb
CHANGED
@@ -23,8 +23,8 @@ module TTY
|
|
23
23
|
if file_with_path?(cmd)
|
24
24
|
return cmd if executable_file?(cmd)
|
25
25
|
extensions.each do |ext|
|
26
|
-
exe = File.join(cmd, ext)
|
27
|
-
return File.absolute_path(exe) if executable_file?(exe)
|
26
|
+
exe = ::File.join(cmd, ext)
|
27
|
+
return ::File.absolute_path(exe) if executable_file?(exe)
|
28
28
|
end
|
29
29
|
return nil
|
30
30
|
end
|
@@ -32,12 +32,12 @@ module TTY
|
|
32
32
|
search_path ||= search_paths
|
33
33
|
search_path.each do |path|
|
34
34
|
if file_with_exec_ext?(cmd)
|
35
|
-
exe = File.join(path, cmd)
|
36
|
-
return File.absolute_path(exe) if executable_file?(exe)
|
35
|
+
exe = ::File.join(path, cmd)
|
36
|
+
return ::File.absolute_path(exe) if executable_file?(exe)
|
37
37
|
end
|
38
38
|
extensions.each do |ext|
|
39
|
-
exe = File.join(path, "#{cmd}#{ext}")
|
40
|
-
return File.absolute_path(exe) if executable_file?(exe)
|
39
|
+
exe = ::File.join(path, "#{cmd}#{ext}")
|
40
|
+
return ::File.absolute_path(exe) if executable_file?(exe)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
nil
|
@@ -75,7 +75,7 @@ module TTY
|
|
75
75
|
# @api private
|
76
76
|
def search_paths(path = ENV['PATH'])
|
77
77
|
paths = if path && !path.empty?
|
78
|
-
path.split(File::PATH_SEPARATOR)
|
78
|
+
path.split(::File::PATH_SEPARATOR)
|
79
79
|
else
|
80
80
|
%w(/usr/local/bin /usr/ucb /usr/bin /bin)
|
81
81
|
end
|
@@ -120,9 +120,9 @@ module TTY
|
|
120
120
|
#
|
121
121
|
# @api private
|
122
122
|
def executable_file?(filename, dir = nil)
|
123
|
-
path = File.join(dir, filename) if dir
|
123
|
+
path = ::File.join(dir, filename) if dir
|
124
124
|
path ||= filename
|
125
|
-
File.file?(path) && File.executable?(path)
|
125
|
+
::File.file?(path) && ::File.executable?(path)
|
126
126
|
end
|
127
127
|
module_function :executable_file?
|
128
128
|
|
@@ -139,7 +139,7 @@ module TTY
|
|
139
139
|
#
|
140
140
|
# @api private
|
141
141
|
def file_with_exec_ext?(filename)
|
142
|
-
extension = File.extname(filename)
|
142
|
+
extension = ::File.extname(filename)
|
143
143
|
return false if extension.empty?
|
144
144
|
extensions.any? { |ext| extension.casecmp(ext).zero? }
|
145
145
|
end
|
@@ -154,7 +154,7 @@ module TTY
|
|
154
154
|
#
|
155
155
|
# @api private
|
156
156
|
def file_with_path?(cmd)
|
157
|
-
File.expand_path(cmd) == cmd
|
157
|
+
::File.expand_path(cmd) == cmd
|
158
158
|
end
|
159
159
|
module_function :file_with_path?
|
160
160
|
end # Which
|
data/lib/tty/which/version.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
RSpec.describe TTY::Which, '#executable_file?' do
|
4
4
|
it "checks if file is executable" do
|
5
|
-
allow(File).to receive(:join).with('/usr/local/bin', 'ruby').
|
5
|
+
allow(::File).to receive(:join).with('/usr/local/bin', 'ruby').
|
6
6
|
and_return('/usr/local/bin/ruby')
|
7
7
|
|
8
|
-
allow(File).to receive(:file?).and_return(true)
|
9
|
-
allow(File).to receive(:executable?).with('/usr/local/bin/ruby').and_return(true)
|
8
|
+
allow(::File).to receive(:file?).and_return(true)
|
9
|
+
allow(::File).to receive(:executable?).with('/usr/local/bin/ruby').and_return(true)
|
10
10
|
|
11
11
|
expect(TTY::Which.executable_file?('ruby', '/usr/local/bin')).to eq(true)
|
12
12
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
RSpec.describe TTY::Which, '#search_paths' do
|
4
|
-
let(:path_sep) { File::PATH_SEPARATOR }
|
5
|
-
|
6
4
|
it "defauls search paths" do
|
7
5
|
allow(ENV).to receive(:[]).with('PATH').and_return([])
|
8
6
|
allow(Dir).to receive(:exist?).and_return(true)
|
@@ -13,7 +11,7 @@ RSpec.describe TTY::Which, '#search_paths' do
|
|
13
11
|
|
14
12
|
it "finds paths in path environment" do
|
15
13
|
paths = ['/bin', '/usr/bin', '/usr/local/bin', '/opt/local/bin']
|
16
|
-
path = paths.join(File::PATH_SEPARATOR)
|
14
|
+
path = paths.join(::File::PATH_SEPARATOR)
|
17
15
|
allow(ENV).to receive(:[]).with('PATH').and_return(path)
|
18
16
|
allow(Dir).to receive(:exist?).and_return(true)
|
19
17
|
|
@@ -22,7 +20,7 @@ RSpec.describe TTY::Which, '#search_paths' do
|
|
22
20
|
|
23
21
|
it "accepts paths to search as an argument" do
|
24
22
|
paths = ['/bin', '/usr/bin', '/usr/local/bin', '/opt/local/bin']
|
25
|
-
path = paths.join(File::PATH_SEPARATOR)
|
23
|
+
path = paths.join(::File::PATH_SEPARATOR)
|
26
24
|
allow(Dir).to receive(:exist?).and_return(true)
|
27
25
|
|
28
26
|
expect(TTY::Which.search_paths(path)).to eq(paths)
|
data/spec/unit/which_spec.rb
CHANGED
@@ -11,8 +11,8 @@ RSpec.describe TTY::Which, '#which' do
|
|
11
11
|
before do
|
12
12
|
allow(ENV).to receive(:[]).with('PATHEXT').and_return(nil)
|
13
13
|
allow(ENV).to receive(:[]).with('PATH').and_return(path)
|
14
|
-
stub_const("File::PATH_SEPARATOR", ':')
|
15
|
-
stub_const("File::SEPARATOR", '/')
|
14
|
+
stub_const("::File::PATH_SEPARATOR", ':')
|
15
|
+
stub_const("::File::SEPARATOR", '/')
|
16
16
|
allow(Dir).to receive(:exist?) { true }
|
17
17
|
end
|
18
18
|
|
@@ -37,11 +37,11 @@ RSpec.describe TTY::Which, '#which' do
|
|
37
37
|
allow(Which).to receive(:file_with_path?) { false }
|
38
38
|
allow(Which).to receive(:file_with_exec_ext?) { false }
|
39
39
|
|
40
|
-
allow(File).to receive(:join)
|
41
|
-
allow(File).to receive(:join).with(dir_path, cmd).and_return(expected_path)
|
40
|
+
allow(::File).to receive(:join)
|
41
|
+
allow(::File).to receive(:join).with(dir_path, cmd).and_return(expected_path)
|
42
42
|
allow(Which).to receive(:executable_file?) { false }
|
43
43
|
allow(Which).to receive(:executable_file?).with(expected_path) { true }
|
44
|
-
allow(File).to receive(:absolute_path).with(expected_path).
|
44
|
+
allow(::File).to receive(:absolute_path).with(expected_path).
|
45
45
|
and_return(expected_path)
|
46
46
|
|
47
47
|
expect(Which.which(cmd)).to eq(expected_path)
|
@@ -55,8 +55,8 @@ RSpec.describe TTY::Which, '#which' do
|
|
55
55
|
before do
|
56
56
|
allow(ENV).to receive(:[]).with('PATHEXT').and_return(exts)
|
57
57
|
allow(ENV).to receive(:[]).with('PATH').and_return(path)
|
58
|
-
stub_const("File::PATH_SEPARATOR", ';')
|
59
|
-
stub_const("File::SEPARATOR", '\\')
|
58
|
+
stub_const("::File::PATH_SEPARATOR", ';')
|
59
|
+
stub_const("::File::SEPARATOR", '\\')
|
60
60
|
allow(Dir).to receive(:exist?) { true }
|
61
61
|
end
|
62
62
|
|
@@ -67,12 +67,12 @@ RSpec.describe TTY::Which, '#which' do
|
|
67
67
|
path_with_exe_file = 'C:\Program Files\Git\bin\git'
|
68
68
|
expected_path = "#{path_with_exe_file}.exe"
|
69
69
|
|
70
|
-
allow(File).to receive(:join).with(path_with_exe_file, any_args).
|
70
|
+
allow(::File).to receive(:join).with(path_with_exe_file, any_args).
|
71
71
|
and_return(path_with_exe_file)
|
72
|
-
allow(File).to receive(:join).with(path_with_exe_file, '.exe').
|
72
|
+
allow(::File).to receive(:join).with(path_with_exe_file, '.exe').
|
73
73
|
and_return(expected_path)
|
74
74
|
allow(Which).to receive(:executable_file?).with(expected_path) { true }
|
75
|
-
allow(File).to receive(:absolute_path).and_return(expected_path)
|
75
|
+
allow(::File).to receive(:absolute_path).and_return(expected_path)
|
76
76
|
|
77
77
|
expect(Which.which(path_with_exe_file)).to eq(expected_path)
|
78
78
|
end
|
@@ -84,15 +84,15 @@ RSpec.describe TTY::Which, '#which' do
|
|
84
84
|
allow(Which).to receive(:file_with_path?) { false }
|
85
85
|
allow(Which).to receive(:file_with_exec_ext?).with(cmd) { true }
|
86
86
|
|
87
|
-
allow(File).to receive(:join).with(dir_path, any_args)
|
88
|
-
allow(File).to receive(:join).with(dir_path, cmd).and_return(expected_path)
|
87
|
+
allow(::File).to receive(:join).with(dir_path, any_args)
|
88
|
+
allow(::File).to receive(:join).with(dir_path, cmd).and_return(expected_path)
|
89
89
|
allow(Which).to receive(:executable_file?).with(any_args) { false }
|
90
90
|
allow(Which).to receive(:executable_file?).with(expected_path) { true }
|
91
|
-
allow(File).to receive(:absolute_path).with(expected_path).
|
91
|
+
allow(::File).to receive(:absolute_path).with(expected_path).
|
92
92
|
and_return(expected_path)
|
93
93
|
|
94
94
|
expect(Which.which(cmd)).to eq(expected_path)
|
95
|
-
expect(File).to have_received(:absolute_path).with(expected_path)
|
95
|
+
expect(::File).to have_received(:absolute_path).with(expected_path)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "searches path for executable git" do
|
@@ -102,16 +102,16 @@ RSpec.describe TTY::Which, '#which' do
|
|
102
102
|
allow(Which).to receive(:file_with_path?) { false }
|
103
103
|
allow(Which).to receive(:file_with_exec_ext?).with(cmd) { false }
|
104
104
|
|
105
|
-
allow(File).to receive(:join).with(dir_path, any_args)
|
106
|
-
allow(File).to receive(:join).with(dir_path, "#{cmd}.exe").
|
105
|
+
allow(::File).to receive(:join).with(dir_path, any_args)
|
106
|
+
allow(::File).to receive(:join).with(dir_path, "#{cmd}.exe").
|
107
107
|
and_return(expected_path)
|
108
108
|
allow(Which).to receive(:executable_file?).with(any_args) { false }
|
109
109
|
allow(Which).to receive(:executable_file?).with(expected_path) { true }
|
110
|
-
allow(File).to receive(:absolute_path).with(expected_path).
|
110
|
+
allow(::File).to receive(:absolute_path).with(expected_path).
|
111
111
|
and_return(expected_path)
|
112
112
|
|
113
113
|
expect(Which.which(cmd)).to eq(expected_path)
|
114
|
-
expect(File).to have_received(:absolute_path).with(expected_path)
|
114
|
+
expect(::File).to have_received(:absolute_path).with(expected_path)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-which
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|