lato 3.5.8 → 3.5.9

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: b04945a750538aecdc08a8b8632aa661c3e08f7def4fad9b5b9fa1621dd09e80
4
- data.tar.gz: 717437c493529ac4eb5da90ce0e38c917980e388e68bff2475ff37646d40fea9
3
+ metadata.gz: 2096e6aab4a75e7edce579a7a0864de28f146053291970b49099e8103427e050
4
+ data.tar.gz: 81b8ea778664362775b8beb2a095085eb5e0e32c94a2ded4ead6bf8a2fc9bde6
5
5
  SHA512:
6
- metadata.gz: 01d49b48a8bef85902bd4c0b1b21f1a5d7b06789f468b686972ade21546f5e5be6507a1d2fe592dc83b79d364d62576babbe306068febe815ef16604f5b40fcd
7
- data.tar.gz: ac98e3240955cfb5a1c23b30c84c733480e9780d2747fc2ea9aea9a1c2a3828a9b59229c1cabd9d037237fd9350d8be7bcde4a72b0aeeccc4a8ffd13e35fc582
6
+ metadata.gz: 7bbfd89a3199d1d1714050f1e5485b4ed3e54948322de3d409458e5c34cfdd59215ddac0a25d44b1cc0a750057c534d70346ba74c3d1eadce86ca4540288673c
7
+ data.tar.gz: 5c079279e86b805d1a072c6a1d1f01c50f9690b1073212cc70cc030652a4f1bb6ca03917f73e3f6cad74d5357730ebaa6955985583fbcc7c24bb1adbe54f8a57
@@ -37,7 +37,7 @@ module Lato
37
37
  if collection.respond_to?(:lato_index_search)
38
38
  collection = collection.lato_index_search(search)
39
39
  else
40
- query = @_lato_index[key][:searchable_columns].map { |k| "lower(#{k}) LIKE :search" }
40
+ query = @_lato_index[key][:searchable_columns].map { |k| "#{k.to_s == 'id' ? k : "lower(#{k})"} LIKE :search" }
41
41
  collection = collection.where(query.join(' OR '), search: "%#{search.downcase.strip}%")
42
42
  end
43
43
  end
@@ -1,5 +1,6 @@
1
1
  module Lato
2
2
  class User < ApplicationRecord
3
+ include Lato::DependencyHelper
3
4
  include LatoUserApplication
4
5
 
5
6
  has_secure_password
@@ -112,6 +113,8 @@ module Lato
112
113
  end
113
114
 
114
115
  def web3_signin(params)
116
+ depends_on('eth')
117
+
115
118
  self.web3_address = params[:web3_address]
116
119
 
117
120
  user = Lato::User.find_by(web3_address: params[:web3_address].downcase)
@@ -269,6 +272,8 @@ module Lato
269
272
  end
270
273
 
271
274
  def add_web3_connection(params)
275
+ depends_on('eth')
276
+
272
277
  signature_pubkey = Eth::Signature.personal_recover(params[:web3_nonce], params[:web3_signed_nonce])
273
278
  signature_address = Eth::Util.public_key_to_address signature_pubkey
274
279
  unless signature_address.to_s.downcase == params[:web3_address].downcase
data/lib/lato/config.rb CHANGED
@@ -22,6 +22,7 @@ module Lato
22
22
  attr_accessor :legal_privacy_policy_url, :legal_privacy_policy_version, :legal_terms_and_conditions_url, :legal_terms_and_conditions_version
23
23
 
24
24
  # Web3 connection
25
+ # NOTE: It requires the gem 'eth' to be installed in the application Gemfile
25
26
  attr_accessor :web3_connection
26
27
 
27
28
  def initialize
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # NOTE: Taken from https://github.com/andreibondarev/langchainrb/blob/main/lib/langchain/dependency_helper.rb
4
+ # Thanks to Andrei Bondarev for the inspiration!!
5
+
6
+ module Lato
7
+ module DependencyHelper
8
+ class LoadError < ::LoadError; end
9
+
10
+ class VersionError < ScriptError; end
11
+
12
+ # This method requires and loads the given gem, and then checks to see if the version of the gem meets the requirements listed in `lato.gemspec`
13
+ # This solution was built to avoid auto-loading every single gem in the Gemfile when the developer will mostly likely be only using a few of them.
14
+ #
15
+ # @param gem_name [String] The name of the gem to load
16
+ # @return [Boolean] Whether or not the gem was loaded successfully
17
+ # @raise [LoadError] If the gem is not installed
18
+ # @raise [VersionError] If the gem is installed, but the version does not meet the requirements
19
+ #
20
+ def depends_on(gem_name, req: true)
21
+ gem(gem_name) # require the gem
22
+
23
+ return(true) unless defined?(Bundler) # If we're in a non-bundler environment, we're no longer able to determine if we'll meet requirements
24
+
25
+ gem_version = Gem.loaded_specs[gem_name].version
26
+ gem_requirement = Bundler.load.dependencies.find { |g| g.name == gem_name }&.requirement
27
+
28
+ raise LoadError unless gem_requirement
29
+
30
+ unless gem_requirement.satisfied_by?(gem_version)
31
+ raise VersionError, "The #{gem_name} gem is installed, but version #{gem_requirement} is required. You have #{gem_version}."
32
+ end
33
+
34
+ lib_name = gem_name if req == true
35
+ lib_name = req if req.is_a?(String)
36
+
37
+ require(lib_name) if lib_name
38
+
39
+ true
40
+ rescue ::LoadError
41
+ raise LoadError, "Could not load #{gem_name}. Please ensure that the #{gem_name} gem is installed."
42
+ end
43
+ end
44
+ end
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "3.5.8"
2
+ VERSION = "3.5.9"
3
3
  end
data/lib/lato.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  require "kaminari"
2
2
  require "bootstrap"
3
3
  require "browser"
4
- require "eth"
5
4
 
6
5
  require "lato/version"
7
6
  require "lato/engine"
8
7
  require "lato/config"
9
8
  require "lato/btstrap"
9
+ require "lato/dependency_helper"
10
10
 
11
11
  module Lato
12
12
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.8
4
+ version: 3.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-21 00:00:00.000000000 Z
11
+ date: 2024-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -101,7 +101,7 @@ dependencies:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
- type: :runtime
104
+ type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
@@ -229,6 +229,7 @@ files:
229
229
  - lib/lato.rb
230
230
  - lib/lato/btstrap.rb
231
231
  - lib/lato/config.rb
232
+ - lib/lato/dependency_helper.rb
232
233
  - lib/lato/engine.rb
233
234
  - lib/lato/version.rb
234
235
  - lib/tasks/lato_tasks.rake