chloroplast 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chloroplast.rb +10 -0
- data/spec/chloroplast_dsl_spec.rb +10 -0
- data/spec/chloroplast_spec.rb +3 -9
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e69ec9391c36586d72e8a2719fe7d69b06a7a561
|
|
4
|
+
data.tar.gz: e09d455e3c9544adf199d042b863b9fad85995de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 14e00d7bd1221ee78aba7ed697f89dccbcad0fca9b36f727c732dce3058915fd9ca123e7f326fdd1c870a1abac7b977451758db8603eb9fb73b0cc2a9f490241
|
|
7
|
+
data.tar.gz: ad8760d160345279d877ef80996f65f0074eda09e882429a467430cf1d153c44fc168ab0e189c11e95a77b01ed76ceb144bbb7fe83cf3fb5eb0cb8e63f00e51d
|
data/lib/chloroplast.rb
CHANGED
|
@@ -34,6 +34,11 @@ class Chloroplast
|
|
|
34
34
|
@headers.push header
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
# Add multiple table headers
|
|
38
|
+
def add_headers(*headers)
|
|
39
|
+
headers.each &method(:add_header)
|
|
40
|
+
end
|
|
41
|
+
|
|
37
42
|
# Add a table cell, and starting a new row and creating an object if appropriate
|
|
38
43
|
def append_cell(value)
|
|
39
44
|
if @headers.empty?
|
|
@@ -48,5 +53,10 @@ class Chloroplast
|
|
|
48
53
|
end
|
|
49
54
|
end
|
|
50
55
|
end
|
|
56
|
+
|
|
57
|
+
# Add multiple table cells
|
|
58
|
+
def append_cells(*values)
|
|
59
|
+
values.each &method(:append_cell)
|
|
60
|
+
end
|
|
51
61
|
end
|
|
52
62
|
|
|
@@ -26,5 +26,15 @@ describe Chloroplast do
|
|
|
26
26
|
| 4 | 5 | 6 \
|
|
27
27
|
end.to raise_error(/header/i)
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
it 'allows using other binary operator methods as table cell separator' do
|
|
31
|
+
# it is necessary to write () after new when using [] as cell "separators"
|
|
32
|
+
table = Chloroplast.new() \
|
|
33
|
+
[ :name ][ :age ][ :sex ] \
|
|
34
|
+
[ 'John' ][ 30 ][ :male ] \
|
|
35
|
+
[ 'Mary' ][ 40 ][ :female ] \
|
|
36
|
+
|
|
37
|
+
expect(table.objects[1].name).to be == 'Mary'
|
|
38
|
+
end
|
|
29
39
|
end
|
|
30
40
|
end
|
data/spec/chloroplast_spec.rb
CHANGED
|
@@ -7,15 +7,9 @@ describe Chloroplast do
|
|
|
7
7
|
|
|
8
8
|
it 'can be initialized' do
|
|
9
9
|
table = Chloroplast.new
|
|
10
|
-
table.
|
|
11
|
-
table.
|
|
12
|
-
|
|
13
|
-
table.append_cell 'John'
|
|
14
|
-
table.append_cell 30
|
|
15
|
-
table.append_cell :male
|
|
16
|
-
table.append_cell 'Mary'
|
|
17
|
-
table.append_cell 40
|
|
18
|
-
table.append_cell :female
|
|
10
|
+
table.add_headers :name, :age, :sex
|
|
11
|
+
table.append_cells 'John', 30, :male,
|
|
12
|
+
'Mary', 40, :female
|
|
19
13
|
|
|
20
14
|
expect(table.objects.find {|person| person.name == 'John'}.age).to be == 30
|
|
21
15
|
end
|