vue_uk 1.0.0 → 1.2.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +8 -2
- data/lib/vue_uk/cinema.rb +43 -4
- data/lib/vue_uk/internal/parser/api/showtime.rb +1 -0
- data/lib/vue_uk/performance.rb +1 -0
- data/lib/vue_uk/version.rb +2 -2
- data/test/fixtures/website/cinema-10051.html +1 -1
- data/test/lib/vue_uk/cinema_test.rb +57 -0
- data/test/lib/vue_uk/internal/parser/api/showtime_test.rb +11 -2
- data/test/live/integration_test.rb +7 -0
- data/test/support/api_shapes.rb +2 -0
- data/vue_uk.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 88bda243853ffd571e0ed3fe5a688f340ff3edd95586cf444a9ed2fc4ce05af1
|
|
4
|
+
data.tar.gz: d751d0add3165400fce6e0f19b5c5d3a2640294e907b2b82a8b742ee9eb2c83a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1aeb6c8e255951093f821ee9eb150bfee69adb819c3011680f8cfdbc16214b7d4c8768219ac93d0c5504c73cf8aec96e114feaeb853da410b10febff6365876
|
|
7
|
+
data.tar.gz: a353cf8054688f3dee3f85eae915d06f4e4f9991c15780004f9eec59c714a972b877550380126145903d7e6e2fa459e0aca9d0c90ea1a8d7111d38863cadfec0
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [1.2.0] - 2026-11-03
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Uses cinebase 5.9: performances take the raw `title:`, so audience labels become variants, and series prefixes such as `Met Opera:` become the performance's `event`.
|
|
9
|
+
|
|
10
|
+
## [1.1.0] - 2026-10-31
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Cinema#latitude` and `Cinema#longitude` as Floats in decimal degrees, read from `cinemaLocationCoordinates` on the cinema's page like its address. They are `nil` when the page has no readable coordinates or they are 0, 0.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- The cinema list is fetched again after an hour (`Cinema::CACHE_TTL`), so a long-running process sees cinemas Vue opens or closes.
|
|
17
|
+
|
|
5
18
|
## [1.0.0] - 2026-10-22
|
|
6
19
|
|
|
7
20
|
### Added
|
data/README.md
CHANGED
|
@@ -30,8 +30,8 @@ once if the API rejects it.
|
|
|
30
30
|
### Cinema
|
|
31
31
|
|
|
32
32
|
Only UK cinemas are returned; Vue's euro-priced cinemas are left out. The API
|
|
33
|
-
has no addresses, so the first call to an address method
|
|
34
|
-
on myvue.com.
|
|
33
|
+
has no addresses or coordinates, so the first call to an address method,
|
|
34
|
+
`latitude` or `longitude` reads the cinema's page on myvue.com.
|
|
35
35
|
|
|
36
36
|
``` ruby
|
|
37
37
|
VueUk::Cinema.all
|
|
@@ -59,6 +59,12 @@ cinema.full_name
|
|
|
59
59
|
cinema.id
|
|
60
60
|
#=> '10051'
|
|
61
61
|
|
|
62
|
+
cinema.latitude
|
|
63
|
+
#=> 53.754874975913864
|
|
64
|
+
|
|
65
|
+
cinema.longitude
|
|
66
|
+
#=> -2.369161692538972
|
|
67
|
+
|
|
62
68
|
cinema.url
|
|
63
69
|
#=> 'https://www.myvue.com/cinema/accrington'
|
|
64
70
|
```
|
data/lib/vue_uk/cinema.rb
CHANGED
|
@@ -10,9 +10,14 @@ module VueUk
|
|
|
10
10
|
# A county and postcode on one line, e.g. 'Essex CO4 5UP'
|
|
11
11
|
REGION_AND_POSTCODE = /\A(.+?)\s+([A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2})\z/i.freeze
|
|
12
12
|
|
|
13
|
-
# Map coordinates
|
|
13
|
+
# Map coordinates, as on each cinema page and in place of a postcode in
|
|
14
|
+
# some addresses
|
|
14
15
|
COORDINATES = /\A-?\d+(\.\d+)?,\s*-?\d+(\.\d+)?\z/.freeze
|
|
15
16
|
|
|
17
|
+
# Seconds the cinema list is kept, so a long-running process sees
|
|
18
|
+
# cinemas Vue opens or closes
|
|
19
|
+
CACHE_TTL = 3600
|
|
20
|
+
|
|
16
21
|
# Constructor
|
|
17
22
|
# @param [Integer, String] id the cinema id of the format 10051/'10051'
|
|
18
23
|
# @return [VueUk::Cinema]
|
|
@@ -75,6 +80,24 @@ module VueUk
|
|
|
75
80
|
'Vue'.freeze
|
|
76
81
|
end
|
|
77
82
|
|
|
83
|
+
# Latitude of the cinema, read from its page on the Vue website
|
|
84
|
+
# @return [Float, nil] decimal degrees, or nil when unknown
|
|
85
|
+
# @example
|
|
86
|
+
# VueUk::Cinema.new(10051).latitude
|
|
87
|
+
# #=> 53.754874975913864
|
|
88
|
+
def latitude
|
|
89
|
+
coordinates&.first
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Longitude of the cinema, read from its page on the Vue website
|
|
93
|
+
# @return [Float, nil] decimal degrees, or nil when unknown
|
|
94
|
+
# @example
|
|
95
|
+
# VueUk::Cinema.new(10051).longitude
|
|
96
|
+
# #=> -2.369161692538972
|
|
97
|
+
def longitude
|
|
98
|
+
coordinates&.last
|
|
99
|
+
end
|
|
100
|
+
|
|
78
101
|
# The name of the cinema
|
|
79
102
|
# @return [String]
|
|
80
103
|
# @example
|
|
@@ -93,17 +116,20 @@ module VueUk
|
|
|
93
116
|
# @api private
|
|
94
117
|
# Leaves out Vue's euro-priced cinemas outside the UK.
|
|
95
118
|
def self.cinemas_hash
|
|
96
|
-
@cinemas_hash
|
|
119
|
+
if @cinemas_hash.nil? || Time.now - @cinemas_fetched_at > CACHE_TTL
|
|
120
|
+
@cinemas_hash = VueUk::Internal::ApiResponse.new.cinemas
|
|
97
121
|
.select { |cinema| cinema['venueCurrency'] == 'GBP' }
|
|
98
122
|
.to_h { |cinema| [cinema.fetch('cinemaId'), cinema] }
|
|
123
|
+
@cinemas_fetched_at = Time.now
|
|
124
|
+
end
|
|
125
|
+
@cinemas_hash
|
|
99
126
|
end
|
|
100
127
|
private_class_method :cinemas_hash
|
|
101
128
|
|
|
102
129
|
private
|
|
103
130
|
|
|
104
131
|
def address_lines
|
|
105
|
-
|
|
106
|
-
@page.dig('cinemaAddress', 'value').to_s.split(/\r?\n/)
|
|
132
|
+
page.dig('cinemaAddress', 'value').to_s.split(/\r?\n/)
|
|
107
133
|
.map { |line| line.strip.sub(/,\s*(UK|United Kingdom)\z/i, '') }
|
|
108
134
|
.reject { |line| line.empty? || line.match?(COORDINATES) }
|
|
109
135
|
end
|
|
@@ -111,5 +137,18 @@ module VueUk
|
|
|
111
137
|
def cinema_hash
|
|
112
138
|
@cinema_hash ||= self.class.send(:cinemas_hash).fetch(id, {})
|
|
113
139
|
end
|
|
140
|
+
|
|
141
|
+
# 0, 0 marks a cinema whose position was never set
|
|
142
|
+
def coordinates
|
|
143
|
+
value = page.dig('cinemaLocationCoordinates', 'value').to_s.strip
|
|
144
|
+
if value.match?(COORDINATES)
|
|
145
|
+
pair = value.split(',').map(&:to_f)
|
|
146
|
+
pair if pair.any?(&:nonzero?)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def page
|
|
151
|
+
@page ||= VueUk::Internal::Website.new.cinema(cinema_hash.fetch('whatsOnUrl'))
|
|
152
|
+
end
|
|
114
153
|
end
|
|
115
154
|
end
|
|
@@ -44,6 +44,7 @@ module VueUk
|
|
|
44
44
|
film_year: Cinebase::TitleSanitizer.film_year(title),
|
|
45
45
|
language: attribute_names.find { |name| LANGUAGES.include?(name) },
|
|
46
46
|
starting_at: starting_at,
|
|
47
|
+
title: title,
|
|
47
48
|
variant: attribute_names.filter_map { |name| VARIANTS[name] }.uniq
|
|
48
49
|
}
|
|
49
50
|
end
|
data/lib/vue_uk/performance.rb
CHANGED
|
@@ -23,6 +23,7 @@ module VueUk
|
|
|
23
23
|
# @option options [Integer] :film_year (nil) year from the film's title
|
|
24
24
|
# @option options [String] :language (nil) audio language, e.g. 'English'
|
|
25
25
|
# @option options [Time] :starting_at listed start time of the performance
|
|
26
|
+
# @option options [String] :title (nil) raw film title, read for audience labels
|
|
26
27
|
|
|
27
28
|
# Performances within an inclusive range of showing dates, from one request
|
|
28
29
|
# for all of the cinema's advertised dates.
|
data/lib/vue_uk/version.rb
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
<head><title>Vue Accrington</title></head>
|
|
4
4
|
<body>
|
|
5
5
|
<div id="__next"></div>
|
|
6
|
-
<script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"layoutData":{"sitecore":{"context":{"cinema":{"cinemaId":{"value":"10051"},"cinemaName":{"value":"Accrington"},"cinemaAddress":{"value":"1 Example Viaduct\r\nExample Road\r\nAccrington\r\nBB5 0ZZ "}}}}}}}}</script>
|
|
6
|
+
<script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"layoutData":{"sitecore":{"context":{"cinema":{"cinemaId":{"value":"10051"},"cinemaName":{"value":"Accrington"},"cinemaLocationCoordinates":{"value":"53.7548, -2.3691"},"cinemaAddress":{"value":"1 Example Viaduct\r\nExample Road\r\nAccrington\r\nBB5 0ZZ "}}}}}}}}</script>
|
|
7
7
|
</body>
|
|
8
8
|
</html>
|
|
@@ -19,6 +19,22 @@ class VueUk::CinemaTest < Minitest::Test
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def test_cinema_list_expires_after_cache_ttl
|
|
23
|
+
requests = 0
|
|
24
|
+
new_api = lambda do
|
|
25
|
+
requests += 1
|
|
26
|
+
@api_response
|
|
27
|
+
end
|
|
28
|
+
now = Time.now
|
|
29
|
+
|
|
30
|
+
VueUk::Internal::ApiResponse.stub(:new, new_api) do
|
|
31
|
+
Time.stub(:now, now) { 2.times { VueUk::Cinema.all } }
|
|
32
|
+
Time.stub(:now, now + VueUk::Cinema::CACHE_TTL + 1) { VueUk::Cinema.all }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
assert_equal 2, requests
|
|
36
|
+
end
|
|
37
|
+
|
|
22
38
|
def test_name_and_full_name
|
|
23
39
|
with_fakes do
|
|
24
40
|
assert_equal 'Accrington', VueUk::Cinema.new(10051).name
|
|
@@ -91,8 +107,49 @@ class VueUk::CinemaTest < Minitest::Test
|
|
|
91
107
|
assert_equal '255 Example Road', adr[:extended_address]
|
|
92
108
|
end
|
|
93
109
|
|
|
110
|
+
def test_latitude_and_longitude_from_cinema_page
|
|
111
|
+
with_fakes do
|
|
112
|
+
cinema = VueUk::Cinema.new(10051)
|
|
113
|
+
|
|
114
|
+
assert_in_delta 53.7548, cinema.latitude, 0.0001
|
|
115
|
+
assert_in_delta(-2.3691, cinema.longitude, 0.0001)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_latitude_and_longitude_are_nil_without_coordinates
|
|
120
|
+
cinema = cinema_with_page('cinemaAddress' => { 'value' => '1 Example Viaduct' })
|
|
121
|
+
|
|
122
|
+
assert_nil cinema.latitude
|
|
123
|
+
assert_nil cinema.longitude
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_latitude_and_longitude_are_nil_at_zero_zero
|
|
127
|
+
cinema = cinema_with_page('cinemaLocationCoordinates' => { 'value' => '0, 0' })
|
|
128
|
+
|
|
129
|
+
assert_nil cinema.latitude
|
|
130
|
+
assert_nil cinema.longitude
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_latitude_and_longitude_are_nil_for_unreadable_coordinates
|
|
134
|
+
cinema = cinema_with_page('cinemaLocationCoordinates' => { 'value' => 'Accrington' })
|
|
135
|
+
|
|
136
|
+
assert_nil cinema.latitude
|
|
137
|
+
assert_nil cinema.longitude
|
|
138
|
+
end
|
|
139
|
+
|
|
94
140
|
private
|
|
95
141
|
|
|
142
|
+
def cinema_with_page(page)
|
|
143
|
+
website = Object.new
|
|
144
|
+
website.define_singleton_method(:cinema) { |_url| page }
|
|
145
|
+
cinema = VueUk::Cinema.new(10051)
|
|
146
|
+
|
|
147
|
+
VueUk::Internal::ApiResponse.stub(:new, @api_response) do
|
|
148
|
+
VueUk::Internal::Website.stub(:new, website) { cinema.latitude }
|
|
149
|
+
end
|
|
150
|
+
cinema
|
|
151
|
+
end
|
|
152
|
+
|
|
96
153
|
def adr_for(address)
|
|
97
154
|
website = Object.new
|
|
98
155
|
website.define_singleton_method(:cinema) { |_url| { 'cinemaAddress' => { 'value' => address } } }
|
|
@@ -10,6 +10,7 @@ class VueUk::Internal::Parser::Api::ShowtimeTest < Minitest::Test
|
|
|
10
10
|
film_year: 1996,
|
|
11
11
|
language: nil,
|
|
12
12
|
starting_at: Time.utc(2026, 10, 24, 17, 30),
|
|
13
|
+
title: 'From Dusk Till Dawn (1996)',
|
|
13
14
|
variant: []
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -26,19 +27,27 @@ class VueUk::Internal::Parser::Api::ShowtimeTest < Minitest::Test
|
|
|
26
27
|
assert_equal %w(autism_friendly kids), variant
|
|
27
28
|
end
|
|
28
29
|
|
|
30
|
+
def test_performance_reads_audience_label_from_title
|
|
31
|
+
attributes = parse(title: 'Relaxed Screening: Zootropolis 2')
|
|
32
|
+
performance = VueUk::Performance.new(attributes.merge(cinema_id: '10051', cinema_name: 'Accrington'))
|
|
33
|
+
|
|
34
|
+
assert_equal 'Zootropolis 2', performance.film_name
|
|
35
|
+
assert_equal %w(relaxed), performance.variant
|
|
36
|
+
end
|
|
37
|
+
|
|
29
38
|
def test_missing_booking_url
|
|
30
39
|
assert_nil parse(booking_url: nil)[:booking_url]
|
|
31
40
|
end
|
|
32
41
|
|
|
33
42
|
private
|
|
34
43
|
|
|
35
|
-
def parse(attributes: [], booking_url: '/book-tickets/summary/10051/HO1/1')
|
|
44
|
+
def parse(attributes: [], booking_url: '/book-tickets/summary/10051/HO1/1', title: 'From Dusk Till Dawn (1996)')
|
|
36
45
|
session = {
|
|
37
46
|
'bookingUrl' => booking_url,
|
|
38
47
|
'showTimeWithTimeZone' => '2026-10-24T18:30:00+01:00',
|
|
39
48
|
'attributes' => attributes.map { |name| { 'name' => name } }
|
|
40
49
|
}
|
|
41
|
-
film = { 'filmTitle' =>
|
|
50
|
+
film = { 'filmTitle' => title }
|
|
42
51
|
VueUk::Internal::Parser::Api::Showtime.new(session, film: film).to_hash
|
|
43
52
|
end
|
|
44
53
|
end
|
|
@@ -12,6 +12,13 @@ class LiveCinemaTest < Minitest::Test
|
|
|
12
12
|
def test_address_has_a_postcode
|
|
13
13
|
refute_empty VueUk::Cinema.new(10051).postal_code
|
|
14
14
|
end
|
|
15
|
+
|
|
16
|
+
def test_cinema_has_uk_coordinates
|
|
17
|
+
cinema = VueUk::Cinema.new(10051)
|
|
18
|
+
|
|
19
|
+
assert_includes 49.0..61.0, cinema.latitude
|
|
20
|
+
assert_includes(-9.0..2.0, cinema.longitude)
|
|
21
|
+
end
|
|
15
22
|
end
|
|
16
23
|
|
|
17
24
|
class LivePerformanceTest < Minitest::Test
|
data/test/support/api_shapes.rb
CHANGED
|
@@ -34,5 +34,7 @@ module ApiShapes
|
|
|
34
34
|
|
|
35
35
|
def assert_cinema_page_shape(cinema)
|
|
36
36
|
assert_kind_of String, cinema.fetch('cinemaAddress').fetch('value')
|
|
37
|
+
coordinates = cinema.dig('cinemaLocationCoordinates', 'value')
|
|
38
|
+
assert_match(/\A-?\d+(\.\d+)?,\s*-?\d+(\.\d+)?\z/, coordinates.strip) unless coordinates.nil?
|
|
37
39
|
end
|
|
38
40
|
end
|
data/vue_uk.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vue_uk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Croll
|
|
@@ -99,14 +99,14 @@ dependencies:
|
|
|
99
99
|
requirements:
|
|
100
100
|
- - "~>"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '5.
|
|
102
|
+
version: '5.9'
|
|
103
103
|
type: :runtime
|
|
104
104
|
prerelease: false
|
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
|
107
107
|
- - "~>"
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '5.
|
|
109
|
+
version: '5.9'
|
|
110
110
|
description: Pull movie & cinema information from the Vue cinemas website API
|
|
111
111
|
email:
|
|
112
112
|
- andy@goodscary.com
|