data_collector 0.35.0 → 0.36.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b9d99a5bf660ca9feb5bea5dd13f12c2539dcb224d6689b7a1181af32d0ab20
4
- data.tar.gz: 84fa315a8e2fa932caf84cad75d9c86c643c8d3b1faa389b383125de23022630
3
+ metadata.gz: 649b618a7676b2153451b2bc3053726dd332ccc95a58ce0fe7115f4c9cc5a7eb
4
+ data.tar.gz: 625ca0e9da4e6b986d7ead973c80fc04a87a5539f0f7263efc672ee0f3ef7eb1
5
5
  SHA512:
6
- metadata.gz: 82cb1c183a2d7a8ea950a181f2ae9571720533b6defd378bc0cab91fc84d876c75fc71029cd1f46c993c0b004eee7ecf32635bff808cda4419b3236ea7206c42
7
- data.tar.gz: 3bf761a214120ed1d12aad599e8137ce9a9b2028c757a7e59117d0ac3300e307237160cfb359032d8506db8efc37aee3669604bba0cbac59b60b51e064fc79e8
6
+ metadata.gz: 2372b50b9fc9e6f5a17575c1755e169f0ddbaef44ed96847d8f5c87b28a3e30e46276cf47f6e506fe843a2293190b54fd556978ea175f937693abd4f83a637dd
7
+ data.tar.gz: 7a417a9ee3a70140a3601d20613159222f6c2d6d0d7feaa99c447c7e31306f14c6f08c50543cb8fda85315b5fe62abde202e2b3bda51ac421f6a517f7b6be740
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
 
@@ -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
- csv = CSV.parse(data, headers: true, header_converters: [:downcase, :symbol])
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
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module DataCollector
3
- VERSION = "0.35.0"
3
+ VERSION = "0.36.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.35.0
4
+ version: 0.36.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-13 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport