valkey-objects 0.1.0 → 0.1.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
  SHA256:
3
- metadata.gz: '0812801baee7485f097e11e3edeccc34cbd6dfbf8f057db3193141e6a7a936c0'
4
- data.tar.gz: c2865f06b3a7d8032ca23451b5fd0bb0e49de3ae331e1f0106f051eb471a960d
3
+ metadata.gz: 5d03e92ca33a8464f359b2c274cf0532ad8d61c37508e616c95a53257f0f9ae8
4
+ data.tar.gz: 1d9d8cf373c6bfc25df5b19bdaa25518f9a37335941d2d90e83e2014674bff4a
5
5
  SHA512:
6
- metadata.gz: f5d83247f95f62b696d0fcb5ce26376e9cc8e83b76d268fe92c24df4eedc5787f3622fd0601ad7368a02b86b49789c7774040cf7cebd02f54859560d42afc8bf
7
- data.tar.gz: 9a29d72d9b648fbf8f5ff3d9e8dad53b8436a844d58411e0e5bf492abaae17b524b621e7cbae227665a5b9d11b8729156dec5511a6da92259adfebced73fc7df
6
+ metadata.gz: 878958d481d68dd9d066411cf66479772055cac8bfd74dfd4dbc37ced8628581c2d03f1fabb4fc3d6eb1265e440bc31d280683dc93fa8e8e4ae1752cf76b3d37
7
+ data.tar.gz: 9f6a3e4824e27cdcb1c4ee0e9d6931b9a8d8af682d93892950285a609a5dba0ce571d4f15e309e62ef07d234e45031fb76175d55fe98ef6c24cc635b287078a5
data/#class.rb# ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'valkey/objects'
4
+
5
+ require 'pry'
6
+
7
+ class Game
8
+ include VK
9
+ sortedset :points
10
+ queue :log
11
+ def initialize k
12
+ @id = k
13
+ end
14
+ def score p, h={ points: 1 }
15
+ self.points.poke p, h[:points]
16
+ end
17
+ end
18
+
19
+ @game = Hash.new { |h,k| h[k] = Game.new(k) }
20
+
21
+ Pry.start
data/.#class.rb ADDED
@@ -0,0 +1 @@
1
+ erik@z4-home.3169:1729306329
data/README.md CHANGED
@@ -1,39 +1,97 @@
1
- # Valkey::Objects
2
-
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/valkey/objects`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- ## Installation
8
-
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
-
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
-
29
- ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/valkey-objects. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/valkey-objects/blob/master/CODE_OF_CONDUCT.md).
32
-
33
- ## License
34
-
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
-
37
- ## Code of Conduct
38
-
39
- Everyone interacting in the Valkey::Objects project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/valkey-objects/blob/master/CODE_OF_CONDUCT.md).
1
+ # ValKey Objects
2
+ Based upon the redis-objects library, VK allows for ValKey backed ruby objects.
3
+
4
+ ## installation
5
+ ```
6
+ gem install valkey-objects
7
+ ```
8
+
9
+ ## usage
10
+
11
+ ### simple
12
+ ```
13
+ require 'valkey/objects'
14
+ class ValKey
15
+ # 1. include valkey-objects layer
16
+ include VK
17
+ # 2. stitch your object together.
18
+ value :myvalue
19
+ counter :mycounter
20
+ hashkey :myhash
21
+ sortedset :mysortedset
22
+ set :myset
23
+ queue :myqueue
24
+ place :myplace
25
+ pipe :mypipe
26
+ toggle :mytoggle
27
+ # 3. define @id in initialize.
28
+ def initialize k
29
+ @id = k
30
+ end
31
+ # other stuff...
32
+ end
33
+
34
+ @x = ValKey.new("My Special Valkey object.")
35
+ @x.mypipe.on { |msg| puts %[MSG]; ap msg }
36
+ @x.mypipe << "Pipe Connected!"
37
+ @x.myvalue.value = "Hello, World"
38
+ @x.mycounter.value = 1.2345
39
+ @x.myhash[:key] = "Value"
40
+ @x.mysortedset["my other key"] = 9.8
41
+ @x.mysortedset.poke "my key", @x.mysortedset["my other key"]
42
+ @x.mysortedset.value { |i, e| puts %[Sorted Sets: i: #{i} e: #{e}] }
43
+ @x.myset << "my member"
44
+ @x.myset << "my new member"
45
+ h = @x.myset[/ new /]
46
+ @x.myset.value { |i, e| puts %[Sets: i: #{i} e: #{e}] }
47
+ @x.myplace.add "Palermo", 13.361389, 38.115556
48
+ @x.myplace.add "Catania", 15.087269, 37.502669
49
+ distance = @x.myplace.distance "Palermo", "Catania"
50
+ places = @x.myplace.radius 15.087269, 37.502669, 5000
51
+ @x.myplace.value { |i, e| puts %[Places: i: #{i} e: #{e}] }
52
+ ```
53
+
54
+ ### advanced
55
+ ```
56
+ class Game
57
+ include VK
58
+ sortedset :points
59
+ def initialize k
60
+ @id = k
61
+ end
62
+ def score p, h={ points: 1 }
63
+ self.points.poke p, h[:points]
64
+ end
65
+ end
66
+
67
+ @game = Hash.new { |h,k| h[k] = Game.new(k) }
68
+ ```
69
+
70
+ ### modular
71
+ ```
72
+ module X
73
+ @@X = Hash.new { |h,k| h[k] = Ex.new(k) }
74
+ class Ex
75
+ include VK
76
+ set :stuff
77
+ pipe :ear
78
+ def initialize k
79
+ @id = k
80
+ end
81
+ end
82
+ def self.keys
83
+ @@X.keys
84
+ end
85
+ def self.[] k
86
+ if !@@X.has_key?(k)
87
+ @@X[k].ear.on { |msg| puts "MSG[#{k}]:"; ap msg }
88
+ end
89
+ @@X[k]
90
+ end
91
+ end
92
+
93
+ X['Aaa'].ear << %[A]
94
+ X['Bbb'].ear << %[B]
95
+ X['Ccc'].ear << %[C]
96
+
97
+ ```
data/class.rb~ ADDED
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'valkey/objects'
4
+
5
+ # Using ValKey Objects
6
+ ## Create your class object
7
+ class ValKey
8
+ # 1. include valkey-objects layer
9
+ include VK
10
+ # 2. stitch your object together.
11
+ value :myvalue
12
+ counter :mycounter
13
+ hashkey :myhash
14
+ sortedset :mysortedset
15
+ set :myset
16
+ queue :myqueue
17
+ place :myplace
18
+ pipe :mypipe
19
+ toggle :mytoggle
20
+ # 3. define @id in initialize.
21
+ def initialize k
22
+ @id = k
23
+ end
24
+ # other stuff...
25
+ end
26
+
27
+ ## then user it.
28
+ puts %[=== Valkey Object Test ===]
29
+ @x = ValKey.new("My Special Valkey object.")
30
+ #### pub/sub pipe
31
+ ##### on message
32
+ @x.mypipe.on { |msg| puts %[MSG]; ap msg }
33
+ ##### publish message
34
+ @x.mypipe << "Pipe Connected!"
35
+ ### get/set string value...
36
+ @x.myvalue.value = "Hello, World"
37
+ ### get/set/incr/decr float value...
38
+ @x.mycounter.value = 1.2345
39
+ ### get/set key/value pairs...
40
+ @x.myhash[:key] = "Value"
41
+ ### sort keys by score...
42
+ #### set
43
+ @x.mysortedset["my other key"] = 9.8
44
+ #### poke/get
45
+ @x.mysortedset.poke "my key", @x.mysortedset["my other key"]
46
+ #### by high score
47
+ @x.mysortedset.value { |i, e| ap %[Sorted Sets: i: #{i} e: #{e}] }
48
+ ### collect keys...
49
+ @x.myset << "my member"
50
+ @x.myset << "my new member"
51
+ #### filter by regexp...
52
+ h = @x.myset[/ new /]
53
+ puts %[Filtered set members:]
54
+ ap h
55
+ #### each collection key....
56
+ @x.myset.value { |i, e| puts %[Sets: i: #{i} e: #{e}] }
57
+ ### points by coordinates...
58
+ @x.myplace.add "Palermo", 13.361389, 38.115556
59
+ @x.myplace.add "Catania", 15.087269, 37.502669
60
+ #### distance between points.
61
+ distance = @x.myplace.distance "Palermo", "Catania"
62
+ ap %[The meters between the points: #{distance}]
63
+ #### places within radius by coordinates
64
+ places = @x.myplace.radius 15.087269, 37.502669, 5000
65
+ ap %[The places within 5000 meters of the coordinates: #{places}]
66
+ puts %[Place Values...]
67
+ #### collection of places...
68
+ @x.myplace.value { |i, e| puts %[Places: i: #{i} e: #{e}] }
69
+ ap VK['*']
70
+
71
+
72
+
73
+ ## Or as a collection of "X"s...
74
+ module X
75
+ @@X = Hash.new { |h,k| h[k] = Ex.new(k) }
76
+ class Ex
77
+ include VK
78
+ set :stuff
79
+ pipe :ear
80
+ def initialize k
81
+ @id = k
82
+ end
83
+ end
84
+ def self.keys
85
+ @@X.keys
86
+ end
87
+ def self.[] k
88
+ if !@@X.has_key?(k)
89
+ @@X[k].ear.on { |msg| puts "MSG[#{k}]:"; ap msg }
90
+ end
91
+ @@X[k]
92
+ end
93
+ end
94
+
95
+ @x[:a] = X['Aaa']
96
+ @x[:b] = X['Bbb']
97
+ @x[:c] = X['Ccc']
data/example.rb~ ADDED
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'valkey/objects'
4
+
5
+ # Using ValKey Objects
6
+ ## Create your class object
7
+ class ValKey
8
+ # 1. include valkey-objects layer
9
+ include VK
10
+ # 2. stitch your object together.
11
+ value :myvalue
12
+ counter :mycounter
13
+ hashkey :myhash
14
+ sortedset :mysortedset
15
+ set :myset
16
+ queue :myqueue
17
+ place :myplace
18
+ pipe :mypipe
19
+ toggle :mytoggle
20
+ # 3. define @id in initialize.
21
+ def initialize k
22
+ @id = k
23
+ end
24
+ # other stuff...
25
+ end
26
+
27
+
28
+
29
+ require 'awesome_print'
30
+
31
+ @x = {}
32
+
33
+ ## then user it.
34
+ puts %[=== Valkey Object Test ===]
35
+ @x[:x] = ValKey.new("My Special Valkey object.")
36
+ #### pub/sub pipe
37
+ ##### on message
38
+ @x[:x].mypipe.on { |msg| puts %[MSG]; ap msg }
39
+ ##### publish message
40
+ @x[:x].mypipe << "Pipe Connected!"
41
+ ### get/set string value...
42
+ @x[:x].myvalue.value = "Hello, World"
43
+ ### get/set/incr/decr float value...
44
+ @x[:x].mycounter.value = 1.2345
45
+ ### get/set key/value pairs...
46
+ @x[:x].myhash[:key] = "Value"
47
+ ### sort keys by score...
48
+ #### set
49
+ @x[:x].mysortedset["my other key"] = 9.8
50
+ #### poke/get
51
+ @x[:x].mysortedset.poke "my key", @x[:x].mysortedset["my other key"]
52
+ #### by high score
53
+ @x[:x].mysortedset.value { |i, e| ap %[Sorted Sets: i: #{i} e: #{e}] }
54
+ ### collect keys...
55
+ @x[:x].myset << "my member"
56
+ @x[:x].myset << "my new member"
57
+ #### filter by regexp...
58
+ h = @x[:x].myset[/ new /]
59
+ puts %[Filtered set members:]
60
+ ap h
61
+ #### each collection key....
62
+ @x[:x].myset.value { |i, e| puts %[Sets: i: #{i} e: #{e}] }
63
+ ### points by coordinates...
64
+ @x[:x].myplace.add "Palermo", 13.361389, 38.115556
65
+ @x[:x].myplace.add "Catania", 15.087269, 37.502669
66
+ #### distance between points.
67
+ distance = @x[:x].myplace.distance "Palermo", "Catania"
68
+ ap %[The meters between the points: #{distance}]
69
+ #### places within radius by coordinates
70
+ places = @x[:x].myplace.radius 15.087269, 37.502669, 5000
71
+ ap %[The places within 5000 meters of the coordinates: #{places}]
72
+ puts %[Place Values...]
73
+ #### collection of places...
74
+ @x[:x].myplace.value { |i, e| puts %[Places: i: #{i} e: #{e}] }
75
+ ap VK['*']
76
+
77
+ ## Or as a collection of "X"s...
78
+ module X
79
+ @@X = Hash.new { |h,k| h[k] = Ex.new(k) }
80
+ class Ex
81
+ include VK
82
+ set :stuff
83
+ pipe :ear
84
+ def initialize k
85
+ @id = k
86
+ end
87
+ end
88
+ def self.keys
89
+ @@X.keys
90
+ end
91
+ def self.[] k
92
+ if !@@X.has_key?(k)
93
+ @@X[k].ear.on { |msg| puts "MSG[#{k}]:"; ap msg }
94
+ end
95
+ @@X[k]
96
+ end
97
+ end
98
+
99
+ @x[:a] = X['Aaa']
100
+ @x[:b] = X['Bbb']
101
+ @x[:c] = X['Ccc']
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Valkey
4
4
  module Objects
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
@@ -3,21 +3,67 @@
3
3
  require_relative "objects/version"
4
4
 
5
5
  require 'redis-client'
6
+ require 'json'
7
+ require 'ruby-duration'
8
+
6
9
  module VK
7
10
  def self.included(x)
8
11
  x.extend VK
9
12
  end
10
13
 
11
14
  def self.extended(x)
12
- define_method(:value) { |k| define_method(k.to_sym) { V.new(%[#{x}:V:#{k}:#{@id}]) } };
13
- define_method(:counter) { |k| define_method(k.to_sym) { C.new(%[#{x}:C:#{k}:#{@id}]); } };
14
- define_method(:hashkey) { |k| define_method(k.to_sym) { H.new(%[#{x}:H:#{k}:#{@id}]); } };
15
- define_method(:sortedset) { |k| define_method(k.to_sym) { S.new(%[#{x}:S:#{k}:#{@id}]); } };
16
- define_method(:set) { |k| define_method(k.to_sym) { G.new(%[#{x}:S:#{k}:#{@id}]); } };
17
- define_method(:queue) { |k| define_method(k.to_sym) { Q.new(%[#{x}:Q:#{k}:#{@id}]); } };
18
- define_method(:place) { |k| define_method(k.to_sym) { P.new(%[#{x}:P:#{k}:#{@id}]); } };
15
+ xx = x.name.gsub("::", "-")
16
+ define_method(:value) { |k| define_method(k.to_sym) { V.new(%[#{xx}:value:#{k}:#{@id}]) } };
17
+ define_method(:counter) { |k| define_method(k.to_sym) { C.new(%[#{xx}:counter:#{k}:#{@id}]); } };
18
+ define_method(:hashkey) { |k| define_method(k.to_sym) { H.new(%[#{xx}:hash:#{k}:#{@id}]); } };
19
+ define_method(:sortedset) { |k| define_method(k.to_sym) { S.new(%[#{xx}:sortedset:#{k}:#{@id}]); } };
20
+ define_method(:set) { |k| define_method(k.to_sym) { G.new(%[#{xx}:set:#{k}:#{@id}]); } };
21
+ define_method(:queue) { |k| define_method(k.to_sym) { Q.new(%[#{xx}:queue:#{k}:#{@id}]); } };
22
+ define_method(:place) { |k| define_method(k.to_sym) { P.new(%[#{xx}:place:#{k}:#{@id}]); } };
23
+ define_method(:pipe) { |k| define_method(k.to_sym) { B.new(%[#{xx}:pipe:#{k}:#{@id}]); } };
24
+ define_method(:toggle) { |k| define_method(k.to_sym) { T.new(%[#{xx}:toggle:#{k}:#{@id}]); } };
25
+ end
26
+
27
+ def id
28
+ @id
19
29
  end
20
30
 
31
+ module AGO
32
+ class Error < StandardError; end
33
+ class Clock
34
+ def initialize t
35
+ @t = AGO.now
36
+ @s = @t.to_i - t.to_i
37
+ @t = Time.new(t.to_i).utc
38
+ @d = Duration.new(@s.abs)
39
+ end
40
+ def to_i
41
+ @s
42
+ end
43
+ def to_s *s
44
+ if s[0]
45
+ @d.format(s[0])
46
+ else
47
+ @d.format('%w %~w %d %~d %H:%M:%S')
48
+ end
49
+ end
50
+ end
51
+ def self.now
52
+ Time.now.utc
53
+ end
54
+ def self.[] k
55
+ Clock.new(k)
56
+ end
57
+ end
58
+
59
+ def self.clock *t
60
+ if t[0]
61
+ AGO[t[0]]
62
+ else
63
+ AGO.now
64
+ end
65
+ end
66
+
21
67
  def self.redis
22
68
  RedisClient.config(host: "127.0.0.1", port: 6379, db: 0).new_client
23
69
  end
@@ -28,6 +74,51 @@ module VK
28
74
  @key = k
29
75
  end
30
76
  end
77
+
78
+ class T < O
79
+ def value
80
+ VK.redis.call("GET", key) == 'true' ? true : false
81
+ end
82
+ def value= x
83
+ VK.redis.call("SET", key, "#{x.to_s}")
84
+ end
85
+ def value!
86
+ if self.value
87
+ self.value = false
88
+ else
89
+ self.value = true
90
+ end
91
+ end
92
+ end
93
+
94
+ class B < O
95
+ def on &b
96
+ pubsub = VK.redis.pubsub
97
+ pubsub.call("SUBSCRIBE", key)
98
+ Process.detach( fork do
99
+ loop do
100
+ if m = pubsub.next_event(0)
101
+ cn, ty, na, id = key.split(":")
102
+ if m[0] == "message"
103
+ b.call({ stub: na, object: cn.gsub("-", "::"), type: ty, id: id, event: m[0], data: JSON.parse(m[2]) })
104
+ else
105
+ ap({ stub: na, object: cn.gsub("-", "::"), type: ty, id: id, event: m[0], data: m[2] })
106
+ end
107
+ end
108
+ end
109
+ end
110
+ );
111
+ end
112
+ def << x
113
+ if x.class == String
114
+ VK.redis.call("PUBLISH", key, JSON.generate({ input: x }))
115
+ elsif x.class == Array
116
+ VK.redis.call("PUBLISH", key, JSON.generate({ inputs: x }))
117
+ elsif x.class == Hash
118
+ VK.redis.call("PUBLISH", key, JSON.generate(x))
119
+ end
120
+ end
121
+ end
31
122
 
32
123
  class V < O
33
124
  def value
@@ -47,7 +138,10 @@ module VK
47
138
  end
48
139
  def value
49
140
  VK.redis.call("GET", key).to_f
50
- end
141
+ end
142
+ def value= n
143
+ VK.redis.call("SET", key, n.to_f)
144
+ end
51
145
  end
52
146
 
53
147
  class H < O
@@ -60,6 +154,9 @@ module VK
60
154
  end
61
155
 
62
156
  class Q < O
157
+ def value &b
158
+ VK.redis.call("LRANGE", key, 0, -1, 'WITHSCORES').each_with_index { |e, i| b.call(i, e) }
159
+ end
63
160
  def length
64
161
  VK.redis.call("LLEN", key)
65
162
  end
@@ -73,7 +170,7 @@ module VK
73
170
 
74
171
  class S < O
75
172
  def value &b
76
- VK.redis.call("ZREVRANGE", key, 0, -1, 'WITHSCORES').each_with_index { |e, i| b.call(i, e[0], e[1]) }
173
+ VK.redis.call("ZREVRANGE", key, 0, -1, 'WITHSCORES').each_with_index { |e, i| b.call(i, e) }
77
174
  end
78
175
  def [] k
79
176
  VK.redis.call("ZSCORE", key, k).to_f;
@@ -87,8 +184,8 @@ module VK
87
184
  end
88
185
 
89
186
  class G < O
90
- def value
91
- VK.redis.call("SMEMBERS", key)
187
+ def value &b
188
+ VK.redis.call("SMEMBERS", key).each_with_index { |e, i| b.call(i, e) }
92
189
  end
93
190
  def length
94
191
  VK.redis.call("SCARD", key)
@@ -105,11 +202,16 @@ module VK
105
202
  def | k
106
203
  VK.redis.call("SUNION", key, k.key)
107
204
  end
205
+ def [] k
206
+ r, h = Regexp.new(k), {}
207
+ VK.redis.call("SMEMBERS", key).each { |e| if m = r.match(e); h[e] = m; end; }
208
+ return h
209
+ end
108
210
  end
109
-
211
+
110
212
  class P < O
111
- def value
112
- VK.redis.call("ZRANGE", key, 0, -1);
213
+ def value &b
214
+ VK.redis.call("ZRANGE", key, 0, -1).each_with_index { |e, i| b.call(i, e) };
113
215
  end
114
216
  def add i, lon, lat
115
217
  VK.redis.call("GEOADD", key, lon, lat, i)
@@ -127,6 +229,14 @@ module VK
127
229
  return h
128
230
  end
129
231
  end
232
+ def self.flushdb!
233
+ VK.redis.call("FLUSHDB")
234
+ end
235
+ def self.[] k
236
+ VK.redis.call("KEYS", k)
237
+ end
130
238
  end
131
239
 
132
240
 
241
+
242
+
data/module.rb~ ADDED
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'valkey/objects'
4
+
5
+ # Using ValKey Objects
6
+ ## Create your class object
7
+ class ValKey
8
+ # 1. include valkey-objects layer
9
+ include VK
10
+ # 2. stitch your object together.
11
+ value :myvalue
12
+ counter :mycounter
13
+ hashkey :myhash
14
+ sortedset :mysortedset
15
+ set :myset
16
+ queue :myqueue
17
+ place :myplace
18
+ pipe :mypipe
19
+ toggle :mytoggle
20
+ # 3. define @id in initialize.
21
+ def initialize k
22
+ @id = k
23
+ end
24
+ # other stuff...
25
+ end
26
+
27
+
28
+
29
+ require 'awesome_print'
30
+
31
+ @x = {}
32
+
33
+ ## Or as a collection of "X"s...
34
+ module X
35
+ @@X = Hash.new { |h,k| h[k] = Ex.new(k) }
36
+ class Ex
37
+ include VK
38
+ set :stuff
39
+ pipe :ear
40
+ def initialize k
41
+ @id = k
42
+ end
43
+ end
44
+ def self.keys
45
+ @@X.keys
46
+ end
47
+ def self.[] k
48
+ if !@@X.has_key?(k)
49
+ @@X[k].ear.on { |msg| puts "MSG[#{k}]:"; ap msg }
50
+ end
51
+ @@X[k]
52
+ end
53
+ end
54
+
55
+ X['Aaa'].ear << %[A]
56
+ X['Bbb'].ear << %[B]
57
+ X['Ccc'].ear << %[C]
Binary file
@@ -32,7 +32,9 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  # Uncomment to register a new dependency of your gem
34
34
  spec.add_dependency "redis-client"
35
-
35
+ spec.add_dependency "awesome_print"
36
+ spec.add_dependency "json"
37
+ spec.add_dependency "ruby-duration"
36
38
  # For more information and examples about making a new gem, check out our
37
39
  # guide at: https://bundler.io/guides/creating_gem.html
38
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valkey-objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Olson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-18 00:00:00.000000000 Z
11
+ date: 2024-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client
@@ -24,6 +24,48 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: awesome_print
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-duration
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
27
69
  description: A ruby valkey client inspired by the redis-objects gem.
28
70
  email:
29
71
  - xorgnak@gmail.com
@@ -31,14 +73,20 @@ executables: []
31
73
  extensions: []
32
74
  extra_rdoc_files: []
33
75
  files:
76
+ - "#class.rb#"
77
+ - ".#class.rb"
34
78
  - CHANGELOG.md
35
79
  - CODE_OF_CONDUCT.md
36
80
  - LICENSE.txt
37
81
  - README.md
38
82
  - Rakefile
83
+ - class.rb~
84
+ - example.rb~
39
85
  - lib/valkey/objects.rb
40
86
  - lib/valkey/objects/version.rb
87
+ - module.rb~
41
88
  - sig/valkey/objects.rbs
89
+ - valkey-objects-0.1.0.gem
42
90
  - valkey-objects.gemspec
43
91
  homepage: https://github.com/xorgnak/valkey-client
44
92
  licenses: