Skip to content
Browse files

failed attempt at ignoring leading dots

  • Loading branch information...
1 parent cbaa2bb commit 834db39674c02742eb83c3ad588bc0fa7a5c13c7 @alexch committed Jul 3, 2012
Showing with 6 additions and 4 deletions.
  1. +4 −2 lib/rerun/glob.rb
  2. +2 −2 spec/glob_spec.rb
View
6 lib/rerun/glob.rb
@@ -1,10 +1,11 @@
# based on http://cpan.uwinnipeg.ca/htdocs/Text-Glob/Text/Glob.pm.html#glob_to_regex_string-
# todo: release as separate gem
+# todo: make NO_LEADING_DOT optional
#
module Rerun
class Glob
- NO_LEADING_DOT = '(?=[^\.])' # todo
+ NO_LEADING_DOT = '(?=[^\.])'
def initialize glob_string
@glob_string = glob_string
@@ -17,7 +18,7 @@ def to_regexp_string
curlies = 0;
escaping = false;
- chars.map do |char|
+ regexp_string = chars.map do |char|
if escaping
escaping = false
char
@@ -58,6 +59,7 @@ def to_regexp_string
end
end
end.join
+ NO_LEADING_DOT + regexp_string
end
def to_regexp
View
4 spec/glob_spec.rb
@@ -30,15 +30,15 @@ module Rerun
}.each_pair do |glob_string, regexp_string|
specify glob_string do
- Glob.new(glob_string).to_regexp_string.should == regexp_string
+ Glob.new(glob_string).to_regexp_string.should == Glob::NO_LEADING_DOT + regexp_string
end
end
it "excludes files beginning with dots"
describe "#to_regexp" do
it "makes a regexp" do
- Glob.new("foo*").to_regexp.should == /foo.*/
+ Glob.new("foo*").to_regexp.should == /#{Glob::NO_LEADING_DOT}foo.*/
end
end

0 comments on commit 834db39

Please sign in to comment.
Something went wrong with that request. Please try again.