elasticsearch-dsl-builder 0.0.15 → 0.0.16
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 418d5192343837465ab9d7a60484aacc9eb9f501
|
4
|
+
data.tar.gz: e0627ac86a4f19429291920b72002b9d282ecb8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d44a4bb6bb06cc966024627bf37715a96f01b706732d8ed00a5601f8e1ac13b5a5a91b0a0daf0680dd087e0792febbec00a6a7e0a6d8ce11b6afbd6dbf9a87cb
|
7
|
+
data.tar.gz: b2b3566b4d78722c80029f2da00a28510f1e2eee02c702180eb7cc82a693fa07215aa1102071d5604a89f9dd47ebe6a939f117007822b32202e69a7dc83dd059
|
data/Gemfile.lock
CHANGED
@@ -15,6 +15,13 @@ module ElasticsearchDslBuilder
|
|
15
15
|
self
|
16
16
|
end
|
17
17
|
|
18
|
+
def inline(inline)
|
19
|
+
raise ArgumentError, 'can be inline or file script. not both' if @file
|
20
|
+
raise ArgumentError, 'inline must be a String' unless inline.instance_of?(String)
|
21
|
+
@inline = inline
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
18
25
|
def file(file)
|
19
26
|
raise ArgumentError, 'can be inline or file script. not both' if @source
|
20
27
|
raise ArgumentError, 'file must be a String' unless file.instance_of?(String)
|
@@ -32,6 +39,7 @@ module ElasticsearchDslBuilder
|
|
32
39
|
script = {}
|
33
40
|
@lang ||= 'painless'
|
34
41
|
script.update(lang: @lang, source: @source) if @source
|
42
|
+
script.update(lang: @lang, inline: @inline) if @inline
|
35
43
|
script.update(file: @file) if @file
|
36
44
|
script.update(params: @params) if @params
|
37
45
|
script
|
@@ -11,6 +11,11 @@ describe ElasticsearchDslBuilder::DSL::Search::Script do
|
|
11
11
|
expect { Script.new.source(nil) }.to raise_error(ArgumentError)
|
12
12
|
end
|
13
13
|
|
14
|
+
it 'should raise error if inline not valid' do
|
15
|
+
expect { Script.new.inline(123) }.to raise_error(ArgumentError)
|
16
|
+
expect { Script.new.inline(nil) }.to raise_error(ArgumentError)
|
17
|
+
end
|
18
|
+
|
14
19
|
it 'should raise error if file not valid' do
|
15
20
|
expect { Script.new.file(123) }.to raise_error(ArgumentError)
|
16
21
|
expect { Script.new.file(nil) }.to raise_error(ArgumentError)
|
@@ -27,6 +32,9 @@ describe ElasticsearchDslBuilder::DSL::Search::Script do
|
|
27
32
|
end
|
28
33
|
|
29
34
|
it 'should chain build valid ES script' do
|
35
|
+
script = Script.new.lang('painless').inline('inline').params(field: 'value')
|
36
|
+
expect(script.to_hash).to eq(lang: 'painless', inline: 'inline', params: { field: 'value' })
|
37
|
+
|
30
38
|
script = Script.new.lang('painless').source('source').params(field: 'value')
|
31
39
|
expect(script.to_hash).to eq(lang: 'painless', source: 'source', params: { field: 'value' })
|
32
40
|
|