primedia-endeca 0.9.18 → 0.9.19

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.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{endeca}
3
- s.version = "0.9.18"
3
+ s.version = "0.9.19"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Rein Henrichs", "Andy Stone"]
data/lib/core_ext.rb CHANGED
@@ -58,6 +58,14 @@ class Hash
58
58
  end
59
59
  }.join('&').to_params
60
60
  end
61
+
62
+ def symbolize_keys
63
+ inject({}) do |options, (key, value)|
64
+ options[(key.to_sym rescue key) || key] = value
65
+ options
66
+ end
67
+ end
68
+
61
69
  end
62
70
 
63
71
  class NilClass
data/lib/endeca.rb CHANGED
@@ -21,7 +21,7 @@ require 'endeca/document'
21
21
  module Endeca
22
22
 
23
23
  # :stopdoc:
24
- VERSION = '0.9.18'
24
+ VERSION = '0.9.19'
25
25
  # :startdoc:
26
26
 
27
27
  # Returns the version string for the library.
data/lib/endeca/map.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Endeca
2
2
  class Map
3
- def initialize(old_key=nil, new_key=nil)
4
- @old_key = old_key
5
- @new_key = new_key
3
+ def initialize(old_key, new_key=nil)
4
+ @old_key = old_key.to_sym
5
+ @new_key = new_key || @old_key
6
6
  boolean
7
7
  end
8
8
 
@@ -75,7 +75,7 @@ module Endeca
75
75
 
76
76
  # Perform the mapping as defined for the current_query
77
77
  def perform(current_query)
78
- @current_query = current_query.with_indifferent_access
78
+ @current_query = current_query.symbolize_keys
79
79
 
80
80
  perform_transformation
81
81
  perform_map
@@ -25,11 +25,12 @@ module Endeca
25
25
  # Use the mappings hash to replace domain level query query_options with
26
26
  # their Endeca equivalent.
27
27
  def transform_query_options(query_options)
28
- query = query_options.dup
28
+ query = query_options.symbolize_keys
29
29
  query.each do |key, value|
30
30
  if mappings[key]
31
31
  new_options = mappings[key].perform(query_options)
32
32
  query_options.delete(key)
33
+ query_options.delete(key.to_s)
33
34
  query_options.update(new_options)
34
35
  end
35
36
  end
@@ -241,6 +241,14 @@ describe Endeca::Document do
241
241
  after do
242
242
  Endeca::Document.mappings = {}
243
243
  end
244
+
245
+ describe "when the key to be mapped is a string" do
246
+ it "maps correctly" do
247
+ Endeca::Document.map(:apartments => :showapartments)
248
+ Endeca::Document.transform_query_options("apartments" => true).
249
+ should == {:showapartments => 1}
250
+ end
251
+ end
244
252
 
245
253
  describe "when there is no mapping for the given key" do
246
254
  it "returns the query options without modification" do
@@ -48,21 +48,27 @@ describe Endeca::Map do
48
48
 
49
49
  describe "#perform_into" do
50
50
  describe "with an enclosing string" do
51
- map = Endeca::Map.new(:foo, :bar)
52
- map.into(:bizz).enclose(:AND)
53
- map.perform(:foo => :quux).should == {:bizz => 'AND(bar:quux)'}
51
+ it "wraps the parameter" do
52
+ map = Endeca::Map.new(:foo, :bar)
53
+ map.into(:bizz).enclose(:AND)
54
+ map.perform(:foo => :quux).should == {:bizz => 'AND(bar:quux)'}
55
+ end
54
56
  end
55
57
 
56
58
  describe "with replace" do
57
- map = Endeca::Map.new(:foo, :bar)
58
- map.into(:bizz).replace!
59
- map.perform(:foo => :quux, :bizz => :foobar).should == {:bizz => 'bar:quux'}
59
+ it "replaces the existing parameter" do
60
+ map = Endeca::Map.new(:foo, :bar)
61
+ map.into(:bizz).replace!
62
+ map.perform(:foo => :quux, :bizz => :foobar).should == {:bizz => 'bar:quux'}
63
+ end
60
64
  end
61
65
 
62
66
  describe "with enclose and replace" do
63
- map = Endeca::Map.new(:foo, :bar)
64
- map.into(:bizz).enclose(:AND).replace!
65
- map.perform(:foo => :quux, :bizz => :foobar).should == {:bizz => 'AND(bar:quux)'}
67
+ it "wraps the parameter and replaces the existing parameter" do
68
+ map = Endeca::Map.new(:foo, :bar)
69
+ map.into(:bizz).enclose(:AND).replace!
70
+ map.perform(:foo => :quux, :bizz => :foobar).should == {:bizz => 'AND(bar:quux)'}
71
+ end
66
72
  end
67
73
  end
68
74
 
@@ -96,11 +102,11 @@ describe Endeca::Map do
96
102
 
97
103
  describe "#transform" do
98
104
  it "should execute the transformation block on the query"
99
- map = Endeca::Map.new(:field_list)
100
- map.into(:F).transform do |fields_array|
101
- fields_array.collect{|field| "#{field.to_s}:1"}.join('|')
105
+ map = Endeca::Map.new(:field_list)
106
+ map.into(:F).transform do |fields_array|
107
+ fields_array.collect{|field| "#{field.to_s}:1"}.join('|')
108
+ map.perform(:field_list => [:first_name, :last_name, :email]).
109
+ should == {:F => "first_name:1|last_name:1|email:1"}
102
110
  end
103
- map.perform(:field_list => [:first_name, :last_name, :email]).
104
- should == {:F => "first_name:1|last_name:1|email:1"}
105
111
  end
106
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primedia-endeca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.18
4
+ version: 0.9.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rein Henrichs