chiketto 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/chiketto.gemspec +2 -0
- data/lib/chiketto.rb +6 -0
- data/lib/chiketto/address.rb +15 -0
- data/lib/chiketto/attr_attribute.rb +29 -0
- data/lib/chiketto/attribute.rb +14 -0
- data/lib/chiketto/event.rb +30 -4
- data/lib/chiketto/organizer.rb +7 -0
- data/lib/chiketto/resource.rb +12 -14
- data/lib/chiketto/ticket_class.rb +16 -0
- data/lib/chiketto/venue.rb +11 -0
- data/lib/chiketto/version.rb +1 -1
- data/test/address_test.rb +30 -0
- data/test/attribute_test.rb +30 -0
- data/test/event_test.rb +56 -3
- data/test/organizer_test.rb +23 -0
- data/test/ticket_class_test.rb +38 -0
- data/test/venue_test.rb +33 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1768bc70da3e48380d8910456c5f55fcd9a882c1
|
4
|
+
data.tar.gz: 2f949518b15b4258dee4a863758e58b28b1d304e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31416533b8c8c98c82b2940846037a3fb817378e72f346f35e69962b75d8f1474322704a1c73afc6e31c0ab8abc4fb1040879a33038874e0275be7822503c6bb
|
7
|
+
data.tar.gz: ccb0f0bf3eac15fcbd932b8443bdb95b208b642658791145f97377d4fe12af2dd7c95b0517d656d950297d5c3e33686bd485878bd7f591e2760bc5356006e001
|
data/chiketto.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.required_ruby_version = '>= 1.9.3'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
24
|
spec.add_development_dependency "coveralls"
|
23
25
|
spec.add_development_dependency "codeclimate-test-reporter"
|
data/lib/chiketto.rb
CHANGED
@@ -2,7 +2,13 @@ module Chiketto
|
|
2
2
|
ENDPOINT = 'https://www.eventbriteapi.com/v3/'
|
3
3
|
|
4
4
|
require 'chiketto/version'
|
5
|
+
require 'chiketto/attribute'
|
6
|
+
require 'chiketto/attr_attribute'
|
5
7
|
require 'chiketto/resource'
|
8
|
+
require 'chiketto/address'
|
6
9
|
require 'chiketto/event'
|
10
|
+
require 'chiketto/organizer'
|
11
|
+
require 'chiketto/ticket_class'
|
12
|
+
require 'chiketto/venue'
|
7
13
|
|
8
14
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Chiketto
|
2
|
+
class Address < Resource
|
3
|
+
attr_accessor :city,
|
4
|
+
:country,
|
5
|
+
:region,
|
6
|
+
:address_1,
|
7
|
+
:address_2,
|
8
|
+
:country_name
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
[@address_1, @address_2, @city, @region, @country].
|
12
|
+
reject { |p| p.nil? }.join(', ')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Chiketto
|
2
|
+
module AttrDSL
|
3
|
+
def self.included(base)
|
4
|
+
base.extend DSL
|
5
|
+
end
|
6
|
+
|
7
|
+
module DSL
|
8
|
+
def attr_attrib(*args)
|
9
|
+
args.map do |value|
|
10
|
+
define_method value.to_s do
|
11
|
+
Chiketto::Attribute.new Hash.new(instance_variable_get("@#{value}"))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def attr_date(*args)
|
17
|
+
args.map do |value|
|
18
|
+
define_method value.to_s do
|
19
|
+
date = instance_variable_get("@#{value}")
|
20
|
+
return date if date.nil?
|
21
|
+
|
22
|
+
date = date['utc'] if date.is_a?(Hash)
|
23
|
+
DateTime.strptime date, '%FT%TZ'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/chiketto/event.rb
CHANGED
@@ -1,10 +1,36 @@
|
|
1
1
|
module Chiketto
|
2
2
|
class Event < Resource
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
attr_reader :resource_uri,
|
4
|
+
:url,
|
5
|
+
:capacity,
|
6
|
+
:categories,
|
7
|
+
:status
|
8
|
+
|
9
|
+
attr_attrib :description,
|
10
|
+
:name
|
11
|
+
|
12
|
+
attr_date :start,
|
13
|
+
:end,
|
14
|
+
:created,
|
15
|
+
:changed
|
16
|
+
|
17
|
+
def organizer
|
18
|
+
Chiketto::Organizer.new Hash.new(@organizer)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ticket_classes
|
22
|
+
@ticket_classes.map do |t_class|
|
23
|
+
Chiketto::TicketClass.new Hash.new(t_class)
|
7
24
|
end
|
8
25
|
end
|
26
|
+
|
27
|
+
def venue
|
28
|
+
Chiketto::Venue.new Hash.new(@venue)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.find(id)
|
32
|
+
event = get "events/#{id}"
|
33
|
+
Event.new event
|
34
|
+
end
|
9
35
|
end
|
10
36
|
end
|
data/lib/chiketto/resource.rb
CHANGED
@@ -3,6 +3,8 @@ require 'open-uri'
|
|
3
3
|
|
4
4
|
module Chiketto
|
5
5
|
class Resource
|
6
|
+
include Chiketto::AttrDSL
|
7
|
+
|
6
8
|
attr_reader :id
|
7
9
|
|
8
10
|
def initialize(args)
|
@@ -11,22 +13,18 @@ module Chiketto
|
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
16
|
+
def self.get(uri)
|
17
|
+
uri = endpoint uri
|
18
|
+
resource = open uri
|
19
|
+
JSON.parse resource.read
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def self.endpoint(uri)
|
23
|
+
ENDPOINT + uri + token
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
def self.token
|
27
|
+
"?token=#{ENV['EVENTBRITE_API_TOKEN']}"
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
data/lib/chiketto/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class AddressTest < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@address = Chiketto::Address.new 'city' => 'San Francisco',
|
6
|
+
'country' => 'US',
|
7
|
+
'region' => 'CA',
|
8
|
+
'address_1' => '651 Brannan',
|
9
|
+
'address_2' => 'Suite 110',
|
10
|
+
'country_name' => 'United States'
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_responds_to_methods
|
14
|
+
assert_respond_to @address, :city
|
15
|
+
assert_respond_to @address, :country
|
16
|
+
assert_respond_to @address, :region
|
17
|
+
assert_respond_to @address, :address_1
|
18
|
+
assert_respond_to @address, :address_2
|
19
|
+
assert_respond_to @address, :country_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_responds_to_string_method
|
23
|
+
assert_equal '651 Brannan, Suite 110, San Francisco, CA, US', @address.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_does_not_include_blanks_in_string
|
27
|
+
@address.region = nil
|
28
|
+
assert_equal '651 Brannan, Suite 110, San Francisco, US', @address.to_s
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class AttributeTest < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@attrib = Chiketto::Attribute.new 'text' => 'Test', 'html' => '<p>Test</p>'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_attribute_accepts_and_returns_values
|
9
|
+
assert_respond_to @attrib, :text
|
10
|
+
assert_respond_to @attrib, :html
|
11
|
+
assert_equal 'Test', @attrib.text
|
12
|
+
assert_equal '<p>Test</p>', @attrib.html
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_attribute_responds_to_s
|
16
|
+
assert_respond_to @attrib, :to_s
|
17
|
+
assert_equal 'Test', @attrib.to_s
|
18
|
+
assert_equal 'Test', "#{@attrib}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_html_falls_back_to_text
|
22
|
+
attrib = Chiketto::Attribute.new 'text' => 'Test'
|
23
|
+
assert_equal 'Test', attrib.html
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_text_falls_back_to_empty_string
|
27
|
+
attrib = Chiketto::Attribute.new
|
28
|
+
assert_equal '', attrib.text
|
29
|
+
end
|
30
|
+
end
|
data/test/event_test.rb
CHANGED
@@ -1,10 +1,63 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class EventTest < MiniTest::Test
|
4
|
-
|
4
|
+
TEST_ID = '9203575141'
|
5
|
+
|
6
|
+
def setup
|
5
7
|
VCR.use_cassette 'eventbriteapi' do
|
6
|
-
event = Chiketto::Event.find
|
7
|
-
assert_equal event.id, '9203575141'
|
8
|
+
@event = Chiketto::Event.find TEST_ID
|
8
9
|
end
|
9
10
|
end
|
11
|
+
|
12
|
+
def test_fetching_event
|
13
|
+
assert_kind_of Chiketto::Event, @event
|
14
|
+
assert_equal @event.id, TEST_ID
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_event_exposes_data
|
18
|
+
assert_respond_to @event, :id
|
19
|
+
assert_respond_to @event, :name
|
20
|
+
assert_respond_to @event, :description
|
21
|
+
assert_respond_to @event, :resource_uri
|
22
|
+
assert_respond_to @event, :organizer
|
23
|
+
assert_respond_to @event, :venue
|
24
|
+
assert_respond_to @event, :ticket_classes
|
25
|
+
assert_respond_to @event, :url
|
26
|
+
assert_respond_to @event, :start
|
27
|
+
assert_respond_to @event, :end
|
28
|
+
assert_respond_to @event, :created
|
29
|
+
assert_respond_to @event, :changed
|
30
|
+
assert_respond_to @event, :capacity
|
31
|
+
assert_respond_to @event, :categories
|
32
|
+
assert_respond_to @event, :status
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_name_attribute_is_valid
|
36
|
+
assert_respond_to @event.name, :html
|
37
|
+
assert_respond_to @event.name, :text
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_description_attribute_is_valid
|
41
|
+
assert_respond_to @event.description, :html
|
42
|
+
assert_respond_to @event.description, :text
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_organizer_is_object
|
46
|
+
assert_kind_of Chiketto::Organizer, @event.organizer
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_venue_is_object
|
50
|
+
assert_kind_of Chiketto::Venue, @event.venue
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_ticket_classes_is_object
|
54
|
+
assert_kind_of Chiketto::TicketClass, @event.ticket_classes.first
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_date_attributes
|
58
|
+
assert_kind_of DateTime, @event.end
|
59
|
+
assert_kind_of DateTime, @event.start
|
60
|
+
assert_kind_of DateTime, @event.created
|
61
|
+
assert_kind_of DateTime, @event.changed
|
62
|
+
end
|
10
63
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class OrganizerTest < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@organizer = Chiketto::Organizer.new 'description' => {
|
6
|
+
'text' => 'Description of the Example Organizer',
|
7
|
+
'html' => '<p>Description of the Example Organizer</p>'
|
8
|
+
},
|
9
|
+
'id' => '1667263718',
|
10
|
+
'name' => 'Example Organizer'
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_responds_to_methods
|
14
|
+
assert_respond_to @organizer, :description
|
15
|
+
assert_respond_to @organizer, :id
|
16
|
+
assert_respond_to @organizer, :name
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_description_is_an_attribute
|
20
|
+
assert_respond_to @organizer.description, :html
|
21
|
+
assert_respond_to @organizer.description, :text
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TicketClassTest < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@tclass = Chiketto::TicketClass.new 'id' => '22315349',
|
6
|
+
'name' => 'General Admission',
|
7
|
+
'cost' => nil,
|
8
|
+
'fee' => nil,
|
9
|
+
'currency' => nil,
|
10
|
+
'free' => true,
|
11
|
+
'minimum_quantity' => 1,
|
12
|
+
'maximum_quantity' => nil,
|
13
|
+
'quantity_total' => 19999,
|
14
|
+
'quantity_sold' => 1000,
|
15
|
+
'sales_start' => nil,
|
16
|
+
'sales_end' => '2014-12-01T22:59:59Z'
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_ticket_class_responds_to_methods
|
20
|
+
assert_respond_to @tclass, :id
|
21
|
+
assert_respond_to @tclass, :name
|
22
|
+
assert_respond_to @tclass, :cost
|
23
|
+
assert_respond_to @tclass, :fee
|
24
|
+
assert_respond_to @tclass, :currency
|
25
|
+
assert_respond_to @tclass, :free
|
26
|
+
assert_respond_to @tclass, :minimum_quantity
|
27
|
+
assert_respond_to @tclass, :maximum_quantity
|
28
|
+
assert_respond_to @tclass, :quantity_total
|
29
|
+
assert_respond_to @tclass, :quantity_sold
|
30
|
+
assert_respond_to @tclass, :sales_start
|
31
|
+
assert_respond_to @tclass, :sales_end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_ticket_dates_return_datetime
|
35
|
+
assert_kind_of NilClass, @tclass.sales_start
|
36
|
+
assert_kind_of DateTime, @tclass.sales_end
|
37
|
+
end
|
38
|
+
end
|
data/test/venue_test.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class VenueTest < MiniTest::Test
|
4
|
+
def test_venue_methods_exist
|
5
|
+
@venue = Chiketto::Venue.new 'id' => '545454',
|
6
|
+
'address' => {
|
7
|
+
'city' => 'San Francisco',
|
8
|
+
'country' => 'US',
|
9
|
+
'region' => 'CA',
|
10
|
+
'address_1' => '651 Brannan',
|
11
|
+
'address_2' => 'Suite 110',
|
12
|
+
'country_name' => 'United States'
|
13
|
+
},
|
14
|
+
'latitude' => '42.3618641',
|
15
|
+
'longitude' => '-71.0905626',
|
16
|
+
'name' => 'Eventbrite HQ'
|
17
|
+
|
18
|
+
assert_respond_to @venue, :id
|
19
|
+
assert_respond_to @venue, :address
|
20
|
+
assert_respond_to @venue, :latitude
|
21
|
+
assert_respond_to @venue, :longitude
|
22
|
+
assert_respond_to @venue, :name
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_venue_with_no_address
|
26
|
+
@venue = Chiketto::Venue.new 'id' => '545454',
|
27
|
+
'latitude' => '42.3618641',
|
28
|
+
'longitude' => '-71.0905626',
|
29
|
+
'name' => 'Eventbrite HQ'
|
30
|
+
|
31
|
+
assert_respond_to @venue.address, :to_s
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chiketto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Radford
|
@@ -137,12 +137,23 @@ files:
|
|
137
137
|
- Rakefile
|
138
138
|
- chiketto.gemspec
|
139
139
|
- lib/chiketto.rb
|
140
|
+
- lib/chiketto/address.rb
|
141
|
+
- lib/chiketto/attr_attribute.rb
|
142
|
+
- lib/chiketto/attribute.rb
|
140
143
|
- lib/chiketto/event.rb
|
144
|
+
- lib/chiketto/organizer.rb
|
141
145
|
- lib/chiketto/resource.rb
|
146
|
+
- lib/chiketto/ticket_class.rb
|
147
|
+
- lib/chiketto/venue.rb
|
142
148
|
- lib/chiketto/version.rb
|
149
|
+
- test/address_test.rb
|
150
|
+
- test/attribute_test.rb
|
143
151
|
- test/chiketto_test.rb
|
144
152
|
- test/event_test.rb
|
153
|
+
- test/organizer_test.rb
|
145
154
|
- test/test_helper.rb
|
155
|
+
- test/ticket_class_test.rb
|
156
|
+
- test/venue_test.rb
|
146
157
|
homepage: https://github.com/chrisradford/chiketto
|
147
158
|
licenses:
|
148
159
|
- MIT
|
@@ -155,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
166
|
requirements:
|
156
167
|
- - ">="
|
157
168
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
169
|
+
version: 1.9.3
|
159
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
171
|
requirements:
|
161
172
|
- - ">="
|
@@ -168,6 +179,11 @@ signing_key:
|
|
168
179
|
specification_version: 4
|
169
180
|
summary: Chiketto is a ruby gem for interacting with the Eventbrite V3 API
|
170
181
|
test_files:
|
182
|
+
- test/address_test.rb
|
183
|
+
- test/attribute_test.rb
|
171
184
|
- test/chiketto_test.rb
|
172
185
|
- test/event_test.rb
|
186
|
+
- test/organizer_test.rb
|
173
187
|
- test/test_helper.rb
|
188
|
+
- test/ticket_class_test.rb
|
189
|
+
- test/venue_test.rb
|