-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchisel.rb
More file actions
48 lines (39 loc) · 969 Bytes
/
chisel.rb
File metadata and controls
48 lines (39 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'pry'
require './parser_assigner'
class Chisel
attr_reader :chunks, :handle, :input, :output, :assigned_chunks
def initialize(input=ARGV[0], output=ARGV[1])
@handle = File.open(input, "r")
@chunks = []
@input = input
@output = output
@assigned_chunks = []
end
def load_input
markdown = handle.read
@chunks = markdown.split("\n\n")
end
def assign_parser
parse_it = ParserAssigner.new
@chunks.each do |chunk|
chunk.rstrip
assigned_chunks << parse_it.assign_chunk(chunk)
end
end
def join_html
assign_parser
@assigned_chunks.join("\n\n")
end
def process_output
html = File.open(output,'w+')
html.write(join_html)
html.rewind
handle.rewind
puts "Converted #{input} (#{handle.readlines.count.to_s} lines) to #{output} (#{html.readlines.count.to_s} lines)"
handle.close
html.close
end
end
chisel = Chisel.new
chisel.load_input
chisel.process_output