table_structure 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +0 -2
- data/lib/table_structure/csv/writer.rb +2 -2
- data/lib/table_structure/version.rb +1 -1
- data/lib/table_structure/writer.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54e6d65c5123ccefa563ba83cfa9ef28fe25ee407224c0838afe17158afe5bbc
|
4
|
+
data.tar.gz: bb6cdd925323a59eb93d77c610a09b2136c6ee96e6cf618e2b0502171f2bdd4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c2c95aed368f8e5afa555e4fc335b96d69e4ec307626bd00bc57a71f1b15b0601074f80321d02652a38ae74ece1d548be6277722786b7ba1c431813d8716f2c
|
7
|
+
data.tar.gz: fcb0d97b7f2d92ce49fab996d5472272db653163eaade94ab08a165b70ab04a9c1a0ffc732783e6375ea8eed65708d2e010a09c28503d103ca9791112d1c8aaa
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.3.10
|
2
|
+
Changes:
|
3
|
+
- `TableStructure::Writer`
|
4
|
+
- Fix an issue that objects with both `call` and` each` methods could not be enumerated.
|
5
|
+
- `TableStructure::CSV::Writer`
|
6
|
+
- Fix write method's block to work.
|
7
|
+
|
1
8
|
# 0.3.9
|
2
9
|
Changes:
|
3
10
|
- Add `TableStructure::CSV::Writer`. This is a wrapper for `TableStructure::Writer`.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -99,8 +99,6 @@ items = [
|
|
99
99
|
|
100
100
|
## When using `find_each` method of Rails
|
101
101
|
# items = Enumerator.new { |y| Item.find_each { |item| y << item } }
|
102
|
-
## or
|
103
|
-
# items = ->(y) { Item.find_each { |item| y << item } }
|
104
102
|
|
105
103
|
table = []
|
106
104
|
writer.write(items, to: table)
|
@@ -22,10 +22,10 @@ module TableStructure
|
|
22
22
|
@writer = ::TableStructure::Writer.new(schema, **@options)
|
23
23
|
end
|
24
24
|
|
25
|
-
def write(items, to:, **options)
|
25
|
+
def write(items, to:, **options, &block)
|
26
26
|
options = @options.merge(options).merge(FIXED_OPTIONS)
|
27
27
|
to.send(options[:method], BOM) if options[:bom]
|
28
|
-
@writer.write(items, to: ::CSV.new(to), **options)
|
28
|
+
@writer.write(items, to: ::CSV.new(to), **options, &block)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -35,9 +35,14 @@ module TableStructure
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def enumerize(items)
|
38
|
-
items.respond_to?(:
|
39
|
-
Enumerator.new { |y| items.call(y) } :
|
38
|
+
if items.respond_to?(:each)
|
40
39
|
items
|
40
|
+
elsif items.respond_to?(:call)
|
41
|
+
warn "[TableStructure] Use `Enumerator` instead of `lambda` to wrap items. `lambda` has been deprecated. #{items}"
|
42
|
+
Enumerator.new { |y| items.call(y) }
|
43
|
+
else
|
44
|
+
raise ::TableStructure::Error, 'Items is not enumerable.'
|
45
|
+
end
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_structure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jsmmr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|