Class: Taeval::GitCheckout::Config

Inherits:
Object
  • Object
show all
Includes:
FileHelper
Defined in:
lib/taeval/git_checkout/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileHelper

#create, #exist?, #flatten_include!, #open, #path_of

Constructor Details

#initialize(conf_h) ⇒ Config

Returns a new instance of Config.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/taeval/git_checkout/config.rb', line 11

def initialize(conf_h)
  @tokens = conf_h.fetch('token', '')
  file    = open(path_of(conf_h['source']))
  @source = file.readlines
                .map { |line| line.split(';').map(&:strip) }
                .map { |e| {name: e[0], id: e[1], host: e[2], user: e[3], repo: e[4]} }

  @attr               = {}
  @attr[:private]     = conf_h.fetch('private', true)
  @attr[:fork]        = conf_h.fetch('fork', false)
  @attr[:forks_count] = conf_h.fetch('forks_count', 0).to_i
  @attr[:fork_parent] = conf_h.fetch('fork_parent', '')

  @branch      = conf_h.fetch('branch', 'main')
  @prefix      = conf_h.fetch('prefix', '')
  
  @solution    = path_of(conf_h.dig('solution', 'path'))
  if !File.exist?(@solution)
    Dir.mkdir @solution
  end
end

Instance Attribute Details

#attrObject (readonly)

Returns the value of attribute attr.



9
10
11
# File 'lib/taeval/git_checkout/config.rb', line 9

def attr
  @attr
end

#branchObject (readonly)

Returns the value of attribute branch.



9
10
11
# File 'lib/taeval/git_checkout/config.rb', line 9

def branch
  @branch
end

#fork_parentObject (readonly)

Returns the value of attribute fork_parent.



9
10
11
# File 'lib/taeval/git_checkout/config.rb', line 9

def fork_parent
  @fork_parent
end

#prefixObject (readonly)

Returns the value of attribute prefix.



9
10
11
# File 'lib/taeval/git_checkout/config.rb', line 9

def prefix
  @prefix
end

#solutionObject (readonly)

Returns the value of attribute solution.



9
10
11
# File 'lib/taeval/git_checkout/config.rb', line 9

def solution
  @solution
end

#sourceObject (readonly)

Returns the value of attribute source.



9
10
11
# File 'lib/taeval/git_checkout/config.rb', line 9

def source
  @source
end

#tokensObject (readonly)

Returns the value of attribute tokens.



9
10
11
# File 'lib/taeval/git_checkout/config.rb', line 9

def tokens
  @tokens
end