whichr 0.3.2 → 0.3.3
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.
- data/lib/whichr.rb +49 -49
- metadata +21 -19
data/lib/whichr.rb
CHANGED
@@ -5,9 +5,9 @@ class RubyWhich
|
|
5
5
|
# like ['abc'] (in windows, also searches for abc.bat)
|
6
6
|
# or ['ab*'] (a glob, in windows, also reveals ab*.bat)
|
7
7
|
def which( names, return_non_executables_too = false, realtime_output = false )
|
8
|
-
|
8
|
+
|
9
9
|
puts "higher in the list is executed first" if realtime_output
|
10
|
-
|
10
|
+
|
11
11
|
names = Array(names)
|
12
12
|
|
13
13
|
if OS.windows?
|
@@ -24,64 +24,64 @@ class RubyWhich
|
|
24
24
|
path = ENV['PATH']
|
25
25
|
# on windows add cwd
|
26
26
|
path += (File::PATH_SEPARATOR + '.') if OS.windows?
|
27
|
-
|
27
|
+
|
28
28
|
path.split(File::PATH_SEPARATOR).each do |dir|
|
29
|
-
|
29
|
+
|
30
30
|
for name in names
|
31
31
|
if OS.windows?
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
names2 = Dir.glob(dir.gsub("\\", "/") + '/' + name.strip)
|
33
|
+
unless return_non_executables_too
|
34
|
+
names2 = names2.select{|name| File.executable?(name)} # only real execs
|
35
|
+
end
|
36
|
+
names2.collect!{|name| File.expand_path(name)} # get the right capitalization
|
37
37
|
else
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
all_found += uniques
|
74
|
-
|
38
|
+
names2 = Dir.glob(dir + '/' + name.strip)
|
39
|
+
end
|
40
|
+
|
41
|
+
# expand paths
|
42
|
+
names2.collect!{|name| File.expand_path(name).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)}
|
43
|
+
|
44
|
+
# make sure we aren't repeating a previous
|
45
|
+
uniques = names2.select{|new|
|
46
|
+
new = new.downcase if OS.windows?
|
47
|
+
am_unique = true
|
48
|
+
all_found.each{|old|
|
49
|
+
old = old.downcase if OS.windows?
|
50
|
+
if old == new
|
51
|
+
am_unique = false
|
52
|
+
break
|
53
|
+
end
|
54
|
+
}
|
55
|
+
am_unique
|
56
|
+
}
|
57
|
+
|
58
|
+
if realtime_output
|
59
|
+
uniques.each{ |file|
|
60
|
+
print file
|
61
|
+
|
62
|
+
if !File.executable? file
|
63
|
+
print += ' (is not executable)'
|
64
|
+
end
|
65
|
+
|
66
|
+
if File.directory?(file)
|
67
|
+
print ' (is a directory)'
|
68
|
+
end
|
69
|
+
puts
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
all_found += uniques
|
74
|
+
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
if realtime_output
|
79
79
|
if all_found == []
|
80
|
-
|
80
|
+
puts 'none found (' + names.inspect + ')'
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
all_found
|
85
85
|
end
|
86
86
|
|
87
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whichr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 3
|
9
|
+
version: 0.3.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Roger Pack
|
@@ -9,29 +14,22 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-11-24 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: rdoc
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 2.3.0
|
24
|
-
version:
|
25
20
|
- !ruby/object:Gem::Dependency
|
26
21
|
name: sane
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
30
25
|
requirements:
|
31
26
|
- - ">="
|
32
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
33
30
|
version: "0"
|
34
|
-
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
35
33
|
description: windows friendly which command
|
36
34
|
email:
|
37
35
|
- rogerdpack@gmail.comm
|
@@ -55,21 +53,25 @@ rdoc_options: []
|
|
55
53
|
require_paths:
|
56
54
|
- lib
|
57
55
|
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
58
57
|
requirements:
|
59
58
|
- - ">="
|
60
59
|
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
61
62
|
version: "0"
|
62
|
-
version:
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
64
65
|
requirements:
|
65
66
|
- - ">="
|
66
67
|
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
67
70
|
version: "0"
|
68
|
-
version:
|
69
71
|
requirements: []
|
70
72
|
|
71
73
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.3.
|
74
|
+
rubygems_version: 1.3.7
|
73
75
|
signing_key:
|
74
76
|
specification_version: 3
|
75
77
|
summary: windows friendly which command
|