cellar 0.1.3 → 0.1.5
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 +17 -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: be9c519146063e4b17e8736dfd6d58f968411ef172c2c7ba4bb6f9f2669f7ebc
|
4
|
+
data.tar.gz: a030af0aaa876017a8ec86960aff3fb3f10d0265b8750b6a7f2fb8e14260f5ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d6004af8953418d4b3e76cc96fd7ed3e7f6b26cef82f11eb0b5f2476aef4249b63dad569eecfeb31618115606b204ce41fdb58b6b4187ef1521a2b89007321c
|
7
|
+
data.tar.gz: a1b75505baec7086b318b2d88f5bea5a2bb80aa0aec53373a065f545867e72b7f3551bde3a841cfc47941142474da932753b9343a95219655583cd21e5e70d31
|
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
|
5
|
+
# Date: October 9, 2024
|
6
6
|
#
|
7
7
|
# TODO:
|
8
8
|
# • Should we failover to empty strings like this: (value || "")
|
@@ -24,7 +24,7 @@ class Object
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Cellar
|
27
|
-
VERSION="0.1.
|
27
|
+
VERSION="0.1.5"
|
28
28
|
|
29
29
|
attr_reader :fields
|
30
30
|
attr_reader :values
|
@@ -62,6 +62,19 @@ class Cellar
|
|
62
62
|
index
|
63
63
|
end
|
64
64
|
|
65
|
+
def rename_field(field, other)
|
66
|
+
field = field.to_s
|
67
|
+
index = index(field) or raise "unable to rename the #{field.inspect} field"
|
68
|
+
@finder.delete(field.downcase.gsub(/\W/,'_'))
|
69
|
+
@finder.delete(field)
|
70
|
+
other = other.to_s
|
71
|
+
fields[index] = other
|
72
|
+
@finder[other.downcase.gsub(/\W/,'_')] ||= index
|
73
|
+
@finder[other] ||= index
|
74
|
+
@widest = fields.map(&:size).max
|
75
|
+
index
|
76
|
+
end
|
77
|
+
|
65
78
|
def index(field)
|
66
79
|
case field
|
67
80
|
when String, Symbol
|
@@ -98,6 +111,8 @@ class Cellar
|
|
98
111
|
when 0
|
99
112
|
[]
|
100
113
|
when 1
|
114
|
+
first = fields.first
|
115
|
+
first.is_a?(Cellar) and return self[*first.fields]
|
101
116
|
index = index(fields.first)
|
102
117
|
value = @values[index] if index
|
103
118
|
else
|
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.1.
|
4
|
+
version: 0.1.5
|
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-
|
11
|
+
date: 2024-10-10 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
|