inquisitio 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/inquisitio/configuration.rb +5 -2
- data/lib/inquisitio/indexer.rb +15 -6
- data/lib/inquisitio/version.rb +1 -1
- data/test/configuration_test.rb +13 -0
- data/test/indexer_test.rb +12 -0
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjQ5Y2RhNzkxM2MwZmE5OTVmY2FkYjI0NGJmNDFlY2JkM2Q5ZmE5NQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzE0OWNkZjkwZTk5M2VmZjQyOWIxOWYxNGUwMjBlZjhmNjlhZTc4MA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTM0NWJmMjlmMTNmYjZlZDFkMTdhMzI2OTNmZmUzZDA4OWJkOTljYTk0OTYw
|
10
|
+
Mjk3ODBiNWVjMjZjOTA5ZWZlOGI2MDcwZjE2NWI1M2I3N2ZhMmJlYjY0ZTY2
|
11
|
+
NzZhNjA1MTZlY2Y1NzA2NzAyMDU1OTM0NWNkNGZmZTMxZTZiMGI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZWUwMzViZjJhMDQ3MjllY2NiOTc4MzY0MWNkZGI2MmYzN2M0NDNmMjg2MjRk
|
14
|
+
YzMyOTMzYjM5ZTUzNGI2ZDBkYmNiNmQwOWM4ZWY0ZjMyZjJmNTYyZTAwOWMx
|
15
|
+
Y2ZmMWEyNzZjOTZiOTlkNjZlOTk1MDJhZTYwZjdkNTE5MjMzOWU=
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -9,12 +9,15 @@ module Inquisitio
|
|
9
9
|
:search_endpoint,
|
10
10
|
:document_endpoint,
|
11
11
|
:default_search_size,
|
12
|
+
:dry_run,
|
12
13
|
:logger
|
13
14
|
]
|
15
|
+
|
14
16
|
attr_writer *SETTINGS
|
15
17
|
|
16
18
|
def initialize
|
17
19
|
self.logger = Inquisitio::Logger.new
|
20
|
+
self.dry_run = false
|
18
21
|
end
|
19
22
|
|
20
23
|
SETTINGS.each do |setting|
|
@@ -26,8 +29,8 @@ module Inquisitio
|
|
26
29
|
private
|
27
30
|
|
28
31
|
def get_or_raise(setting)
|
29
|
-
instance_variable_get("@#{setting.to_s}")
|
30
|
-
|
32
|
+
val = instance_variable_get("@#{setting.to_s}")
|
33
|
+
val.nil?? raise(InquisitioConfigurationError.new("Configuration for #{setting} is not set")) : val
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
data/lib/inquisitio/indexer.rb
CHANGED
@@ -16,12 +16,11 @@ module Inquisitio
|
|
16
16
|
|
17
17
|
def index
|
18
18
|
Inquisitio.config.logger.info "Indexer posting to #{batch_index_url} body: #{body}"
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
response.body
|
19
|
+
if Inquisitio.config.dry_run
|
20
|
+
Inquisitio.config.logger.info "Skipping POST as running in dry-run mode"
|
21
|
+
else
|
22
|
+
post_to_endpoint
|
23
|
+
end
|
25
24
|
end
|
26
25
|
|
27
26
|
private
|
@@ -34,5 +33,15 @@ module Inquisitio
|
|
34
33
|
def batch_index_url
|
35
34
|
"#{Inquisitio.config.document_endpoint}/2011-02-01/documents/batch"
|
36
35
|
end
|
36
|
+
|
37
|
+
def post_to_endpoint
|
38
|
+
response = Excon.post(batch_index_url,
|
39
|
+
:body => body,
|
40
|
+
:headers => {"Content-Type" =>"application/json"})
|
41
|
+
Inquisitio.config.logger.info "Response - status: #{response.status} body: #{response.body}"
|
42
|
+
raise InquisitioError.new("Index failed with status code: #{response.status} Message: #{response.body}") unless response.status == 200
|
43
|
+
response.body
|
44
|
+
end
|
45
|
+
|
37
46
|
end
|
38
47
|
end
|
data/lib/inquisitio/version.rb
CHANGED
data/test/configuration_test.rb
CHANGED
@@ -54,6 +54,19 @@ module Inquisitio
|
|
54
54
|
Inquisitio.config.default_search_size
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
def test_logger_is_configured_by_default
|
59
|
+
assert_kind_of Inquisitio::Logger, Inquisitio.config.logger
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_dry_run_disabled_by_default
|
63
|
+
refute Inquisitio.config.dry_run
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_enable_dry_run
|
67
|
+
Inquisitio.config.dry_run = true
|
68
|
+
assert Inquisitio.config.dry_run
|
69
|
+
end
|
57
70
|
end
|
58
71
|
end
|
59
72
|
|
data/test/indexer_test.rb
CHANGED
@@ -7,6 +7,8 @@ module Inquisitio
|
|
7
7
|
Inquisitio.config.document_endpoint = @document_endpoint
|
8
8
|
#def initialize(type, id, version, fields)
|
9
9
|
@documents = [Document.new("add", "12345", 1, {})]
|
10
|
+
|
11
|
+
Inquisitio.config.dry_run = false
|
10
12
|
end
|
11
13
|
|
12
14
|
def teardown
|
@@ -70,5 +72,15 @@ module Inquisitio
|
|
70
72
|
response = indexer.index
|
71
73
|
assert_equal body, response
|
72
74
|
end
|
75
|
+
|
76
|
+
def test_index_does_not_post_when_in_dry_run_mode
|
77
|
+
Excon.defaults[:mock] = true
|
78
|
+
|
79
|
+
Inquisitio.config.dry_run = true
|
80
|
+
|
81
|
+
indexer = Indexer.new(@documents)
|
82
|
+
response = indexer.index
|
83
|
+
assert response.nil?
|
84
|
+
end
|
73
85
|
end
|
74
86
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inquisitio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Walker
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: excon
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
name: ruby_deep_clone
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - '>='
|
33
|
+
- - ! '>='
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - '>='
|
40
|
+
- - ! '>='
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
@@ -58,42 +58,42 @@ dependencies:
|
|
58
58
|
name: rake
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - '>='
|
61
|
+
- - ! '>='
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- - '>='
|
68
|
+
- - ! '>='
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: mocha
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - '>='
|
75
|
+
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - '>='
|
82
|
+
- - ! '>='
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: yard
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - '>='
|
89
|
+
- - ! '>='
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- - '>='
|
96
|
+
- - ! '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
- !ruby/object:Gem::Dependency
|
@@ -165,17 +165,17 @@ require_paths:
|
|
165
165
|
- lib
|
166
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- - '>='
|
168
|
+
- - ! '>='
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
172
|
requirements:
|
173
|
-
- - '>='
|
173
|
+
- - ! '>='
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.1.9
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: This wraps AWS CloudSearch in a Ruby Gem
|