chiketto 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c7ae750d116ab1df0463f0674fb1444b57371c6
4
- data.tar.gz: 24ee0e3f5ea28e4f5d124d0b136cc559aa351ff0
3
+ metadata.gz: 2d3c982cc44a739bfced986438e2c622e3ea8fa8
4
+ data.tar.gz: c82350ae60fe519bbe9aa6839ac1933a9e454176
5
5
  SHA512:
6
- metadata.gz: 5a01a2ecacc729b7c779447d74d031353852a2f79e2b31d3bdeaa07e78b5c6dbeb5692b182f7c3f62b309b881ab884d21aec4b62cadcbd06d21067008f457c8a
7
- data.tar.gz: 8a889152c916171eae8eab2afe5012bde446e8e5c1f2dc2f7cf41fd45cce2fe77f3b5c6a54c0c99b7c41682aa0155cad3eadda02d268a40d654acf02477fa4a9
6
+ metadata.gz: ee1253d5e183e441d3d664e62c3897dfb345e0f2c1351a650795bece8d569fc5970c2c61dde2d012750fed4035974ccfe2edeac7eeea0e60ab20418f885568d0
7
+ data.tar.gz: 28c12c5b26dc440daff2d703bed88a1d2a59307935f0c89d1161caf1fded0523149d522944b5a34ad192315ce9f6469678dc027cadacbdea0ece5b0813d6ef06
@@ -88,18 +88,16 @@ module Chiketto
88
88
  get "events/#{id}/attendees", params
89
89
  end
90
90
 
91
- def self.paginated_attendees(id, params, page = 1, attendees = [])
92
- response = Event.find_attendees id, params.merge(page: page.to_s)
93
- attendees.concat response['attendees']
94
- if should_paginate(response['pagination'])
95
- Event.paginated_attendees id, params, page + 1, attendees
96
- else
97
- attendees
91
+ def self.paginated_attendees(id, params)
92
+ page = 0
93
+ attendees = []
94
+ loop do
95
+ page += 1
96
+ response = Event.find_attendees id, params.merge(page: page.to_s)
97
+ attendees.concat response['attendees']
98
+ break unless should_paginate(response['pagination'])
98
99
  end
99
- end
100
-
101
- def self.should_paginate(pagination)
102
- pagination['page_count'] > pagination['page_number']
100
+ attendees
103
101
  end
104
102
  end
105
103
  end
@@ -49,5 +49,9 @@ module Chiketto
49
49
  def self.token
50
50
  "/?token=#{Chiketto.api_key}"
51
51
  end
52
+
53
+ def self.should_paginate(pagination)
54
+ pagination['page_count'] > pagination['page_number']
55
+ end
52
56
  end
53
57
  end
data/lib/chiketto/user.rb CHANGED
@@ -18,8 +18,8 @@ module Chiketto
18
18
  end
19
19
 
20
20
  def events(params = {})
21
- events = User.find_events @id, params
22
- events['events'].map { |e| Event.new e }
21
+ events = User.paginated_events @id, params
22
+ events.map { |e| Event.new e }
23
23
  end
24
24
 
25
25
  def organizers
@@ -36,5 +36,17 @@ module Chiketto
36
36
  def self.find_organizers(id)
37
37
  get "users/#{id}/organizers"
38
38
  end
39
+
40
+ def self.paginated_events(id, params)
41
+ page = 0
42
+ events = []
43
+ loop do
44
+ page += 1
45
+ response = User.find_events id, params.merge(page: page.to_s)
46
+ events.concat response['events']
47
+ break unless should_paginate(response['pagination'])
48
+ end
49
+ events
50
+ end
39
51
  end
40
52
  end
@@ -1,3 +1,3 @@
1
1
  module Chiketto
2
- VERSION = "0.4.8"
2
+ VERSION = "0.4.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chiketto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Radford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler