garb 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ module Garb
4
4
  methods.each do |method|
5
5
  class_eval <<-CODE
6
6
  def #{method}(field, value)
7
- self.parameters << {SymbolOperator.new(field, :#{method}) => value}
7
+ @filter_hash.merge!({SymbolOperator.new(field, :#{method}) => value})
8
8
  end
9
9
  CODE
10
10
  end
@@ -20,7 +20,11 @@ module Garb
20
20
  end
21
21
 
22
22
  def filters(&block)
23
+ @filter_hash = {}
24
+
23
25
  instance_eval &block
26
+
27
+ self.parameters << @filter_hash
24
28
  end
25
29
 
26
30
  def to_params
@@ -28,8 +32,8 @@ module Garb
28
32
  param.map do |k,v|
29
33
  next unless k.is_a?(SymbolOperator)
30
34
  "#{URI.encode(k.to_google_analytics, /[=<>]/)}#{CGI::escape(v.to_s)}"
31
- end.join(',') # Hash AND
32
- end.join(';') # Array OR
35
+ end.join(';') # Hash AND (no duplicate keys)
36
+ end.join(',') # Array OR
33
37
 
34
38
  value.empty? ? {} : {'filters' => value}
35
39
  end
@@ -3,7 +3,7 @@ module Garb
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- TINY = 1
6
+ TINY = 2
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
@@ -9,7 +9,9 @@ module Garb
9
9
  symbol = :foo
10
10
 
11
11
  SymbolOperator.expects(:new).with(:bar, operator).returns(new_operator)
12
- @filter_parameters.send(operator.to_sym, :bar, 100)
12
+ @filter_parameters.filters do
13
+ send(operator.to_sym, :bar, 100)
14
+ end
13
15
 
14
16
  parameter = {new_operator => 100}
15
17
  assert_equal parameter, @filter_parameters.parameters.last
@@ -33,14 +35,14 @@ module Garb
33
35
  end
34
36
 
35
37
  context "when converting parameters hash into query string parameters" do
36
- should "parameterize hash operators and join elements" do
38
+ should "parameterize hash operators and join elements with AND" do
37
39
  @filter_parameters.filters do
38
- eql(:city, 'New York')
40
+ eql(:city, 'New York City')
39
41
  eql(:state, 'New York')
40
42
  end
41
43
 
42
- params = {'filters' => 'ga:city%3D%3DNew+York;ga:state%3D%3DNew+York'}
43
- assert_equal params, @filter_parameters.to_params
44
+ params = ['ga:city%3D%3DNew+York+City', 'ga:state%3D%3DNew+York']
45
+ assert_equal params, @filter_parameters.to_params['filters'].split(';').sort
44
46
  end
45
47
 
46
48
  should "properly encode operators" do
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 7
8
+ - 2
9
+ version: 0.7.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Tony Pitale
@@ -9,29 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-02 00:00:00 -05:00
17
+ date: 2010-03-05 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: happymapper
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ~>
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 3
30
+ - 0
23
31
  version: 0.3.0
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 3
44
+ - 0
33
45
  version: 2.3.0
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  description:
36
49
  email: tony.pitale@viget.com
37
50
  executables: []
@@ -94,18 +107,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
107
  requirements:
95
108
  - - ">="
96
109
  - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
97
112
  version: "0"
98
- version:
99
113
  required_rubygems_version: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
102
116
  - !ruby/object:Gem::Version
117
+ segments:
118
+ - 0
103
119
  version: "0"
104
- version:
105
120
  requirements: []
106
121
 
107
122
  rubyforge_project: viget
108
- rubygems_version: 1.3.5
123
+ rubygems_version: 1.3.6
109
124
  signing_key:
110
125
  specification_version: 3
111
126
  summary: Google Analytics API Ruby Wrapper