flexor 0.1.2 → 0.1.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
  SHA256:
3
- metadata.gz: 4829c05a12464754b396dce1819af07f73ab4be5701bd1386bf75b17d25cf20d
4
- data.tar.gz: c160abc174ce641f4b9f08fd5cdff829f64980b63282059d1181a88e8ee4aecd
3
+ metadata.gz: 9f8b7ac8e70f6731e117cdb6682c20a503749b202fa61b6dad9d2e89334fefa5
4
+ data.tar.gz: 0d9fc1b7946a7fc7ec5ccae87502d132864ac2993812bdd99835d7d6926ca481
5
5
  SHA512:
6
- metadata.gz: 7f9bcadb983ea41a9420a1bac2b4c537b24ad86ab8d515dfd9de01d3fd6c4feddab1d52a8e2afe9e82f1dfb40b233772bc30c80a243ef1543a39258413486596
7
- data.tar.gz: '0858ff2f829320da4c0eefe619e5269063d649ea659d7d2c6c2b75cd3ed5adaacec74117689a6a73e104fe980c8a42f567d49706893ff3b347d6fc84436ccb4c'
6
+ metadata.gz: 1f77a7de94d262e22227b41757bf14863f13fba7ab1868cdfd170985ff50b933714fcb5c0060fbc78c9f7967ab55048b82353ca3ccc4f832cf86e324f152ceac
7
+ data.tar.gz: 0a6527a96bdf205ccb9293cccfc2044c6762f3d2db2702bfdf4366854f432d4011c08c3a5cd0a1714e7fabe3dbae6710d4f1539ab66231e3c5b2c5f49d6c7943
data/issues.rec CHANGED
@@ -167,3 +167,17 @@ Description: #Write a spec/test for the following example:
167
167
  + end
168
168
  + ```
169
169
  Status: open
170
+
171
+ Id: 86B389D2-41A8-11F1-89B0-FE6CB9572C2F
172
+ Updated: Sun, 26 Apr 2026 15:45:49 -0400
173
+ Title: 'Coerce' error when using sum
174
+ Description: Running this code raised the error below it:
175
+ +
176
+ + ```ruby
177
+ + f.records.map(&:delta_revenue).map(&:to_f).sum
178
+ + ```
179
+ + /Users/davidgillis/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/flexor-0.1.2/lib/flexor/method_dispatch.rb:18:in "Flexor::MethodDispatch#method_missing": undefined method "coerce" for an instance of Flexor (NoMethodError)
180
+ +
181
+ + Regardless, this error looks like an internal bug and should be invisible to the user
182
+ +
183
+ Status: open
@@ -18,13 +18,18 @@ class Flexor
18
18
 
19
19
  def init_with(coder)
20
20
  @root = coder["root"]
21
- @store = vivify(symbolize_keys(coder["store"] || {}))
21
+
22
+ @store = coder.then { it["store"] || {} }
23
+ .then { symbolize_keys it }
24
+ .then { vivify it }
22
25
  end
23
26
 
24
27
  private
25
28
 
26
29
  def symbolize_keys(hash)
27
- hash.transform_keys(&:to_sym).transform_values do |v|
30
+ hash
31
+ .transform_keys(&:to_sym)
32
+ .transform_values do |v|
28
33
  v.is_a?(Hash) ? symbolize_keys(v) : v
29
34
  end
30
35
  end
@@ -1,3 +1,3 @@
1
1
  class Flexor
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
@@ -2,6 +2,10 @@ class Flexor
2
2
  ##
3
3
  # Methods for recursively converting raw Hashes and Arrays into Flexor objects.
4
4
  module Vivification
5
+ FLOAT = /[0-9.-]+/
6
+ INTEGER = /^(?<!0)[0-9-]+/
7
+ DATELIKE = /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}/
8
+
5
9
  private
6
10
 
7
11
  def vivify(hash)
@@ -18,8 +22,13 @@ class Flexor
18
22
 
19
23
  def vivify_value(value)
20
24
  case value
21
- when Hash then self.class.new(value, root: false)
22
- when Array then vivify_array(value)
25
+ in Hash then self.class.new(value, root: false)
26
+ in Array then vivify_array(value)
27
+ in INTEGER then value.to_i
28
+ in FLOAT then value.to_f
29
+ in DATELIKE
30
+ require "datetime"
31
+ DateTime.parse(it)
23
32
  else value
24
33
  end
25
34
  end
data/patterns_spec.rb ADDED
@@ -0,0 +1,10 @@
1
+ require "rspec"
2
+
3
+ FLOAT = /^(?:(?<!0)(?:[-+] ?)?[0-9])+(?:\.(?:[0-9](?!\.))+)?$/
4
+ RSpec.describe "Patterns" do
5
+ describe FLOAT do
6
+ it "does not allow leading zeroes" do
7
+ skip "not done yet"
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gillis
@@ -43,6 +43,7 @@ files:
43
43
  - lib/flexor/serialization.rb
44
44
  - lib/flexor/version.rb
45
45
  - lib/flexor/vivification.rb
46
+ - patterns_spec.rb
46
47
  - rakelib/benchmark.rake
47
48
  - rakelib/rdoc.rake
48
49
  homepage: https://github.com/gillisd/flexor
@@ -66,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  requirements: []
69
- rubygems_version: 4.0.9
70
+ rubygems_version: 4.0.13
70
71
  specification_version: 4
71
72
  summary: A Hash-like data store that does what you tell it to do
72
73
  test_files: []