Top Level Namespace

Defined Under Namespace

Modules: Fbquick, Fbtok, Fbtree, Fbx, SportDb

Constant Summary collapse

FILEPACK_HEADER_RE =

PACK eng|en

add NAME eng|en   - why? why not?

change to FILEPACK_NAME - why? why not?

%r{\A
    (?: PACK ) [ ]+
    (?<header> .+?)   ## note - use non-greedy
\z}x
FILEPACK_DIR_RE =

DIR /sports/openfootball

CD  /sports/openfootball     -- keep - why? why not?
%r{\A
        (?: DIR|CD ) [ ]+
        (?<dir> .+? )      ## note - use non-greedy

\z}x

Instance Method Summary collapse

Instance Method Details

#build_pathspecs(args, filepack: nil) ⇒ Object

build pathspecs via arguments

- (i) every dir is a pathspec entry/record
- (ii) all files get bundled together into <input> pathspec entry/record

note: was formerly known as expand_args


240
241
242
# File 'lib/fbtok/pathspec.rb', line 240

def build_pathspecs( args, filepack: nil )
   SportDb::Pathspec.build( args, filepack: filepack )
end

#parse_filepack(txt) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fbtok/filepack.rb', line 30

def parse_filepack( txt )
    h={}
    recs    = nil
    basedir = nil

    txt.each_line do |line|
      line = line.strip

      next  if line.start_with?('#') || line.empty?

      break if line == '__END__'


      if m=FILEPACK_HEADER_RE.match(line)
        keys    = m[:header].strip.split(  /[ ]*\|[ ]*/ )
        basedir = nil
        recs = []
        ## note - normalize keys for now (always downcase)
        keys.each {|key| h[key.downcase] = recs }
      elsif m=FILEPACK_DIR_RE.match(line)
        basedir = m[:dir].strip
      else
        file =  basedir ? File.join( basedir, line ) : line
        recs << file
      end
    end

    h
end

#read_filepack(path) ⇒ Object



61
62
63
# File 'lib/fbtok/filepack.rb', line 61

def read_filepack( path )
  parse_filepack( read_text( path ))
end

#read_pathspecs(src) ⇒ Object

read pathspecs via csv file (using path column)



246
247
248
# File 'lib/fbtok/pathspec.rb', line 246

def read_pathspecs( src )
    SportDb::Pathspec.read( src )
end