endeca_on_demand 1.0.1 → 1.1.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.
- data/endeca_on_demand.gemspec +4 -0
- data/lib/endeca_on_demand/client.rb +24 -0
- data/lib/endeca_on_demand/collection.rb +41 -0
- data/lib/endeca_on_demand/pp.rb +48 -0
- data/lib/endeca_on_demand/proxy.rb +58 -8
- data/lib/endeca_on_demand/query.rb +187 -0
- data/lib/endeca_on_demand/response/applied_filters/keyword_redirect.rb +42 -0
- data/lib/endeca_on_demand/response/applied_filters/search_report/search.rb +42 -0
- data/lib/endeca_on_demand/response/applied_filters/search_report.rb +50 -0
- data/lib/endeca_on_demand/response/applied_filters/selected_dimension_value_id.rb +32 -0
- data/lib/endeca_on_demand/response/applied_filters.rb +39 -0
- data/lib/endeca_on_demand/response/breadcrumb/bread.rb +42 -0
- data/lib/endeca_on_demand/response/breadcrumb.rb +35 -0
- data/lib/endeca_on_demand/response/business_rules_result/business_rule.rb +54 -0
- data/lib/endeca_on_demand/response/business_rules_result.rb +31 -0
- data/lib/endeca_on_demand/response/dimension/dimension_value.rb +50 -0
- data/lib/endeca_on_demand/response/dimension.rb +50 -0
- data/lib/endeca_on_demand/response/property.rb +36 -0
- data/lib/endeca_on_demand/response/records_set/record.rb +53 -0
- data/lib/endeca_on_demand/response/records_set.rb +50 -0
- data/lib/endeca_on_demand/response.rb +62 -0
- data/lib/endeca_on_demand/version.rb +1 -1
- data/lib/endeca_on_demand.rb +251 -243
- metadata +69 -17
- data/lib/endeca_on_demand/bread_crumb.rb +0 -12
- data/lib/endeca_on_demand/business_rules_result/property.rb +0 -14
- data/lib/endeca_on_demand/business_rules_result.rb +0 -33
- data/lib/endeca_on_demand/dimension/dimension_value.rb +0 -14
- data/lib/endeca_on_demand/dimension.rb +0 -24
- data/lib/endeca_on_demand/keyword_redirect.rb +0 -12
- data/lib/endeca_on_demand/record_set/record.rb +0 -14
- data/lib/endeca_on_demand/record_set.rb +0 -24
- data/lib/endeca_on_demand/search_report/search.rb +0 -14
- data/lib/endeca_on_demand/search_report.rb +0 -21
- data/lib/endeca_on_demand/selected_dimension_value_id.rb +0 -12
@@ -0,0 +1,54 @@
|
|
1
|
+
class EndecaOnDemand::Response::BusinessRulesResult::BusinessRule < EndecaOnDemand::Proxy
|
2
|
+
|
3
|
+
include EndecaOnDemand::PP
|
4
|
+
|
5
|
+
def inspect_attributes; [ :options, :properties, :records_set ]; end
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
|
9
|
+
attr_reader :options, :properties, :records_set
|
10
|
+
|
11
|
+
def initialize(records_set, xml)
|
12
|
+
@records_set, @xml = records_set, xml
|
13
|
+
end
|
14
|
+
|
15
|
+
## override proxy ##
|
16
|
+
|
17
|
+
def class
|
18
|
+
EndecaOnDemand::Response::BusinessRulesResult::BusinessRule
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
|
23
|
+
## associations ##
|
24
|
+
|
25
|
+
def properties
|
26
|
+
@properties ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Property, xml.children.css('properties'), self)
|
27
|
+
end
|
28
|
+
|
29
|
+
def records_set
|
30
|
+
@records_set ||= EndecaOnDemand::Response::RecordsSet.new(self, xml.children.css('RecordsSet'))
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
|
35
|
+
## data ##
|
36
|
+
|
37
|
+
def options
|
38
|
+
xml.xpath('child::node()[not(local-name() = "properties" or local-name() = "RecordsSet")]').inject({}.with_indifferent_access) do |hash,child|
|
39
|
+
hash.tap do
|
40
|
+
hash[child.name] = child.content
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
def method_missing(method, *args, &block)
|
50
|
+
return options[method] if options.has_key?(method)
|
51
|
+
super(method, *args, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class EndecaOnDemand::Response::BusinessRulesResult < EndecaOnDemand::Proxy
|
2
|
+
|
3
|
+
include EndecaOnDemand::PP
|
4
|
+
|
5
|
+
def inspect_attributes; [ :business_rules ]; end
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
|
9
|
+
attr_reader :business_rules, :response
|
10
|
+
|
11
|
+
def initialize(response, xml)
|
12
|
+
@response, @xml = response, xml
|
13
|
+
end
|
14
|
+
|
15
|
+
## override proxy ##
|
16
|
+
|
17
|
+
def class
|
18
|
+
EndecaOnDemand::Response::BusinessRulesResult
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
|
23
|
+
## associations ##
|
24
|
+
|
25
|
+
def business_rules
|
26
|
+
@business_rules ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::BusinessRulesResult::BusinessRule, xml.children.css('BusinessRule'), self)
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class EndecaOnDemand::Response::Dimension::DimensionValue < EndecaOnDemand::Proxy
|
2
|
+
|
3
|
+
include EndecaOnDemand::PP
|
4
|
+
|
5
|
+
def inspect_attributes; [ :options ]; end
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
|
9
|
+
attr_reader :dimension, :options
|
10
|
+
|
11
|
+
def initialize(dimension, xml)
|
12
|
+
@dimension, @xml = dimension, xml
|
13
|
+
end
|
14
|
+
|
15
|
+
## override proxy ##
|
16
|
+
|
17
|
+
def class
|
18
|
+
EndecaOnDemand::Response::Dimension::DimensionValue
|
19
|
+
end
|
20
|
+
|
21
|
+
# def inspection
|
22
|
+
# options.sort_by(&:first).map { |k,v| "#{k}: #{v.inspect}" }
|
23
|
+
# end
|
24
|
+
|
25
|
+
def inspection
|
26
|
+
Hash[*options.sort_by(&:first).flatten]
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
|
31
|
+
## data ##
|
32
|
+
|
33
|
+
def options
|
34
|
+
xml.children.inject({}.with_indifferent_access) do |hash,child|
|
35
|
+
hash.tap do
|
36
|
+
hash[child.name] = child.content
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def method_missing(method, *args, &block)
|
46
|
+
return options[method] if options.has_key?(method)
|
47
|
+
super(method, *args, &block)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class EndecaOnDemand::Response::Dimension < EndecaOnDemand::Proxy
|
2
|
+
|
3
|
+
include EndecaOnDemand::PP
|
4
|
+
|
5
|
+
def inspect_attributes; [ :dimension_values, :options ]; end
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
|
9
|
+
attr_reader :dimension_values, :options, :response
|
10
|
+
|
11
|
+
def initialize(response, xml)
|
12
|
+
@response, @xml = response, xml
|
13
|
+
end
|
14
|
+
|
15
|
+
## override proxy ##
|
16
|
+
|
17
|
+
def class
|
18
|
+
EndecaOnDemand::Response::Dimension
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
|
23
|
+
## associations ##
|
24
|
+
|
25
|
+
def dimension_values
|
26
|
+
@dimension_values ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Dimension::DimensionValue, xml.children.css('DimensionValues > DimensionValue'), self)
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
|
31
|
+
## data ##
|
32
|
+
|
33
|
+
def options
|
34
|
+
xml.xpath('child::node()[not(local-name() = "DimensionValues")]').inject({}.with_indifferent_access) do |hash,child|
|
35
|
+
hash.tap do
|
36
|
+
hash[child.name] = child.content
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def method_missing(method, *args, &block)
|
46
|
+
return options[method] if options.has_key?(method)
|
47
|
+
super(method, *args, &block)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class EndecaOnDemand::Response::Property < EndecaOnDemand::Proxy
|
2
|
+
|
3
|
+
include EndecaOnDemand::PP
|
4
|
+
|
5
|
+
def inspect_attributes; [ :label, :value ]; end
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
|
9
|
+
attr_reader :parent
|
10
|
+
|
11
|
+
def initialize(parent, xml)
|
12
|
+
@parent, @xml = parent, xml
|
13
|
+
end
|
14
|
+
|
15
|
+
## override proxy ##
|
16
|
+
|
17
|
+
def class
|
18
|
+
EndecaOnDemand::Response::Property
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
|
23
|
+
## data ##
|
24
|
+
|
25
|
+
def label
|
26
|
+
xml.name.to_s.gsub(/^p_/, '')
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
xml.content
|
31
|
+
end
|
32
|
+
alias :value :to_s
|
33
|
+
|
34
|
+
##
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class EndecaOnDemand::Response::RecordsSet::Record < EndecaOnDemand::Proxy
|
2
|
+
|
3
|
+
include EndecaOnDemand::PP
|
4
|
+
|
5
|
+
def inspect_attributes; [ :properties ]; end
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
|
9
|
+
attr_reader :properties, :records_set
|
10
|
+
|
11
|
+
def initialize(records_set, xml)
|
12
|
+
@records_set, @xml = records_set, xml
|
13
|
+
end
|
14
|
+
|
15
|
+
## override proxy ##
|
16
|
+
|
17
|
+
def class
|
18
|
+
EndecaOnDemand::Response::RecordsSet::Record
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
|
23
|
+
## associations ##
|
24
|
+
|
25
|
+
def properties
|
26
|
+
@properties ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Property, xml.children, self)
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
|
31
|
+
## data ##
|
32
|
+
|
33
|
+
def keys
|
34
|
+
properties.map { |property| property.name }
|
35
|
+
end
|
36
|
+
|
37
|
+
def serializable_hash
|
38
|
+
properties.inject({}.with_indifferent_access) { |hash,property| hash.tap { hash[property.name] = property } }
|
39
|
+
end
|
40
|
+
alias :to_hash :serializable_hash
|
41
|
+
|
42
|
+
##
|
43
|
+
|
44
|
+
protected
|
45
|
+
|
46
|
+
def method_missing(method, *args, &block)
|
47
|
+
if @properties.present? and (property = properties.where(label: method.to_s).first || properties.where(name: method.to_s).first).present?
|
48
|
+
return property
|
49
|
+
end
|
50
|
+
super(method, *args, &block)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class EndecaOnDemand::Response::RecordsSet < EndecaOnDemand::Proxy
|
2
|
+
|
3
|
+
include EndecaOnDemand::PP
|
4
|
+
|
5
|
+
def inspect_attributes; [ :options, :records ]; end
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
|
9
|
+
attr_reader :parent, :records
|
10
|
+
|
11
|
+
def initialize(parent, xml)
|
12
|
+
@parent, @xml = parent, xml
|
13
|
+
end
|
14
|
+
|
15
|
+
## override proxy ##
|
16
|
+
|
17
|
+
def class
|
18
|
+
EndecaOnDemand::Response::RecordsSet
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
|
23
|
+
## associations ##
|
24
|
+
|
25
|
+
def records
|
26
|
+
@records ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::RecordsSet::Record, xml.children.css('Record'), self)
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
|
31
|
+
## data ##
|
32
|
+
|
33
|
+
def options
|
34
|
+
xml.xpath('child::node()[not(local-name() = "Record")]').inject({}.with_indifferent_access) do |hash,child|
|
35
|
+
hash.tap do
|
36
|
+
hash[child.name] = child.content
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def method_missing(method, *args, &block)
|
46
|
+
return options[method] if options.has_key?(method)
|
47
|
+
super(method, *args, &block)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class EndecaOnDemand::Response < EndecaOnDemand::Proxy
|
2
|
+
|
3
|
+
include EndecaOnDemand::PP
|
4
|
+
|
5
|
+
def inspect_attributes; [ :applied_filters, :breadcrumbs, :business_rules_result, :dimensions, :records_set ]; end
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
attr_reader :errors, :query, :result, :xml
|
9
|
+
|
10
|
+
def initialize(query, result)
|
11
|
+
@query, @result = query, result
|
12
|
+
end
|
13
|
+
|
14
|
+
## override proxy ##
|
15
|
+
|
16
|
+
def class
|
17
|
+
EndecaOnDemand::Response
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
|
22
|
+
## associations ##
|
23
|
+
|
24
|
+
def records_set
|
25
|
+
@records_set ||= EndecaOnDemand::Response::RecordsSet.new(self, xml.root.children.css('RecordsSet'))
|
26
|
+
end
|
27
|
+
|
28
|
+
def breadcrumbs
|
29
|
+
@breadcrumbs ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Breadcrumb, xml.root.children.css('Breadcrumbs > Breads'), self)
|
30
|
+
end
|
31
|
+
|
32
|
+
def dimensions
|
33
|
+
@dimensions ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Dimension, xml.root.children.css('Dimensions > Dimension'), self)
|
34
|
+
end
|
35
|
+
|
36
|
+
def business_rules_result
|
37
|
+
@business_rules_result ||= EndecaOnDemand::Response::BusinessRulesResult.new(self, xml.root.children.css('BusinessRulesResult > BusinessRules'))
|
38
|
+
end
|
39
|
+
|
40
|
+
def applied_filters
|
41
|
+
@applied_filters ||= EndecaOnDemand::Response::AppliedFilters.new(self, xml.root.children.css('AppliedFilters'))
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
|
46
|
+
## data ##
|
47
|
+
|
48
|
+
def xml
|
49
|
+
@xml ||= Nokogiri::XML.parse(result.body) { |config| config.strict.noblanks }
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
|
54
|
+
## flags ##
|
55
|
+
|
56
|
+
def valid?
|
57
|
+
errors.blank?
|
58
|
+
end
|
59
|
+
|
60
|
+
##
|
61
|
+
|
62
|
+
end
|