csv2hash 0.7.0 → 0.7.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: d0017cb5da55df2b12a7a2a859cb6735dcfe2e17
4
- data.tar.gz: a720666766679ea852bd1337f6d0795073d30f3f
3
+ metadata.gz: 78efc416ea706262ed45cd1732953a91ab59c3ac
4
+ data.tar.gz: 045440b7c850178eedeb7e0d54c8797a374a7aea
5
5
  SHA512:
6
- metadata.gz: 686218a873857c290b1352f83313031cc29bfb6fb23871eb83c2d3f2b520a59d654c0bc30be9141ea43f83816bc36828b7a44fca86a7e071541dab7186ff6cab
7
- data.tar.gz: 7d77cc8c42c5facd840c4b8aa34bb9c140822f0947ab54bb229c1866e98993eb9e0b48cc8b6242451538ef8bd27e239c06cf0447b1b77195c3306b786038aff5
6
+ metadata.gz: 9db537dbfddb6ef012bd23acdfb2faedb15c20b4471cb66457d0156d15773991a828c875f5d17f0232fe79e178b009e9eba7f48f879dd8497a6881a0c3c8d507
7
+ data.tar.gz: 33a571b8d8e0217abf628c73c83c6b6264705d0407b5bd0d217410c836a711f330af66f256321141ef6a5007355e4263fdf139d7c42b13b8a37107464eacf36f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ### VERSION 0.7.1
2
+
3
+ * enhancements
4
+ * update yaml coercer to deserialize string position to regex
5
+
6
+ * [fullchanges](https://github.com/FinalCAD/csv2hash/pull/21)
7
+
8
+ * [Author Ale Paredes](https://github.com/ale7714)
9
+
1
10
  ### VERSION 0.7.0
2
11
 
3
12
  * feature
@@ -5,6 +14,8 @@
5
14
 
6
15
  * [fullchanges](https://github.com/FinalCAD/csv2hash/pull/20)
7
16
 
17
+ * [Author Ale Paredes](https://github.com/ale7714)
18
+
8
19
  ### VERSION 0.6.8
9
20
 
10
21
  * bug fix
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- csv2hash (0.7.0)
4
+ csv2hash (0.7.1)
5
5
  activesupport (~> 4.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -243,7 +243,6 @@ became
243
243
  cell position: [[0, /Employment/],1], key: 'employment'
244
244
  ```
245
245
 
246
-
247
246
  ### [COLLECTION] Validation of a collection (Regular CSV)
248
247
 
249
248
  Consider the following CSV:
@@ -304,7 +303,7 @@ This is a special feature for finding a specific column index on header. For exa
304
303
  | | |
305
304
  ```
306
305
 
307
- You want to extract `Name` and 'Age' for all rows but you want the order of the columns to be able to change.
306
+ You want to extract `Name` and `Age` for all rows but you want the order of the columns to be able to change.
308
307
  You change the position to the regex of column index you are looking for. So this how the position
309
308
 
310
309
  ```
data/UPGRADE.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Upgrading
2
2
 
3
+ # Upgrading from 0.7.0 to 0.7.1
4
+
5
+ nothing
6
+
3
7
  # Upgrading from 0.6.8 to 0.7.0
4
8
 
5
9
  nothing
@@ -24,6 +24,8 @@ module Csv2hash
24
24
  if y.is_a?(Array)
25
25
  column, matcher_string = y
26
26
  self.rules[:position] = [[column, Regexp.new(matcher_string)],x]
27
+ elsif y.is_a?(String)
28
+ self.rules[:position] = Regexp.new("\\A(#{y})\\z")
27
29
  end
28
30
  end
29
31
 
@@ -1,3 +1,3 @@
1
1
  module Csv2hash
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -26,7 +26,6 @@ module Csv2hash
26
26
  set_header_size { header_size }
27
27
  set_structure_rules { structure_rules }
28
28
  end
29
-
30
29
  self.conf.fetch(:rules).each do |rule|
31
30
  definition.cells << Cell.new(rule)
32
31
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ module Csv2hash
4
+ module Coercers
5
+ describe YamlCoercer do
6
+ context 'when position is a string' do
7
+ let(:rules) { {:position=>"Mobile phone number", :key=>"mobile_phone", :allow_blank=>true} }
8
+ let(:result_rules) { {:position=>/\A(Mobile phone number)\z/, :key=>"mobile_phone", :allow_blank=>true} }
9
+ subject { YamlCoercer.new(rules) }
10
+
11
+ before { subject.deserialize! }
12
+
13
+ it{expect(subject.rules).to eql(result_rules)}
14
+ end
15
+
16
+ context 'when position is a array' do
17
+ let(:rules) { {:position=>[[1,"Mobile phone number"],2], :key=>"mobile_phone", :allow_blank=>true} }
18
+ let(:result_rules) { {:position=>[[1, /Mobile phone number/], 2], :key=>"mobile_phone", :allow_blank=>true} }
19
+ subject { YamlCoercer.new(rules) }
20
+
21
+ before { subject.deserialize! }
22
+
23
+ it{expect(subject.rules).to eql(result_rules)}
24
+ end
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv2hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel AZEMAR
@@ -155,6 +155,7 @@ files:
155
155
  - spec/csv2hash/validator/collection_spec.rb
156
156
  - spec/csv2hash/validator/mapping_spec.rb
157
157
  - spec/csv2hash/validator_spec.rb
158
+ - spec/csv2hash/yaml_coercer_spec.rb
158
159
  - spec/csv2hash/yaml_loader_spec.rb
159
160
  - spec/csv2hash_spec.rb
160
161
  - spec/generators_helper.rb
@@ -196,6 +197,7 @@ test_files:
196
197
  - spec/csv2hash/validator/collection_spec.rb
197
198
  - spec/csv2hash/validator/mapping_spec.rb
198
199
  - spec/csv2hash/validator_spec.rb
200
+ - spec/csv2hash/yaml_coercer_spec.rb
199
201
  - spec/csv2hash/yaml_loader_spec.rb
200
202
  - spec/csv2hash_spec.rb
201
203
  - spec/generators_helper.rb