camdram 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/camdram/client.rb +24 -0
- data/lib/camdram/diary.rb +28 -0
- data/lib/camdram/event.rb +36 -0
- data/lib/camdram/version.rb +1 -1
- data/test/diary_tests.rb +38 -0
- data/test/user_tests.rb +10 -9
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cca1db57085086273a264020e522c5bce72095f0dbc1ffd903b90fb5596d51f
|
4
|
+
data.tar.gz: e16efd9e4684a2e8fd2640c9352550319edd1058298ebdd90bd312e3e7a4e8ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e479b753fc8f809143340414959c4d8378a509b3c9ea8267afa8bd17dd4ae9346de1e03b9d210b4522ae871a533f2c6f525f08c834da1f454a949961ac0a846
|
7
|
+
data.tar.gz: d9407c4319165ce7a71218e0e6482993de99f083978af6ac0cdbea62df21e437be474ddbef21b0969323ed6a6fb268048f27d1b752ad2e7c7dec5ed163c4c857
|
data/README.md
CHANGED
@@ -25,8 +25,12 @@ client.user.get_shows
|
|
25
25
|
client.user.get_shows[0].society
|
26
26
|
client.user.get_shows[0].venue
|
27
27
|
client.user.get_shows[0].performances
|
28
|
+
client.user.get_orgs
|
28
29
|
client.user.get_orgs[0].name
|
29
30
|
client.user.get_orgs[0].twitter_id
|
31
|
+
client.user.get_venues
|
32
|
+
client.user.get_venues[0].slug
|
33
|
+
client.user.get_venues[0].facebook_id
|
30
34
|
```
|
31
35
|
|
32
36
|
These public actions don't require an API key (although you are still strongly advised to use one anyway):
|
@@ -59,7 +63,7 @@ As a result of this policy, you can (and should) specify a dependency on this ge
|
|
59
63
|
[Pessimistic Version Constraint](http://guides.rubygems.org/patterns/#pessimistic-version-constraint) with two digits of precision.
|
60
64
|
For example:
|
61
65
|
```ruby
|
62
|
-
spec.add_runtime_dependency 'camdram', '~> 1.
|
66
|
+
spec.add_runtime_dependency 'camdram', '~> 1.1'
|
63
67
|
```
|
64
68
|
|
65
69
|
## Copyright
|
data/lib/camdram/client.rb
CHANGED
@@ -8,6 +8,7 @@ require 'camdram/venue'
|
|
8
8
|
require 'camdram/person'
|
9
9
|
require 'camdram/role'
|
10
10
|
require 'camdram/search'
|
11
|
+
require 'camdram/diary'
|
11
12
|
|
12
13
|
module Camdram
|
13
14
|
class Client
|
@@ -193,6 +194,29 @@ module Camdram
|
|
193
194
|
split_object( response, Search )
|
194
195
|
end
|
195
196
|
|
197
|
+
# Gets a diary object which contains an array of upcoming calendar events
|
198
|
+
#
|
199
|
+
# @return [Camdram::Diary] A Diary object.
|
200
|
+
def diary(start_date=nil, end_date=nil)
|
201
|
+
url = "/diary.json"
|
202
|
+
if start_date && end_date
|
203
|
+
url = "/diary/#{start_date}.json?end=#{end_date}"
|
204
|
+
end
|
205
|
+
response = get(url)
|
206
|
+
Diary.new(response)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Gets a diary object which contains an array of events occuring in the given year/term
|
210
|
+
#
|
211
|
+
# @return [Camdram::Diary] A Diary object.
|
212
|
+
def termly_diary(year, term=nil)
|
213
|
+
url = "/diary/#{year}"
|
214
|
+
url << "/#{term}" if term
|
215
|
+
url << ".json"
|
216
|
+
response = get(url)
|
217
|
+
Diary.new(response)
|
218
|
+
end
|
219
|
+
|
196
220
|
# Returns the program version that is currently running
|
197
221
|
#
|
198
222
|
# @return [String] The version of camdram-ruby that is currently running.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'camdram/base'
|
2
|
+
require 'camdram/api'
|
3
|
+
require 'camdram/event'
|
4
|
+
|
5
|
+
module Camdram
|
6
|
+
class Diary < Base
|
7
|
+
include API
|
8
|
+
attr_accessor :events
|
9
|
+
|
10
|
+
# Instantiate a new Diary object from a JSON hash
|
11
|
+
#
|
12
|
+
# @param options [Hash] A single JSON hash with symbolized keys.
|
13
|
+
# @return [Camdram::Event] The new Diary object.
|
14
|
+
def initialize(options = {})
|
15
|
+
super(options)
|
16
|
+
@events = split_object( @events, Event ) unless @events.nil?
|
17
|
+
end
|
18
|
+
|
19
|
+
# Return a hash of the diary's attributes
|
20
|
+
#
|
21
|
+
# @return [Hash] Hash with symbolized keys.
|
22
|
+
def info
|
23
|
+
{
|
24
|
+
events: events,
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'camdram/base'
|
2
|
+
require 'camdram/api'
|
3
|
+
require 'camdram/show'
|
4
|
+
require 'camdram/venue'
|
5
|
+
|
6
|
+
module Camdram
|
7
|
+
class Event < Base
|
8
|
+
include API
|
9
|
+
attr_accessor :id, :start_date, :end_date, :time, :other_venue, :show, :venue
|
10
|
+
|
11
|
+
# Instantiate a new Event object from a JSON hash
|
12
|
+
#
|
13
|
+
# @param options [Hash] A single JSON hash with symbolized keys.
|
14
|
+
# @return [Camdram::Event] The new Event object.
|
15
|
+
def initialize(options = {})
|
16
|
+
super(options)
|
17
|
+
@show = Show.new( @show ) unless @show.nil?
|
18
|
+
@venue = Venue.new( @venue ) unless @venue.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
# Return a hash of the image's attributes
|
22
|
+
#
|
23
|
+
# @return [Hash] Hash with symbolized keys.
|
24
|
+
def info
|
25
|
+
{
|
26
|
+
id: id,
|
27
|
+
start_date: start_date,
|
28
|
+
end_date: end_date,
|
29
|
+
time: time,
|
30
|
+
other_venue: other_venue,
|
31
|
+
show: show,
|
32
|
+
venue: venue,
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/camdram/version.rb
CHANGED
data/test/diary_tests.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ClientTests < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
# There is some real magic going on here. Not really sure why
|
6
|
+
# some of the shows have start dates of -0001. There is a
|
7
|
+
# special place reserved in hell for the data returned by the
|
8
|
+
# Camdram API.
|
9
|
+
|
10
|
+
def test_diary
|
11
|
+
diary = @client.diary("2005-01-01", "2005-01-02")
|
12
|
+
events = diary.events
|
13
|
+
assert_equal 6503, events.first.id
|
14
|
+
assert_equal 1840, events.first.show.id
|
15
|
+
assert_equal "ADC Theatre", events.first.venue.name
|
16
|
+
assert_equal 6577, events[2].id
|
17
|
+
assert_equal "1970-01-01T19:30:00+00:00", events[2].time
|
18
|
+
assert_equal 3899, events[2].show.id
|
19
|
+
assert_equal 90, events[2].venue.id
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_termly_diary
|
23
|
+
diary = @client.termly_diary("2001", "summer-vacation")
|
24
|
+
events = diary.events
|
25
|
+
assert_equal 6455, events[0].id
|
26
|
+
assert_equal "2003-12-06T00:00:00+00:00", events[0].end_date
|
27
|
+
assert_equal 10, events[0].show.id
|
28
|
+
assert_equal "Alice in Wonderland", events[0].show.name
|
29
|
+
assert_equal 29, events[0].venue.id
|
30
|
+
assert_equal "ADC Theatre", events[0].venue.name
|
31
|
+
assert_equal 6503, events[1].id
|
32
|
+
assert_equal "2008-12-06T00:00:00+00:00", events[1].end_date
|
33
|
+
assert_equal 1840, events[1].show.id
|
34
|
+
assert_equal "Theseus and the Minotaur: ADC/Footlights Panto 2008", events[1].show.name
|
35
|
+
assert_equal 29, events[1].venue.id
|
36
|
+
assert_equal "ADC Theatre", events[1].venue.name
|
37
|
+
end
|
38
|
+
end
|
data/test/user_tests.rb
CHANGED
@@ -35,13 +35,14 @@ class ClientTests < MiniTest::Unit::TestCase
|
|
35
35
|
assert_equal "1002481303", org.twitter_id
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
# This test requires being added as an ADC venue administrator on Camdram
|
39
|
+
# def test_user_venues
|
40
|
+
# venue = @client.user.get_venues.first
|
41
|
+
# assert_equal 29, venue.id
|
42
|
+
# assert_equal "ADC Theatre", venue.name
|
43
|
+
# assert_equal "ADC Theatre", venue.short_name
|
44
|
+
# assert_equal "adc-theatre", venue.slug
|
45
|
+
# assert_equal "33348320992", venue.facebook_id
|
46
|
+
# assert_equal "36725639", venue.twitter_id
|
47
|
+
# end
|
47
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camdram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Jonas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -86,7 +86,9 @@ files:
|
|
86
86
|
- lib/camdram/api.rb
|
87
87
|
- lib/camdram/base.rb
|
88
88
|
- lib/camdram/client.rb
|
89
|
+
- lib/camdram/diary.rb
|
89
90
|
- lib/camdram/error.rb
|
91
|
+
- lib/camdram/event.rb
|
90
92
|
- lib/camdram/http.rb
|
91
93
|
- lib/camdram/image.rb
|
92
94
|
- lib/camdram/news.rb
|
@@ -100,6 +102,7 @@ files:
|
|
100
102
|
- lib/camdram/venue.rb
|
101
103
|
- lib/camdram/version.rb
|
102
104
|
- test/client_tests.rb
|
105
|
+
- test/diary_tests.rb
|
103
106
|
- test/search_tests.rb
|
104
107
|
- test/test_helper.rb
|
105
108
|
- test/user_tests.rb
|
@@ -129,6 +132,7 @@ specification_version: 4
|
|
129
132
|
summary: A lovely API wrapper for Camdram written in Ruby
|
130
133
|
test_files:
|
131
134
|
- test/client_tests.rb
|
135
|
+
- test/diary_tests.rb
|
132
136
|
- test/search_tests.rb
|
133
137
|
- test/test_helper.rb
|
134
138
|
- test/user_tests.rb
|