Class: CheckHamlData
- Inherits:
-
Object
- Object
- CheckHamlData
- Includes:
- CheckTable
- Defined in:
- lib/asker/check_input/check_haml_data.rb
Instance Attribute Summary collapse
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(filepath) ⇒ CheckHamlData
constructor
A new instance of CheckHamlData.
- #ok? ⇒ Boolean
- #show ⇒ Object
- #show_errors ⇒ Object
Methods included from CheckTable
#check_col, #check_row, #check_table, #check_template, #check_text
Constructor Details
#initialize(filepath) ⇒ CheckHamlData
Returns a new instance of CheckHamlData.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/asker/check_input/check_haml_data.rb', line 11 def initialize(filepath) @inputs = File.read(filepath).split("\n") @outputs = [] @inputs.each_with_index do |line, index| output = { id: index, level: 0, state: :none, type: :none, source: line, msg: '' } @outputs << output end @ok = false end |
Instance Attribute Details
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
9 10 11 |
# File 'lib/asker/check_input/check_haml_data.rb', line 9 def inputs @inputs end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
9 10 11 |
# File 'lib/asker/check_input/check_haml_data.rb', line 9 def outputs @outputs end |
Instance Method Details
#check ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/asker/check_input/check_haml_data.rb', line 60 def check @ok = true @inputs.each_with_index do |line, index| check_empty_lines(line, index) check_map(line, index) check_concept(line, index) check_names(line, index) (line, index) check_def(line, index) check_table(line, index) check_row(line, index) check_col(line, index) check_template(line, index) check_code(line, index) check_type(line, index) check_path(line, index) check_features(line, index) check_unknown(line, index) @ok = false unless @outputs[index][:state] == :ok @ok = false if @outputs[index][:type] == :unkown end @ok end |
#ok? ⇒ Boolean
26 27 28 |
# File 'lib/asker/check_input/check_haml_data.rb', line 26 def ok? @ok end |
#show ⇒ Object
30 31 32 33 34 |
# File 'lib/asker/check_input/check_haml_data.rb', line 30 def show @outputs.each do |i| puts "#{i[:id]}: #{i[:state]} [#{i[:type]}] #{i[:msg]}" end end |
#show_errors ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/asker/check_input/check_haml_data.rb', line 36 def show_errors errors = 0 # puts "Line : Error description" puts "\n" @outputs.each do |i| next if i[:state] == :ok errors += 1 if errors < 11 data = { id: i[:id], msg: i[:msg], source: i[:source][0, 40] } order = i[:id] + 1 data = { order: order, msg: i[:msg], source: i[:source][0, 40] } print format(' %<order>03d : %<msg>32s. => '.white, data) puts format('%<source>s'.light_yellow, data) end puts '...' if errors == 11 end if errors.positive? puts "\n[ ASKER ] Please! Revise #{errors.to_s.light_red} error/s\n" end puts 'Syntax OK!'.green if errors.zero? end |