fedux_org-stdlib 0.1.1 → 0.1.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.
- data/lib/fedux_org/stdlib/command.rb +19 -7
- data/lib/fedux_org/stdlib/models/class_based_model.rb +8 -2
- data/lib/fedux_org/stdlib/rake/documentation/yard.rb +6 -1
- data/lib/fedux_org/stdlib/rake/gems/bundler.rb +6 -1
- data/lib/fedux_org/stdlib/rake/version/bump.rb +13 -2
- data/lib/fedux_org/stdlib/version.rb +1 -1
- data/spec/command_spec.rb +21 -1
- data/spec/logger/logger_spec.rb +1 -1
- metadata +2 -2
@@ -1,6 +1,12 @@
|
|
1
|
+
begin
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
rescue LoadError
|
5
|
+
$stderr.puts 'You need to install the "activesupport"-gem to make that library work.'
|
6
|
+
exit 1
|
7
|
+
end
|
8
|
+
|
1
9
|
require 'open3'
|
2
|
-
require 'active_support/core_ext/string/inflections'
|
3
|
-
require 'active_support/core_ext/object/blank'
|
4
10
|
|
5
11
|
require 'fedux_org/stdlib/environment'
|
6
12
|
require 'fedux_org/stdlib/command/command_result'
|
@@ -54,18 +60,24 @@ module FeduxOrg
|
|
54
60
|
# Search for command
|
55
61
|
# @param [String] cmd
|
56
62
|
# name of command or path to command (will be reduced to basename and then searched in PATH)
|
63
|
+
#
|
64
|
+
# @param [Array,String] paths
|
65
|
+
# a string containing paths separated by "File::PATH_SEPARATOR" or an array of paths
|
66
|
+
#
|
67
|
+
# @param [Array,String] pathexts
|
68
|
+
# a string containing pathexts separated by ";" or an array of pathexts
|
57
69
|
#
|
58
70
|
# @return [String]
|
59
71
|
# path to command
|
60
|
-
def which(cmd)
|
72
|
+
def which(cmd, paths=ENV['PATH'].split(File::PATH_SEPARATOR), pathexts=ENV['PATHEXT'].to_s.split( /;/ ) )
|
61
73
|
return nil if cmd.blank?
|
62
74
|
|
63
75
|
cmd = File.basename( cmd )
|
76
|
+
pathexts = [''] if pathexts.blank?
|
64
77
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
exe = File.join(path, "#{cmd}#{ext}")
|
78
|
+
Array( paths ).each do |path|
|
79
|
+
Array( pathexts ).each do |ext|
|
80
|
+
exe = File.join(path, "#{cmd}#{ext.to_s}")
|
69
81
|
return exe if File.executable? exe
|
70
82
|
end
|
71
83
|
end
|
@@ -1,5 +1,11 @@
|
|
1
|
-
|
2
|
-
require 'active_support/core_ext/
|
1
|
+
begin
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
rescue LoadError
|
5
|
+
$stderr.puts 'You need to install the "activesupport"-gem to make that library work.'
|
6
|
+
exit 1
|
7
|
+
end
|
8
|
+
|
3
9
|
require 'fedux_org/stdlib/models/filesystem_based_model'
|
4
10
|
require 'find'
|
5
11
|
|
@@ -1,7 +1,18 @@
|
|
1
1
|
require_relative 'base'
|
2
2
|
|
3
|
-
|
4
|
-
require '
|
3
|
+
begin
|
4
|
+
require 'active_support/core_ext/string/strip'
|
5
|
+
rescue LoadError
|
6
|
+
$stderr.puts 'You need to install the "activesupport"-gem to make that rake task work.'
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'erubis'
|
12
|
+
rescue LoadError
|
13
|
+
$stderr.puts 'You need to install the "erubis"-gem to make that rake task work.'
|
14
|
+
exit 1
|
15
|
+
end
|
5
16
|
|
6
17
|
namespace :version do
|
7
18
|
desc 'bump version of library to new version'
|
data/spec/command_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe Command do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
context '#which' do
|
28
|
+
context '#which', :focus do
|
29
29
|
klass = Class.new do
|
30
30
|
include Command
|
31
31
|
end
|
@@ -37,5 +37,25 @@ describe Command do
|
|
37
37
|
it 'returns full path for a valid command although a full path is given' do
|
38
38
|
expect( klass.new.which( '/usr/bin/which' ) ).to eq( '/usr/bin/which' )
|
39
39
|
end
|
40
|
+
|
41
|
+
it 'returns nil if no executable can be found in path' do
|
42
|
+
expect( klass.new.which( 'asdfasdf' ) ).to eq( nil )
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'uses paths string to search for command' do
|
46
|
+
expect( klass.new.which( 'which', '/usr/bin' ) ).to eq( '/usr/bin/which' )
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'uses paths array to search for command' do
|
50
|
+
expect( klass.new.which( 'which', [ '/usr/bin' ] ) ).to eq( '/usr/bin/which' )
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'uses pathexts to search for command' do
|
54
|
+
expect( klass.new.which( 'which', [ '/usr/bin' ], '' ) ).to eq( '/usr/bin/which' )
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'uses pathexts array to search for command' do
|
58
|
+
expect( klass.new.which( 'which', [ '/usr/bin' ], [ '' ]) ).to eq( '/usr/bin/which' )
|
59
|
+
end
|
40
60
|
end
|
41
61
|
end
|
data/spec/logger/logger_spec.rb
CHANGED
@@ -33,7 +33,7 @@ describe FeduxOrg::Stdlib::Logging::Logger do
|
|
33
33
|
expect( bucket.string ).not_to include( 'Not visible' )
|
34
34
|
end
|
35
35
|
|
36
|
-
it 'changes the mode (log level) of the logger'
|
36
|
+
it 'changes the mode (log level) of the logger' do
|
37
37
|
bucket = StringIO.new
|
38
38
|
|
39
39
|
logger = FeduxOrg::Stdlib::Logging::Logger.new( Logger.new( bucket) )
|
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.1.
|
4
|
+
version: 0.1.2
|
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-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|