bumblebee 3.1.0.pre.alpha → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/README.md +8 -8
- data/lib/bumblebee/mutator.rb +3 -11
- data/lib/bumblebee/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b778ae4e05a2d4d578f8fb3f98af32929d2b1a00f2289fefe29b4a3e7d41a353
|
|
4
|
+
data.tar.gz: f48433f936d8c11fba080224ba64df7b167717d24c72f1a8e92971ab603cb0fb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ba3577b2116ff8f9a27fa1275555f7c322d9ea26df18ee6518a4dfdfb993ade238cc5c92951b33f8468a16baacad88f407707cf81a0cf22fd9c2aae63364059
|
|
7
|
+
data.tar.gz: 6a10009dfa2ca2b0d2c4415ff4198469f1f5cb1b3460f66c390b785b8053435f2c38ec354d724584defbbc4f6361e089e9c10a698aff5101750e1d872205f1ff
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -46,13 +46,13 @@ Then `objects` is this array of hashes:
|
|
|
46
46
|
|
|
47
47
|
````ruby
|
|
48
48
|
[
|
|
49
|
-
{ id: '1', name: 'Matt', dob: '
|
|
50
|
-
{ id: '2', name: 'Nick', dob: '
|
|
51
|
-
{ id: '3', name: 'Sam', dob: '12
|
|
49
|
+
{ id: '1', name: 'Matt', dob: '1901-02-03', phone: '555-555-5555' },
|
|
50
|
+
{ id: '2', name: 'Nick', dob: '1921-09-03', phone: '444-444-4444' },
|
|
51
|
+
{ id: '3', name: 'Sam', dob: '1932-12-12', phone: '333-333-3333' }
|
|
52
52
|
]
|
|
53
53
|
````
|
|
54
54
|
|
|
55
|
-
*Note: Data, in this case, would be the
|
|
55
|
+
*Note: Data, in this case, would be the CSV file contents in string format.*
|
|
56
56
|
|
|
57
57
|
### Custom Headers
|
|
58
58
|
|
|
@@ -99,7 +99,7 @@ objects = [
|
|
|
99
99
|
demo: { dob: '1932-12-12' },
|
|
100
100
|
contact: { phone: '333-333-3333' }
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
}
|
|
103
103
|
````
|
|
104
104
|
|
|
105
105
|
We could create a flat-file CSV:
|
|
@@ -127,7 +127,7 @@ columns = {
|
|
|
127
127
|
property: :phone,
|
|
128
128
|
through: :contact
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
}
|
|
131
131
|
````
|
|
132
132
|
|
|
133
133
|
And executing the following:
|
|
@@ -136,7 +136,7 @@ And executing the following:
|
|
|
136
136
|
csv = Bumblebee::Template.new(columns: columns).generate(objects)
|
|
137
137
|
````
|
|
138
138
|
|
|
139
|
-
The above columns config would work both ways, so if we received the CSV, we could parse it to an array of nested hashes.
|
|
139
|
+
The above columns config would work both ways, so if we received the CSV, we could parse it to an array of nested hashes.
|
|
140
140
|
|
|
141
141
|
### Custom Formatting
|
|
142
142
|
|
|
@@ -278,7 +278,7 @@ objects = Bumblebee::Template.new(columns: columns, object_class: OpenStruct).pa
|
|
|
278
278
|
|
|
279
279
|
Objects will now be an array of OpenStruct objects instead of Hash objects.
|
|
280
280
|
|
|
281
|
-
*
|
|
281
|
+
*Note:* you must also specify this in pluck_split:
|
|
282
282
|
|
|
283
283
|
````ruby
|
|
284
284
|
columns = {
|
data/lib/bumblebee/mutator.rb
CHANGED
|
@@ -14,22 +14,14 @@ module Bumblebee
|
|
|
14
14
|
module Types
|
|
15
15
|
IGNORE = :ignore
|
|
16
16
|
end
|
|
17
|
-
include
|
|
17
|
+
include Types
|
|
18
18
|
|
|
19
19
|
attr_reader :converter, :type
|
|
20
20
|
|
|
21
21
|
def initialize(arg)
|
|
22
|
-
@type = nil
|
|
23
22
|
@resolver = Objectable.resolver
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@converter = NullConverter.new
|
|
27
|
-
elsif mutator?(arg)
|
|
28
|
-
@type = Mutator::Types.const_get(arg.to_s.upcase.to_sym)
|
|
29
|
-
@converter = NullConverter.new
|
|
30
|
-
else
|
|
31
|
-
@converter = SimpleConverter.new(arg)
|
|
32
|
-
end
|
|
23
|
+
@converter = arg.nil? || mutator?(arg) ? NullConverter.new : SimpleConverter.new(arg)
|
|
24
|
+
@type = mutator?(arg) ? Types.const_get(arg.to_s.upcase.to_sym) : nil
|
|
33
25
|
|
|
34
26
|
freeze
|
|
35
27
|
end
|
data/lib/bumblebee/version.rb
CHANGED
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: 3.1.0
|
|
4
|
+
version: 3.1.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-12-
|
|
11
|
+
date: 2019-12-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: acts_as_hashable
|
|
@@ -200,9 +200,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
200
200
|
version: 2.3.8
|
|
201
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
requirements:
|
|
203
|
-
- - "
|
|
203
|
+
- - ">="
|
|
204
204
|
- !ruby/object:Gem::Version
|
|
205
|
-
version:
|
|
205
|
+
version: '0'
|
|
206
206
|
requirements: []
|
|
207
207
|
rubygems_version: 3.0.3
|
|
208
208
|
signing_key:
|