revector 0.1.0 → 0.1.1
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/README.md +10 -8
- data/lib/revector/predicate/equal.rb +1 -1
- data/lib/revector/version.rb +1 -1
- data/lib/revector.rb +11 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55552970c0c202e03b178d35afa19acb75e3f1350429f77068d7ea828d16617e
|
4
|
+
data.tar.gz: 2c1cc807e1d503af911c6f04dce07d3e683820ca43cea6cd5350166e545c9dca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 917aa56974f1d057f1b621e0a26c53d38ac263db166a18e5fca44fc8363b524a4c431dfbfe5e49fc1d764f064279bd5589bd826161b690266813c893dac38f77
|
7
|
+
data.tar.gz: da812d7d3128692f47446b37e2a7fe2ec9388972359b24f3d0f1e44c8f13e2ca3976f61af4ff9077db9444f6b56331c267f78be6446c14eccecc8dbc63b89641
|
data/README.md
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
</p>
|
5
5
|
|
6
6
|
<p align="center">
|
7
|
-
<a href="https://rubygems.org/gems/revector">
|
7
|
+
<a href="https://rubygems.org/gems/revector" style="text-decoration: none !important;">
|
8
8
|
<img alt="Gem" src="https://img.shields.io/gem/v/revector.svg">
|
9
9
|
</a>
|
10
10
|
|
11
|
-
<a href="https://github.com/thadeu/revector/actions/workflows/ci.yml">
|
11
|
+
<a href="https://github.com/thadeu/revector/actions/workflows/ci.yml" style="text-decoration: none !important;">
|
12
12
|
<img alt="Build Status" src="https://github.com/thadeu/revector/actions/workflows/ci.yml/badge.svg">
|
13
13
|
</a>
|
14
14
|
</p>
|
@@ -35,7 +35,7 @@ unreleased | https://github.com/thadeu/revector/blob/main/README.md
|
|
35
35
|
|
36
36
|
| kind | branch | ruby |
|
37
37
|
| -------------- | ------- | ------------------ |
|
38
|
-
| unreleased | main | >= 2.
|
38
|
+
| unreleased | main | >= 2.7 |
|
39
39
|
|
40
40
|
## Installation
|
41
41
|
|
@@ -67,14 +67,16 @@ Without configuration, because we use only Ruby. ❤️
|
|
67
67
|
| ----------- | ----------- | ----------- |
|
68
68
|
| Equal | eq | Anywhere |
|
69
69
|
| NotEqual | noteq | Anywhere |
|
70
|
+
| Exists | ex | Anywhere |
|
71
|
+
| NotExists | not_ex | Anywhere |
|
70
72
|
| Contains | cont | Anywhere |
|
71
|
-
| NotContains | notcont | Anywhere |
|
73
|
+
| NotContains | notcont, not_cont | Anywhere |
|
72
74
|
| Included | in | Anywhere |
|
73
|
-
| NotIncluded | notin
|
74
|
-
| Start | start | Anywhere |
|
75
|
-
| NotStart | notstart | Anywhere |
|
75
|
+
| NotIncluded | notin, not_in | Anywhere |
|
76
|
+
| Start | start, st | Anywhere |
|
77
|
+
| NotStart | notstart, notst, not_start, not_st | Anywhere |
|
76
78
|
| End | end | Anywhere |
|
77
|
-
| NotEnd | notend | Anywhere |
|
79
|
+
| NotEnd | notend, not_end | Anywhere |
|
78
80
|
| LessThan | lt | Anywhere |
|
79
81
|
| LessThanEqual | lteq | Anywhere |
|
80
82
|
| GreaterThan | gt | Anywhere |
|
data/lib/revector/version.rb
CHANGED
data/lib/revector.rb
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
require 'set'
|
4
4
|
|
5
5
|
require_relative 'revector/utility'
|
6
|
+
require_relative 'revector/predicate/equal'
|
7
|
+
require_relative 'revector/predicate/exists'
|
6
8
|
require_relative 'revector/predicate/startify'
|
7
9
|
require_relative 'revector/predicate/endify'
|
8
|
-
require_relative 'revector/predicate/equal'
|
9
10
|
require_relative 'revector/predicate/contains'
|
10
11
|
require_relative 'revector/predicate/in'
|
11
12
|
require_relative 'revector/predicate/less_than'
|
@@ -54,6 +55,7 @@ class Revector
|
|
54
55
|
|
55
56
|
case right
|
56
57
|
in [*]
|
58
|
+
right = [''] unless right.any?
|
57
59
|
Array(right).any? { |o| predicatable.compare(o, valueable) }
|
58
60
|
else
|
59
61
|
predicatable.compare(right, valueable)
|
@@ -67,7 +69,7 @@ class Revector
|
|
67
69
|
predicate = Array(parts[-2..]).filter do |pkey|
|
68
70
|
next unless PREDICATES.include? pkey
|
69
71
|
|
70
|
-
parts
|
72
|
+
parts -= [pkey]
|
71
73
|
|
72
74
|
pkey
|
73
75
|
end&.last || :eq
|
@@ -103,21 +105,25 @@ class Revector
|
|
103
105
|
not_end: NotEndify,
|
104
106
|
in: Included,
|
105
107
|
notin: NotIncluded,
|
106
|
-
not_in: NotIncluded
|
108
|
+
not_in: NotIncluded,
|
109
|
+
ex: Exists,
|
110
|
+
not_ex: NotExists
|
107
111
|
}[named.to_sym || :eq]
|
108
112
|
end
|
109
113
|
private_constant :Predicate
|
110
114
|
|
111
115
|
AFFIRMATIVES = %w[
|
112
|
-
eq
|
116
|
+
eq ex
|
113
117
|
in cont
|
114
118
|
lt lteq
|
115
119
|
gt gteq
|
116
|
-
st start
|
120
|
+
st start
|
121
|
+
end
|
117
122
|
].freeze
|
118
123
|
|
119
124
|
NEGATIVES = %w[
|
120
125
|
noteq not_eq
|
126
|
+
not_ex
|
121
127
|
notcont not_cont
|
122
128
|
notstart notst not_start not_st
|
123
129
|
notend not_end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thadeu Esteves
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Filter collections using predicates like Ransack gem.
|
14
14
|
email:
|