Class: Asciibuild::Extensions::ConcatBlock

Inherits:
Asciidoctor::Extensions::BlockProcessor
  • Object
show all
Defined in:
lib/asciibuild/extensions.rb

Instance Method Summary collapse

Instance Method Details

#process(parent, reader, attrs) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/asciibuild/extensions.rb', line 72

def process parent, reader, attrs
  doctitle = parent.document.attributes["doctitle"]
  body = reader.read

  puts ""
  puts "#{doctitle} > #{parent.title} > #{attrs['title']}"
  puts (">" * 80)

  fname = if not include_section?(parent, attrs)
    if parent.document.attributes["error"]
      puts "Section \"#{parent.title}\" skipped due to previous error."
      attrs['title'] = 'icon:pause-circle[role=red] ' + attrs['title'] + " (previous error)"
    else
      sections = parent.document.attributes["sections"].split(/,[ ]*/)
      puts "Section \"#{parent.title}\" skipped. Does not match #{sections}."
      attrs['title'] = 'icon:pause-circle[role=yellow] ' + attrs['title']
    end
    false
  else
    attrs["file"]
  end

  if fname
    if not parent.document.attributes["#{parent.title} #{fname}"]
      open(fname, 'w') do |f|
        f.write("")
      end
      parent.document.attributes["#{parent.title} #{fname}"] = true
    end

    open(fname, 'a') do |f|
      f.write(body + "\n")
    end
    puts body
  end

  puts ("<" * 80)

  create_open_block parent, ["----", body, "----"], attrs
end