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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15634b3115faa6adf71706af3ee278aa08b196408e4bcf895de38d1dd9401dff
4
- data.tar.gz: 678ca7958dbb6edfea148639c4e9ec51e336226112f6e7f5d9ca65a511cadf41
3
+ metadata.gz: 54e6d65c5123ccefa563ba83cfa9ef28fe25ee407224c0838afe17158afe5bbc
4
+ data.tar.gz: bb6cdd925323a59eb93d77c610a09b2136c6ee96e6cf618e2b0502171f2bdd4d
5
5
  SHA512:
6
- metadata.gz: 605978ebfae00094056ad2dd53e4ff3c26a4caf3575b8efcf54545998ea36bcfc5cc93eb779c7bc43df277f562337cf6b22b381b392e2552d32636e7b65e0459
7
- data.tar.gz: 99f37c9c2d3b3feaed7332c0c9a4e6d76c3eb3f3960ccced2b2db13abd973f3f68914ce26465f36df72da5a200005bec8a644bd6216f9ce5c1b3c629a92f1a4e
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- table_structure (0.3.9)
4
+ table_structure (0.3.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TableStructure
4
- VERSION = '0.3.9'
4
+ VERSION = '0.3.10'
5
5
  end
@@ -35,9 +35,14 @@ module TableStructure
35
35
  private
36
36
 
37
37
  def enumerize(items)
38
- items.respond_to?(:call) ?
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.9
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-21 00:00:00.000000000 Z
11
+ date: 2019-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler