primedia-endeca 0.9.22 → 0.9.23

Sign up to get free protection for your applications and to get access to all the features.
data/endeca.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{endeca}
5
- s.version = "0.9.22"
5
+ s.version = "0.9.23"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Rein Henrichs", "Andy Stone"]
data/lib/core_ext.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Array
2
- def to_params
3
- join('&').to_params
2
+ def to_endeca_params
3
+ join('&').to_endeca_params
4
4
  end
5
5
  end
6
6
 
@@ -67,7 +67,7 @@ class Class
67
67
  end
68
68
 
69
69
  class Hash
70
- def to_params
70
+ def to_endeca_params
71
71
  map { |k, v|
72
72
  if v.instance_of?(Hash)
73
73
  v.map { |sk, sv|
@@ -76,26 +76,26 @@ class Hash
76
76
  else
77
77
  "#{k}=#{v}"
78
78
  end
79
- }.join('&').to_params
79
+ }.join('&').to_endeca_params
80
80
  end
81
-
81
+
82
82
  def symbolize_keys
83
83
  inject({}) do |options, (key, value)|
84
84
  options[(key.to_sym rescue key) || key] = value
85
85
  options
86
86
  end
87
87
  end
88
-
88
+
89
89
  end
90
90
 
91
91
  class NilClass
92
- def to_params
92
+ def to_endeca_params
93
93
  ''
94
94
  end
95
95
  end
96
96
 
97
97
  class String
98
- def to_params
98
+ def to_endeca_params
99
99
  Endeca.escape(self)
100
100
  end
101
101
  end
@@ -19,7 +19,7 @@ module Endeca
19
19
  end
20
20
  alias_method :attributes, :raw
21
21
 
22
- def to_params
22
+ def to_endeca_params
23
23
  selection_link || removal_link
24
24
  end
25
25
 
@@ -30,7 +30,7 @@ module Endeca
30
30
  (@raw['Dimensions'] || []).first || {}
31
31
  end
32
32
 
33
- def to_params
33
+ def to_endeca_params
34
34
  expansion_link || contraction_link
35
35
  end
36
36
 
@@ -54,7 +54,7 @@ module Endeca
54
54
  end
55
55
 
56
56
  def query_string
57
- query_string_parts = [@uri.query, @query.to_params]
57
+ query_string_parts = [@uri.query, @query.to_endeca_params]
58
58
  query_string_parts.reject!{ |s| s.nil? || s.empty? }
59
59
 
60
60
  query_string_parts.empty? ? nil : query_string_parts.join('&')
data/lib/endeca.rb CHANGED
@@ -25,16 +25,16 @@ module Endeca
25
25
  extend Logging
26
26
 
27
27
  # :stopdoc:
28
- VERSION = '0.9.22'
28
+ VERSION = '0.9.23'
29
29
  # :startdoc:
30
30
 
31
31
  # Returns the version string for the library.
32
- #
33
32
  def self.version
34
33
  VERSION
35
34
  end
36
35
 
37
36
  # Set Endeca.debug = true to turn on query logging
37
+ # Set Endeca.benchmark = true to turn on query benchmarking
38
38
  class << self
39
39
  attr_accessor :logger
40
40
  attr_accessor :debug
@@ -44,7 +44,7 @@ module Endeca
44
44
  self.logger = Logger.new(STDOUT)
45
45
  self.debug = false
46
46
  self.benchmark = false
47
-
47
+
48
48
  # Endeca URIs require colons to be escaped
49
49
  def self.escape(str)
50
50
  URI.escape(str, /[^-_.!~*'()a-zA-Z\d;\/?@&=+$,\[\]]/n)
@@ -1,54 +1,74 @@
1
1
  require File.join(File.dirname(__FILE__), %w[spec_helper])
2
2
 
3
3
  describe Array do
4
- describe "#to_params" do
4
+ describe "#to_endeca_params" do
5
5
  it "should join the elements with ampersand" do
6
- ["foo=1","bar=3"].to_params.should == "foo=1&bar=3"
6
+ ["foo=1","bar=3"].to_endeca_params.should == "foo=1&bar=3"
7
7
  end
8
8
 
9
9
  it "should escape all elements" do
10
- ['|=|','||=||'].to_params.should == '%7C=%7C&%7C%7C=%7C%7C'
10
+ ['|=|','||=||'].to_endeca_params.should == '%7C=%7C&%7C%7C=%7C%7C'
11
+ end
12
+ end
13
+ end
14
+
15
+ describe Benchmark do
16
+ describe ".realtime" do
17
+ it "should check the time twice" do
18
+ Time.should_receive(:now).exactly(2).times
19
+ Benchmark.realtime(){}
20
+ end
21
+
22
+ it "should return the time difference as a float" do
23
+ Benchmark.realtime(){}.should be_a_kind_of(Float)
24
+ end
25
+ end
26
+
27
+ describe ".ms" do
28
+ it "should be 1000 times the realtime value" do
29
+ Benchmark.stub!(:realtime).and_return(1)
30
+ Benchmark.ms.should == 1000
11
31
  end
12
32
  end
13
33
  end
14
34
 
15
35
  describe Hash do
16
- describe "#to_params" do
36
+ describe "#to_endeca_params" do
17
37
  it "should join a key-value pair with equals" do
18
- {:foo => :bar}.to_params.should == 'foo=bar'
38
+ {:foo => :bar}.to_endeca_params.should == 'foo=bar'
19
39
  end
20
40
 
21
41
  it "should join two key-value pairs with ampersand" do
22
- result = {:foo => :bar, :bizz => :bazz}.to_params
42
+ result = {:foo => :bar, :bizz => :bazz}.to_endeca_params
23
43
  (result == 'foo=bar&bizz=bazz' || result == 'bizz=bazz&foo=bar').should be_true
24
44
  end
25
45
 
26
46
  it "should use brackets to indicate a nested hash" do
27
- {:foo => {:foo => :bar}}.to_params.should == 'foo[foo]=bar'
47
+ {:foo => {:foo => :bar}}.to_endeca_params.should == 'foo[foo]=bar'
28
48
  end
29
49
 
30
50
  it "should escape all elements" do
31
- {'|' => '||'}.to_params.should == '%7C=%7C%7C'
51
+ {'|' => '||'}.to_endeca_params.should == '%7C=%7C%7C'
32
52
  end
33
53
  end
34
54
  end
35
55
 
36
56
  describe NilClass do
37
- describe "to_params" do
57
+ describe "to_endeca_params" do
38
58
  it "should return the empty string" do
39
- nil.to_params.should == ''
59
+ nil.to_endeca_params.should == ''
40
60
  end
41
61
  end
42
62
  end
43
63
 
44
64
  describe String do
45
- describe "#to_params" do
65
+ describe "#to_endeca_params" do
46
66
  it "should URI escape the contents" do
47
- '|'.to_params.should == '%7C'
67
+ '|'.to_endeca_params.should == '%7C'
48
68
  end
49
69
 
50
70
  it "should URI escape a colon" do
51
- ':'.to_params.should == "%3A"
71
+ ':'.to_endeca_params.should == "%3A"
52
72
  end
53
73
  end
54
74
  end
@@ -9,7 +9,7 @@ describe Endeca::Dimension do
9
9
  end
10
10
  end
11
11
 
12
- describe "#to_params" do
12
+ describe "#to_endeca_params" do
13
13
  before do
14
14
  @dimension = Endeca::Dimension.new
15
15
  @selection = mock('selection link')
@@ -21,7 +21,7 @@ describe Endeca::Dimension do
21
21
  @dimension.stub!(:selection_link => @selection_link)
22
22
  @dimension.stub!(:removal_link => nil)
23
23
 
24
- @dimension.to_params.should == @selection_link
24
+ @dimension.to_endeca_params.should == @selection_link
25
25
  end
26
26
  end
27
27
 
@@ -30,7 +30,7 @@ describe Endeca::Dimension do
30
30
  @dimension.stub!(:selection_link => nil)
31
31
  @dimension.stub!(:removal_link => @removal_link)
32
32
 
33
- @dimension.to_params.should == @removal_link
33
+ @dimension.to_endeca_params.should == @removal_link
34
34
  end
35
35
  end
36
36
  end
@@ -53,8 +53,8 @@ describe Endeca::Refinement do
53
53
  end
54
54
  end
55
55
 
56
- it "should return to_params on the contraction link " do
57
- @refinement.to_params.should == "N="
56
+ it "should return to_endeca_params on the contraction link " do
57
+ @refinement.to_endeca_params.should == "N="
58
58
  end
59
59
 
60
60
  it "should return an array of dimensions for dimension_values" do
@@ -52,14 +52,14 @@ describe Endeca::Request do
52
52
  describe "with a hash of query options" do
53
53
  it "should append the query options onto the url" do
54
54
  query = {:foo => :bar}
55
- Endeca::Request.new(@path, query).uri.query.should == query.to_params
55
+ Endeca::Request.new(@path, query).uri.query.should == query.to_endeca_params
56
56
  end
57
57
  end
58
58
 
59
59
  describe "with a string of query options" do
60
60
  it "should append the query options string onto the url" do
61
61
  query = 'N=56'
62
- Endeca::Request.new(@path, query).uri.query.should == query.to_params
62
+ Endeca::Request.new(@path, query).uri.query.should == query.to_endeca_params
63
63
  end
64
64
  end
65
65
  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.22
4
+ version: 0.9.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rein Henrichs