picturehouse_uk 3.0.14 → 5.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.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +26 -0
- data/.github/workflows/release.yml +26 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +44 -0
- data/LICENSE +617 -0
- data/README.md +5 -4
- data/Rakefile +12 -0
- data/lib/picturehouse_uk/cinema.rb +152 -127
- data/lib/picturehouse_uk/internal/api.rb +42 -0
- data/lib/picturehouse_uk/internal/parser/address.rb +36 -9
- data/lib/picturehouse_uk/internal/parser/screenings.rb +89 -95
- data/lib/picturehouse_uk/internal/title_sanitizer.rb +61 -65
- data/lib/picturehouse_uk/internal/website.rb +10 -12
- data/lib/picturehouse_uk/performance.rb +60 -0
- data/lib/picturehouse_uk/version.rb +2 -2
- data/lib/picturehouse_uk.rb +3 -4
- data/picturehouse_uk.gemspec +5 -7
- data/rake/fixture_creator.rb +62 -0
- data/test/fixtures/cinemas.html +4262 -0
- data/test/fixtures/duke-of-york-s-picturehouse/cinema.html +6187 -0
- data/test/fixtures/duke-of-york-s-picturehouse/get_movies.json +120552 -0
- data/test/fixtures/duke-of-york-s-picturehouse/information.html +3725 -0
- data/test/fixtures/duke-s-at-komedia/cinema.html +6138 -0
- data/test/fixtures/duke-s-at-komedia/get_movies.json +112 -0
- data/test/fixtures/duke-s-at-komedia/information.html +3690 -0
- data/test/fixtures/home.html +6236 -565
- data/test/fixtures/phoenix-picturehouse/cinema.html +6089 -0
- data/test/fixtures/phoenix-picturehouse/get_movies.json +120552 -0
- data/test/fixtures/phoenix-picturehouse/information.html +3630 -0
- data/test/lib/picturehouse_uk/cinema_test.rb +113 -142
- data/test/lib/picturehouse_uk/internal/api_test.rb +92 -0
- data/test/lib/picturehouse_uk/internal/parser/{address_parser_test.rb → address_test.rb} +11 -11
- data/test/lib/picturehouse_uk/internal/parser/screenings_test.rb +100 -48
- data/test/lib/picturehouse_uk/internal/title_sanitizer_test.rb +48 -48
- data/test/lib/picturehouse_uk/internal/website_test.rb +15 -31
- data/test/lib/picturehouse_uk/performance_test.rb +197 -0
- data/test/lib/picturehouse_uk/version_test.rb +1 -1
- data/test/live/integration_test.rb +15 -32
- data/test/support/fake_api.rb +16 -0
- data/test/support/fake_website.rb +24 -0
- data/test/test_helper.rb +13 -2
- metadata +52 -67
- data/.rdoc_options +0 -16
- data/.travis.yml +0 -5
- data/lib/picturehouse_uk/film.rb +0 -59
- data/lib/picturehouse_uk/screening.rb +0 -70
- data/test/fixture_updater.rb +0 -73
- data/test/fixtures/cinema/Duke_Of_Yorks.html +0 -2984
- data/test/fixtures/cinema/Dukes_At_Komedia.html +0 -5518
- data/test/fixtures/cinema/National_Media_Museum.html +0 -10266
- data/test/fixtures/cinema/Phoenix_Picturehouse.html +0 -5202
- data/test/fixtures/info/Duke_Of_Yorks.html +0 -549
- data/test/fixtures/info/Dukes_At_Komedia.html +0 -537
- data/test/fixtures/info/Phoenix_Picturehouse.html +0 -553
- data/test/fixtures/whats_on/Duke_Of_Yorks.html +0 -2737
- data/test/fixtures/whats_on/Dukes_At_Komedia.html +0 -5132
- data/test/fixtures/whats_on/National_Media_Museum.html +0 -9690
- data/test/fixtures/whats_on/Phoenix_Picturehouse.html +0 -4916
- data/test/lib/picturehouse_uk/film_test.rb +0 -141
- data/test/lib/picturehouse_uk/screening_test.rb +0 -181
- /data/{LICENSE.txt → COMM-LICENSE} +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
require 'minitest/autorun'
|
|
2
2
|
require 'minitest/reporters'
|
|
3
|
-
|
|
4
|
-
Minitest::Reporters.use! [
|
|
3
|
+
|
|
4
|
+
Minitest::Reporters.use! [
|
|
5
|
+
Minitest::Reporters::DefaultReporter.new(color: true)
|
|
6
|
+
]
|
|
5
7
|
|
|
6
8
|
require File.expand_path('../../../lib/picturehouse_uk.rb', __FILE__)
|
|
7
9
|
|
|
@@ -12,57 +14,38 @@ describe PicturehouseUk::Cinema do
|
|
|
12
14
|
subject { described_class.all }
|
|
13
15
|
|
|
14
16
|
it 'returns an Array of CineworldUK::Cinemas' do
|
|
15
|
-
subject.must_be_instance_of(Array)
|
|
17
|
+
_(subject).must_be_instance_of(Array)
|
|
16
18
|
subject.each do |value|
|
|
17
|
-
value.must_be_instance_of(PicturehouseUk::Cinema)
|
|
19
|
+
_(value).must_be_instance_of(PicturehouseUk::Cinema)
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
it 'returns the correctly sized array' do
|
|
22
|
-
subject.size.must_be :>, 18
|
|
24
|
+
_(subject.size).must_be :>, 18
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
it 'returns the right cinemas' do
|
|
26
|
-
subject.first.name.must_equal '
|
|
27
|
-
subject.last.name.must_equal 'City Screen
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe PicturehouseUk::Film do
|
|
33
|
-
let(:described_class) { PicturehouseUk::Film }
|
|
34
|
-
|
|
35
|
-
describe '.at(cinema_id)' do
|
|
36
|
-
subject { described_class.at('Duke_Of_Yorks') }
|
|
37
|
-
|
|
38
|
-
it 'returns an array of films' do
|
|
39
|
-
subject.must_be_instance_of(Array)
|
|
40
|
-
subject.each do |film|
|
|
41
|
-
film.must_be_instance_of(PicturehouseUk::Film)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'returns a decent number of films' do
|
|
46
|
-
subject.count.must_be :>, 5
|
|
28
|
+
_(subject.first.name).must_equal 'Little Theatre Cinema'
|
|
29
|
+
_(subject.last.name).must_equal 'City Screen York'
|
|
47
30
|
end
|
|
48
31
|
end
|
|
49
32
|
end
|
|
50
33
|
|
|
51
|
-
describe PicturehouseUk::
|
|
52
|
-
let(:described_class) { PicturehouseUk::
|
|
34
|
+
describe PicturehouseUk::Performance do
|
|
35
|
+
let(:described_class) { PicturehouseUk::Performance }
|
|
53
36
|
|
|
54
37
|
describe '.at(cinema_id)' do
|
|
55
38
|
subject { described_class.at('Duke_Of_Yorks') }
|
|
56
39
|
|
|
57
40
|
it 'returns an array of screenings' do
|
|
58
|
-
subject.must_be_instance_of(Array)
|
|
59
|
-
subject.each do |
|
|
60
|
-
|
|
41
|
+
_(subject).must_be_instance_of(Array)
|
|
42
|
+
subject.each do |performance|
|
|
43
|
+
_(performance).must_be_instance_of(PicturehouseUk::Performance)
|
|
61
44
|
end
|
|
62
45
|
end
|
|
63
46
|
|
|
64
47
|
it 'returns correct number of screenings' do
|
|
65
|
-
subject.count.must_be :>, 10
|
|
48
|
+
_(subject.count).must_be :>, 10
|
|
66
49
|
end
|
|
67
50
|
end
|
|
68
51
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
# Fake API client for reading JSON fixtures from disk
|
|
4
|
+
class FakeApi
|
|
5
|
+
def get_movies(cinema_id, _date = 'show_all_dates')
|
|
6
|
+
JSON.parse(read_file("../../fixtures/#{cinema_id}/get_movies.json"))
|
|
7
|
+
rescue Errno::ENOENT
|
|
8
|
+
{ 'response' => 'error', 'movies' => [] }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def read_file(filepath)
|
|
14
|
+
File.read(File.expand_path(filepath, __FILE__))
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Fake website for reading fixtures from disk
|
|
2
|
+
class FakeWebsite
|
|
3
|
+
def home
|
|
4
|
+
read_file('../../fixtures/home.html')
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def cinemas
|
|
8
|
+
read_file('../../fixtures/cinemas.html')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def cinema(cinema_id)
|
|
12
|
+
read_file("../../fixtures/#{cinema_id}/cinema.html")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def information(cinema_id)
|
|
16
|
+
read_file("../../fixtures/#{cinema_id}/information.html")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def read_file(filepath)
|
|
22
|
+
File.read(File.expand_path(filepath, __FILE__))
|
|
23
|
+
end
|
|
24
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
require 'simplecov'
|
|
2
|
+
SimpleCov.start
|
|
3
|
+
|
|
1
4
|
require 'minitest/autorun'
|
|
2
5
|
require 'minitest/reporters'
|
|
3
|
-
|
|
4
|
-
Minitest::Reporters.use! [
|
|
6
|
+
|
|
7
|
+
Minitest::Reporters.use! [
|
|
8
|
+
Minitest::Reporters::DefaultReporter.new(color: true, slow_count: 5)
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
require 'webmock/minitest'
|
|
12
|
+
WebMock.allow_net_connect!
|
|
5
13
|
|
|
6
14
|
require 'webmock/minitest'
|
|
7
15
|
|
|
8
16
|
require File.expand_path('../../lib/picturehouse_uk.rb', __FILE__)
|
|
17
|
+
|
|
18
|
+
require_relative 'support/fake_api'
|
|
19
|
+
require_relative 'support/fake_website'
|
metadata
CHANGED
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: picturehouse_uk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.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:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1.3'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.3'
|
|
27
12
|
- !ruby/object:Gem::Dependency
|
|
28
13
|
name: minitest-reporters
|
|
29
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,7 +38,7 @@ dependencies:
|
|
|
53
38
|
- !ruby/object:Gem::Version
|
|
54
39
|
version: '0'
|
|
55
40
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
41
|
+
name: simplecov
|
|
57
42
|
requirement: !ruby/object:Gem::Requirement
|
|
58
43
|
requirements:
|
|
59
44
|
- - ">="
|
|
@@ -67,13 +52,13 @@ dependencies:
|
|
|
67
52
|
- !ruby/object:Gem::Version
|
|
68
53
|
version: '0'
|
|
69
54
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
55
|
+
name: webmock
|
|
71
56
|
requirement: !ruby/object:Gem::Requirement
|
|
72
57
|
requirements:
|
|
73
58
|
- - ">="
|
|
74
59
|
- !ruby/object:Gem::Version
|
|
75
60
|
version: '0'
|
|
76
|
-
type: :
|
|
61
|
+
type: :development
|
|
77
62
|
prerelease: false
|
|
78
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
64
|
requirements:
|
|
@@ -81,21 +66,21 @@ dependencies:
|
|
|
81
66
|
- !ruby/object:Gem::Version
|
|
82
67
|
version: '0'
|
|
83
68
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
69
|
+
name: cinebase
|
|
85
70
|
requirement: !ruby/object:Gem::Requirement
|
|
86
71
|
requirements:
|
|
87
|
-
- - "
|
|
72
|
+
- - "~>"
|
|
88
73
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0'
|
|
74
|
+
version: '3.0'
|
|
90
75
|
type: :runtime
|
|
91
76
|
prerelease: false
|
|
92
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
78
|
requirements:
|
|
94
|
-
- - "
|
|
79
|
+
- - "~>"
|
|
95
80
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0'
|
|
81
|
+
version: '3.0'
|
|
97
82
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
83
|
+
name: nokogiri
|
|
99
84
|
requirement: !ruby/object:Gem::Requirement
|
|
100
85
|
requirements:
|
|
101
86
|
- - ">="
|
|
@@ -108,60 +93,63 @@ dependencies:
|
|
|
108
93
|
- - ">="
|
|
109
94
|
- !ruby/object:Gem::Version
|
|
110
95
|
version: '0'
|
|
111
|
-
description:
|
|
96
|
+
description: API pulling information from picturehouse.com
|
|
112
97
|
email:
|
|
113
98
|
- andy@goodscary.com
|
|
114
99
|
executables: []
|
|
115
100
|
extensions: []
|
|
116
101
|
extra_rdoc_files: []
|
|
117
102
|
files:
|
|
103
|
+
- ".github/workflows/ci.yml"
|
|
104
|
+
- ".github/workflows/release.yml"
|
|
118
105
|
- ".gitignore"
|
|
119
|
-
- ".
|
|
120
|
-
- ".travis.yml"
|
|
106
|
+
- ".ruby-version"
|
|
121
107
|
- ".yardopts"
|
|
122
108
|
- CHANGELOG.md
|
|
109
|
+
- COMM-LICENSE
|
|
123
110
|
- Gemfile
|
|
124
|
-
- LICENSE
|
|
111
|
+
- LICENSE
|
|
125
112
|
- README.md
|
|
126
113
|
- Rakefile
|
|
127
114
|
- lib/picturehouse_uk.rb
|
|
128
115
|
- lib/picturehouse_uk/cinema.rb
|
|
129
|
-
- lib/picturehouse_uk/
|
|
116
|
+
- lib/picturehouse_uk/internal/api.rb
|
|
130
117
|
- lib/picturehouse_uk/internal/parser/address.rb
|
|
131
118
|
- lib/picturehouse_uk/internal/parser/screenings.rb
|
|
132
119
|
- lib/picturehouse_uk/internal/title_sanitizer.rb
|
|
133
120
|
- lib/picturehouse_uk/internal/website.rb
|
|
134
|
-
- lib/picturehouse_uk/
|
|
121
|
+
- lib/picturehouse_uk/performance.rb
|
|
135
122
|
- lib/picturehouse_uk/version.rb
|
|
136
123
|
- picturehouse_uk.gemspec
|
|
137
|
-
-
|
|
138
|
-
- test/fixtures/
|
|
139
|
-
- test/fixtures/cinema
|
|
140
|
-
- test/fixtures/
|
|
141
|
-
- test/fixtures/
|
|
124
|
+
- rake/fixture_creator.rb
|
|
125
|
+
- test/fixtures/cinemas.html
|
|
126
|
+
- test/fixtures/duke-of-york-s-picturehouse/cinema.html
|
|
127
|
+
- test/fixtures/duke-of-york-s-picturehouse/get_movies.json
|
|
128
|
+
- test/fixtures/duke-of-york-s-picturehouse/information.html
|
|
129
|
+
- test/fixtures/duke-s-at-komedia/cinema.html
|
|
130
|
+
- test/fixtures/duke-s-at-komedia/get_movies.json
|
|
131
|
+
- test/fixtures/duke-s-at-komedia/information.html
|
|
142
132
|
- test/fixtures/home.html
|
|
143
|
-
- test/fixtures/
|
|
144
|
-
- test/fixtures/
|
|
145
|
-
- test/fixtures/
|
|
146
|
-
- test/fixtures/whats_on/Duke_Of_Yorks.html
|
|
147
|
-
- test/fixtures/whats_on/Dukes_At_Komedia.html
|
|
148
|
-
- test/fixtures/whats_on/National_Media_Museum.html
|
|
149
|
-
- test/fixtures/whats_on/Phoenix_Picturehouse.html
|
|
133
|
+
- test/fixtures/phoenix-picturehouse/cinema.html
|
|
134
|
+
- test/fixtures/phoenix-picturehouse/get_movies.json
|
|
135
|
+
- test/fixtures/phoenix-picturehouse/information.html
|
|
150
136
|
- test/lib/picturehouse_uk/cinema_test.rb
|
|
151
|
-
- test/lib/picturehouse_uk/
|
|
152
|
-
- test/lib/picturehouse_uk/internal/parser/
|
|
137
|
+
- test/lib/picturehouse_uk/internal/api_test.rb
|
|
138
|
+
- test/lib/picturehouse_uk/internal/parser/address_test.rb
|
|
153
139
|
- test/lib/picturehouse_uk/internal/parser/screenings_test.rb
|
|
154
140
|
- test/lib/picturehouse_uk/internal/title_sanitizer_test.rb
|
|
155
141
|
- test/lib/picturehouse_uk/internal/website_test.rb
|
|
156
|
-
- test/lib/picturehouse_uk/
|
|
142
|
+
- test/lib/picturehouse_uk/performance_test.rb
|
|
157
143
|
- test/lib/picturehouse_uk/version_test.rb
|
|
158
144
|
- test/live/integration_test.rb
|
|
145
|
+
- test/support/fake_api.rb
|
|
146
|
+
- test/support/fake_website.rb
|
|
159
147
|
- test/test_helper.rb
|
|
160
148
|
homepage: ''
|
|
161
149
|
licenses:
|
|
150
|
+
- AGPL
|
|
162
151
|
- MIT
|
|
163
152
|
metadata: {}
|
|
164
|
-
post_install_message:
|
|
165
153
|
rdoc_options: []
|
|
166
154
|
require_paths:
|
|
167
155
|
- lib
|
|
@@ -176,33 +164,30 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
176
164
|
- !ruby/object:Gem::Version
|
|
177
165
|
version: '0'
|
|
178
166
|
requirements: []
|
|
179
|
-
|
|
180
|
-
rubygems_version: 2.2.2
|
|
181
|
-
signing_key:
|
|
167
|
+
rubygems_version: 3.6.9
|
|
182
168
|
specification_version: 4
|
|
183
169
|
summary: It's a scraper, but a nice one
|
|
184
170
|
test_files:
|
|
185
|
-
- test/
|
|
186
|
-
- test/fixtures/cinema
|
|
187
|
-
- test/fixtures/
|
|
188
|
-
- test/fixtures/
|
|
189
|
-
- test/fixtures/cinema
|
|
171
|
+
- test/fixtures/cinemas.html
|
|
172
|
+
- test/fixtures/duke-of-york-s-picturehouse/cinema.html
|
|
173
|
+
- test/fixtures/duke-of-york-s-picturehouse/get_movies.json
|
|
174
|
+
- test/fixtures/duke-of-york-s-picturehouse/information.html
|
|
175
|
+
- test/fixtures/duke-s-at-komedia/cinema.html
|
|
176
|
+
- test/fixtures/duke-s-at-komedia/get_movies.json
|
|
177
|
+
- test/fixtures/duke-s-at-komedia/information.html
|
|
190
178
|
- test/fixtures/home.html
|
|
191
|
-
- test/fixtures/
|
|
192
|
-
- test/fixtures/
|
|
193
|
-
- test/fixtures/
|
|
194
|
-
- test/fixtures/whats_on/Duke_Of_Yorks.html
|
|
195
|
-
- test/fixtures/whats_on/Dukes_At_Komedia.html
|
|
196
|
-
- test/fixtures/whats_on/National_Media_Museum.html
|
|
197
|
-
- test/fixtures/whats_on/Phoenix_Picturehouse.html
|
|
179
|
+
- test/fixtures/phoenix-picturehouse/cinema.html
|
|
180
|
+
- test/fixtures/phoenix-picturehouse/get_movies.json
|
|
181
|
+
- test/fixtures/phoenix-picturehouse/information.html
|
|
198
182
|
- test/lib/picturehouse_uk/cinema_test.rb
|
|
199
|
-
- test/lib/picturehouse_uk/
|
|
200
|
-
- test/lib/picturehouse_uk/internal/parser/
|
|
183
|
+
- test/lib/picturehouse_uk/internal/api_test.rb
|
|
184
|
+
- test/lib/picturehouse_uk/internal/parser/address_test.rb
|
|
201
185
|
- test/lib/picturehouse_uk/internal/parser/screenings_test.rb
|
|
202
186
|
- test/lib/picturehouse_uk/internal/title_sanitizer_test.rb
|
|
203
187
|
- test/lib/picturehouse_uk/internal/website_test.rb
|
|
204
|
-
- test/lib/picturehouse_uk/
|
|
188
|
+
- test/lib/picturehouse_uk/performance_test.rb
|
|
205
189
|
- test/lib/picturehouse_uk/version_test.rb
|
|
206
190
|
- test/live/integration_test.rb
|
|
191
|
+
- test/support/fake_api.rb
|
|
192
|
+
- test/support/fake_website.rb
|
|
207
193
|
- test/test_helper.rb
|
|
208
|
-
has_rdoc:
|
data/.rdoc_options
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
--- !ruby/object:RDoc::Options
|
|
2
|
-
encoding: UTF-8
|
|
3
|
-
static_path: []
|
|
4
|
-
rdoc_include:
|
|
5
|
-
- .
|
|
6
|
-
charset: UTF-8
|
|
7
|
-
exclude:
|
|
8
|
-
hyperlink_all: false
|
|
9
|
-
line_numbers: false
|
|
10
|
-
main_page:
|
|
11
|
-
markup: tomdoc
|
|
12
|
-
show_hash: false
|
|
13
|
-
tab_width: 8
|
|
14
|
-
title:
|
|
15
|
-
visibility: :protected
|
|
16
|
-
webcvs:
|
data/.travis.yml
DELETED
data/lib/picturehouse_uk/film.rb
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
module PicturehouseUk
|
|
2
|
-
# A film on the Picturehouse UK website
|
|
3
|
-
class Film
|
|
4
|
-
include Comparable
|
|
5
|
-
|
|
6
|
-
# @return [String] the name of the film
|
|
7
|
-
attr_reader :name
|
|
8
|
-
# @return [String] the normalized slug derived from the film name
|
|
9
|
-
attr_reader :slug
|
|
10
|
-
|
|
11
|
-
# @param [String] name the film name
|
|
12
|
-
# @return [PicturehouseUk::Film]
|
|
13
|
-
def initialize(name)
|
|
14
|
-
@name = name
|
|
15
|
-
@slug = name.downcase.gsub(/[^0-9a-z ]/, '').gsub(/\s+/, '-')
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Films at a single cinema
|
|
19
|
-
# @param [String] cinema_id the id of the cinema
|
|
20
|
-
# @return [Array<PicturehouseUk::Film>]
|
|
21
|
-
def self.at(cinema_id)
|
|
22
|
-
screenings(cinema_id).map { |hash| new hash[:film_name] }.uniq
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Allows sort on objects
|
|
26
|
-
# @param [PicturehouseUk::Film] other another film object
|
|
27
|
-
# @return [Integer] -1, 0 or 1
|
|
28
|
-
def <=>(other)
|
|
29
|
-
slug <=> other.slug
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Check an object is the same as another object.
|
|
33
|
-
# @param [PicturehouseUk::Film] other another film
|
|
34
|
-
# @return [Boolean] True if both objects are the same exact object, or if
|
|
35
|
-
# they are of the same type and share an equal slug
|
|
36
|
-
# @note Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
|
|
37
|
-
def eql?(other)
|
|
38
|
-
self.class == other.class && self == other
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Generates hash of slug in order to allow two records of the same type and
|
|
42
|
-
# id to work with something like:
|
|
43
|
-
#
|
|
44
|
-
# [ Film.new('AB'), Film.new('EF') ] & [ Film.new('EF'), Film.new('GH') ]
|
|
45
|
-
# #=> [ Film.new('EF') ]
|
|
46
|
-
#
|
|
47
|
-
# @return [Integer] hash of slug
|
|
48
|
-
# @note Guided by http://woss.name/2011/01/20/equality-comparison-and-ordering-in-ruby/
|
|
49
|
-
def hash
|
|
50
|
-
slug.hash
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
private
|
|
54
|
-
|
|
55
|
-
def self.screenings(cinema_id)
|
|
56
|
-
PicturehouseUk::Internal::Parser::Screenings.new(cinema_id).to_a
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
module PicturehouseUk
|
|
2
|
-
# A single screening of a film on the Picturehouse UK website
|
|
3
|
-
class Screening
|
|
4
|
-
# @return [String] the booking URL on the cinema website
|
|
5
|
-
attr_reader :booking_url
|
|
6
|
-
# @return [String] the cinema name
|
|
7
|
-
attr_reader :cinema_name
|
|
8
|
-
# @return [String] 2d or 3d
|
|
9
|
-
attr_reader :dimension
|
|
10
|
-
# @return [String] the film name
|
|
11
|
-
attr_reader :film_name
|
|
12
|
-
|
|
13
|
-
# @param [Hash] options
|
|
14
|
-
def initialize(options)
|
|
15
|
-
@booking_url = options.fetch(:booking_url, nil)
|
|
16
|
-
@cinema_name = options.fetch(:cinema_name)
|
|
17
|
-
@cinema_id = options.fetch(:cinema_id)
|
|
18
|
-
@dimension = options.fetch(:dimension, '2d')
|
|
19
|
-
@film_name = options.fetch(:film_name)
|
|
20
|
-
@time = options.fetch(:time)
|
|
21
|
-
@variant = options.fetch(:variant, [])
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Screenings at a single cinema
|
|
25
|
-
# @param [String] cinema_id the id of the cinema
|
|
26
|
-
# @return [Array<PicturehouseUk::Screening>]
|
|
27
|
-
def self.at(cinema_id)
|
|
28
|
-
screenings(cinema_id).map do |attributes|
|
|
29
|
-
new cinema_hash(cinema_id).merge(attributes)
|
|
30
|
-
end.uniq
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# The UTC time of the screening
|
|
34
|
-
# @return [Time]
|
|
35
|
-
def showing_at
|
|
36
|
-
@showing_at ||= begin
|
|
37
|
-
if @time.utc?
|
|
38
|
-
@time
|
|
39
|
-
else
|
|
40
|
-
TZInfo::Timezone.get('Europe/London').local_to_utc(@time)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# The date of the screening
|
|
46
|
-
# @return [Date]
|
|
47
|
-
def showing_on
|
|
48
|
-
showing_at.to_date
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# The kinds of screening
|
|
52
|
-
# @return <Array[String]>
|
|
53
|
-
def variant
|
|
54
|
-
@variant.map(&:downcase).sort
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
|
|
59
|
-
def self.cinema_hash(cinema_id)
|
|
60
|
-
{
|
|
61
|
-
cinema_id: cinema_id,
|
|
62
|
-
cinema_name: PicturehouseUk::Cinema.find(cinema_id).name
|
|
63
|
-
}
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def self.screenings(cinema_id)
|
|
67
|
-
PicturehouseUk::Internal::Parser::Screenings.new(cinema_id).to_a
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
data/test/fixture_updater.rb
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../lib/picturehouse_uk.rb', __FILE__)
|
|
2
|
-
|
|
3
|
-
def fixture(name)
|
|
4
|
-
File.expand_path("../fixtures/#{name}.html", __FILE__)
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
File.open(fixture('home'), 'w') do |file|
|
|
8
|
-
puts '* Homepage'
|
|
9
|
-
file.write PicturehouseUk::Internal::Website.new.home
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# DUKE OF YORKS
|
|
13
|
-
|
|
14
|
-
File.open(fixture('cinema/Duke_Of_Yorks'), 'w') do |file|
|
|
15
|
-
puts '* Duke of Yorks'
|
|
16
|
-
file.write PicturehouseUk::Internal::Website.new.cinema('Duke_Of_Yorks')
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
File.open(fixture('info/Duke_Of_Yorks'), 'w') do |file|
|
|
20
|
-
puts '* Duke of Yorks Information'
|
|
21
|
-
file.write PicturehouseUk::Internal::Website.new.info('Duke_Of_Yorks')
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
File.open(fixture('whats_on/Duke_Of_Yorks'), 'w') do |file|
|
|
25
|
-
puts '* Duke of Yorks Whats On'
|
|
26
|
-
file.write PicturehouseUk::Internal::Website.new.whats_on('Duke_Of_Yorks')
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# KOMEDIA
|
|
30
|
-
|
|
31
|
-
File.open(fixture('cinema/Dukes_At_Komedia'), 'w') do |file|
|
|
32
|
-
puts '* Dukes at Komedia'
|
|
33
|
-
file.write PicturehouseUk::Internal::Website.new.cinema('Dukes_At_Komedia')
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
File.open(fixture('info/Dukes_At_Komedia'), 'w') do |file|
|
|
37
|
-
puts '* Dukes at Komedia Information'
|
|
38
|
-
file.write PicturehouseUk::Internal::Website.new.info('Dukes_At_Komedia')
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
File.open(fixture('whats_on/Dukes_At_Komedia'), 'w') do |file|
|
|
42
|
-
puts '* Dukes at Komedia Whats On'
|
|
43
|
-
file.write PicturehouseUk::Internal::Website.new.whats_on('Dukes_At_Komedia')
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# PHEONIX OXFORD
|
|
47
|
-
|
|
48
|
-
File.open(fixture('cinema/Phoenix_Picturehouse'), 'w') do |file|
|
|
49
|
-
puts '* Pheonix Oxford'
|
|
50
|
-
file.write PicturehouseUk::Internal::Website.new.cinema('Phoenix_Picturehouse')
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
File.open(fixture('info/Phoenix_Picturehouse'), 'w') do |file|
|
|
54
|
-
puts '* Pheonix Oxford Information'
|
|
55
|
-
file.write PicturehouseUk::Internal::Website.new.info('Phoenix_Picturehouse')
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
File.open(fixture('whats_on/Phoenix_Picturehouse'), 'w') do |file|
|
|
59
|
-
puts '* Pheonix Oxford Whats On'
|
|
60
|
-
file.write PicturehouseUk::Internal::Website.new.whats_on('Phoenix_Picturehouse')
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# NATIONAL MEDIA MUSEUM (IMAX)
|
|
64
|
-
|
|
65
|
-
File.open(fixture('cinema/National_Media_Museum'), 'w') do |file|
|
|
66
|
-
puts '* National Media Museum'
|
|
67
|
-
file.write PicturehouseUk::Internal::Website.new.cinema('National_Media_Museum')
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
File.open(fixture('whats_on/National_Media_Museum'), 'w') do |file|
|
|
71
|
-
puts '* National Media Museum Whats On'
|
|
72
|
-
file.write PicturehouseUk::Internal::Website.new.whats_on('National_Media_Museum')
|
|
73
|
-
end
|