sqa 0.0.19 → 0.0.20

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
  SHA256:
3
- metadata.gz: a8dd5577340edd8f74a73428779129e4f97bcfbb4b8eaa23ce02c6b1f290baa4
4
- data.tar.gz: fa03b7e2203edbb69da04b9ff022776a6932a481e33a7290e4ff46b573375a89
3
+ metadata.gz: eaf6c6d975b4bb899fc3f82e79b1fb87b6f4cdad17b19d7e2c5b8300d8cce107
4
+ data.tar.gz: 2b06b6ffcc711e4d593e18ba7f68508bfb423d60be9d4358ef0953ce2a8983d7
5
5
  SHA512:
6
- metadata.gz: ca34483321c0ac6391d322acef9ed2a9ba5d1e87db15201d4c89f760346e1c620b1ce5182cf203c393b118703a743bf535f84e52f099bad12445eacc1b82d39b
7
- data.tar.gz: 89cb9767f3febdc9e20970e0d73a679f378f75260b4e6b146bd413dc49d942200a60f03c2ecb7f02ae6e87662ece5744fa45aead39d147fa7aad81d2037128fc
6
+ metadata.gz: 9ddbd102bb0aa138c39177f4900159e5767739c60943e3ea5d03c07b0cfd1cdfa6cd78db3ea13f502aeee4a31826be64fb36e3d8f9ffa895c30263d5577e6759
7
+ data.tar.gz: 3b9365d693970575b0d922deccb2c37261ebb4a0ffe5c35109522e85ad861410d2391914b6a3ea7ff4b01d84be721470ee3dc783086517a0e55de84161e2d1c4
@@ -0,0 +1 @@
1
+ 46d87a1698df7159658dbb5be0d8d3b50209d85cac5085c5d7ee904b1d095c955a25f5f89a79f1af9a0a8c64cda51db58ebb8ae0b23ded2f8d4d680d8ed49606
@@ -22,11 +22,51 @@ class SQA::DataFrame
22
22
  attr_accessor :data
23
23
 
24
24
  # Expects a Hash of Arrays (hofa)
25
- def initialize(a_hash={})
26
- @data = Data.new(a_hash)
25
+ # mapping: and transformers: are optional
26
+ # mapping is a Hash { old_key => new_key }
27
+ # transformers is also a Hash { key => Proc}
28
+ def initialize(
29
+ aofh_or_hofa= {}, # Array of Hashes or hash of array or hash
30
+ mapping: {}, # { old_key => new_key }
31
+ transformers: {} # { key => Proc }
32
+ )
33
+
34
+ if aofh_or_hofa.is_a? Hash
35
+ initialize_hofa(aofh_or_hofa, mapping: mapping)
36
+
37
+ elsif aofh_or_hofa.is_a?(Array) &&
38
+ aofh_or_hofa.first.is_a?(Hash)
39
+ initialize_aofh(aofh_or_hofa, mapping: mapping)
40
+
41
+ else
42
+ raise BadParameterError, "Expecting Hash or Array of Hashes got: #{aofh_or_hofa.class}"
43
+ end
44
+
45
+ coerce_vectors!(transformers) unless transformers.empty?
46
+ end
47
+
48
+
49
+ def initialize_aofh(aofh, mapping:)
50
+ hofa = self.class.aofh_to_hofa(
51
+ aofh,
52
+ mapping: mapping
53
+ )
54
+
55
+ initialize_hofa(hofa, mapping: mapping)
56
+ end
57
+
58
+
59
+ def initialize_hofa(hofa, mapping:)
60
+ hofa = self.class.normalize_keys(
61
+ hofa,
62
+ adapter_mapping: mapping
63
+ ) unless mapping.empty?
64
+
65
+ @data = Data.new(hofa)
27
66
  end
28
67
 
29
68
 
69
+
30
70
  def to_csv(path_to_file)
31
71
  CSV.open(path_to_file, 'w') do |csv|
32
72
  csv << keys
@@ -202,11 +242,9 @@ class SQA::DataFrame
202
242
 
203
243
  def from_aofh(aofh, mapping: {}, transformers: {})
204
244
  new(
205
- aofh_to_hofa(
206
- aofh,
207
- mapping: mapping,
208
- transformers: transformers
209
- )
245
+ aofh,
246
+ mapping: mapping,
247
+ transformers: transformers
210
248
  )
211
249
  end
212
250
 
data/lib/sqa/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SQA
4
- VERSION = "0.0.19"
4
+ VERSION = "0.0.20"
5
5
 
6
6
  class << self
7
7
  def version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-21 00:00:00.000000000 Z
11
+ date: 2023-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alphavantage
@@ -231,6 +231,7 @@ files:
231
231
  - checksums/sqa-0.0.18.gem.sha512
232
232
  - checksums/sqa-0.0.19.gem.sha512
233
233
  - checksums/sqa-0.0.2.gem.sha512
234
+ - checksums/sqa-0.0.20.gem.sha512
234
235
  - checksums/sqa-0.0.3.gem.sha512
235
236
  - checksums/sqa-0.0.4.gem.sha512
236
237
  - checksums/sqa-0.0.5.gem.sha512