-
Notifications
You must be signed in to change notification settings - Fork 3
/
dummy_app.rb
36 lines (31 loc) · 917 Bytes
/
dummy_app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'net/http'
require 'json'
require 'logger'
module DummyApp
class Base
def initialize
logfile = File.new(File.join(__dir__, "logs", "error.log"), 'w')
@log = Logger.new(logfile)
end
def arelle_validation(filename)
uri = URI("http://arelle:8080/rest/xbrl/validation?file=/ixbrl/#{filename}&media=json")
request_validation(filename, uri)
end
def business_validation(filename)
uri = URI("http://validator:4567/validate/#{filename}")
request_validation(filename, uri)
end
def request_validation(filename, uri)
begin
request = Net::HTTP.get(uri)
response = JSON.parse(request)
File.open(File.join(__dir__, "logs", filename.gsub("html", "json")), 'w') do |f|
f.write(JSON.pretty_generate(response))
end
response
rescue Exception => e
@log.error(e)
end
end
end
end