riksteatern 0.0.1

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.
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'venue/address'
4
+ require_relative 'venue/location'
5
+ require_relative 'venue/accessibility'
6
+
7
+ module Riksteatern
8
+ class Venue
9
+ class << self
10
+ def find(id)
11
+ data = get_data(venueId: id)
12
+ new(data.first) if data.any?
13
+ end
14
+
15
+ def all(params = {})
16
+ get_data(params).map { |c| new(c) }
17
+ end
18
+
19
+ alias :query :all
20
+
21
+ def get_data(params = {})
22
+ Riksteatern.api.locations(params)
23
+ end
24
+ end
25
+
26
+ attr_reader :api_url, :id, :name, :type_id, :type, :number_of_seats,
27
+ :stage_width, :stage_depth, :stage_opening, :acting_depth,
28
+ :stage_min_height, :homepage, :phone_numbers,
29
+ :address, :location, :accessibility
30
+
31
+ def initialize(data)
32
+ @data = data.tap do |d|
33
+ i = d['venueInformation'] || {}
34
+ v = d['venueDescription'] || {}
35
+
36
+ @api_url = d['venueUrl']
37
+ @name = d['venueName']
38
+
39
+ @type_id = v['venueTypeId']
40
+ @type = v['venueType']
41
+ @number_of_seats = v['numberOfSeats']
42
+ @stage_width = v['stageWidth']
43
+ @stage_depth = v['stageDepth']
44
+ @stage_opening = v['stageOpening']
45
+ @acting_depth = v['actingDepth']
46
+ @stage_min_height = v['stageMinHeight']
47
+
48
+ @homepage = i['homepage']
49
+ @phone_numbers = i['phoneNumber']
50
+
51
+ @address = Address.new(i['address'])
52
+ @location = Location.new(i['location'])
53
+ @accessibility = Accessibility.new(i['accesibility'])
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ module Riksteatern
4
+ class Venue
5
+ class Accessibility
6
+ attr_reader :wheelchair_seats_in_salon, :wheelchair_seats_placement,
7
+ :rwc_audience, :rwc_participants, :disabled_parking,
8
+ :entrance_foyer_accessibility_adapted, :comments,
9
+ :hearing_loop_in_salon, :hearing_loop_control_date,
10
+ :hearing_loop_on_stage,
11
+ :accessibility_to_stage_for_wheelchair
12
+
13
+
14
+ def initialize(data)
15
+ @wheelchair_seats_in_salon = data['wheelchairSeatsInSalon']
16
+ @wheelchair_seats_placement = data['wheelchairSeatsPlacement']
17
+
18
+ @rwc_audience = data['rwcAudience']
19
+ @rwc_participants = data['rwcParticipants']
20
+
21
+ @hearing_loop_in_salon = data['hearingLoopInSalon']
22
+ @hearing_loop_control_date = data['hearingLoopControlDate']
23
+ @hearing_loop_on_stage = data['hearingLoopOnStage']
24
+
25
+ @disabled_parking = data['disabledParking']
26
+ @entrance_foyer_accessibility_adapted = data['entranceFoyerAccesibilityAdapted']
27
+ @accessibility_to_stage_for_wheelchair = data['accessibilityToStageForWheelchair']
28
+
29
+ @comments = data['commentsAccessibility']
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ module Riksteatern
4
+ class Venue
5
+ class Address
6
+ attr_reader :address1, :address2, :postal_code, :postal_city, :country_code
7
+
8
+ def initialize(data)
9
+ @address1 = data['address1']
10
+ @address2 = data['address2']
11
+ @postal_code = data['postalCode']
12
+ @postal_city = data['postalCity']
13
+ @country_code = data['countryCode']
14
+ end
15
+
16
+ def to_s
17
+ [
18
+ address1,
19
+ address2,
20
+ postal_code,
21
+ postal_city,
22
+ country_code
23
+ ].compact.join("\n")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ module Riksteatern
4
+ class Venue
5
+ class Location
6
+ attr_reader :region, :municipality, :latitude, :longitude
7
+
8
+ def initialize(data)
9
+ pos = data.fetch('geoPosition', {}).fetch('geoPositionShipping', {})
10
+
11
+ @region = data['regionName']
12
+ @municipality = data['municipalityName']
13
+ @latitude = pos['lat']
14
+ @longitude = pos['lon']
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module Riksteatern
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'riksteatern/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "riksteatern"
9
+ spec.version = Riksteatern::VERSION
10
+ spec.authors = ["Peter Hellberg"]
11
+ spec.email = ["peter@c7.se"]
12
+ spec.summary = %q{Ruby client for the Riksteatern API}
13
+ spec.homepage = "https://github.com/peterhellberg/riksteatern"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.test_files = spec.files.grep(%r{^spec/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "minitest"
23
+ end
@@ -0,0 +1,54 @@
1
+ {
2
+ "venueUrl" : "https://riksteatern.se:8181/api/lokal.json/0180126",
3
+ "venueName" : "Finlandsinstitutet, Sibeliussalen",
4
+ "venueInformation" : {
5
+ "homepage" : "www.finlansinstitutet.se",
6
+ "address" : {
7
+ "address1" : "Snickarbacken 2-4",
8
+ "address2" : " ",
9
+ "postalCode" : null,
10
+ "postalCity" : null,
11
+ "countryCode" : null
12
+ },
13
+ "location" : {
14
+ "regionName" : "Stockholms län",
15
+ "municipalityName" : "Stockholm",
16
+ "geoPosition" : {
17
+ "geoPositionShipping" : {
18
+ "lat" : "59.3380803",
19
+ "lon" : "18.0684012"
20
+ }
21
+ }
22
+ },
23
+ "phoneNumber" : [ {
24
+ "type" : "phone",
25
+ "number" : "08-54521200"
26
+ }, {
27
+ "type" : "fax",
28
+ "number" : "08-54521210"
29
+ } ],
30
+ "accesibility" : {
31
+ "wheelchairSeatsInSalon" : " ",
32
+ "wheelchairSeatsPlacement" : " ",
33
+ "rwcAudience" : " ",
34
+ "disabledParking" : "Svårtillgänglig pga. parkering",
35
+ "entranceFoyerAccesibilityAdapted" : " ",
36
+ "hearingLoopInSalon" : " ",
37
+ "hearingLoopControlDate" : " ",
38
+ "hearingLoopOnStage" : " ",
39
+ "accessibilityToStageForWheelchair" : " ",
40
+ "rwcParticipants" : " ",
41
+ "commentsAccessibility" : " "
42
+ }
43
+ },
44
+ "venueDescription" : {
45
+ "venueTypeId" : 2,
46
+ "venueType" : "Sal",
47
+ "numberOfSeats" : 200,
48
+ "stageWidth" : 0,
49
+ "stageDepth" : 0,
50
+ "stageOpening" : null,
51
+ "actingDepth" : 0,
52
+ "stageMinHeight" : 0
53
+ }
54
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "venueUrl" : "https://riksteatern.se:8181/api/lokal.json/5015846",
3
+ "venueName" : "Folkets Hus, Idun",
4
+ "venueInformation" : {
5
+ "homepage" : "www.hallundafolketshus.se",
6
+ "address" : {
7
+ "address1" : "Folkets Hus",
8
+ "address2" : "Box 134, Borgvägen 1",
9
+ "postalCode" : null,
10
+ "postalCity" : null,
11
+ "countryCode" : null
12
+ },
13
+ "location" : {
14
+ "regionName" : "Stockholms län",
15
+ "municipalityName" : "Botkyrka",
16
+ "geoPosition" : {
17
+ "geoPositionShipping" : {
18
+ "lat" : "59.25",
19
+ "lon" : "17.783333"
20
+ }
21
+ }
22
+ },
23
+ "phoneNumber" : [ {
24
+ "type" : "phone",
25
+ "number" : "08/53062570"
26
+ }, {
27
+ "type" : "fax",
28
+ "number" : " "
29
+ } ],
30
+ "accesibility" : {
31
+ "wheelchairSeatsInSalon" : "Ja 2st vi biovisning ",
32
+ "wheelchairSeatsPlacement" : " ",
33
+ "rwcAudience" : "Ja",
34
+ "disabledParking" : "Ja",
35
+ "entranceFoyerAccesibilityAdapted" : "Ja",
36
+ "hearingLoopInSalon" : "Ja",
37
+ "hearingLoopControlDate" : "2011-10-01",
38
+ "hearingLoopOnStage" : "Ja",
39
+ "accessibilityToStageForWheelchair" : "Nej",
40
+ "rwcParticipants" : "Nej",
41
+ "commentsAccessibility" : "Med läktaren inne så är scenen tillgänglig för rullstolar."
42
+ }
43
+ },
44
+ "venueDescription" : {
45
+ "venueTypeId" : 2,
46
+ "venueType" : "Sal",
47
+ "numberOfSeats" : 135,
48
+ "stageWidth" : 8000,
49
+ "stageDepth" : 9000,
50
+ "stageOpening" : null,
51
+ "actingDepth" : 3000,
52
+ "stageMinHeight" : 5000
53
+ }
54
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "productionUrl" : "https://riksteatern.se:8181/api/produktion.json/1674",
3
+ "productionInformation" : {
4
+ "productionName" : "Wishing Well",
5
+ "productionIntroText" : "Wishing Well - en hyllning till de egna önskningarna och drömmarna!\n",
6
+ "productionDescription" : "Önskebrunnarnas magiska krafter har varit omtalade långt tillbaka genom historien. De har använts både för utövande av magi, förbannelser, ritualer, healing, spådomskonst men framför allt har de använts till att uppfylla önskningar.\nI fontäner världen över ligger inte bara mynt utan också miljontals människors drömmar och förhoppningar. Vilka döljer sig under ytan i stadens egna fontän? Vilka vill du lägga däri?\n\nWishing Well är en performanceritual som utförs om morgonen kl 07.00.\nGör din dag till en lyckodag. Det enda du behöver är ett mynt!",
7
+ "productionHomepage" : null,
8
+ "participants" : "Sofia Breimo\nJohannes Blomqvist\nLokal cellist",
9
+ "numberOfParticipants" : 3,
10
+ "performanceLengthHrs" : null,
11
+ "performanceLengthMns" : 45,
12
+ "pause" : null,
13
+ "category" : [ "Alternativa spelplatser", "Teater", "Musik", "Ny scenkonst", "Performance", "Familje-föreställning" ],
14
+ "productionPictures" : [ "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/j.JPG", "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/dd.JPG", "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/kk.jpg", "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/e.JPG", "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/11.JPG", "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/3.. Wishing Well", "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/2011", "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/performance", "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_production_big/Olohuone.JPG" ],
15
+ "firstPerformanceLocation" : null,
16
+ "firstPerformanceDate" : null,
17
+ "premiereLocation" : "Åbo",
18
+ "premiereDate" : "2011-06-06",
19
+ "newPremiereLoction" : null,
20
+ "newPremiereDate" : null
21
+ },
22
+ "producerInformation" : {
23
+ "producerId" : 796,
24
+ "producerName" : "Sofia Breimo",
25
+ "mainContactId" : null,
26
+ "producerHomepage" : "http://www.sofiabreimo.com",
27
+ "producerLogotype" : "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_producer_big/Fjällnära.jpg"
28
+ }
29
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "productionUrl" : "https://riksteatern.se:8181/api/produktion.json/314",
3
+ "productionInformation" : {
4
+ "productionName" : "Kan man älska en hamster?",
5
+ "productionIntroText" : "Ett kärlekslabratorium som vänder och vrider på kärleken. Kärleken till mormor, IdolOlle, spagetti och köttfärssås, bästisen eller sin alldeles egna hamster!",
6
+ "productionDescription" : "Kan man älska en hamster? – är en lustfylld och lekfull föreställning om kärlek som bygger på text, rörelse och interaktivitet. Vad är kärlek egentligen? Vad händer i kroppen och hur känns det? Kan kärleken till min hamster vara lika stor som den till mamma och pappa eller lillebror? Vad händer med omvärlden när man blir kär? Förändras färgerna och lukterna, smakar pappas fiskpinnar godare? Aldrig är skillnaderna i mognad så stora som i mellanstadiet. Vissa har redan provat att kyssas medan andra fortfarande bygger med lego. Det är en ålder med stora dramatiska känslor och vännerna är det viktigaste på jorden. \r\n\r\nKan man älska en hamster? vänder och vrider på kärleken i ett vidare begrepp än den kärlek som gör dig kär. Kärleken till mormor, IdolOlle, spagetti och köttfärssås, bästisen eller sin alldeles egna hamster!",
7
+ "productionHomepage" : "www.tagegranit.se",
8
+ "participants" : "Manus & regi: Susanne Lindberg. \r\nSkådespelare: Ulrika Lindberg, Hanna Nyroos, Josef Säterhagen\r\nKoreograf: Maria Rimshult. Scenograf: Lina Serning. Dramapedagog: Ewa Lindberg. \r\nProducent: Anna Marking\r\n",
9
+ "numberOfParticipants" : 3,
10
+ "performanceLengthHrs" : 1,
11
+ "performanceLengthMns" : null,
12
+ "pause" : "0",
13
+ "category" : [ "Barn/Skola", "Teater", "Workshops/kurser" ],
14
+ "productionPictures" : [ ],
15
+ "firstPerformanceLocation" : "Teater Pero",
16
+ "firstPerformanceDate" : "2011-10-28",
17
+ "premiereLocation" : "Teater Pero",
18
+ "premiereDate" : "2011-10-28",
19
+ "newPremiereLoction" : null,
20
+ "newPremiereDate" : null
21
+ },
22
+ "producerInformation" : {
23
+ "producerId" : 214,
24
+ "producerName" : "Tage Granit",
25
+ "mainContactId" : null,
26
+ "producerHomepage" : "http://www.tagegranit.se",
27
+ "producerLogotype" : "http://scenkonstportalen.riksteatern.se/sites/default/files/uploaded_files/size_producer_big/litenlogga.jpg"
28
+ }
29
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "eventUrl" : "https://riksteatern.se:8181/api/repertoar.json/992308",
3
+ "arrangerId" : "222",
4
+ "arrangerName" : "",
5
+ "eventInformation" : {
6
+ "eventName" : "Under hatten",
7
+ "eventMetaDescription" : "En dansföreställning med dockor. Ur Erik Saties musik växer det fram poetiska bilder som ett drömspel eller kanske kompositörens tankar och visioner. Under hatten är en föreställning utan ord, där musiken och det visuella får tala.",
8
+ "informationLink" : "",
9
+ "venueUrl" : "https://riksteatern.se:8181/api/lokal.json/5015846",
10
+ "venueName" : "Folkets Hus, Idun",
11
+ "regionName" : "Stockholms län",
12
+ "municipalityName" : "Botkyrka",
13
+ "eventDate" : "2013-03-16",
14
+ "eventTime" : "15:00:00",
15
+ "ticketInformation" : "Biljetter för 40 kr/styck kan beställas på tfn 08-531 \r\n996 40.\r\nÖverblivna biljetter säljs 15 min före föreställningens \r\nbörjan.",
16
+ "ticketInformationScenpass" : "",
17
+ "scenpassBenefit" : false,
18
+ "ticketInformationOnline" : "",
19
+ "publicShow" : true,
20
+ "coProducer" : "ABF Botkyrka-Salem",
21
+ "cancelledEvent" : false
22
+ }
23
+ }
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ describe "Api" do
6
+ subject { Riksteatern::Api.new(config) }
7
+
8
+ let(:config) {
9
+ Riksteatern::Config.new.tap do |c|
10
+ c.base_url = base_url
11
+ c.http_client = BounceURI
12
+
13
+ c.username = 'foo'
14
+ c.password = 'bar'
15
+ end
16
+ }
17
+
18
+ let(:base_url) { 'https://api.test:1234/api' }
19
+
20
+ describe "get" do
21
+ it "should raise an exception if the username is blank" do
22
+ config.username = nil
23
+
24
+ -> { Riksteatern::Api.new(config).get('foo') }.
25
+ must_raise Riksteatern::UnauthorizedUser
26
+ end
27
+ end
28
+
29
+ describe "get_json" do
30
+ it "returns parsed JSON" do
31
+ expected_venue_name = 'Finlandsinstitutet, Sibeliussalen'
32
+
33
+ subject.stub(:http_get, fixture('lokal/0180126')) do
34
+ subject.get_json(:lokal)['venueName'].must_equal expected_venue_name
35
+ end
36
+ end
37
+
38
+ it "loads a blank JSON document if the GET request returns nil" do
39
+ subject.stub(:get, nil) do
40
+ subject.get_json(:unknown).must_equal({})
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ describe "Config" do
6
+ subject {
7
+ Riksteatern::Config.new do |c|
8
+ c.base_url = base_url
9
+ c.username = 'foo@site.com'
10
+ c.password = 'bar'
11
+ end
12
+ }
13
+
14
+ let(:base_url) { 'https://base.url/api' }
15
+
16
+ it "returns the base_url" do
17
+ subject.base_url.must_equal base_url
18
+ end
19
+
20
+ describe "json_parser" do
21
+ it "is a lambda by default" do
22
+ subject.json_parser.
23
+ call('{"foo":123}')['foo'].must_equal 123
24
+ end
25
+
26
+ it "can be changed" do
27
+ subject.json_parser = "foo"
28
+ subject.json_parser.must_equal "foo"
29
+ end
30
+ end
31
+
32
+ describe "http_client" do
33
+ it "is Net::HTTP by default" do
34
+ subject.http_client.must_equal Riksteatern::HTTP
35
+ end
36
+
37
+ it "can be changed" do
38
+ subject.http_client = "bar"
39
+ subject.http_client.must_equal "bar"
40
+ end
41
+ end
42
+ end