cellar 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cellar.rb +10 -5
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e474bc4dc354fe4c5fff6e2381e33e068ceb17a58fec95658ecd333ac7077bc
4
- data.tar.gz: 540a05eaf9f6625240f4a27ccfd7956055466786ddf3e818a0c260e14a92eed0
3
+ metadata.gz: 8673b22bfc18be6cd4c5a213584c61f537c084ccc46350014b641abc5842f616
4
+ data.tar.gz: b2da2314a3dc9bd428eceff45005544a42e34f423c0be44a78997cafd4beb5e3
5
5
  SHA512:
6
- metadata.gz: 3ec873d0b0010c91e7b4bc0015b465a8866ae144aab223b6db5116c74a1e753cf9207713c9714eead2026c30d108883dfe1593812d0a197bf80ed7f35e0996db
7
- data.tar.gz: 27f2fc1462e97b3613411a1129976cb963e5b77df810b1c914e2886c21e8aee3f9a39e27e71bc21744a30a3c95ef6db8c912d4b2a8a010d077528cbbeb6959f7
6
+ metadata.gz: 35177971cabb780bc9af73dcd11d8e2502376422a21be2712744b7fdfab576681956319b958c37fa7a84a57c8e764c81ddde9c6027ae78b57ba020fde0d71aad
7
+ data.tar.gz: '08ff64300ed51e6d9b334a4d8e7a05dcf122181218a270ebc851b20561fafbfb4874904b94f7233a630eed150571b7e8bcc55a56f5095f8155ba52e3ebb59e9c'
data/lib/cellar.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # cellar - Ruby gem to deal with cells of data in rows and columns
3
3
  #
4
4
  # Author: Steve Shreeve (steve.shreeve@gmail.com)
5
- # Date: October 14, 2024
5
+ # Date: January 8, 2025
6
6
  #
7
7
  # TODO:
8
8
  # • Should we failover to empty strings like this: (value || "")
@@ -28,17 +28,18 @@ class Object
28
28
  end
29
29
 
30
30
  class Cellar
31
- VERSION="0.2.0"
31
+ VERSION="0.2.2"
32
32
 
33
33
  attr_reader :fields
34
34
  attr_reader :values
35
35
  attr_accessor :strict
36
36
 
37
- def initialize(obj=nil, header: true, strict: true, index: nil)
37
+ def initialize(obj=nil, header: true, strict: true, warn: true, index: nil)
38
38
  @fields = []
39
39
  @values = []
40
40
  @finder = {}
41
41
  @seeker = {}
42
+ @warn = warn
42
43
  @index = index
43
44
  @widest = 0
44
45
 
@@ -60,7 +61,7 @@ class Cellar
60
61
  @fields << field
61
62
  finders = @finder.size
62
63
  @finder[field.downcase.gsub(/\W/,'_')] ||= index
63
- @finder.size == finders + 1 or warn "field clash for #{field.inspect}"
64
+ @finder.size == finders + 1 or (@warn and warn "field clash for #{field.inspect}")
64
65
  @finder[field] ||= index
65
66
  @widest = field.length if field.length > @widest
66
67
  index
@@ -238,7 +239,11 @@ class Cellar
238
239
  field = data.fields[idx]
239
240
  index = index(field) || add_field(field)
240
241
  value = @values[index]
241
- @values[index] = block && !value.nil? ? block.call(value, val) : val
242
+ if block && !value.blank?
243
+ val = block.call(value, val)
244
+ next if val.blank?
245
+ end
246
+ @values[index] = val
242
247
  end
243
248
  self
244
249
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cellar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-19 00:00:00.000000000 Z
11
+ date: 2025-01-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby gem to deal with cells of data in rows and columns
14
14
  email: steve.shreeve@gmail.com
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  requirements: []
42
- rubygems_version: 3.5.21
42
+ rubygems_version: 3.5.22
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: A Ruby gem to deal with cells of data in rows and columns