which_works 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format doc
data/.rvmrc ADDED
@@ -0,0 +1,41 @@
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 ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem 'rake', '~> 0.9.2'
10
+ gem 'rspec', '~> 2.8.0'
11
+ gem 'shoulda', '~> 2.11.3'
12
+ gem 'bundler'
13
+ gem 'jeweler', '~> 1.8.3'
14
+ gem 'simplecov', '~> 0.5.4'
15
+ gem 'yard', '~> 0.7.5'
16
+ gem 'rdiscount', '~> 1.6.8'
17
+ gem 'travis-lint', '~> 1.3.0'
18
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
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/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Alpha Hydrae (hydrae.alpha@gmail.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # which_works
2
+
3
+ **Ruby UNIX-like which.**
4
+
5
+ ## License (MIT)
6
+
7
+ Copyright (c) 2011 Alpha Hydrae
8
+
9
+ 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:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
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{Ruby UNIX-like which.}
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/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,20 @@
1
+
2
+ class Which
3
+
4
+ def self.which cmd
5
+
6
+ # valid file extensions (cross-platform)
7
+ extensions = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [ '' ]
8
+
9
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
10
+
11
+ extensions.each do |ext|
12
+
13
+ absolute_path = File.expand_path "#{cmd}#{ext}", path
14
+ return absolute_path if File.executable? absolute_path
15
+ end
16
+ end
17
+
18
+ return nil
19
+ end
20
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,22 @@
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
+
@@ -0,0 +1,35 @@
1
+ require 'helper'
2
+
3
+ describe Which do
4
+ COMMANDS = %w( /bin/ls /usr/bin/screen /home/johndoe/bin/custom )
5
+
6
+ before :each do
7
+
8
+ ENV.stub!(:[]) do |name|
9
+ case name
10
+ when 'PATH'
11
+ "/bin#{File::PATH_SEPARATOR}/usr/bin"
12
+ when 'PATHEXT'
13
+ nil
14
+ end
15
+ end
16
+
17
+ File.stub!(:executable?) do |name|
18
+ COMMANDS.include? name.to_s
19
+ end
20
+ end
21
+
22
+ it "should find commands" do
23
+ Which.which('ls').should == '/bin/ls'
24
+ end
25
+
26
+ it "should find commands with absolute paths" do
27
+ Which.which('/bin/ls').should == '/bin/ls'
28
+ end
29
+
30
+ it "should not find commands that do not exist" do
31
+ [ 'wrong', 'cp', '/usr/bin/du' ].each do |unknown|
32
+ Which.which(unknown).should be_nil
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,77 @@
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 = "0.1.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-09"
13
+ s.description = "Ruby UNIX-like which."
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/helper.rb",
32
+ "spec/which_spec.rb",
33
+ "which_works.gemspec"
34
+ ]
35
+ s.homepage = "http://github.com/AlphaHydrae/which_works"
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = "1.8.17"
39
+ s.summary = "Ruby UNIX-like which."
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
46
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
47
+ s.add_development_dependency(%q<shoulda>, ["~> 2.11.3"])
48
+ s.add_development_dependency(%q<bundler>, [">= 0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
50
+ s.add_development_dependency(%q<simplecov>, ["~> 0.5.4"])
51
+ s.add_development_dependency(%q<yard>, ["~> 0.7.5"])
52
+ s.add_development_dependency(%q<rdiscount>, ["~> 1.6.8"])
53
+ s.add_development_dependency(%q<travis-lint>, ["~> 1.3.0"])
54
+ else
55
+ s.add_dependency(%q<rake>, ["~> 0.9.2"])
56
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
57
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
58
+ s.add_dependency(%q<bundler>, [">= 0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
60
+ s.add_dependency(%q<simplecov>, ["~> 0.5.4"])
61
+ s.add_dependency(%q<yard>, ["~> 0.7.5"])
62
+ s.add_dependency(%q<rdiscount>, ["~> 1.6.8"])
63
+ s.add_dependency(%q<travis-lint>, ["~> 1.3.0"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<rake>, ["~> 0.9.2"])
67
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
68
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
69
+ s.add_dependency(%q<bundler>, [">= 0"])
70
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
71
+ s.add_dependency(%q<simplecov>, ["~> 0.5.4"])
72
+ s.add_dependency(%q<yard>, ["~> 0.7.5"])
73
+ s.add_dependency(%q<rdiscount>, ["~> 1.6.8"])
74
+ s.add_dependency(%q<travis-lint>, ["~> 1.3.0"])
75
+ end
76
+ end
77
+
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: which_works
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - AlphaHydrae
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-09 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70294153990340 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70294153990340
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70294153989580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70294153989580
36
+ - !ruby/object:Gem::Dependency
37
+ name: shoulda
38
+ requirement: &70294153988860 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.11.3
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70294153988860
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &70294153988380 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70294153988380
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &70294153987820 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.8.3
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70294153987820
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: &70294153987300 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.5.4
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70294153987300
80
+ - !ruby/object:Gem::Dependency
81
+ name: yard
82
+ requirement: &70294153851360 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 0.7.5
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70294153851360
91
+ - !ruby/object:Gem::Dependency
92
+ name: rdiscount
93
+ requirement: &70294153850820 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 1.6.8
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70294153850820
102
+ - !ruby/object:Gem::Dependency
103
+ name: travis-lint
104
+ requirement: &70294153850340 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.3.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70294153850340
113
+ description: Ruby UNIX-like which.
114
+ email: hydrae.alpha@gmail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files:
118
+ - LICENSE.txt
119
+ - README.md
120
+ files:
121
+ - .document
122
+ - .rspec
123
+ - .rvmrc
124
+ - .travis.yml
125
+ - Gemfile
126
+ - Gemfile.lock
127
+ - LICENSE.txt
128
+ - README.md
129
+ - Rakefile
130
+ - VERSION
131
+ - lib/which_works.rb
132
+ - spec/helper.rb
133
+ - spec/which_spec.rb
134
+ - which_works.gemspec
135
+ homepage: http://github.com/AlphaHydrae/which_works
136
+ licenses:
137
+ - MIT
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ segments:
149
+ - 0
150
+ hash: 4513161161405820055
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 1.8.17
160
+ signing_key:
161
+ specification_version: 3
162
+ summary: Ruby UNIX-like which.
163
+ test_files: []