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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0564dab361818f8fe4bd139c3deeda65f415489
4
- data.tar.gz: 5bcb87690ee5c6f434f86c296a277e476c2a389a
3
+ metadata.gz: 03043a40c5cf44b4afbd6c213c373fd75299e8cc
4
+ data.tar.gz: 80a1f7dc2748814fb8d3b9d0f92fad214a2098a9
5
5
  SHA512:
6
- metadata.gz: 99d898008a1993662be188d7423bf689a211c909af5e9ec8274a96e890f8af5058dadccf002fd8552327b1656c9f114db81ac21312e67ed8bcc2856b8759ddec
7
- data.tar.gz: 0afa8540a55ff6134e8d2d1180d8f1a4815804cbbefdd34faafcce5e582f6f80803b30c3eb20eb855e5e088b4b096e9d16b7ea8bc06f367e48923f7340d298fc
6
+ metadata.gz: 5ef5e7498c79265dd91d347b33ab45afc7e4ce43e298d6339733cd554dec32bdcf256644340f9458e9283bcddc3332c1eebe736b16569bc3b681a2e3f32a0753
7
+ data.tar.gz: a116bc4bed3540b165351932a4d5644e53c66313ee87190e08b8e47f4a438b1f227c0b1de70aecaeb3eb115f3f2b7e06b37f137cffc3a52299d616b977ba8daa
@@ -1,5 +1,12 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.3.0] - 2017-03-20
4
+
5
+ ### Changed
6
+ * Change #extensions to use file path separator
7
+ * Change files loading
8
+ * Remove search paths caching
9
+
3
10
  ## [v0.2.2] - 2017-02-06
4
11
 
5
12
  ### Fixed
@@ -1,3 +1,3 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'tty/which'
3
+ require_relative 'tty/which'
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'tty/which/version'
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
- search_path ||= search_paths
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 files that contain a '.' in name
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(';').select { |part| part.include?('.') }
100
+ path_ext.split(::File::PATH_SEPARATOR).select { |part| part.include?('.') }
102
101
  end
103
102
  module_function :extensions
104
103
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  module Which
5
- VERSION = "0.2.2"
5
+ VERSION = "0.3.0"
6
6
  end # Which
7
7
  end # TTY
@@ -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.2.2
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-02-06 00:00:00.000000000 Z
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