lib/bond/actions.rb in cldwalker-bond-0.1.3 vs lib/bond/actions.rb in cldwalker-bond-0.1.4
- old
+ new
@@ -9,11 +9,11 @@
# Helper function for evaluating strings in the current console binding.
def current_eval(string)
Missions::ObjectMission.current_eval(string)
rescue Exception
- nil
+ []
end
# Completes backtick and Kernel#system with shell commands available in ENV['PATH']
def shell_commands(input)
ENV['PATH'].split(File::PATH_SEPARATOR).uniq.map {|e| Dir.entries(e) }.flatten.uniq - ['.', '..']
@@ -48,18 +48,22 @@
input =~ /^(\.{0,2}#{fs}|~)/ and return files(input).select {|f| f =~ extensions_regex or File.directory? f }
dir_entries = proc {|dir| Dir.entries(dir).delete_if {|e| %w{. ..}.include?(e) }.map {|f|
File.directory?(File.join(dir,f)) ? f+fs : f } }
input_regex = /^#{Regexp.escape(input)}/
- $:.select {|e| File.directory?(e)}.inject([]) do |t,dir|
+ require_paths.select {|e| File.directory?(e)}.inject([]) do |t,dir|
if input[/.$/] == fs && File.directory?(File.join(dir,input))
matches = dir_entries.call(File.join(dir,input)).select {|e| e =~ extensions_regex }.map {|e| input + e }
else
entries = input.include?(fs) && File.directory?(File.join(dir,File.dirname(input))) ?
dir_entries.call(File.join(dir,File.dirname(input))).map {|e| File.join(File.dirname(input), e) } : dir_entries.call(dir)
matches = entries.select {|e| e=~ extensions_regex && e =~ input_regex }
end
t += matches
end
+ end
+
+ def require_paths
+ $: + Gem.path.map {|e| Dir["#{e}/gems/*/lib"] }.flatten.uniq rescue $:
end
end
end
\ No newline at end of file