familia 0.9.3 → 0.10.0

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: 41c7c66be20ea8a959ec23a2cbf7124ad7bd78e7fd63949ee97dbdee85461207
4
- data.tar.gz: 3befcbeb6154d9efe92ec3bf519fb8e14257f7ad6b4f09a2a348782745f45374
3
+ metadata.gz: 85be10b89ba21af81625429bd874cb415ea83325c52811cbf73ccadb436e83ad
4
+ data.tar.gz: 0c60a40a22069927164afc9c3426f294f7b7d4e5066f5197c206a0940fc8b16a
5
5
  SHA512:
6
- metadata.gz: 54b20874123486ea007225c8aa5953a8d08a9682f13cec3cd208c9c73d4ec2d91a42fa13a2d81f2709e9b5977a91d169cf2e356c2975da0e752893a9305c6cfa
7
- data.tar.gz: 6fdd2f5713f8ba9e1cfcf51bd508b28212f92ab829514bb5c78cd151c3679451ef7ac71b01930c9f2aa521178599f94fcabe3a6ec2772128dc5880167db12d91
6
+ metadata.gz: 57d68342db867a3e472b6a1c27b3d9f1c728d7b8ca821caf79d80d44f03fca0546263532ea5e43659cd379331d421a666b0fb94dd707de248f5453bfb0c527be
7
+ data.tar.gz: 1251c83b61231e5b392da125b88cc8312b65d6892df285f6fed3ef4a12d354304c5f3a21f5d6f5cc95f2479ad04b53a98783e0429868d469c224506f46a41f70
@@ -0,0 +1,69 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ include:
17
+ - ruby: '3.3'
18
+ bundler: latest
19
+ rubygems: latest
20
+
21
+ - ruby: '3.2'
22
+ bundler: latest
23
+ rubygems: latest
24
+
25
+ - ruby: '3.1'
26
+ bundler: latest
27
+ rubygems: latest
28
+
29
+ - ruby: '3.0'
30
+ bundler: latest
31
+ rubygems: latest
32
+
33
+ - ruby: '2.7'
34
+ bundler: '2.4.22'
35
+ rubygems: '3.2.3'
36
+
37
+ services:
38
+ redis:
39
+ image: redis:bookworm@sha256:e422889e156ebea83856b6ff973bfe0c86bce867d80def228044eeecf925592b
40
+ # Set health checks to wait until redis has started
41
+ options: >-
42
+ --health-cmd "redis-cli ping"
43
+ --health-interval 10s
44
+ --health-timeout 3s
45
+ --health-retries 5
46
+ ports:
47
+ # https://docs.github.com/en/actions/using-containerized-services/creating-redis-service-containers#running-jobs-in-containers
48
+ # Maps port 6379 on service container to the host
49
+ - 6379:6379
50
+
51
+ steps:
52
+ - uses: actions/checkout@v3
53
+ - name: Set up Ruby
54
+ uses: ruby/setup-ruby@v1
55
+ with:
56
+ ruby-version: ${{ matrix.ruby }}
57
+ rubygems: ${{ matrix.rubygems }}
58
+ bundler: ${{ matrix.bundler }}
59
+ # When the following is true, also run "bundle install",
60
+ # and cache the result automatically. Ran into an issue
61
+ # with the caching and multiple ruby versions. Needs
62
+ # further investigation.
63
+ bundler-cache: false
64
+
65
+ - name: Re-run bundle install
66
+ run: bundle install
67
+
68
+ - name: Run the tryouts
69
+ run: bundle exec try -v
@@ -0,0 +1,69 @@
1
+ ##
2
+ # Pre-Commit Configuration
3
+ #
4
+ # Initial setup:
5
+ #
6
+ # 0. Install the pre-commit framework (if it isn't already on your system):
7
+
8
+ # $ pip install pre-commit
9
+ #
10
+ # 1. Install the git hook:
11
+ #
12
+ # $ pre-commit install
13
+ #
14
+ #
15
+ # Other commands:
16
+ #
17
+ # Run it on all the files in this repo:
18
+ # $ pre-commit run --all-files
19
+ #
20
+ # Updating plugin repositories:
21
+ # $ pre-commit autoupdate
22
+ #
23
+ # Automatically enable pre-commit on repositories
24
+ # $ git config --global init.templateDir ~/.git-template
25
+ # $ pre-commit init-templatedir ~/.git-template
26
+ #
27
+ # See also:
28
+ # - https://pre-commit.com for more information
29
+ # - https://pre-commit.com/hooks.html for more hooks
30
+ #
31
+
32
+ default_install_hook_types:
33
+ - pre-commit
34
+ - prepare-commit-msg
35
+
36
+ fail_fast: true
37
+
38
+ repos:
39
+ - repo: meta
40
+ hooks:
41
+ - id: check-hooks-apply
42
+ - id: check-useless-excludes
43
+ - id: identity
44
+
45
+ - repo: https://github.com/pre-commit/pre-commit-hooks
46
+ rev: v4.6.0
47
+ hooks:
48
+ - id: trailing-whitespace
49
+ - id: end-of-file-fixer
50
+ - id: check-yaml
51
+ - id: detect-private-key
52
+ - id: mixed-line-ending
53
+ - id: check-added-large-files
54
+ args: ["--maxkb=1000"]
55
+ - id: no-commit-to-branch
56
+ args: ["--branch", "develop", "--branch", "rel/.*"]
57
+ - id: check-merge-conflict
58
+ - id: forbid-submodules
59
+
60
+ - repo: https://github.com/avilaton/add-msg-issue-prefix-hook
61
+ rev: v0.0.11
62
+ hooks:
63
+ - id: add-msg-issue-prefix
64
+ stages: [prepare-commit-msg]
65
+ name: Link commit to Github issue
66
+ args:
67
+ - "--default=[NOJIRA]"
68
+ - "--pattern=[a-zA-Z0-9]{0,10}-?[0-9]{1,5}"
69
+ - "--template=[#{}]"
data/Gemfile CHANGED
@@ -1,13 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby '>= 2.6.8'
3
+ ruby '>= 2.7.8'
4
4
 
5
- gem 'redis', '>= 4.8', '< 7'
6
- gem 'uri-redis'
7
- gem 'gibbler'
8
- gem 'storable'
9
- gem 'multi_json'
5
+ gem 'redis', '>= 4.8.1', '< 6.0'
6
+ gem 'uri-redis', '>= 1.3.0'
7
+ gem 'gibbler', '~> 1.0.0'
8
+ gem 'storable', '~> 0.10.0'
9
+ gem 'multi_json', '~> 1.15'
10
10
 
11
11
  group :development, :test do
12
- gem 'tryouts', '~> 2.2'
12
+ gem 'pry-byebug', '~> 3.10.1', require: false
13
+ gem 'tryouts', '~> 2.2', require: false
13
14
  end
data/Gemfile.lock CHANGED
@@ -1,36 +1,51 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- attic (1.0.0)
4
+ attic (1.0.1)
5
5
  rake (~> 13.0.6)
6
+ byebug (11.1.3)
7
+ coderay (1.1.3)
8
+ connection_pool (2.4.1)
6
9
  drydock (0.6.9)
7
10
  gibbler (1.0.0)
8
11
  attic (~> 1.0)
9
12
  rake (~> 13.0)
13
+ method_source (1.1.0)
10
14
  multi_json (1.15.0)
15
+ pry (0.14.2)
16
+ coderay (~> 1.1)
17
+ method_source (~> 1.0)
18
+ pry-byebug (3.10.1)
19
+ byebug (~> 11.0)
20
+ pry (>= 0.13, < 0.15)
11
21
  rake (13.0.6)
12
- redis (4.8.1)
22
+ redis (5.2.0)
23
+ redis-client (>= 0.22.0)
24
+ redis-client (0.22.2)
25
+ connection_pool
13
26
  storable (0.10.0)
14
27
  sysinfo (0.10.0)
15
28
  drydock (< 1.0)
16
29
  storable (~> 0.10)
17
30
  tryouts (2.2.0)
18
31
  sysinfo (~> 0.10)
19
- uri-redis (0.4.2)
32
+ uri-redis (1.3.0)
20
33
 
21
34
  PLATFORMS
22
- arm64-darwin-22
35
+ arm64-darwin-24
36
+ ruby
23
37
 
24
38
  DEPENDENCIES
25
- gibbler
26
- multi_json
27
- redis (~> 4.8)
28
- storable
39
+ gibbler (~> 1.0.0)
40
+ multi_json (~> 1.15)
41
+ pry-byebug (~> 3.10.1)
42
+ redis (>= 4.8.1, < 6.0)
43
+ storable (~> 0.10.0)
29
44
  tryouts (~> 2.2)
30
- uri-redis
45
+ uri-redis (>= 1.3.0)
31
46
 
32
47
  RUBY VERSION
33
- ruby 2.6.8p205
48
+ ruby 3.2.4p170
34
49
 
35
50
  BUNDLED WITH
36
- 2.4.12
51
+ 2.5.9
data/README.md CHANGED
@@ -1,7 +1,14 @@
1
- # Familia - 0.9 (2024-04-04)
1
+ # Familia - 0.10.0
2
2
 
3
- **Organize and store ruby objects in Redis**
3
+ **Organize and store ruby objects in Redis. A Ruby ORM for Redis.**
4
4
 
5
+ ## Installation
6
+
7
+ Get it in one of the following ways:
8
+
9
+ * In your Gemfile: `gem 'familia', '>= 0.10.0'`
10
+ * Install it by hand: `gem install familia`
11
+ * Or for development: `git clone git@github.com:delano/familia.git`
5
12
 
6
13
  ## Basic Example
7
14
 
@@ -21,4 +28,5 @@
21
28
 
22
29
  ## More Information
23
30
 
24
- * [Codes](https://github.com/delano/familia)
31
+ * [Github](https://github.com/delano/familia)
32
+ * [Rubygems](https://rubygems.org/gems/familia)
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :MAJOR: 0
3
- :MINOR: 9
4
- :PATCH: 3
3
+ :MINOR: 10
4
+ :PATCH: 0
data/familia.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "familia"
3
- s.version = "0.9.3"
3
+ s.version = "0.10.0"
4
4
  s.summary = "Organize and store ruby objects in Redis"
5
5
  s.description = "Familia: #{s.summary}"
6
6
  s.authors = ["Delano Mandelbaum"]
7
- s.email = "delano@solutious.com"
7
+ s.email = "gems@solutious.com"
8
8
  s.homepage = "https://github.com/delano/familia"
9
9
  s.license = "MIT"
10
10
 
@@ -13,11 +13,5 @@ Gem::Specification.new do |s|
13
13
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
14
14
  s.require_paths = ["lib"]
15
15
 
16
- s.required_ruby_version = Gem::Requirement.new(">= 2.6.8")
17
-
18
- s.add_dependency "redis", ">= 4.8", "< 7"
19
- s.add_dependency "uri-redis", ">= 1.0.0"
20
- s.add_dependency "gibbler", "~> 1.0.0"
21
- s.add_dependency "storable", "~> 0.10.0"
22
- s.add_dependency "multi_json", "~> 1.15"
16
+ s.required_ruby_version = Gem::Requirement.new(">= 2.7.8")
23
17
  end
@@ -46,7 +46,7 @@ module Familia
46
46
  end
47
47
  end
48
48
 
49
- attr_reader :name, :parent
49
+ attr_reader :name, :parent, :opts
50
50
  attr_writer :redis
51
51
 
52
52
  # RedisObject instances are frozen. `cache` is a hash
@@ -260,7 +260,7 @@ module Familia
260
260
  def to_redis v
261
261
  return v unless @opts[:class]
262
262
  ret = case @opts[:class]
263
- when ::Symbol, ::String, ::Fixnum, ::Float, Gibbler::Digest
263
+ when ::Symbol, ::String, ::Integer, ::Float, Gibbler::Digest
264
264
  v
265
265
  else
266
266
  if ::String === v
@@ -297,7 +297,7 @@ module Familia
297
297
  v.to_s
298
298
  when ::Symbol
299
299
  v.to_s.to_sym
300
- when ::Fixnum, ::Float
300
+ when ::Integer, ::Float
301
301
  @opts[:class].induced_from v
302
302
  else
303
303
  objs = values
@@ -734,7 +734,7 @@ module Familia
734
734
  #
735
735
  # sorted_sets.rb:374:in `zrevrange': wrong number of arguments (given 4, expected 3) (ArgumentError)
736
736
  #
737
- redis.zrange(rediskey, sidx, eidx, :withscores => opts[:withscores])
737
+ redis.zrange(rediskey, sidx, eidx, **opts)
738
738
  end
739
739
 
740
740
  def revrange sidx, eidx, opts={}
@@ -744,7 +744,7 @@ module Familia
744
744
  end
745
745
 
746
746
  def revrangeraw sidx, eidx, opts={}
747
- redis.zrevrange(rediskey, sidx, eidx, :withscores => opts[:withscores])
747
+ redis.zrevrange(rediskey, sidx, eidx, **opts)
748
748
  end
749
749
 
750
750
  # e.g. obj.metrics.rangebyscore (now-12.hours), now, :limit => [0, 10]
@@ -756,7 +756,7 @@ module Familia
756
756
 
757
757
  def rangebyscoreraw sscore, escore, opts={}
758
758
  echo :rangebyscoreraw, caller[0] if Familia.debug
759
- redis.zrangebyscore(rediskey, sscore, escore, :withscores => opts[:withscores])
759
+ redis.zrangebyscore(rediskey, sscore, escore, **opts)
760
760
  end
761
761
 
762
762
  def remrangebyrank srank, erank
@@ -36,5 +36,5 @@ class Limiter < Storable
36
36
  include Familia
37
37
  index :name
38
38
  field :name
39
- string :counter, :quantize => true, :ttl => 1.hour, :quantize => [10.minutes, '%H:%M', 1302468980]
40
- end
39
+ string :counter, :ttl => 1.hour, :quantize => [10.minutes, '%H:%M', 1302468980]
40
+ end
data/lib/familia.rb CHANGED
@@ -46,13 +46,13 @@ module Familia
46
46
  def ld *msg
47
47
  info *msg if debug?
48
48
  end
49
- def trace label, redis_client, ident, context=nil
49
+ def trace label, redis_instance, ident, context=nil
50
50
  return unless Familia.debug?
51
- info "[%s] %s/%s" % [label, redis_client.uri, ident]
51
+ info "[%s] %s/%s" % [label, redis_instance.id, ident]
52
52
  if context
53
53
  context = [context].flatten
54
54
  context.reject! { |line| line =~ /lib\/familia/ }
55
- info " %s" % context[0..6].join("\n ")
55
+ info " %s" % context[0..6].join("\n ")
56
56
  end
57
57
  end
58
58
  def uri= v
@@ -61,9 +61,9 @@ module Familia
61
61
  end
62
62
  # A convenience method for returning the appropriate Redis
63
63
  # connection. If +uri+ is an Integer, we'll treat it as a
64
- # database number. If it's a String, we'll treat it as a
64
+ # database number. If it's a String, we'll treat it as a
65
65
  # full URI (e.g. redis://1.2.3.4/15).
66
- # Otherwise we'll return the default connection.
66
+ # Otherwise we'll return the default connection.
67
67
  def redis(uri=nil)
68
68
  if Integer === uri
69
69
  tmp = Familia.uri
@@ -73,7 +73,7 @@ module Familia
73
73
  uri &&= URI.parse uri
74
74
  end
75
75
  uri ||= Familia.uri
76
- connect(uri) unless @clients[uri.serverid]
76
+ connect(uri) unless @clients[uri.serverid]
77
77
  @clients[uri.serverid]
78
78
  end
79
79
  def log(level, path)
@@ -111,29 +111,29 @@ module Familia
111
111
  el.unshift @apiversion unless @apiversion.nil?
112
112
  el.join(Familia.delim)
113
113
  end
114
- def apiversion(r=nil, &blk)
114
+ def apiversion(r=nil, &blk)
115
115
  if blk.nil?
116
- @apiversion = r if r;
116
+ @apiversion = r if r;
117
117
  else
118
118
  tmp = @apiversion
119
119
  @apiversion = r
120
120
  blk.call
121
121
  @apiversion = tmp
122
122
  end
123
- @apiversion
123
+ @apiversion
124
124
  end
125
125
  def now n=Time.now
126
126
  n.utc.to_i
127
127
  end
128
128
  # A quantized timestamp
129
129
  # e.g. 12:32 -> 12:30
130
- #
130
+ #
131
131
  def qnow quantum=10.minutes, now=Familia.now
132
132
  rounded = now - (now % quantum)
133
133
  Time.at(rounded).utc.to_i
134
134
  end
135
135
  end
136
-
136
+
137
137
  class Problem < RuntimeError; end
138
138
  class NoIndex < Problem; end
139
139
  class NonUniqueKey < Problem; end
@@ -146,7 +146,7 @@ module Familia
146
146
  "No client for #{uri.serverid}"
147
147
  end
148
148
  end
149
-
149
+
150
150
  def self.included(obj)
151
151
  obj.send :include, Familia::InstanceMethods
152
152
  obj.send :include, Gibbler::Complex
@@ -154,7 +154,7 @@ module Familia
154
154
  obj.class_zset :instances, :class => obj, :reference => true
155
155
  Familia.classes << obj
156
156
  end
157
-
157
+
158
158
  require 'familia/object'
159
159
  require 'familia/helpers'
160
160
 
@@ -170,5 +170,5 @@ module Familia
170
170
  def included(obj)
171
171
  self.klasses << obj
172
172
  end
173
- end
173
+ end
174
174
  end
@@ -1,6 +1,8 @@
1
1
  require 'familia'
2
2
  require 'familia/test_helpers'
3
3
 
4
+ # Familia.debug = true
5
+
4
6
  @a = Bone.new 'atoken', 'akey'
5
7
 
6
8
  ## Familia::SortedSet#add
@@ -9,11 +11,11 @@ require 'familia/test_helpers'
9
11
  @a.metrics.add 0, :metric0
10
12
  @a.metrics.add 1, :metric1
11
13
  @a.metrics.add 3, :metric3
12
- ##=> true
14
+ #=> true
13
15
 
14
16
  ## Familia::SortedSet#members
15
17
  @a.metrics.members
16
- ##=> ['metric0', 'metric1', 'metric2', 'metric3', 'metric4']
18
+ #=> ['metric0', 'metric1', 'metric2', 'metric3', 'metric4']
17
19
 
18
20
  ## Familia::SortedSet#members
19
21
  @a.metrics.revmembers
metadata CHANGED
@@ -1,98 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: familia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: redis
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '4.8'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '7'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '4.8'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '7'
33
- - !ruby/object:Gem::Dependency
34
- name: uri-redis
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 1.0.0
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 1.0.0
47
- - !ruby/object:Gem::Dependency
48
- name: gibbler
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: 1.0.0
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: 1.0.0
61
- - !ruby/object:Gem::Dependency
62
- name: storable
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: 0.10.0
68
- type: :runtime
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: 0.10.0
75
- - !ruby/object:Gem::Dependency
76
- name: multi_json
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '1.15'
82
- type: :runtime
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '1.15'
11
+ date: 2024-06-16 00:00:00.000000000 Z
12
+ dependencies: []
89
13
  description: 'Familia: Organize and store ruby objects in Redis'
90
- email: delano@solutious.com
14
+ email: gems@solutious.com
91
15
  executables: []
92
16
  extensions: []
93
17
  extra_rdoc_files: []
94
18
  files:
19
+ - ".github/workflows/ruby.yml"
95
20
  - ".gitignore"
21
+ - ".pre-commit-config.yaml"
96
22
  - Gemfile
97
23
  - Gemfile.lock
98
24
  - LICENSE.txt
@@ -119,7 +45,7 @@ homepage: https://github.com/delano/familia
119
45
  licenses:
120
46
  - MIT
121
47
  metadata: {}
122
- post_install_message:
48
+ post_install_message:
123
49
  rdoc_options: []
124
50
  require_paths:
125
51
  - lib
@@ -127,15 +53,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
53
  requirements:
128
54
  - - ">="
129
55
  - !ruby/object:Gem::Version
130
- version: 2.6.8
56
+ version: 2.7.8
131
57
  required_rubygems_version: !ruby/object:Gem::Requirement
132
58
  requirements:
133
59
  - - ">="
134
60
  - !ruby/object:Gem::Version
135
61
  version: '0'
136
62
  requirements: []
137
- rubygems_version: 3.2.3
138
- signing_key:
63
+ rubygems_version: 3.4.19
64
+ signing_key:
139
65
  specification_version: 4
140
66
  summary: Organize and store ruby objects in Redis
141
67
  test_files: []