rokaki 0.8.0.pre.pre → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd7982d23aa428243393be242a44e66655f3805cd23e2cb75e9f9ac1d9f6e8a3
4
- data.tar.gz: 07d183020e8234b19d253cbde9172a3d802a705be0e535d982c6be06087ab3a5
3
+ metadata.gz: b0654c6e63cc988e84b4df0a33b2055661bc5f7e29367923bdc1267fc4bbe64e
4
+ data.tar.gz: fd7f3e44cc48096389697d82f89b720a67900bbe073ce60e62828362fd46376d
5
5
  SHA512:
6
- metadata.gz: 8a22d6928e09c881f021e16b92bffa57f43f8a872528ab49f1b25f5ffc0c0a5918898944ea41439ed58d5e1fa1a40fbc16cbc6fa628f7380680cc2cc1bc3abe2
7
- data.tar.gz: 8e9ac460a085d3bc32b72cb9b9d1c6198da65bae3e6d76a03a916708faa2e5862c3102d66407b795c23c93e4b527ea5fbda190d93ae876a583253d8b18d08ce7
6
+ metadata.gz: dc938b3a7c3632ed7f92a0452b87a91c5e50f0ae37b3f00cb5f9d79a65e0ca0f23f60d5b92b6cd709c287ddcf4a891bde460fd757df1e2fd8c4b0f551499fd05
7
+ data.tar.gz: a350805490d53b145b68813fdf9144b37871fa9b06942df0d2befb906e7912244258ffe14d0b5174bd0ab1fe7f92b4b9fcf650b847c1a36aefba2ecb8aee344b
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  tags
13
+ *.gem
@@ -1,32 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rokaki (0.7.0)
4
+ rokaki (0.8.0)
5
5
  activesupport
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.0.0)
11
- activesupport (= 6.0.0)
12
- activerecord (6.0.0)
13
- activemodel (= 6.0.0)
14
- activesupport (= 6.0.0)
15
- activesupport (6.0.0)
10
+ activemodel (6.0.3.2)
11
+ activesupport (= 6.0.3.2)
12
+ activerecord (6.0.3.2)
13
+ activemodel (= 6.0.3.2)
14
+ activesupport (= 6.0.3.2)
15
+ activesupport (6.0.3.2)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 0.7, < 2)
18
18
  minitest (~> 5.1)
19
19
  tzinfo (~> 1.1)
20
- zeitwerk (~> 2.1, >= 2.1.8)
21
- byebug (11.0.1)
22
- coderay (1.1.2)
23
- concurrent-ruby (1.1.5)
20
+ zeitwerk (~> 2.2, >= 2.2.2)
21
+ byebug (11.1.3)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.1.6)
24
24
  diff-lcs (1.3)
25
- factory_bot (5.1.1)
26
- activesupport (>= 4.2.0)
27
- ffi (1.11.1)
25
+ factory_bot (6.0.2)
26
+ activesupport (>= 5.0.0)
27
+ ffi (1.13.1)
28
28
  formatador (0.2.5)
29
- guard (2.15.0)
29
+ guard (2.16.2)
30
30
  formatador (>= 0.2.4)
31
31
  listen (>= 2.7, < 4.0)
32
32
  lumberjack (>= 1.0.12, < 2.0)
@@ -40,51 +40,49 @@ GEM
40
40
  guard (~> 2.1)
41
41
  guard-compat (~> 1.1)
42
42
  rspec (>= 2.99.0, < 4.0)
43
- i18n (1.6.0)
43
+ i18n (1.8.3)
44
44
  concurrent-ruby (~> 1.0)
45
- listen (3.1.5)
46
- rb-fsevent (~> 0.9, >= 0.9.4)
47
- rb-inotify (~> 0.9, >= 0.9.7)
48
- ruby_dep (~> 1.2)
49
- lumberjack (1.0.13)
50
- method_source (0.9.2)
51
- minitest (5.11.3)
45
+ listen (3.2.1)
46
+ rb-fsevent (~> 0.10, >= 0.10.3)
47
+ rb-inotify (~> 0.9, >= 0.9.10)
48
+ lumberjack (1.2.6)
49
+ method_source (1.0.0)
50
+ minitest (5.14.1)
52
51
  nenv (0.3.0)
53
52
  notiffany (0.1.3)
54
53
  nenv (~> 0.1)
55
54
  shellany (~> 0.0)
56
- pg (1.1.4)
57
- pry (0.12.2)
58
- coderay (~> 1.1.0)
59
- method_source (~> 0.9.0)
60
- pry-byebug (3.7.0)
55
+ pg (1.2.3)
56
+ pry (0.13.1)
57
+ coderay (~> 1.1)
58
+ method_source (~> 1.0)
59
+ pry-byebug (3.9.0)
61
60
  byebug (~> 11.0)
62
- pry (~> 0.10)
61
+ pry (~> 0.13.0)
63
62
  rake (10.5.0)
64
- rb-fsevent (0.10.3)
65
- rb-inotify (0.10.0)
63
+ rb-fsevent (0.10.4)
64
+ rb-inotify (0.10.1)
66
65
  ffi (~> 1.0)
67
- rspec (3.8.0)
68
- rspec-core (~> 3.8.0)
69
- rspec-expectations (~> 3.8.0)
70
- rspec-mocks (~> 3.8.0)
71
- rspec-core (3.8.2)
72
- rspec-support (~> 3.8.0)
73
- rspec-expectations (3.8.4)
66
+ rspec (3.9.0)
67
+ rspec-core (~> 3.9.0)
68
+ rspec-expectations (~> 3.9.0)
69
+ rspec-mocks (~> 3.9.0)
70
+ rspec-core (3.9.2)
71
+ rspec-support (~> 3.9.3)
72
+ rspec-expectations (3.9.2)
74
73
  diff-lcs (>= 1.2.0, < 2.0)
75
- rspec-support (~> 3.8.0)
76
- rspec-mocks (3.8.1)
74
+ rspec-support (~> 3.9.0)
75
+ rspec-mocks (3.9.1)
77
76
  diff-lcs (>= 1.2.0, < 2.0)
78
- rspec-support (~> 3.8.0)
79
- rspec-support (3.8.2)
80
- ruby_dep (1.5.0)
77
+ rspec-support (~> 3.9.0)
78
+ rspec-support (3.9.3)
81
79
  shellany (0.0.1)
82
- sqlite3 (1.4.1)
83
- thor (0.20.3)
80
+ sqlite3 (1.4.2)
81
+ thor (1.0.1)
84
82
  thread_safe (0.3.6)
85
- tzinfo (1.2.5)
83
+ tzinfo (1.2.7)
86
84
  thread_safe (~> 0.1)
87
- zeitwerk (2.1.9)
85
+ zeitwerk (2.3.0)
88
86
 
89
87
  PLATFORMS
90
88
  ruby
@@ -104,4 +102,4 @@ DEPENDENCIES
104
102
  sqlite3
105
103
 
106
104
  BUNDLED WITH
107
- 2.1.3
105
+ 2.1.4
data/README.md CHANGED
@@ -190,7 +190,38 @@ end
190
190
  ```
191
191
  Or
192
192
 
193
- #### 2. The porcelain command syntax
193
+ #### 2. The `filter_map` command syntax
194
+ `filter_map` takes the model name, then a single 'query' field and maps it to fields named in the options, this is useful if you want to search for a single value across many different fields or associated tables simultaneously. (builds on `define_filter_map`)
195
+
196
+
197
+ ```ruby
198
+ class AuthorFilter
199
+ include Rokaki::FilterModel
200
+
201
+ filter_map :author, :query,
202
+ like: {
203
+ articles: {
204
+ title: :circumfix,
205
+ reviews: {
206
+ title: :circumfix
207
+ }
208
+ },
209
+ }
210
+
211
+ attr_accessor :filters, :model
212
+
213
+ def initialize(filters:)
214
+ @filters = filters
215
+ end
216
+ end
217
+
218
+ filters = { query: "Jiddu" }
219
+ filtered_authors = AuthorFilter.new(filters: filters).results
220
+ ```
221
+
222
+ In the above example we search for authors who have written articles containing the word "Jiddu" in the title that also have reviews containing the sames word in their titles.
223
+
224
+ #### 3. The porcelain command syntax
194
225
 
195
226
  In this syntax you will need to provide three keywords:- `filters`, `like` and `filter_model` if you are not passing in the model type and assigning it to `@model`
196
227
 
@@ -25,6 +25,16 @@ module Rokaki
25
25
 
26
26
  private
27
27
 
28
+ def filter_map(model, query_key, options)
29
+ filter_model(model)
30
+ @_query_key = query_key
31
+
32
+ @_filter_db = options[:db] || :postgres
33
+ like(options[:like]) if options[:like]
34
+ ilike(options[:ilike]) if options[:ilike]
35
+ filters(*options[:match]) if options[:match]
36
+ end
37
+
28
38
  def filter(model, options)
29
39
  filter_model(model)
30
40
 
@@ -35,7 +45,11 @@ module Rokaki
35
45
  end
36
46
 
37
47
  def filters(*filter_keys)
38
- define_filter_keys(*filter_keys)
48
+ if @_query_key
49
+ define_filter_map(@_query_key, *filter_keys)
50
+ else
51
+ define_filter_keys(*filter_keys)
52
+ end
39
53
 
40
54
  @_chain_filters ||= []
41
55
  filter_keys.each do |filter_key|
@@ -1,3 +1,3 @@
1
1
  module Rokaki
2
- VERSION = "0.8.0-pre"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rokaki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.pre.pre
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Martin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-10 00:00:00.000000000 Z
11
+ date: 2020-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -222,9 +222,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  requirements:
225
- - - ">"
225
+ - - ">="
226
226
  - !ruby/object:Gem::Version
227
- version: 1.3.1
227
+ version: '0'
228
228
  requirements: []
229
229
  rubygems_version: 3.1.2
230
230
  signing_key: