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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f53de79d6c24688e67edb48195a2f1ce4adaf69eaa616033cf1886cccd1e696
4
- data.tar.gz: f5d13e7d3d03a9218c66c15907501f78b3e565ae8c69c012d6139ac28156a493
3
+ metadata.gz: d5f35afbd231bcacdb1d225cded55d4d7a0879ef71a9521241bb5e32c0ebacc7
4
+ data.tar.gz: 9c93c8e26d33921fd678668cf0ce2a152cbcd35d7d7fe928f03f328b25bd0f00
5
5
  SHA512:
6
- metadata.gz: 426fe700363732ab23659a865d31d9cafe1eea16d7ad3e9deaddeb614d831e723f3e27d7cbd4ced72141e15928272eed11c1af4c7cb049aa38ad5aaf0088a48b
7
- data.tar.gz: b0c57cad550f8f04c004fcae3c3b2b4879c8c01030aef5e29506752d8da397db1efce01a65c3df3cede620ef66acb64ee0e5cc2b3e926ac732b399b61e8742d4
6
+ metadata.gz: 3cd04dd04c330c3232ffe61810ec3b1e250c820872495bdbb6019590a68d603db596cb419e080bd01e858bd50ec50f630101254cb3787bacf042c8cf3e4c3991
7
+ data.tar.gz: d77da04c3d513adaedf983b83215a5c1427d0e1599df9c8d3cf6d702461b5eb96f52ef3d86a29f0471dc3ae314d3a9ac8d74f9772a7433d3b24df8b42e6e9742
@@ -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
- graph = RDF::Graph.new do |graph|
210
- RDF::Turtle::Reader.new(data) { |reader| graph << reader }
211
- end
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
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module DataCollector
3
- VERSION = "0.56.0"
3
+ VERSION = "0.57.0"
4
4
  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.56.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-09 00:00:00.000000000 Z
11
+ date: 2025-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport