primedia-endeca 0.9.19 → 0.9.20

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,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{endeca}
3
- s.version = "0.9.19"
3
+ s.version = "0.9.20"
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"]
7
- s.date = %q{2009-02-06}
7
+ s.date = %q{2009-02-09}
8
8
  s.description = %q{An Endeca client library for Ruby.}
9
9
  s.email = %q{}
10
10
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
data/lib/endeca/map.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Endeca
2
2
  class Map
3
3
  def initialize(old_key, new_key=nil)
4
- @old_key = old_key.to_sym
4
+ @old_key = old_key
5
5
  @new_key = new_key || @old_key
6
6
  boolean
7
7
  end
@@ -26,6 +26,7 @@ module Endeca
26
26
  # ?ntk=propercity&ntt=>Atlanta
27
27
  def into(hash)
28
28
  @into = hash
29
+ @into = @into.symbolize_keys if @into.respond_to?(:symbolize_keys)
29
30
  @with ||= ':'
30
31
  @join ||= '|'
31
32
  self
@@ -76,6 +77,7 @@ module Endeca
76
77
  # Perform the mapping as defined for the current_query
77
78
  def perform(current_query)
78
79
  @current_query = current_query.symbolize_keys
80
+ @current_value = @current_query[@old_key]
79
81
 
80
82
  perform_transformation
81
83
  perform_map
@@ -108,8 +110,7 @@ module Endeca
108
110
 
109
111
  def perform_transformation
110
112
  return unless transformations?
111
-
112
- current_value = @current_query[@old_key]
113
+ current_value = @current_value
113
114
  transformations.each do |transformation|
114
115
  current_value = transformation.call(current_value)
115
116
  end
@@ -117,12 +118,12 @@ module Endeca
117
118
  end
118
119
 
119
120
  def perform_map
120
- @new_query = {@new_key => @current_value}
121
+ @new_query = {@new_key => @current_value}.symbolize_keys
121
122
  end
122
123
 
123
124
  def perform_into
124
125
  return unless into?
125
-
126
+
126
127
  old_key, old_value = Array(@new_query).flatten
127
128
  new_key, new_value = Array(@into).flatten
128
129
  if new_value
@@ -11,6 +11,7 @@ module Endeca
11
11
  # map(:new_name)
12
12
  def map(mapping = {})
13
13
  mapping = {mapping => mapping} if Symbol === mapping
14
+ mapping = mapping.symbolize_keys
14
15
 
15
16
  if mapping.length > 1
16
17
  raise ArgumentError, "map only accepts one key=>value pair"
@@ -25,16 +26,17 @@ module Endeca
25
26
  # Use the mappings hash to replace domain level query query_options with
26
27
  # their Endeca equivalent.
27
28
  def transform_query_options(query_options)
29
+ # {"apartments" => true}
28
30
  query = query_options.symbolize_keys
29
- query.each do |key, value|
30
- if mappings[key]
31
- new_options = mappings[key].perform(query_options)
32
- query_options.delete(key)
33
- query_options.delete(key.to_s)
34
- query_options.update(new_options)
31
+ # {:apartments => true}
32
+ query.each do |key, _|
33
+ if mapping = mappings[key]
34
+ new_options = mapping.perform(query)
35
+ query.delete(key)
36
+ query.update(new_options)
35
37
  end
36
38
  end
37
- query_options
39
+ query
38
40
  end
39
41
 
40
42
  end
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.19'
24
+ VERSION = '0.9.20'
25
25
  # :startdoc:
26
26
 
27
27
  # Returns the version string for the library.
@@ -249,6 +249,17 @@ describe Endeca::Document do
249
249
  should == {:showapartments => 1}
250
250
  end
251
251
  end
252
+
253
+ describe "with multiple keys that are joined" do
254
+ it "should include all the keys" do
255
+ require 'pp'
256
+ Endeca::Document.map(:apartments => :showapartments).into('Ntt' => 'Ntk')
257
+ Endeca::Document.map(:colleges => :showcolleges).into('Ntt' => 'Ntk')
258
+ ntt = Endeca::Document.transform_query_options('apartments' => '1', 'colleges' => '2')[:Ntt]
259
+ ntt.should include('showapartments')
260
+ ntt.should include('showcolleges')
261
+ end
262
+ end
252
263
 
253
264
  describe "when there is no mapping for the given key" do
254
265
  it "returns the query options without modification" do
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.19
4
+ version: 0.9.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rein Henrichs
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-02-06 00:00:00 -08:00
13
+ date: 2009-02-09 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency