Module: Ghaki::Report::Mixin::LinearParser
- Defined in:
- lib/ghaki/report/mixin/linear_parser.rb
Constant Summary collapse
- PARSER_UNKNOWN_UNLIMITED =
0
- PARSER_UNKNOWN_MAX_DEF =
PARSER_UNKNOWN_UNLIMITED
- PARSER_WARN_UNLIMITED =
0
- PARSER_WARN_MAX_DEF =
10
- PARSER_ERROR_UNLIMITED =
0
- PARSER_ERROR_MAX_DEF =
1
Instance Attribute Summary collapse
-
#parser_curr_lcnt ⇒ Object
readonly
Returns the value of attribute parser_curr_lcnt.
-
#parser_curr_line ⇒ Object
readonly
Returns the value of attribute parser_curr_line.
-
#parser_error_max ⇒ Object
Returns the value of attribute parser_error_max.
-
#parser_unknown_max ⇒ Object
Returns the value of attribute parser_unknown_max.
-
#parser_warn_max ⇒ Object
Returns the value of attribute parser_warn_max.
Instance Method Summary collapse
-
#_parser_basic_check(msg, max, unl, maj, min, exc) ⇒ Object
PARSER STATE CHECKS.
- #_parser_error_check(msg) ⇒ Object
- #_parser_unknown_check(msg) ⇒ Object
- #_parser_warn_check(msg) ⇒ Object
- #parser_advance(line) ⇒ Object
- #parser_cleanup ⇒ Object
- #parser_engine(text, &block) ⇒ Object
- #parser_error(msg = 'Parser Error') ⇒ Object
- #parser_invalid(msg = 'Invalid Line') ⇒ Object
-
#parser_matched(msg = '') ⇒ Object
PARSING STATUS.
- #parser_reset_state ⇒ Object
- #parser_reset_stats ⇒ Object
- #parser_skipped(msg = 'Expected') ⇒ Object
- #parser_startup ⇒ Object
- #parser_unknown(msg = 'Unknown Input') ⇒ Object
- #parser_warn(msg = 'Parser Warning') ⇒ Object
Instance Attribute Details
#parser_curr_lcnt ⇒ Object (readonly)
Returns the value of attribute parser_curr_lcnt.
18 19 20 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 18 def parser_curr_lcnt @parser_curr_lcnt end |
#parser_curr_line ⇒ Object (readonly)
Returns the value of attribute parser_curr_line.
18 19 20 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 18 def parser_curr_line @parser_curr_line end |
#parser_error_max ⇒ Object
Returns the value of attribute parser_error_max.
19 20 21 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 19 def parser_error_max @parser_error_max end |
#parser_unknown_max ⇒ Object
Returns the value of attribute parser_unknown_max.
19 20 21 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 19 def parser_unknown_max @parser_unknown_max end |
#parser_warn_max ⇒ Object
Returns the value of attribute parser_warn_max.
19 20 21 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 19 def parser_warn_max @parser_warn_max end |
Instance Method Details
#_parser_basic_check(msg, max, unl, maj, min, exc) ⇒ Object
PARSER STATE CHECKS
103 104 105 106 107 108 109 110 111 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 103 def _parser_basic_check msg, max, unl, maj, min, exc stats.incr maj, min return if max == unl raise ReportContentError, msg if max == 1 cnt = stats.get( maj, min ) if cnt >= max raise ReportContentError, exc + ' Maximum Exceeded: ' + cnt.to_s end end |
#_parser_error_check(msg) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 113 def _parser_error_check msg _parser_basic_check( msg, @parser_error_max, PARSER_ERROR_UNLIMITED, 'Parser State', 'Errors', 'Parser Error' ) end |
#_parser_unknown_check(msg) ⇒ Object
127 128 129 130 131 132 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 127 def _parser_unknown_check msg _parser_basic_check( msg, @parser_unknown_max, PARSER_UNKNOWN_UNLIMITED, 'Input Lines', 'Unknown', 'Unknown Line' ) end |
#_parser_warn_check(msg) ⇒ Object
120 121 122 123 124 125 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 120 def _parser_warn_check msg _parser_basic_check( msg, @parser_warn_max, PARSER_WARN_UNLIMITED, 'Parser State', 'Warnings', 'Parser Warning' ) end |
#parser_advance(line) ⇒ Object
46 47 48 49 50 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 46 def parser_advance line @parser_curr_lcnt += 1 @parser_curr_line = line stats.incr 'Input Lines', 'Read' end |
#parser_cleanup ⇒ Object
43 44 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 43 def parser_cleanup end |
#parser_engine(text, &block) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 52 def parser_engine text, &block parser_startup text.each_line do |line| parser_advance line block.call( line ) end parser_cleanup end |
#parser_error(msg = 'Parser Error') ⇒ Object
86 87 88 89 90 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 86 def parser_error msg='Parser Error' logger.error "#{msg} At Line #{@parser_curr_lcnt}" logger.puts @parser_curr_line _parser_error_check msg end |
#parser_invalid(msg = 'Invalid Line') ⇒ Object
81 82 83 84 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 81 def parser_invalid msg='Invalid Line' stats.incr 'Input Lines', 'Invalid' parser_error msg end |
#parser_matched(msg = '') ⇒ Object
PARSING STATUS
65 66 67 68 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 65 def parser_matched msg='' stats.incr 'Input Lines', 'Matched' stats.incr 'Matched Lines', msg unless msg.empty? end |
#parser_reset_state ⇒ Object
30 31 32 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 30 def parser_reset_state @parser_curr_lcnt = 0 end |
#parser_reset_stats ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 34 def parser_reset_stats stats.clear stats.def_zero 'Input Lines', 'Read' stats.def_zero 'Input Lines', 'Skipped' stats.def_zero 'Input Lines', 'Matched' stats.def_zero 'Input Lines', 'Invalid' stats.def_zero 'Input Lines', 'Unknown' end |
#parser_skipped(msg = 'Expected') ⇒ Object
70 71 72 73 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 70 def parser_skipped msg='Expected' stats.incr 'Input Lines', 'Skipped' stats.incr 'Skipped Lines', msg end |
#parser_startup ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 22 def parser_startup @parser_unknown_max ||= PARSER_UNKNOWN_MAX_DEF @parser_warn_max ||= PARSER_WARN_MAX_DEF @parser_error_max ||= PARSER_ERROR_MAX_DEF parser_reset_stats parser_reset_state end |
#parser_unknown(msg = 'Unknown Input') ⇒ Object
75 76 77 78 79 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 75 def parser_unknown msg='Unknown Input' logger.warn "#{msg} At Line #{@parser_curr_lcnt}" logger.puts @parser_curr_line _parser_unknown_check msg end |
#parser_warn(msg = 'Parser Warning') ⇒ Object
92 93 94 95 96 |
# File 'lib/ghaki/report/mixin/linear_parser.rb', line 92 def parser_warn msg='Parser Warning' logger.warn "#{msg} At Line #{@parser_curr_lcnt}" logger.puts @parser_curr_line _parser_warn_check msg end |