goodyear 0.1.0 → 0.2.0
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 +4 -4
- data/lib/goodyear/index.rb +49 -0
- data/lib/goodyear/version.rb +1 -1
- data/lib/goodyear.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50ec1a555376dedcd7d61bd6ee0af28c5ff1d223
|
4
|
+
data.tar.gz: cc8c41f84f247e8e5b6545b0d370bd2880811d4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/goodyear/version.rb
CHANGED
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.
|
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-
|
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
|