-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
137 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'camdram/base' | ||
require 'camdram/api' | ||
require 'camdram/event' | ||
|
||
module Camdram | ||
class Diary < Base | ||
include API | ||
attr_accessor :events | ||
|
||
# Instantiate a new Diary object from a JSON hash | ||
# | ||
# @param options [Hash] A single JSON hash with symbolized keys. | ||
# @return [Camdram::Event] The new Diary object. | ||
def initialize(options = {}) | ||
super(options) | ||
@events = split_object( @events, Event ) unless @events.nil? | ||
end | ||
|
||
# Return a hash of the diary's attributes | ||
# | ||
# @return [Hash] Hash with symbolized keys. | ||
def info | ||
{ | ||
events: events, | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'camdram/base' | ||
require 'camdram/api' | ||
require 'camdram/show' | ||
require 'camdram/venue' | ||
|
||
module Camdram | ||
class Event < Base | ||
include API | ||
attr_accessor :id, :start_date, :end_date, :time, :other_venue, :show, :venue | ||
|
||
# Instantiate a new Event object from a JSON hash | ||
# | ||
# @param options [Hash] A single JSON hash with symbolized keys. | ||
# @return [Camdram::Event] The new Event object. | ||
def initialize(options = {}) | ||
super(options) | ||
@show = Show.new( @show ) unless @show.nil? | ||
@venue = Venue.new( @venue ) unless @venue.nil? | ||
end | ||
|
||
# Return a hash of the image's attributes | ||
# | ||
# @return [Hash] Hash with symbolized keys. | ||
def info | ||
{ | ||
id: id, | ||
start_date: start_date, | ||
end_date: end_date, | ||
time: time, | ||
other_venue: other_venue, | ||
show: show, | ||
venue: venue, | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Camdram | ||
VERSION = '1.1.0' | ||
VERSION = '1.2.0' | ||
BASE_URL = 'https://www.camdram.net' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'test_helper' | ||
|
||
class ClientTests < MiniTest::Unit::TestCase | ||
|
||
# There is some real magic going on here. Not really sure why | ||
# some of the shows have start dates of -0001. There is a | ||
# special place reserved in hell for the data returned by the | ||
# Camdram API. | ||
|
||
def test_diary | ||
diary = @client.diary("2005-01-01", "2005-01-02") | ||
events = diary.events | ||
assert_equal 6503, events.first.id | ||
assert_equal 1840, events.first.show.id | ||
assert_equal "ADC Theatre", events.first.venue.name | ||
assert_equal 6577, events[2].id | ||
assert_equal "1970-01-01T19:30:00+00:00", events[2].time | ||
assert_equal 3899, events[2].show.id | ||
assert_equal 90, events[2].venue.id | ||
end | ||
|
||
def test_termly_diary | ||
diary = @client.termly_diary("2001", "summer-vacation") | ||
events = diary.events | ||
assert_equal 6455, events[0].id | ||
assert_equal "2003-12-06T00:00:00+00:00", events[0].end_date | ||
assert_equal 10, events[0].show.id | ||
assert_equal "Alice in Wonderland", events[0].show.name | ||
assert_equal 29, events[0].venue.id | ||
assert_equal "ADC Theatre", events[0].venue.name | ||
assert_equal 6503, events[1].id | ||
assert_equal "2008-12-06T00:00:00+00:00", events[1].end_date | ||
assert_equal 1840, events[1].show.id | ||
assert_equal "Theseus and the Minotaur: ADC/Footlights Panto 2008", events[1].show.name | ||
assert_equal 29, events[1].venue.id | ||
assert_equal "ADC Theatre", events[1].venue.name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters