planvine 0.0.8 → 0.0.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: 43646e86bb1b86fd98387aaf416b07eb45e79a51
4
- data.tar.gz: 06b445842b46ec4a0085adb0d30c579212b93112
3
+ metadata.gz: 05ccc8202243a3cfb0eac6d2a12eac0d0faf9431
4
+ data.tar.gz: 64fa9de473cb05f2ae7b7f669c6e304a07d7a1b6
5
5
  SHA512:
6
- metadata.gz: d7118689625ecae51d2498d1caca20281ea2f46f19a8315a41f5dff88218a335499e215dd935dffa40aa17b662df1caff9b715757d9a8b4fd86e541b083288c9
7
- data.tar.gz: dd723c609b01c8bffb72f720c9755416a1035efaabe70bc12e303e4c643cb74552b63d710bd96e65326357c99b33939c4a351b51a57dedec3a4a293ac6da9e64
6
+ metadata.gz: 9c31db93c0380a8fd946bfe2d2bd9b70f9f67d3a0a9602d0129ee6fecb7008d2f34bf332e613464dc89d87b9e260adecfd57af2a0064e63b8049e68408364692
7
+ data.tar.gz: fb94b7c7048f934906329963473dd02c34f82ef5e77afb579e4a73095366574b7b188c677325aa936d2470b039b3353e2bf5d11982a01b9625622debb94c2151
@@ -19,8 +19,9 @@ module Planvine
19
19
  def events
20
20
  return [] if api.category_events(id).nil?
21
21
  api.category_events(id).map do |event|
22
+ return [] if event.nil?
22
23
  EventsBuilder.build(event)
23
- end
24
+ end.flatten
24
25
  end
25
26
 
26
27
  def api
@@ -1,17 +1,20 @@
1
1
  module Planvine
2
2
  class EventsBuilder
3
3
  def self.build(event)
4
- Event.new(
5
- :end_date => event["end_date"],
6
- :title => event["title"],
7
- :url => event["url"],
8
- :photo => (event["photo"].nil? ? "" : event["photo"]["url"]),
9
- :start_date => event["start_date"],
10
- :description => event["description"],
11
- :source => event["source"],
12
- :venue => Venue.new(event["venue"]),
13
- :id => event["id"]
14
- )
4
+ begin
5
+ Event.new(
6
+ :end_date => event["end_date"],
7
+ :title => event["title"],
8
+ :url => event["url"],
9
+ :photo => (event["photo"].nil? ? "" : event["photo"]["url"]),
10
+ :start_date => event["start_date"],
11
+ :description => event["description"],
12
+ :source => event["source"],
13
+ :venue => Venue.new(event["venue"]),
14
+ :id => event["id"]
15
+ )
16
+ rescue
17
+ end
15
18
  end
16
19
  end
17
20
  end
@@ -22,7 +22,15 @@ module Planvine
22
22
  end
23
23
 
24
24
  def category_events(id)
25
- self.class.get("/category/#{id}/events?api_key=#{@api_key}")["data"]
25
+ number_of_pages = self.class.get("/category/#{id}/events?api_key=#{@api_key}")["_metadata"]["total_pages"]
26
+ events = [self.class.get("/category/#{id}/events?api_key=#{@api_key}")["data"]]
27
+ return events if number_of_pages == 1
28
+
29
+ self.class.get("/category/#{id}/events?api_key=#{@api_key}")["_metadata"]["total_pages"].times do |i|
30
+ next if (i+1) == 1
31
+ events << self.class.get("/category/#{id}/events?api_key=#{@api_key}&page=#{i + 1}")["data"]
32
+ end
33
+ events.flatten
26
34
  end
27
35
 
28
36
  def venue(id)
@@ -1,3 +1,3 @@
1
1
  module Planvine
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: planvine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Patching
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-03 00:00:00.000000000 Z
11
+ date: 2013-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty