class JekyllGetBooks::GetBooksGenerator
Public Instance Methods
generate(site)
click to toggle source
# File lib/jekyll-get-books/converter.rb, line 12 def generate(site) config = site.config['jekyll_get_books'] if !config warn "No config".yellow return end if !config.kind_of?(Array) config = [config] end config.each do |d| begin target = site.data[d['data']] source = d['json'] file = d['file'] results = {} if !(File.file?(file)) warn "File does not exist / Path is incorrect".yellow end CSV.foreach((file), headers: true, col_sep: ",") do |row| output = JSON.load(URI.open(source+row['isbn'])) results.deep_merge(output) end site.data[d['data']] = results rescue next end end end