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,32 +1,38 @@
1
- class EndecaOnDemand::Response::Breadcrumb < EndecaOnDemand::Proxy
1
+ module EndecaOnDemand
2
+ class Response
3
+ class Breadcrumb < EndecaOnDemand::Proxy
2
4
 
3
- include EndecaOnDemand::PP
5
+ include EndecaOnDemand::PP
4
6
 
5
- def inspect_attributes; [ :breads ]; end
7
+ def inspect_attributes; [ :breads ]; end
6
8
 
7
- ## fields ##
9
+ ## fields ##
8
10
 
9
- attr_reader :response
10
- attr_accessor :breads
11
+ attr_reader :response
12
+ attr_accessor :breads
11
13
 
12
- def initialize(response, xml)
13
- @response, @xml = response, xml
14
- end
14
+ def initialize(response, xml)
15
+ @response, @xml = response, xml
16
+ end
15
17
 
16
- ## override proxy ##
18
+ ## override proxy ##
17
19
 
18
- def class
19
- EndecaOnDemand::Response::Breadcrumb
20
- end
20
+ def class
21
+ EndecaOnDemand::Response::Breadcrumb
22
+ end
23
+
24
+ ##
21
25
 
22
- ##
26
+ ## associations ##
23
27
 
24
- ## associations ##
28
+ def breads
29
+ @breads ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Breadcrumb::Bread, xml.children.css('Bread'), self)
30
+ end
25
31
 
26
- def breads
27
- @breads ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Breadcrumb::Bread, xml.children.css('Bread'), self)
32
+ ##
33
+
34
+ end
28
35
  end
36
+ end
29
37
 
30
- ##
31
-
32
- end
38
+ require 'endeca_on_demand/response/breadcrumb/bread'
@@ -1,42 +1,43 @@
1
- class EndecaOnDemand::Response::Breadcrumb::Bread < EndecaOnDemand::Proxy
1
+ module EndecaOnDemand
2
+ class Response
3
+ class Breadcrumb
4
+ class Bread < 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 :breadcrumb
12
+ attr_reader :breadcrumb
10
13
 
11
- def initialize(breadcrumb, xml)
12
- @breadcrumb, @xml = breadcrumb, xml
13
- end
14
-
15
- ## override proxy ##
14
+ def initialize(breadcrumb, xml)
15
+ @breadcrumb, @xml = breadcrumb, xml
16
16
 
17
- def class
18
- EndecaOnDemand::Response::Breadcrumb::Bread
19
- end
17
+ define_getters(:options)
18
+ end
20
19
 
21
- ##
20
+ ## override proxy ##
22
21
 
23
- ## data ##
22
+ def class
23
+ EndecaOnDemand::Response::Breadcrumb::Bread
24
+ end
24
25
 
25
- def options
26
- xml.children.inject({}) do |hash,child|
27
- hash.tap do
28
- hash[child.name] = child.content
29
- end
30
- end.symbolize_keys
31
- end
26
+ ##
32
27
 
33
- ##
28
+ ## data ##
34
29
 
35
- protected
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
36
+ end
36
37
 
37
- def method_missing(method, *args, &block)
38
- return options[method] if options.has_key?(method)
39
- super(method, *args, &block)
38
+ ##
39
+
40
+ end
41
+ end
40
42
  end
41
-
42
43
  end
@@ -1,31 +1,37 @@
1
- class EndecaOnDemand::Response::BusinessRulesResult < EndecaOnDemand::Proxy
1
+ module EndecaOnDemand
2
+ class Response
3
+ class BusinessRulesResult < EndecaOnDemand::Proxy
2
4
 
3
- include EndecaOnDemand::PP
5
+ include EndecaOnDemand::PP
4
6
 
5
- def inspect_attributes; [ :business_rules ]; end
7
+ def inspect_attributes; [ :business_rules ]; end
6
8
 
7
- ## fields ##
9
+ ## fields ##
8
10
 
9
- attr_reader :business_rules, :response
11
+ attr_reader :business_rules, :response
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::BusinessRulesResult
19
- end
19
+ def class
20
+ EndecaOnDemand::Response::BusinessRulesResult
21
+ end
22
+
23
+ ##
20
24
 
21
- ##
25
+ ## associations ##
22
26
 
23
- ## associations ##
27
+ def business_rules
28
+ @business_rules ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::BusinessRulesResult::BusinessRule, xml.children.css('BusinessRule'), self)
29
+ end
24
30
 
25
- def business_rules
26
- @business_rules ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::BusinessRulesResult::BusinessRule, xml.children.css('BusinessRule'), self)
31
+ ##
32
+
33
+ end
27
34
  end
35
+ end
28
36
 
29
- ##
30
-
31
- end
37
+ require 'endeca_on_demand/response/business_rules_result/business_rule'
@@ -1,54 +1,55 @@
1
- class EndecaOnDemand::Response::BusinessRulesResult::BusinessRule < EndecaOnDemand::Proxy
1
+ module EndecaOnDemand
2
+ class Response
3
+ class BusinessRulesResult
4
+ class BusinessRule < EndecaOnDemand::Proxy
2
5
 
3
- include EndecaOnDemand::PP
6
+ include EndecaOnDemand::PP
4
7
 
5
- def inspect_attributes; [ :options, :properties, :records_set ]; end
8
+ def inspect_attributes; [ :options, :properties, :records_set ]; end
6
9
 
7
- ## fields ##
10
+ ## fields ##
8
11
 
9
- attr_reader :options, :properties, :records_set
12
+ attr_reader :options, :properties, :records_set
10
13
 
11
- def initialize(records_set, xml)
12
- @records_set, @xml = records_set, xml
13
- end
14
+ def initialize(records_set, xml)
15
+ @records_set, @xml = records_set, xml
14
16
 
15
- ## override proxy ##
17
+ define_getters(:options)
18
+ end
16
19
 
17
- def class
18
- EndecaOnDemand::Response::BusinessRulesResult::BusinessRule
19
- end
20
+ ## override proxy ##
20
21
 
21
- ##
22
+ def class
23
+ EndecaOnDemand::Response::BusinessRulesResult::BusinessRule
24
+ end
22
25
 
23
- ## associations ##
26
+ ##
24
27
 
25
- def properties
26
- @properties ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Property, xml.children.css('properties'), self)
27
- end
28
+ ## associations ##
28
29
 
29
- def records_set
30
- @records_set ||= EndecaOnDemand::Response::RecordsSet.new(self, xml.children.css('RecordsSet'))
31
- end
30
+ def properties
31
+ @properties ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Property, xml.children.css('properties'), self)
32
+ end
32
33
 
33
- ##
34
+ def records_set
35
+ @records_set ||= EndecaOnDemand::Response::RecordsSet.new(self, xml.children.css('RecordsSet'))
36
+ end
34
37
 
35
- ## data ##
38
+ ##
36
39
 
37
- def options
38
- xml.xpath('child::node()[not(local-name() = "properties" or local-name() = "RecordsSet")]').inject({}) do |hash,child|
39
- hash.tap do
40
- hash[child.name] = child.content
41
- end
42
- end.symbolize_keys
43
- end
40
+ ## data ##
44
41
 
45
- ##
42
+ def options
43
+ @options ||= xml.xpath('child::node()[not(local-name() = "properties" or local-name() = "RecordsSet")]').inject({}) do |hash,child|
44
+ hash.tap do
45
+ hash[child.name] = child.content
46
+ end
47
+ end.symbolize_keys
48
+ end
46
49
 
47
- protected
50
+ ##
48
51
 
49
- def method_missing(method, *args, &block)
50
- return options[method] if options.has_key?(method)
51
- super(method, *args, &block)
52
+ end
53
+ end
52
54
  end
53
-
54
55
  end
@@ -1,50 +1,51 @@
1
- class EndecaOnDemand::Response::Dimension < EndecaOnDemand::Proxy
1
+ module EndecaOnDemand
2
+ class Response
3
+ class Dimension < EndecaOnDemand::Proxy
2
4
 
3
- include EndecaOnDemand::PP
5
+ include EndecaOnDemand::PP
4
6
 
5
- def inspect_attributes; [ :dimension_values, :options ]; end
7
+ def inspect_attributes; [ :dimension_values, :options ]; end
6
8
 
7
- ## fields ##
9
+ ## fields ##
8
10
 
9
- attr_reader :dimension_values, :options, :response
10
-
11
- def initialize(response, xml)
12
- @response, @xml = response, xml
13
- end
11
+ attr_reader :dimension_values, :options, :response
12
+
13
+ def initialize(response, xml)
14
+ @response, @xml = response, xml
14
15
 
15
- ## override proxy ##
16
+ define_getters(:options)
17
+ end
16
18
 
17
- def class
18
- EndecaOnDemand::Response::Dimension
19
- end
19
+ ## override proxy ##
20
20
 
21
- ##
21
+ def class
22
+ EndecaOnDemand::Response::Dimension
23
+ end
22
24
 
23
- ## associations ##
25
+ ##
24
26
 
25
- def dimension_values
26
- @dimension_values ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Dimension::DimensionValue, xml.children.css('DimensionValues > DimensionValue'), self)
27
- end
27
+ ## associations ##
28
28
 
29
- ##
29
+ def dimension_values
30
+ @dimension_values ||= EndecaOnDemand::Collection.new(EndecaOnDemand::Response::Dimension::DimensionValue, xml.children.css('DimensionValues > DimensionValue'), self)
31
+ end
30
32
 
31
- ## data ##
33
+ ##
32
34
 
33
- def options
34
- xml.xpath('child::node()[not(local-name() = "DimensionValues")]').inject({}) do |hash,child|
35
- hash.tap do
36
- hash[child.name] = child.content
37
- end
38
- end.symbolize_keys
39
- end
35
+ ## data ##
40
36
 
41
- ##
37
+ def options
38
+ @options ||= xml.xpath('child::node()[not(local-name() = "DimensionValues")]').inject({}) do |hash,child|
39
+ hash.tap do
40
+ hash[child.name] = child.content
41
+ end
42
+ end.symbolize_keys
43
+ end
42
44
 
43
- protected
45
+ ##
44
46
 
45
- def method_missing(method, *args, &block)
46
- return options[method] if options.has_key?(method)
47
- super(method, *args, &block)
47
+ end
48
48
  end
49
+ end
49
50
 
50
- end
51
+ require 'endeca_on_demand/response/dimension/dimension_value'
@@ -1,50 +1,43 @@
1
- class EndecaOnDemand::Response::Dimension::DimensionValue < EndecaOnDemand::Proxy
1
+ module EndecaOnDemand
2
+ class Response
3
+ class Dimension
4
+ class DimensionValue < 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 :dimension, :options
12
+ attr_reader :dimension, :options
10
13
 
11
- def initialize(dimension, xml)
12
- @dimension, @xml = dimension, xml
13
- end
14
+ def initialize(dimension, xml)
15
+ @dimension, @xml = dimension, xml
14
16
 
15
- ## override proxy ##
17
+ define_getters(:options)
18
+ end
16
19
 
17
- def class
18
- EndecaOnDemand::Response::Dimension::DimensionValue
19
- end
20
+ ## override proxy ##
20
21
 
21
- # def inspection
22
- # options.sort_by(&:first).map { |k,v| "#{k}: #{v.inspect}" }
23
- # end
22
+ def class
23
+ EndecaOnDemand::Response::Dimension::DimensionValue
24
+ end
24
25
 
25
- def inspection
26
- Hash[*options.sort_by(&:first).flatten]
27
- end
26
+ ##
28
27
 
29
- ##
28
+ ## data ##
30
29
 
31
- ## data ##
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
36
+ end
32
37
 
33
- def options
34
- xml.children.inject({}) do |hash,child|
35
- hash.tap do
36
- hash[child.name] = child.content
37
- end
38
- end.symbolize_keys
39
- end
38
+ ##
40
39
 
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)
40
+ end
41
+ end
48
42
  end
49
-
50
43
  end
@@ -1,36 +1,43 @@
1
- class EndecaOnDemand::Response::Property < EndecaOnDemand::Proxy
1
+ module EndecaOnDemand
2
+ class Response
3
+ class Property < EndecaOnDemand::Proxy
2
4
 
3
- include EndecaOnDemand::PP
5
+ include EndecaOnDemand::PP
4
6
 
5
- def inspect_attributes; [ :label, :value ]; end
7
+ def inspect_attributes; [ :label, :value ]; end
6
8
 
7
- ## fields ##
9
+ def inspect; "#{label}: #{value.inspect}"; end
8
10
 
9
- attr_reader :parent
11
+ ## fields ##
10
12
 
11
- def initialize(parent, xml)
12
- @parent, @xml = parent, xml
13
- end
13
+ attr_reader :parent
14
14
 
15
- ## override proxy ##
15
+ def initialize(parent, xml)
16
+ @parent, @xml = parent, xml
17
+ end
16
18
 
17
- def class
18
- EndecaOnDemand::Response::Property
19
- end
19
+ ## override proxy ##
20
20
 
21
- ##
21
+ def class
22
+ EndecaOnDemand::Response::Property
23
+ end
22
24
 
23
- ## data ##
25
+ ##
24
26
 
25
- def label
26
- xml.name.to_s.gsub(/^p_/, '')
27
- end
27
+ ## data ##
28
28
 
29
- def to_s
30
- xml.content
31
- end
32
- alias :value :to_s
29
+ def label
30
+ xml.name.to_s.gsub(/^p_/, '')
31
+ end
32
+
33
+ def value
34
+ xml.content
35
+ end
36
+ alias :to_s :value
37
+ alias :to_param :value
33
38
 
34
- ##
39
+ ##
35
40
 
41
+ end
42
+ end
36
43
  end