script_finder 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/script_finder/script_finder.rb +7 -21
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ftools'
|
2
|
+
require 'abbrev'
|
2
3
|
|
3
4
|
module ScriptFinder
|
4
5
|
DEFAULT_BIN_DIR = 'script'
|
@@ -69,31 +70,16 @@ module ScriptFinder
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
72
|
-
|
73
|
-
def unique_prefixes(possibles
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
if prefix_is_not_unique?(cmd, prefixes[cmd], possibles)
|
78
|
-
prefixes[cmd] += cmd[prefixes[cmd].size,1]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
unique_prefixes(possibles, prefixes)
|
82
|
-
else
|
73
|
+
|
74
|
+
def unique_prefixes(possibles)
|
75
|
+
all_prefixes = possibles.abbrev
|
76
|
+
all_prefixes.keys.sort.inject({ }) do |prefixes, abbrev|
|
77
|
+
prefixes[all_prefixes[abbrev]] ||= abbrev
|
83
78
|
prefixes
|
84
79
|
end
|
85
80
|
end
|
86
|
-
|
87
|
-
protected
|
88
81
|
|
89
|
-
|
90
|
-
other_possibles = possibles.clone
|
91
|
-
other_possibles.delete(current_cmd)
|
92
|
-
|
93
|
-
(current_prefix.empty? or
|
94
|
-
other_possibles.inject(false) {|accum, c| accum || c[0,current_prefix.length] == current_prefix}) and
|
95
|
-
current_cmd.length > current_prefix.length
|
96
|
-
end
|
82
|
+
protected
|
97
83
|
|
98
84
|
def bin_dir_exists_in_pwd?
|
99
85
|
File.exists?(bin_dir) and
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: script_finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Crawley
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-04-09 00:00:00 -04:00
|
13
13
|
default_executable: s
|
14
14
|
dependencies: []
|
15
15
|
|