revector 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: f00522f0cf5e6aabfadf23fe8a8892497a3e7c0c9abb2ee64b0b4b2f7b3b690f
4
- data.tar.gz: 7bf974dc51348cacb8ae6bd9d148478185b7f5cb8df306cca645686d4468f49f
3
+ metadata.gz: 55552970c0c202e03b178d35afa19acb75e3f1350429f77068d7ea828d16617e
4
+ data.tar.gz: 2c1cc807e1d503af911c6f04dce07d3e683820ca43cea6cd5350166e545c9dca
5
5
  SHA512:
6
- metadata.gz: eaee10f684d1a0bd9c66dae55c63a62c33489fe64e1a0293f1e95e99822d99821a4c71d0693d6f10eccb0045182b8f0e642e0298a51a1865b8bcf042367d7979
7
- data.tar.gz: 3f633dc545f1a97ca2db9ded7c93fef8da5e086aebaae7fc2ad5df72043bd1be85a469f631274d34b21a217b86bc57bb08958009b61b6d89b48ea7bb66c57bdd
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.5.8, <= 3.1.x |
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 | Anywhere |
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 |
@@ -17,7 +17,7 @@ class Revector
17
17
  end
18
18
 
19
19
  def self.compare(value, expected_value)
20
- !Equal.compare(value, expected_value)
20
+ !Exists.compare(value) && !Equal.compare(value, expected_value)
21
21
  end
22
22
  end
23
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Revector
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
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 = parts - [pkey]
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 end
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.0
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 00:00:00.000000000 Z
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: