lib/sportdb/formats/datafile.rb in sportdb-formats-0.1.1 vs lib/sportdb/formats/datafile.rb in sportdb-formats-0.1.2

- old
+ new

@@ -4,11 +4,12 @@ module Datafile # note: keep Datafile in its own top-level module/namespace for now - why? why not? def self.find( path, pattern ) datafiles = [] - ## check all txt files (incl. starting with dot (.)) as candidates + ## check all txt files + ## note: incl. files starting with dot (.)) as candidates (normally excluded with just *) candidates = Dir.glob( "#{path}/**/{*,.*}.txt" ) pp candidates candidates.each do |candidate| datafiles << candidate if pattern.match( candidate ) end @@ -30,23 +31,28 @@ }x def self.find_clubs( path, pattern: CLUBS_REGEX ) find( path, pattern ); end def self.find_clubs_wiki( path, pattern: CLUBS_WIKI_REGEX ) find( path, pattern ); end + def self.match_clubs( path ) CLUBS_REGEX.match( path ); end + def self.match_clubs_wiki( path ) CLUBS_WIKI_REGEX.match( path ); end + + LEAGUES_REGEX = %r{ (?:^|/) # beginning (^) or beginning of path (/) leagues\.txt$ }x - def self.find_leagues( path, pattern: LEAGUES_REGEX ) find( path, pattern ); end + def self.find_leagues( path, pattern: LEAGUES_REGEX ) find( path, pattern ); end + def self.match_leagues( path ) LEAGUES_REGEX.match( path ); end CONF_REGEX = %r{ (?:^|/) # beginning (^) or beginning of path (/) \.conf\.txt$ }x - def self.find_conf( path, pattern: CONF_REGEX ) find( path, pattern ); end - + def self.find_conf( path, pattern: CONF_REGEX ) find( path, pattern ); end + def self.match_conf( path ) CONF_REGEX.match( path ); end def self.write_bundle( path, datafiles:, header: nil ) File.open( path, 'w:utf-8') do |fout|