primedia-endeca 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/endeca.gemspec +2 -2
- data/example/listing.rb +1 -1
- data/lib/endeca/request.rb +18 -1
- data/lib/endeca.rb +1 -1
- data/spec/endeca/request_spec.rb +33 -10
- metadata +2 -2
data/endeca.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{endeca}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.12.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Rein Henrichs", "Andy Stone"]
|
9
|
-
s.date = %q{2009-04-
|
9
|
+
s.date = %q{2009-04-06}
|
10
10
|
s.description = %q{An Endeca client library for Ruby.}
|
11
11
|
s.email = %q{}
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
|
data/example/listing.rb
CHANGED
data/lib/endeca/request.rb
CHANGED
@@ -15,7 +15,9 @@ module Endeca
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def perform
|
18
|
-
handle_response(get_response)
|
18
|
+
response = handle_response(get_response)
|
19
|
+
raise RequestError, endeca_error(response)[:message] if endeca_error?(response)
|
20
|
+
return response
|
19
21
|
end
|
20
22
|
|
21
23
|
def uri
|
@@ -27,6 +29,21 @@ module Endeca
|
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
32
|
+
|
33
|
+
def endeca_error(response)
|
34
|
+
method_response = response["methodResponse"]
|
35
|
+
fault = method_response && response["methodResponse"]["fault"]
|
36
|
+
values = fault && response["methodResponse"]["fault"]["value"]
|
37
|
+
return nil unless values
|
38
|
+
{
|
39
|
+
:code => values["faultCode"].to_i,
|
40
|
+
:message => values["faultString"]
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def endeca_error?(response)
|
45
|
+
!endeca_error(response).nil?
|
46
|
+
end
|
30
47
|
|
31
48
|
def get_response #:nodoc:
|
32
49
|
Endeca.log "ENDECA ADAPTER REQUEST"
|
data/lib/endeca.rb
CHANGED
data/spec/endeca/request_spec.rb
CHANGED
@@ -34,6 +34,10 @@ describe Endeca::Request do
|
|
34
34
|
it "should return the parsed JSON of the response body" do
|
35
35
|
@request.perform.should == @response_hash
|
36
36
|
end
|
37
|
+
|
38
|
+
it "should not raise an error" do
|
39
|
+
lambda { @request.perform }.should_not raise_error
|
40
|
+
end
|
37
41
|
end
|
38
42
|
|
39
43
|
describe "when unsuccessful" do
|
@@ -46,20 +50,39 @@ describe Endeca::Request do
|
|
46
50
|
end
|
47
51
|
|
48
52
|
end
|
53
|
+
|
54
|
+
describe "when the response contains an error hash" do
|
55
|
+
before do
|
56
|
+
@error_message = "com.endeca.soleng.urlformatter.QueryBuildException: com.endeca.navigation.UrlENEQueryParseException: java.lang.NumberFormatException: For input string: \"asdjkhfgasdfjkhg\""
|
57
|
+
@error_response = {
|
58
|
+
"methodResponse"=>
|
59
|
+
{"fault"=>
|
60
|
+
{"value"=>
|
61
|
+
{"faultCode"=>"-1",
|
62
|
+
"faultString"=> @error_message}}}}
|
63
|
+
@error_request = Endeca::Request.new(@path)
|
64
|
+
@error_request.stub!(:handle_response).and_return(@error_response)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should raise an Endeca::RequestError" do
|
68
|
+
lambda { @error_request.perform }.should raise_error(Endeca::RequestError, @error_message)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
49
72
|
end
|
50
73
|
|
51
74
|
describe '#uri'
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
75
|
+
describe "with a hash of query options" do
|
76
|
+
it "should append the query options onto the url" do
|
77
|
+
query = {:foo => :bar}
|
78
|
+
Endeca::Request.new(@path, query).uri.query.should == query.to_endeca_params
|
57
79
|
end
|
80
|
+
end
|
58
81
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
82
|
+
describe "with a string of query options" do
|
83
|
+
it "should append the query options string onto the url" do
|
84
|
+
query = 'N=56'
|
85
|
+
Endeca::Request.new(@path, query).uri.query.should == query.to_endeca_params
|
64
86
|
end
|
87
|
+
end
|
65
88
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primedia-endeca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rein Henrichs
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-04-
|
13
|
+
date: 2009-04-06 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|