familia 1.2.1 → 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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +51 -9
- data/VERSION.yml +1 -1
- data/familia.gemspec +1 -0
- data/lib/familia/horreum/class_methods.rb +20 -0
- data/try/91_json_bug_try.rb +6 -6
- data/try/92_symbolize_try.rb +3 -2
- data/try/93_string_coercion_try.rb +3 -5
- metadata +17 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f31819ffd924bb211c9e1e09768aeb026f95f135ae820e6f97948fa6e95bb475
|
4
|
+
data.tar.gz: dccb8cb66025a0990dec762b7ea7ef50e4ae48ad02476e33fa6f01910e0dc50f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24173fa04960a2a0e14fee55e616b8b2ca172ec761afcbf76f1b7b6a0512cd30c5d2f57763f07d64584582d7fcb613fa7401c33e201c888a85e505a601d86af2
|
7
|
+
data.tar.gz: 6c1f92d8f1fe3e97226bdba409c85bf91c6a04295132c3f04d0dfc1670459e048c03bd120c97f8f96f58e7e6f4a13782497379eab960b81b489b096768c165bf
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
familia (1.2.
|
4
|
+
familia (1.2.3)
|
5
|
+
logger
|
5
6
|
redis (>= 4.8.1, < 6.0)
|
6
7
|
stringio (~> 3.1.1)
|
7
8
|
uri-redis (~> 1.3)
|
@@ -13,29 +14,65 @@ GEM
|
|
13
14
|
byebug (11.1.3)
|
14
15
|
coderay (1.1.3)
|
15
16
|
connection_pool (2.4.1)
|
16
|
-
|
17
|
+
date (3.4.1)
|
18
|
+
diff-lcs (1.6.2)
|
19
|
+
erb (5.0.2)
|
20
|
+
io-console (0.8.1)
|
21
|
+
irb (1.15.2)
|
22
|
+
pp (>= 0.6.0)
|
23
|
+
rdoc (>= 4.0.0)
|
24
|
+
reline (>= 0.4.2)
|
17
25
|
json (2.7.2)
|
18
26
|
language_server-protocol (3.17.0.3)
|
27
|
+
logger (1.7.0)
|
19
28
|
method_source (1.1.0)
|
29
|
+
minitest (5.25.5)
|
20
30
|
parallel (1.25.1)
|
21
31
|
parser (3.3.4.0)
|
22
32
|
ast (~> 2.4.1)
|
23
33
|
racc
|
34
|
+
pastel (0.8.0)
|
35
|
+
tty-color (~> 0.5)
|
36
|
+
pp (0.6.2)
|
37
|
+
prettyprint
|
38
|
+
prettyprint (0.2.0)
|
39
|
+
prism (1.4.0)
|
24
40
|
pry (0.14.2)
|
25
41
|
coderay (~> 1.1)
|
26
42
|
method_source (~> 1.0)
|
27
43
|
pry-byebug (3.10.1)
|
28
44
|
byebug (~> 11.0)
|
29
45
|
pry (>= 0.13, < 0.15)
|
46
|
+
psych (5.2.6)
|
47
|
+
date
|
48
|
+
stringio
|
30
49
|
racc (1.8.0)
|
31
50
|
rainbow (3.1.1)
|
51
|
+
rdoc (6.14.2)
|
52
|
+
erb
|
53
|
+
psych (>= 4.0.0)
|
32
54
|
redis (5.2.0)
|
33
55
|
redis-client (>= 0.22.0)
|
34
56
|
redis-client (0.22.2)
|
35
57
|
connection_pool
|
36
58
|
regexp_parser (2.9.2)
|
59
|
+
reline (0.6.2)
|
60
|
+
io-console (~> 0.5)
|
37
61
|
rexml (3.3.2)
|
38
62
|
strscan
|
63
|
+
rspec (3.13.1)
|
64
|
+
rspec-core (~> 3.13.0)
|
65
|
+
rspec-expectations (~> 3.13.0)
|
66
|
+
rspec-mocks (~> 3.13.0)
|
67
|
+
rspec-core (3.13.5)
|
68
|
+
rspec-support (~> 3.13.0)
|
69
|
+
rspec-expectations (3.13.5)
|
70
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
+
rspec-support (~> 3.13.0)
|
72
|
+
rspec-mocks (3.13.5)
|
73
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
74
|
+
rspec-support (~> 3.13.0)
|
75
|
+
rspec-support (3.13.4)
|
39
76
|
rubocop (1.65.0)
|
40
77
|
json (~> 2.3)
|
41
78
|
language_server-protocol (>= 3.17.0)
|
@@ -55,14 +92,19 @@ GEM
|
|
55
92
|
rubocop-thread_safety (0.5.1)
|
56
93
|
rubocop (>= 0.90.0)
|
57
94
|
ruby-progressbar (1.13.0)
|
58
|
-
storable (0.10.0)
|
59
95
|
stringio (3.1.1)
|
60
96
|
strscan (3.1.0)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
97
|
+
tryouts (3.2.1)
|
98
|
+
irb
|
99
|
+
minitest (~> 5.0)
|
100
|
+
pastel (~> 0.8)
|
101
|
+
prism (~> 1.0)
|
102
|
+
rspec (~> 3.0)
|
103
|
+
tty-cursor (~> 0.7)
|
104
|
+
tty-screen (~> 0.8)
|
105
|
+
tty-color (0.6.0)
|
106
|
+
tty-cursor (0.7.1)
|
107
|
+
tty-screen (0.8.2)
|
66
108
|
unicode-display_width (2.5.0)
|
67
109
|
uri-redis (1.3.0)
|
68
110
|
|
@@ -78,7 +120,7 @@ DEPENDENCIES
|
|
78
120
|
rubocop
|
79
121
|
rubocop-performance
|
80
122
|
rubocop-thread_safety
|
81
|
-
tryouts (~> 2
|
123
|
+
tryouts (~> 3.2)
|
82
124
|
|
83
125
|
BUNDLED WITH
|
84
126
|
2.5.13
|
data/VERSION.yml
CHANGED
data/familia.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.8')
|
21
21
|
|
22
|
+
spec.add_dependency 'logger'
|
22
23
|
spec.add_dependency 'redis', '>= 4.8.1', '< 6.0'
|
23
24
|
spec.add_dependency 'stringio', '~> 3.1.1'
|
24
25
|
spec.add_dependency 'uri-redis', '~> 1.3'
|
@@ -138,7 +138,13 @@ module Familia
|
|
138
138
|
# # Method implementation
|
139
139
|
# end
|
140
140
|
#
|
141
|
+
if method_defined?(:"#{name}!")
|
142
|
+
warn "Method #{name}! is already defined for #{self}"
|
143
|
+
return
|
144
|
+
end
|
145
|
+
|
141
146
|
define_method :"#{name}!" do |*args|
|
147
|
+
|
142
148
|
# Check if the correct number of arguments is provided (exactly one).
|
143
149
|
raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0 or 1)" if args.size > 1
|
144
150
|
|
@@ -235,6 +241,20 @@ module Familia
|
|
235
241
|
@prefix || name.downcase.gsub('::', Familia.delim).to_sym
|
236
242
|
end
|
237
243
|
|
244
|
+
# Converts the class name into a string that can be used to look up
|
245
|
+
# configuration values. This is particularly useful when mapping
|
246
|
+
# familia models with specific database numbers in the configuration.
|
247
|
+
#
|
248
|
+
# @example V2::Session.config_name => 'session'
|
249
|
+
#
|
250
|
+
# @return [String] The underscored class name as a string
|
251
|
+
def config_name
|
252
|
+
name.split('::').last
|
253
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
254
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
255
|
+
.downcase
|
256
|
+
end
|
257
|
+
|
238
258
|
# Creates and persists a new instance of the class.
|
239
259
|
#
|
240
260
|
# @param *args [Array] Variable number of positional arguments to be passed
|
data/try/91_json_bug_try.rb
CHANGED
@@ -51,26 +51,26 @@ raw_data
|
|
51
51
|
puts "Config after refresh:"
|
52
52
|
puts @test_obj.config.inspect
|
53
53
|
puts "Config class: "
|
54
|
-
[@test_obj.config.class, @test_obj.config
|
55
|
-
#=> [Hash,
|
54
|
+
[@test_obj.config.class, @test_obj.config]
|
55
|
+
#=> [Hash, {theme: "dark", notifications: true, settings: {volume: 80}}]
|
56
56
|
|
57
57
|
## Test 5: Array should be deserialized back to Array
|
58
58
|
puts "Tags after refresh:"
|
59
59
|
puts @test_obj.tags.inspect
|
60
60
|
puts "Tags class: #{@test_obj.tags.class}"
|
61
61
|
@test_obj.tags.inspect
|
62
|
-
@test_obj.tags
|
62
|
+
@test_obj.tags
|
63
63
|
#=> ["ruby", "redis", "json", "familia"]
|
64
|
-
|
64
|
+
#=:> Array
|
65
65
|
|
66
66
|
## Test 6: Simple string should remain a string (this works correctly)
|
67
67
|
puts "Simple after refresh:"
|
68
68
|
puts @test_obj.simple.inspect
|
69
69
|
puts "Simple class: #{@test_obj.simple.class}"
|
70
70
|
@test_obj.simple.inspect
|
71
|
-
@test_obj.simple
|
71
|
+
@test_obj.simple
|
72
72
|
#=> "just a string"
|
73
|
-
|
73
|
+
#=:> String
|
74
74
|
|
75
75
|
## Demonstrate the asymmetry:
|
76
76
|
puts "\n=== ASYMMETRY DEMONSTRATION ==="
|
data/try/92_symbolize_try.rb
CHANGED
@@ -13,7 +13,7 @@ end
|
|
13
13
|
@test_obj = SymbolizeTest.new
|
14
14
|
@test_obj.id = "symbolize_test_1"
|
15
15
|
|
16
|
-
|
16
|
+
# Test with a hash containing string keys
|
17
17
|
@test_hash = { "name" => "John", "age" => 30, "nested" => { "theme" => "dark" } }
|
18
18
|
@test_obj.config = @test_hash
|
19
19
|
@test_obj.save
|
@@ -58,6 +58,7 @@ end
|
|
58
58
|
@symbol_result[:name]
|
59
59
|
#=> "John"
|
60
60
|
|
61
|
+
## Check name as a string
|
61
62
|
@string_result["name"]
|
62
63
|
#=> "John"
|
63
64
|
|
@@ -92,5 +93,5 @@ end
|
|
92
93
|
@test_obj.deserialize_value('invalid json')
|
93
94
|
#=> "invalid json"
|
94
95
|
|
95
|
-
|
96
|
+
|
96
97
|
@test_obj.destroy!
|
@@ -5,15 +5,14 @@ require_relative './test_helpers'
|
|
5
5
|
|
6
6
|
Familia.debug = false
|
7
7
|
|
8
|
-
# Error handling: object without proper identifier setup
|
9
8
|
class ::BadIdentifierTest < Familia::Horreum
|
9
|
+
# Error handling: object without proper identifier setup
|
10
10
|
# No identifier method defined - should cause issues
|
11
11
|
end
|
12
12
|
|
13
13
|
@bad_obj = ::BadIdentifierTest.new
|
14
14
|
|
15
|
-
# Test polymorphic string usage for Familia objects
|
16
|
-
@customer_id = 'customer-string-coercion-test'
|
15
|
+
@customer_id = 'customer-string-coercion-test' # Test polymorphic string usage for Familia objects
|
17
16
|
@customer = Customer.new(@customer_id)
|
18
17
|
@customer.name = 'John Doe'
|
19
18
|
@customer.planid = 'premium'
|
@@ -25,8 +24,7 @@ end
|
|
25
24
|
@session.useragent = 'Test Browser'
|
26
25
|
@session.save
|
27
26
|
|
28
|
-
|
29
|
-
@bone = Bone.new
|
27
|
+
@bone = Bone.new # Complex identifier test with array-based identifier
|
30
28
|
@bone.token = 'test_token'
|
31
29
|
@bone.name = 'test_name'
|
32
30
|
|
metadata
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: familia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: logger
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
13
26
|
- !ruby/object:Gem::Dependency
|
14
27
|
name: redis
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,7 +145,6 @@ licenses:
|
|
132
145
|
- MIT
|
133
146
|
metadata:
|
134
147
|
rubygems_mfa_required: 'true'
|
135
|
-
post_install_message:
|
136
148
|
rdoc_options: []
|
137
149
|
require_paths:
|
138
150
|
- lib
|
@@ -147,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
159
|
- !ruby/object:Gem::Version
|
148
160
|
version: '0'
|
149
161
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
151
|
-
signing_key:
|
162
|
+
rubygems_version: 3.6.9
|
152
163
|
specification_version: 4
|
153
164
|
summary: An ORM for Redis in Ruby.
|
154
165
|
test_files: []
|