web47core 3.2.3.26 → 3.2.3.27

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: 751e34226f9e73c0116cf5e6efaf5cb3347888652e4c9cc12ab11c2dfca77e1d
4
- data.tar.gz: bddd2a674da0b40d964955f5dabdd42e7fb315491e9fda8aa9a2db366e4dfdb9
3
+ metadata.gz: 81b8ef76b5902c84baaf31f91abbc7580e89d6b7e858891996debdc5be285be9
4
+ data.tar.gz: cd2526dd341085fba1c0afe692ac48ae68d080003e144cd0965f95c17923cb9f
5
5
  SHA512:
6
- metadata.gz: 8ee80510dc73c71e4476976f0a90784fade08f6d4b003e7fab97fb9c55a65f7a887de7f17d0570ec0af010a0598f714f082dcd493b899bf5b453e7018ec2d5c0
7
- data.tar.gz: 5b814027d75d250b7a1b2b1ee5b1ce0cd9147ce1810b9a85bb0e39d873d8decd79aecb4b56cf38af6dff33bd330ceefa2607416d195828e760b0c422af568dbc
6
+ metadata.gz: 84e30c300ea6a6d2f47314ac71ea5099ce859ba078d24a8c9808cd8cd18a36e249eaf4db5238cf60205cf6385e0c4cab034507d6dba25cccca8e3086b96fda45
7
+ data.tar.gz: a85b4f138e901296b023d4977bc6f4d89d114c282e4c0ded09ef6e4e4b298d16a6b404e8d0f75c48daf5c133f8c82eb483accc9bfe28356ca024a1806cffe6ad
@@ -0,0 +1,81 @@
1
+ #
2
+ # Convert the thingy listed below to a true/false value
3
+ #
4
+ # BooleanFluxCapacitor
5
+ #
6
+ # Provides a common `to_bool` method for core Ruby types, similar in spirit
7
+ # to `to_s` or `to_i`.
8
+ #
9
+ # The goal is to produce TOTAL boolean coercion:
10
+ # - Always returns `true` or `false`
11
+ # - Never raises
12
+ # - Never returns `nil`
13
+ #
14
+ # Conversion rules are explicit and deterministic.
15
+ #
16
+ module BooleanFluxCapacitor
17
+ # Truthy string values (case-insensitive, whitespace ignored)
18
+ TRUTHY = /\A(true|on|yes|y|1)\z/i
19
+
20
+ # Convert the receiver into a Boolean value.
21
+ #
22
+ # This method is intended for configuration, environment variables,
23
+ # and user-supplied input where values may arrive as different types.
24
+ #
25
+ # Conversion rules:
26
+ #
27
+ # * `true` → `true`
28
+ # * `false` → `false`
29
+ # * `nil` → `false`
30
+ #
31
+ # * Numeric values:
32
+ # * `0` → `false`
33
+ # * non-zero → `true`
34
+ #
35
+ # * String values:
36
+ # * Case-insensitive match of:
37
+ # "true", "on", "yes", "y", "1" → `true`
38
+ # * All other strings → `false`
39
+ #
40
+ # * All other object types:
41
+ # * Converted using `to_s` and evaluated using the same string rules
42
+ #
43
+ # Notes:
44
+ # * This method does NOT affect Ruby's native truthiness.
45
+ # * It exists solely for explicit boolean coercion.
46
+ #
47
+ # Examples:
48
+ #
49
+ # true.to_bool # => true
50
+ # false.to_bool # => false
51
+ # nil.to_bool # => false
52
+ #
53
+ # 0.to_bool # => false
54
+ # 42.to_bool # => true
55
+ #
56
+ # "true".to_bool # => true
57
+ # " YES ".to_bool # => true
58
+ # "false".to_bool # => false
59
+ # "anything else".to_bool # => false
60
+ #
61
+ def to_bool
62
+ case self
63
+ when true
64
+ true
65
+ when false, nil
66
+ false
67
+ when Numeric
68
+ !zero?
69
+ else
70
+ to_s.strip.match?(TRUTHY)
71
+ end
72
+ end
73
+ end
74
+
75
+ # Extend core classes with `to_bool`
76
+ NilClass.include(BooleanFluxCapacitor)
77
+ TrueClass.include(BooleanFluxCapacitor)
78
+ FalseClass.include(BooleanFluxCapacitor)
79
+ Numeric.include(BooleanFluxCapacitor)
80
+ String.include(BooleanFluxCapacitor)
81
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '3.2.3.26'
4
+ VERSION = '3.2.3.27'
5
5
  end
data/lib/web47core.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'web47core/config'
2
+ require 'web47core/boolean_flux_capacitor'
2
3
  require 'app/models/concerns/app47_logger'
3
4
  require 'app/models/concerns/api_tokenable'
4
5
  require 'app/models/concerns/archive_able'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3.26
4
+ version: 3.2.3.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-18 00:00:00.000000000 Z
11
+ date: 2025-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -6628,6 +6628,7 @@ files:
6628
6628
  - lib/templates/slack/failed_delayed_job.liquid
6629
6629
  - lib/update_icons.rb
6630
6630
  - lib/web47core.rb
6631
+ - lib/web47core/boolean_flux_capacitor.rb
6631
6632
  - lib/web47core/config.rb
6632
6633
  - lib/web47core/engine.rb
6633
6634
  - lib/web47core/version.rb