Module: Support

Defined in:
lib/support.rb

Overview

TODO implement validation

Instance Method Summary collapse

Instance Method Details

#validate(filename, type) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/support.rb', line 3

def validate(filename, type)
  filename = "#{filename}"
  file = File.new(filename, 'rb')
  RestClient.post('http://localhost:1400/validate/csv',
                  {"file" => file,
                   "type" => type})
  return true
rescue RestClient::BadRequest
  @valid = false
  return false
end

#validate_outputObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/support.rb', line 15

def validate_output
  unless validate(output_organizations_path, "organization")
    puts "Organization data not valid"
  end
  unless validate(output_locations_path, "location")
    puts "Location data not valid"
  end
  unless validate(output_services_path, "service")
    puts "Service data not valid"
  end
  unless validate(output_phones_path, "phone")
    puts "Phone data not valid"
  end
rescue Errno::ECONNREFUSED
  puts "Can't connect to validation service."
end