class Object
Constants
- FORMAT_STRING_EVENTS
- FORMAT_STRING_META
- FORMAT_STRING_PLACES
- RESULT_LIMIT
- SEARCH_STRINGS
Public Instance Methods
check_config(config)
click to toggle source
# File lib/jekyll/hoffnung3000/main.rb, line 75 def check_config(config) raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 block" unless config["hoffnung3000"] unless config["hoffnung3000"]["url"] raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 > url value" end config end
fetch_data(url, key)
click to toggle source
# File lib/jekyll/hoffnung3000/main.rb, line 88 def fetch_data(url, key) HTTP.get(format("%<url>s/api/%<key>s", { url: url, key: key }), { params: { limit: RESULT_LIMIT } }).body end
format_data(data, key)
click to toggle source
# File lib/jekyll/hoffnung3000/main.rb, line 65 def format_data(data, key) jq = JQ(data, parse_json: true) jq.search(SEARCH_STRINGS[key]) end
get_hoffnung(config, key)
click to toggle source
# File lib/jekyll/hoffnung3000/main.rb, line 92 def get_hoffnung(config, key) url = url(config) data = fetch_data(url, key) formatted_data = format_data(data, key) write_data(formatted_data, key) end
url(config)
click to toggle source
# File lib/jekyll/hoffnung3000/main.rb, line 84 def url(config) check_config(config)["hoffnung3000"]["url"] end
write_data(data, file_name)
click to toggle source
# File lib/jekyll/hoffnung3000/main.rb, line 70 def write_data(data, file_name) Dir.mkdir("_data") unless Dir.exist?("_data") File.write(format("_data/%s.json", file_name), JSON.generate(data)) end