goodyear 0.1.0 → 0.2.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: 5c0e7a5df2d732be684ff4696771e3f6746a363c
4
- data.tar.gz: 731af182b52f774cd37d02ce2f05755c4addd351
3
+ metadata.gz: 50ec1a555376dedcd7d61bd6ee0af28c5ff1d223
4
+ data.tar.gz: cc8c41f84f247e8e5b6545b0d370bd2880811d4e
5
5
  SHA512:
6
- metadata.gz: 87df72d054ec674f2b3b06e8ebb747001dc7a7ed709627a7dcfad7848337dcc478f12c3d3141737f0f60a04def4f6183073274bdb38aed32e758554e940b509a
7
- data.tar.gz: 57ee26b0a4f0cfa3f2038980ad235b084b56aca6e5807ad3f8527f7e0a07747d48d92e3c1ed6622008b3a76a3cd515e975f942b01d8da09e3a7e3b1aea3bf850
6
+ metadata.gz: 730d430c78ae09d1d856c7c609ee49f012009f98901843c65c5553ad9f7570f735e2ba338d56ae394f00888f57d6db5fc2d1e4e042a680383b61083298519ac4
7
+ data.tar.gz: c25747f334ffca81cb31d807aee123e6fcb4a46b3f32c13e96a2414d87bf55c364ee6006729a94af221f568003ccddba35f8203cad6e2b22f894af39ba4d8bb1
@@ -0,0 +1,49 @@
1
+ module Tire
2
+ class Index
3
+ def store(*args)
4
+ document, options = args
5
+
6
+ id = get_id_from_document(document)
7
+ type = get_type_from_document(document)
8
+ index = get_index_from_document(document)
9
+ document = convert_document_to_json(document)
10
+
11
+ options ||= {}
12
+ params = {}
13
+
14
+ if options[:percolate]
15
+ params[:percolate] = options[:percolate]
16
+ params[:percolate] = "*" if params[:percolate] === true
17
+ end
18
+
19
+ params[:parent] = options[:parent] if options[:parent]
20
+ params[:routing] = options[:routing] if options[:routing]
21
+ params[:replication] = options[:replication] if options[:replication]
22
+ params[:version] = options[:version] if options[:version]
23
+
24
+ params_encoded = params.empty? ? '' : "?#{params.to_param}"
25
+
26
+ url_with_index = index.blank? ? self.url : self.url.gsub(name, index)
27
+ url = id ? "#{url_with_index}/#{type}/#{Utils.escape(id)}#{params_encoded}" : "#{url_with_index}/#{type}/#{params_encoded}"
28
+
29
+ @response = Configuration.client.post url, document
30
+ MultiJson.decode(@response.body)
31
+ ensure
32
+ curl = %Q|curl -X POST "#{url}" -d '#{document}'|
33
+ logged([type, id].join('/'), curl)
34
+ end
35
+
36
+
37
+ def get_index_from_document(document)
38
+ ind = case
39
+ when document.is_a?(Hash)
40
+ document[:_index] || document['_index']
41
+ when document.respond_to?(:_index)
42
+ document._index
43
+ end
44
+
45
+ return ind if ind.to_s != @name.to_s
46
+ end
47
+
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module Goodyear
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/goodyear.rb CHANGED
@@ -2,6 +2,7 @@ require 'goodyear/railtie' if defined?(Rails)
2
2
  require "goodyear/version"
3
3
  require "goodyear/query_methods"
4
4
  require 'goodyear/persistence'
5
+ require 'goodyear/index'
5
6
 
6
7
  module Goodyear
7
8
  mattr_accessor :force_cache
@@ -24,5 +25,6 @@ module Goodyear
24
25
  Goodyear.force_cache = false
25
26
  lm
26
27
  end
28
+
27
29
  end
28
30
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodyear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spencer Markowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-25 00:00:00.000000000 Z
11
+ date: 2014-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,6 +57,7 @@ files:
57
57
  - lib/goodyear/facet_methods.rb
58
58
  - lib/goodyear/filter_methods.rb
59
59
  - lib/goodyear/finder_methods.rb
60
+ - lib/goodyear/index.rb
60
61
  - lib/goodyear/persistence.rb
61
62
  - lib/goodyear/query.rb
62
63
  - lib/goodyear/query_builder.rb