esse 0.1.1 → 0.1.2

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: 74a999f5083a3e258834ca27ac444c63e8f10e20940106f1415331d8a5e772b7
4
- data.tar.gz: e7e2853b5fe1296795e6a5d306d12e2ac5c91e88cba671e2cd980ee1b1edfb2e
3
+ metadata.gz: 4dff3560f305debeee691263267e43df0e70a17591f6ecfc897025a5c07ada8a
4
+ data.tar.gz: a8ba452b0bfc81210f104293f852ecacaef585ea23b2e8f24177197fa2555e69
5
5
  SHA512:
6
- metadata.gz: 04a5efa492606d9385b07d8f076966b85bf825ffb49d37c9e35edd8fa5be5c4d283ac193097733f16583f920472aa83e2f1c05a00188649932c2c63ce6f14e53
7
- data.tar.gz: 34b4426c3014edfcfe2c1320da019ba6b5c2566842baeb78e14e73df1df173f7a3a7298505b94128180a094aa953ee83dbf09a0e48791d65aa70f04f9e2c5fd9
6
+ metadata.gz: 73bfc1a130c18df947cd02120087eed2b571fa174b84009b687dc0e343697aec1a1a20ae00eb0fc8465a9ad603d95318c02d324b98fe811baddc0b08d3533e28
7
+ data.tar.gz: 160aaf9fdef9da05108c1e966cfc03a45f9357aeb4682d551458546f66dc067d0585e52f0836aa0b4ee8fb5d634d3b705bced6340e91a99013d571fcded5f574
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_operation'
4
+
5
+ module Esse
6
+ module CLI
7
+ class Index::Import < Index::BaseOperation
8
+ def run
9
+ validate_options!
10
+ indices.each do |index|
11
+ index.elasticsearch.import!(**options)
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def options
18
+ @options.slice(*@options.keys - CLI_IGNORE_OPTS)
19
+ end
20
+
21
+ def validate_options!
22
+ validate_indices_option!
23
+ end
24
+ end
25
+ end
26
+ end
@@ -77,6 +77,14 @@ module Esse
77
77
  require_relative 'index/open'
78
78
  Open.new(indices: index_classes, **options.to_h.transform_keys(&:to_sym)).run
79
79
  end
80
+
81
+ desc 'import *INDEX_CLASSES', 'Import documents from the given classes'
82
+ option :suffix, type: :string, default: nil, aliases: '-s', desc: 'Suffix to append to index name'
83
+ option :context, type: :hash, default: {}, required: true, desc: 'List of options to pass to the index class'
84
+ def import(*index_classes)
85
+ require_relative 'index/import'
86
+ Import.new(indices: index_classes, **HashUtils.deep_transform_keys(options.to_h, &:to_sym)).run
87
+ end
80
88
  end
81
89
  end
82
90
  end
@@ -26,15 +26,15 @@ class <%= @index_name %> < <%= @base_class %>
26
26
 
27
27
  yield(rows, **params)
28
28
  end
29
+ end
29
30
 
30
- protected
31
+ protected
31
32
 
32
- attr_reader :params
33
+ attr_reader :params
33
34
 
34
- # @param offset [Number] Offset to start from
35
- def find_all(offset)
36
- # @TODO load data from persistent store
37
- end
35
+ # @param offset [Number] Offset to start from
36
+ def find_all(offset)
37
+ # @TODO load data from persistent store
38
38
  end
39
39
  end
40
40
  end
@@ -6,6 +6,17 @@ module Esse
6
6
  module HashUtils
7
7
  module_function
8
8
 
9
+ def deep_transform_keys(hash, &block)
10
+ hash.each_with_object({}) do |(key, value), result|
11
+ result[yield(key)] = \
12
+ if value.is_a?(Hash)
13
+ deep_transform_keys(value, &block)
14
+ else
15
+ value
16
+ end
17
+ end
18
+ end
19
+
9
20
  def deep_merge(target, source)
10
21
  target.merge(source) do |key, oldval, newval|
11
22
  if oldval.is_a?(Hash) && newval.is_a?(Hash)
data/lib/esse/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Esse
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos G. Zimmermann
8
8
  autorequire:
9
9
  bindir: exec
10
10
  cert_chain: []
11
- date: 2022-01-27 00:00:00.000000000 Z
11
+ date: 2022-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch
@@ -246,6 +246,7 @@ files:
246
246
  - lib/esse/cli/index/close.rb
247
247
  - lib/esse/cli/index/create.rb
248
248
  - lib/esse/cli/index/delete.rb
249
+ - lib/esse/cli/index/import.rb
249
250
  - lib/esse/cli/index/open.rb
250
251
  - lib/esse/cli/index/reset.rb
251
252
  - lib/esse/cli/index/update_aliases.rb