-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.rb
37 lines (30 loc) · 960 Bytes
/
Main.rb
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
$: << File.expand_path(File.dirname(__FILE__) + '/MapsDotCom/')
require 'rubygems'
require 'bundler/setup'
require 'CIAFactbookScraper/FactbookReader'
require 'CIAFactbookScraper/M101FactbookRenderer'
cia_html_directory = ARGV.first
unless Dir.exists? cia_html_directory
puts "Cannot find directory #{cia_html_directory}"
exit 1
end
output_dir = ARGV[1]
unless Dir.exists? output_dir
Dir.mkdir output_dir, 0777
end
Dir.open cia_html_directory do |d|
d.each do |filename|
if filename.end_with? '.html'
puts "Reading #{filename}"
File.open(File.join(d.path, filename), 'r') do |input|
reader = MapsDotCom::CIAFactbookScraper::FactbookReader.new input
#sections = reader.sections
puts "Writing #{filename}"
File.open(File.join(output_dir, filename), 'w') do |output|
renderer = M101FactbookRenderer.new reader
output.puts(renderer.to_html)
end
end
end
end
end