data_collector 0.43.0 → 0.45.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/ext/base.rb +25 -24
- data/lib/data_collector/input.rb +11 -6
- data/lib/data_collector/output.rb +4 -3
- data/lib/data_collector/rules_ng.rb +9 -1
- 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: a49714819cab65865ffa979707a867868ac0ce744a2e5dc6c278b29f63b61cb7
|
4
|
+
data.tar.gz: 69bdbf4961d01e4f3f83fd5ab56dd24a62da4d24c9cf7ac7633bbcd10d2320dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e60a28fbcdc39cfa01540bca282de4ad4a2fd4c256c7ef8193b77cfec6aaf62955d741a342b8ba8f68d58bfab714bb54cdfabcfe3c4e9411da52bd5d3f9afbd
|
7
|
+
data.tar.gz: 6e8630411c26f55a74d6230f237370e31cc05ca1971d7bf849fc9258b15f03103ba97f952c5ae49ded8bf343c536b7baf39effb1a3f528408e6c14c22a9a1414
|
@@ -33,31 +33,32 @@ module BunnyBurrow
|
|
33
33
|
:connection_name
|
34
34
|
)
|
35
35
|
|
36
|
-
def initialize
|
37
|
-
|
38
|
-
|
39
|
-
# private
|
40
|
-
#
|
41
|
-
# def connection
|
42
|
-
# Connection.instance.connection_name = @connection_name
|
43
|
-
# Connection.instance.verify_peer = @verify_peer
|
44
|
-
# Connection.instance.rabbitmq_url = @rabbitmq_url
|
45
|
-
#
|
46
|
-
# unless @connection
|
47
|
-
# @connection = Connection.instance.connection
|
48
|
-
# @connection.start unless @connection.open?
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# @connection
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# def channel
|
55
|
-
# Connection.instance.connection_name = @connection_name
|
56
|
-
# Connection.instance.verify_peer = @verify_peer
|
57
|
-
# Connection.instance.rabbitmq_url = @rabbitmq_url
|
58
|
-
#
|
59
|
-
# @channel = Connection.instance.channel
|
36
|
+
# def initialize
|
37
|
+
# super
|
38
|
+
# @connection_name = "#{Process.pid}-#{SecureRandom.uuid}"
|
60
39
|
# end
|
40
|
+
# private
|
41
|
+
#
|
42
|
+
# def connection
|
43
|
+
# Connection.instance.connection_name = @connection_name
|
44
|
+
# Connection.instance.verify_peer = @verify_peer
|
45
|
+
# Connection.instance.rabbitmq_url = @rabbitmq_url
|
46
|
+
#
|
47
|
+
# unless @connection
|
48
|
+
# @connection = Connection.instance.connection
|
49
|
+
# @connection.start unless @connection.open?
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# @connection
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# def channel
|
56
|
+
# Connection.instance.connection_name = @connection_name
|
57
|
+
# Connection.instance.verify_peer = @verify_peer
|
58
|
+
# Connection.instance.rabbitmq_url = @rabbitmq_url
|
59
|
+
#
|
60
|
+
# @channel = Connection.instance.channel
|
61
|
+
# end
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
data/lib/data_collector/input.rb
CHANGED
@@ -140,6 +140,11 @@ module DataCollector
|
|
140
140
|
http_query_options[:body] = options[:body]
|
141
141
|
|
142
142
|
http_response = http.follow.post(escape_uri(uri), http_query_options)
|
143
|
+
elsif options.key?(:method) && options[:method].downcase.eql?('put')
|
144
|
+
raise DataCollector::InputError, "No body found, a PUT request needs a body" unless options.key?(:body)
|
145
|
+
http_query_options[:body] = options[:body]
|
146
|
+
|
147
|
+
http_response = http.follow.put(escape_uri(uri), http_query_options)
|
143
148
|
else
|
144
149
|
http_response = http.follow.get(escape_uri(uri), http_query_options)
|
145
150
|
end
|
@@ -172,7 +177,7 @@ module DataCollector
|
|
172
177
|
data = html_to_hash(data, options)
|
173
178
|
when 'text/turtle'
|
174
179
|
graph = RDF::Graph.new do |graph|
|
175
|
-
RDF::Turtle::Reader.new(data) {|reader| graph << reader}
|
180
|
+
RDF::Turtle::Reader.new(data) { |reader| graph << reader }
|
176
181
|
end
|
177
182
|
data = JSON.parse(graph.dump(:jsonld, validate: false, standard_prefixes: true))
|
178
183
|
when /^image/
|
@@ -238,9 +243,9 @@ module DataCollector
|
|
238
243
|
data << xml_to_hash(d, options)
|
239
244
|
end
|
240
245
|
end
|
241
|
-
end #block
|
242
|
-
end #entry
|
243
|
-
end #tar
|
246
|
+
end # block
|
247
|
+
end # entry
|
248
|
+
end # tar
|
244
249
|
when '.csv'
|
245
250
|
data = csv_to_hash(data, options)
|
246
251
|
when '.jpg', '.png', '.gif'
|
@@ -267,7 +272,7 @@ module DataCollector
|
|
267
272
|
|
268
273
|
def image_to_data(data, options = {})
|
269
274
|
file_type = options['file_type']
|
270
|
-
"data:#{file_type}
|
275
|
+
"data:#{file_type};base64,#{Base64.encode64(data)}"
|
271
276
|
end
|
272
277
|
|
273
278
|
def xml_to_hash(data, options = {})
|
@@ -290,7 +295,7 @@ module DataCollector
|
|
290
295
|
|
291
296
|
def csv_to_hash(data, options = {})
|
292
297
|
csv_option_keys = options.keys & CSV::DEFAULT_OPTIONS.keys
|
293
|
-
all_cvs_options = {headers: true, header_converters: [:downcase, :symbol]}
|
298
|
+
all_cvs_options = { headers: true, header_converters: [:downcase, :symbol] }
|
294
299
|
|
295
300
|
csv_option_keys.each do |k|
|
296
301
|
all_cvs_options[k] = options[k]
|
@@ -49,7 +49,8 @@ module DataCollector
|
|
49
49
|
if v.is_a?(Array) # merge with array
|
50
50
|
@data[k] = [@data[k]] + v
|
51
51
|
else
|
52
|
-
|
52
|
+
#@data[k] = [@data[k], v]
|
53
|
+
@data[k] = v
|
53
54
|
end
|
54
55
|
end
|
55
56
|
else
|
@@ -287,8 +288,8 @@ module DataCollector
|
|
287
288
|
end
|
288
289
|
|
289
290
|
def to_https(uri, options)
|
290
|
-
|
291
|
-
|
291
|
+
input = Input.new
|
292
|
+
input.from_uri(uri.to_s, options)
|
292
293
|
end
|
293
294
|
|
294
295
|
def to_file(uri, options)
|
@@ -22,8 +22,16 @@ module DataCollector
|
|
22
22
|
|
23
23
|
case rule
|
24
24
|
when Array
|
25
|
+
odata = {}
|
25
26
|
rule.each do |sub_rule|
|
26
|
-
apply_rule(tag, sub_rule, input_data, output_data, options)
|
27
|
+
d=apply_rule(tag, sub_rule, input_data, output_data, options)
|
28
|
+
next if d.nil?
|
29
|
+
odata.merge!(d) {|k,v, n|
|
30
|
+
[v,n].flatten
|
31
|
+
}
|
32
|
+
end
|
33
|
+
odata.each do |k,v|
|
34
|
+
output_data.data[k] = v
|
27
35
|
end
|
28
36
|
return output_data
|
29
37
|
when String
|
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.45.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: 2024-01-
|
11
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|