whichr 0.3.1 → 0.3.2

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