odeon_uk 3.0.6 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -3
- data/CHANGELOG.md +14 -0
- data/{LICENSE.txt → COMM-LICENSE} +0 -0
- data/LICENSE +617 -0
- data/README.md +58 -29
- data/Rakefile +7 -21
- data/lib/odeon_uk.rb +5 -14
- data/lib/odeon_uk/cinema.rb +123 -75
- data/lib/odeon_uk/{api/response.rb → internal/api_response.rb} +3 -3
- data/lib/odeon_uk/internal/parser/api/film_lookup.rb +34 -0
- data/lib/odeon_uk/internal/parser/api/performance_day.rb +92 -0
- data/lib/odeon_uk/internal/title_sanitizer.rb +34 -39
- data/lib/odeon_uk/performance.rb +87 -0
- data/lib/odeon_uk/version.rb +2 -2
- data/odeon_uk.gemspec +19 -21
- data/rake/fixture_creator.rb +5 -57
- 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
- data/test/lib/odeon_uk/cinema_test.rb +154 -373
- data/test/lib/odeon_uk/{api/response_test.rb → internal/api_response_test.rb} +7 -4
- data/test/lib/odeon_uk/performance_test.rb +149 -0
- data/test/lib/odeon_uk/version_test.rb +3 -5
- data/test/support/api_fixtures_helper.rb +9 -3
- data/test/support/fake_api_response.rb +17 -0
- data/test/test_helper.rb +9 -3
- metadata +89 -145
- data/.rdoc_options +0 -16
- data/lib/odeon_uk/api/cinema.rb +0 -67
- data/lib/odeon_uk/api/screenings.rb +0 -103
- data/lib/odeon_uk/configuration.rb +0 -21
- data/lib/odeon_uk/html/cinema.rb +0 -101
- data/lib/odeon_uk/html/parser/film_with_screenings.rb +0 -160
- data/lib/odeon_uk/html/screenings.rb +0 -38
- data/lib/odeon_uk/html/website.rb +0 -38
- data/lib/odeon_uk/screening.rb +0 -71
- data/test/fixtures/api/film_times/71-100747.plist +0 -0
- data/test/fixtures/api/film_times/71-100750.plist +0 -0
- data/test/fixtures/api/film_times/71-100790.plist +0 -0
- data/test/fixtures/api/film_times/71-14646.plist +0 -0
- data/test/fixtures/api/film_times/71-14725.plist +0 -0
- data/test/fixtures/api/film_times/71-15086.plist +0 -0
- data/test/fixtures/api/film_times/71-15096.plist +0 -0
- data/test/fixtures/api/film_times/71-15122.plist +0 -0
- data/test/fixtures/api/film_times/71-15130.plist +0 -0
- data/test/fixtures/api/film_times/71-15141.plist +0 -0
- data/test/fixtures/api/film_times/71-15142.plist +0 -0
- data/test/fixtures/api/film_times/71-15143.plist +0 -0
- data/test/fixtures/api/film_times/71-15144.plist +0 -0
- data/test/fixtures/api/film_times/71-15145.plist +0 -0
- data/test/fixtures/api/film_times/71-15170.plist +0 -0
- data/test/fixtures/api/film_times/71-15172.plist +0 -0
- data/test/fixtures/api/film_times/71-15177.plist +0 -0
- data/test/fixtures/api/film_times/71-15179.plist +0 -0
- data/test/fixtures/api/film_times/71-15182.plist +0 -0
- data/test/fixtures/api/film_times/71-15286.plist +0 -0
- data/test/fixtures/api/film_times/71-15360.plist +0 -0
- data/test/fixtures/api/film_times/71-15586.plist +0 -0
- data/test/fixtures/api/film_times/71-15700.plist +0 -0
- data/test/fixtures/api/film_times/71-15718.plist +0 -0
- data/test/fixtures/api/film_times/71-15768.plist +0 -0
- data/test/fixtures/api/film_times/71-15788.plist +0 -0
- data/test/fixtures/api/film_times/71-15793.plist +0 -0
- data/test/fixtures/api/film_times/71-15794.plist +0 -0
- data/test/fixtures/api/film_times/71-15795.plist +0 -0
- data/test/fixtures/api/film_times/71-15796.plist +0 -0
- data/test/fixtures/api/film_times/71-15799.plist +0 -0
- data/test/fixtures/api/film_times/71-15802.plist +0 -0
- data/test/fixtures/api/film_times/71-15814.plist +0 -0
- data/test/fixtures/api/film_times/71-15817.plist +0 -0
- data/test/fixtures/api/film_times/71-15840.plist +0 -0
- data/test/fixtures/html/cinema/105.html +0 -2622
- data/test/fixtures/html/cinema/211.html +0 -3241
- data/test/fixtures/html/cinema/71.html +0 -3448
- data/test/fixtures/html/showtimes/11-imax.html +0 -170
- data/test/fixtures/html/showtimes/171-d-box.html +0 -203
- data/test/fixtures/html/showtimes/71-0.html +0 -59
- data/test/fixtures/html/showtimes/71.html +0 -2395
- data/test/fixtures/html/sitemap.html +0 -1303
- data/test/lib/odeon_uk/api/cinema_test.rb +0 -165
- data/test/lib/odeon_uk/api/screenings_test.rb +0 -58
- data/test/lib/odeon_uk/configuration_test.rb +0 -29
- data/test/lib/odeon_uk/html/cinema_test.rb +0 -149
- data/test/lib/odeon_uk/html/parser/film_with_screenings_test.rb +0 -97
- data/test/lib/odeon_uk/html/screenings_test.rb +0 -44
- data/test/lib/odeon_uk/html/website_test.rb +0 -67
- data/test/lib/odeon_uk/screening_test.rb +0 -92
- data/test/support/website_fixtures_helper.rb +0 -30
@@ -1,44 +0,0 @@
|
|
1
|
-
require_relative '../../../test_helper'
|
2
|
-
|
3
|
-
describe OdeonUk::Html::Screenings do
|
4
|
-
include WebsiteFixturesHelper
|
5
|
-
|
6
|
-
let(:described_class) { OdeonUk::Html::Screenings }
|
7
|
-
|
8
|
-
let(:website) { Minitest::Mock.new }
|
9
|
-
|
10
|
-
before { WebMock.disable_net_connect! }
|
11
|
-
|
12
|
-
describe '.at(cinema_id)' do
|
13
|
-
subject { described_class.at(71) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
website.expect(:sitemap, sitemap_html)
|
17
|
-
website.expect(:showtimes, showtimes_html(71), [71])
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns an array of screening attributes as hashes' do
|
21
|
-
OdeonUk::Html::Website.stub :new, website do
|
22
|
-
subject.must_be_instance_of(Array)
|
23
|
-
subject.each do |screening|
|
24
|
-
screening.must_be_instance_of(Hash)
|
25
|
-
screening.keys.must_include(:film_name)
|
26
|
-
|
27
|
-
screening.keys.must_include(:time)
|
28
|
-
screening[:time].must_be_instance_of(Time)
|
29
|
-
|
30
|
-
screening.keys.must_include(:variant)
|
31
|
-
|
32
|
-
screening.keys.must_include(:dimension)
|
33
|
-
screening[:dimension].must_match(/[23]d/)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'returns correct number of screenings' do
|
39
|
-
OdeonUk::Html::Website.stub :new, website do
|
40
|
-
subject.count.must_equal 212
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require_relative '../../../test_helper'
|
2
|
-
|
3
|
-
describe OdeonUk::Html::Website do
|
4
|
-
include WebsiteFixturesHelper
|
5
|
-
|
6
|
-
let(:described_class) { OdeonUk::Html::Website }
|
7
|
-
|
8
|
-
describe '#cinema(id)' do
|
9
|
-
subject { described_class.new.cinema(71) }
|
10
|
-
|
11
|
-
describe 'successful http request' do
|
12
|
-
before { stub_get('cinemas/odeon/71/', cinema_html(71)) }
|
13
|
-
|
14
|
-
it 'returns a string' do
|
15
|
-
subject.class.must_equal String
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'unsuccessful http request' do
|
20
|
-
before { stub_get_with_500('cinemas/odeon/71/') }
|
21
|
-
|
22
|
-
it 'returns an empty string' do
|
23
|
-
subject.must_equal ''
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#sitemap' do
|
29
|
-
subject { described_class.new.sitemap }
|
30
|
-
|
31
|
-
describe 'successful http request' do
|
32
|
-
before { stub_get('sitemap/', sitemap_html) }
|
33
|
-
|
34
|
-
it 'returns a string' do
|
35
|
-
subject.class.must_equal String
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'unsuccessful http request' do
|
40
|
-
before { stub_get_with_500('sitemap/') }
|
41
|
-
|
42
|
-
it 'returns an empty string' do
|
43
|
-
subject.must_equal ''
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#showtimes(id)' do
|
49
|
-
subject { described_class.new.showtimes(71) }
|
50
|
-
|
51
|
-
describe 'successful http request' do
|
52
|
-
before { stub_get('showtimes/week/71/?siteId=71', showtimes_html(71)) }
|
53
|
-
|
54
|
-
it 'returns a string' do
|
55
|
-
subject.class.must_equal String
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'unsuccessful http request' do
|
60
|
-
before { stub_get_with_500('showtimes/week/71/?siteId=71') }
|
61
|
-
|
62
|
-
it 'returns an empty string' do
|
63
|
-
subject.must_equal ''
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe OdeonUk::Screening, 'html' do
|
4
|
-
include WebsiteFixturesHelper
|
5
|
-
|
6
|
-
let(:described_class) { OdeonUk::Screening }
|
7
|
-
|
8
|
-
let(:website) { Minitest::Mock.new }
|
9
|
-
|
10
|
-
before do
|
11
|
-
WebMock.disable_net_connect!
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '.at(cinema_id)' do
|
15
|
-
subject { described_class.at(71) }
|
16
|
-
|
17
|
-
before do
|
18
|
-
website.expect(:cinema, cinema_html(71), [71])
|
19
|
-
website.expect(:showtimes, showtimes_html(71), [71])
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns an array of screening attributes as hashes' do
|
23
|
-
OdeonUk::Html::Website.stub :new, website do
|
24
|
-
subject.must_be_instance_of(Array)
|
25
|
-
subject.each do |screening|
|
26
|
-
screening.must_be_instance_of(described_class)
|
27
|
-
screening.cinema_name.must_equal('Brighton')
|
28
|
-
screening.cinema_id.must_equal(71)
|
29
|
-
screening.film_name.wont_be_nil
|
30
|
-
screening.showing_at.must_be_instance_of(Time)
|
31
|
-
screening.showing_on.must_be_instance_of(Date)
|
32
|
-
screening.dimension.must_match(/[23]d/)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'returns correct number of screenings' do
|
38
|
-
OdeonUk::Html::Website.stub :new, website do
|
39
|
-
subject.count.must_equal 212
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe OdeonUk::Screening, 'api' do
|
46
|
-
include ApiFixturesHelper
|
47
|
-
|
48
|
-
let(:described_class) { OdeonUk::Screening }
|
49
|
-
|
50
|
-
let(:website) { Minitest::Mock.new }
|
51
|
-
|
52
|
-
before do
|
53
|
-
WebMock.disable_net_connect!
|
54
|
-
end
|
55
|
-
|
56
|
-
describe '.at(cinema_id)' do
|
57
|
-
subject { described_class.at(71) }
|
58
|
-
|
59
|
-
before do
|
60
|
-
OdeonUk.configure { |config| config.method = :api }
|
61
|
-
|
62
|
-
stub_post('app-init', nil, app_init_plist)
|
63
|
-
film_times_plists(71).each do |name|
|
64
|
-
film_id = name.match(/(\d+)\.plist/)[1]
|
65
|
-
stub_post('film-times',
|
66
|
-
{ s: '71', m: film_id },
|
67
|
-
film_times_plist(71, film_id))
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
after do
|
72
|
-
OdeonUk.configure { |config| config.method = :html }
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'returns an array of screening attributes as hashes' do
|
76
|
-
subject.must_be_instance_of(Array)
|
77
|
-
subject.each do |screening|
|
78
|
-
screening.must_be_instance_of(described_class)
|
79
|
-
screening.cinema_name.must_equal('Brighton')
|
80
|
-
screening.cinema_id.must_equal(71)
|
81
|
-
screening.film_name.wont_be_nil
|
82
|
-
screening.showing_at.must_be_instance_of(Time)
|
83
|
-
screening.showing_on.must_be_instance_of(Date)
|
84
|
-
screening.dimension.must_match(/[23]d/)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'returns correct number of screenings' do
|
89
|
-
subject.count.must_equal 159
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module WebsiteFixturesHelper
|
2
|
-
private
|
3
|
-
|
4
|
-
def cinema_html(id)
|
5
|
-
read_fixture("html/cinema/#{id}")
|
6
|
-
end
|
7
|
-
|
8
|
-
def showtimes_html(id, i = nil)
|
9
|
-
read_fixture("html/showtimes/#{id}#{ "-#{i}" if i }")
|
10
|
-
end
|
11
|
-
|
12
|
-
def sitemap_html
|
13
|
-
read_fixture('html/sitemap')
|
14
|
-
end
|
15
|
-
|
16
|
-
def read_fixture(filepath)
|
17
|
-
File.read(File.expand_path("../../fixtures/#{filepath}.html", __FILE__))
|
18
|
-
end
|
19
|
-
|
20
|
-
def stub_get_with_500(site_path)
|
21
|
-
url = "http://www.odeon.co.uk/#{site_path}"
|
22
|
-
stub_request(:get, url).to_return(status: [500, 'Internal Server Error'])
|
23
|
-
end
|
24
|
-
|
25
|
-
def stub_get(site_path, response_body)
|
26
|
-
url = "http://www.odeon.co.uk/#{site_path}"
|
27
|
-
response = { status: 200, body: response_body, headers: {} }
|
28
|
-
stub_request(:get, url).to_return(response)
|
29
|
-
end
|
30
|
-
end
|