fedux_org-stdlib 0.0.30 → 0.0.31
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/RELEASE_NOTES.md +3 -0
- data/doc/commands.md +20 -0
- data/lib/fedux_org/stdlib/command.rb +3 -1
- data/lib/fedux_org/stdlib/version.rb +1 -1
- data/spec/command_spec.rb +4 -0
- metadata +3 -2
data/RELEASE_NOTES.md
CHANGED
data/doc/commands.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# FeduxOrg::Stdlib::Command
|
2
|
+
|
3
|
+
## Usage
|
4
|
+
|
5
|
+
### which
|
6
|
+
|
7
|
+
Searches command in PATH. It supports the usage of a full path as well.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
require 'fedux_org/stdlib/command'
|
11
|
+
|
12
|
+
class XY
|
13
|
+
include Command
|
14
|
+
|
15
|
+
def method
|
16
|
+
cmd_path = which( 'echo' )
|
17
|
+
cmd_path = which( '/usr/bin/echo' )
|
18
|
+
end
|
19
|
+
end
|
20
|
+
```
|
@@ -53,13 +53,15 @@ module FeduxOrg
|
|
53
53
|
|
54
54
|
# Search for command
|
55
55
|
# @param [String] cmd
|
56
|
-
# name of command
|
56
|
+
# name of command or path to command (will be reduced to basename and then searched in PATH)
|
57
57
|
#
|
58
58
|
# @return [String]
|
59
59
|
# path to command
|
60
60
|
def which(cmd)
|
61
61
|
return nil if cmd.blank?
|
62
62
|
|
63
|
+
cmd = File.basename( cmd )
|
64
|
+
|
63
65
|
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
64
66
|
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
65
67
|
exts.each do |ext|
|
data/spec/command_spec.rb
CHANGED
@@ -33,5 +33,9 @@ describe Command do
|
|
33
33
|
it 'returns full path for a valid command' do
|
34
34
|
expect( klass.new.which( 'which' ) ).to eq( '/usr/bin/which' )
|
35
35
|
end
|
36
|
+
|
37
|
+
it 'returns full path for a valid command although a full path is given' do
|
38
|
+
expect( klass.new.which( '/usr/bin/which' ) ).to eq( '/usr/bin/which' )
|
39
|
+
end
|
36
40
|
end
|
37
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fedux_org-stdlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.31
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- RELEASE_NOTES.md
|
78
78
|
- Rakefile
|
79
79
|
- doc/colors.md
|
80
|
+
- doc/commands.md
|
80
81
|
- doc/logic_converters.md
|
81
82
|
- doc/models.md
|
82
83
|
- fedux_org-stdlib.gemspec
|