planvine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 21f17b61e63b21d5cb61fec2c979fc20de5e665a
4
+ data.tar.gz: 011f2dc5e25309cfc9dde05d83b78e2142a86631
5
+ SHA512:
6
+ metadata.gz: 9ac8523a6efe0c6c0318d3c87b26ec1555538b6c9388a093abe5ceed4e0394aa732812b95c2afaf697e3f2c1df0caf894fa14652fda325530f9e5436a78e4aa4
7
+ data.tar.gz: a458b49002b2b6635c4dfd62903b37207ce1533328d7eb6f07f7568ca7045d5496d969b1ebaecc561f934efc37abd023d6195e19c31c258c8c502aac2ae7ee0b
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in planvine.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Richard Patching
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Planvine
2
+
3
+ Ruby lib that wraps the Planvine API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'planvine'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install planvine
18
+
19
+ ## Usage
20
+
21
+ Return events
22
+
23
+ Planvine.for('My-API-KEY').events
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,45 @@
1
+ module Planvine
2
+ class CategoriesBuilder
3
+ def self.build(category, api)
4
+ Category.new(
5
+ photo: category["photo"]["url"],
6
+ slug: category["slug"],
7
+ name: category["name"],
8
+ id: category["id"],
9
+ api: api
10
+ )
11
+ end
12
+ end
13
+
14
+ class Category
15
+ def initialize(params)
16
+ @params = params
17
+ end
18
+
19
+ def events
20
+ self.class.get("/category/#{id}/events?api_key=#{@api_key}")["data"].map do |event|
21
+ EventsBuilder.build(event)
22
+ end
23
+ end
24
+
25
+ def api
26
+ @params.fetch(:api)
27
+ end
28
+
29
+ def photo
30
+ @params.fetch(:photo)
31
+ end
32
+
33
+ def slug
34
+ @params.fetch(:slug)
35
+ end
36
+
37
+ def name
38
+ @params.fetch(:name)
39
+ end
40
+
41
+ def id
42
+ @params.fetch(:id)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,49 @@
1
+ module Planvine
2
+ class EventsBuilder
3
+ def self.build(event)
4
+ Event.new(
5
+ end_date: Date.parse(event["end_date"]),
6
+ title: event["title"],
7
+ url: event["url"],
8
+ photo: event["photo"]["url"],
9
+ start_date: Date.parse(event["start_date"]),
10
+ venue: Venue.new(event["venue"]),
11
+ id: event["id"]
12
+ )
13
+ end
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
+ end
@@ -0,0 +1,35 @@
1
+ module Planvine
2
+ class Event
3
+ def initialize(params)
4
+ @params = params
5
+ end
6
+
7
+ def venue
8
+ @params.fetch(:venue)
9
+ end
10
+
11
+ def end_date
12
+ @params.fetch(:end_date, '')
13
+ end
14
+
15
+ def title
16
+ @params.fetch(:title, '')
17
+ end
18
+
19
+ def url
20
+ @params.fetch(:url, '')
21
+ end
22
+
23
+ def photo
24
+ @params.fetch(:photo, '')
25
+ end
26
+
27
+ def start_date
28
+ @params.fetch(:start_date, '')
29
+ end
30
+
31
+ def id
32
+ @params.fetch(:id)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ module Planvine
2
+ class PlanvineAPI
3
+ include HTTParty
4
+ base_uri 'http://planvine.com/api/v1'
5
+
6
+ def initialize(api_key)
7
+ @api_key = api_key
8
+ end
9
+
10
+ def events
11
+ self.class.get("/event?api_key=#{@api_key}")["data"].map do |event|
12
+ EventsBuilder.build(event)
13
+ end
14
+ end
15
+
16
+ def categories
17
+ self.class.get("/category?api_key=#{@api_key}")["data"].map do |category|
18
+ CategoriesBuilder.build(category, self)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Planvine
2
+ VERSION = "0.0.1"
3
+ end
data/lib/planvine.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'httparty'
2
+ require "planvine/version"
3
+ require "planvine/planvine_api"
4
+ require "planvine/event"
5
+ require "planvine/builders/events_builder"
6
+ require "planvine/builders/categories_builder"
7
+
8
+ module Planvine
9
+ def self.for(api_key)
10
+ PlanvineAPI.new(api_key)
11
+ end
12
+ end
data/planvine.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'planvine/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "planvine"
8
+ spec.version = Planvine::VERSION
9
+ spec.authors = ["Richard Patching"]
10
+ spec.email = ["richard@justaddpixels.com"]
11
+ spec.description = %q{Ruby lib that wraps the planvine API}
12
+ spec.summary = %q{Ruby lib that wraps the planvine API}
13
+ spec.homepage = "http://github.com/patchfx/planvine"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "httparty"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "pry"
26
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ module Planvine
4
+ describe EventsBuilder do
5
+ let(:params) {
6
+ {
7
+ "end_date" => "2013-03-21T00:00:00",
8
+ "title" => "Kirill Karabits conducts a concert of Russian Music",
9
+ "url" => "http://planvine.com/event/kirill-karabits-conducts-a-concert-of-russian-music",
10
+ "photo" => {
11
+ "url" => "http://s3.amazonaws.com/com.planvine.v4.image/5126b7af-82ae-4c71-8689-2d3f925c7935.png"
12
+ },
13
+ "venue" => {
14
+ "lat" => 51.506405,
15
+ "lng" => -0.116059,
16
+ "uid" => "c8f72081-2e81-11e2-aa7b-123139333993",
17
+ "short_address" => "Southbank Centre",
18
+ "address" => "The South Bank Centre/Belvedere Rd, London, United Kingdom"
19
+ },
20
+ "start_date" => "2013-03-20T00:00:00",
21
+ "id" => "6557"
22
+ }
23
+ }
24
+
25
+ it 'builds events from the json response' do
26
+ EventsBuilder.build(params).should be_an_instance_of(Planvine::Event)
27
+ end
28
+
29
+ it 'builds the venue from the json response' do
30
+ EventsBuilder.build(params).venue.should be_an_instance_of(Planvine::Venue)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Planvine do
4
+ describe '#for' do
5
+ it 'returns a planvine api object' do
6
+ Planvine.for('API-KEY').should be_an_instance_of(Planvine::PlanvineAPI)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+ require 'planvine'
7
+ require 'rspec'
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: planvine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Richard Patching
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Ruby lib that wraps the planvine API
84
+ email:
85
+ - richard@justaddpixels.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/planvine.rb
96
+ - lib/planvine/builders/categories_builder.rb
97
+ - lib/planvine/builders/events_builder.rb
98
+ - lib/planvine/event.rb
99
+ - lib/planvine/planvine_api.rb
100
+ - lib/planvine/version.rb
101
+ - planvine.gemspec
102
+ - spec/lib/builders/events_builder_spec.rb
103
+ - spec/lib/planvine_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: http://github.com/patchfx/planvine
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.0.0
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Ruby lib that wraps the planvine API
129
+ test_files:
130
+ - spec/lib/builders/events_builder_spec.rb
131
+ - spec/lib/planvine_spec.rb
132
+ - spec/spec_helper.rb
133
+ has_rdoc: