tty-which 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/tty-which.rb +1 -1
- data/lib/tty/which.rb +4 -5
- data/lib/tty/which/version.rb +1 -1
- data/spec/unit/extensions_spec.rb +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03043a40c5cf44b4afbd6c213c373fd75299e8cc
|
4
|
+
data.tar.gz: 80a1f7dc2748814fb8d3b9d0f92fad214a2098a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef5e7498c79265dd91d347b33ab45afc7e4ce43e298d6339733cd554dec32bdcf256644340f9458e9283bcddc3332c1eebe736b16569bc3b681a2e3f32a0753
|
7
|
+
data.tar.gz: a116bc4bed3540b165351932a4d5644e53c66313ee87190e08b8e47f4a438b1f227c0b1de70aecaeb3eb115f3f2b7e06b37f137cffc3a52299d616b977ba8daa
|
data/CHANGELOG.md
CHANGED
data/lib/tty-which.rb
CHANGED
data/lib/tty/which.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'which/version'
|
4
4
|
|
5
5
|
module TTY
|
6
6
|
# A class responsible for finding an executable in the PATH
|
@@ -29,8 +29,7 @@ module TTY
|
|
29
29
|
return nil
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
search_path.each do |path|
|
32
|
+
search_paths.each do |path|
|
34
33
|
if file_with_exec_ext?(cmd)
|
35
34
|
exe = ::File.join(path, cmd)
|
36
35
|
return ::File.absolute_path(exe) if executable_file?(exe)
|
@@ -83,7 +82,7 @@ module TTY
|
|
83
82
|
end
|
84
83
|
module_function :search_paths
|
85
84
|
|
86
|
-
# All
|
85
|
+
# All possible file extensions
|
87
86
|
#
|
88
87
|
# @example
|
89
88
|
# extensions('.exe;cmd;.bat')
|
@@ -98,7 +97,7 @@ module TTY
|
|
98
97
|
# @api private
|
99
98
|
def extensions(path_ext = ENV['PATHEXT'])
|
100
99
|
return [''] unless path_ext
|
101
|
-
path_ext.split(
|
100
|
+
path_ext.split(::File::PATH_SEPARATOR).select { |part| part.include?('.') }
|
102
101
|
end
|
103
102
|
module_function :extensions
|
104
103
|
|
data/lib/tty/which/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
RSpec.describe TTY::Which, '#extensions' do
|
4
|
+
it "provides extensions" do
|
5
|
+
exts = [".COM", ".EXE", ".BAT", ".CMD", ".VBS", ".RB", ".RBW"]
|
6
|
+
exts_path = exts.join(::File::PATH_SEPARATOR)
|
7
|
+
allow(ENV).to receive(:[]).with('PATHEXT').and_return(exts_path)
|
8
|
+
|
9
|
+
expect(TTY::Which.extensions).to eq(exts)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "finds no extensions" do
|
13
|
+
allow(ENV).to receive(:[]).with('PATHEXT').and_return(nil)
|
14
|
+
expect(TTY::Which.extensions).to eq([''])
|
15
|
+
end
|
16
|
+
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- spec/spec_helper.rb
|
67
67
|
- spec/unit/executable_file_spec.rb
|
68
68
|
- spec/unit/exist_spec.rb
|
69
|
+
- spec/unit/extensions_spec.rb
|
69
70
|
- spec/unit/file_with_exec_ext_spec.rb
|
70
71
|
- spec/unit/search_paths_spec.rb
|
71
72
|
- spec/unit/which_spec.rb
|
@@ -101,6 +102,7 @@ test_files:
|
|
101
102
|
- spec/spec_helper.rb
|
102
103
|
- spec/unit/executable_file_spec.rb
|
103
104
|
- spec/unit/exist_spec.rb
|
105
|
+
- spec/unit/extensions_spec.rb
|
104
106
|
- spec/unit/file_with_exec_ext_spec.rb
|
105
107
|
- spec/unit/search_paths_spec.rb
|
106
108
|
- spec/unit/which_spec.rb
|