cineworld_uk 3.1.0 → 4.0.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.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.agents/setup +51 -0
  3. data/.github/workflows/test.yml +17 -0
  4. data/.gitignore +1 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +13 -0
  7. data/README.md +67 -16
  8. data/Rakefile +4 -37
  9. data/cineworld_uk.gemspec +6 -4
  10. data/lib/cineworld_uk/cinema.rb +7 -4
  11. data/lib/cineworld_uk/internal/api_response.rb +99 -56
  12. data/lib/cineworld_uk/internal/parser/api/cinema_address.rb +24 -24
  13. data/lib/cineworld_uk/internal/parser/api/film.rb +10 -8
  14. data/lib/cineworld_uk/internal/parser/api/performance.rb +6 -11
  15. data/lib/cineworld_uk/performance.rb +42 -23
  16. data/lib/cineworld_uk/version.rb +2 -2
  17. data/lib/cineworld_uk.rb +6 -2
  18. data/test/fixtures/api/cinema-list.json +1 -1
  19. data/test/fixtures/api/dates-14.json +1 -0
  20. data/test/fixtures/api/performances-tomorrow-14.json +1 -0
  21. data/test/fixtures/api/vista-showtimes-brighton.json +1 -0
  22. data/test/lib/cineworld_uk/cinema_test.rb +47 -47
  23. data/test/lib/cineworld_uk/internal/api_response_test.rb +111 -68
  24. data/test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb +14 -14
  25. data/test/lib/cineworld_uk/internal/parser/api/film_test.rb +43 -55
  26. data/test/lib/cineworld_uk/internal/parser/api/performance_test.rb +11 -12
  27. data/test/lib/cineworld_uk/internal/title_sanitizer_test.rb +18 -18
  28. data/test/lib/cineworld_uk/performance_test.rb +31 -32
  29. data/test/lib/cineworld_uk/version_test.rb +1 -1
  30. data/test/live/integration_test.rb +9 -9
  31. data/test/support/fixture_reader.rb +2 -14
  32. data/test/test_helper.rb +3 -2
  33. metadata +47 -36
  34. data/.travis.yml +0 -10
  35. data/lib/cineworld_uk/internal/parser/api/film_lookup.rb +0 -38
  36. data/lib/cineworld_uk/internal/parser/api/performances_by_day.rb +0 -54
  37. data/test/fixtures/api/cinema-detail-10.json +0 -1
  38. data/test/fixtures/api/cinema-detail-21.json +0 -1
  39. data/test/fixtures/api/cinema-detail-3.json +0 -1
  40. data/test/fixtures/api/cinema-detail-96.json +0 -1
  41. data/test/fixtures/api/dates-3.json +0 -1
  42. data/test/fixtures/api/film-list-comingsoon.json +0 -1
  43. data/test/fixtures/api/film-list.json +0 -1
  44. data/test/fixtures/api/performances-tomorrow-3.json +0 -1
  45. data/test/lib/cineworld_uk/internal/parser/api/film_lookup_test.rb +0 -31
@@ -6,6 +6,7 @@ Minitest::Reporters.use! [
6
6
  ]
7
7
 
8
8
  require File.expand_path('../../../lib/cineworld_uk.rb', __FILE__)
9
+ CineworldUk.token = ENV.fetch("CINEWORLD_TOKEN")
9
10
 
10
11
  describe CineworldUk::Cinema do
11
12
  let(:described_class) { CineworldUk::Cinema }
@@ -14,19 +15,18 @@ describe CineworldUk::Cinema do
14
15
  subject { described_class.all }
15
16
 
16
17
  it 'returns an Array of CineworldUK::Cinemas' do
17
- subject.must_be_instance_of(Array)
18
+ _(subject).must_be_instance_of(Array)
18
19
  subject.each do |value|
19
- value.must_be_instance_of(CineworldUk::Cinema)
20
+ _(value).must_be_instance_of(CineworldUk::Cinema)
20
21
  end
21
22
  end
22
23
 
23
24
  it 'returns the correctly sized array' do
24
- subject.size.must_be :>, 18
25
+ _(subject.size).must_be :>, 18
25
26
  end
26
27
 
27
28
  it 'returns the right cinemas' do
28
- subject.first.name.must_equal 'Aberdeen: Queens Links'
29
- subject.last.name.must_equal 'Yeovil'
29
+ _(subject.detect { |cinema| cinema.id == 14 }.name).must_equal "Brighton"
30
30
  end
31
31
  end
32
32
  end
@@ -35,17 +35,17 @@ describe CineworldUk::Performance do
35
35
  let(:described_class) { CineworldUk::Performance }
36
36
 
37
37
  describe '.at(cinema_id)' do
38
- subject { described_class.at(3) }
38
+ subject { described_class.at(14, from: Date.today + 1, to: Date.today + 1) }
39
39
 
40
40
  it 'returns an array of screenings' do
41
- subject.must_be_instance_of(Array)
41
+ _(subject).must_be_instance_of(Array)
42
42
  subject.each do |performance|
43
- performance.must_be_instance_of(CineworldUk::Performance)
43
+ _(performance).must_be_instance_of(CineworldUk::Performance)
44
44
  end
45
45
  end
46
46
 
47
47
  it 'returns correct number of screenings' do
48
- subject.count.must_be :>, 10
48
+ _(subject.count).must_be :>, 10
49
49
  end
50
50
  end
51
51
  end
@@ -9,24 +9,12 @@ module Support
9
9
  read_file("#{FIXTURE_PATH}/cinema-list.json")
10
10
  end
11
11
 
12
- def cinema_detail_json(num)
13
- read_file("#{FIXTURE_PATH}/cinema-detail-#{num}.json")
14
- end
15
-
16
12
  def dates_json(num)
17
13
  read_file("#{FIXTURE_PATH}/dates-#{num}.json")
18
14
  end
19
15
 
20
16
  def fake_dates_tomorrow_json
21
- { "dates": [tomorrow_s] }.to_json
22
- end
23
-
24
- def film_list_comingsoon_json
25
- read_file("#{FIXTURE_PATH}/film-list-comingsoon.json")
26
- end
27
-
28
- def film_list_json
29
- read_file("#{FIXTURE_PATH}/film-list.json")
17
+ { "body": { "dates": [tomorrow_s] } }.to_json
30
18
  end
31
19
 
32
20
  def performances_tomorrow_json(num)
@@ -38,7 +26,7 @@ module Support
38
26
  end
39
27
 
40
28
  def tomorrow_s
41
- (Date.today + 1).strftime('%Y%m%d')
29
+ (Date.today + 1).strftime('%Y-%m-%d')
42
30
  end
43
31
  end
44
32
  end
data/test/test_helper.rb CHANGED
@@ -1,7 +1,8 @@
1
- require 'codeclimate-test-reporter'
2
- CodeClimate::TestReporter.start
1
+ require 'simplecov'
2
+ SimpleCov.start
3
3
 
4
4
  require 'minitest/autorun'
5
+ require 'minitest/mock'
5
6
  require 'minitest/reporters'
6
7
  reporter_options = { color: true, slow_count: 5 }
7
8
  Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(reporter_options)]
metadata CHANGED
@@ -1,31 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cineworld_uk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Croll
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2016-09-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '1.3'
18
+ version: '2.0'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '1.3'
25
+ version: '2.0'
27
26
  - !ruby/object:Gem::Dependency
28
- name: codeclimate-test-reporter
27
+ name: minitest-mock
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ">="
@@ -66,6 +65,20 @@ dependencies:
66
65
  - - ">="
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: simplecov
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '1'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '1'
69
82
  - !ruby/object:Gem::Dependency
70
83
  name: webmock
71
84
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +99,28 @@ dependencies:
86
99
  requirements:
87
100
  - - "~>"
88
101
  - !ruby/object:Gem::Version
89
- version: 3.0.0
102
+ version: '5.0'
90
103
  type: :runtime
91
104
  prerelease: false
92
105
  version_requirements: !ruby/object:Gem::Requirement
93
106
  requirements:
94
107
  - - "~>"
95
108
  - !ruby/object:Gem::Version
96
- version: 3.0.0
109
+ version: '5.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: nokogiri
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '1.11'
117
+ type: :runtime
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '1.11'
97
124
  description: Pull movie & cinema information from the Cineworld iOS API
98
125
  email:
99
126
  - andy@goodscary.com
@@ -101,8 +128,10 @@ executables: []
101
128
  extensions: []
102
129
  extra_rdoc_files: []
103
130
  files:
131
+ - ".agents/setup"
132
+ - ".github/workflows/test.yml"
104
133
  - ".gitignore"
105
- - ".travis.yml"
134
+ - ".ruby-version"
106
135
  - CHANGELOG.md
107
136
  - COMM-LICENSE
108
137
  - Gemfile
@@ -115,25 +144,17 @@ files:
115
144
  - lib/cineworld_uk/internal/api_response.rb
116
145
  - lib/cineworld_uk/internal/parser/api/cinema_address.rb
117
146
  - lib/cineworld_uk/internal/parser/api/film.rb
118
- - lib/cineworld_uk/internal/parser/api/film_lookup.rb
119
147
  - lib/cineworld_uk/internal/parser/api/performance.rb
120
- - lib/cineworld_uk/internal/parser/api/performances_by_day.rb
121
148
  - lib/cineworld_uk/internal/title_sanitizer.rb
122
149
  - lib/cineworld_uk/performance.rb
123
150
  - lib/cineworld_uk/version.rb
124
- - test/fixtures/api/cinema-detail-10.json
125
- - test/fixtures/api/cinema-detail-21.json
126
- - test/fixtures/api/cinema-detail-3.json
127
- - test/fixtures/api/cinema-detail-96.json
128
151
  - test/fixtures/api/cinema-list.json
129
- - test/fixtures/api/dates-3.json
130
- - test/fixtures/api/film-list-comingsoon.json
131
- - test/fixtures/api/film-list.json
132
- - test/fixtures/api/performances-tomorrow-3.json
152
+ - test/fixtures/api/dates-14.json
153
+ - test/fixtures/api/performances-tomorrow-14.json
154
+ - test/fixtures/api/vista-showtimes-brighton.json
133
155
  - test/lib/cineworld_uk/cinema_test.rb
134
156
  - test/lib/cineworld_uk/internal/api_response_test.rb
135
157
  - test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb
136
- - test/lib/cineworld_uk/internal/parser/api/film_lookup_test.rb
137
158
  - test/lib/cineworld_uk/internal/parser/api/film_test.rb
138
159
  - test/lib/cineworld_uk/internal/parser/api/performance_test.rb
139
160
  - test/lib/cineworld_uk/internal/title_sanitizer_test.rb
@@ -147,7 +168,6 @@ licenses:
147
168
  - AGPL
148
169
  - MIT
149
170
  metadata: {}
150
- post_install_message:
151
171
  rdoc_options: []
152
172
  require_paths:
153
173
  - lib
@@ -162,25 +182,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
182
  - !ruby/object:Gem::Version
163
183
  version: '0'
164
184
  requirements: []
165
- rubyforge_project:
166
- rubygems_version: 2.4.5
167
- signing_key:
185
+ rubygems_version: 3.6.9
168
186
  specification_version: 4
169
187
  summary: It's a scraper, but a nice one
170
188
  test_files:
171
- - test/fixtures/api/cinema-detail-10.json
172
- - test/fixtures/api/cinema-detail-21.json
173
- - test/fixtures/api/cinema-detail-3.json
174
- - test/fixtures/api/cinema-detail-96.json
175
189
  - test/fixtures/api/cinema-list.json
176
- - test/fixtures/api/dates-3.json
177
- - test/fixtures/api/film-list-comingsoon.json
178
- - test/fixtures/api/film-list.json
179
- - test/fixtures/api/performances-tomorrow-3.json
190
+ - test/fixtures/api/dates-14.json
191
+ - test/fixtures/api/performances-tomorrow-14.json
192
+ - test/fixtures/api/vista-showtimes-brighton.json
180
193
  - test/lib/cineworld_uk/cinema_test.rb
181
194
  - test/lib/cineworld_uk/internal/api_response_test.rb
182
195
  - test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb
183
- - test/lib/cineworld_uk/internal/parser/api/film_lookup_test.rb
184
196
  - test/lib/cineworld_uk/internal/parser/api/film_test.rb
185
197
  - test/lib/cineworld_uk/internal/parser/api/performance_test.rb
186
198
  - test/lib/cineworld_uk/internal/title_sanitizer_test.rb
@@ -189,4 +201,3 @@ test_files:
189
201
  - test/live/integration_test.rb
190
202
  - test/support/fixture_reader.rb
191
203
  - test/test_helper.rb
192
- has_rdoc:
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.4
4
- - 2.3.0
5
- addons:
6
- code_climate:
7
- repo_token: 52f46a80ce5154b027b4ee2f37d8abd7f428e1615a7bdbdfd5d35efd81586c34
8
- notifications:
9
- slack:
10
- secure: Cz8KU8SOjTgtMhU7F9JrlkoxNfvy/gon7rSzcIbMvQZKHwttmaMHrZlX0a+vrKlcVcLMGNzEJFNChNNrnhso4yYPhUwfF8XXbwvC7IwFwOQjx7Nw9GTRP6wZLsLPYg0zcOLlEZBBG3LNfy20D+PnT9/DiuxLcwr7Rb0/ClhHUnE=
@@ -1,38 +0,0 @@
1
- module CineworldUk
2
- # @api private
3
- module Internal
4
- module Parser
5
- module Api
6
- # Parses a string to derive address
7
- class FilmLookup
8
- # @return [Hash{Integer => CineworldUk::Internal::Parser::Api::Film}]
9
- # contains all films & upcoming films keyed by id
10
- def to_hash
11
- @to_hash ||= all_films.each_with_object({}) do |item, lookup|
12
- next if item['edi'].nil?
13
- lookup[item['edi']] = Film.new(item)
14
- end
15
- end
16
-
17
- private
18
-
19
- def all_films
20
- films_data + comingsoon_data
21
- end
22
-
23
- def api
24
- @api ||= CineworldUk::Internal::ApiResponse.new
25
- end
26
-
27
- def comingsoon_data
28
- @comingsoon_data ||= JSON.parse(api.film_list_comingsoon)['films']
29
- end
30
-
31
- def films_data
32
- @films_data ||= JSON.parse(api.film_list)['films']
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,54 +0,0 @@
1
- module CineworldUk
2
- # @api private
3
- module Internal
4
- module Parser
5
- module Api
6
- # A day of performances, a parser for a single API call
7
- class PerformancesByDay
8
- def initialize(cinema_id, date, film_lookup)
9
- @cinema_id = cinema_id
10
- @date = date
11
- @film_lookup = film_lookup
12
- end
13
-
14
- # Details of performance from single day
15
- # @return [Array<Hash>] :booking_url, :dimension, :film_name,
16
- # :starting_at, :variant
17
- def to_a
18
- performances.map do |performance|
19
- film = @film_lookup[performance.film_id]
20
- {
21
- booking_url: performance.booking_url,
22
- dimension: film.dimension,
23
- film_name: film.name,
24
- starting_at: utc(performance.starting_at),
25
- variant: (performance.variant + film.variant).sort
26
- }
27
- end
28
- end
29
-
30
- private
31
-
32
- def performances
33
- parsed_response.map do |hash|
34
- Internal::Parser::Api::Performance.new(hash)
35
- end
36
- end
37
-
38
- def parsed_response
39
- JSON.parse(response)['performances']
40
- end
41
-
42
- def response
43
- Internal::ApiResponse.new.performances(@cinema_id, @date)
44
- end
45
-
46
- def utc(time)
47
- time if time.utc?
48
- TZInfo::Timezone.get('Europe/London').local_to_utc(time)
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1 +0,0 @@
1
- {"cinema":{"id":10,"name":"London - Chelsea","address":"279 Kings Road, Chelsea, London","postcode":"SW3 5EW","tel":"0871 200 2000","services":["con","ns","vh","3d","sb","hfr","etx","ad","dig","gdog","adv"]}}
@@ -1 +0,0 @@
1
- {"cinema":{"id":21,"name":"Edinburgh","address":"Fountain Park, 130/3 Dundee Street, Edinburgh","postcode":"EH11 1AF","tel":"0871 200 2000","services":["con","ns","cb","vh","ix","stb","dba","au","3d","dbp","sb","hfr","etx","ad","dig","m4j","bas","bar","gdog","adv"]}}
@@ -1 +0,0 @@
1
- {"cinema":{"id":3,"name":"Brighton","address":"Brighton Marina Village, Brighton","postcode":"BN2 5UF","tel":"0871 200 2000","services":["con","ns","vh","dba","au","3d","dbp","sb","hfr","etx","ad","dig","m4j","bas","gdog","adv"]}}
@@ -1 +0,0 @@
1
- {"cinema":{"id":96,"name":"Birmingham - NEC","address":"Resorts World, Pendigo Way, Birmingham","postcode":"B40 1PU","tel":"0871 200 2000","services":["con","ns","park","vh","ix","stb","dba","au","3d","dbp","sb","hfr","etx","ad","dig","m4j","bas","gdog","adv"]}}
@@ -1 +0,0 @@
1
- {"dates":["20160911","20160912","20160913","20160914","20160915","20160916","20160917","20160918","20160919","20160920","20160921","20160922","20161002","20161005","20161006","20161007","20161008","20161009","20161010","20161011","20161012","20161013","20161016","20161027","20161117","20161118","20161119","20161120","20161121","20161122","20161123","20161124","20161127"]}