rogerdpack-whichr 0.0.6

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 (3) hide show
  1. data/README +20 -0
  2. data/bin/whichr +49 -0
  3. metadata +75 -0
data/README ADDED
@@ -0,0 +1,20 @@
1
+ which_ruby: the linux "which" command re-written in ruby [and windows-friendly+aware [recognizes .bat files, etc.]]
2
+
3
+ A which command for windows that actually works!
4
+
5
+ Itch it scratches: there seems to be a lack of a "which" command for windows that actually works--they all skip batch files or report file output without extensions, so even if you run "which xxx" you never know what you're really running when you type xxx in the command line--is it xxx.exe [the thing reported from 'which'] or xxx.bat somewhere previous to this in the path? This executable makes this crystal clear and is a must have for every windows developer.
6
+
7
+ To install:
8
+ C:> gem install rogerdpack-whichr
9
+
10
+ C:> whichr executable_name_here [extension could be included, but is optional]
11
+
12
+ example:
13
+ C:\>whichr ruby
14
+ higher in the list will be executed first
15
+ C:/Ruby/bin/ruby.exe
16
+ c:/cygwin/bin/ruby.exe
17
+
18
+ Based originally on some code stolen from ruby gnuplot, extracted.
19
+
20
+ Feedback welcome rogerdpack on github
data/bin/whichr ADDED
@@ -0,0 +1,49 @@
1
+ # stolen from the gnuplot gem
2
+ # and then modified
3
+ require 'sane'
4
+
5
+ if(ARGV[0].in?( ['-h', '--help'])) || !ARGV[0]
6
+ puts 'syntax: binary_name'
7
+ else
8
+ puts 'higher in the list will be executed first'
9
+ def which ( bins )
10
+ success = false
11
+ path = '.' + File::PATH_SEPARATOR + ENV['PATH']
12
+
13
+ path.split(File::PATH_SEPARATOR).each do |dir|
14
+ for bin in bins
15
+ candidates = Dir.glob(dir.gsub("\\", "/") + '/' + bin.strip)
16
+ for candidate in candidates
17
+ if File::executable?(candidate)
18
+ print candidate
19
+ if(File.directory?(candidate))
20
+ print ' (is a directory)'
21
+ end
22
+ success = true
23
+ puts
24
+ elsif File::exist? candidate
25
+ puts candidate + ' (is not executable)'
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ # This is an implementation that works when the which command is
32
+ # available.
33
+ #
34
+ # IO.popen("which #{bin}") { |io| return io.readline.chomp }
35
+ return success
36
+ end
37
+
38
+ list = [ARGV[0]]
39
+
40
+ if RUBY_PLATFORM =~ /mswin|mingw/
41
+ # windows compat.
42
+ for extension in ['.exe', '.bat', '.cmd', '.dll'] do
43
+ list << ARGV[0] + extension
44
+ end
45
+ end
46
+
47
+ which(list)
48
+
49
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rogerdpack-whichr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Roger Pack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-16 00:00:00 -07:00
13
+ default_executable:
14
+ 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
+ - !ruby/object:Gem::Dependency
26
+ name: rogerdpack-sane
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: windows friendly which command
36
+ email:
37
+ - rogerdpack@gmail.comm
38
+ executables:
39
+ - whichr
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - bin/whichr
46
+ - README
47
+ has_rdoc: false
48
+ homepage: http://github.com/rogerdpack/which_ruby
49
+ licenses:
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.5
71
+ signing_key:
72
+ specification_version: 2
73
+ summary: windows friendly which command
74
+ test_files: []
75
+