seek_party 0.0.1 → 0.0.2

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: 7366a41454326575b488a8149cefab4ee1fa184b9df1695e332cf3b114cae5cc
4
- data.tar.gz: ebc591f2d3f4a962f953df3caf19f986560f2838fb9b5688f3b71bb70e38f779
3
+ metadata.gz: '0924852e23e1fe893c17e0bea8305d4c1c1f31d6f73eedd3e2b91c009b9f8809'
4
+ data.tar.gz: 8a63dbfc9a23816286856195f820e67d78b1ac2016a20882c645e5b08e575200
5
5
  SHA512:
6
- metadata.gz: 5c360583067ade61cbb950fe07eca9f00b03cafa1843f61d880bf1bf32cb61938a05becf230efe5cd86b6290a57bb506a705861cfb61d4bd6fabd6eecf437601
7
- data.tar.gz: b04839f0ba524ae18fd0f62406a9b6252f33c5e2ad95407b2a25e2802810af66aedc309acdd44b7bd2add6e7015f7f9ed5a2cf49e0bed59b788914cfdae7ca9f
6
+ metadata.gz: 91b7c0211204c18d97c7ae9f81d7d341730b923e39783838f720afc97965441c1fd9a037146ee45df391f7393dad27d9c02cce6aea83a91a9626c5787ccb8dc4
7
+ data.tar.gz: 746be003921717ebfc0a2ee4b7a252f039d38103f364b326c1fd8bf06df534aff31e85aae05c2863073c4d15d7efa0ad3fd47fd05cabd2f846bd08a27368a346
data/Gemfile.lock CHANGED
@@ -1,54 +1,54 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seek_party (0.0.1)
4
+ seek_party (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (5.2.4)
10
- actionpack (= 5.2.4)
9
+ actioncable (5.2.4.1)
10
+ actionpack (= 5.2.4.1)
11
11
  nio4r (~> 2.0)
12
12
  websocket-driver (>= 0.6.1)
13
- actionmailer (5.2.4)
14
- actionpack (= 5.2.4)
15
- actionview (= 5.2.4)
16
- activejob (= 5.2.4)
13
+ actionmailer (5.2.4.1)
14
+ actionpack (= 5.2.4.1)
15
+ actionview (= 5.2.4.1)
16
+ activejob (= 5.2.4.1)
17
17
  mail (~> 2.5, >= 2.5.4)
18
18
  rails-dom-testing (~> 2.0)
19
- actionpack (5.2.4)
20
- actionview (= 5.2.4)
21
- activesupport (= 5.2.4)
22
- rack (~> 2.0)
19
+ actionpack (5.2.4.1)
20
+ actionview (= 5.2.4.1)
21
+ activesupport (= 5.2.4.1)
22
+ rack (~> 2.0, >= 2.0.8)
23
23
  rack-test (>= 0.6.3)
24
24
  rails-dom-testing (~> 2.0)
25
25
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
- actionview (5.2.4)
27
- activesupport (= 5.2.4)
26
+ actionview (5.2.4.1)
27
+ activesupport (= 5.2.4.1)
28
28
  builder (~> 3.1)
29
29
  erubi (~> 1.4)
30
30
  rails-dom-testing (~> 2.0)
31
31
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
- activejob (5.2.4)
33
- activesupport (= 5.2.4)
32
+ activejob (5.2.4.1)
33
+ activesupport (= 5.2.4.1)
34
34
  globalid (>= 0.3.6)
35
- activemodel (5.2.4)
36
- activesupport (= 5.2.4)
37
- activerecord (5.2.4)
38
- activemodel (= 5.2.4)
39
- activesupport (= 5.2.4)
35
+ activemodel (5.2.4.1)
36
+ activesupport (= 5.2.4.1)
37
+ activerecord (5.2.4.1)
38
+ activemodel (= 5.2.4.1)
39
+ activesupport (= 5.2.4.1)
40
40
  arel (>= 9.0)
41
- activestorage (5.2.4)
42
- actionpack (= 5.2.4)
43
- activerecord (= 5.2.4)
41
+ activestorage (5.2.4.1)
42
+ actionpack (= 5.2.4.1)
43
+ activerecord (= 5.2.4.1)
44
44
  marcel (~> 0.3.1)
45
- activesupport (5.2.4)
45
+ activesupport (5.2.4.1)
46
46
  concurrent-ruby (~> 1.0, >= 1.0.2)
47
47
  i18n (>= 0.7, < 2)
48
48
  minitest (~> 5.1)
49
49
  tzinfo (~> 1.1)
50
50
  arel (9.0.0)
51
- builder (3.2.3)
51
+ builder (3.2.4)
52
52
  codeclimate-test-reporter (1.0.7)
53
53
  simplecov
54
54
  concurrent-ruby (1.1.5)
@@ -60,7 +60,7 @@ GEM
60
60
  activesupport (>= 4.2.0)
61
61
  i18n (1.7.0)
62
62
  concurrent-ruby (~> 1.0)
63
- json (2.2.0)
63
+ json (2.3.0)
64
64
  loofah (2.4.0)
65
65
  crass (~> 1.0.2)
66
66
  nokogiri (>= 1.5.9)
@@ -76,30 +76,30 @@ GEM
76
76
  nio4r (2.5.2)
77
77
  nokogiri (1.10.7)
78
78
  mini_portile2 (~> 2.4.0)
79
- rack (2.0.7)
79
+ rack (2.0.8)
80
80
  rack-test (1.1.0)
81
81
  rack (>= 1.0, < 3)
82
- rails (5.2.4)
83
- actioncable (= 5.2.4)
84
- actionmailer (= 5.2.4)
85
- actionpack (= 5.2.4)
86
- actionview (= 5.2.4)
87
- activejob (= 5.2.4)
88
- activemodel (= 5.2.4)
89
- activerecord (= 5.2.4)
90
- activestorage (= 5.2.4)
91
- activesupport (= 5.2.4)
82
+ rails (5.2.4.1)
83
+ actioncable (= 5.2.4.1)
84
+ actionmailer (= 5.2.4.1)
85
+ actionpack (= 5.2.4.1)
86
+ actionview (= 5.2.4.1)
87
+ activejob (= 5.2.4.1)
88
+ activemodel (= 5.2.4.1)
89
+ activerecord (= 5.2.4.1)
90
+ activestorage (= 5.2.4.1)
91
+ activesupport (= 5.2.4.1)
92
92
  bundler (>= 1.3.0)
93
- railties (= 5.2.4)
93
+ railties (= 5.2.4.1)
94
94
  sprockets-rails (>= 2.0.0)
95
95
  rails-dom-testing (2.0.3)
96
96
  activesupport (>= 4.2.0)
97
97
  nokogiri (>= 1.6)
98
98
  rails-html-sanitizer (1.3.0)
99
99
  loofah (~> 2.3)
100
- railties (5.2.4)
101
- actionpack (= 5.2.4)
102
- activesupport (= 5.2.4)
100
+ railties (5.2.4.1)
101
+ actionpack (= 5.2.4.1)
102
+ activesupport (= 5.2.4.1)
103
103
  method_source
104
104
  rake (>= 0.8.7)
105
105
  thor (>= 0.19.0, < 2.0)
@@ -138,7 +138,7 @@ GEM
138
138
  activesupport (>= 4.0)
139
139
  sprockets (>= 3.0.0)
140
140
  sqlite3 (1.4.1)
141
- thor (0.20.3)
141
+ thor (1.0.1)
142
142
  thread_safe (0.3.6)
143
143
  tzinfo (1.2.5)
144
144
  thread_safe (~> 0.1)
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # SeekParty - Searches made easy
2
2
 
3
- <p align="center">
4
- <img width="1000" height="204" src="https://i.ibb.co/CHjZYwj/search-party-logo-vector.png">
5
- </p>
6
-
7
3
  ### What is this?
8
4
 
9
5
  Have you ever had to write a search functionality for a web application and found yourself
@@ -37,6 +33,8 @@ Below is what's currently doable:
37
33
  PS: The DEFAULT_BLACK_LIST contains the attributes :id, :created_at and :updated_at. You can pass your own
38
34
  DEFAULT_BLACK_LIST when calling the #search method from your model, but I recommend using the WHITE_LIST,
39
35
  as SeekParty will then only generate queries using the column names present there.
36
+ You should also keep in mind that when building the queries, seek_party tries to pluralize your table name in order to refer to the table
37
+ columns by their full name (ex: 'your_table.your_column_name').
40
38
 
41
39
  ## Getting started
42
40
 
@@ -45,7 +43,7 @@ PS: The DEFAULT_BLACK_LIST contains the attributes :id, :created_at and :updated
45
43
  Add the following to your Gemfile
46
44
 
47
45
  ``` ruby
48
- gem 'seek_party', '~> 0.0.1'
46
+ gem 'seek_party', '~> 0.0.2'
49
47
  ```
50
48
  Then run:
51
49
 
@@ -86,7 +84,7 @@ instance that is available at the controller level.
86
84
  And it would produce the following query for Sqlite3:
87
85
 
88
86
  ``` sql
89
- SELECT "users".* FROM "users" WHERE (LOWER(CAST(name AS TEXT)) LIKE '%bilbo%' OR LOWER(CAST(email AS TEXT)) LIKE '%bilbo%')
87
+ SELECT "users".* FROM "users" WHERE (LOWER(CAST(users.name AS TEXT)) LIKE '%bilbo%' OR LOWER(CAST(users.email AS TEXT)) LIKE '%bilbo%')
90
88
  ```
91
89
 
92
90
  As you can see, it took all of the attributes into consideration when generating the
@@ -101,7 +99,7 @@ User.search(params: params, white_list: ['name'])
101
99
  Which would in turn produce the following query:
102
100
 
103
101
  ``` sql
104
- SELECT "users".* FROM "users" WHERE (LOWER(CAST(name AS TEXT)) LIKE '%bilbo%')
102
+ SELECT "users".* FROM "users" WHERE (LOWER(CAST(users.name AS TEXT)) LIKE '%bilbo%')
105
103
  ```
106
104
 
107
105
  If your params hash does not contain a search key, SeekParty will try to compare
@@ -116,7 +114,7 @@ User.search(params: params)
116
114
 
117
115
  Would produce a query like this:
118
116
  ``` sql
119
- SELECT "users".* FROM "users" WHERE (LOWER(CAST(name AS TEXT)) = 'bilbo')
117
+ SELECT "users".* FROM "users" WHERE (LOWER(CAST(users.name AS TEXT)) = 'bilbo')
120
118
  ```
121
119
 
122
120
  SeekParty would use the equals operator instead of the LIKE, since it infers that
@@ -136,7 +134,7 @@ User.search(params: params)
136
134
  And this would result in the following query being produced:
137
135
 
138
136
  ``` sql
139
- SELECT "users".* FROM "users" WHERE (LOWER(CAST(name AS TEXT)) LIKE '%sugoi%' AND LOWER(CAST(name AS TEXT)) = 'bilbo' OR LOWER(CAST(email AS TEXT)) LIKE '%sugoi%' AND LOWER(CAST(name AS TEXT)) = 'bilbo')
137
+ SELECT "users".* FROM "users" WHERE (LOWER(CAST(users.name AS TEXT)) LIKE '%sugoi%' AND LOWER(CAST(users.name AS TEXT)) = 'bilbo' OR LOWER(CAST(users.email AS TEXT)) LIKE '%sugoi%' AND LOWER(CAST(users.name AS TEXT)) = 'bilbo')
140
138
  ```
141
139
 
142
140
  ### TO DO
@@ -28,7 +28,9 @@ module SeekParty
28
28
  next unless another_model.has_attribute? attribute
29
29
  next if black_listed? attribute
30
30
 
31
- attributes << attribute if white_listed? attribute
31
+ if white_listed? attribute
32
+ attributes << "#{pluralize_and_snake_case_class_name}.#{attribute}"
33
+ end
32
34
  end
33
35
 
34
36
  attributes
@@ -43,5 +45,9 @@ module SeekParty
43
45
  def black_listed?(attribute_name)
44
46
  black_list.include? attribute_name
45
47
  end
48
+
49
+ def pluralize_and_snake_case_class_name
50
+ inspected_class.name.pluralize.underscore
51
+ end
46
52
  end
47
53
  end
@@ -1,3 +1,3 @@
1
1
  module SeekParty
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seek_party
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Washington
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-21 00:00:00.000000000 Z
11
+ date: 2019-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler