endeca_on_demand 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/endeca_on_demand.gemspec +1 -0
- data/lib/endeca_on_demand.rb +1 -0
- data/lib/endeca_on_demand/client.rb +1 -1
- data/lib/endeca_on_demand/query.rb +18 -10
- data/lib/endeca_on_demand/response/applied_filters/keyword_redirect.rb +5 -5
- data/lib/endeca_on_demand/response/applied_filters/search_report.rb +5 -5
- data/lib/endeca_on_demand/response/applied_filters/search_report/search.rb +5 -5
- data/lib/endeca_on_demand/response/breadcrumb.rb +1 -4
- data/lib/endeca_on_demand/response/breadcrumb/bread.rb +2 -2
- data/lib/endeca_on_demand/response/business_rules_result/business_rule.rb +2 -2
- data/lib/endeca_on_demand/response/dimension.rb +2 -2
- data/lib/endeca_on_demand/response/dimension/dimension_value.rb +2 -2
- data/lib/endeca_on_demand/response/records_set.rb +2 -2
- data/lib/endeca_on_demand/response/records_set/record.rb +6 -2
- data/lib/endeca_on_demand/version.rb +2 -2
- metadata +24 -13
data/endeca_on_demand.gemspec
CHANGED
data/lib/endeca_on_demand.rb
CHANGED
@@ -9,7 +9,7 @@ class EndecaOnDemand::Client
|
|
9
9
|
attr_reader :api, :default_options, :query
|
10
10
|
|
11
11
|
def initialize(api, default_options = {})
|
12
|
-
@api, @default_options = api, default_options.dup.
|
12
|
+
@api, @default_options = api, default_options.dup.recurse(&:symbolize_keys)
|
13
13
|
end
|
14
14
|
|
15
15
|
## associations ##
|
@@ -9,7 +9,7 @@ class EndecaOnDemand::Query
|
|
9
9
|
attr_reader :body, :client, :errors, :http, :options, :response, :uri, :xml
|
10
10
|
|
11
11
|
def initialize(client, options = {})
|
12
|
-
@client, @options = client, options.dup.
|
12
|
+
@client, @options = client, options.dup.recurse(&:symbolize_keys)
|
13
13
|
|
14
14
|
process_options!
|
15
15
|
end
|
@@ -77,11 +77,11 @@ class EndecaOnDemand::Query
|
|
77
77
|
### data ###
|
78
78
|
|
79
79
|
def flags
|
80
|
-
@flags ||= options[:flags] = (options[:flags] || {}).inject({}
|
80
|
+
@flags ||= options[:flags] = (options[:flags] || {}).inject({}) do |hash,(key,value)|
|
81
81
|
hash.tap do
|
82
82
|
hash[key.to_s.underscore] = value
|
83
83
|
end
|
84
|
-
end
|
84
|
+
end.symbolize_keys
|
85
85
|
end
|
86
86
|
|
87
87
|
def searches
|
@@ -109,11 +109,11 @@ class EndecaOnDemand::Query
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def advanced_parameters
|
112
|
-
@advanced_parameters ||= options[:advanced] = (options[:advanced] || {}).inject({}
|
112
|
+
@advanced_parameters ||= options[:advanced] = (options[:advanced] || {}).inject({}) do |hash,(key,value)|
|
113
113
|
hash.tap do
|
114
114
|
hash[key.to_s.underscore] = value
|
115
115
|
end
|
116
|
-
end
|
116
|
+
end.symbolize_keys
|
117
117
|
end
|
118
118
|
|
119
119
|
###
|
@@ -132,8 +132,8 @@ class EndecaOnDemand::Query
|
|
132
132
|
xml.tag!(:Searches) do
|
133
133
|
searches.each do |key,term|
|
134
134
|
xml.tag!(:Search) do
|
135
|
-
xml.tag!('search-key', key)
|
136
|
-
xml.tag!('search-term', term)
|
135
|
+
xml.tag!('search-key', key.to_s)
|
136
|
+
xml.tag!('search-term', term.to_s)
|
137
137
|
end
|
138
138
|
end
|
139
139
|
end
|
@@ -160,7 +160,7 @@ class EndecaOnDemand::Query
|
|
160
160
|
xml.tag!(:Sorts) do
|
161
161
|
sorts.each do |key,direction|
|
162
162
|
xml.tag!(:Sort) do
|
163
|
-
xml.tag!('sort-key', key)
|
163
|
+
xml.tag!('sort-key', key.to_s)
|
164
164
|
xml.tag!('sort-direction', direction.to_s.capitalize)
|
165
165
|
end
|
166
166
|
end
|
@@ -178,8 +178,16 @@ class EndecaOnDemand::Query
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def process_options!
|
181
|
-
|
182
|
-
|
181
|
+
new_options = (client.default_options[:query] || {}).dup
|
182
|
+
|
183
|
+
(new_options[:flags] ||= {}).merge!(options[:flags] || {}).recurse(&:symbolize_keys) if options[:flags].present?
|
184
|
+
(new_options[:paging] ||= {}).merge!(options[:paging] || {}).recurse(&:symbolize_keys) if options[:paging].present?
|
185
|
+
(new_options[:searches] ||= {}).merge!(options[:searches] || {}).recurse(&:symbolize_keys) if options[:searches].present?
|
186
|
+
(new_options[:sorts] ||= {}).merge!(options[:sorts] || {}).recurse(&:symbolize_keys) if options[:sorts].present?
|
187
|
+
(new_options[:dimensions] = [*new_options[:dimensions]]).concat [*options[:dimensions]] if options[:dimensions].present?
|
188
|
+
new_options[:category] = options[:category] if options[:category].present?
|
189
|
+
|
190
|
+
@options = new_options
|
183
191
|
end
|
184
192
|
|
185
193
|
##
|
@@ -23,11 +23,11 @@ class EndecaOnDemand::Response::AppliedFilters::KeywordRedirect < EndecaOnDemand
|
|
23
23
|
## data ##
|
24
24
|
|
25
25
|
def options
|
26
|
-
@options ||= xml.children.inject({}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
@options ||= xml.children.inject({}) do |hash,child|
|
27
|
+
hash.tap do
|
28
|
+
hash[child.name] = child.content
|
29
|
+
end
|
30
|
+
end.symbolize_keys
|
31
31
|
end
|
32
32
|
|
33
33
|
##
|
@@ -31,11 +31,11 @@ class EndecaOnDemand::Response::AppliedFilters::SearchReport < EndecaOnDemand::P
|
|
31
31
|
## data ##
|
32
32
|
|
33
33
|
def options
|
34
|
-
@options ||= xml.xpath('child::node()[not(local-name() = "Search")]').inject({}
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
@options ||= xml.xpath('child::node()[not(local-name() = "Search")]').inject({}) do |hash,child|
|
35
|
+
hash.tap do
|
36
|
+
hash[child.name] = child.content
|
37
|
+
end
|
38
|
+
end.symbolize_keys
|
39
39
|
end
|
40
40
|
|
41
41
|
##
|
@@ -23,11 +23,11 @@ class EndecaOnDemand::Response::AppliedFilters::SearchReport::Search < EndecaOnD
|
|
23
23
|
## data ##
|
24
24
|
|
25
25
|
def options
|
26
|
-
@options ||= xml.children.inject({}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
@options ||= xml.children.inject({}) do |hash,child|
|
27
|
+
hash.tap do
|
28
|
+
hash[child.name] = child.content
|
29
|
+
end
|
30
|
+
end.symbolize_keys
|
31
31
|
end
|
32
32
|
|
33
33
|
##
|
@@ -7,6 +7,7 @@ class EndecaOnDemand::Response::Breadcrumb < EndecaOnDemand::Proxy
|
|
7
7
|
## fields ##
|
8
8
|
|
9
9
|
attr_reader :response
|
10
|
+
attr_accessor :breads
|
10
11
|
|
11
12
|
def initialize(response, xml)
|
12
13
|
@response, @xml = response, xml
|
@@ -18,10 +19,6 @@ class EndecaOnDemand::Response::Breadcrumb < EndecaOnDemand::Proxy
|
|
18
19
|
EndecaOnDemand::Response::Breadcrumb
|
19
20
|
end
|
20
21
|
|
21
|
-
# def inspection
|
22
|
-
# [ "breads: #{breads.inspect}" ]
|
23
|
-
# end
|
24
|
-
|
25
22
|
##
|
26
23
|
|
27
24
|
## associations ##
|
@@ -23,11 +23,11 @@ class EndecaOnDemand::Response::Breadcrumb::Bread < EndecaOnDemand::Proxy
|
|
23
23
|
## data ##
|
24
24
|
|
25
25
|
def options
|
26
|
-
xml.children.inject({}
|
26
|
+
xml.children.inject({}) do |hash,child|
|
27
27
|
hash.tap do
|
28
28
|
hash[child.name] = child.content
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end.symbolize_keys
|
31
31
|
end
|
32
32
|
|
33
33
|
##
|
@@ -35,11 +35,11 @@ class EndecaOnDemand::Response::BusinessRulesResult::BusinessRule < EndecaOnDema
|
|
35
35
|
## data ##
|
36
36
|
|
37
37
|
def options
|
38
|
-
xml.xpath('child::node()[not(local-name() = "properties" or local-name() = "RecordsSet")]').inject({}
|
38
|
+
xml.xpath('child::node()[not(local-name() = "properties" or local-name() = "RecordsSet")]').inject({}) do |hash,child|
|
39
39
|
hash.tap do
|
40
40
|
hash[child.name] = child.content
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end.symbolize_keys
|
43
43
|
end
|
44
44
|
|
45
45
|
##
|
@@ -31,11 +31,11 @@ class EndecaOnDemand::Response::Dimension < EndecaOnDemand::Proxy
|
|
31
31
|
## data ##
|
32
32
|
|
33
33
|
def options
|
34
|
-
xml.xpath('child::node()[not(local-name() = "DimensionValues")]').inject({}
|
34
|
+
xml.xpath('child::node()[not(local-name() = "DimensionValues")]').inject({}) do |hash,child|
|
35
35
|
hash.tap do
|
36
36
|
hash[child.name] = child.content
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end.symbolize_keys
|
39
39
|
end
|
40
40
|
|
41
41
|
##
|
@@ -31,11 +31,11 @@ class EndecaOnDemand::Response::Dimension::DimensionValue < EndecaOnDemand::Prox
|
|
31
31
|
## data ##
|
32
32
|
|
33
33
|
def options
|
34
|
-
xml.children.inject({}
|
34
|
+
xml.children.inject({}) do |hash,child|
|
35
35
|
hash.tap do
|
36
36
|
hash[child.name] = child.content
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end.symbolize_keys
|
39
39
|
end
|
40
40
|
|
41
41
|
##
|
@@ -31,11 +31,11 @@ class EndecaOnDemand::Response::RecordsSet < EndecaOnDemand::Proxy
|
|
31
31
|
## data ##
|
32
32
|
|
33
33
|
def options
|
34
|
-
xml.xpath('child::node()[not(local-name() = "Record")]').inject({}
|
34
|
+
xml.xpath('child::node()[not(local-name() = "Record")]').inject({}) do |hash,child|
|
35
35
|
hash.tap do
|
36
36
|
hash[child.name] = child.content
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end.symbolize_keys
|
39
39
|
end
|
40
40
|
|
41
41
|
##
|
@@ -10,6 +10,8 @@ class EndecaOnDemand::Response::RecordsSet::Record < EndecaOnDemand::Proxy
|
|
10
10
|
|
11
11
|
def initialize(records_set, xml)
|
12
12
|
@records_set, @xml = records_set, xml
|
13
|
+
|
14
|
+
properties
|
13
15
|
end
|
14
16
|
|
15
17
|
## override proxy ##
|
@@ -35,7 +37,7 @@ class EndecaOnDemand::Response::RecordsSet::Record < EndecaOnDemand::Proxy
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def serializable_hash
|
38
|
-
properties.inject({}
|
40
|
+
properties.inject({}) { |hash,property| hash.tap { hash[property.name] = property } }.symbolize_keys
|
39
41
|
end
|
40
42
|
alias :to_hash :serializable_hash
|
41
43
|
|
@@ -45,9 +47,11 @@ class EndecaOnDemand::Response::RecordsSet::Record < EndecaOnDemand::Proxy
|
|
45
47
|
|
46
48
|
def method_missing(method, *args, &block)
|
47
49
|
if @properties.present? and (property = properties.where(label: method.to_s).first || properties.where(name: method.to_s).first).present?
|
48
|
-
return property
|
50
|
+
return property.value
|
49
51
|
end
|
50
52
|
super(method, *args, &block)
|
53
|
+
rescue NoMethodError
|
54
|
+
''
|
51
55
|
end
|
52
56
|
|
53
57
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "1.
|
1
|
+
module EndecaOnDemand
|
2
|
+
VERSION = "1.2.0"
|
3
3
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: endeca_on_demand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-10 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70144082452440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70144082452440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: pry
|
27
|
-
requirement: &
|
27
|
+
requirement: &70144082452020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70144082452020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: nokogiri
|
38
|
-
requirement: &
|
38
|
+
requirement: &70144082451580 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70144082451580
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: builder
|
49
|
-
requirement: &
|
49
|
+
requirement: &70144082451040 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70144082451040
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: activesupport
|
60
|
-
requirement: &
|
60
|
+
requirement: &70144082443940 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.1'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70144082443940
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: i18n
|
71
|
-
requirement: &
|
71
|
+
requirement: &70144082443100 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,18 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70144082443100
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: facets
|
82
|
+
requirement: &70144082442160 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70144082442160
|
80
91
|
description: EndecaOnDemand will take a query-string and construct an XML query and
|
81
92
|
send it to an hosted Endeca On-Demand Cluster. It will then parse the response and
|
82
93
|
expose an API for using the response data.
|