Class: Gitlab::Git::GitmodulesParser::State

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/git/gitmodules_parser.rb

Instance Method Summary collapse

Constructor Details

#initializeState

Returns a new instance of State.


21
22
23
24
# File 'lib/gitlab/git/gitmodules_parser.rb', line 21

def initialize
  @result = {}
  @current_submodule = nil
end

Instance Method Details

#section_started?Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/gitlab/git/gitmodules_parser.rb', line 38

def section_started?
  !@current_submodule.nil?
end

#set_attribute(attr, value) ⇒ Object


34
35
36
# File 'lib/gitlab/git/gitmodules_parser.rb', line 34

def set_attribute(attr, value)
  @current_submodule[attr] = value
end

#start_section(section) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/gitlab/git/gitmodules_parser.rb', line 26

def start_section(section)
  # In some .gitmodules files (e.g. nodegit's), a header
  # with the same name appears multiple times; we want to
  # accumulate the configs across these
  @current_submodule = @result[section] || { 'name' => section }
  @result[section] = @current_submodule
end

#submodules_by_nameObject


42
43
44
# File 'lib/gitlab/git/gitmodules_parser.rb', line 42

def submodules_by_name
  @result
end