fat_core 1.2.2 → 1.2.3
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/fat_core/table.rb +7 -5
- data/lib/fat_core/version.rb +1 -1
- data/spec/lib/table_spec.rb +28 -0
- 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: 797e6994f7aa6ed0c11d9b25350e1e9b9877c3d2
|
4
|
+
data.tar.gz: 2d4ff594b7d3e2e46b20b6d5936076ea15d34e7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81fa59c2ad8689e4421be2dfd0d5398038b52baddb9c763a11a1cb9c52248bc4bf7e4de7d433ca51cbda559f0c96a096fdbbdfd6ca6886b839a9f5ece4c404f9
|
7
|
+
data.tar.gz: be6cc5052d2574cb61e83f61996724a1092521bbacd641c626d58780d965b2ea92aaba932700128a12d06e365c5dcd50ee16d2ead6b657e0b67c252a555754a3
|
data/lib/fat_core/table.rb
CHANGED
@@ -118,12 +118,14 @@ module FatCore
|
|
118
118
|
# Return the rows of the table as an array of hashes, keyed by the headers.
|
119
119
|
def rows
|
120
120
|
rows = []
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
unless columns.empty?
|
122
|
+
0.upto(columns.first.items.last_i) do |rnum|
|
123
|
+
row = {}
|
124
|
+
columns.each do |col|
|
125
|
+
row[col.header] = col[rnum]
|
126
|
+
end
|
127
|
+
rows << row
|
125
128
|
end
|
126
|
-
rows << row
|
127
129
|
end
|
128
130
|
rows
|
129
131
|
end
|
data/lib/fat_core/version.rb
CHANGED
data/spec/lib/table_spec.rb
CHANGED
@@ -603,6 +603,34 @@ EOS
|
|
603
603
|
tab2 = tab1.where("date < Date.parse('2006-06-01')")
|
604
604
|
expect(tab2[:date].max).to be < Date.parse('2006-06-01')
|
605
605
|
end
|
606
|
+
|
607
|
+
it 'should select by boolean columns' do
|
608
|
+
tab =
|
609
|
+
[['Ref', 'Date', 'Code', 'Raw', 'Shares', 'Price', 'Info', 'Bool'],
|
610
|
+
[1, '2013-05-02', 'P', 795_546.20, 795_546.2, 1.1850, 'ZMPEF1', 'T'],
|
611
|
+
[2, '2013-05-02', 'P', 118_186.40, 118_186.4, 11.8500, 'ZMPEF1', 'T'],
|
612
|
+
[7, '2013-05-20', 'S', 12_000.00, 5046.00, 28.2804, 'ZMEAC', 'F'],
|
613
|
+
[8, '2013-05-20', 'S', 85_000.00, 35_742.50, 28.3224, 'ZMEAC', 'T'],
|
614
|
+
[9, '2013-05-20', 'S', 33_302.00, 14_003.49, 28.6383, 'ZMEAC', 'T'],
|
615
|
+
[10, '2013-05-23', 'S', 8000.00, 3364.00, 27.1083, 'ZMEAC', 'T'],
|
616
|
+
[11, '2013-05-23', 'S', 23_054.00, 9694.21, 26.8015, 'ZMEAC', 'F'],
|
617
|
+
[12, '2013-05-23', 'S', 39_906.00, 16_780.47, 25.1749, 'ZMEAC', 'T'],
|
618
|
+
[13, '2013-05-29', 'S', 13_459.00, 5659.51, 24.7464, 'ZMEAC', 'T'],
|
619
|
+
[14, '2013-05-29', 'S', 15_700.00, 6601.85, 24.7790, 'ZMEAC', 'F'],
|
620
|
+
[15, '2013-05-29', 'S', 15_900.00, 6685.95, 24.5802, 'ZMEAC', 'T'],
|
621
|
+
[16, '2013-05-30', 'S', 6_679.00, 2808.52, 25.0471, 'ZMEAC', 'T']]
|
622
|
+
tab = Table.new(tab).add_sum_footer([:raw, :shares, :price])
|
623
|
+
tab2 = tab.where('!bool || code == "P"')
|
624
|
+
expect(tab2.rows.size).to eq(5)
|
625
|
+
tab2 = tab.where('code == "S" && raw < 10_000')
|
626
|
+
expect(tab2.rows.size).to eq(2)
|
627
|
+
tab2 = tab.where('@row > 10')
|
628
|
+
expect(tab2.rows.size).to eq(2)
|
629
|
+
tab2 = tab.where('info =~ /zmeac/i')
|
630
|
+
expect(tab2.rows.size).to eq(10)
|
631
|
+
tab2 = tab.where('info =~ /xxxx/')
|
632
|
+
expect(tab2.rows.size).to eq(0)
|
633
|
+
end
|
606
634
|
end
|
607
635
|
|
608
636
|
describe 'group_by' do
|