Sha256: a5b621be2b8b7fc44a251e3c088f88157bfb80f97bcbc1623f13a68ae02b2abd
Contents?: true
Size: 759 Bytes
Versions: 12
Compression:
Stored size: 759 Bytes
Contents
#-- # Author:: Tyler Rick # Copyright:: Copyright (c) 2007 QualitySmith, Inc. # License:: Ruby License # Submit to Facets?:: Yes #++ # To do: # * Is there a more object-oriented way to do this? Instance method instead of class method? class File def self.exact_match_regexp(filename) /(^|\/)#{Regexp.escape(filename)}$/ end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TheTest < Test::Unit::TestCase def test_1 assert 'bar.rb' =~ File.exact_match_regexp('bar.rb') assert '/path/to/bar.rb' =~ File.exact_match_regexp('bar.rb') # But: assert 'foobar.rb' !~ File.exact_match_regexp('bar.rb') end end =end
Version data entries
12 entries across 12 versions & 1 rubygems