key-vortex 1.0.0 → 1.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: ccc7720fa67e489fa24c0158866cfde5be930f1b0f68ccc04b94b77e193b69f1
4
- data.tar.gz: 350476269a57fed2af54c84ccd887d828f0804d287445b1133b67d2a4b66ce7c
3
+ metadata.gz: d9f0c82f8fe8c9435860c8856e79302b4d64e0efd5524807ad8b524545ae7588
4
+ data.tar.gz: a9995decc14a86f8ccb93e5539297dcb3bb206c0efe0062882a8d81be62daadd
5
5
  SHA512:
6
- metadata.gz: 21a080f1f96c1d2aa6dde92071f3b5df4d73e96d11207a4cca025ad4c01be5f8f93fc4567da53087645c58f3d2d74afbede919e3ef45bc2cc63e3fe85a0341b0
7
- data.tar.gz: 2c73b0c9eeae66681633c15d887c595c86aa468afed4dec676ca5527466908f33e4d084494da2dae682ed87cae82e2255ba82941d303fad57d504836225bea5a
6
+ metadata.gz: '05844fa94ddb3598dc84949711bf61632ab87261fa5f58a79105c05d808caaf4e6c6976c270c61c90018df610975efc2fc8804a55adc531c773aabf0ed832e64'
7
+ data.tar.gz: beb5082bdbe2e93ef622a6df07917f595ae505bcbb884b44187a820b5b15aa56b648efdaf52325ef595b51ce5c226bcbd9ee155d21cbcb2a0394799e89cace9f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- key-vortex (1.0.0)
4
+ key-vortex (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "key_vortex/constraint/base"
4
+
5
+ class KeyVortex
6
+ module Constraint
7
+ # Enforces that strings match the specified pattern. Because
8
+ # regular expressions are too complicated to establish clean
9
+ # bounds, it will not be considered when narrowing based on
10
+ # adapter constraints.
11
+ class Regexp < KeyVortex::Constraint::Base
12
+ # @return [Regexp] The regexp the value must match
13
+ attr_reader :pattern
14
+
15
+ # @param pattern [Regexp] The regexp the value must match
16
+ def initialize(pattern)
17
+ super()
18
+ @pattern = pattern
19
+ end
20
+
21
+ # @return [Symbol] :regexp
22
+ def attribute
23
+ :regexp
24
+ end
25
+
26
+ # @param [any]
27
+ # @return [true] Regular expressions are too flexible, they cannot be compared
28
+ def within?(_)
29
+ true
30
+ end
31
+
32
+ # @param value [String]
33
+ # @return [Boolean] True if pattern =~ value
34
+ def accepts?(value)
35
+ pattern =~ value
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,6 +4,7 @@ require "key_vortex/constraint/base"
4
4
  require "key_vortex/constraint/length"
5
5
  require "key_vortex/constraint/maximum"
6
6
  require "key_vortex/constraint/minimum"
7
+ require "key_vortex/constraint/regexp"
7
8
 
8
9
  class KeyVortex
9
10
  # Constraints define a restriction on the values which can be used
@@ -25,8 +26,8 @@ class KeyVortex
25
26
  #
26
27
  # All constraints can determine if a value is valid for them.
27
28
  #
28
- # All constraints, when compared with other instances of themselves,
29
- # it can always be determined if ones limitations fit within the
29
+ # Most constraints, when compared with other instances of
30
+ # themselves, can be determined if ones limitations fit within the
30
31
  # others. More formally, given an instance x of a constraint, an
31
32
  # instance y of the same constraint fits within x if and only if for
32
33
  # all values v that are valid for y, v is also valid for x.
@@ -45,6 +46,8 @@ class KeyVortex
45
46
  KeyVortex::Constraint::Maximum.new(limit)
46
47
  when :minimum
47
48
  KeyVortex::Constraint::Minimum.new(limit)
49
+ when :regexp
50
+ KeyVortex::Constraint::Regexp.new(limit)
48
51
  else
49
52
  raise KeyVortex::Error, "Unexpected attribute: #{attribute}"
50
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class KeyVortex
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: key-vortex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lambda Null
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-16 00:00:00.000000000 Z
11
+ date: 2023-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Defines abstractions that can be built on top of for key/value storage
14
14
  on different technologies (file, s3, sql, redis, etc.)
@@ -40,6 +40,7 @@ files:
40
40
  - lib/key_vortex/constraint/length.rb
41
41
  - lib/key_vortex/constraint/maximum.rb
42
42
  - lib/key_vortex/constraint/minimum.rb
43
+ - lib/key_vortex/constraint/regexp.rb
43
44
  - lib/key_vortex/field.rb
44
45
  - lib/key_vortex/limitation.rb
45
46
  - lib/key_vortex/record.rb
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  requirements: []
70
- rubygems_version: 3.2.33
71
+ rubygems_version: 3.4.1
71
72
  signing_key:
72
73
  specification_version: 4
73
74
  summary: Abstraction for interacting with various record stores