hsds_transformer 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/api.rb +52 -0
- data/lib/datapackage/datapackage.json +1579 -0
- data/lib/datapackage/open211_miami_datapackage.json +1007 -0
- data/lib/hsds_transformer/base_transformer.rb +182 -0
- data/lib/hsds_transformer/custom/ilao_transformer.rb +80 -0
- data/lib/hsds_transformer/custom/open211_miami_transformer.rb +168 -0
- data/lib/hsds_transformer/exceptions.rb +5 -0
- data/lib/hsds_transformer/file_paths.rb +40 -0
- data/lib/hsds_transformer/headers.rb +31 -0
- data/lib/hsds_transformer/runner.rb +32 -0
- data/lib/hsds_transformer.rb +15 -0
- data/lib/support.rb +31 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e911449b148656bce8dcd5c10110a25e8f2d86af9d676544a059516860daa5a
|
4
|
+
data.tar.gz: 246bbd0c2d57cdf66b3ddb8f9b586ab30d75732eef53216244247f59ee2ca572
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 36870c841e466cf83927ee4e586c76d83dbc485420810db0cb6f4b1f3d9940b2e6a440407627a68bb050870981738511920a4ebc9441e91181adb2dc96ab23f4
|
7
|
+
data.tar.gz: 87d3e610a1a951449b77b4715f823eeadc71b9e4ca19770c6c1c94ee7a9939897f5007670a2001f048aa1a4a89614c73172af6dab5d83ff8025de26ca2aa6390
|
data/lib/api.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "sinatra"
|
2
|
+
require "sinatra/base"
|
3
|
+
require_relative "../lib/hsds_transformer"
|
4
|
+
|
5
|
+
class Api < Sinatra::Base
|
6
|
+
set :bind, '0.0.0.0'
|
7
|
+
|
8
|
+
before do
|
9
|
+
content_type 'multipart/form-data'
|
10
|
+
end
|
11
|
+
|
12
|
+
get "/transform" do
|
13
|
+
"Submit your data uri"
|
14
|
+
end
|
15
|
+
|
16
|
+
# TODO catch the Exceptions and return error reponses
|
17
|
+
post "/transform" do
|
18
|
+
input_path = params[:input_path]
|
19
|
+
mapping_uri = params[:mapping]
|
20
|
+
include_custom = params[:include_custom]
|
21
|
+
custom_transformer = params[:custom_transformer]
|
22
|
+
|
23
|
+
if mapping_uri.nil?
|
24
|
+
halt 422, "A mapping file is required."
|
25
|
+
end
|
26
|
+
|
27
|
+
if input_path.nil?
|
28
|
+
halt 422, "An input_path is required."
|
29
|
+
end
|
30
|
+
|
31
|
+
transformer = HsdsTransformer::Runner.run(
|
32
|
+
input_path: input_path,
|
33
|
+
mapping: mapping_uri,
|
34
|
+
include_custom: include_custom,
|
35
|
+
zip_output: true,
|
36
|
+
custom_transformer: custom_transformer
|
37
|
+
)
|
38
|
+
|
39
|
+
send_file transformer.zipfile_name
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
#require "net/http"
|
45
|
+
|
46
|
+
# uri = URI.parse("http://localhost:4567")
|
47
|
+
|
48
|
+
# http = Net::HTTP.new(uri.host, uri.port)
|
49
|
+
# request = Net::HTTP::Post.new("/v1.1/auth")
|
50
|
+
# request.add_field('Content-Type', 'application/json')
|
51
|
+
# request.body = {'credentials' => ''}
|
52
|
+
#response = http.request(request)
|