pwnalytics_client 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -31,6 +31,9 @@ Finally, get the logged events for that site:
31
31
 
32
32
  # Restrict query to events with certain names.
33
33
  events = site.events :names => ['page', 'unload']
34
+
35
+ # Avoid a data flood.
36
+ events = site.events :limit => 200
34
37
 
35
38
  Events have the same data as in the JSON output.
36
39
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -30,11 +30,16 @@ class Site
30
30
  #
31
31
  # Options supports the following keys:
32
32
  # :names:: only get events whose names are contained in this array
33
+ # :limit:: return the first events matching the criteria
34
+ #
35
+ # Events will be resturned in the reverse order of their occurrence.
33
36
  def events(options = {})
34
37
  request = "/web_properties/#{@uid}/events.json?"
38
+ request << "limit=#{options[:limit] || 'no'}"
39
+
35
40
  if options[:names]
36
41
  request << options[:names].
37
- map { |name| 'names%5B%5D=' + CGI.escape(name) }.join('&')
42
+ map { |name| '&names%5B%5D=' + CGI.escape(name) }.join('')
38
43
  end
39
44
  @client.request(request).map { |data| Event.new self, data }
40
45
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pwnalytics_client}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Victor Costan"]
@@ -7,19 +7,27 @@ describe PwnalyticsClient::Site do
7
7
  describe 'events' do
8
8
  it 'should request all events by default' do
9
9
  client.should_receive(:request).
10
- with('/web_properties/AA/events.json?').and_return({})
10
+ with('/web_properties/AA/events.json?limit=no').and_return({})
11
11
  site.events.should be_empty
12
12
  end
13
13
 
14
14
  it 'should encode name filter if given' do
15
15
  client.should_receive(:request).
16
- with('/web_properties/AA/events.json?names%5B%5D=AB&names%5B%5D=C+D').
16
+ with('/web_properties/AA/events.json?limit=no&' +
17
+ 'names%5B%5D=AB&names%5B%5D=C+D').
17
18
  and_return({})
18
19
  site.events(:names => ['AB', 'C D']).should be_empty
19
20
  end
20
21
 
22
+ it 'should encode limit filter if given' do
23
+ client.should_receive(:request).
24
+ with('/web_properties/AA/events.json?limit=42').and_return({})
25
+ site.events(:limit => 42).should be_empty
26
+ end
27
+
21
28
  let(:result) do
22
- client.should_receive(:request).with('/web_properties/AA/events.json?').
29
+ client.should_receive(:request).
30
+ with('/web_properties/AA/events.json?limit=no').
23
31
  and_return([{'name' => 'page', 'referrer' => {'url' => 'null'},'data' => {},'pixels' => {'screen' => {'height' => 1440,'width' => 4240},'document' => {'height' => 863,'width' => 1680},'window' => {'x' => 2215,'y' => 181}},'id' => 1,'visitor' => {'uid' => '12f49459540.11faa9b963f5c4f0'},'page' => {'url' => 'http://localhost:3000/'},'ip' => '127.0.0.1', 'browser' => {'ua' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Ubuntu/10.10 Chromium/10.0.648.204 Chrome/10.0.648.204 Safari/534.16', 'time' => 1302682242437}},
24
32
  {'name' => 'unload', 'referrer' => {'url' => 'null'},'data' => {},'pixels' => {'screen' => {'height' => 1440,'width' => 4240},'document' => {'height' => 863,'width' => 1680},'window' => {'x' => 2215,'y' => 181}},'id' => 2,'visitor' => {'uid' => '12f49459540.11faa9b963f5c4f0'},'page' => {'url' => 'http://localhost:3000/'},'ip' => '127.0.0.1', 'browser' => {'ua' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Ubuntu/10.10 Chromium/10.0.648.204 Chrome/10.0.648.204 Safari/534.16', 'time' => 1302682245565}}])
25
33
  site.events
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwnalytics_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Victor Costan