picturehouse_uk 3.0.13 → 3.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/picturehouse_uk/internal/parser/screenings.rb +14 -18
- data/lib/picturehouse_uk/internal/website.rb +8 -0
- data/lib/picturehouse_uk/version.rb +2 -2
- data/test/fixture_updater.rb +20 -0
- data/test/fixtures/cinema/Duke_Of_Yorks.html +947 -685
- data/test/fixtures/cinema/Dukes_At_Komedia.html +2336 -1546
- data/test/fixtures/cinema/National_Media_Museum.html +3930 -2128
- data/test/fixtures/cinema/Phoenix_Picturehouse.html +2765 -1025
- data/test/fixtures/home.html +55 -64
- data/test/fixtures/info/Duke_Of_Yorks.html +41 -21
- data/test/fixtures/info/Dukes_At_Komedia.html +37 -20
- data/test/fixtures/info/Phoenix_Picturehouse.html +36 -21
- data/test/fixtures/whats_on/Duke_Of_Yorks.html +2737 -0
- data/test/fixtures/whats_on/Dukes_At_Komedia.html +5132 -0
- data/test/fixtures/whats_on/National_Media_Museum.html +9690 -0
- data/test/fixtures/whats_on/Phoenix_Picturehouse.html +4916 -0
- data/test/lib/picturehouse_uk/film_test.rb +3 -3
- data/test/lib/picturehouse_uk/internal/parser/screenings_test.rb +3 -3
- data/test/lib/picturehouse_uk/internal/website_test.rb +22 -3
- data/test/lib/picturehouse_uk/screening_test.rb +5 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b2b5301da3720096e032a4724f261260088819f
|
4
|
+
data.tar.gz: 22d763115ac63d96bce5b56853c42a7c7ed7bf68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be35d4ae43654002ab6946598a660a5a3c52d0918305a4b7d958ca815567dbfa173e507c43b2797937486d4daa8881308ec4c500fa20a85461cdb07c0472529a
|
7
|
+
data.tar.gz: 057eca9caad7fc07ef6c14b3af858ee954ea7176a956b04f1d2cf7c91ab8afda4ac53e1cd19995cfac814b371c47e99e5c4de9b5bea5b43217750b4e6fca8f73
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [3.0.14] - 2015-05-17
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
- Films for the following year incorrectly dated
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- Internal date calculation method changed for screenings
|
11
|
+
|
4
12
|
## [3.0.13] - 2015-05-06
|
5
13
|
|
6
14
|
### Added
|
@@ -6,39 +6,35 @@ module PicturehouseUk
|
|
6
6
|
# Parses screenings page into an array of hashes for an individual cinema
|
7
7
|
Screenings = Struct.new(:cinema_id) do
|
8
8
|
# css for a day of films & screenings
|
9
|
-
LISTINGS = '
|
9
|
+
LISTINGS = '.listings li:not(.dark)'
|
10
|
+
DATE = '.nav-collapse.collapse'
|
10
11
|
|
11
12
|
# parse the cinema page into an array of screenings attributes
|
12
13
|
# @return [Array<Hash>]
|
13
14
|
def to_a
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
date = date_parse(node.text)
|
18
|
-
else
|
19
|
-
result << FilmWithShowtimes.new(node, date).to_a
|
20
|
-
end
|
21
|
-
end.flatten
|
15
|
+
doc.css(LISTINGS).flat_map do |node|
|
16
|
+
FilmWithShowtimes.new(node, date_from_html(node.css(DATE).to_s)).to_a
|
17
|
+
end
|
22
18
|
end
|
23
19
|
|
24
20
|
private
|
25
21
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
def date_from_html(html)
|
23
|
+
if !!html.match(/listings-further-ahead-today/)
|
24
|
+
Date.now
|
25
|
+
else
|
26
|
+
html.match(/listings-further-ahead-(\d{4})(\d{2})(\d{2})/) do |m|
|
27
|
+
Date.new(m[1].to_i, m[2].to_i, m[3].to_i)
|
28
|
+
end
|
29
|
+
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def doc
|
33
33
|
@doc ||= Nokogiri::HTML(page)
|
34
34
|
end
|
35
35
|
|
36
|
-
def date?(text)
|
37
|
-
!!text.match(/(Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day \d{1,2}(st|nd|th) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/)
|
38
|
-
end
|
39
|
-
|
40
36
|
def page
|
41
|
-
@page ||= PicturehouseUk::Internal::Website.new.
|
37
|
+
@page ||= PicturehouseUk::Internal::Website.new.whats_on(cinema_id)
|
42
38
|
end
|
43
39
|
end
|
44
40
|
end
|
@@ -12,6 +12,14 @@ module PicturehouseUk
|
|
12
12
|
get("cinema/#{id}")
|
13
13
|
end
|
14
14
|
|
15
|
+
# get the cinema screenings page for passed id
|
16
|
+
# @return [String]
|
17
|
+
def whats_on(id)
|
18
|
+
get("cinema/#{id}/Whats_On")
|
19
|
+
rescue OpenURI::HTTPError
|
20
|
+
''
|
21
|
+
end
|
22
|
+
|
15
23
|
# get the cinema contact information page for passed id
|
16
24
|
# @return [String]
|
17
25
|
def info(id)
|
data/test/fixture_updater.rb
CHANGED
@@ -21,6 +21,11 @@ File.open(fixture('info/Duke_Of_Yorks'), 'w') do |file|
|
|
21
21
|
file.write PicturehouseUk::Internal::Website.new.info('Duke_Of_Yorks')
|
22
22
|
end
|
23
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
|
+
|
24
29
|
# KOMEDIA
|
25
30
|
|
26
31
|
File.open(fixture('cinema/Dukes_At_Komedia'), 'w') do |file|
|
@@ -33,6 +38,11 @@ File.open(fixture('info/Dukes_At_Komedia'), 'w') do |file|
|
|
33
38
|
file.write PicturehouseUk::Internal::Website.new.info('Dukes_At_Komedia')
|
34
39
|
end
|
35
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
|
+
|
36
46
|
# PHEONIX OXFORD
|
37
47
|
|
38
48
|
File.open(fixture('cinema/Phoenix_Picturehouse'), 'w') do |file|
|
@@ -45,9 +55,19 @@ File.open(fixture('info/Phoenix_Picturehouse'), 'w') do |file|
|
|
45
55
|
file.write PicturehouseUk::Internal::Website.new.info('Phoenix_Picturehouse')
|
46
56
|
end
|
47
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
|
+
|
48
63
|
# NATIONAL MEDIA MUSEUM (IMAX)
|
49
64
|
|
50
65
|
File.open(fixture('cinema/National_Media_Museum'), 'w') do |file|
|
51
66
|
puts '* National Media Museum'
|
52
67
|
file.write PicturehouseUk::Internal::Website.new.cinema('National_Media_Museum')
|
53
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
|