Class: Rubolite::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/rubolite/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf_file) ⇒ Parser

Returns a new instance of Parser.



5
6
7
8
9
# File 'lib/rubolite/parser.rb', line 5

def initialize(conf_file)
  @conf_file = conf_file
  @groups = {}
  parse!
end

Instance Attribute Details

#conf_fileObject (readonly)

Returns the value of attribute conf_file.



3
4
5
# File 'lib/rubolite/parser.rb', line 3

def conf_file
  @conf_file
end

#groupsObject (readonly)

Returns the value of attribute groups.



3
4
5
# File 'lib/rubolite/parser.rb', line 3

def groups
  @groups
end

#reposObject (readonly)

Returns the value of attribute repos.



3
4
5
# File 'lib/rubolite/parser.rb', line 3

def repos
  @repos
end

Instance Method Details

#parse_group_line(group_line) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/rubolite/parser.rb', line 31

def parse_group_line(group_line)
  if matched = group_line.match(/@([\w]+)\s+=\s+(.*)/)
    group_name = matched[1]
    names = matched[2].split(" ")
    
    [group_name, names]
  else
    nil
  end
end

#parse_permissions_line(permission_line) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/rubolite/parser.rb', line 23

def parse_permissions_line(permission_line)
  if matched = permission_line.match(/([R|W|\+\-]+)\s+=\s+([\@\w\d\-]+)/)
    [matched[1], matched[2]]
  else
    []
  end
end

#parse_repo_line(repo_line) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/rubolite/parser.rb', line 15

def parse_repo_line(repo_line)
  if matched = repo_line.match(/repo ([\w\-\d]+)/)
    matched[1]
  else
    nil
  end
end

#writerObject



11
12
13
# File 'lib/rubolite/parser.rb', line 11

def writer
  @writer ||= Writer.new(self)
end