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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67e6d6f2d83ec3fb7ff25437e214118d6cdfa642
4
- data.tar.gz: 4a93723d522fa9fd888c8dc0f348558c75d36b29
3
+ metadata.gz: 797e6994f7aa6ed0c11d9b25350e1e9b9877c3d2
4
+ data.tar.gz: 2d4ff594b7d3e2e46b20b6d5936076ea15d34e7a
5
5
  SHA512:
6
- metadata.gz: 333bd2bc212bc5dbf7e4f2224be5893af3e1cb9b8acee8c6626de1c6ff8e44cbdbfe57258d04e9dc8885cacc438b1606af20b44b844b7d6ec4e7e7adc8b28a70
7
- data.tar.gz: ca90b99e78170731a10216e5dd76b110b1b5252cba2a0b64724ba4f89cc20e746bc8ad76798ae564641e99e736f0bab4213411268ebc99b6dd35e7dd35820ad5
6
+ metadata.gz: 81fa59c2ad8689e4421be2dfd0d5398038b52baddb9c763a11a1cb9c52248bc4bf7e4de7d433ca51cbda559f0c96a096fdbbdfd6ca6886b839a9f5ece4c404f9
7
+ data.tar.gz: be6cc5052d2574cb61e83f61996724a1092521bbacd641c626d58780d965b2ea92aaba932700128a12d06e365c5dcd50ee16d2ead6b657e0b67c252a555754a3
@@ -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
- 0.upto(columns.first.items.last_i) do |rnum|
122
- row = {}
123
- columns.each do |col|
124
- row[col.header] = col[rnum]
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
@@ -1,7 +1,7 @@
1
1
  module FatCore
2
2
  MAJOR = 1
3
3
  MINOR = 2
4
- PATCH = 2
4
+ PATCH = 3
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty