bumblebee 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +16 -7
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +24 -9
- data/README.md +78 -9
- data/bumblebee.gemspec +3 -1
- data/lib/bumblebee/column.rb +6 -12
- data/lib/bumblebee/version.rb +1 -1
- data/spec/bumblebee/bumblebee_spec.rb +76 -29
- data/spec/bumblebee/column_spec.rb +34 -8
- data/spec/fixtures/custom_readme_example.csv +4 -0
- data/spec/{bumblebee/fixtures → fixtures}/simple_readme_example.csv +0 -0
- data/spec/spec_helper.rb +21 -0
- metadata +37 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8295218b496c6f59aae9de01d637270c3d975f59d60b8c82b33ce8e8b7e6f8c
|
4
|
+
data.tar.gz: 25eb49fed0dc2c3fcaabf3450a118e45e7cd08bfe481377b9bfa5f4f0c29ba3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ae9820932be10273e929b55cb04f16264e765988438539315e0d7259b125dda7691e22dfff8810b46518e6dd254c7177fd00f97bfd61e5a7961ce02991f15b4
|
7
|
+
data.tar.gz: aeaad7ac5781a2f3eee96187a0c9e08516a304133cb1253a542539cb553f12c486dbcf0fad4c739f91d088467ef9c555f4baf4e5bfa268012fca4a35011d1ace
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.0
|
data/.travis.yml
CHANGED
@@ -1,11 +1,20 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=a14b1cf423f3f72a1d6aaceff4959c25793586e8ec14695d5f378864b75d705d
|
1
4
|
language: ruby
|
2
5
|
rvm:
|
3
|
-
# Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
|
4
|
-
- 2.3.8
|
5
|
-
- 2.4.5
|
6
|
-
- 2.5.3
|
7
|
-
- 2.6.0
|
6
|
+
# Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
|
7
|
+
- 2.3.8
|
8
|
+
- 2.4.5
|
9
|
+
- 2.5.3
|
10
|
+
- 2.6.0
|
8
11
|
cache: bundler
|
12
|
+
before_script:
|
13
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
+
- chmod +x ./cc-test-reporter
|
15
|
+
- ./cc-test-reporter before-build
|
9
16
|
script:
|
10
|
-
- bundle exec rubocop
|
11
|
-
- bundle exec rspec
|
17
|
+
- bundle exec rubocop
|
18
|
+
- bundle exec rspec
|
19
|
+
after_script:
|
20
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 2.0.0 (January 31, 2019)
|
2
|
+
|
3
|
+
* Upgraded Rubocop
|
4
|
+
* Updated README
|
5
|
+
* Hooked up CodeClimate / Test Coverage
|
6
|
+
* Changed internal implementation of Column#csv_to_object. This is a breaking change that reverse's the flow of assignment: When a column is parsed and value is extracted, it will iterate over the to_object values one by one, chaining the previous value with the next. Once it is complete, it assigns the value to the field.
|
7
|
+
|
1
8
|
# 1.2.1 (January 22, 2019)
|
2
9
|
|
3
10
|
* README enhancements.
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bumblebee (
|
4
|
+
bumblebee (2.0.0)
|
5
5
|
acts_as_hashable (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
acts_as_hashable (1.0.
|
10
|
+
acts_as_hashable (1.0.4)
|
11
|
+
ansi (1.5.0)
|
11
12
|
ast (2.4.0)
|
12
13
|
coderay (1.1.2)
|
13
14
|
diff-lcs (1.3)
|
15
|
+
docile (1.3.1)
|
14
16
|
ffi (1.9.25)
|
15
17
|
formatador (0.2.5)
|
16
18
|
guard (2.15.0)
|
@@ -27,7 +29,9 @@ GEM
|
|
27
29
|
guard (~> 2.1)
|
28
30
|
guard-compat (~> 1.1)
|
29
31
|
rspec (>= 2.99.0, < 4.0)
|
30
|
-
|
32
|
+
hirb (0.7.3)
|
33
|
+
jaro_winkler (1.5.2)
|
34
|
+
json (2.1.0)
|
31
35
|
listen (3.1.5)
|
32
36
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
33
37
|
rb-inotify (~> 0.9, >= 0.9.7)
|
@@ -38,8 +42,8 @@ GEM
|
|
38
42
|
notiffany (0.1.1)
|
39
43
|
nenv (~> 0.1)
|
40
44
|
shellany (~> 0.0)
|
41
|
-
parallel (1.
|
42
|
-
parser (2.
|
45
|
+
parallel (1.13.0)
|
46
|
+
parser (2.6.0.0)
|
43
47
|
ast (~> 2.4.0)
|
44
48
|
powerpack (0.1.2)
|
45
49
|
pry (0.12.2)
|
@@ -62,19 +66,28 @@ GEM
|
|
62
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
67
|
rspec-support (~> 3.8.0)
|
64
68
|
rspec-support (3.8.0)
|
65
|
-
rubocop (0.
|
69
|
+
rubocop (0.63.1)
|
66
70
|
jaro_winkler (~> 1.5.1)
|
67
71
|
parallel (~> 1.10)
|
68
72
|
parser (>= 2.5, != 2.5.1.1)
|
69
73
|
powerpack (~> 0.1)
|
70
74
|
rainbow (>= 2.2.2, < 4.0)
|
71
75
|
ruby-progressbar (~> 1.7)
|
72
|
-
unicode-display_width (~> 1.
|
76
|
+
unicode-display_width (~> 1.4.0)
|
73
77
|
ruby-progressbar (1.10.0)
|
74
78
|
ruby_dep (1.5.0)
|
75
79
|
shellany (0.0.1)
|
80
|
+
simplecov (0.16.1)
|
81
|
+
docile (~> 1.1)
|
82
|
+
json (>= 1.8, < 3)
|
83
|
+
simplecov-html (~> 0.10.0)
|
84
|
+
simplecov-console (0.4.2)
|
85
|
+
ansi
|
86
|
+
hirb
|
87
|
+
simplecov
|
88
|
+
simplecov-html (0.10.2)
|
76
89
|
thor (0.20.3)
|
77
|
-
unicode-display_width (1.4.
|
90
|
+
unicode-display_width (1.4.1)
|
78
91
|
|
79
92
|
PLATFORMS
|
80
93
|
ruby
|
@@ -83,7 +96,9 @@ DEPENDENCIES
|
|
83
96
|
bumblebee!
|
84
97
|
guard-rspec (~> 4.7)
|
85
98
|
rspec (~> 3.8)
|
86
|
-
rubocop (~> 0.
|
99
|
+
rubocop (~> 0.63.1)
|
100
|
+
simplecov (~> 0.16.1)
|
101
|
+
simplecov-console (~> 0.4.2)
|
87
102
|
|
88
103
|
BUNDLED WITH
|
89
104
|
1.17.2
|
data/README.md
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# Bumblebee
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/bluemarblepayroll/bumblebee.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/bumblebee)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/bumblebee.svg)](https://badge.fury.io/rb/bumblebee) [![Build Status](https://travis-ci.org/bluemarblepayroll/bumblebee.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/bumblebee) [![Maintainability](https://api.codeclimate.com/v1/badges/e56cf63628a6b12ad1aa/maintainability)](https://codeclimate.com/github/bluemarblepayroll/bumblebee/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/e56cf63628a6b12ad1aa/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/bumblebee/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
4
4
|
|
5
5
|
Higher level languages, such as Ruby, make interacting with CSV (Comma Separated Values) files trivial. Even so, this library provides a very simple object/CSV mapper that allows you to fully interact with CSV's in a declarative way. Locking in common patterns, even in higher level languages, is important in large codebases. Using a library, such as this, will help ensure standardization around CSV interaction.
|
6
6
|
|
7
|
-
However, there are situations where this level of abstraciton may not be appropriate. For example, this library is not meant to be extremely performant given large files and/or datasets. This library shines with CSV and/or data-sets of less than 100,000 records (approx).
|
8
|
-
|
9
7
|
## Installation
|
10
8
|
|
11
9
|
To install through Rubygems:
|
@@ -136,7 +134,7 @@ csv = Bumblebee.generate_csv(columns, objects)
|
|
136
134
|
|
137
135
|
The above columns config would work both ways, so if we received the CSV, we could parse it to an array of nested hashes. Unfortunately, for now, we cannot do better than an array of nested hashes.
|
138
136
|
|
139
|
-
### Custom Formatting
|
137
|
+
### Custom To CSV Formatting
|
140
138
|
|
141
139
|
You can also pass in functions that can do the value formatting. For example:
|
142
140
|
|
@@ -166,6 +164,77 @@ columns = [
|
|
166
164
|
|
167
165
|
would ensure the CSV has only upper-case `First Name` values.
|
168
166
|
|
167
|
+
### Custom To Object Formatting
|
168
|
+
|
169
|
+
You can also choose a custom method how the CSV's value is parsed just like you can customize how values are set for a CSV. This helps function as an intermediate extractor/formatter/converter, in theory, should be able to give you alot more custom control over the parsing.
|
170
|
+
|
171
|
+
A previous example above showed a custom nested object-to-csv flow. This time, let's go csv-to-object with this dataset:
|
172
|
+
|
173
|
+
ID # | First Name | Date of Birth | Phone #
|
174
|
+
---- | ---------- | ------------- | ------------
|
175
|
+
1 | Matt | 1901-02-03 | 555-555-5555
|
176
|
+
2 | Nick | 1921-09-03 | 444-444-4444
|
177
|
+
3 | Sam | 1932-12-12 | 333-333-3333
|
178
|
+
|
179
|
+
Using the following column config:
|
180
|
+
|
181
|
+
````ruby
|
182
|
+
columns = [
|
183
|
+
{
|
184
|
+
field: :id,
|
185
|
+
header: 'ID #',
|
186
|
+
to_object: ->(o) { o['ID #'].to_i }
|
187
|
+
},
|
188
|
+
{
|
189
|
+
field: :name,
|
190
|
+
header: 'First Name',
|
191
|
+
to_csv: %i[name first],
|
192
|
+
to_object: ->(o) { { first: o['First Name'] } }
|
193
|
+
},
|
194
|
+
{ field: :demo,
|
195
|
+
header: 'Date of Birth',
|
196
|
+
to_csv: %i[demo dob],
|
197
|
+
to_object: ->(o) { { dob: o['Date of Birth'] } }
|
198
|
+
},
|
199
|
+
{ field: :contact,
|
200
|
+
header: 'Phone #',
|
201
|
+
to_csv: %i[contact phone],
|
202
|
+
to_object: ->(o) { { phone: o['Phone #'] } }
|
203
|
+
}
|
204
|
+
]
|
205
|
+
````
|
206
|
+
|
207
|
+
Executing the following:
|
208
|
+
|
209
|
+
````ruby
|
210
|
+
objects = Bumblebee.parse_csv(columns, data)
|
211
|
+
````
|
212
|
+
|
213
|
+
Would give us the following:
|
214
|
+
|
215
|
+
````ruby
|
216
|
+
objects = [
|
217
|
+
{
|
218
|
+
id: 1,
|
219
|
+
name: { first: 'Matt' },
|
220
|
+
demo: { dob: '1901-02-03' },
|
221
|
+
contact: { phone: '555-555-5555' }
|
222
|
+
},
|
223
|
+
{
|
224
|
+
id: 2,
|
225
|
+
name: { first: 'Nick' },
|
226
|
+
demo: { dob: '1921-09-03' },
|
227
|
+
contact: { phone: '444-444-4444' }
|
228
|
+
},
|
229
|
+
{
|
230
|
+
id: 3,
|
231
|
+
name: { first: 'Sam' },
|
232
|
+
demo: { dob: '1932-12-12' },
|
233
|
+
contact: { phone: '333-333-3333' }
|
234
|
+
}
|
235
|
+
]
|
236
|
+
````
|
237
|
+
|
169
238
|
#### Further CSV Customization
|
170
239
|
|
171
240
|
The two main methods:
|
@@ -214,12 +283,12 @@ Note: ensure you have proper authorization before trying to publish new versions
|
|
214
283
|
After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
|
215
284
|
|
216
285
|
1. Merge Pull Request into master
|
217
|
-
2. Update
|
218
|
-
3.
|
219
|
-
4. Update CHANGELOG.md
|
220
|
-
5. Commit &
|
286
|
+
2. Update ```lib/bumblebee/version.rb``` using [semantic versioning](https://semver.org/)
|
287
|
+
3. Install dependencies: ```bundle```
|
288
|
+
4. Update ```CHANGELOG.md``` with release notes
|
289
|
+
5. Commit & push master to remote and ensure CI builds master successfully
|
221
290
|
6. Build the project locally: `gem build bumblebee`
|
222
|
-
7. Publish package to
|
291
|
+
7. Publish package to RubyGems: `gem push bumblebee-X.gem` where X is the version to push
|
223
292
|
8. Tag master with new version: `git tag <version>`
|
224
293
|
9. Push tags remotely: `git push origin --tags`
|
225
294
|
|
data/bumblebee.gemspec
CHANGED
@@ -26,5 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_development_dependency('guard-rspec', '~>4.7')
|
28
28
|
s.add_development_dependency('rspec', '~> 3.8')
|
29
|
-
s.add_development_dependency('rubocop', '~>
|
29
|
+
s.add_development_dependency('rubocop', '~>0.63.1')
|
30
|
+
s.add_development_dependency('simplecov', '~>0.16.1')
|
31
|
+
s.add_development_dependency('simplecov-console', '~>0.4.2')
|
30
32
|
end
|
data/lib/bumblebee/column.rb
CHANGED
@@ -24,7 +24,7 @@ module Bumblebee
|
|
24
24
|
@field = field
|
25
25
|
@header = make_header(header || field)
|
26
26
|
@to_csv = Array(to_csv || field)
|
27
|
-
@to_object = Array(to_object ||
|
27
|
+
@to_object = Array(to_object || @header)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Take a object and convert to a value.
|
@@ -45,20 +45,14 @@ module Bumblebee
|
|
45
45
|
def csv_to_object(csv_hash)
|
46
46
|
return nil unless csv_hash
|
47
47
|
|
48
|
-
value
|
49
|
-
pointer = hash = {}
|
48
|
+
value = csv_hash
|
50
49
|
|
51
|
-
to_object
|
52
|
-
|
53
|
-
value = f.call(value)
|
54
|
-
else
|
55
|
-
pointer = pointer[f] = {}
|
56
|
-
end
|
50
|
+
to_object.each do |f|
|
51
|
+
value = single_extract(value, f)
|
57
52
|
end
|
58
53
|
|
59
|
-
|
60
|
-
|
61
|
-
hash
|
54
|
+
hash = {}
|
55
|
+
hash.tap { hash[field] = value }
|
62
56
|
end
|
63
57
|
|
64
58
|
private
|
data/lib/bumblebee/version.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
#
|
9
9
|
|
10
10
|
require './spec/spec_helper'
|
11
|
-
require 'stringio'
|
12
11
|
|
13
12
|
describe ::Bumblebee do
|
14
13
|
let(:columns) do
|
@@ -65,36 +64,84 @@ describe ::Bumblebee do
|
|
65
64
|
end
|
66
65
|
|
67
66
|
describe 'README examples' do
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
67
|
+
describe 'the simple 1:1 parsing example' do
|
68
|
+
let(:data) { fixture('simple_readme_example.csv') }
|
69
|
+
|
70
|
+
let(:columns) do
|
71
|
+
[
|
72
|
+
{ field: 'id' },
|
73
|
+
{ field: 'name' },
|
74
|
+
{ field: 'dob' },
|
75
|
+
{ field: 'phone' }
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
let(:output) do
|
80
|
+
[
|
81
|
+
{ 'id' => '1', 'name' => 'Matt', 'dob' => '2/3/01', 'phone' => '555-555-5555' },
|
82
|
+
{ 'id' => '2', 'name' => 'Nick', 'dob' => '9/3/21', 'phone' => '444-444-4444' },
|
83
|
+
{ 'id' => '3', 'name' => 'Sam', 'dob' => '12/12/32', 'phone' => '333-333-3333' }
|
84
|
+
]
|
85
|
+
end
|
86
|
+
|
87
|
+
specify 'works as advertised' do
|
88
|
+
expect(Bumblebee.parse_csv(columns, data)).to eq output
|
89
|
+
end
|
75
90
|
end
|
76
91
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
92
|
+
describe 'the custom parsing example' do
|
93
|
+
let(:data) { fixture('custom_readme_example.csv') }
|
94
|
+
|
95
|
+
let(:columns) do
|
96
|
+
[
|
97
|
+
{
|
98
|
+
field: :id,
|
99
|
+
header: 'ID #',
|
100
|
+
to_object: ->(o) { o['ID #'].to_i }
|
101
|
+
},
|
102
|
+
{
|
103
|
+
field: :name,
|
104
|
+
header: 'First Name',
|
105
|
+
to_csv: %i[name first],
|
106
|
+
to_object: ->(o) { { first: o['First Name'] } }
|
107
|
+
},
|
108
|
+
{ field: :demo,
|
109
|
+
header: 'Date of Birth',
|
110
|
+
to_csv: %i[demo dob],
|
111
|
+
to_object: ->(o) { { dob: o['Date of Birth'] } } },
|
112
|
+
{ field: :contact,
|
113
|
+
header: 'Phone #',
|
114
|
+
to_csv: %i[contact phone],
|
115
|
+
to_object: ->(o) { { phone: o['Phone #'] } } }
|
116
|
+
]
|
117
|
+
end
|
118
|
+
|
119
|
+
let(:output) do
|
120
|
+
[
|
121
|
+
{
|
122
|
+
id: 1,
|
123
|
+
name: { first: 'Matt' },
|
124
|
+
demo: { dob: '1901-02-03' },
|
125
|
+
contact: { phone: '555-555-5555' }
|
126
|
+
},
|
127
|
+
{
|
128
|
+
id: 2,
|
129
|
+
name: { first: 'Nick' },
|
130
|
+
demo: { dob: '1921-09-03' },
|
131
|
+
contact: { phone: '444-444-4444' }
|
132
|
+
},
|
133
|
+
{
|
134
|
+
id: 3,
|
135
|
+
name: { first: 'Sam' },
|
136
|
+
demo: { dob: '1932-12-12' },
|
137
|
+
contact: { phone: '333-333-3333' }
|
138
|
+
}
|
139
|
+
]
|
140
|
+
end
|
141
|
+
|
142
|
+
specify 'works as advertised' do
|
143
|
+
expect(Bumblebee.parse_csv(columns, data)).to eq output
|
144
|
+
end
|
98
145
|
end
|
99
146
|
end
|
100
147
|
end
|
@@ -24,7 +24,7 @@ describe ::Bumblebee::Column do
|
|
24
24
|
name: 'Mattycakes',
|
25
25
|
dob: '1921-01-02',
|
26
26
|
pizza: 'Pepperoni',
|
27
|
-
license:
|
27
|
+
license: { id: '123456' }
|
28
28
|
}
|
29
29
|
end
|
30
30
|
|
@@ -41,7 +41,7 @@ describe ::Bumblebee::Column do
|
|
41
41
|
expect(column.field).to eq(field)
|
42
42
|
expect(column.header).to eq(field.to_s)
|
43
43
|
expect(column.to_csv).to eq([field])
|
44
|
-
expect(column.to_object).to eq([field])
|
44
|
+
expect(column.to_object).to eq([field.to_s])
|
45
45
|
end
|
46
46
|
|
47
47
|
describe 'header computation' do
|
@@ -98,23 +98,49 @@ describe ::Bumblebee::Column do
|
|
98
98
|
expect(column.csv_to_object(csv_row)).to eq(record)
|
99
99
|
end
|
100
100
|
|
101
|
-
it 'should correctly extract the value using custom
|
101
|
+
it 'should correctly extract the value using custom to_object value' do
|
102
102
|
csv_row = {
|
103
|
-
'First
|
103
|
+
'First' => 'Nathan'
|
104
104
|
}
|
105
105
|
|
106
106
|
record = {
|
107
|
-
'
|
107
|
+
'name' => 'Nathan'
|
108
108
|
}
|
109
109
|
|
110
110
|
column = ::Bumblebee::Column.new(
|
111
|
-
field:
|
112
|
-
header:
|
113
|
-
to_object:
|
111
|
+
field: 'name',
|
112
|
+
header: 'First Name',
|
113
|
+
to_object: 'First'
|
114
114
|
)
|
115
115
|
|
116
116
|
expect(column.csv_to_object(csv_row)).to eq(record)
|
117
117
|
end
|
118
|
+
|
119
|
+
it 'should correctly extract the value using to_object with a proc' do
|
120
|
+
record = {
|
121
|
+
'name' => 'Nathan'
|
122
|
+
}
|
123
|
+
|
124
|
+
column = ::Bumblebee::Column.new(field: 'name', to_object: ->(o) { o['name'] })
|
125
|
+
|
126
|
+
expect(column.csv_to_object(record)).to eq(record)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should correctly build up a nested hash' do
|
130
|
+
record = {
|
131
|
+
'name' => 'Nathan'
|
132
|
+
}
|
133
|
+
|
134
|
+
column = ::Bumblebee::Column.new(
|
135
|
+
field: :person,
|
136
|
+
to_object: [
|
137
|
+
'name',
|
138
|
+
->(o) { { first: o } }
|
139
|
+
]
|
140
|
+
)
|
141
|
+
|
142
|
+
expect(column.csv_to_object(record)).to eq(person: { first: record['name'] })
|
143
|
+
end
|
118
144
|
end
|
119
145
|
|
120
146
|
describe '#object_to_csv' do
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -7,4 +7,25 @@
|
|
7
7
|
# LICENSE file in the root directory of this source tree.
|
8
8
|
#
|
9
9
|
|
10
|
+
require 'stringio'
|
11
|
+
|
12
|
+
require 'simplecov'
|
13
|
+
require 'simplecov-console'
|
14
|
+
SimpleCov.formatter = SimpleCov::Formatter::Console
|
15
|
+
SimpleCov.start
|
16
|
+
|
10
17
|
require './lib/bumblebee'
|
18
|
+
|
19
|
+
def fixture_path(filename)
|
20
|
+
File.join('spec', 'fixtures', filename)
|
21
|
+
end
|
22
|
+
|
23
|
+
def fixture(filename)
|
24
|
+
# Excel adds a Byte Order Mark to the beginning of the file. Let Ruby
|
25
|
+
# know about this so that the first 'id' column is correctly parsed.
|
26
|
+
# More info about the Excel Byte Order Mark and Ruby is available at:
|
27
|
+
# https://estl.tech/of-ruby-and-hidden-csv-characters-ef482c679b35 .
|
28
|
+
file = File.open(fixture_path(filename), 'r:bom|utf-8')
|
29
|
+
|
30
|
+
file.read
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumblebee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -58,14 +58,42 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.63.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.63.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.16.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.16.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov-console
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.4.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.4.2
|
69
97
|
description: |2
|
70
98
|
Higher level languages, such as Ruby, make interacting with CSVs trivial.
|
71
99
|
Even so, this library provides a very simple object/csv mapper that allows you to fully interact with CSVs in a declarative way.
|
@@ -79,6 +107,7 @@ files:
|
|
79
107
|
- ".editorconfig"
|
80
108
|
- ".gitignore"
|
81
109
|
- ".rubocop.yml"
|
110
|
+
- ".ruby-version"
|
82
111
|
- ".travis.yml"
|
83
112
|
- CHANGELOG.md
|
84
113
|
- Gemfile
|
@@ -95,7 +124,8 @@ files:
|
|
95
124
|
- lib/bumblebee/version.rb
|
96
125
|
- spec/bumblebee/bumblebee_spec.rb
|
97
126
|
- spec/bumblebee/column_spec.rb
|
98
|
-
- spec/
|
127
|
+
- spec/fixtures/custom_readme_example.csv
|
128
|
+
- spec/fixtures/simple_readme_example.csv
|
99
129
|
- spec/spec_helper.rb
|
100
130
|
homepage: https://github.com/bluemarblepayroll/bumblebee
|
101
131
|
licenses:
|
@@ -123,5 +153,6 @@ summary: Object/CSV Mapper
|
|
123
153
|
test_files:
|
124
154
|
- spec/bumblebee/bumblebee_spec.rb
|
125
155
|
- spec/bumblebee/column_spec.rb
|
126
|
-
- spec/
|
156
|
+
- spec/fixtures/custom_readme_example.csv
|
157
|
+
- spec/fixtures/simple_readme_example.csv
|
127
158
|
- spec/spec_helper.rb
|