From edaf64ea5c946fe1015fc5f7ef59db73123c7412 Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Thu, 11 Dec 2014 12:18:04 +0100 Subject: [PATCH] Do not fail when file has no game data --- nikoli.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nikoli.rb b/nikoli.rb index 1aa073c..97bb061 100755 --- a/nikoli.rb +++ b/nikoli.rb @@ -35,5 +35,6 @@ get "/data/:game/:file.json" do |game, file| data_file = File.expand_path(File.join(settings.data_folder, game, "#{file}.yml")) halt(404) unless File.exist?(data_file) - json YAML.load_file(data_file)['data'].sample + data = YAML.load_file(data_file)['data'] + json Array(data).sample end