Class: Krambook::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/krambook.rb

Instance Method Summary collapse

Instance Method Details

#joinObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/krambook.rb', line 15

def join
	files            = []
			joined_file_path = File.expand_path './manuscript/' + 'Joined.md'
			File.delete(joined_file_path) if File.exist?(joined_file_path)

			File.open(File.expand_path('./manuscript/Book.txt'), 'r') do |f|
f.each_line do |line|
	files << line.gsub(/\s+/, "")
end
			end

			File.open(joined_file_path, 'a') do |f|
files.each do |file_path|
	full_file_path = File.expand_path './manuscript/' + file_path
	f.puts Kramdown::Document.new(IO.read(full_file_path)).send("to_#{options[:format]}".to_sym) if File.exists?(full_file_path)
	f.puts '' unless file_path = files.last
end
			end
end