endeca_on_demand 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.travis.yml +3 -0
- data/Gemfile +14 -0
- data/Guardfile +5 -0
- data/{README.rdoc → README.md} +97 -71
- data/Rakefile +4 -0
- data/endeca_on_demand.gemspec +6 -5
- data/lib/endeca_on_demand.rb +11 -299
- data/lib/endeca_on_demand/client.rb +16 -14
- data/lib/endeca_on_demand/collection.rb +29 -27
- data/lib/endeca_on_demand/core_ext.rb +1 -0
- data/lib/endeca_on_demand/core_ext/hash.rb +30 -0
- data/lib/endeca_on_demand/pp.rb +39 -37
- data/lib/endeca_on_demand/proxy.rb +49 -57
- data/lib/endeca_on_demand/query.rb +129 -147
- data/lib/endeca_on_demand/response.rb +50 -41
- data/lib/endeca_on_demand/response/applied_filters.rb +33 -25
- data/lib/endeca_on_demand/response/applied_filters/keyword_redirect.rb +28 -27
- data/lib/endeca_on_demand/response/applied_filters/search_report.rb +36 -33
- data/lib/endeca_on_demand/response/applied_filters/search_report/search.rb +30 -27
- data/lib/endeca_on_demand/response/applied_filters/selected_dimension_value_id.rb +26 -20
- data/lib/endeca_on_demand/response/breadcrumb.rb +26 -20
- data/lib/endeca_on_demand/response/breadcrumb/bread.rb +29 -28
- data/lib/endeca_on_demand/response/business_rules_result.rb +25 -19
- data/lib/endeca_on_demand/response/business_rules_result/business_rule.rb +36 -35
- data/lib/endeca_on_demand/response/dimension.rb +34 -33
- data/lib/endeca_on_demand/response/dimension/dimension_value.rb +28 -35
- data/lib/endeca_on_demand/response/property.rb +29 -22
- data/lib/endeca_on_demand/response/records_set.rb +40 -32
- data/lib/endeca_on_demand/response/records_set/record.rb +43 -36
- data/lib/endeca_on_demand/version.rb +1 -1
- data/spec/endeca_on_demand_spec.rb +11 -0
- data/spec/spec_helper.rb +21 -0
- metadata +59 -29
@@ -1,62 +1,71 @@
|
|
1
|
-
|
1
|
+
module EndecaOnDemand
|
2
|
+
class Response < EndecaOnDemand::Proxy
|
2
3
|
|
3
|
-
|
4
|
+
include EndecaOnDemand::PP
|
4
5
|
|
5
|
-
|
6
|
+
def inspect_attributes; [ :applied_filters, :breadcrumbs, :business_rules_result, :dimensions, :records_set ]; end
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
## fields ##
|
9
|
+
attr_reader :errors, :query, :result, :xml
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def initialize(query, result)
|
12
|
+
@query, @result = query, result
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
## override proxy ##
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def class
|
18
|
+
EndecaOnDemand::Response
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
+
##
|
21
22
|
|
22
|
-
|
23
|
+
## associations ##
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
def records_set
|
26
|
+
@records_set ||= EndecaOnDemand::Response::RecordsSet.new(self, xml.root.children.css('RecordsSet'))
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
def breadcrumbs
|
30
|
+
@breadcrumbs ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Breadcrumb, xml.root.children.css('Breadcrumbs > Breads'), self)
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def dimensions
|
34
|
+
@dimensions ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Dimension, xml.root.children.css('Dimensions > Dimension'), self)
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
def business_rules_result
|
38
|
+
@business_rules_result ||= EndecaOnDemand::Response::BusinessRulesResult.new(self, xml.root.children.css('BusinessRulesResult > BusinessRules'))
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
def applied_filters
|
42
|
+
@applied_filters ||= EndecaOnDemand::Response::AppliedFilters.new(self, xml.root.children.css('AppliedFilters'))
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
+
##
|
45
46
|
|
46
|
-
|
47
|
+
## data ##
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def xml
|
50
|
+
@xml ||= Nokogiri::XML.parse(result.body) { |config| config.strict.noblanks }
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
+
##
|
53
54
|
|
54
|
-
|
55
|
+
## flags ##
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
def valid?
|
58
|
+
errors.blank?
|
59
|
+
end
|
59
60
|
|
60
|
-
|
61
|
+
##
|
61
62
|
|
62
|
-
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
require 'endeca_on_demand/response/applied_filters'
|
67
|
+
require 'endeca_on_demand/response/breadcrumb'
|
68
|
+
require 'endeca_on_demand/response/business_rules_result'
|
69
|
+
require 'endeca_on_demand/response/dimension'
|
70
|
+
require 'endeca_on_demand/response/property'
|
71
|
+
require 'endeca_on_demand/response/records_set'
|
@@ -1,39 +1,47 @@
|
|
1
|
-
|
1
|
+
module EndecaOnDemand
|
2
|
+
class Response
|
3
|
+
class AppliedFilters < EndecaOnDemand::Proxy
|
2
4
|
|
3
|
-
|
5
|
+
include EndecaOnDemand::PP
|
4
6
|
|
5
|
-
|
7
|
+
def inspect_attributes; [ :keyword_redirects, :search_reports, :selected_dimension_value_ids ]; end
|
6
8
|
|
7
|
-
|
9
|
+
## fields ##
|
8
10
|
|
9
|
-
|
11
|
+
attr_reader :response, :search_reports
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
def initialize(response, xml)
|
14
|
+
@response, @xml = response, xml
|
15
|
+
end
|
14
16
|
|
15
|
-
|
17
|
+
## override proxy ##
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
def class
|
20
|
+
EndecaOnDemand::Response::AppliedFilters
|
21
|
+
end
|
20
22
|
|
21
|
-
|
23
|
+
##
|
22
24
|
|
23
|
-
|
25
|
+
## associations ##
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
def search_reports
|
28
|
+
@search_reports ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::AppliedFilters::SearchReport, xml.children.css('SearchReports > SearchReport'), self)
|
29
|
+
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
def selected_dimension_value_ids
|
32
|
+
@selected_dimension_value_ids ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::AppliedFilters::SelectedDimensionValueId, xml.children.css('SelectedDimensionValueIds > DimensionValueId'), self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def keyword_redirects
|
36
|
+
@keyword_redirects ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::AppliedFilters::KeywordRedirect, xml.children.css('KeywordRedirects'), self)
|
37
|
+
end
|
32
38
|
|
33
|
-
|
34
|
-
|
39
|
+
##
|
40
|
+
|
41
|
+
end
|
35
42
|
end
|
43
|
+
end
|
36
44
|
|
37
|
-
|
38
|
-
|
39
|
-
|
45
|
+
require 'endeca_on_demand/response/applied_filters/keyword_redirect'
|
46
|
+
require 'endeca_on_demand/response/applied_filters/search_report'
|
47
|
+
require 'endeca_on_demand/response/applied_filters/selected_dimension_value_id'
|
@@ -1,42 +1,43 @@
|
|
1
|
-
|
1
|
+
module EndecaOnDemand
|
2
|
+
class Response
|
3
|
+
class AppliedFilters
|
4
|
+
class KeywordRedirect < EndecaOnDemand::Proxy
|
2
5
|
|
3
|
-
|
6
|
+
include EndecaOnDemand::PP
|
4
7
|
|
5
|
-
|
8
|
+
def inspect_attributes; [ :options ]; end
|
6
9
|
|
7
|
-
|
10
|
+
## fields ##
|
8
11
|
|
9
|
-
|
12
|
+
attr_reader :applied_filters
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
def initialize(applied_filters, xml)
|
15
|
+
@applied_filters, @xml = applied_filters, xml
|
16
|
+
|
17
|
+
define_getters(:options)
|
18
|
+
end
|
14
19
|
|
15
|
-
|
20
|
+
## override proxy ##
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
def class
|
23
|
+
EndecaOnDemand::Response::AppliedFilters::KeywordRedirect
|
24
|
+
end
|
20
25
|
|
21
|
-
|
26
|
+
##
|
22
27
|
|
23
|
-
|
28
|
+
## data ##
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
def options
|
31
|
+
@options ||= xml.children.inject({}) do |hash,child|
|
32
|
+
hash.tap do
|
33
|
+
hash[child.name] = child.content
|
34
|
+
end
|
35
|
+
end.symbolize_keys
|
29
36
|
end
|
30
|
-
end.symbolize_keys
|
31
|
-
end
|
32
37
|
|
33
|
-
|
38
|
+
##
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
def method_missing(method, *args, &block)
|
38
|
-
return options[method] if @options.present? and options.has_key?(method)
|
39
|
-
super(method, *args, &block)
|
40
|
+
end
|
41
|
+
end
|
40
42
|
end
|
41
|
-
|
42
43
|
end
|
@@ -1,50 +1,53 @@
|
|
1
|
-
|
1
|
+
module EndecaOnDemand
|
2
|
+
class Response
|
3
|
+
class AppliedFilters
|
4
|
+
class SearchReport < EndecaOnDemand::Proxy
|
2
5
|
|
3
|
-
|
6
|
+
include EndecaOnDemand::PP
|
4
7
|
|
5
|
-
|
8
|
+
def inspect_attributes; [ :options, :search ]; end
|
6
9
|
|
7
|
-
|
10
|
+
## fields ##
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
12
|
+
attr_reader :applied_filters, :search
|
13
|
+
|
14
|
+
def initialize(applied_filters, xml)
|
15
|
+
@applied_filters, @xml = applied_filters, xml
|
14
16
|
|
15
|
-
|
17
|
+
define_getters(:options)
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
EndecaOnDemand::Response::AppliedFilters::SearchReport
|
19
|
-
end
|
20
|
+
## override proxy ##
|
20
21
|
|
21
|
-
|
22
|
+
def class
|
23
|
+
EndecaOnDemand::Response::AppliedFilters::SearchReport
|
24
|
+
end
|
22
25
|
|
23
|
-
|
26
|
+
##
|
24
27
|
|
25
|
-
|
26
|
-
@search ||= EndecaOnDemand::Response::AppliedFilters::SearchReport::Search.new(self, xml.children.css('Search'))
|
27
|
-
end
|
28
|
+
## associations ##
|
28
29
|
|
29
|
-
|
30
|
+
def search
|
31
|
+
@search ||= EndecaOnDemand::Response::AppliedFilters::SearchReport::Search.new(self, xml.children.css('Search'))
|
32
|
+
end
|
30
33
|
|
31
|
-
|
34
|
+
##
|
32
35
|
|
33
|
-
|
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
|
-
end
|
36
|
+
## data ##
|
40
37
|
|
41
|
-
|
38
|
+
def options
|
39
|
+
@options ||= xml.xpath('child::node()[not(local-name() = "Search")]').inject({}) do |hash,child|
|
40
|
+
hash.tap do
|
41
|
+
hash[child.name] = child.content
|
42
|
+
end
|
43
|
+
end.symbolize_keys
|
44
|
+
end
|
42
45
|
|
43
|
-
|
46
|
+
##
|
44
47
|
|
45
|
-
|
46
|
-
|
47
|
-
super(method, *args, &block)
|
48
|
+
end
|
49
|
+
end
|
48
50
|
end
|
51
|
+
end
|
49
52
|
|
50
|
-
|
53
|
+
require 'endeca_on_demand/response/applied_filters/search_report/search'
|
@@ -1,42 +1,45 @@
|
|
1
|
-
|
1
|
+
module EndecaOnDemand
|
2
|
+
class Response
|
3
|
+
class AppliedFilters
|
4
|
+
class SearchReport
|
5
|
+
class Search < EndecaOnDemand::Proxy
|
2
6
|
|
3
|
-
|
7
|
+
include EndecaOnDemand::PP
|
4
8
|
|
5
|
-
|
9
|
+
def inspect_attributes; [ :options ]; end
|
6
10
|
|
7
|
-
|
11
|
+
## fields ##
|
8
12
|
|
9
|
-
|
13
|
+
attr_reader :search_report
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
15
|
+
def initialize(search_report, xml)
|
16
|
+
@search_report, @xml = search_report, xml
|
14
17
|
|
15
|
-
|
18
|
+
define_getters(:options)
|
19
|
+
end
|
16
20
|
|
17
|
-
|
18
|
-
EndecaOnDemand::Response::AppliedFilters::SearchReport::Search
|
19
|
-
end
|
21
|
+
## override proxy ##
|
20
22
|
|
21
|
-
|
23
|
+
def class
|
24
|
+
EndecaOnDemand::Response::AppliedFilters::SearchReport::Search
|
25
|
+
end
|
22
26
|
|
23
|
-
|
27
|
+
##
|
24
28
|
|
25
|
-
|
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
|
-
end
|
29
|
+
## data ##
|
32
30
|
|
33
|
-
|
31
|
+
def options
|
32
|
+
@options ||= xml.children.inject({}) do |hash,child|
|
33
|
+
hash.tap do
|
34
|
+
hash[child.name] = child.content
|
35
|
+
end
|
36
|
+
end.symbolize_keys
|
37
|
+
end
|
34
38
|
|
35
|
-
|
39
|
+
##
|
36
40
|
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
40
44
|
end
|
41
|
-
|
42
45
|
end
|
@@ -1,32 +1,38 @@
|
|
1
|
-
|
1
|
+
module EndecaOnDemand
|
2
|
+
class Response
|
3
|
+
class AppliedFilters
|
4
|
+
class SelectedDimensionValueId < EndecaOnDemand::Proxy
|
2
5
|
|
3
|
-
|
6
|
+
include EndecaOnDemand::PP
|
4
7
|
|
5
|
-
|
8
|
+
def inspect_attributes; [ :value ]; end
|
6
9
|
|
7
|
-
|
10
|
+
## fields ##
|
8
11
|
|
9
|
-
|
12
|
+
attr_reader :applied_filters
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
def initialize(applied_filters, xml)
|
15
|
+
@applied_filters, @xml = applied_filters, xml
|
16
|
+
end
|
14
17
|
|
15
|
-
|
18
|
+
## override proxy ##
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
def class
|
21
|
+
EndecaOnDemand::Response::AppliedFilters::SelectedDimensionValueId
|
22
|
+
end
|
20
23
|
|
21
|
-
|
24
|
+
##
|
22
25
|
|
23
|
-
|
26
|
+
## data ##
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
def value
|
29
|
+
xml.content
|
30
|
+
end
|
31
|
+
alias :to_s :value
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
##
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
32
38
|
end
|