Skip to content

Commit

Permalink
failed attempt at ignoring leading dots
Browse files Browse the repository at this point in the history
  • Loading branch information
alexch committed Jul 3, 2012
1 parent cbaa2bb commit 834db39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions 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
Expand All @@ -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
Expand Down Expand Up @@ -58,6 +59,7 @@ def to_regexp_string
end
end
end.join
NO_LEADING_DOT + regexp_string
end

def to_regexp
Expand Down
4 changes: 2 additions & 2 deletions spec/glob_spec.rb
Expand Up @@ -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

Expand Down

0 comments on commit 834db39

Please sign in to comment.