csv_model 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -0
- data/lib/csv_model/header_row.rb +2 -2
- data/lib/csv_model/version.rb +1 -1
- data/spec/csv_model/header_row_spec.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2c3dcb21cddf9d14f4d44336770c35d737c4165
|
4
|
+
data.tar.gz: 96510b317ed2ec88d19ad86a51ee15c1b1c5c8ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 565a7e1407cdcbbedcea280b6cf1cc63e050954275fd87b9c45e6b4073b69463aefc49baa77df3809f134259a69164ca6c95415e877fd8c40e4ed6e1e89a3de9
|
7
|
+
data.tar.gz: 90f26d172765c9b1e28f49cd85045f753c896b41d6ca77fc4fe47e9b9bbe5aa5ba5f0e41cd4225c778eec950eb6df5e4f11af60f1e66fc088e39fd930d82c970
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/csv_model/header_row.rb
CHANGED
@@ -25,7 +25,7 @@ module CSVModel
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def errors
|
28
|
-
duplicate_column_errors + illegal_column_errors + missing_column_errors + missing_key_column_errors
|
28
|
+
(duplicate_column_errors + illegal_column_errors + missing_column_errors + missing_key_column_errors).uniq
|
29
29
|
end
|
30
30
|
|
31
31
|
def has_column?(key)
|
@@ -170,7 +170,7 @@ module CSVModel
|
|
170
170
|
end
|
171
171
|
|
172
172
|
def primary_key_column_errors
|
173
|
-
missing_primary_key_column_names.collect { |name| "Missing
|
173
|
+
missing_primary_key_column_names.collect { |name| "Missing column #{name}" }
|
174
174
|
end
|
175
175
|
|
176
176
|
def primary_key_column_keys
|
data/lib/csv_model/version.rb
CHANGED
@@ -106,7 +106,12 @@ describe CSVModel::HeaderRow do
|
|
106
106
|
|
107
107
|
it "returns required column message when header is missing required primary key columns" do
|
108
108
|
subject = described_class.new(data, primary_key: ["Column Two"])
|
109
|
-
expect(subject.errors).to eq(["Missing
|
109
|
+
expect(subject.errors).to eq(["Missing column Column Two"])
|
110
|
+
end
|
111
|
+
|
112
|
+
it "returns single message when column is missing required and primary key" do
|
113
|
+
subject = described_class.new(data, primary_key: ["Column Two"], required_columns: ["Column Two"])
|
114
|
+
expect(subject.errors).to eq(["Missing column Column Two"])
|
110
115
|
end
|
111
116
|
|
112
117
|
it "returns empty array when header is missing required primary key column but alternate is available" do
|
@@ -116,7 +121,7 @@ describe CSVModel::HeaderRow do
|
|
116
121
|
|
117
122
|
it "returns required column message when header is missing required primary key and alternate is not available " do
|
118
123
|
subject = described_class.new(data, primary_key: ["Column Two"], alternate_primary_key: ["Column Three"])
|
119
|
-
expect(subject.errors).to eq(["Missing
|
124
|
+
expect(subject.errors).to eq(["Missing column Column Two"])
|
120
125
|
end
|
121
126
|
end
|
122
127
|
|