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: 3cd56b7c2da3fde323d2b45b9a44cfa90aa2ad1b
4
- data.tar.gz: 8d3cbbd3d97b17a88ca1ba879c38eb4981e4a09d
3
+ metadata.gz: 418d5192343837465ab9d7a60484aacc9eb9f501
4
+ data.tar.gz: e0627ac86a4f19429291920b72002b9d282ecb8f
5
5
  SHA512:
6
- metadata.gz: d78f1a2d967897f2b5e39125ab947792c3226dce95a6c9ed17bfc5e42c928e3202a46a31e5b2d2f7fdd65768f4f96027f3629282d67d3c8bde9b13234dd3f014
7
- data.tar.gz: 349e21160f7121ae9ba3882721968961ccb2c5fe8c7ac87d5c2bb4e8e8e824b32db227388520933a78672c849e481874f667785faa6b2174c9580477f9912929
6
+ metadata.gz: d44a4bb6bb06cc966024627bf37715a96f01b706732d8ed00a5601f8e1ac13b5a5a91b0a0daf0680dd087e0792febbec00a6a7e0a6d8ce11b6afbd6dbf9a87cb
7
+ data.tar.gz: b2b3566b4d78722c80029f2da00a28510f1e2eee02c702180eb7cc82a693fa07215aa1102071d5604a89f9dd47ebe6a939f117007822b32202e69a7dc83dd059
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elasticsearch-dsl-builder (0.0.14)
4
+ elasticsearch-dsl-builder (0.0.16)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'elasticsearch-dsl-builder'
3
- s.version = '0.0.15'
3
+ s.version = '0.0.16'
4
4
  s.date = '2017-10-06'
5
5
  s.summary = 'Library utilizing builder pattern providing Ruby API for the Elasticsearch Query DSL'
6
6
  s.description = 'TBD'
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-dsl-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Guerra