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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -3
  3. data/CHANGELOG.md +14 -0
  4. data/{LICENSE.txt → COMM-LICENSE} +0 -0
  5. data/LICENSE +617 -0
  6. data/README.md +58 -29
  7. data/Rakefile +7 -21
  8. data/lib/odeon_uk.rb +5 -14
  9. data/lib/odeon_uk/cinema.rb +123 -75
  10. data/lib/odeon_uk/{api/response.rb → internal/api_response.rb} +3 -3
  11. data/lib/odeon_uk/internal/parser/api/film_lookup.rb +34 -0
  12. data/lib/odeon_uk/internal/parser/api/performance_day.rb +92 -0
  13. data/lib/odeon_uk/internal/title_sanitizer.rb +34 -39
  14. data/lib/odeon_uk/performance.rb +87 -0
  15. data/lib/odeon_uk/version.rb +2 -2
  16. data/odeon_uk.gemspec +19 -21
  17. data/rake/fixture_creator.rb +5 -57
  18. data/test/fixtures/api/all_cinemas.plist +0 -0
  19. data/test/fixtures/api/app_init.plist +0 -0
  20. data/test/fixtures/api/film_times/71-14876.plist +0 -0
  21. data/test/fixtures/api/film_times/71-15408.plist +0 -0
  22. data/test/fixtures/api/film_times/71-15684.plist +0 -0
  23. data/test/fixtures/api/film_times/71-15866.plist +0 -0
  24. data/test/fixtures/api/film_times/71-15868.plist +0 -0
  25. data/test/fixtures/api/film_times/71-15961.plist +0 -0
  26. data/test/fixtures/api/film_times/71-15963.plist +0 -0
  27. data/test/fixtures/api/film_times/71-15965.plist +0 -0
  28. data/test/fixtures/api/film_times/71-15967.plist +0 -0
  29. data/test/fixtures/api/film_times/71-15969.plist +0 -0
  30. data/test/fixtures/api/film_times/71-15977.plist +0 -0
  31. data/test/fixtures/api/film_times/71-15980.plist +0 -0
  32. data/test/fixtures/api/film_times/71-16037.plist +0 -0
  33. data/test/fixtures/api/film_times/71-16136.plist +0 -0
  34. data/test/fixtures/api/film_times/71-16142.plist +0 -0
  35. data/test/fixtures/api/film_times/71-16143.plist +0 -0
  36. data/test/fixtures/api/film_times/71-16187.plist +0 -0
  37. data/test/fixtures/api/film_times/71-16369.plist +0 -0
  38. data/test/fixtures/api/film_times/71-16370.plist +0 -0
  39. data/test/fixtures/api/film_times/71-16374.plist +0 -0
  40. data/test/fixtures/api/film_times/71-16386.plist +0 -0
  41. data/test/fixtures/api/film_times/71-16387.plist +0 -0
  42. data/test/fixtures/api/film_times/71-16388.plist +0 -0
  43. data/test/fixtures/api/film_times/71-16438.plist +0 -0
  44. data/test/fixtures/api/film_times/71-16454.plist +0 -0
  45. data/test/fixtures/api/film_times/71-16457.plist +0 -0
  46. data/test/fixtures/api/film_times/71-16477.plist +0 -0
  47. data/test/fixtures/api/film_times/71-16478.plist +0 -0
  48. data/test/fixtures/api/film_times/71-16480.plist +0 -0
  49. data/test/fixtures/api/film_times/71-16482.plist +0 -0
  50. data/test/fixtures/api/film_times/71-16489.plist +0 -0
  51. data/test/lib/odeon_uk/cinema_test.rb +154 -373
  52. data/test/lib/odeon_uk/{api/response_test.rb → internal/api_response_test.rb} +7 -4
  53. data/test/lib/odeon_uk/performance_test.rb +149 -0
  54. data/test/lib/odeon_uk/version_test.rb +3 -5
  55. data/test/support/api_fixtures_helper.rb +9 -3
  56. data/test/support/fake_api_response.rb +17 -0
  57. data/test/test_helper.rb +9 -3
  58. metadata +89 -145
  59. data/.rdoc_options +0 -16
  60. data/lib/odeon_uk/api/cinema.rb +0 -67
  61. data/lib/odeon_uk/api/screenings.rb +0 -103
  62. data/lib/odeon_uk/configuration.rb +0 -21
  63. data/lib/odeon_uk/html/cinema.rb +0 -101
  64. data/lib/odeon_uk/html/parser/film_with_screenings.rb +0 -160
  65. data/lib/odeon_uk/html/screenings.rb +0 -38
  66. data/lib/odeon_uk/html/website.rb +0 -38
  67. data/lib/odeon_uk/screening.rb +0 -71
  68. data/test/fixtures/api/film_times/71-100747.plist +0 -0
  69. data/test/fixtures/api/film_times/71-100750.plist +0 -0
  70. data/test/fixtures/api/film_times/71-100790.plist +0 -0
  71. data/test/fixtures/api/film_times/71-14646.plist +0 -0
  72. data/test/fixtures/api/film_times/71-14725.plist +0 -0
  73. data/test/fixtures/api/film_times/71-15086.plist +0 -0
  74. data/test/fixtures/api/film_times/71-15096.plist +0 -0
  75. data/test/fixtures/api/film_times/71-15122.plist +0 -0
  76. data/test/fixtures/api/film_times/71-15130.plist +0 -0
  77. data/test/fixtures/api/film_times/71-15141.plist +0 -0
  78. data/test/fixtures/api/film_times/71-15142.plist +0 -0
  79. data/test/fixtures/api/film_times/71-15143.plist +0 -0
  80. data/test/fixtures/api/film_times/71-15144.plist +0 -0
  81. data/test/fixtures/api/film_times/71-15145.plist +0 -0
  82. data/test/fixtures/api/film_times/71-15170.plist +0 -0
  83. data/test/fixtures/api/film_times/71-15172.plist +0 -0
  84. data/test/fixtures/api/film_times/71-15177.plist +0 -0
  85. data/test/fixtures/api/film_times/71-15179.plist +0 -0
  86. data/test/fixtures/api/film_times/71-15182.plist +0 -0
  87. data/test/fixtures/api/film_times/71-15286.plist +0 -0
  88. data/test/fixtures/api/film_times/71-15360.plist +0 -0
  89. data/test/fixtures/api/film_times/71-15586.plist +0 -0
  90. data/test/fixtures/api/film_times/71-15700.plist +0 -0
  91. data/test/fixtures/api/film_times/71-15718.plist +0 -0
  92. data/test/fixtures/api/film_times/71-15768.plist +0 -0
  93. data/test/fixtures/api/film_times/71-15788.plist +0 -0
  94. data/test/fixtures/api/film_times/71-15793.plist +0 -0
  95. data/test/fixtures/api/film_times/71-15794.plist +0 -0
  96. data/test/fixtures/api/film_times/71-15795.plist +0 -0
  97. data/test/fixtures/api/film_times/71-15796.plist +0 -0
  98. data/test/fixtures/api/film_times/71-15799.plist +0 -0
  99. data/test/fixtures/api/film_times/71-15802.plist +0 -0
  100. data/test/fixtures/api/film_times/71-15814.plist +0 -0
  101. data/test/fixtures/api/film_times/71-15817.plist +0 -0
  102. data/test/fixtures/api/film_times/71-15840.plist +0 -0
  103. data/test/fixtures/html/cinema/105.html +0 -2622
  104. data/test/fixtures/html/cinema/211.html +0 -3241
  105. data/test/fixtures/html/cinema/71.html +0 -3448
  106. data/test/fixtures/html/showtimes/11-imax.html +0 -170
  107. data/test/fixtures/html/showtimes/171-d-box.html +0 -203
  108. data/test/fixtures/html/showtimes/71-0.html +0 -59
  109. data/test/fixtures/html/showtimes/71.html +0 -2395
  110. data/test/fixtures/html/sitemap.html +0 -1303
  111. data/test/lib/odeon_uk/api/cinema_test.rb +0 -165
  112. data/test/lib/odeon_uk/api/screenings_test.rb +0 -58
  113. data/test/lib/odeon_uk/configuration_test.rb +0 -29
  114. data/test/lib/odeon_uk/html/cinema_test.rb +0 -149
  115. data/test/lib/odeon_uk/html/parser/film_with_screenings_test.rb +0 -97
  116. data/test/lib/odeon_uk/html/screenings_test.rb +0 -44
  117. data/test/lib/odeon_uk/html/website_test.rb +0 -67
  118. data/test/lib/odeon_uk/screening_test.rb +0 -92
  119. data/test/support/website_fixtures_helper.rb +0 -30
@@ -1,165 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- describe OdeonUk::Api::Cinema do
4
- include ApiFixturesHelper
5
-
6
- let(:described_class) { OdeonUk::Api::Cinema }
7
-
8
- let(:response) { Minitest::Mock.new }
9
-
10
- before do
11
- WebMock.disable_net_connect!
12
- end
13
-
14
- describe '.ids' do
15
- subject { described_class.ids }
16
-
17
- before do
18
- response.expect(:all_cinemas, parse(all_cinemas_plist))
19
- end
20
-
21
- it 'returns an Array of integers' do
22
- OdeonUk::Api::Response.stub :new, response do
23
- subject.must_be_instance_of(Array)
24
- subject.each do |value|
25
- value.must_be_instance_of(Fixnum)
26
- end
27
- end
28
- end
29
-
30
- it 'returns the correctly sized array' do
31
- OdeonUk::Api::Response.stub :new, response do
32
- subject.size.must_equal 115
33
- end
34
- end
35
- end
36
-
37
- describe '.new(id)' do
38
- subject { described_class.new(id) }
39
-
40
- describe 'Brighton' do
41
- let(:id) { 71 }
42
-
43
- it 'returns a cinema' do
44
- subject.must_be_instance_of(described_class)
45
- subject.id.must_equal(id)
46
- end
47
- end
48
- end
49
-
50
- describe '#name' do
51
- subject { described_class.new(id).name }
52
-
53
- before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
54
-
55
- describe 'Brighton' do
56
- let(:id) { 71 }
57
-
58
- it 'returns cinema name' do
59
- OdeonUk::Api::Response.stub :new, response do
60
- subject.must_equal 'Brighton'
61
- end
62
- end
63
- end
64
-
65
- describe 'Leicester Square' do
66
- let(:id) { 105 }
67
-
68
- it 'returns cinema name' do
69
- OdeonUk::Api::Response.stub :new, response do
70
- subject.must_equal 'London - Leicester Square'
71
- end
72
- end
73
- end
74
- end
75
-
76
- describe '#locality' do
77
- subject { described_class.new(id).locality }
78
-
79
- before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
80
-
81
- describe 'Short Address (Brighton)' do
82
- let(:id) { 71 }
83
-
84
- before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
85
-
86
- it 'returns town name' do
87
- OdeonUk::Api::Response.stub :new, response do
88
- subject.must_equal 'Brighton'
89
- end
90
- end
91
- end
92
- end
93
-
94
- describe '#postal_code' do
95
- subject { described_class.new(id).postal_code }
96
-
97
- describe 'short address' do
98
- let(:id) { 71 }
99
-
100
- before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
101
-
102
- it 'returns the postcode' do
103
- OdeonUk::Api::Response.stub :new, response do
104
- subject.must_equal 'BN1 2RE'
105
- end
106
- end
107
- end
108
-
109
- describe 'short address (London)' do
110
- let(:id) { 211 }
111
-
112
- before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
113
-
114
- it 'returns the postcode' do
115
- OdeonUk::Api::Response.stub :new, response do
116
- subject.must_equal 'SE1 8XR'
117
- end
118
- end
119
- end
120
-
121
- describe 'short address (extra London Postcode)' do
122
- let(:id) { 105 }
123
-
124
- before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
125
-
126
- it 'returns the postcode' do
127
- OdeonUk::Api::Response.stub :new, response do
128
- subject.must_equal 'WC2H 7LQ'
129
- end
130
- end
131
- end
132
- end
133
-
134
- describe '#street_address' do
135
- subject { described_class.new(id).street_address }
136
-
137
- describe 'short address' do
138
- let(:id) { 71 }
139
-
140
- before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
141
-
142
- it 'returns first line of address' do
143
- OdeonUk::Api::Response.stub :new, response do
144
- subject.must_equal 'Kingswest'
145
- end
146
- end
147
- end
148
- end
149
-
150
- describe '#url' do
151
- subject { described_class.new(id).url }
152
-
153
- describe 'short address' do
154
- let(:id) { 71 }
155
-
156
- before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
157
-
158
- it 'returns first line of address' do
159
- OdeonUk::Api::Response.stub :new, response do
160
- subject.must_equal 'http://www.odeon.co.uk/cinemas/brighton/71/'
161
- end
162
- end
163
- end
164
- end
165
- end
@@ -1,58 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- describe OdeonUk::Api::Screenings do
4
- include ApiFixturesHelper
5
-
6
- let(:described_class) { OdeonUk::Api::Screenings }
7
-
8
- before { WebMock.disable_net_connect! }
9
-
10
- describe '.at(cinema_id)' do
11
- subject { described_class.at(71) }
12
-
13
- before do
14
- stub_post('app-init', nil, app_init_plist)
15
- film_times_plists(71).each do |name|
16
- film_id = name.match(/(\d+)\.plist/)[1]
17
- stub_post('film-times',
18
- { s: '71', m: film_id },
19
- film_times_plist(71, film_id))
20
- end
21
- end
22
-
23
- it 'returns an array of screening attributes as hashes' do
24
- subject.must_be_instance_of(Array)
25
- subject.each do |screening|
26
- screening.must_be_instance_of(Hash)
27
- screening.keys.must_include(:film_name)
28
-
29
- screening.keys.must_include(:time)
30
- screening[:time].must_be_instance_of(Time)
31
-
32
- screening.keys.must_include(:variant)
33
- screening[:variant].must_be_instance_of(Array)
34
-
35
- screening.keys.must_include(:dimension)
36
- screening[:dimension].must_match(/[23]d/)
37
- end
38
- end
39
-
40
- it 'returns at least some non-empty variants' do
41
- variants = subject.map { |screening| screening[:variant] }
42
- variants.select { |v| !v.empty? }.count.must_be :>, 0
43
- end
44
-
45
- it 'returns valid variant types' do
46
- variants = subject.map { |screening| screening[:variant] }
47
- variants.each do |v|
48
- if v.length > 0
49
- v.each { |e| %w(arts kids imax baby senior).must_include(e) }
50
- end
51
- end
52
- end
53
-
54
- it 'returns correct number of screenings' do
55
- subject.count.must_equal 159
56
- end
57
- end
58
- end
@@ -1,29 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- describe OdeonUk do
4
- describe '.configuration' do
5
- describe '.method' do
6
- it 'sets default value' do
7
- OdeonUk.configuration.method.must_equal(:html)
8
- end
9
- end
10
- end
11
-
12
- describe '.configure' do
13
- before do
14
- OdeonUk.configure do |config|
15
- config.method = :api
16
- end
17
- end
18
-
19
- after do
20
- OdeonUk.configure do |config|
21
- config.method = :html
22
- end
23
- end
24
-
25
- it 'sets the small words for the gem to downcase' do
26
- OdeonUk.configuration.method.must_equal(:api)
27
- end
28
- end
29
- end
@@ -1,149 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- describe OdeonUk::Html::Cinema do
4
- include WebsiteFixturesHelper
5
-
6
- let(:described_class) { OdeonUk::Html::Cinema }
7
-
8
- let(:website) { Minitest::Mock.new }
9
-
10
- before do
11
- WebMock.disable_net_connect!
12
- end
13
-
14
- describe '.ids' do
15
- subject { described_class.ids }
16
-
17
- before do
18
- website.expect(:sitemap, sitemap_html)
19
- end
20
-
21
- it 'returns an Array of OdeonUk::Html::Cinemas' do
22
- OdeonUk::Html::Website.stub :new, website do
23
- subject.must_be_instance_of(Array)
24
- subject.each do |value|
25
- value.must_be_instance_of(Fixnum)
26
- end
27
- end
28
- end
29
-
30
- it 'returns the correctly sized array' do
31
- OdeonUk::Html::Website.stub :new, website do
32
- subject.size.must_equal 115
33
- end
34
- end
35
- end
36
-
37
- describe '.new(id)' do
38
- subject { described_class.new(id) }
39
-
40
- describe 'Brighton' do
41
- let(:id) { 71 }
42
-
43
- it 'returns a cinema' do
44
- subject.must_be_instance_of(described_class)
45
- subject.id.must_equal(id)
46
- end
47
- end
48
- end
49
-
50
- describe '#name' do
51
- subject { described_class.new(id).name }
52
-
53
- before { website.expect(:sitemap, sitemap_html) }
54
-
55
- describe 'Brighton' do
56
- let(:id) { 71 }
57
-
58
- it 'returns cinema name' do
59
- OdeonUk::Html::Website.stub :new, website do
60
- subject.must_equal 'Brighton'
61
- end
62
- end
63
- end
64
-
65
- describe 'Leicester Square' do
66
- let(:id) { 105 }
67
-
68
- it 'returns cinema name' do
69
- OdeonUk::Html::Website.stub :new, website do
70
- subject.must_equal 'London - Leicester Square'
71
- end
72
- end
73
- end
74
- end
75
-
76
- describe '#locality' do
77
- subject { described_class.new(id).locality }
78
-
79
- before { website.expect(:sitemap, sitemap_html) }
80
-
81
- describe 'Short Address (Brighton)' do
82
- let(:id) { 71 }
83
-
84
- before { website.expect(:cinema, cinema_html(71), [71]) }
85
-
86
- it 'returns town name' do
87
- OdeonUk::Html::Website.stub :new, website do
88
- subject.must_equal 'Brighton'
89
- end
90
- end
91
- end
92
- end
93
-
94
- describe '#postal_code' do
95
- subject { described_class.new(id).postal_code }
96
-
97
- describe 'short address' do
98
- let(:id) { 71 }
99
-
100
- before { website.expect(:cinema, cinema_html(71), [71]) }
101
-
102
- it 'returns the postcode' do
103
- OdeonUk::Html::Website.stub :new, website do
104
- subject.must_equal 'BN1 2RE'
105
- end
106
- end
107
- end
108
-
109
- describe 'short address (London)' do
110
- let(:id) { 211 }
111
-
112
- before { website.expect(:cinema, cinema_html(211), [211]) }
113
-
114
- it 'returns the postcode' do
115
- OdeonUk::Html::Website.stub :new, website do
116
- subject.must_equal 'SE1 8XR'
117
- end
118
- end
119
- end
120
-
121
- describe 'short address (extra London Postcode)' do
122
- let(:id) { 105 }
123
-
124
- before { website.expect(:cinema, cinema_html(105), [105]) }
125
-
126
- it 'returns the postcode' do
127
- OdeonUk::Html::Website.stub :new, website do
128
- subject.must_equal 'WC2H 7LQ'
129
- end
130
- end
131
- end
132
- end
133
-
134
- describe '#street_address' do
135
- subject { described_class.new(id).street_address }
136
-
137
- describe 'short address' do
138
- let(:id) { 71 }
139
-
140
- before { website.expect(:cinema, cinema_html(71), [71]) }
141
-
142
- it 'returns first line of address' do
143
- OdeonUk::Html::Website.stub :new, website do
144
- subject.must_equal 'Kingswest'
145
- end
146
- end
147
- end
148
- end
149
- end
@@ -1,97 +0,0 @@
1
- require_relative '../../../../test_helper'
2
-
3
- describe OdeonUk::Html::Parser::FilmWithScreenings do
4
- include WebsiteFixturesHelper
5
-
6
- let(:described_class) { OdeonUk::Html::Parser::FilmWithScreenings }
7
-
8
- describe '#film_name' do
9
- subject { described_class.new(film_html).film_name }
10
-
11
- describe 'passed film html' do
12
- let(:film_html) { showtimes_html('71-0') }
13
-
14
- it 'returns film name' do
15
- subject.must_equal 'Home'
16
- end
17
- end
18
- end
19
-
20
- describe '#to_a' do
21
- subject { described_class.new(film_html).to_a }
22
-
23
- describe 'passed film html' do
24
- let(:film_html) { showtimes_html('71-0') }
25
-
26
- it 'returns an array of hashes of screening attributes' do
27
- subject.must_be_instance_of Array
28
- subject.each do |hash|
29
- hash[:booking_url].must_match 'https://www.odeon.co.uk/'
30
- hash[:dimension].must_match(/[23]d/)
31
- hash[:film_name].must_be_instance_of String
32
- hash[:time].must_be_instance_of Time
33
- hash[:time].zone.must_equal 'UTC'
34
- end
35
- end
36
-
37
- it 'returns the same film title' do
38
- first_title = subject[0][:film_name]
39
- subject.each do |hash|
40
- hash[:film_name].must_equal first_title
41
- end
42
- end
43
-
44
- it 'returns at least 1' do
45
- subject.count.must_be :>=, 1
46
- end
47
- end
48
-
49
- describe 'passed imax film html' do
50
- let(:film_html) { showtimes_html('11-imax') }
51
-
52
- it 'returns an array of hashes of screening attributes' do
53
- subject.must_be_instance_of Array
54
- subject.each do |hash|
55
- hash[:booking_url].must_match 'https://www.odeon.co.uk/'
56
- hash[:dimension].must_match(/[23]d/)
57
- hash[:film_name].must_be_instance_of String
58
- hash[:time].must_be_instance_of Time
59
- hash[:time].zone.must_equal 'UTC'
60
- end
61
- end
62
-
63
- it 'contains imax in the variant' do
64
- variants = subject.map { |hash| hash[:variant] }
65
- variants.must_include('imax')
66
- end
67
-
68
- it 'returns at least 1' do
69
- subject.count.must_be :>=, 1
70
- end
71
- end
72
-
73
- describe 'passed d-box film html' do
74
- let(:film_html) { showtimes_html('171-d-box') }
75
-
76
- it 'returns an array of hashes of screening attributes' do
77
- subject.must_be_instance_of Array
78
- subject.each do |hash|
79
- hash[:booking_url].must_match 'https://www.odeon.co.uk/'
80
- hash[:dimension].must_match(/[23]d/)
81
- hash[:film_name].must_be_instance_of String
82
- hash[:time].must_be_instance_of Time
83
- hash[:time].zone.must_equal 'UTC'
84
- end
85
- end
86
-
87
- it 'contains d-box in the variant' do
88
- variants = subject.map { |hash| hash[:variant] }
89
- variants.must_include('d-box')
90
- end
91
-
92
- it 'returns at least 1' do
93
- subject.count.must_be :>=, 1
94
- end
95
- end
96
- end
97
- end