rhino_project_core 0.20.0.beta.87 → 0.20.0.beta.91

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: 2086a5bc5fa1a3845b613f84d271c859e62e42980768ef046f69054a270e6e15
4
- data.tar.gz: 0b66c2cecfb4590c858fc8f87789c7c73e78b4966171befba075d07991843633
3
+ metadata.gz: 4b13e16249dfcf0ffe63cd28c60ac6fce08e64b1e8148a4f77cc58cdd380997f
4
+ data.tar.gz: 565da4f95028585899cf7dbb160b39c889a144069c63816f9094d0ed37939e44
5
5
  SHA512:
6
- metadata.gz: 4b1718c518d2cef5ec8278c1ba6b7d8c91386ea75c1bed88d81d75491c8ceba273f88485f0ea39b19cb6fd243159eebdaea6730acd644c0d88541b07dd43d3dd
7
- data.tar.gz: 4ebb8055e81f059a48c974f99e8188b775c54db919cbd4d64ee666f8a1178233a634a9e5b64a2a93d9bd5dfcca68d1c5eafa408923a99ac37af3e6e9b93f93b7
6
+ metadata.gz: 5b183f05953cad514ba0819d28461a47d90192f4406ac727d2b5cd898333b7ada483479c5c9baef3ad45d5292b99b855a864f71a9b689e0b17ad17f3770f34ea
7
+ data.tar.gz: 57f24e2d114a5af334a41dc09d5c240fae75da66877e82779b339abc2ebac751136b7da193c564ddaec4f0bd78ca23e2d7f63bd0b4fb29d5d5270686719fc662
data/lib/rhino/engine.rb CHANGED
@@ -12,6 +12,7 @@ require "devise"
12
12
  require "devise_invitable"
13
13
  require "devise_token_auth"
14
14
  require "friendly_id"
15
+ require "geocoder"
15
16
  require "omniauth"
16
17
  require "omniauth-azure-activedirectory-v2"
17
18
  require "omniauth-auth0"
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rhino
4
+ module Sieve
5
+ class Geospatial
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ # geospatial={near: {location: { latitude: 41.2565, longitude: -95.9345 }, max_distance: 10, units: 'km'}}
11
+ # geospatial={near: {location: 'Omaha, NE, US', max_distance: 10, units: 'km'}}
12
+ def resolve(scope, params)
13
+ return @app.resolve(scope, params) unless valid?(params)
14
+
15
+ @app.resolve(
16
+ scope.near(
17
+ @location_params,
18
+ @near_params[:max_distance],
19
+ units: @near_params[:units]
20
+ ), params
21
+ )
22
+ end
23
+
24
+ private
25
+ def valid?(params) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
26
+ @geospatial_params = params[:geospatial]
27
+ return false unless @geospatial_params.is_a?(ActionController::Parameters)
28
+
29
+ @near_params = @geospatial_params[:near]
30
+ return false unless @near_params.is_a?(ActionController::Parameters)
31
+
32
+ @location_params = @near_params[:location]
33
+ if @location_params.is_a?(String)
34
+ @location_params = @near_params[:location]
35
+ elsif @location_params.is_a?(ActionController::Parameters) && @location_params[:latitude].present? && @location_params[:longitude].present?
36
+ @location_params = [@location_params[:latitude], @location_params[:longitude]]
37
+ else
38
+ return false
39
+ end
40
+
41
+ @near_params[:max_distance].present?
42
+ end
43
+ end
44
+ end
45
+ end
data/lib/rhino/sieve.rb CHANGED
@@ -5,6 +5,7 @@ module Rhino
5
5
  extend ActiveSupport::Autoload
6
6
 
7
7
  autoload :Filter
8
+ autoload :Geospatial
8
9
  autoload :Limit
9
10
  autoload :Offset
10
11
  autoload :Order
data/lib/rhino/version.rb CHANGED
@@ -10,7 +10,7 @@ module Rhino
10
10
  MAJOR = 0
11
11
  MINOR = 20
12
12
  TINY = 0
13
- PRE = "beta.87"
13
+ PRE = "beta.91"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -65,6 +65,8 @@ module Rhino
65
65
  self.sieves = Rhino::SieveStack.new do |sieve|
66
66
  sieve.use Rhino::Sieve::Filter
67
67
 
68
+ sieve.use Rhino::Sieve::Geospatial
69
+
68
70
  sieve.use Rhino::Sieve::Search
69
71
 
70
72
  sieve.use Rhino::Sieve::Order
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhino_project_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0.beta.87
4
+ version: 0.20.0.beta.91
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Rosevear
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -156,6 +156,20 @@ dependencies:
156
156
  - - '='
157
157
  - !ruby/object:Gem::Version
158
158
  version: 5.3.0
159
+ - !ruby/object:Gem::Dependency
160
+ name: geocoder
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - '='
164
+ - !ruby/object:Gem::Version
165
+ version: 1.8.2
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - '='
171
+ - !ruby/object:Gem::Version
172
+ version: 1.8.2
159
173
  - !ruby/object:Gem::Dependency
160
174
  name: js_regex
161
175
  requirement: !ruby/object:Gem::Requirement
@@ -471,6 +485,7 @@ files:
471
485
  - lib/rhino/resource/sieves.rb
472
486
  - lib/rhino/sieve.rb
473
487
  - lib/rhino/sieve/filter.rb
488
+ - lib/rhino/sieve/geospatial.rb
474
489
  - lib/rhino/sieve/helpers.rb
475
490
  - lib/rhino/sieve/limit.rb
476
491
  - lib/rhino/sieve/offset.rb