data_collector 0.35.0 → 0.38.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/README.md +7 -0
- data/data_collector.gemspec +2 -0
- data/lib/data_collector/ext/base.rb +58 -0
- data/lib/data_collector/input/generic.rb +3 -0
- data/lib/data_collector/input/rpc.rb +1 -5
- data/lib/data_collector/input.rb +11 -4
- data/lib/data_collector/output/generic.rb +2 -0
- data/lib/data_collector/output/rpc.rb +4 -2
- data/lib/data_collector/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c584cb29547a8e6e2caf026d8860228366e2cae387ac4111c125e5450a90586
|
4
|
+
data.tar.gz: ea87c6fec5817023b653472f6566bf48e951755e16b8e5ab08378c4600ca01fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6b8fbe6975c800cd2ca179d6cc97555aa6b2cfa279d223f9cb52c03fa48186e336f6129701b820630eba912901c7d4b2a60f58678f282742cba36f4b46e0b3c
|
7
|
+
data.tar.gz: f08929aea4bb836e55a8ac0203cf14048ccfe1c60d1ed7af871625938877c0b2f38619cf2923da48bac9e002fa9dd37967639713390f0bc4c011dcd54f7eb50d
|
data/README.md
CHANGED
@@ -403,6 +403,13 @@ Should give as output
|
|
403
403
|
</data>
|
404
404
|
```
|
405
405
|
|
406
|
+
You can provide options to input.from_uri for better reading CSV formats these
|
407
|
+
are the same the Ruby [CSV](https://docs.ruby-lang.org/en/master/CSV.html#class-CSV-label-Options) class
|
408
|
+
|
409
|
+
Loading a CSV file with **;** as the row seperator
|
410
|
+
```ruby
|
411
|
+
i = input.from_uri('https://support.staffbase.com/hc/en-us/article_attachments/360009197031/username.csv', col_sep: ';')
|
412
|
+
```
|
406
413
|
|
407
414
|
## Installation
|
408
415
|
|
data/data_collector.gemspec
CHANGED
@@ -51,6 +51,8 @@ Gem::Specification.new do |spec|
|
|
51
51
|
spec.add_runtime_dependency 'builder', '~> 3.2'
|
52
52
|
spec.add_runtime_dependency 'parse-cron', '~> 0.1'
|
53
53
|
spec.add_runtime_dependency 'linkeddata', '~> 3.3'
|
54
|
+
spec.add_runtime_dependency 'connection_pool', '~> 2.4'
|
55
|
+
|
54
56
|
|
55
57
|
spec.add_development_dependency 'bundler', '~> 2.3'
|
56
58
|
spec.add_development_dependency 'minitest', '~> 5.18'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'connection_pool'
|
2
|
+
|
3
|
+
module BunnyBurrow
|
4
|
+
class Connection
|
5
|
+
include Singleton
|
6
|
+
attr_reader :connection, :started
|
7
|
+
attr_accessor :verify_peer, :name, :rabbitmq_url
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super
|
11
|
+
@started = false
|
12
|
+
end
|
13
|
+
def connection
|
14
|
+
@connection ||= Bunny.new(@rabbitmq_url, verify_peer: @verify_peer, connection_name: @name)
|
15
|
+
unless @started
|
16
|
+
@connection.start
|
17
|
+
@started = true
|
18
|
+
end
|
19
|
+
|
20
|
+
@connection
|
21
|
+
end
|
22
|
+
|
23
|
+
def channel
|
24
|
+
@channel ||= ConnectionPool::Wrapper.new do
|
25
|
+
connection.create_channel
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Base
|
31
|
+
attr_accessor(
|
32
|
+
:name
|
33
|
+
)
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def connection
|
38
|
+
Connection.instance.name = @name
|
39
|
+
Connection.instance.verify_peer = @verify_peer
|
40
|
+
Connection.instance.rabbitmq_url = @rabbitmq_url
|
41
|
+
|
42
|
+
unless @connection
|
43
|
+
@connection = Connection.instance.connection
|
44
|
+
end
|
45
|
+
|
46
|
+
@connection
|
47
|
+
end
|
48
|
+
|
49
|
+
def channel
|
50
|
+
Connection.instance.name = @name
|
51
|
+
Connection.instance.verify_peer = @verify_peer
|
52
|
+
Connection.instance.rabbitmq_url = @rabbitmq_url
|
53
|
+
|
54
|
+
@channel ||= Connection.instance.channel
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -1,9 +1,4 @@
|
|
1
1
|
require_relative 'generic'
|
2
|
-
require 'bunny_burrow'
|
3
|
-
require 'active_support/core_ext/hash'
|
4
|
-
require 'ostruct'
|
5
|
-
require 'securerandom'
|
6
|
-
require 'thread'
|
7
2
|
|
8
3
|
module DataCollector
|
9
4
|
class Input
|
@@ -64,6 +59,7 @@ module DataCollector
|
|
64
59
|
server.rabbitmq_url = @bunny_uri.to_s
|
65
60
|
server.rabbitmq_exchange = @bunny_channel
|
66
61
|
|
62
|
+
#server.connection_name = @name
|
67
63
|
server.logger = DataCollector::Core.logger if log
|
68
64
|
end
|
69
65
|
|
data/lib/data_collector/input.rb
CHANGED
@@ -161,7 +161,7 @@ module DataCollector
|
|
161
161
|
when 'application/atom+xml'
|
162
162
|
data = xml_to_hash(data, options)
|
163
163
|
when 'text/csv'
|
164
|
-
data = csv_to_hash(data)
|
164
|
+
data = csv_to_hash(data, options)
|
165
165
|
when 'application/xml'
|
166
166
|
data = xml_to_hash(data, options)
|
167
167
|
when 'text/xml'
|
@@ -231,7 +231,7 @@ module DataCollector
|
|
231
231
|
end #entry
|
232
232
|
end #tar
|
233
233
|
when '.csv'
|
234
|
-
data = csv_to_hash(data)
|
234
|
+
data = csv_to_hash(data, options)
|
235
235
|
else
|
236
236
|
raise "Do not know how to process #{uri.to_s}"
|
237
237
|
end
|
@@ -264,8 +264,15 @@ module DataCollector
|
|
264
264
|
nori.parse(data)
|
265
265
|
end
|
266
266
|
|
267
|
-
def csv_to_hash(data)
|
268
|
-
|
267
|
+
def csv_to_hash(data, options = {})
|
268
|
+
csv_option_keys = options.keys & CSV::DEFAULT_OPTIONS.keys
|
269
|
+
all_cvs_options = {headers: true, header_converters: [:downcase, :symbol]}
|
270
|
+
|
271
|
+
csv_option_keys.each do |k|
|
272
|
+
all_cvs_options[k] = options[k]
|
273
|
+
end
|
274
|
+
|
275
|
+
csv = CSV.parse(data, **all_cvs_options)
|
269
276
|
|
270
277
|
csv.collect do |record|
|
271
278
|
record.to_hash
|
@@ -20,12 +20,14 @@ module DataCollector
|
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
|
-
def create_producer
|
23
|
+
def create_producer(log = false)
|
24
24
|
@producer ||= BunnyBurrow::Client.new do |client|
|
25
25
|
parse_uri
|
26
26
|
client.rabbitmq_url = @bunny_uri.to_s
|
27
27
|
client.rabbitmq_exchange = @bunny_channel
|
28
|
-
client.
|
28
|
+
#client.connection_name = @name
|
29
|
+
|
30
|
+
client.logger = DataCollector::Core.logger if log
|
29
31
|
@running = true
|
30
32
|
end
|
31
33
|
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.38.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: 2023-11-
|
11
|
+
date: 2023-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -220,6 +220,20 @@ dependencies:
|
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '3.3'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: connection_pool
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - "~>"
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '2.4'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '2.4'
|
223
237
|
- !ruby/object:Gem::Dependency
|
224
238
|
name: bundler
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -296,6 +310,7 @@ files:
|
|
296
310
|
- lib/data_collector.rb
|
297
311
|
- lib/data_collector/config_file.rb
|
298
312
|
- lib/data_collector/core.rb
|
313
|
+
- lib/data_collector/ext/base.rb
|
299
314
|
- lib/data_collector/ext/xml_utility_node.rb
|
300
315
|
- lib/data_collector/input.rb
|
301
316
|
- lib/data_collector/input/dir.rb
|