which_works 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -9
- data/LICENSE.txt +1 -1
- data/README.md +7 -13
- data/VERSION +1 -1
- data/lib/which_works.rb +1 -0
- metadata +51 -66
- data/.document +0 -5
- data/.rspec +0 -2
- data/.rvmrc +0 -41
- data/.travis.yml +0 -5
- data/Gemfile.lock +0 -47
- data/Rakefile +0 -58
- data/spec/all_spec.rb +0 -24
- data/spec/array_spec.rb +0 -24
- data/spec/basic_spec.rb +0 -42
- data/spec/helper.rb +0 -52
- data/spec/options_spec.rb +0 -77
- data/which_works.gemspec +0 -80
data/Gemfile
CHANGED
@@ -6,13 +6,10 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
-
gem 'rake'
|
10
|
-
gem 'rspec'
|
11
|
-
gem '
|
12
|
-
gem '
|
13
|
-
gem '
|
14
|
-
gem '
|
15
|
-
gem 'yard', '~> 0.7.5'
|
16
|
-
gem 'rdiscount', '~> 1.6.8'
|
17
|
-
gem 'travis-lint', '~> 1.3.0'
|
9
|
+
gem 'rake'
|
10
|
+
gem 'rspec'
|
11
|
+
gem 'jeweler'
|
12
|
+
gem 'simplecov'
|
13
|
+
gem 'travis-lint'
|
14
|
+
gem 'rake-version'
|
18
15
|
end
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
**Ruby UNIX-like which. Locates a program file in the user's path.**
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/which_works.png)](http://badge.fury.io/rb/which\_works)
|
6
|
+
[![Dependency Status](https://gemnasium.com/AlphaHydrae/which_works.png)](https://gemnasium.com/AlphaHydrae/which\_works)
|
7
|
+
[![Build Status](https://secure.travis-ci.org/AlphaHydrae/which_works.png?branch=master)](http://travis-ci.org/AlphaHydrae/which\_works)
|
8
|
+
|
5
9
|
The `which` method takes a list of command names and searches the path
|
6
10
|
for each executable file that would be run had these commands actually
|
7
11
|
been invoked.
|
@@ -41,17 +45,7 @@ Which.which('ls', :array => false) #=> "/bin/ls"
|
|
41
45
|
Which.options #=> { :all => true, :array => true }
|
42
46
|
```
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
* master [![Build Status](https://secure.travis-ci.org/AlphaHydrae/which_works.png?branch=master)](http://travis-ci.org/AlphaHydrae/which\_works)
|
47
|
-
* develop [![Build Status](https://secure.travis-ci.org/AlphaHydrae/which_works.png?branch=develop)](http://travis-ci.org/AlphaHydrae/which\_works)
|
48
|
-
|
49
|
-
## License (MIT)
|
50
|
-
|
51
|
-
Copyright (c) 2011 Alpha Hydrae
|
52
|
-
|
53
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
54
|
-
|
55
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
48
|
+
## Meta
|
56
49
|
|
57
|
-
|
50
|
+
* **Author:** Simon Oulevay (Alpha Hydrae)
|
51
|
+
* **License:** MIT (see [LICENSE.txt](https://raw.github.com/AlphaHydrae/which_works/master/LICENSE.txt))
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/which_works.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: which_works
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,107 +9,104 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0
|
21
|
+
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rspec
|
27
|
-
requirement: &70324806493580 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70324806493580
|
29
|
+
version: '0'
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement:
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
34
|
requirements:
|
41
|
-
- -
|
35
|
+
- - ! '>='
|
42
36
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
37
|
+
version: '0'
|
44
38
|
type: :development
|
45
39
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: bundler
|
49
|
-
requirement: &70324806492460 !ruby/object:Gem::Requirement
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
41
|
none: false
|
51
42
|
requirements:
|
52
43
|
- - ! '>='
|
53
44
|
- !ruby/object:Gem::Version
|
54
45
|
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *70324806492460
|
58
46
|
- !ruby/object:Gem::Dependency
|
59
47
|
name: jeweler
|
60
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
61
49
|
none: false
|
62
50
|
requirements:
|
63
|
-
- -
|
51
|
+
- - ! '>='
|
64
52
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
53
|
+
version: '0'
|
66
54
|
type: :development
|
67
55
|
prerelease: false
|
68
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
69
62
|
- !ruby/object:Gem::Dependency
|
70
63
|
name: simplecov
|
71
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
72
65
|
none: false
|
73
66
|
requirements:
|
74
|
-
- -
|
67
|
+
- - ! '>='
|
75
68
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0
|
69
|
+
version: '0'
|
77
70
|
type: :development
|
78
71
|
prerelease: false
|
79
|
-
version_requirements:
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: yard
|
82
|
-
requirement: &70324806490800 !ruby/object:Gem::Requirement
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
73
|
none: false
|
84
74
|
requirements:
|
85
|
-
- -
|
75
|
+
- - ! '>='
|
86
76
|
- !ruby/object:Gem::Version
|
87
|
-
version: 0
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *70324806490800
|
77
|
+
version: '0'
|
91
78
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
93
|
-
requirement:
|
79
|
+
name: travis-lint
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
94
81
|
none: false
|
95
82
|
requirements:
|
96
|
-
- -
|
83
|
+
- - ! '>='
|
97
84
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
85
|
+
version: '0'
|
99
86
|
type: :development
|
100
87
|
prerelease: false
|
101
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
102
94
|
- !ruby/object:Gem::Dependency
|
103
|
-
name:
|
104
|
-
requirement:
|
95
|
+
name: rake-version
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
105
97
|
none: false
|
106
98
|
requirements:
|
107
|
-
- -
|
99
|
+
- - ! '>='
|
108
100
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
101
|
+
version: '0'
|
110
102
|
type: :development
|
111
103
|
prerelease: false
|
112
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
113
110
|
description: Locates a program file in the user's path. The which method takes a list
|
114
111
|
of command names and searches the path for each executable file that would be run
|
115
112
|
had these commands actually been invoked.
|
@@ -120,24 +117,12 @@ extra_rdoc_files:
|
|
120
117
|
- LICENSE.txt
|
121
118
|
- README.md
|
122
119
|
files:
|
123
|
-
- .document
|
124
|
-
- .rspec
|
125
|
-
- .rvmrc
|
126
|
-
- .travis.yml
|
127
120
|
- Gemfile
|
128
|
-
- Gemfile.lock
|
129
121
|
- LICENSE.txt
|
130
122
|
- README.md
|
131
|
-
- Rakefile
|
132
123
|
- VERSION
|
133
124
|
- lib/which_works.rb
|
134
|
-
|
135
|
-
- spec/array_spec.rb
|
136
|
-
- spec/basic_spec.rb
|
137
|
-
- spec/helper.rb
|
138
|
-
- spec/options_spec.rb
|
139
|
-
- which_works.gemspec
|
140
|
-
homepage: http://github.com/AlphaHydrae/which_works
|
125
|
+
homepage: https://github.com/AlphaHydrae/which_works
|
141
126
|
licenses:
|
142
127
|
- MIT
|
143
128
|
post_install_message:
|
@@ -152,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
137
|
version: '0'
|
153
138
|
segments:
|
154
139
|
- 0
|
155
|
-
hash:
|
140
|
+
hash: 4415458449905220860
|
156
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
142
|
none: false
|
158
143
|
requirements:
|
@@ -161,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
146
|
version: '0'
|
162
147
|
requirements: []
|
163
148
|
rubyforge_project:
|
164
|
-
rubygems_version: 1.8.
|
149
|
+
rubygems_version: 1.8.25
|
165
150
|
signing_key:
|
166
151
|
specification_version: 3
|
167
152
|
summary: Ruby UNIX-like which.
|
data/.document
DELETED
data/.rspec
DELETED
data/.rvmrc
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
-
environment_id="ruby-1.9.2@which_works"
|
8
|
-
|
9
|
-
#
|
10
|
-
# First we attempt to load the desired environment directly from the environment
|
11
|
-
# file. This is very fast and efficicent compared to running through the entire
|
12
|
-
# CLI and selector. If you want feedback on which environment was used then
|
13
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
14
|
-
#
|
15
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
16
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
17
|
-
then
|
18
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
19
|
-
|
20
|
-
if [[ -s ".rvm/hooks/after_use" ]]
|
21
|
-
then
|
22
|
-
. ".rvm/hooks/after_use"
|
23
|
-
fi
|
24
|
-
else
|
25
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
26
|
-
if ! rvm --create "$environment_id"
|
27
|
-
then
|
28
|
-
echo "Failed to create RVM environment ''."
|
29
|
-
fi
|
30
|
-
fi
|
31
|
-
|
32
|
-
#
|
33
|
-
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
34
|
-
# it be automatically loaded. Uncomment the following and adjust the filename if
|
35
|
-
# necessary.
|
36
|
-
#
|
37
|
-
# filename=".gems"
|
38
|
-
# if [[ -s "$filename" ]] ; then
|
39
|
-
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
40
|
-
# fi
|
41
|
-
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.1.3)
|
5
|
-
git (1.2.5)
|
6
|
-
hashr (0.0.19)
|
7
|
-
jeweler (1.8.3)
|
8
|
-
bundler (~> 1.0)
|
9
|
-
git (>= 1.2.5)
|
10
|
-
rake
|
11
|
-
rdoc
|
12
|
-
json (1.6.5)
|
13
|
-
multi_json (1.0.4)
|
14
|
-
rake (0.9.2.2)
|
15
|
-
rdiscount (1.6.8)
|
16
|
-
rdoc (3.12)
|
17
|
-
json (~> 1.4)
|
18
|
-
rspec (2.8.0)
|
19
|
-
rspec-core (~> 2.8.0)
|
20
|
-
rspec-expectations (~> 2.8.0)
|
21
|
-
rspec-mocks (~> 2.8.0)
|
22
|
-
rspec-core (2.8.0)
|
23
|
-
rspec-expectations (2.8.0)
|
24
|
-
diff-lcs (~> 1.1.2)
|
25
|
-
rspec-mocks (2.8.0)
|
26
|
-
shoulda (2.11.3)
|
27
|
-
simplecov (0.5.4)
|
28
|
-
multi_json (~> 1.0.3)
|
29
|
-
simplecov-html (~> 0.5.3)
|
30
|
-
simplecov-html (0.5.3)
|
31
|
-
travis-lint (1.3.0)
|
32
|
-
hashr (>= 0.0.19)
|
33
|
-
yard (0.7.5)
|
34
|
-
|
35
|
-
PLATFORMS
|
36
|
-
ruby
|
37
|
-
|
38
|
-
DEPENDENCIES
|
39
|
-
bundler
|
40
|
-
jeweler (~> 1.8.3)
|
41
|
-
rake (~> 0.9.2)
|
42
|
-
rdiscount (~> 1.6.8)
|
43
|
-
rspec (~> 2.8.0)
|
44
|
-
shoulda (~> 2.11.3)
|
45
|
-
simplecov (~> 0.5.4)
|
46
|
-
travis-lint (~> 1.3.0)
|
47
|
-
yard (~> 0.7.5)
|
data/Rakefile
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "which_works"
|
18
|
-
gem.homepage = "http://github.com/AlphaHydrae/which_works"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Ruby UNIX-like which.}
|
21
|
-
gem.description = %Q{Locates a program file in the user's path. The which method takes a list of command names and searches the path for each executable file that would be run had these commands actually been invoked.}
|
22
|
-
gem.email = "hydrae.alpha@gmail.com"
|
23
|
-
gem.authors = ["AlphaHydrae"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rspec/core/rake_task'
|
29
|
-
desc "Run specs"
|
30
|
-
RSpec::Core::RakeTask.new do |t|
|
31
|
-
#t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
32
|
-
# Put spec opts in a file named .rspec in root
|
33
|
-
end
|
34
|
-
|
35
|
-
task :default => :spec
|
36
|
-
|
37
|
-
desc "Generate documentation"
|
38
|
-
task :doc => ['doc:generate']
|
39
|
-
namespace :doc do
|
40
|
-
project_root = File.dirname __FILE__
|
41
|
-
doc_destination = File.join project_root, 'doc'
|
42
|
-
|
43
|
-
begin
|
44
|
-
require 'yard'
|
45
|
-
require 'yard/rake/yardoc_task'
|
46
|
-
|
47
|
-
YARD::Rake::YardocTask.new(:generate) do |yt|
|
48
|
-
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
|
49
|
-
[ File.join(project_root, 'README.md') ]
|
50
|
-
yt.options = ['--output-dir', doc_destination, '--readme', 'README.md', '--private', '--protected']
|
51
|
-
end
|
52
|
-
rescue LoadError
|
53
|
-
desc "Generate YARD Documentation"
|
54
|
-
task :generate do
|
55
|
-
abort "Please install the YARD gem to generate rdoc."
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/spec/all_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe ':all option' do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
WhichSpecHelper.stub_unix!
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should find all executable files" do
|
10
|
-
Which.which('svn', :all => true).should == [ '/opt/local/bin/svn', '/usr/bin/svn' ]
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should find all executable files and other files" do
|
14
|
-
Which.which('ls', 'svn', 'screen', :all => true).should == [ '/bin/ls', '/opt/local/bin/svn', '/usr/bin/svn', '/usr/bin/screen' ]
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should not find anything when given no command to find" do
|
18
|
-
Which.which({ :all => true }).should be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should only find one executable file when given an absolute path" do
|
22
|
-
Which.which('/opt/local/bin/svn', :all => true).should == '/opt/local/bin/svn'
|
23
|
-
end
|
24
|
-
end
|
data/spec/array_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe ':array option' do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
WhichSpecHelper.stub_unix!
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should return an array when given nothing to find" do
|
10
|
-
Which.which({ :array => true }).should == []
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return an array if the given command does not exist" do
|
14
|
-
Which.which('unknown', :array => true).should == []
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should return an array when finding a single command" do
|
18
|
-
Which.which('ls', :array => true).should == [ '/bin/ls' ]
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should return an array when finding several commands" do
|
22
|
-
Which.which('ls', 'svn', :array => true).should == [ '/bin/ls', '/opt/local/bin/svn' ]
|
23
|
-
end
|
24
|
-
end
|
data/spec/basic_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Which do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
WhichSpecHelper.stub_unix!
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should find a single command" do
|
10
|
-
Which.which('ls').should == '/bin/ls'
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should find a single command with an absolute path" do
|
14
|
-
Which.which('/bin/ls').should == '/bin/ls'
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should not find commands that do not exist" do
|
18
|
-
[ 'foo', 'bar', 'wrong', 'cp', '/usr/bin/du' ].each do |unknown|
|
19
|
-
Which.which(unknown).should be_nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should find nothing when given nothing" do
|
24
|
-
Which.which.should be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should find several commands" do
|
28
|
-
Which.which('ls', 'screen').should == [ '/bin/ls', '/usr/bin/screen' ]
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should find only existing commands" do
|
32
|
-
Which.which('ls', 'cp', 'screen', '/bin/foo').should == [ '/bin/ls', '/usr/bin/screen' ]
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should not find a command that is not in the path" do
|
36
|
-
Which.which('custom').should be_nil
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should find the first executable file in the path" do
|
40
|
-
Which.which('svn').should == '/opt/local/bin/svn'
|
41
|
-
end
|
42
|
-
end
|
data/spec/helper.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
require 'simplecov'
|
4
|
-
|
5
|
-
# test coverage
|
6
|
-
SimpleCov.start
|
7
|
-
|
8
|
-
begin
|
9
|
-
Bundler.setup(:default, :development)
|
10
|
-
rescue Bundler::BundlerError => e
|
11
|
-
$stderr.puts e.message
|
12
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
-
exit e.status_code
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'rspec'
|
17
|
-
require 'shoulda'
|
18
|
-
|
19
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
20
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
21
|
-
require 'which_works'
|
22
|
-
|
23
|
-
module WhichSpecHelper
|
24
|
-
UNIX_COMMANDS = %w( /bin/ls /usr/bin/screen /home/johndoe/bin/custom /opt/local/bin/svn /usr/bin/svn )
|
25
|
-
UNIX_PATH = "/bin:/opt/local/bin:/usr/bin"
|
26
|
-
|
27
|
-
def self.stub_unix!
|
28
|
-
|
29
|
-
v = $VERBOSE
|
30
|
-
$VERBOSE = nil
|
31
|
-
File.const_set :SEPARATOR, '/'
|
32
|
-
File.const_set :PATH_SEPARATOR, ':'
|
33
|
-
$VERBOSE = v
|
34
|
-
|
35
|
-
UNIX_COMMANDS.each{ |com| com.gsub!(/\//, File::SEPARATOR) }
|
36
|
-
UNIX_PATH.gsub!(/\:/, File::PATH_SEPARATOR).gsub!(/\//, File::SEPARATOR)
|
37
|
-
|
38
|
-
ENV.stub!(:[]) do |name|
|
39
|
-
case name
|
40
|
-
when 'PATH'
|
41
|
-
UNIX_PATH
|
42
|
-
when 'PATHEXT'
|
43
|
-
nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
File.stub!(:executable?) do |name|
|
48
|
-
UNIX_COMMANDS.include? name.to_s
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
data/spec/options_spec.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe 'Default Options' do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
WhichSpecHelper.stub_unix!
|
7
|
-
Which.options.clear
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should have no options by default" do
|
11
|
-
Which.options.should == {}
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should allow to set the :all option to true by default" do
|
15
|
-
Which.options = { :all => true }
|
16
|
-
Which.which('svn').should == [ '/opt/local/bin/svn', '/usr/bin/svn' ]
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should allow to set the :array option to true by default" do
|
20
|
-
Which.options = { :array => true }
|
21
|
-
Which.which('ls').should == [ '/bin/ls' ]
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should allow to set all options to true by default" do
|
25
|
-
Which.options = { :all => true, :array => true }
|
26
|
-
Which.which('ls').should == [ '/bin/ls' ]
|
27
|
-
Which.which('svn').should == [ '/opt/local/bin/svn', '/usr/bin/svn' ]
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should allow to clear default options" do
|
31
|
-
Which.options = { :all => true, :array => true }
|
32
|
-
Which.options = {}
|
33
|
-
Which.options.should == {}
|
34
|
-
Which.which('ls').should == '/bin/ls'
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should return the default options" do
|
38
|
-
Which.options = { :all => true, :array => false }
|
39
|
-
Which.options.should == { :all => true, :array => false }
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should copy the given options" do
|
43
|
-
options = { :all => true, :array => true }
|
44
|
-
Which.options = options
|
45
|
-
Which.options.should == options
|
46
|
-
Which.options.should_not equal(options)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should return its internal default options hash" do
|
50
|
-
Which.options[:array] = true
|
51
|
-
Which.options[:all] = 42
|
52
|
-
Which.options[:array].should be_true
|
53
|
-
Which.options[:all].should == 42
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should allow to override the :all option" do
|
57
|
-
Which.options = { :all => true, :array => true }
|
58
|
-
Which.which('svn', :all => false).should == [ '/opt/local/bin/svn' ]
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should allow to override the :array option" do
|
62
|
-
Which.options = { :all => true, :array => true }
|
63
|
-
Which.which('ls', :array => false).should == '/bin/ls'
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should allow to override all options" do
|
67
|
-
Which.options = { :all => true, :array => true }
|
68
|
-
Which.which('ls', :all => false, :array => false).should == '/bin/ls'
|
69
|
-
Which.which('svn', :all => false, :array => false).should == '/opt/local/bin/svn'
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should only accept a hash as default options" do
|
73
|
-
[ nil, false, true, String.new, Array.new, 2, 4.5 ].each do |invalid|
|
74
|
-
lambda{ Which.options = invalid }.should raise_error(ArgumentError)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
data/which_works.gemspec
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "which_works"
|
8
|
-
s.version = "1.0.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["AlphaHydrae"]
|
12
|
-
s.date = "2012-03-11"
|
13
|
-
s.description = "Locates a program file in the user's path. The which method takes a list of command names and searches the path for each executable file that would be run had these commands actually been invoked."
|
14
|
-
s.email = "hydrae.alpha@gmail.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".rspec",
|
22
|
-
".rvmrc",
|
23
|
-
".travis.yml",
|
24
|
-
"Gemfile",
|
25
|
-
"Gemfile.lock",
|
26
|
-
"LICENSE.txt",
|
27
|
-
"README.md",
|
28
|
-
"Rakefile",
|
29
|
-
"VERSION",
|
30
|
-
"lib/which_works.rb",
|
31
|
-
"spec/all_spec.rb",
|
32
|
-
"spec/array_spec.rb",
|
33
|
-
"spec/basic_spec.rb",
|
34
|
-
"spec/helper.rb",
|
35
|
-
"spec/options_spec.rb",
|
36
|
-
"which_works.gemspec"
|
37
|
-
]
|
38
|
-
s.homepage = "http://github.com/AlphaHydrae/which_works"
|
39
|
-
s.licenses = ["MIT"]
|
40
|
-
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = "1.8.17"
|
42
|
-
s.summary = "Ruby UNIX-like which."
|
43
|
-
|
44
|
-
if s.respond_to? :specification_version then
|
45
|
-
s.specification_version = 3
|
46
|
-
|
47
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
-
s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
|
49
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
50
|
-
s.add_development_dependency(%q<shoulda>, ["~> 2.11.3"])
|
51
|
-
s.add_development_dependency(%q<bundler>, [">= 0"])
|
52
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
53
|
-
s.add_development_dependency(%q<simplecov>, ["~> 0.5.4"])
|
54
|
-
s.add_development_dependency(%q<yard>, ["~> 0.7.5"])
|
55
|
-
s.add_development_dependency(%q<rdiscount>, ["~> 1.6.8"])
|
56
|
-
s.add_development_dependency(%q<travis-lint>, ["~> 1.3.0"])
|
57
|
-
else
|
58
|
-
s.add_dependency(%q<rake>, ["~> 0.9.2"])
|
59
|
-
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
60
|
-
s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
|
61
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
62
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
63
|
-
s.add_dependency(%q<simplecov>, ["~> 0.5.4"])
|
64
|
-
s.add_dependency(%q<yard>, ["~> 0.7.5"])
|
65
|
-
s.add_dependency(%q<rdiscount>, ["~> 1.6.8"])
|
66
|
-
s.add_dependency(%q<travis-lint>, ["~> 1.3.0"])
|
67
|
-
end
|
68
|
-
else
|
69
|
-
s.add_dependency(%q<rake>, ["~> 0.9.2"])
|
70
|
-
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
71
|
-
s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
|
72
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
73
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
74
|
-
s.add_dependency(%q<simplecov>, ["~> 0.5.4"])
|
75
|
-
s.add_dependency(%q<yard>, ["~> 0.7.5"])
|
76
|
-
s.add_dependency(%q<rdiscount>, ["~> 1.6.8"])
|
77
|
-
s.add_dependency(%q<travis-lint>, ["~> 1.3.0"])
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|