stretcher 1.21.0.beta2 → 1.21.0

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
  SHA1:
3
- metadata.gz: 0ce236606130c06da32f892b0dc2b65bae05118f
4
- data.tar.gz: d609025a35624c98fa675dfe4fa878a8900f7e61
3
+ metadata.gz: 85bcaf96526c898dbcdf9787e6ae41fbf8d88be5
4
+ data.tar.gz: 668a0bbe9a04ec5e69c2b3d62b771449d59f4588
5
5
  SHA512:
6
- metadata.gz: fbc088865620e42c268673837cd6c66ac8398f7643ff00be75e12a8310b15050010355f86d3e3d4c1fd64d0c1b325b2c6fdad51f2393d0b0c6712bf25ca25eee
7
- data.tar.gz: 6e54d0d191f3a7adfc507ad7c1f3743b3bb11132198b4d84e4c01b303544b109b673d02de6a03eb108910ce49653b1e878773ec6e939d59ce9e6307ffb162231
6
+ metadata.gz: 113de685c58e2350fbf8cd1eaa00c46393fa20d33f681ddbfb0540a568ffe564911bf59fc0b05d909c3c6c9ebc3019a10e2de4c5f2c117b5a5ead116c058c211
7
+ data.tar.gz: 419d71e6f5c7549d8740a39601d03577b5cdc14173474ecc231d9e861b435a088f93ba9f9ad6f5964b331e1af9d95f3e67c0faee72195959cd9391cf76cc86f3
@@ -6,6 +6,5 @@ services:
6
6
  rvm:
7
7
  - 2.0.0
8
8
  - 1.9.3
9
- - jruby-head
10
9
  - jruby-19mode
11
10
  - rbx-19mode
data/README.md CHANGED
@@ -17,7 +17,7 @@ A concise, fast ElasticSearch Ruby client designed to reflect the actual elastic
17
17
  * Logs curl commandline statements in debug mode
18
18
  * Pure, threadsafe, ruby
19
19
  * Easily swap HTTP clients via Faraday
20
- * Tested against Ruby 2.0,1.9,1.8.7, Jruby, and Rubinius
20
+ * Tested against Ruby 2.0,1.9, Jruby, and Rubinius
21
21
  * [Semantically versioned](http://semver.org/)
22
22
 
23
23
  ## Installation
@@ -11,7 +11,7 @@ module Stretcher
11
11
  def initialize(raw)
12
12
  @raw_plain = raw
13
13
  end
14
-
14
+
15
15
  # Returns a plain (string keyed) hash of the raw response
16
16
  # Normally stretcher deals in Hashie::Mash-ified versions of data
17
17
  # If you have truly gigantic result sets this may matter.
@@ -23,7 +23,7 @@ module Stretcher
23
23
  def raw
24
24
  @raw ||= Hashie::Mash.new(@raw_plain)
25
25
  end
26
-
26
+
27
27
  # Returns the total number of results
28
28
  def total
29
29
  @total ||= raw_plain['hits']['total']
@@ -33,12 +33,12 @@ module Stretcher
33
33
  # Equivalent to raw[:facets]
34
34
  def facets
35
35
  @facets ||= raw[:facets]
36
- end
37
-
36
+ end
37
+
38
38
  # Returns a 'prettier' version of elasticsearch results
39
39
  # Also aliased as +docs+
40
40
  # This will:
41
- #
41
+ #
42
42
  # 1. Return either '_source' or 'fields' as the base of the result
43
43
  # 2. Merge any keys beginning with a '_' into it as well (such as '_score')
44
44
  # 3. Copy the 'highlight' field into '_highlight'
@@ -59,9 +59,9 @@ module Stretcher
59
59
  def results
60
60
  documents
61
61
  end
62
-
62
+
63
63
  private
64
-
64
+
65
65
  def extract_source(hit)
66
66
  # Memoize the key, since it will be uniform across results
67
67
  @doc_key ||= if hit.key?(:_source)
@@ -71,8 +71,8 @@ module Stretcher
71
71
  else
72
72
  nil
73
73
  end
74
-
75
- Hashie::Mash.new(@doc_key ? hit[@doc_key] : Hashie::Mash.new)
74
+
75
+ Hashie::Mash.new(@doc_key ? hit[@doc_key] : Hashie::Mash.new)
76
76
  end
77
77
 
78
78
  def copy_underscores(hit, doc)
@@ -80,13 +80,13 @@ module Stretcher
80
80
  hit.each do |k,v|
81
81
  doc[k] = v if k && k[0] == "_"
82
82
  end
83
-
83
+
84
84
  doc
85
85
  end
86
86
 
87
87
  def copy_highlight(hit, doc)
88
- if highlight = hit.key?("highlight")
89
- doc[:_highlight] = highlight
88
+ if highlight = hit["highlight"]
89
+ doc[:_highlight] = highlight
90
90
  end
91
91
  doc
92
92
  end
@@ -1,3 +1,3 @@
1
1
  module Stretcher
2
- VERSION = "1.21.0.beta2"
2
+ VERSION = "1.21.0"
3
3
  end
@@ -10,20 +10,47 @@ describe Stretcher::SearchResults do
10
10
  '_score' => 255,
11
11
  '_id' => 2,
12
12
  '_index' => 'index_name',
13
- '_type' => 'type_name'
13
+ '_type' => 'type_name',
14
14
  }]
15
15
  }
16
16
  })
17
17
  end
18
18
 
19
- context 'merges in select keys' do
19
+ let(:result_with_hightlight) do
20
+ Hashie::Mash.new({
21
+ 'facets' => [],
22
+ 'hits' => {
23
+ 'total' => 1,
24
+ 'hits' => [{
25
+ '_score' => 255,
26
+ '_id' => 2,
27
+ '_index' => 'index_name',
28
+ '_type' => 'type_name',
29
+ 'highlight' => {'message.*' => ["meeting at <hit>protonet</hit>!"]}
30
+ }]
31
+ }
32
+ })
33
+ end
34
+
35
+
36
+ context 'merges in underscore keys' do
20
37
  subject(:search_result) {
21
38
  Stretcher::SearchResults.new(result).documents.first
22
39
  }
23
-
40
+
24
41
  its(:_score) { should == 255 }
25
42
  its(:_id) { should == 2 }
26
43
  its(:_index) { should == 'index_name' }
27
44
  its(:_type) { should == 'type_name' }
45
+ its(:_highlight) { should be(nil) }
46
+ end
47
+
48
+ context 'merges in optional keys' do
49
+ subject(:search_result) {
50
+ Stretcher::SearchResults.new(result_with_hightlight).documents.first
51
+ }
52
+
53
+ its(:_id) { should == 2 }
54
+ its(:_highlight) { should == {'message.*' => ["meeting at <hit>protonet</hit>!"]} }
28
55
  end
29
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stretcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.0.beta2
4
+ version: 1.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Cholakian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-30 00:00:00.000000000 Z
11
+ date: 2013-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -213,9 +213,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  requirements:
216
- - - '>'
216
+ - - '>='
217
217
  - !ruby/object:Gem::Version
218
- version: 1.3.1
218
+ version: '0'
219
219
  requirements: []
220
220
  rubyforge_project:
221
221
  rubygems_version: 2.0.2