Method: Fbup::GitHubConfig#add

Defined in:
lib/fbup/github_config.rb

#add(recs) ⇒ Object



29
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
59
60
61
62
63
64
65
66
67
68
# File 'lib/fbup/github_config.rb', line 29

def add( recs )
  recs.each do |rec|
    path = rec['path']  ## use pathspec - why? why not?
                        ##  or repospec or such

    ## auto-expand to openfootball as default org if no @ specified
    owner, path = if path.index( '@')
                      path.split( '@', 2 )
                  else
                      ['openfootball', path ]
                  end
    name, path = path.split( '/', 2 )


    ## openfootball@europe/france
    ##    =>
    ##    owner: openfootball
    ##    name:  europe
    ##    path:  france
    ##
    ## openfootball@austria
    ##    =>
    ##    owner: openfootball
    ##    name:  austria
    ##    path:  nil
    @table[ rec['key'] ] = {  'owner' => owner, ## (required)
                              'name'  => name,  ## (required)
                              'path'  => path   ## extra/inner/inside/local path (optional)
                            }

    ## check for/add flags
      flags = rec['flags'].split( /[ ]*[|][ ]*/ )
      ## generte hash
      ##    e.g.   v2 | flat   => { 'v2' => true, 'flat' => true } etc.
      flags = flags.map { |flag| [flag, true] }.to_h   
      @table[ rec['key'] ]['flags'] = flags      if flags.size > 0
  end

  
end