endeca_on_demand 0.9.7 → 0.9.8
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.
- data/lib/endeca_on_demand/business_rule.rb +1 -7
- data/lib/endeca_on_demand/business_rule_property.rb +1 -7
- data/lib/endeca_on_demand/crumb.rb +1 -7
- data/lib/endeca_on_demand/dimension.rb +1 -7
- data/lib/endeca_on_demand/dimension_value.rb +1 -7
- data/lib/endeca_on_demand/dimension_value_id.rb +1 -7
- data/lib/endeca_on_demand/proxy.rb +11 -0
- data/lib/endeca_on_demand/record.rb +1 -7
- data/lib/endeca_on_demand/search.rb +1 -7
- data/lib/endeca_on_demand/version.rb +1 -1
- data/lib/endeca_on_demand.rb +60 -50
- metadata +3 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class BusinessRule
|
2
|
+
class BusinessRule < Proxy
|
3
3
|
|
4
4
|
attr_reader :properties_array
|
5
5
|
|
@@ -13,11 +13,5 @@ class EndecaOnDemand
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def method_missing(method, *args, &block)
|
17
|
-
unless self.instance_variables.include?(:"@#{method}")
|
18
|
-
"N/A"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
16
|
end
|
23
17
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class BusinessRuleProperty
|
2
|
+
class BusinessRuleProperty < Proxy
|
3
3
|
|
4
4
|
def initialize(property)
|
5
5
|
property.each do |key, value|
|
@@ -8,11 +8,5 @@ class EndecaOnDemand
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def method_missing(method, *args, &block)
|
12
|
-
unless self.instance_variables.include?(:"@#{method}")
|
13
|
-
"N/A"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
11
|
end
|
18
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class Crumb
|
2
|
+
class Crumb < Proxy
|
3
3
|
|
4
4
|
def initialize(crumb)
|
5
5
|
crumb.each do |key, value|
|
@@ -8,11 +8,5 @@ class EndecaOnDemand
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def method_missing(method, *args, &block)
|
12
|
-
unless self.instance_variables.include?(:"@#{method}")
|
13
|
-
"N/A"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
11
|
end
|
18
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class Dimension
|
2
|
+
class Dimension < Proxy
|
3
3
|
|
4
4
|
attr_reader :dimension_values
|
5
5
|
|
@@ -12,11 +12,5 @@ class EndecaOnDemand
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def method_missing(method, *args, &block)
|
16
|
-
unless self.instance_variables.include?(:"@#{method}")
|
17
|
-
"N/A"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
15
|
end
|
22
16
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class DimensionValue
|
2
|
+
class DimensionValue < Proxy
|
3
3
|
|
4
4
|
def initialize(dimension_value)
|
5
5
|
dimension_value.each do |key, value|
|
@@ -8,11 +8,5 @@ class EndecaOnDemand
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def method_missing(method, *args, &block)
|
12
|
-
unless self.instance_variables.include?(:"@#{method}")
|
13
|
-
"N/A"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
11
|
end
|
18
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class DimensionValueId
|
2
|
+
class DimensionValueId < Proxy
|
3
3
|
|
4
4
|
def initialize(id)
|
5
5
|
id.each do |key, value|
|
@@ -8,11 +8,5 @@ class EndecaOnDemand
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def method_missing(method, *args, &block)
|
12
|
-
unless self.instance_variables.include?(:"@#{method}")
|
13
|
-
"N/A"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
11
|
end
|
18
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class Record
|
2
|
+
class Record < Proxy
|
3
3
|
|
4
4
|
def initialize(record)
|
5
5
|
record.each do |key, value|
|
@@ -8,11 +8,5 @@ class EndecaOnDemand
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def method_missing(method, *args, &block)
|
12
|
-
unless self.instance_variables.include?(:"@#{method}")
|
13
|
-
"N/A"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
11
|
end
|
18
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class Search
|
2
|
+
class Search < Proxy
|
3
3
|
|
4
4
|
def initialize(report)
|
5
5
|
report.each do |key, value|
|
@@ -8,11 +8,5 @@ class EndecaOnDemand
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def method_missing(method, *args, &block)
|
12
|
-
unless self.instance_variables.include?(:"@#{method}")
|
13
|
-
"N/A"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
11
|
end
|
18
12
|
end
|
data/lib/endeca_on_demand.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'endeca_on_demand/proxy'
|
2
|
+
|
1
3
|
Dir["#{File.dirname(__FILE__)}/endeca_on_demand/*"].each { |file| require(file)}
|
2
4
|
|
3
5
|
require 'builder'
|
@@ -28,28 +30,66 @@ class EndecaOnDemand
|
|
28
30
|
end
|
29
31
|
|
30
32
|
### API
|
33
|
+
attr_reader :records, :record_offset, :records_per_page, :total_record_count
|
34
|
+
attr_reader :breadcrumbs, :filtercrumbs
|
35
|
+
attr_reader :dimensions
|
36
|
+
attr_reader :rules
|
37
|
+
attr_reader :searchs, :matchedrecordcount, :matchedmode, :applied_search_adjustments, :suggested_search_adjustments
|
38
|
+
attr_reader :selected_dimension_value_ids
|
39
|
+
|
40
|
+
## DEBUG
|
41
|
+
attr_reader :uri, :http
|
42
|
+
attr_reader :base, :query, :request, :raw_response, :response, :error
|
43
|
+
## /DEBUG
|
44
|
+
### /API
|
31
45
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
attr_reader :rules
|
36
|
-
attr_reader :searchs, :matchedrecordcount, :matchedmode, :applied_search_adjustments, :suggested_search_adjustments
|
37
|
-
attr_reader :selected_dimension_value_ids
|
38
|
-
|
39
|
-
## DEBUG
|
40
|
-
attr_reader :uri, :http
|
41
|
-
attr_reader :base, :query, :request, :raw_response, :response, :error
|
42
|
-
## /DEBUG
|
46
|
+
def success?
|
47
|
+
@error.blank?
|
48
|
+
end
|
43
49
|
|
44
|
-
|
50
|
+
private
|
45
51
|
|
46
52
|
def method_missing(method, *args, &block)
|
47
53
|
unless self.instance_variables.include?(:"@#{method}")
|
48
|
-
puts "
|
54
|
+
puts "#{method} is unavailable."
|
55
|
+
else
|
56
|
+
puts "Unable to retrieve #{method} because: #{@error.message}."
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
52
|
-
|
60
|
+
## SEND REQUEST
|
61
|
+
|
62
|
+
# Completes the endeca XML reqeust by inserting the XML body into the requred 'Query' tags, and sends the request to your hosted Endeca On-Demand Web API
|
63
|
+
def send_request
|
64
|
+
@query = Builder::XmlMarkup.new(:indent => 2)
|
65
|
+
@query.Query do
|
66
|
+
@query << @body.target!
|
67
|
+
end
|
68
|
+
|
69
|
+
begin
|
70
|
+
@request, @raw_response = @http.post(@uri.path, @query.target!, 'Content-type' => 'application/xml')
|
71
|
+
handle_response(Crackoid::XML.parse(@raw_response))
|
72
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => error
|
73
|
+
@error = error
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
## HANDLE RESPONSE
|
78
|
+
|
79
|
+
def handle_response(response)
|
80
|
+
@response = response['Final']
|
81
|
+
|
82
|
+
build_data
|
83
|
+
end
|
84
|
+
|
85
|
+
def build_data
|
86
|
+
build_records
|
87
|
+
build_breadcrumbs
|
88
|
+
build_filtercrumbs
|
89
|
+
build_dimensions
|
90
|
+
build_business_rules
|
91
|
+
build_applied_filters
|
92
|
+
end
|
53
93
|
|
54
94
|
### XML REQUEST ###
|
55
95
|
|
@@ -150,39 +190,9 @@ class EndecaOnDemand
|
|
150
190
|
# puts @body.target!
|
151
191
|
end
|
152
192
|
|
153
|
-
|
154
|
-
|
155
|
-
# Completes the endeca XML reqeust by inserting the XML body into the requred 'Query' tags, and sends the request to your hosted Endeca On-Demand Web API
|
156
|
-
def send_request
|
157
|
-
@query = Builder::XmlMarkup.new(:indent => 2)
|
158
|
-
@query.Query do
|
159
|
-
@query << @body.target!
|
160
|
-
end
|
161
|
-
|
162
|
-
begin
|
163
|
-
@request, @raw_response = @http.post(@uri.path, @query.target!, 'Content-type' => 'application/xml')
|
164
|
-
handle_response(Crackoid::XML.parse(@raw_response))
|
165
|
-
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => error
|
166
|
-
@error = error
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
## HANDLE RESPONSE
|
171
|
-
|
172
|
-
def handle_response(response)
|
173
|
-
@response = response['Final']
|
174
|
-
|
175
|
-
build_data
|
176
|
-
end
|
193
|
+
### RESPONSE XML ###
|
177
194
|
|
178
|
-
|
179
|
-
build_records
|
180
|
-
build_breadcrumbs
|
181
|
-
build_filtercrumbs
|
182
|
-
build_dimensions
|
183
|
-
build_business_rules
|
184
|
-
build_applied_filters
|
185
|
-
end
|
195
|
+
## BUILD RESPONSE
|
186
196
|
|
187
197
|
# Builds an array of RECORDS
|
188
198
|
def build_records
|
@@ -260,21 +270,21 @@ class EndecaOnDemand
|
|
260
270
|
breads = @response['Breadcrumbs']['Breads']
|
261
271
|
if breads.instance_of?(Hash)
|
262
272
|
breads.each do |key, value|
|
263
|
-
@filtercrumbs.push(
|
273
|
+
@filtercrumbs.push(value)
|
264
274
|
end
|
265
275
|
elsif breads.instance_of?(Array)
|
266
276
|
breads.each do |bread|
|
267
277
|
if bread.instance_of?(Hash)
|
268
|
-
@filtercrumbs.push(bread
|
278
|
+
@filtercrumbs.push(bread)
|
269
279
|
elsif bread.instance_of?(Array)
|
270
280
|
bread['Bread'].each do |crumb|
|
271
|
-
@filtercrumbs.push(
|
281
|
+
@filtercrumbs.push(crumb)
|
272
282
|
end
|
273
283
|
end
|
274
284
|
end
|
275
285
|
end
|
276
286
|
else
|
277
|
-
puts 'There are no
|
287
|
+
puts 'There are no filtercrumbs (breadcrumbs) with this response!'
|
278
288
|
end
|
279
289
|
end
|
280
290
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: endeca_on_demand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- sdomino
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-22 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: crackoid
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/endeca_on_demand/dimension.rb
|
58
58
|
- lib/endeca_on_demand/dimension_value.rb
|
59
59
|
- lib/endeca_on_demand/dimension_value_id.rb
|
60
|
+
- lib/endeca_on_demand/proxy.rb
|
60
61
|
- lib/endeca_on_demand/record.rb
|
61
62
|
- lib/endeca_on_demand/search.rb
|
62
63
|
- lib/endeca_on_demand/version.rb
|