csv-diff 0.6.0 → 0.6.1

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
  SHA1:
3
- metadata.gz: 9dde7ded89bb58f75505ae9237c97b8acd365c42
4
- data.tar.gz: adcf17af6b67797c9b5fbab80b6c7d421cd73d6e
3
+ metadata.gz: 87807b9af487947c60d18ac81d38b6782133dfdb
4
+ data.tar.gz: 3681d305dc566f49e7b5166fd22f5ea858f1260f
5
5
  SHA512:
6
- metadata.gz: 1aad2d1174758488d1e984239ae38917211bf1e185d2b37350a402e145bde652b44e437774f2695bb33c2b48531637f6c9ed13fb5fbaa0b610ac9d7810ec16ed
7
- data.tar.gz: 3aab02344cfa4f111433c616caa445f43d3f4515c65e8ef7175f2287996d8f6bc592e1daca5683bef5d561e21f6f23e954a1115854577cced4551582ec4fa293
6
+ metadata.gz: d4b617cae1c1e2201633ba5bdb2752aa16af6e293ac32c75b812502c11e54f8d930b965d7e86a81fd5592b1a469db2498a71b635fd563d576039a4808b6dd776
7
+ data.tar.gz: a6561a7c91e8e4cb8ef8487032fd8bd46794bc79854dca274d7134e251741395f049c2e5c8ca603e257310a961788d6c1472fdc9bf82a171b099f869c59cefcf
@@ -45,7 +45,7 @@ class CSVDiff
45
45
  when :sibling_position
46
46
  @sibling_position
47
47
  else
48
- @fields[key]
48
+ @fields[key] || @fields[key.to_s.intern] || @fields[key.to_s]
49
49
  end
50
50
  end
51
51
 
@@ -115,7 +115,7 @@ class CSVDiff
115
115
  @trim_whitespace = options.fetch(:trim_whitespace, false)
116
116
  @ignore_header = options[:ignore_header]
117
117
  @include = options[:include]
118
- @exclued = options[:exclude]
118
+ @exclude = options[:exclude]
119
119
  @path = options.fetch(:path, 'NA') unless @path
120
120
  @warnings = []
121
121
  end
@@ -214,6 +214,17 @@ class CSVDiff
214
214
  @data.each{ |rec| csv << rec }
215
215
  end
216
216
  end
217
+
218
+
219
+ # Convert the data in this source to Array<Hash> using the field names
220
+ # as keys for the Hash in each row.
221
+ def to_hash
222
+ @data.map do |row|
223
+ hsh = {}
224
+ @field_names.each_with_index.map{ |fld, i| hsh[fld] = row[i] }
225
+ hsh
226
+ end
227
+ end
217
228
 
218
229
 
219
230
  private
@@ -11,8 +11,8 @@ class CSVDiff
11
11
  attr_accessor :context
12
12
 
13
13
  # Create a new XMLSource, identified by +path+. Normally this is a path
14
- # to the XML document, but any value is fine, as it isreally just a label
15
- # to identify this data set.
14
+ # to the XML document, but any value is fine, as it is just a label to
15
+ # identify this data set.
16
16
  #
17
17
  # @param path [String] A label for this data set (often a path to the
18
18
  # XML document used as the source).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Gardiner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-28 00:00:00.000000000 Z
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  This library performs diffs of CSV data, or any table-like source.