cellar 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cellar.rb +10 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8673b22bfc18be6cd4c5a213584c61f537c084ccc46350014b641abc5842f616
|
4
|
+
data.tar.gz: b2da2314a3dc9bd428eceff45005544a42e34f423c0be44a78997cafd4beb5e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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.
|
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
|
-
|
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.
|
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:
|
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.
|
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
|