File: elastic_ruby_console

package info (click to toggle)
ruby-elasticsearch 7.17.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,820 kB
  • sloc: ruby: 44,308; sh: 16; makefile: 2
file content (46 lines) | stat: -rwxr-xr-x 1,264 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.expand_path('../../elasticsearch/lib', __dir__))
$LOAD_PATH.unshift(File.expand_path('../../elasticsearch-transport/lib', __dir__))
$LOAD_PATH.unshift(File.expand_path('../../elasticsearch-dsl/lib', __dir__))
$LOAD_PATH.unshift(File.expand_path('../../elasticsearch-api/lib', __dir__))
$LOAD_PATH.unshift(File.expand_path('../../elasticsearch-xpack/lib', __dir__))
$LOAD_PATH.unshift(File.expand_path('../../elasticsearch-extensions/lib', __dir__))

require 'elasticsearch'
require 'elasticsearch-transport'
require 'elasticsearch-api'

gems_not_loaded = ['elasticsearch-dsl', 'elasticsearch/xpack', 'elasticsearch-extensions'].reject do |gem|
  begin
    (require gem) || true
  rescue LoadError
    false
  end
end

unless gems_not_loaded.empty?
  warn "The following gems were not loaded: [#{gems_not_loaded.join(', ')}]. Please install and require them explicitly."
end

include Elasticsearch
include Elasticsearch::DSL if defined?(Elasticsearch::DSL)

begin
  require 'pry'
rescue LoadError
end

begin
  require 'irb'
rescue LoadError
end

if defined?(Pry)
  Pry.config.prompt_name = 'elastic_ruby'
  Pry.start
elsif defined?(IRB)
  IRB.start
else
  abort 'LoadError: elastic_ruby_console requires Pry or IRB'
end