cineworld_uk 3.1.0 → 4.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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.agents/setup +51 -0
  3. data/.github/workflows/test.yml +43 -0
  4. data/.gitignore +1 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +21 -0
  7. data/README.md +136 -16
  8. data/Rakefile +5 -37
  9. data/cineworld_uk.gemspec +7 -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/guest_token.rb +73 -0
  13. data/lib/cineworld_uk/internal/parser/api/cinema_address.rb +24 -24
  14. data/lib/cineworld_uk/internal/parser/api/film.rb +10 -8
  15. data/lib/cineworld_uk/internal/parser/api/performance.rb +6 -11
  16. data/lib/cineworld_uk/performance.rb +42 -23
  17. data/lib/cineworld_uk/version.rb +2 -2
  18. data/lib/cineworld_uk.rb +12 -2
  19. data/tasks/package.rake +84 -0
  20. data/test/fixtures/api/cinema-list.json +1 -1
  21. data/test/fixtures/api/dates-14.json +1 -0
  22. data/test/fixtures/api/performances-tomorrow-14.json +1 -0
  23. data/test/fixtures/api/vista-showtimes-brighton.json +1 -0
  24. data/test/lib/cineworld_uk/cinema_test.rb +47 -47
  25. data/test/lib/cineworld_uk/internal/api_response_test.rb +177 -58
  26. data/test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb +14 -14
  27. data/test/lib/cineworld_uk/internal/parser/api/film_test.rb +43 -55
  28. data/test/lib/cineworld_uk/internal/parser/api/performance_test.rb +11 -12
  29. data/test/lib/cineworld_uk/internal/title_sanitizer_test.rb +18 -18
  30. data/test/lib/cineworld_uk/performance_test.rb +31 -32
  31. data/test/lib/cineworld_uk/version_test.rb +1 -1
  32. data/test/live/integration_test.rb +9 -9
  33. data/test/package_test.rb +49 -0
  34. data/test/support/fixture_reader.rb +2 -14
  35. data/test/test_helper.rb +3 -2
  36. metadata +65 -36
  37. data/.travis.yml +0 -10
  38. data/lib/cineworld_uk/internal/parser/api/film_lookup.rb +0 -38
  39. data/lib/cineworld_uk/internal/parser/api/performances_by_day.rb +0 -54
  40. data/test/fixtures/api/cinema-detail-10.json +0 -1
  41. data/test/fixtures/api/cinema-detail-21.json +0 -1
  42. data/test/fixtures/api/cinema-detail-3.json +0 -1
  43. data/test/fixtures/api/cinema-detail-96.json +0 -1
  44. data/test/fixtures/api/dates-3.json +0 -1
  45. data/test/fixtures/api/film-list-comingsoon.json +0 -1
  46. data/test/fixtures/api/film-list.json +0 -1
  47. data/test/fixtures/api/performances-tomorrow-3.json +0 -1
  48. data/test/lib/cineworld_uk/internal/parser/api/film_lookup_test.rb +0 -31
@@ -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.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: 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
@@ -80,20 +93,48 @@ dependencies:
80
93
  - - ">="
81
94
  - !ruby/object:Gem::Version
82
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: base64
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.3'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.3'
83
110
  - !ruby/object:Gem::Dependency
84
111
  name: cinebase
85
112
  requirement: !ruby/object:Gem::Requirement
86
113
  requirements:
87
114
  - - "~>"
88
115
  - !ruby/object:Gem::Version
89
- version: 3.0.0
116
+ version: '5.0'
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: 3.0.0
123
+ version: '5.0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: nokogiri
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '1.11'
131
+ type: :runtime
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '1.11'
97
138
  description: Pull movie & cinema information from the Cineworld iOS API
98
139
  email:
99
140
  - andy@goodscary.com
@@ -101,8 +142,10 @@ executables: []
101
142
  extensions: []
102
143
  extra_rdoc_files: []
103
144
  files:
145
+ - ".agents/setup"
146
+ - ".github/workflows/test.yml"
104
147
  - ".gitignore"
105
- - ".travis.yml"
148
+ - ".ruby-version"
106
149
  - CHANGELOG.md
107
150
  - COMM-LICENSE
108
151
  - Gemfile
@@ -113,33 +156,28 @@ files:
113
156
  - lib/cineworld_uk.rb
114
157
  - lib/cineworld_uk/cinema.rb
115
158
  - lib/cineworld_uk/internal/api_response.rb
159
+ - lib/cineworld_uk/internal/guest_token.rb
116
160
  - lib/cineworld_uk/internal/parser/api/cinema_address.rb
117
161
  - lib/cineworld_uk/internal/parser/api/film.rb
118
- - lib/cineworld_uk/internal/parser/api/film_lookup.rb
119
162
  - lib/cineworld_uk/internal/parser/api/performance.rb
120
- - lib/cineworld_uk/internal/parser/api/performances_by_day.rb
121
163
  - lib/cineworld_uk/internal/title_sanitizer.rb
122
164
  - lib/cineworld_uk/performance.rb
123
165
  - 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
166
+ - tasks/package.rake
128
167
  - 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
168
+ - test/fixtures/api/dates-14.json
169
+ - test/fixtures/api/performances-tomorrow-14.json
170
+ - test/fixtures/api/vista-showtimes-brighton.json
133
171
  - test/lib/cineworld_uk/cinema_test.rb
134
172
  - test/lib/cineworld_uk/internal/api_response_test.rb
135
173
  - test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb
136
- - test/lib/cineworld_uk/internal/parser/api/film_lookup_test.rb
137
174
  - test/lib/cineworld_uk/internal/parser/api/film_test.rb
138
175
  - test/lib/cineworld_uk/internal/parser/api/performance_test.rb
139
176
  - test/lib/cineworld_uk/internal/title_sanitizer_test.rb
140
177
  - test/lib/cineworld_uk/performance_test.rb
141
178
  - test/lib/cineworld_uk/version_test.rb
142
179
  - test/live/integration_test.rb
180
+ - test/package_test.rb
143
181
  - test/support/fixture_reader.rb
144
182
  - test/test_helper.rb
145
183
  homepage: https://github.com/andycroll/cineworld_uk
@@ -147,7 +185,6 @@ licenses:
147
185
  - AGPL
148
186
  - MIT
149
187
  metadata: {}
150
- post_install_message:
151
188
  rdoc_options: []
152
189
  require_paths:
153
190
  - lib
@@ -162,31 +199,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
199
  - !ruby/object:Gem::Version
163
200
  version: '0'
164
201
  requirements: []
165
- rubyforge_project:
166
- rubygems_version: 2.4.5
167
- signing_key:
202
+ rubygems_version: 3.6.9
168
203
  specification_version: 4
169
204
  summary: It's a scraper, but a nice one
170
205
  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
206
  - 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
207
+ - test/fixtures/api/dates-14.json
208
+ - test/fixtures/api/performances-tomorrow-14.json
209
+ - test/fixtures/api/vista-showtimes-brighton.json
180
210
  - test/lib/cineworld_uk/cinema_test.rb
181
211
  - test/lib/cineworld_uk/internal/api_response_test.rb
182
212
  - test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb
183
- - test/lib/cineworld_uk/internal/parser/api/film_lookup_test.rb
184
213
  - test/lib/cineworld_uk/internal/parser/api/film_test.rb
185
214
  - test/lib/cineworld_uk/internal/parser/api/performance_test.rb
186
215
  - test/lib/cineworld_uk/internal/title_sanitizer_test.rb
187
216
  - test/lib/cineworld_uk/performance_test.rb
188
217
  - test/lib/cineworld_uk/version_test.rb
189
218
  - test/live/integration_test.rb
219
+ - test/package_test.rb
190
220
  - test/support/fixture_reader.rb
191
221
  - 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"]}