cinebase 5.8.0 → 5.9.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 +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +34 -1
- data/lib/cinebase/a1web/performance.rb +1 -0
- data/lib/cinebase/audience.rb +26 -0
- data/lib/cinebase/boxoffice/performance.rb +1 -0
- data/lib/cinebase/event.rb +32 -0
- data/lib/cinebase/festival.rb +20 -4
- data/lib/cinebase/performance.rb +25 -3
- data/lib/cinebase/title_sanitizer.rb +69 -12
- data/lib/cinebase/version.rb +1 -1
- data/lib/cinebase.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddfc1ea3e2cacacf74828b2e586840907802ca0685fadca5a57aec629144f1d1
|
|
4
|
+
data.tar.gz: dd598494811d3c2c5c62f4774045d84a30790665f17e097fbf14f55d670ee785
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 31bd8500df420827e1fa3ec31f5d58ba89537f17cb6fec9f753f18a7e0188f1369ee4b0822aeb787873e0945eb53c00d0d33a465372df0a1fe677bb862639ad8
|
|
7
|
+
data.tar.gz: 41ef31ab861f2eec0ed0052b35b93a304e0bb5ae058909653df62d9b06cfdab5636aefc1eb948714926ca44ebb9265f934ae7297335267eb55c59d8b53a11092
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
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
|
+
## [5.9.1] - 2026-11-03
|
|
6
|
+
### Fixed
|
|
7
|
+
- Titles with non-breaking spaces now match the common rules and audience labels.
|
|
8
|
+
- `COMMON_REMOVE` also strips presenter credits such as `Bar Trash Presents:`, an anniversary at the end of a title without brackets, `– Live On Stage` with an en dash, Q&A add-ons naming a `Dir.`, and bracketed Q&As.
|
|
9
|
+
|
|
10
|
+
## [5.9.0] - 2026-11-03
|
|
11
|
+
### Added
|
|
12
|
+
- `Cinebase::Event` for opera, ballet, theatre and exhibition screenings. `Performance#event` names the series from the `film_name` prefix the title sanitizer gives, such as `Met Opera: `, and `Performance#film_name` leaves it out.
|
|
13
|
+
- `Cinebase::Audience` reads relaxed, kids, baby, dog-friendly, members and preview labels from a raw title.
|
|
14
|
+
- `Performance` takes the raw `title:`. With it, `#variant` adds audience variants and `#festival` falls back to one named in the title.
|
|
15
|
+
- Festival prefixes for Cinecity, FFF, French Film Fest UK, IFF, Into Film Festival, JFF, LDNDOCS, London Palestine Film Festival, LPFF, NFF, Queer East, RFF, SLA and Women and the World Festival, with or without a year, which may have two digits.
|
|
16
|
+
- Bengali, Gujarati, Japanese, Romanian and Vietnamese language versions.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- `COMMON_REPLACE` names every spelling of a Met Opera, Royal Ballet and Opera, National Theatre Live, Exhibition on Screen or Bolshoi season with one prefix, including Met operas listed in an RBO season.
|
|
20
|
+
- `COMMON_REMOVE` also strips audience labels, festival gala labels, bracketed 3D and 4K, `4K Restoration`, restorations after an anniversary, square-bracketed anniversaries, bracketed encores, `(Recorded)`, `(English Dubbed)`, `- Live On Stage`, and `+ ScreenTalk`, `+ Intro` and `+ Short Film` add-ons.
|
|
21
|
+
- Titles listed in capitals are title cased.
|
|
22
|
+
|
|
5
23
|
## [5.8.0] - 2026-11-02
|
|
6
24
|
### Added
|
|
7
25
|
- `Cinebase::Http` for chain gems' requests: `get`, and `post` with a form or JSON body, over HTTPS. It retries dropped connections twice, never follows redirects, raises errors that name the status and host but leave out the body, and returns bodies as UTF-8. `keep_alive: true` reuses one connection per host until `close`. Tests stub `Cinebase::Http.pause` to skip the waits between attempts.
|
data/README.md
CHANGED
|
@@ -53,7 +53,8 @@ module CinemaChainName
|
|
|
53
53
|
def self.at(cinema_id)
|
|
54
54
|
# parse webpages or apis to get performances for a cinema, built with
|
|
55
55
|
# booking_url:, cinema_id:, cinema_name:, dimension:, festival:,
|
|
56
|
-
# film_name:, film_year:, language:, starting_at:
|
|
56
|
+
# film_name:, film_year:, language:, starting_at:, title: (the raw
|
|
57
|
+
# title) and variant:
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
end
|
|
@@ -93,6 +94,38 @@ Cinebase::Festival.from_title('UKJFF - From Cable Street To Brick Lane', year: 2
|
|
|
93
94
|
|
|
94
95
|
`COMMON_REMOVE` strips the same prefixes from titles.
|
|
95
96
|
|
|
97
|
+
### Stage shows
|
|
98
|
+
|
|
99
|
+
The common rules name opera, ballet, theatre and exhibition screenings with
|
|
100
|
+
one prefix per series, such as `Met Opera: Tosca`. A performance strips it
|
|
101
|
+
from `film_name` and names the series as its `event`, with an `arts` variant:
|
|
102
|
+
|
|
103
|
+
```ruby
|
|
104
|
+
performance = CinemaChainName::Performance.new(film_name: 'Met Opera: Tosca', ...)
|
|
105
|
+
performance.film_name #=> "Tosca"
|
|
106
|
+
performance.event #=> #<data Cinebase::Event name="Met Opera">
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
A chain's own `replace` rules should produce the same prefixes.
|
|
110
|
+
|
|
111
|
+
### Audiences
|
|
112
|
+
|
|
113
|
+
Some chains name relaxed, toddler, parent and baby, dog-friendly, members'
|
|
114
|
+
or preview screenings in the title. `COMMON_REMOVE` strips the label, and a
|
|
115
|
+
performance given `title:` adds the variant:
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
Cinebase::Audience.variants('Relaxed Screening: Wicked') #=> ["relaxed"]
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
A performance given `title:` also finds its festival when not given one.
|
|
122
|
+
|
|
123
|
+
### Titles in capitals
|
|
124
|
+
|
|
125
|
+
A title listed in capitals is title cased, keeping acronyms without vowels,
|
|
126
|
+
Roman numerals and words with digits: `ROCKY IV` reads `Rocky IV`, and
|
|
127
|
+
`BTS 'ARIRANG'` reads `BTS 'Arirang'`.
|
|
128
|
+
|
|
96
129
|
### Film years
|
|
97
130
|
|
|
98
131
|
Titles often end with the film's year. `COMMON_REMOVE` strips it, and
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cinebase
|
|
4
|
+
# Screenings for a particular audience, which some chains name in the title
|
|
5
|
+
module Audience
|
|
6
|
+
SEPARATOR = /\s*[-–:]?\s*/
|
|
7
|
+
|
|
8
|
+
# Title labels, keyed by the variant they mark
|
|
9
|
+
LABELS = {
|
|
10
|
+
'kids' => [/\A(?:Toddler (?:Club|Kino)|Kids'? Club)\s*:\s*/i],
|
|
11
|
+
'relaxed' => [/\ARelaxed(?: Screening)?\s*:\s*/i, /#{SEPARATOR}(?:Sensory|Autism) Friendly Screening\z/i],
|
|
12
|
+
'dog_friendly' => [/\ADog-Friendly Screening\s*:\s*/i],
|
|
13
|
+
'baby' => [/\s*\(Parent (?:&|and) Baby(?: Only Show)?\)/i],
|
|
14
|
+
'members' => [/#{SEPARATOR}(?:Unlimited|MyOmnipass Member) Screening\z/i],
|
|
15
|
+
'preview' => [/\s*[-–]\s*(?:Special )?Preview\z/i]
|
|
16
|
+
}.freeze
|
|
17
|
+
|
|
18
|
+
PATTERNS = LABELS.values.flatten.freeze
|
|
19
|
+
|
|
20
|
+
# @param [String] title raw film title
|
|
21
|
+
# @return [Array<String>] variants the title's labels mark
|
|
22
|
+
def self.variants(title)
|
|
23
|
+
LABELS.select { |_, patterns| patterns.any? { |pattern| title.match?(pattern) } }.keys
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cinebase
|
|
4
|
+
Event = Data.define(:name)
|
|
5
|
+
|
|
6
|
+
# A stage show or exhibition screened in cinemas rather than a film
|
|
7
|
+
class Event
|
|
8
|
+
# Prefixes title sanitizers give these shows, keyed by the series
|
|
9
|
+
PREFIXES = {
|
|
10
|
+
'Met Opera' => /\AMet Opera: /,
|
|
11
|
+
'Royal Ballet and Opera' => /\A(?:Royal Ballet and Opera|The Royal Ballet|The Royal Opera): /,
|
|
12
|
+
'National Theatre Live' => /\A(?:National Theatre Live|National Theatre|NT Live): /,
|
|
13
|
+
'Exhibition on Screen' => /\AExhibition on Screen: /,
|
|
14
|
+
'Bolshoi Ballet' => /\ABolshoi(?: Ballet)?: /
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
PREFIX = Regexp.union(PREFIXES.values)
|
|
18
|
+
|
|
19
|
+
# @param [String] film_name sanitized film name, e.g. "Met Opera: Tosca"
|
|
20
|
+
# @return [Cinebase::Event, nil]
|
|
21
|
+
def self.from_name(film_name)
|
|
22
|
+
name, = PREFIXES.find { |_, prefix| film_name.match?(prefix) }
|
|
23
|
+
new(name: name) if name
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @param [String] film_name sanitized film name, e.g. "Met Opera: Tosca"
|
|
27
|
+
# @return [String] the show's own name, e.g. "Tosca"
|
|
28
|
+
def self.strip(film_name)
|
|
29
|
+
film_name.sub(PREFIX, '')
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/cinebase/festival.rb
CHANGED
|
@@ -5,15 +5,22 @@ module Cinebase
|
|
|
5
5
|
|
|
6
6
|
# An annual festival edition a film is screened in
|
|
7
7
|
class Festival
|
|
8
|
+
NAMES = [
|
|
9
|
+
'CFF', 'Cinecity', 'FFF', 'French Film Fest UK', 'IFF', 'Into Film Festival', 'JFF', 'LDNDOCS',
|
|
10
|
+
'London Palestine Film Festival', 'LPFF', 'NFF', 'Queer East', 'RFF', 'SLA', 'UKJFF',
|
|
11
|
+
'Women and the World Festival'
|
|
12
|
+
].freeze
|
|
13
|
+
|
|
8
14
|
# Title prefixes naming a festival: the name, then the year when given
|
|
9
15
|
PREFIXES = [
|
|
10
16
|
/\A(Cine-Excess) (20\d{2}): /,
|
|
11
17
|
/\A(Cinemagic) (\d{4}) -/,
|
|
12
|
-
/\A(
|
|
13
|
-
/\A(
|
|
14
|
-
/\A(Horror Season) (20\d{2}) /
|
|
18
|
+
/\A(Horror Season) (20\d{2}) /,
|
|
19
|
+
/\A(#{NAMES.map { |name| Regexp.escape(name) }.join('|')})(?: ((?:20)?\d{2}))?\s*[:–-]\s*/
|
|
15
20
|
].freeze
|
|
16
21
|
|
|
22
|
+
CENTURY = 2000
|
|
23
|
+
|
|
17
24
|
# @param [String] title raw film title
|
|
18
25
|
# @param [Integer] year the edition when the title gives none, usually the
|
|
19
26
|
# screening's year
|
|
@@ -21,9 +28,18 @@ module Cinebase
|
|
|
21
28
|
def self.from_title(title, year:)
|
|
22
29
|
PREFIXES.each do |prefix|
|
|
23
30
|
match = title.match(prefix)
|
|
24
|
-
return new(name: match[1], year:
|
|
31
|
+
return new(name: match[1], year: edition(match[2]) || year) if match
|
|
25
32
|
end
|
|
26
33
|
nil
|
|
27
34
|
end
|
|
35
|
+
|
|
36
|
+
# "26" in "Queer East 26:" is 2026
|
|
37
|
+
def self.edition(year)
|
|
38
|
+
return unless year
|
|
39
|
+
|
|
40
|
+
year = Integer(year, 10)
|
|
41
|
+
year < 100 ? CENTURY + year : year
|
|
42
|
+
end
|
|
43
|
+
private_class_method :edition
|
|
28
44
|
end
|
|
29
45
|
end
|
data/lib/cinebase/performance.rb
CHANGED
|
@@ -7,10 +7,9 @@ module Cinebase
|
|
|
7
7
|
attr_reader :dimension
|
|
8
8
|
attr_reader :cinema_id
|
|
9
9
|
attr_reader :cinema_name
|
|
10
|
-
attr_reader :festival
|
|
11
|
-
attr_reader :film_name
|
|
12
10
|
attr_reader :film_year
|
|
13
11
|
attr_reader :language
|
|
12
|
+
attr_reader :title
|
|
14
13
|
|
|
15
14
|
def initialize(options)
|
|
16
15
|
@booking_url = options.fetch(:booking_url, nil)
|
|
@@ -22,6 +21,7 @@ module Cinebase
|
|
|
22
21
|
@film_year = options.fetch(:film_year, nil)
|
|
23
22
|
@language = options.fetch(:language, nil)
|
|
24
23
|
@time = options.fetch(:starting_at)
|
|
24
|
+
@title = options.fetch(:title, nil)&.gsub(/[[:space:]]/, ' ')
|
|
25
25
|
@variant = options.fetch(:variant, [])
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -43,14 +43,36 @@ module Cinebase
|
|
|
43
43
|
starting_at.to_date
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
# Given, or named by the raw title
|
|
47
|
+
def festival
|
|
48
|
+
@festival || (title && Festival.from_title(title, year: starting_at.year))
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# The show's own name when it is an Event, e.g. "Tosca"
|
|
52
|
+
def film_name
|
|
53
|
+
Event.strip(@film_name)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# A stage show or exhibition, which title sanitizers name as a prefix
|
|
57
|
+
def event
|
|
58
|
+
Event.from_name(@film_name)
|
|
59
|
+
end
|
|
60
|
+
|
|
46
61
|
def variant
|
|
47
62
|
@variant = @variant.split(' ') if @variant.is_a?(String)
|
|
48
|
-
@variant.map(&:downcase).sort.uniq
|
|
63
|
+
(@variant + title_variants).map(&:downcase).sort.uniq
|
|
49
64
|
end
|
|
50
65
|
|
|
51
66
|
# English subtitles or open captions
|
|
52
67
|
def subtitled?
|
|
53
68
|
variant.include?('subtitled')
|
|
54
69
|
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def title_variants
|
|
74
|
+
audiences = title ? Audience.variants(title) : []
|
|
75
|
+
event ? audiences + %w(arts) : audiences
|
|
76
|
+
end
|
|
55
77
|
end
|
|
56
78
|
end
|
|
@@ -5,14 +5,16 @@ module Cinebase
|
|
|
5
5
|
TitleSanitizer = Struct.new(:title) do
|
|
6
6
|
def sanitized
|
|
7
7
|
@sanitized ||= begin
|
|
8
|
-
sanitized = title.
|
|
8
|
+
sanitized = title.gsub(/[[:space:]]/, ' ')
|
|
9
9
|
remove.each do |pattern|
|
|
10
10
|
sanitized.gsub! pattern, ''
|
|
11
11
|
end
|
|
12
12
|
replace.each do |pattern, prefix|
|
|
13
13
|
sanitized.gsub!(pattern) { |_| prefix + $1 }
|
|
14
14
|
end
|
|
15
|
-
sanitized.squeeze(' ').strip
|
|
15
|
+
sanitized = sanitized.squeeze(' ').strip
|
|
16
|
+
series = sanitized[Event::PREFIX].to_s
|
|
17
|
+
series + title_case(sanitized.delete_prefix(series))
|
|
16
18
|
end
|
|
17
19
|
end
|
|
18
20
|
|
|
@@ -32,25 +34,36 @@ module Cinebase
|
|
|
32
34
|
# Rules every chain can share; subclasses opt in after their own patterns,
|
|
33
35
|
# e.g. `[...] + COMMON_REMOVE` in #remove
|
|
34
36
|
class TitleSanitizer
|
|
35
|
-
LANGUAGES = %w(Arabic Cantonese French Hindi
|
|
36
|
-
Malayalam Mandarin Marathi Polish
|
|
37
|
-
Turkish).freeze
|
|
37
|
+
LANGUAGES = %w(Arabic Bengali Cantonese French Gujarati Hindi Japanese
|
|
38
|
+
Kannada Korean Lithuanian Malayalam Mandarin Marathi Polish
|
|
39
|
+
Punjabi Romanian Tamil Telugu Turkish Vietnamese).freeze
|
|
38
40
|
|
|
39
41
|
# A trailing "(1996)", allowing other bracketed markers after it
|
|
40
42
|
FILM_YEAR = /\s*\((1[89]\d{2}|20\d{2})\)(?=(?:\s*\([^)]*\))*\s*\z)/
|
|
41
43
|
|
|
42
44
|
COMMON_REMOVE = [
|
|
43
45
|
*Festival::PREFIXES, # festival prefix
|
|
46
|
+
*Audience::PATTERNS, # audience label
|
|
47
|
+
/\A(?:Opening|Closing|Centrepiece|Documentary)(?: Night)? Gala:\s*/i, # festival gala
|
|
48
|
+
/\A[^:]+?\s+presents:\s*/i, # presenter credit
|
|
44
49
|
/\s+[23]d\b/i, # dimension
|
|
50
|
+
/\s*\([23]D\)/i, # bracketed dimension
|
|
45
51
|
/\((#{LANGUAGES.join('|')})\)/i, # language version
|
|
46
|
-
/\((Dubbed|Subbed|English Dub
|
|
47
|
-
/\(\d+(st|nd|rd|th) Anniversary\
|
|
52
|
+
/\((Dubbed|Subbed|English Dub(?:bed)?|[^)]*subtitles)\)/i, # dub or subtitle version
|
|
53
|
+
/\s*[(\[]\d+(st|nd|rd|th) Anniversary(?: 4K)?(?: Restoration)?[)\]]/i, # anniversary re-release
|
|
54
|
+
/\s*\(4K(?: Restoration)?\)/i, # bracketed 4K restoration
|
|
55
|
+
/\s*\((?:20\d{2} )?Encore\)/i, # bracketed encore
|
|
56
|
+
/\s*\(Recorded\)/i, # recorded, not live
|
|
57
|
+
/\s+[-–]\s+Live On Stage\z/i, # filmed stage show
|
|
48
58
|
/\(Re-release\)/i, # re-release
|
|
49
59
|
FILM_YEAR, # film year, see .film_year
|
|
50
|
-
/\s*\+\s*(?:[\w
|
|
60
|
+
/\s*\+\s*(?:[\w.-]+\s+)*Q(?:&|\+)A\z/i, # Q&A add-on
|
|
61
|
+
/\s*\((?:with )?[^)]*Q(?:&|\+)A\)/i, # bracketed Q&A
|
|
51
62
|
/\s*\+\s*Discussion\z/i, # discussion add-on
|
|
63
|
+
/\s*\+\s*(?:ScreenTalk|Intro(?:duction)?|Short Film)\z/i, # talk or short add-on
|
|
52
64
|
/\s*\((35|70)mm\)/i, # film gauge
|
|
53
|
-
/\s+4K
|
|
65
|
+
/\s+4K(?: Restoration)?\b/i, # 4K restoration
|
|
66
|
+
/\s*[-–]?\s*\d+(?:st|nd|rd|th) Anniversary\z/i, # trailing anniversary
|
|
54
67
|
/:\s*Encore\z/i, # encore
|
|
55
68
|
/\bsing-?a-?long\z/i, # singalong
|
|
56
69
|
'amp;' # html ampersands
|
|
@@ -62,10 +75,54 @@ module Cinebase
|
|
|
62
75
|
title[FILM_YEAR, 1]&.to_i
|
|
63
76
|
end
|
|
64
77
|
|
|
78
|
+
ARTS_SEASON = %r{\s*(?:(?:20)?\d{2}[-/]\d{2})?}
|
|
79
|
+
ARTS_SEPARATOR = %r{(?:\s*[:/]\s*|\s+[-–]\s+)}
|
|
80
|
+
|
|
81
|
+
# Arts series named the way Event::PREFIXES expects; Met Opera first, as
|
|
82
|
+
# some chains list it inside an RBO season
|
|
65
83
|
COMMON_REPLACE = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
/\A(?:RBO[^:]*:\s*)?(?:The )?Met\.?(?: Opera)?(?:\s+(?:Live|Encore))?#{ARTS_SEASON}#{ARTS_SEPARATOR}(.*)/i =>
|
|
85
|
+
'Met Opera: ',
|
|
86
|
+
/\A(?:RBO|Royal Ballet (?:and|&) Opera|(?:The )?Royal (?:Ballet|Opera))(?:\s+(?:Live|Encore|Cinema Season))?#{ARTS_SEASON}#{ARTS_SEPARATOR}(?:The Royal (?:Ballet|Opera)\s+[-–]\s+)?(.*)/i =>
|
|
87
|
+
'Royal Ballet and Opera: ',
|
|
88
|
+
/\A(?:NT (?:Live|Encore)(?: Encore)?|NTL|National Theatre(?: Live)?)#{ARTS_SEPARATOR}(.*)/i => 'National Theatre Live: ',
|
|
89
|
+
/\AExhibition on Screen#{ARTS_SEPARATOR}(.*)/i => 'Exhibition on Screen: ',
|
|
90
|
+
/\ABolshoi(?: Ballet)?#{ARTS_SEPARATOR}(.*)/i => 'Bolshoi Ballet: ',
|
|
91
|
+
/WORLD TOUR(.*)/ => 'World Tour'
|
|
69
92
|
}.freeze
|
|
93
|
+
|
|
94
|
+
SMALL_WORDS = %w(a an and as at but by for from in into nor of on or the to v vs with).freeze
|
|
95
|
+
HONORIFICS = %w(dr mr mrs ms st).freeze
|
|
96
|
+
ROMAN_NUMERAL = /\A(?=[IVX])X{0,3}(?:IX|IV|V?I{0,3})\z/
|
|
97
|
+
VOWEL = /[AEIOUYÀ-Ý]/
|
|
98
|
+
OPENS_PHRASE = /[:\-–]\z/
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
|
|
102
|
+
# A title listed in capitals, such as "ROCKY IV", reads "Rocky IV"
|
|
103
|
+
def title_case(text)
|
|
104
|
+
if text.match?(/\p{Ll}/)
|
|
105
|
+
text
|
|
106
|
+
else
|
|
107
|
+
words = text.split(' ')
|
|
108
|
+
words.each_with_index.map do |word, index|
|
|
109
|
+
title_case_word(word, opens_phrase: index.zero? || words[index - 1].match?(OPENS_PHRASE))
|
|
110
|
+
end.join(' ')
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Acronyms such as "BTS", numerals and words with digits keep capitals
|
|
115
|
+
def title_case_word(word, opens_phrase:)
|
|
116
|
+
letters = word.gsub(/\P{L}/, '').downcase
|
|
117
|
+
if word.match?(/\d/) || word.match?(ROMAN_NUMERAL)
|
|
118
|
+
word
|
|
119
|
+
elsif !opens_phrase && SMALL_WORDS.include?(letters)
|
|
120
|
+
word.downcase
|
|
121
|
+
elsif !word.match?(VOWEL) && !HONORIFICS.include?(letters)
|
|
122
|
+
word
|
|
123
|
+
else
|
|
124
|
+
word.split('-').map { |part| part.downcase.sub(/\p{L}/, &:upcase) }.join('-')
|
|
125
|
+
end
|
|
126
|
+
end
|
|
70
127
|
end
|
|
71
128
|
end
|
data/lib/cinebase/version.rb
CHANGED
data/lib/cinebase.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cinebase
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Croll
|
|
@@ -163,12 +163,14 @@ files:
|
|
|
163
163
|
- lib/cinebase/a1web/listings.rb
|
|
164
164
|
- lib/cinebase/a1web/performance.rb
|
|
165
165
|
- lib/cinebase/a1web/showing.rb
|
|
166
|
+
- lib/cinebase/audience.rb
|
|
166
167
|
- lib/cinebase/boxoffice.rb
|
|
167
168
|
- lib/cinebase/boxoffice/cinema.rb
|
|
168
169
|
- lib/cinebase/boxoffice/client.rb
|
|
169
170
|
- lib/cinebase/boxoffice/performance.rb
|
|
170
171
|
- lib/cinebase/boxoffice/showtime.rb
|
|
171
172
|
- lib/cinebase/cinema.rb
|
|
173
|
+
- lib/cinebase/event.rb
|
|
172
174
|
- lib/cinebase/festival.rb
|
|
173
175
|
- lib/cinebase/http.rb
|
|
174
176
|
- lib/cinebase/london.rb
|