odeon_uk 4.0.1 → 5.1.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 +5 -5
- data/.github/workflows/release.yml +73 -0
- data/.github/workflows/test.yml +43 -0
- data/.gitignore +1 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +36 -0
- data/README.md +100 -21
- data/Rakefile +14 -15
- data/lib/odeon_uk/cinema.rb +40 -22
- data/lib/odeon_uk/internal/api_response.rb +19 -39
- data/lib/odeon_uk/internal/guest_token.rb +23 -0
- data/lib/odeon_uk/internal/parser/api/showtime.rb +81 -0
- data/lib/odeon_uk/internal/title_sanitizer.rb +3 -8
- data/lib/odeon_uk/performance.rb +34 -41
- data/lib/odeon_uk/version.rb +3 -3
- data/lib/odeon_uk.rb +16 -2
- data/odeon_uk.gemspec +10 -6
- data/test/fixtures/api/showtimes-824.json +66 -0
- data/test/fixtures/api/sites.json +32 -0
- data/test/lib/odeon_uk/cinema_test.rb +66 -215
- data/test/lib/odeon_uk/internal/api_response_test.rb +48 -29
- data/test/lib/odeon_uk/internal/fixture_shape_test.rb +14 -0
- data/test/lib/odeon_uk/internal/guest_token_test.rb +84 -0
- data/test/lib/odeon_uk/internal/parser/api/showtime_test.rb +77 -0
- data/test/lib/odeon_uk/internal/title_sanitizer_test.rb +109 -89
- data/test/lib/odeon_uk/performance_test.rb +129 -146
- data/test/lib/odeon_uk/version_test.rb +3 -3
- data/test/live/api_shape_test.rb +19 -0
- data/test/live/integration_test.rb +21 -0
- data/test/live/live_helper.rb +11 -0
- data/test/package_test.rb +56 -0
- data/test/support/api_fixtures_helper.rb +5 -30
- data/test/support/api_shapes.rb +46 -0
- data/test/support/fake_api_response.rb +9 -6
- data/test/test_helper.rb +6 -3
- metadata +67 -89
- data/.travis.yml +0 -7
- data/lib/odeon_uk/internal/parser/api/film_lookup.rb +0 -34
- data/lib/odeon_uk/internal/parser/api/performance_day.rb +0 -92
- data/rake/fixture_creator.rb +0 -46
- data/test/fixtures/api/all_cinemas.plist +0 -0
- data/test/fixtures/api/app_init.plist +0 -0
- data/test/fixtures/api/film_times/71-14876.plist +0 -0
- data/test/fixtures/api/film_times/71-15408.plist +0 -0
- data/test/fixtures/api/film_times/71-15684.plist +0 -0
- data/test/fixtures/api/film_times/71-15866.plist +0 -0
- data/test/fixtures/api/film_times/71-15868.plist +0 -0
- data/test/fixtures/api/film_times/71-15961.plist +0 -0
- data/test/fixtures/api/film_times/71-15963.plist +0 -0
- data/test/fixtures/api/film_times/71-15965.plist +0 -0
- data/test/fixtures/api/film_times/71-15967.plist +0 -0
- data/test/fixtures/api/film_times/71-15969.plist +0 -0
- data/test/fixtures/api/film_times/71-15977.plist +0 -0
- data/test/fixtures/api/film_times/71-15980.plist +0 -0
- data/test/fixtures/api/film_times/71-16037.plist +0 -0
- data/test/fixtures/api/film_times/71-16136.plist +0 -0
- data/test/fixtures/api/film_times/71-16142.plist +0 -0
- data/test/fixtures/api/film_times/71-16143.plist +0 -0
- data/test/fixtures/api/film_times/71-16187.plist +0 -0
- data/test/fixtures/api/film_times/71-16369.plist +0 -0
- data/test/fixtures/api/film_times/71-16370.plist +0 -0
- data/test/fixtures/api/film_times/71-16374.plist +0 -0
- data/test/fixtures/api/film_times/71-16386.plist +0 -0
- data/test/fixtures/api/film_times/71-16387.plist +0 -0
- data/test/fixtures/api/film_times/71-16388.plist +0 -0
- data/test/fixtures/api/film_times/71-16438.plist +0 -0
- data/test/fixtures/api/film_times/71-16454.plist +0 -0
- data/test/fixtures/api/film_times/71-16457.plist +0 -0
- data/test/fixtures/api/film_times/71-16477.plist +0 -0
- data/test/fixtures/api/film_times/71-16478.plist +0 -0
- data/test/fixtures/api/film_times/71-16480.plist +0 -0
- data/test/fixtures/api/film_times/71-16482.plist +0 -0
- data/test/fixtures/api/film_times/71-16489.plist +0 -0
|
@@ -2,40 +2,15 @@
|
|
|
2
2
|
module ApiFixturesHelper
|
|
3
3
|
private
|
|
4
4
|
|
|
5
|
-
def
|
|
6
|
-
read_fixture('api/
|
|
5
|
+
def sites_json
|
|
6
|
+
read_fixture('api/sites')
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
read_fixture(
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def film_times_plist(cinema_id, film_id)
|
|
14
|
-
read_fixture("api/film_times/#{cinema_id}-#{film_id}")
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def film_times_plist_random
|
|
18
|
-
read_fixture("api/film_times/#{film_times_plist_names(71).sample}")
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def film_times_plist_names(cinema_id)
|
|
22
|
-
Dir.entries(File.expand_path('../../fixtures/api/film_times', __FILE__))
|
|
23
|
-
.reject { |filename| !filename.match(/\A#{cinema_id}-/) }
|
|
24
|
-
.map { |filename| filename.gsub('.plist', '') }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def parse(content)
|
|
28
|
-
plist = CFPropertyList::List.new(data: content).value
|
|
29
|
-
CFPropertyList.native_types(plist).fetch('data', {})
|
|
9
|
+
def showtimes_json(cinema_id)
|
|
10
|
+
read_fixture("api/showtimes-#{cinema_id}")
|
|
30
11
|
end
|
|
31
12
|
|
|
32
13
|
def read_fixture(filepath)
|
|
33
|
-
File.read(File.expand_path("../../fixtures/#{filepath}.
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def stub_post(site_path, request_body, response_body)
|
|
37
|
-
url = "https://api.odeon.co.uk/2.1/api/#{site_path}"
|
|
38
|
-
response = { status: 200, body: response_body, headers: {} }
|
|
39
|
-
stub_request(:post, url).with(body: request_body).to_return(response)
|
|
14
|
+
File.read(File.expand_path("../../fixtures/#{filepath}.json", __FILE__))
|
|
40
15
|
end
|
|
41
16
|
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'time'
|
|
2
|
+
|
|
3
|
+
# The parts of Vista responses the gem reads. Checked against the hand-written
|
|
4
|
+
# fixtures and, in the live suite, against real responses held only in memory.
|
|
5
|
+
module ApiShapes
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def assert_sites_shape(data)
|
|
9
|
+
sites = data.fetch('sites')
|
|
10
|
+
refute_empty sites
|
|
11
|
+
sites.each do |site|
|
|
12
|
+
assert_match(/\A\d{3}\z/, site.fetch('id'))
|
|
13
|
+
assert_kind_of String, site.dig('name', 'text')
|
|
14
|
+
address = site.fetch('contactDetails').fetch('address')
|
|
15
|
+
%w(line1 line2 city).each do |key|
|
|
16
|
+
assert_kind_of String, address.fetch(key), "site #{site['id']} #{key}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def assert_showtimes_shape(data)
|
|
22
|
+
related = data.fetch('relatedData')
|
|
23
|
+
films = related.fetch('films').to_h { |film| [film.fetch('id'), film] }
|
|
24
|
+
attributes = related.fetch('attributes').to_h do |attribute|
|
|
25
|
+
[attribute.fetch('id'), attribute]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
films.each_value { |film| assert_kind_of String, film.dig('title', 'text') }
|
|
29
|
+
attributes.each_value do |attribute|
|
|
30
|
+
assert_kind_of String, attribute.dig('shortName', 'text')
|
|
31
|
+
assert_kind_of String, attribute.dig('name', 'text')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
showtimes = data.fetch('showtimes')
|
|
35
|
+
refute_empty showtimes
|
|
36
|
+
showtimes.each do |showtime|
|
|
37
|
+
assert_kind_of String, showtime.fetch('id')
|
|
38
|
+
assert_includes films.keys, showtime.fetch('filmId')
|
|
39
|
+
assert_kind_of Time, Time.iso8601(showtime.fetch('schedule').fetch('startsAt'))
|
|
40
|
+
assert_includes [true, false], showtime.fetch('requires3dGlasses')
|
|
41
|
+
showtime.fetch('attributeIds').each do |id|
|
|
42
|
+
assert_includes attributes.keys, id
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -3,15 +3,18 @@ require_relative 'api_fixtures_helper'
|
|
|
3
3
|
class FakeApiResponse
|
|
4
4
|
include ApiFixturesHelper
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
attr_reader :requested_dates
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
@requested_dates = []
|
|
8
10
|
end
|
|
9
11
|
|
|
10
|
-
def
|
|
11
|
-
parse(
|
|
12
|
+
def sites
|
|
13
|
+
JSON.parse(sites_json).fetch('sites')
|
|
12
14
|
end
|
|
13
15
|
|
|
14
|
-
def
|
|
15
|
-
|
|
16
|
+
def showtimes(cinema_id, date)
|
|
17
|
+
@requested_dates << date
|
|
18
|
+
JSON.parse(showtimes_json(cinema_id))
|
|
16
19
|
end
|
|
17
20
|
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
require '
|
|
2
|
-
|
|
1
|
+
require 'simplecov'
|
|
2
|
+
SimpleCov.start do
|
|
3
|
+
add_filter '/test/'
|
|
4
|
+
end
|
|
3
5
|
|
|
4
6
|
require 'minitest/autorun'
|
|
7
|
+
require 'minitest/mock'
|
|
5
8
|
require 'minitest/reporters'
|
|
6
9
|
|
|
7
10
|
Minitest::Reporters.use! [
|
|
@@ -9,9 +12,9 @@ Minitest::Reporters.use! [
|
|
|
9
12
|
]
|
|
10
13
|
|
|
11
14
|
require 'webmock/minitest'
|
|
12
|
-
WebMock.allow_net_connect!
|
|
13
15
|
|
|
14
16
|
require File.expand_path('../../lib/odeon_uk.rb', __FILE__)
|
|
15
17
|
|
|
16
18
|
require_relative 'support/api_fixtures_helper'
|
|
19
|
+
require_relative 'support/api_shapes'
|
|
17
20
|
require_relative 'support/fake_api_response'
|
metadata
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: odeon_uk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Croll
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: base64
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
@@ -25,7 +24,21 @@ dependencies:
|
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: bundler
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: minitest-mock
|
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
|
30
43
|
requirements:
|
|
31
44
|
- - ">="
|
|
@@ -39,7 +52,7 @@ dependencies:
|
|
|
39
52
|
- !ruby/object:Gem::Version
|
|
40
53
|
version: '0'
|
|
41
54
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
55
|
+
name: minitest-reporters
|
|
43
56
|
requirement: !ruby/object:Gem::Requirement
|
|
44
57
|
requirements:
|
|
45
58
|
- - ">="
|
|
@@ -53,7 +66,7 @@ dependencies:
|
|
|
53
66
|
- !ruby/object:Gem::Version
|
|
54
67
|
version: '0'
|
|
55
68
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
69
|
+
name: rake
|
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
|
58
71
|
requirements:
|
|
59
72
|
- - ">="
|
|
@@ -67,13 +80,27 @@ dependencies:
|
|
|
67
80
|
- !ruby/object:Gem::Version
|
|
68
81
|
version: '0'
|
|
69
82
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
83
|
+
name: simplecov
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "<"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '1'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "<"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '1'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: webmock
|
|
71
98
|
requirement: !ruby/object:Gem::Requirement
|
|
72
99
|
requirements:
|
|
73
100
|
- - ">="
|
|
74
101
|
- !ruby/object:Gem::Version
|
|
75
102
|
version: '0'
|
|
76
|
-
type: :
|
|
103
|
+
type: :development
|
|
77
104
|
prerelease: false
|
|
78
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
106
|
requirements:
|
|
@@ -86,23 +113,25 @@ dependencies:
|
|
|
86
113
|
requirements:
|
|
87
114
|
- - "~>"
|
|
88
115
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
116
|
+
version: '5.4'
|
|
90
117
|
type: :runtime
|
|
91
118
|
prerelease: false
|
|
92
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
120
|
requirements:
|
|
94
121
|
- - "~>"
|
|
95
122
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
97
|
-
description: Pull movie & cinema information from the
|
|
123
|
+
version: '5.4'
|
|
124
|
+
description: Pull movie & cinema information from the ODEON Vista API
|
|
98
125
|
email:
|
|
99
126
|
- andy@goodscary.com
|
|
100
127
|
executables: []
|
|
101
128
|
extensions: []
|
|
102
129
|
extra_rdoc_files: []
|
|
103
130
|
files:
|
|
131
|
+
- ".github/workflows/release.yml"
|
|
132
|
+
- ".github/workflows/test.yml"
|
|
104
133
|
- ".gitignore"
|
|
105
|
-
- ".
|
|
134
|
+
- ".ruby-version"
|
|
106
135
|
- CHANGELOG.md
|
|
107
136
|
- COMM-LICENSE
|
|
108
137
|
- Gemfile
|
|
@@ -112,60 +141,35 @@ files:
|
|
|
112
141
|
- lib/odeon_uk.rb
|
|
113
142
|
- lib/odeon_uk/cinema.rb
|
|
114
143
|
- lib/odeon_uk/internal/api_response.rb
|
|
115
|
-
- lib/odeon_uk/internal/
|
|
116
|
-
- lib/odeon_uk/internal/parser/api/
|
|
144
|
+
- lib/odeon_uk/internal/guest_token.rb
|
|
145
|
+
- lib/odeon_uk/internal/parser/api/showtime.rb
|
|
117
146
|
- lib/odeon_uk/internal/title_sanitizer.rb
|
|
118
147
|
- lib/odeon_uk/performance.rb
|
|
119
148
|
- lib/odeon_uk/version.rb
|
|
120
149
|
- odeon_uk.gemspec
|
|
121
|
-
-
|
|
122
|
-
- test/fixtures/api/
|
|
123
|
-
- test/fixtures/api/app_init.plist
|
|
124
|
-
- test/fixtures/api/film_times/71-14876.plist
|
|
125
|
-
- test/fixtures/api/film_times/71-15408.plist
|
|
126
|
-
- test/fixtures/api/film_times/71-15684.plist
|
|
127
|
-
- test/fixtures/api/film_times/71-15866.plist
|
|
128
|
-
- test/fixtures/api/film_times/71-15868.plist
|
|
129
|
-
- test/fixtures/api/film_times/71-15961.plist
|
|
130
|
-
- test/fixtures/api/film_times/71-15963.plist
|
|
131
|
-
- test/fixtures/api/film_times/71-15965.plist
|
|
132
|
-
- test/fixtures/api/film_times/71-15967.plist
|
|
133
|
-
- test/fixtures/api/film_times/71-15969.plist
|
|
134
|
-
- test/fixtures/api/film_times/71-15977.plist
|
|
135
|
-
- test/fixtures/api/film_times/71-15980.plist
|
|
136
|
-
- test/fixtures/api/film_times/71-16037.plist
|
|
137
|
-
- test/fixtures/api/film_times/71-16136.plist
|
|
138
|
-
- test/fixtures/api/film_times/71-16142.plist
|
|
139
|
-
- test/fixtures/api/film_times/71-16143.plist
|
|
140
|
-
- test/fixtures/api/film_times/71-16187.plist
|
|
141
|
-
- test/fixtures/api/film_times/71-16369.plist
|
|
142
|
-
- test/fixtures/api/film_times/71-16370.plist
|
|
143
|
-
- test/fixtures/api/film_times/71-16374.plist
|
|
144
|
-
- test/fixtures/api/film_times/71-16386.plist
|
|
145
|
-
- test/fixtures/api/film_times/71-16387.plist
|
|
146
|
-
- test/fixtures/api/film_times/71-16388.plist
|
|
147
|
-
- test/fixtures/api/film_times/71-16438.plist
|
|
148
|
-
- test/fixtures/api/film_times/71-16454.plist
|
|
149
|
-
- test/fixtures/api/film_times/71-16457.plist
|
|
150
|
-
- test/fixtures/api/film_times/71-16477.plist
|
|
151
|
-
- test/fixtures/api/film_times/71-16478.plist
|
|
152
|
-
- test/fixtures/api/film_times/71-16480.plist
|
|
153
|
-
- test/fixtures/api/film_times/71-16482.plist
|
|
154
|
-
- test/fixtures/api/film_times/71-16489.plist
|
|
150
|
+
- test/fixtures/api/showtimes-824.json
|
|
151
|
+
- test/fixtures/api/sites.json
|
|
155
152
|
- test/lib/odeon_uk/cinema_test.rb
|
|
156
153
|
- test/lib/odeon_uk/internal/api_response_test.rb
|
|
154
|
+
- test/lib/odeon_uk/internal/fixture_shape_test.rb
|
|
155
|
+
- test/lib/odeon_uk/internal/guest_token_test.rb
|
|
156
|
+
- test/lib/odeon_uk/internal/parser/api/showtime_test.rb
|
|
157
157
|
- test/lib/odeon_uk/internal/title_sanitizer_test.rb
|
|
158
158
|
- test/lib/odeon_uk/performance_test.rb
|
|
159
159
|
- test/lib/odeon_uk/version_test.rb
|
|
160
|
+
- test/live/api_shape_test.rb
|
|
161
|
+
- test/live/integration_test.rb
|
|
162
|
+
- test/live/live_helper.rb
|
|
163
|
+
- test/package_test.rb
|
|
160
164
|
- test/support/api_fixtures_helper.rb
|
|
165
|
+
- test/support/api_shapes.rb
|
|
161
166
|
- test/support/fake_api_response.rb
|
|
162
167
|
- test/test_helper.rb
|
|
163
|
-
homepage:
|
|
168
|
+
homepage: https://github.com/andycroll/odeon_uk
|
|
164
169
|
licenses:
|
|
165
170
|
- AGPL
|
|
166
171
|
- MIT
|
|
167
172
|
metadata: {}
|
|
168
|
-
post_install_message:
|
|
169
173
|
rdoc_options: []
|
|
170
174
|
require_paths:
|
|
171
175
|
- lib
|
|
@@ -173,58 +177,32 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
173
177
|
requirements:
|
|
174
178
|
- - ">="
|
|
175
179
|
- !ruby/object:Gem::Version
|
|
176
|
-
version: '
|
|
180
|
+
version: '3.4'
|
|
177
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
182
|
requirements:
|
|
179
183
|
- - ">="
|
|
180
184
|
- !ruby/object:Gem::Version
|
|
181
185
|
version: '0'
|
|
182
186
|
requirements: []
|
|
183
|
-
|
|
184
|
-
rubygems_version: 2.4.5
|
|
185
|
-
signing_key:
|
|
187
|
+
rubygems_version: 4.0.20
|
|
186
188
|
specification_version: 4
|
|
187
189
|
summary: It's a scraper, but a nice one
|
|
188
190
|
test_files:
|
|
189
|
-
- test/fixtures/api/
|
|
190
|
-
- test/fixtures/api/
|
|
191
|
-
- test/fixtures/api/film_times/71-14876.plist
|
|
192
|
-
- test/fixtures/api/film_times/71-15408.plist
|
|
193
|
-
- test/fixtures/api/film_times/71-15684.plist
|
|
194
|
-
- test/fixtures/api/film_times/71-15866.plist
|
|
195
|
-
- test/fixtures/api/film_times/71-15868.plist
|
|
196
|
-
- test/fixtures/api/film_times/71-15961.plist
|
|
197
|
-
- test/fixtures/api/film_times/71-15963.plist
|
|
198
|
-
- test/fixtures/api/film_times/71-15965.plist
|
|
199
|
-
- test/fixtures/api/film_times/71-15967.plist
|
|
200
|
-
- test/fixtures/api/film_times/71-15969.plist
|
|
201
|
-
- test/fixtures/api/film_times/71-15977.plist
|
|
202
|
-
- test/fixtures/api/film_times/71-15980.plist
|
|
203
|
-
- test/fixtures/api/film_times/71-16037.plist
|
|
204
|
-
- test/fixtures/api/film_times/71-16136.plist
|
|
205
|
-
- test/fixtures/api/film_times/71-16142.plist
|
|
206
|
-
- test/fixtures/api/film_times/71-16143.plist
|
|
207
|
-
- test/fixtures/api/film_times/71-16187.plist
|
|
208
|
-
- test/fixtures/api/film_times/71-16369.plist
|
|
209
|
-
- test/fixtures/api/film_times/71-16370.plist
|
|
210
|
-
- test/fixtures/api/film_times/71-16374.plist
|
|
211
|
-
- test/fixtures/api/film_times/71-16386.plist
|
|
212
|
-
- test/fixtures/api/film_times/71-16387.plist
|
|
213
|
-
- test/fixtures/api/film_times/71-16388.plist
|
|
214
|
-
- test/fixtures/api/film_times/71-16438.plist
|
|
215
|
-
- test/fixtures/api/film_times/71-16454.plist
|
|
216
|
-
- test/fixtures/api/film_times/71-16457.plist
|
|
217
|
-
- test/fixtures/api/film_times/71-16477.plist
|
|
218
|
-
- test/fixtures/api/film_times/71-16478.plist
|
|
219
|
-
- test/fixtures/api/film_times/71-16480.plist
|
|
220
|
-
- test/fixtures/api/film_times/71-16482.plist
|
|
221
|
-
- test/fixtures/api/film_times/71-16489.plist
|
|
191
|
+
- test/fixtures/api/showtimes-824.json
|
|
192
|
+
- test/fixtures/api/sites.json
|
|
222
193
|
- test/lib/odeon_uk/cinema_test.rb
|
|
223
194
|
- test/lib/odeon_uk/internal/api_response_test.rb
|
|
195
|
+
- test/lib/odeon_uk/internal/fixture_shape_test.rb
|
|
196
|
+
- test/lib/odeon_uk/internal/guest_token_test.rb
|
|
197
|
+
- test/lib/odeon_uk/internal/parser/api/showtime_test.rb
|
|
224
198
|
- test/lib/odeon_uk/internal/title_sanitizer_test.rb
|
|
225
199
|
- test/lib/odeon_uk/performance_test.rb
|
|
226
200
|
- test/lib/odeon_uk/version_test.rb
|
|
201
|
+
- test/live/api_shape_test.rb
|
|
202
|
+
- test/live/integration_test.rb
|
|
203
|
+
- test/live/live_helper.rb
|
|
204
|
+
- test/package_test.rb
|
|
227
205
|
- test/support/api_fixtures_helper.rb
|
|
206
|
+
- test/support/api_shapes.rb
|
|
228
207
|
- test/support/fake_api_response.rb
|
|
229
208
|
- test/test_helper.rb
|
|
230
|
-
has_rdoc:
|
data/.travis.yml
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
module OdeonUk
|
|
2
|
-
# @api private
|
|
3
|
-
module Internal
|
|
4
|
-
module Parser
|
|
5
|
-
module Api
|
|
6
|
-
# Parses a string to derive address
|
|
7
|
-
class FilmLookup
|
|
8
|
-
# @param [Integer] cinema_id id of the cinema
|
|
9
|
-
# @return [Hash{Integer => OdeonUk::Internal::Parser::Api::Film}]
|
|
10
|
-
# contains all films keyed by id for a cinema
|
|
11
|
-
def at(cinema_id)
|
|
12
|
-
to_hash.select do |_, film_hash|
|
|
13
|
-
film_hash['sites'].include?(cinema_id)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# @return [Hash{Integer => OdeonUk::Internal::Parser::Api::Film}]
|
|
18
|
-
# contains all films & upcoming films keyed by id
|
|
19
|
-
def to_hash
|
|
20
|
-
@to_hash ||= api.each_with_object({}) do |film_hash, result|
|
|
21
|
-
result[film_hash['filmMasterId'].to_i] = film_hash
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def api
|
|
28
|
-
@api ||= OdeonUk::Internal::ApiResponse.new.app_init['films']
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
module OdeonUk
|
|
2
|
-
# @api private
|
|
3
|
-
module Internal
|
|
4
|
-
module Parser
|
|
5
|
-
module Api
|
|
6
|
-
# A single day of performances for a particular film
|
|
7
|
-
class PerformanceDay
|
|
8
|
-
def initialize(data)
|
|
9
|
-
@data = data
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def to_a
|
|
13
|
-
performance_kinds.each_with_index.flat_map do |_, index|
|
|
14
|
-
starting_times(index).map do |time|
|
|
15
|
-
{
|
|
16
|
-
dimension: dimension(index),
|
|
17
|
-
starting_at: TimeParser.new(date, time).to_utc,
|
|
18
|
-
variant: variant(index)
|
|
19
|
-
}
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def date
|
|
27
|
-
@data['date']
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def dimension(index)
|
|
31
|
-
performance_kind(index).include?('3D') ? '3d' : '2d'
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def performance_kinds
|
|
35
|
-
@data['attributes']
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def performance_kind(index)
|
|
39
|
-
performance_kinds[index]['attribute']
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def starting_times(index)
|
|
43
|
-
performance_kinds[index]['showtimes'][0].map do |h|
|
|
44
|
-
h['performanceTime']
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def variant(index)
|
|
49
|
-
{
|
|
50
|
-
'Culture' => 'arts',
|
|
51
|
-
'Kids' => 'kids',
|
|
52
|
-
'IMAX' => 'imax',
|
|
53
|
-
'Newbies' => 'baby',
|
|
54
|
-
'Silver Cinema' => 'senior'
|
|
55
|
-
}.select { |k, _| performance_kind(index).include?(k) }.values.uniq
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# parse a time to utc time
|
|
59
|
-
TimeParser = Struct.new(:date, :time) do
|
|
60
|
-
def to_utc
|
|
61
|
-
tz.local_to_utc(parsed_time)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
private
|
|
65
|
-
|
|
66
|
-
def early_morning_screening?
|
|
67
|
-
time.match(/\A00/)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def parsed_date
|
|
71
|
-
case date
|
|
72
|
-
when 'Today' then Time.now.strftime '%Y-%m-%d'
|
|
73
|
-
when 'Tomorrow' then (Time.now + 60 * 60 * 24).strftime '%Y-%m-%d'
|
|
74
|
-
else date.gsub('.', '').match(/\d+\s\w+\z/)[0]
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def parsed_time
|
|
79
|
-
parsed_time = Time.parse("#{parsed_date} #{time} UTC")
|
|
80
|
-
# Odeon deliberately mislabel their 00:01 screenings as the day before
|
|
81
|
-
early_morning_screening? ? parsed_time + 60 * 60 * 24 : parsed_time
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def tz
|
|
85
|
-
@tz ||= TZInfo::Timezone.get('Europe/London')
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
data/rake/fixture_creator.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module FixtureCreator
|
|
2
|
-
class Api
|
|
3
|
-
def all_cinemas!
|
|
4
|
-
write_fixture(:all_cinemas)
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def app_init!
|
|
8
|
-
write_fixture(:app_init)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def film_times!(cinema_id)
|
|
12
|
-
OdeonUk::Performance.send(:film_ids_at, cinema_id).each do |i|
|
|
13
|
-
write_film_times_fixture(cinema_id, i)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def fixture(name)
|
|
20
|
-
File.expand_path("../../test/fixtures/api/#{name}.plist", __FILE__)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def log(message)
|
|
24
|
-
puts "Create API fixture: #{message}"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def write_film_times_fixture(cinema_id, film_id)
|
|
28
|
-
FileUtils.mkdir_p 'film_times'
|
|
29
|
-
text = "film_times/#{cinema_id}-#{film_id}"
|
|
30
|
-
File.open(fixture(text), 'w+') do |file|
|
|
31
|
-
log(text)
|
|
32
|
-
file.write OdeonUk::Internal::ApiResponse.new.send(:film_times_raw,
|
|
33
|
-
cinema_id,
|
|
34
|
-
film_id)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def write_fixture(kind)
|
|
39
|
-
FileUtils.mkdir_p kind.to_s
|
|
40
|
-
File.open(fixture(kind), 'w+') do |file|
|
|
41
|
-
log(kind)
|
|
42
|
-
file.write OdeonUk::Internal::ApiResponse.new.send("#{kind}_raw".to_sym)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|