Class: Konfa::AutoDoc::Parser
- Inherits:
-
Object
- Object
- Konfa::AutoDoc::Parser
- Defined in:
- lib/konfa/autodoc/parser.rb
Constant Summary collapse
- RE_VAR =
/ (?: :(\w+)\s*=> # 0: Old style hash key declaration - :key => 'value' | # - or - (\w+): # 1: New style hash key declaration - key: 'value' ) \s* (?: (?:'|")(.+?)(?:'|") # 2: A string constant (FIXME: unless Backrefs to match leading and tailing quote) | # - or - ([\w\@\:\.]+) # 3: Bareword ) \s* ,? # - an optional comma - \s* (?: \#\s*(.+?) # 4: An optional comment (?=\n\s*(?: # Match all lines to next entry, :\w+\s*=> # or end of hash declaraion. The lookahead |\} # ensures we do not gobble up string for next match |\w+: )) )? /xm
Instance Attribute Summary collapse
-
#konfa_class ⇒ Object
readonly
Returns the value of attribute konfa_class.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(const) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(const) ⇒ Parser
Returns a new instance of Parser.
11 12 13 14 |
# File 'lib/konfa/autodoc/parser.rb', line 11 def initialize(const) @variables = [] @konfa_class = const end |
Instance Attribute Details
#konfa_class ⇒ Object (readonly)
Returns the value of attribute konfa_class.
9 10 11 |
# File 'lib/konfa/autodoc/parser.rb', line 9 def konfa_class @konfa_class end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
9 10 11 |
# File 'lib/konfa/autodoc/parser.rb', line 9 def variables @variables end |
Instance Method Details
#parse ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/konfa/autodoc/parser.rb', line 41 def parse @variables = [] code = @konfa_class.method(:allowed_variables).source code.scan(RE_VAR).each do |tokens| @variables << Variable.new( tokens[0] || tokens[1], tokens[2] || tokens[3], trim_comment(tokens[4]) ) end variables end |