diff --git a/app.rb b/app.rb index 79c72d4..f6ff549 100644 --- a/app.rb +++ b/app.rb @@ -10,13 +10,23 @@ end post '/validate' do - tidy_file = params[:tidyDataFile][:tempfile] - schema_file = params[:schemaFile][:tempfile] - schema_string = schema_file.read - csvw_schema = Csvlint::Schema.load_from_string(params[:schemaFile][:filename], - schema_string, - true) - @validator = Csvlint::Validator.new(tidy_file, {}, csvw_schema) -# @validator.validate + tmp_dir = Dir::mktmpdir('csvlint') + tidy_tmpfile = params[:tidyDataFile][:tempfile] + tidy_filename = File::join(tmp_dir, params[:tidyDataFile][:filename]) + File.open(tidy_filename, 'wb') do |tf| + tf.write(tidy_tmpfile.read) + end + schema_tmpfile = params[:schemaFile][:tempfile] + schema_filename = File::join(tmp_dir, params[:schemaFile][:filename]) + File.open(schema_filename, 'wb') do |sf| + sf.write(schema_tmpfile.read) + end + csvw_schema = Csvlint::Schema.load_from_uri(schema_filename) + valid = true + @validator = nil + csvw_schema.tables.keys.each do |source| + @validator = Csvlint::Validator.new(source, {}, csvw_schema) + valid &= @validator.valid? + end erb :results end diff --git a/views/results.erb b/views/results.erb index 186a1ce..86eba22 100644 --- a/views/results.erb +++ b/views/results.erb @@ -19,23 +19,32 @@