Class: Rubolite::Parser
- Inherits:
-
Object
- Object
- Rubolite::Parser
- Defined in:
- lib/rubolite/parser.rb
Instance Attribute Summary collapse
-
#conf_file ⇒ Object
readonly
Returns the value of attribute conf_file.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#repos ⇒ Object
readonly
Returns the value of attribute repos.
Instance Method Summary collapse
-
#initialize(conf_file) ⇒ Parser
constructor
A new instance of Parser.
- #parse_group_line(group_line) ⇒ Object
- #parse_permissions_line(permission_line) ⇒ Object
- #parse_repo_line(repo_line) ⇒ Object
- #writer ⇒ Object
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_file ⇒ Object (readonly)
Returns the value of attribute conf_file.
3 4 5 |
# File 'lib/rubolite/parser.rb', line 3 def conf_file @conf_file end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
3 4 5 |
# File 'lib/rubolite/parser.rb', line 3 def groups @groups end |
#repos ⇒ Object (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 () if matched = .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 |