light_uk 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c9bb0ab361b32336420505a03f2ee0427d0cbf16cc4c0110c3362a349fe1345
4
- data.tar.gz: e0551e3538c344043e0795f71f55d84f3054875770112cfa86eeb7ae03a5f175
3
+ metadata.gz: 26ee411f964fa6a7ecced3b1f759b88189960426e5bace3c168182b67a771ba3
4
+ data.tar.gz: a0bdcb97b4a2dd9f033f0ea227b7188af77aa9190d00aa306048365ba1f3e90e
5
5
  SHA512:
6
- metadata.gz: c119d12a4f8d60ddfed3443878c9e05b79305f7d549ff92da36ea0e6ec4aca564105727f340bf172e28f1a35908a1770056a23c2a87fdd5fcf7a145bf7adf67d
7
- data.tar.gz: d9721d693df1de415e0ba43ffd621c8ab7841c716fbabf5e6accf4f71e97b6ffc8177ab66912329a68ff08bae290b54ffb520c1c6dd204821c6993baf8d925ca
6
+ metadata.gz: ca1717fd43440d750cee63f401b9e8fb28cf9444635917cfbf58baa15f4eeab46e123203284edad90dc162525f622f9c69bd6e17e15e573f92ebfead4b8570db
7
+ data.tar.gz: 9ed2fa1aeea042358034d36d746e5c581a17c45c1ea716258843ea9fa6adc01153cc5bc02b9411311a7ce1aaf3031190c43786d636127ae9b50871397381bb59
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
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.0.1] - 2026-11-02
6
+
7
+ ### Changed
8
+ - Requests and London times use cinebase 5.8's `Cinebase::Http` and `Cinebase::London`.
9
+ - Requests retry dropped connections twice.
10
+ - HTTP errors read "HTTP error 500 from cambridge.thelight.co.uk" instead of "Light HTTP error 500".
11
+
5
12
  ## [1.0.0] - 2026-10-31
6
13
 
7
14
  ### Added
@@ -33,7 +33,6 @@ module LightUk
33
33
  IMAX = /\bIMAX\b/i
34
34
 
35
35
  LANGUAGE = /\((#{Cinebase::TitleSanitizer::LANGUAGES.join('|')})\)/i
36
- TIME_ZONE = "Europe/London"
37
36
 
38
37
  # @param [Hash] session one session
39
38
  # @param [Hash] film the film the session shows
@@ -78,7 +77,7 @@ module LightUk
78
77
  year, month, day = @date.fetch("Key").unpack("a4a2a2").map(&:to_i)
79
78
  hour, minute = @session.fetch("Display").scan(/\d+/).map(&:to_i)
80
79
  local = Time.utc(year, month, day, hour, minute)
81
- TZInfo::Timezone.get(TIME_ZONE).local_to_utc(local) { |periods| periods.first }.utc
80
+ Cinebase::London.utc(local)
82
81
  end
83
82
  end
84
83
 
@@ -8,24 +8,26 @@ module LightUk
8
8
  module Internal
9
9
  # Reads venues and listings from the Light websites, one per venue
10
10
  class Website
11
- include Http
12
-
13
11
  # Every venue's home page lists all the venues
14
12
  SITES_URL = "https://sheffield.thelight.co.uk/"
15
13
  MINIGUIDE_PATH = "/resource/services/miniguide/data.ashx"
16
14
  COMING_SOON_PATH = "/cinema/comingsoon"
17
15
 
16
+ def initialize
17
+ @http = Cinebase::Http.new
18
+ end
19
+
18
20
  # @return [Array<Hash>] venues, e.g. { 'id' => 7, 'title' => 'Sheffield',
19
21
  # 'url' => 'https://sheffield.thelight.co.uk' }
20
22
  def sites
21
- JSON.parse(get(SITES_URL)[/var __sites = (\[.*?\]);/, 1] || "[]")
23
+ JSON.parse(@http.get(SITES_URL)[/var __sites = (\[.*?\]);/, 1] || "[]")
22
24
  end
23
25
 
24
26
  # @param [String] url a venue's home page
25
27
  # @return [String, nil] the address in the page footer, e.g.
26
28
  # 'The Moor, Sheffield, S1 4PF'
27
29
  def address(url)
28
- address = get(url)[%r{<p class="address">(.*?)</p>}m, 1]
30
+ address = @http.get(url)[%r{<p class="address">(.*?)</p>}m, 1]
29
31
  CGI.unescapeHTML(address).strip if address
30
32
  end
31
33
 
@@ -33,7 +35,7 @@ module LightUk
33
35
  # @param [String] url a venue's home page
34
36
  # @return [Array<Hash>] films with their sessions on each date
35
37
  def miniguide(url)
36
- script = get(URI.join(url, MINIGUIDE_PATH).to_s)
38
+ script = @http.get(URI.join(url, MINIGUIDE_PATH).to_s)
37
39
  JSON.parse(script[/var __gfminiguidedata = (\{.*\});/m, 1] || "{}").fetch("Schedule", [])
38
40
  end
39
41
 
@@ -41,7 +43,7 @@ module LightUk
41
43
  # @param [String] url a venue's home page
42
44
  # @return [Array<Hash>] films in the shape of #miniguide
43
45
  def coming_soon(url)
44
- Parser::ComingSoon.new(get(URI.join(url, COMING_SOON_PATH).to_s)).films
46
+ Parser::ComingSoon.new(@http.get(URI.join(url, COMING_SOON_PATH).to_s)).films
45
47
  end
46
48
  end
47
49
  end
@@ -33,7 +33,7 @@ module LightUk
33
33
  # @return [Array<LightUk::Performance>]
34
34
  def self.at(
35
35
  cinema_id,
36
- from: TZInfo::Timezone.get('Europe/London').now.to_date,
36
+ from: Cinebase::London.today,
37
37
  to: from + 13
38
38
  )
39
39
  raise ArgumentError, 'to must not precede from' if to < from
@@ -1,6 +1,6 @@
1
1
  # Ruby interface for https://thelight.co.uk
2
- # @version 1.0.0
2
+ # @version 1.0.1
3
3
  module LightUk
4
4
  # Gem version
5
- VERSION = '1.0.0'.freeze
5
+ VERSION = '1.0.1'.freeze
6
6
  end
data/lib/light_uk.rb CHANGED
@@ -5,7 +5,6 @@ require 'cinebase'
5
5
 
6
6
  require_relative './light_uk/version'
7
7
 
8
- require_relative './light_uk/internal/http'
9
8
  require_relative './light_uk/internal/website'
10
9
  require_relative './light_uk/internal/title_sanitizer'
11
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: light_uk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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.6'
102
+ version: '5.8'
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.6'
109
+ version: '5.8'
110
110
  description: Pull movie & cinema information from the Light cinemas website
111
111
  email:
112
112
  - andy@goodscary.com
@@ -120,7 +120,6 @@ files:
120
120
  - README.md
121
121
  - lib/light_uk.rb
122
122
  - lib/light_uk/cinema.rb
123
- - lib/light_uk/internal/http.rb
124
123
  - lib/light_uk/internal/parser/coming_soon.rb
125
124
  - lib/light_uk/internal/parser/session.rb
126
125
  - lib/light_uk/internal/title_sanitizer.rb
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "net/http"
4
-
5
- module LightUk
6
- # Internal utility classes: Do not use
7
- # @api private
8
- module Internal
9
- # Requests to thelight.co.uk
10
- module Http
11
- private
12
-
13
- def get(url)
14
- uri = URI(url)
15
- request = Net::HTTP::Get.new(uri)
16
- response = Net::HTTP.start(uri.host, uri.port, use_ssl: true,
17
- open_timeout: 10, read_timeout: 30) do |http|
18
- http.request(request)
19
- end
20
- # Omit response bodies from errors, and never follow redirects.
21
- raise "Light HTTP error #{response.code}" unless response.is_a?(Net::HTTPSuccess)
22
-
23
- String.new(response.body, encoding: Encoding::UTF_8)
24
- end
25
- end
26
- end
27
- end