bonsai-elasticsearch-rails 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bonsai-elasticsearch-rails.rb +2 -12
- data/lib/bonsai/elasticsearch/rails/railtie.rb +32 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe04901a601b65d48908d1dd20fe2af94533dc25
|
4
|
+
data.tar.gz: 1bd87fbd2a8bb7bb19f176b2f613ae1b4ec2c7ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfee26a39ef0a57ea98c367dabea99f73552348856cd4270ce1966c5e5aa35a3546dcb4dc47c428b02a14df7032cec74e37de56ddfe5564b7b24cbf458d043e9
|
7
|
+
data.tar.gz: ba496d5cfe65ada972689e98dbc7809480f8b7dbe5b24750405ee2ba310395b58d2562604325efeea7a7fff1389155e79a3d2ff45270ed3bd5c02017487f359c
|
@@ -1,13 +1,3 @@
|
|
1
|
-
|
2
|
-
require 'elasticsearch/rails'
|
3
|
-
|
4
|
-
Rails.logger = Logger.new(STDOUT) if Rails.logger.nil?
|
5
|
-
url = ENV['BONSAI_URL'] || ENV['ELASTICSEARCH_URL']
|
6
|
-
|
7
|
-
unless url.nil?
|
8
|
-
url_safe = url.gsub(/\:[a-z0-9]{1,}@/, ":redacted@")
|
9
|
-
Rails.logger.info("Starting up a new Bonsai Elasticsearch client with url: #{url_safe}")
|
10
|
-
Elasticsearch::Model.client = Elasticsearch::Client.new url: url
|
11
|
-
else
|
12
|
-
Rails.logger.warn('Could not find a `BONSAI_URL` environment variable with a cluster URL. The bonsai-elasticsearch-rails can not create an Elasticsearch client. Please contact support at: support@bonsai.io')
|
1
|
+
if defined?(Rails)
|
2
|
+
require File.expand_path('bonsai/elasticsearch/rails/railtie', File.dirname(__FILE__))
|
13
3
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Bonsai
|
2
|
+
module Elasticsearch
|
3
|
+
module Rails
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
|
6
|
+
config.after_initialize do
|
7
|
+
|
8
|
+
require 'elasticsearch/model'
|
9
|
+
require 'elasticsearch/rails'
|
10
|
+
|
11
|
+
logger = ::Rails.logger
|
12
|
+
url = ENV['BONSAI_URL'] || ENV['ELASTICSEARCH_URL']
|
13
|
+
|
14
|
+
begin
|
15
|
+
if url && URI.parse(url)
|
16
|
+
filtered_url = url.sub(%r{:[^:@]+@}, ':FILTERED@')
|
17
|
+
logger.debug("Bonsai: Initializing default Elasticsearch client with #{filtered_url}")
|
18
|
+
::Elasticsearch::Model.client = ::Elasticsearch::Client.new(
|
19
|
+
url: url
|
20
|
+
)
|
21
|
+
elsif ::Rails.env.production?
|
22
|
+
logger.debug("BONSAI_URL not present, proceeding with Elasticsearch defaults.")
|
23
|
+
end
|
24
|
+
rescue URI::InvalidURIError => e
|
25
|
+
logger.error("Elasticsearch cluster URL is invalid: #{e.message}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bonsai-elasticsearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Sears
|
8
|
+
- Nick Zadrozny
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: elasticsearch-model
|
@@ -99,11 +100,13 @@ description: |2
|
|
99
100
|
The cluster URL is available via the Bonsai dashboard.
|
100
101
|
email:
|
101
102
|
- rob@onemorecloud.com
|
103
|
+
- nick@onemorecloud.com
|
102
104
|
executables: []
|
103
105
|
extensions: []
|
104
106
|
extra_rdoc_files: []
|
105
107
|
files:
|
106
108
|
- lib/bonsai-elasticsearch-rails.rb
|
109
|
+
- lib/bonsai/elasticsearch/rails/railtie.rb
|
107
110
|
homepage: https://github.com/omc/bonsai-elasticsearch-rails
|
108
111
|
licenses:
|
109
112
|
- MIT
|