data_collector 0.56.0 → 0.57.0
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 +4 -4
- data/lib/data_collector/input.rb +12 -12
- data/lib/data_collector/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d5f35afbd231bcacdb1d225cded55d4d7a0879ef71a9521241bb5e32c0ebacc7
|
|
4
|
+
data.tar.gz: 9c93c8e26d33921fd678668cf0ce2a152cbcd35d7d7fe928f03f328b25bd0f00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cd04dd04c330c3232ffe61810ec3b1e250c820872495bdbb6019590a68d603db596cb419e080bd01e858bd50ec50f630101254cb3787bacf042c8cf3e4c3991
|
|
7
|
+
data.tar.gz: d77da04c3d513adaedf983b83215a5c1427d0e1599df9c8d3cf6d702461b5eb96f52ef3d86a29f0471dc3ae314d3a9ac8d74f9772a7433d3b24df8b42e6e9742
|
data/lib/data_collector/input.rb
CHANGED
|
@@ -104,8 +104,6 @@ module DataCollector
|
|
|
104
104
|
|
|
105
105
|
http = HTTP
|
|
106
106
|
|
|
107
|
-
# http.use(logging: {logger: @logger})
|
|
108
|
-
|
|
109
107
|
if options.key?(:user) && options.key?(:password)
|
|
110
108
|
@logger.debug "Set Basic_auth"
|
|
111
109
|
user = options[:user]
|
|
@@ -157,13 +155,9 @@ module DataCollector
|
|
|
157
155
|
when 200..299
|
|
158
156
|
@raw = data = http_response.body.to_s
|
|
159
157
|
|
|
160
|
-
# File.open("#{rand(1000)}.xml", 'wb') do |f|
|
|
161
|
-
# f.puts data
|
|
162
|
-
# end
|
|
163
|
-
|
|
164
158
|
file_type = options.with_indifferent_access.has_key?(:content_type) ? options.with_indifferent_access[:content_type] : file_type_from(http_response.headers)
|
|
165
159
|
|
|
166
|
-
unless options.with_indifferent_access.has_key?(:raw) && options.with_indifferent_access[:raw] == true
|
|
160
|
+
unless options.with_indifferent_access.has_key?(:raw) && options.with_indifferent_access[:raw] == true && !['text/turtle', 'application/rdf+xml'].include?(file_type)
|
|
167
161
|
case file_type
|
|
168
162
|
when 'application/ld+json'
|
|
169
163
|
data = JSON.parse(data)
|
|
@@ -181,6 +175,8 @@ module DataCollector
|
|
|
181
175
|
data = html_to_hash(data, options)
|
|
182
176
|
when 'text/turtle'
|
|
183
177
|
data = rdf_to_hash(data, options)
|
|
178
|
+
when 'application/rdf+xml'
|
|
179
|
+
data = rdf_to_hash(data, options)
|
|
184
180
|
when /^image/
|
|
185
181
|
options['file_type'] = file_type
|
|
186
182
|
data = image_to_data(data, options)
|
|
@@ -206,9 +202,11 @@ module DataCollector
|
|
|
206
202
|
end
|
|
207
203
|
|
|
208
204
|
def rdf_to_hash(data, options = {})
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
205
|
+
format = options[:file_type] || options[:content_type] || 'text/turtle'
|
|
206
|
+
graph = RDF::Graph.new{ |graph| RDF::Format.content_types[format].first.reader.new(data){|reader| graph << reader}}
|
|
207
|
+
|
|
208
|
+
return graph if options.with_indifferent_access[:raw]
|
|
209
|
+
|
|
212
210
|
data = JSON.parse(graph.dump(:jsonld, validate: false, standard_prefixes: true))
|
|
213
211
|
end
|
|
214
212
|
|
|
@@ -223,7 +221,7 @@ module DataCollector
|
|
|
223
221
|
sio.rewind
|
|
224
222
|
file.write(sio.read)
|
|
225
223
|
file.close
|
|
226
|
-
from_file(URI("file://#{file.path}"))
|
|
224
|
+
from_file(URI("file://#{file.path}"), options)
|
|
227
225
|
ensure
|
|
228
226
|
file.unlink
|
|
229
227
|
end
|
|
@@ -234,7 +232,7 @@ module DataCollector
|
|
|
234
232
|
uri = normalize_uri(uri)
|
|
235
233
|
absolute_path = File.absolute_path(uri)
|
|
236
234
|
file_type = MIME::Types.type_for(uri).first.to_s
|
|
237
|
-
options['file_type'] = file_type
|
|
235
|
+
options['file_type'] = options[:content_type] || file_type
|
|
238
236
|
raise DataCollector::Error, "#{uri.to_s} not found" unless File.exist?("#{absolute_path}")
|
|
239
237
|
unless options.has_key?('raw') && options['raw'] == true
|
|
240
238
|
@raw = data = File.read("#{absolute_path}")
|
|
@@ -277,6 +275,8 @@ module DataCollector
|
|
|
277
275
|
data = image_to_data(data, options)
|
|
278
276
|
when '.ttl'
|
|
279
277
|
data = rdf_to_hash(data, options)
|
|
278
|
+
when '.rdf'
|
|
279
|
+
data = rdf_to_hash(data, options)
|
|
280
280
|
else
|
|
281
281
|
raise "Do not know how to process #{uri.to_s}"
|
|
282
282
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: data_collector
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.57.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mehmet Celik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-02-
|
|
11
|
+
date: 2025-02-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|