fat_core 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e60f8326fe791c7c937d2bf069c82312f1a42d73
4
- data.tar.gz: 74562c504f4b8104d8f4d5ad3915076f11475ba7
3
+ metadata.gz: 9e28fd828b1834392ec3d93c6d77d5568851ca2f
4
+ data.tar.gz: a797433c6351eb24e3f6986f49dd28db38f63e30
5
5
  SHA512:
6
- metadata.gz: 16619652648490f700cec9bd6f3f956d501e200e5a5f7606853bf35ec2a5eaa03c40a57dff89aff19d8233893c46b3e11b5cca44bc2c4c57eff873c554acf345
7
- data.tar.gz: 2a873b09a9b550c3b58117241134ecc3d9a65e35d77f98fe4621aa52614c1c574a3fbf3ff67f1c5aa4e2eb0f2bcd74f267f5d46329555d2bc8bd6e9eb86124cb
6
+ metadata.gz: 791d39caea81ff9b176769ada6c36c0a225f3f90167d37bac39f24e5d57b69c9e9b01ed676233620e448b83b996313aeaee5b9aa95b86bf81f2029e5ca3f1f9a
7
+ data.tar.gz: b3fe37887ed9bc39f6704be264090e11a81b00fc5deb21ab4f5f7914e1548081a8f1b91fc1420888beeaed740927a65b730087f93a6360838f93bbd03a8e1557
@@ -8,6 +8,7 @@ require 'fat_core/version'
8
8
 
9
9
  require 'fat_core/array'
10
10
  require 'fat_core/date'
11
+ require 'fat_core/boolean'
11
12
  require 'fat_core/enumerable'
12
13
  require 'fat_core/hash'
13
14
  require 'fat_core/kernel'
@@ -0,0 +1,25 @@
1
+ class TrueClass
2
+ def format_by(fmt = 'T')
3
+ case fmt
4
+ when /^[tf]/i
5
+ 'T'
6
+ when /^[yn]/i
7
+ 'Y'
8
+ else
9
+ 'T'
10
+ end
11
+ end
12
+ end
13
+
14
+ class FalseClass
15
+ def format_by(fmt = 'T')
16
+ case fmt
17
+ when /^[tf]/i
18
+ 'F'
19
+ when /^[yn]/i
20
+ 'N'
21
+ else
22
+ 'F'
23
+ end
24
+ end
25
+ end
@@ -105,8 +105,8 @@ module FatCore
105
105
  when 'TrueClass', 'FalseClass'
106
106
  val_class = val.class
107
107
  val = convert_to_boolean(val)
108
- unless val
109
- raise "Inconsistent value in a Boolean column #{key} has class #{val_class}"
108
+ if val.nil?
109
+ raise "Inconsistent value in a Boolean column #{header} has class #{val_class}"
110
110
  end
111
111
  val
112
112
  when 'DateTime', 'Date'
@@ -1,7 +1,7 @@
1
1
  module FatCore
2
2
  MAJOR = 1
3
3
  MINOR = 2
4
- PATCH = 0
4
+ PATCH = 1
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
@@ -632,19 +632,19 @@ EOS
632
632
  # This is what the data looks like when called from org babel code
633
633
  # blocks.
634
634
  tab =
635
- [['Ref', 'Date', 'Code', 'Raw', 'Shares', 'Price', 'Info'],
636
- [1, '2013-05-02', 'P', 795_546.20, 795_546.2, 1.1850, 'ZMPEF1'],
637
- [2, '2013-05-02', 'P', 118_186.40, 118_186.4, 11.8500, 'ZMPEF1'],
638
- [7, '2013-05-20', 'S', 12_000.00, 5046.00, 28.2804, 'ZMEAC'],
639
- [8, '2013-05-20', 'S', 85_000.00, 35_742.50, 28.3224, 'ZMEAC'],
640
- [9, '2013-05-20', 'S', 33_302.00, 14_003.49, 28.6383, 'ZMEAC'],
641
- [10, '2013-05-23', 'S', 8000.00, 3364.00, 27.1083, 'ZMEAC'],
642
- [11, '2013-05-23', 'S', 23_054.00, 9694.21, 26.8015, 'ZMEAC'],
643
- [12, '2013-05-23', 'S', 39_906.00, 16_780.47, 25.1749, 'ZMEAC'],
644
- [13, '2013-05-29', 'S', 13_459.00, 5659.51, 24.7464, 'ZMEAC'],
645
- [14, '2013-05-29', 'S', 15_700.00, 6601.85, 24.7790, 'ZMEAC'],
646
- [15, '2013-05-29', 'S', 15_900.00, 6685.95, 24.5802, 'ZMEAC'],
647
- [16, '2013-05-30', 'S', 6_679.00, 2808.52, 25.0471, 'ZMEAC']]
635
+ [['Ref', 'Date', 'Code', 'Raw', 'Shares', 'Price', 'Info', 'Bool'],
636
+ [1, '2013-05-02', 'P', 795_546.20, 795_546.2, 1.1850, 'ZMPEF1', 'T'],
637
+ [2, '2013-05-02', 'P', 118_186.40, 118_186.4, 11.8500, 'ZMPEF1', 'T'],
638
+ [7, '2013-05-20', 'S', 12_000.00, 5046.00, 28.2804, 'ZMEAC', 'F'],
639
+ [8, '2013-05-20', 'S', 85_000.00, 35_742.50, 28.3224, 'ZMEAC', 'T'],
640
+ [9, '2013-05-20', 'S', 33_302.00, 14_003.49, 28.6383, 'ZMEAC', 'T'],
641
+ [10, '2013-05-23', 'S', 8000.00, 3364.00, 27.1083, 'ZMEAC', 'T'],
642
+ [11, '2013-05-23', 'S', 23_054.00, 9694.21, 26.8015, 'ZMEAC', 'F'],
643
+ [12, '2013-05-23', 'S', 39_906.00, 16_780.47, 25.1749, 'ZMEAC', 'T'],
644
+ [13, '2013-05-29', 'S', 13_459.00, 5659.51, 24.7464, 'ZMEAC', 'T'],
645
+ [14, '2013-05-29', 'S', 15_700.00, 6601.85, 24.7790, 'ZMEAC', 'F'],
646
+ [15, '2013-05-29', 'S', 15_900.00, 6685.95, 24.5802, 'ZMEAC', 'T'],
647
+ [16, '2013-05-30', 'S', 6_679.00, 2808.52, 25.0471, 'ZMEAC', 'T']]
648
648
  tg = Table.new(tab).add_sum_footer([:raw, :shares, :price])
649
649
  aoa = tg.to_org(formats: { raw: '%,', shares: '%,', price: '%,4' })
650
650
  expect(aoa[-1][0]).to eq 'Total'
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.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
@@ -202,6 +202,7 @@ files:
202
202
  - lib/fat_core.rb
203
203
  - lib/fat_core/ChangeLog
204
204
  - lib/fat_core/array.rb
205
+ - lib/fat_core/boolean.rb
205
206
  - lib/fat_core/column.rb
206
207
  - lib/fat_core/date.rb
207
208
  - lib/fat_core/enumerable.rb