neuron-client 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -72,9 +72,11 @@ module Neuron
72
72
  connected_to_admin!
73
73
  by = (parameters[:by] || parameters['by']).to_s
74
74
  minutes = parameters[:minutes] || parameters['minutes']
75
+ group_by = parameters[:group_by] || parameters['group_by']
75
76
  parameters = {}
76
77
  parameters['by'] = by unless by.blank?
77
78
  parameters['minutes'] = minutes.to_i if minutes.to_i > 0
79
+ parameters['group_by'] = group_by.to_s unless group_by.blank?
78
80
  if validate?
79
81
  unless STATISTIC_TYPES.include?(statistic.to_s)
80
82
  raise "Unsupported statistic: #{statistic}"
@@ -85,6 +87,9 @@ module Neuron
85
87
  unless minutes.blank? || minutes.to_i > 0
86
88
  raise "Unsupported minutes: #{minutes}"
87
89
  end
90
+ unless group_by.blank? || group_by == 'hour'
91
+ raise "Unsupported group_by: #{group_by}"
92
+ end
88
93
  end
89
94
 
90
95
  connection.get("ads/#{id}/recent/#{statistic}", parameters)
@@ -58,6 +58,35 @@ module Neuron
58
58
  Ad.find(ad_id)
59
59
  end
60
60
 
61
+ STATISTIC_TYPES = %w(requests blocks defaults unitloads selections undeliveries impressions redirects clicks)
62
+
63
+ def recent(statistic, parameters={})
64
+ connected_to_admin!
65
+ by = (parameters[:by] || parameters['by']).to_s
66
+ minutes = parameters[:minutes] || parameters['minutes']
67
+ group_by = parameters[:group_by] || parameters['group_by']
68
+ parameters = {}
69
+ parameters['by'] = by unless by.blank?
70
+ parameters['minutes'] = minutes.to_i if minutes.to_i > 0
71
+ parameters['group_by'] = group_by.to_s unless group_by.blank?
72
+ if validate?
73
+ unless STATISTIC_TYPES.include?(statistic.to_s)
74
+ raise "Unsupported statistic: #{statistic}"
75
+ end
76
+ unless by.blank? || by == 'zone'
77
+ raise "Unsupported by: #{by}"
78
+ end
79
+ unless minutes.blank? || minutes.to_i > 0
80
+ raise "Unsupported minutes: #{minutes}"
81
+ end
82
+ unless group_by.blank? || group_by == 'hour'
83
+ raise "Unsupported group_by: #{group_by}"
84
+ end
85
+ end
86
+
87
+ connection.get("zones/#{id}/recent/#{statistic}", parameters)
88
+ end
89
+
61
90
  def unlink(ad_id)
62
91
  connected_to_admin!
63
92
  validate_id!(ad_id)
@@ -76,4 +105,4 @@ module Neuron
76
105
  end
77
106
  end
78
107
  end
79
- end
108
+ end
@@ -1,5 +1,5 @@
1
1
  module Neuron
2
2
  module Client
3
- VERSION = "0.4.4"
3
+ VERSION = "0.4.5"
4
4
  end
5
5
  end
@@ -110,6 +110,15 @@ module Neuron
110
110
  end
111
111
  end
112
112
 
113
+ describe "recent(statistic, by=nil)" do
114
+ it "should call the expected method and return the expected result" do
115
+ zone = Zone.new(@minimal_attributes.merge('id' => 'z99'))
116
+ @connection.should_receive(:get).with('zones/z99/recent/impressions', {'by' => 'zone'}).and_return('return_value')
117
+
118
+ zone.recent('impressions', :by => 'zone').should == 'return_value'
119
+ end
120
+ end
121
+
113
122
  describe "unlink(ad_id)" do
114
123
  it "should call the expected method and return the expected results" do
115
124
  zone = Zone.new(@minimal_attributes.merge('id' => 'z99'))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neuron-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 4
10
- version: 0.4.4
9
+ - 5
10
+ version: 0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - RMM Online
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-02 00:00:00 Z
18
+ date: 2012-03-12 00:00:00 -05:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rest-client
@@ -450,6 +451,7 @@ files:
450
451
  - spec/lib/schema/s3_file_spec.rb
451
452
  - spec/lib/schema/zone_spec.rb
452
453
  - spec/spec_helper.rb
454
+ has_rdoc: true
453
455
  homepage: http://github.com/rmm/neuron-client
454
456
  licenses: []
455
457
 
@@ -479,7 +481,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
479
481
  requirements: []
480
482
 
481
483
  rubyforge_project: neuron-client
482
- rubygems_version: 1.8.10
484
+ rubygems_version: 1.6.2
483
485
  signing_key:
484
486
  specification_version: 3
485
487
  summary: Neuron Admin Client Gem