planvine 0.0.2 → 0.0.3

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: 5e0c38afb9ddbca6396753a59d48418bba41ac61
4
- data.tar.gz: 2028710738a46ee18d6dbe29130940142781fc6d
3
+ metadata.gz: 3d3be0d502d066389276f2318de07a947c0ae2a7
4
+ data.tar.gz: 67b7eb15ccac46c4e3bb72d280e1ec4e0efe15af
5
5
  SHA512:
6
- metadata.gz: 4793fa10ca7cdc57c74065da047ab4b83aa71e9a5ba487eda46cc5e9bcaf3cc10bcce06e6fd77568d35ba4ecf2f3e5ed6319d084f9b4bc3e3addbd7b5d89fba2
7
- data.tar.gz: 5af09543ca88a2802486ec9c2b88feb2bb3396443edfc039ece99ae30e1b8a55fe81730f9934fb8ed825dc76fb5ce5eb2a399cfd74d1c57ed74e43f068231641
6
+ metadata.gz: e197a9e5be64adaf2506c248799ce271fb4599c56fb40b81d350f6c3a28328116724612229cddbe7988057ff6014c3fa6d66c16c3ec5cf101613ff8094903777
7
+ data.tar.gz: 683c0067aacd8b16ac675e0667ff3179c4ef351f1a314ff115d767bb4b668eb48c6dfb3158a0c0893b85bb2053cf24724258c906c249f112c8e7595b4037dddc
data/README.md CHANGED
@@ -22,6 +22,15 @@ Return events
22
22
 
23
23
  Planvine.for('My-API-KEY').events
24
24
 
25
+ Return categories
26
+
27
+ planvine = Planvine.for('MY-API-KEY')
28
+ planvine.categories
29
+
30
+ #return events for a category
31
+ category = planvine.categories.first
32
+ category.events
33
+
25
34
  ## Contributing
26
35
 
27
36
  1. Fork it
@@ -2,7 +2,7 @@ module Planvine
2
2
  class CategoriesBuilder
3
3
  def self.build(category, api)
4
4
  Category.new(
5
- :photo => category["photo"]["url"],
5
+ :photo => (category["photo"] ? category["photo"]["url"] : ''),
6
6
  :slug => category["slug"],
7
7
  :name => category["name"],
8
8
  :id => category["id"],
@@ -17,7 +17,7 @@ module Planvine
17
17
  end
18
18
 
19
19
  def events
20
- self.class.get("/category/#{id}/events?api_key=#{@api_key}")["data"].map do |event|
20
+ api.category_events(id).map do |event|
21
21
  EventsBuilder.build(event)
22
22
  end
23
23
  end
@@ -27,7 +27,7 @@ module Planvine
27
27
  end
28
28
 
29
29
  def photo
30
- @params.fetch(:photo)
30
+ @params.fetch(:photo, nil)
31
31
  end
32
32
 
33
33
  def slug
@@ -2,48 +2,14 @@ module Planvine
2
2
  class EventsBuilder
3
3
  def self.build(event)
4
4
  Event.new(
5
- :end_date => Date.parse(event["end_date"]),
5
+ :end_date => event["end_date"],
6
6
  :title => event["title"],
7
7
  :url => event["url"],
8
- :photo => event["photo"]["url"],
9
- :start_date => Date.parse(event["start_date"]),
8
+ :photo => (event["photo"].nil? ? "" : event["photo"]["url"]),
9
+ :start_date => event["start_date"],
10
10
  :venue => Venue.new(event["venue"]),
11
11
  :id => event["id"]
12
12
  )
13
13
  end
14
14
  end
15
-
16
- class Venue
17
- def initialize(params)
18
- @params = params
19
- end
20
-
21
- def uid
22
- @params.fetch("uid")
23
- end
24
-
25
- def lat
26
- @params.fetch("lat")
27
- end
28
-
29
- def lng
30
- @params.fetch("lng")
31
- end
32
-
33
- def short_address
34
- @params.fetch("short_address")
35
- end
36
-
37
- def short_date
38
- @params.fetch("short_date_string")
39
- end
40
-
41
- def long_date_string
42
- @params.fetch("long_date_string")
43
- end
44
-
45
- def venue_id
46
- @params.fetch("id")
47
- end
48
- end
49
15
  end
@@ -14,9 +14,14 @@ module Planvine
14
14
  end
15
15
 
16
16
  def categories
17
- self.class.get("/category?api_key=#{@api_key}")["data"].map do |category|
17
+ categories = self.class.get("/category?api_key=#{@api_key}")
18
+ JSON.parse(categories)["data"].map do |category|
18
19
  CategoriesBuilder.build(category, self)
19
20
  end
20
21
  end
22
+
23
+ def category_events(id)
24
+ JSON.parse(self.class.get("/category/#{id}/events?api_key=#{@api_key}"))["data"]
25
+ end
21
26
  end
22
27
  end
@@ -0,0 +1,32 @@
1
+ module Planvine
2
+ class Venue
3
+ attr_reader :params
4
+ def initialize(params)
5
+ @params = params
6
+ end
7
+
8
+ def uid
9
+ @params.fetch(:uid, '')
10
+ end
11
+
12
+ def name
13
+ @params.fetch(:name, '')
14
+ end
15
+
16
+ def lat
17
+ @params.fetch(:lat, '')
18
+ end
19
+
20
+ def lng
21
+ @params.fetch(:lng, '')
22
+ end
23
+
24
+ def address
25
+ @params.fetch(:address, '')
26
+ end
27
+
28
+ def short_address
29
+ @params.fetch(:short_address, '')
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Planvine
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/planvine.rb CHANGED
@@ -2,6 +2,7 @@ require 'httparty'
2
2
  require "planvine/version"
3
3
  require "planvine/planvine_api"
4
4
  require "planvine/event"
5
+ require "planvine/venue"
5
6
  require "planvine/builders/events_builder"
6
7
  require "planvine/builders/categories_builder"
7
8
 
data/planvine.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "httparty"
22
+ spec.add_dependency "json"
22
23
  spec.add_development_dependency "bundler", "~> 1.3"
23
24
  spec.add_development_dependency "rake"
24
25
  spec.add_development_dependency "rspec"
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.2
4
+ version: 0.0.3
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-04-25 00:00:00.000000000 Z
11
+ date: 2013-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -97,6 +111,7 @@ files:
97
111
  - lib/planvine/builders/events_builder.rb
98
112
  - lib/planvine/event.rb
99
113
  - lib/planvine/planvine_api.rb
114
+ - lib/planvine/venue.rb
100
115
  - lib/planvine/version.rb
101
116
  - planvine.gemspec
102
117
  - spec/lib/builders/events_builder_spec.rb