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