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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc7f47e1bf37f9995c5ca275813ffe5d8730596e
4
- data.tar.gz: 8d63a6095235389577e80de18d76552f89c6293e
3
+ metadata.gz: 9b2b5301da3720096e032a4724f261260088819f
4
+ data.tar.gz: 22d763115ac63d96bce5b56853c42a7c7ed7bf68
5
5
  SHA512:
6
- metadata.gz: b068354d804434d10beec8e9319e7c5de342301c37737979697f977e23d93381de264e7a1ee31607f941020507d1fd0947493635438aa53920e3aca3ee42229b
7
- data.tar.gz: 56f8adab48cd13a255b6c3099f95f61fab02c7afd604c2312a3be0b7b38fce6f68deef39d6677ae268eea541468756c4ce003f5a09aff31b99fdc15879f70ba2
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 = '#today .listings > li, #this-week .listings > li, #further-ahead .listings > li'
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
- date = Date.today
15
- doc.css(LISTINGS).each_with_object([]) do |node, result|
16
- if date?(node.text)
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 date_parse(text)
27
- Date.parse(text)
28
- rescue ArgumentError
29
- nil
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.cinema(cinema_id)
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)
@@ -1,6 +1,6 @@
1
1
  # Ruby interface for http://www.picturehouses.co.uk
2
- # @version 3.0.13
2
+ # @version 3.0.14
3
3
  module PicturehouseUk
4
4
  # Gem version
5
- VERSION = '3.0.13'
5
+ VERSION = '3.0.14'
6
6
  end
@@ -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