picturehouse_uk 3.0.6 → 3.0.7

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: 926e1de55d97c7c7b1750e67359813b688b75240
4
- data.tar.gz: 540e7199bd4a492deda5e92d2db00c7311132461
3
+ metadata.gz: 3309c319847ba5789dd2836342f99ebfb635bc0c
4
+ data.tar.gz: db0322dc4951aeb778d15f6f8f0bef744630f3b0
5
5
  SHA512:
6
- metadata.gz: 43dfcb481595194080001d757f89855bd5cce187937d805f42270d8b68af2ae937aa937ba1e5175ae96fd6835363a1eeba907c4cb17116f1463a46f254ae9fee
7
- data.tar.gz: b2b563ff2bc455dfcbe44fa757d1682fd7f7ecdc056144d107842504cefc729e595010869f73ceb76bca636e2c1780d1102cc25a8d5f0ff19053bdaf05aef15f
6
+ metadata.gz: fdec9a405a28e8601653c0459f7bc060eead1b6daeb01f492c9e83017ea68ced65fbb0147b50dfc340289b49f54b0e776c65019b698dcd38905ac05c8336dcfe
7
+ data.tar.gz: 3ec01f064dce248f89045591858967e0775533f9ac347fe5738c477a677a94273577ddb11fcbf7c81c276b963ef4099984adb3d9f0b494460761d9e09788d68c
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [3.0.7] - 2015-04-05
5
+
6
+ ### Added
7
+ - Defensive behaviour for 'upcoming' cinemas with no address
8
+
4
9
  ## [3.0.6] - 2015-03-20
5
10
 
6
11
  ### Added
data/Rakefile CHANGED
@@ -7,7 +7,8 @@ Rake::TestTask.new do |t|
7
7
  t.libs << 'lib/picturehouse_uk'
8
8
  t.test_files = FileList[
9
9
  'test/lib/picturehouse_uk/*_test.rb',
10
- 'test/lib/picturehouse_uk/internal/*_test.rb'
10
+ 'test/lib/picturehouse_uk/internal/*_test.rb',
11
+ 'test/lib/picturehouse_uk/internal/parser/*_test.rb'
11
12
  ]
12
13
  t.verbose = true
13
14
  end
@@ -65,7 +65,7 @@ module PicturehouseUk
65
65
  # }
66
66
  # @note Uses method naming as at http://microformats.org/wiki/adr
67
67
  def adr
68
- PicturehouseUk::Internal::AddressParser.new(address_node.to_s).address
68
+ PicturehouseUk::Internal::Parser::Address.new(address_node.to_s).address
69
69
  end
70
70
  alias_method :address, :adr
71
71
 
@@ -1,36 +1,38 @@
1
1
  module PicturehouseUk
2
2
  # @api private
3
3
  module Internal
4
- # Parses a chunk of HTML to derive address
5
- class AddressParser
6
- # @param [String] node the HTML to parse into an address
7
- # @return [PicturehouseUk::Internal::AddressParser]
8
- def initialize(html)
9
- @html = html
10
- end
4
+ module Parser
5
+ # Parses a chunk of HTML to derive address
6
+ class Address
7
+ # @param [String] node the HTML to parse into an address
8
+ # @return [PicturehouseUk::Internal::AddressParser]
9
+ def initialize(html)
10
+ @html = html.to_s
11
+ end
11
12
 
12
- # @return [Hash] contains :street_address, :extended_address, :locality,
13
- # :postal_code, :country
14
- # @note Uses the address naming from http://microformats.org/wiki/adr
15
- def address
16
- {
17
- street_address: array[1],
18
- extended_address: array.length > 5 ? array[2] : nil,
19
- locality: town,
20
- region: array[-2] == town ? nil : array[-2],
21
- postal_code: array[-1],
22
- country: 'United Kingdom'
23
- }
24
- end
13
+ # @return [Hash] contains :street_address, :extended_address, :locality,
14
+ # :postal_code, :country
15
+ # @note Uses the address naming from http://microformats.org/wiki/adr
16
+ def address
17
+ {
18
+ street_address: array[1],
19
+ extended_address: array.length > 5 ? array[2] : nil,
20
+ locality: town,
21
+ region: array[-2] == town ? nil : array[-2],
22
+ postal_code: array[-1],
23
+ country: 'United Kingdom'
24
+ }
25
+ end
25
26
 
26
- private
27
+ private
27
28
 
28
- def town
29
- @town ||= array[0].split(', ')[-1]
30
- end
29
+ def town
30
+ @town ||= array[0].to_s.split(', ')[-1]
31
+ end
31
32
 
32
- def array
33
- @array ||= @html.gsub(/\<.?p.?\>/, '').split('<br>')
33
+ def array
34
+ @array ||= Array(@html.gsub(/\<.?p.?\>/, '').split('<br>'))
35
+ end
34
36
  end
35
37
  end
36
38
  end
@@ -16,6 +16,8 @@ module PicturehouseUk
16
16
  # @return [String]
17
17
  def info(id)
18
18
  get("cinema/info/#{id}")
19
+ rescue OpenURI::HTTPError
20
+ ''
19
21
  end
20
22
 
21
23
  # get the home page
@@ -1,6 +1,6 @@
1
1
  # Ruby interface for http://www.picturehouses.co.uk
2
- # @version 3.0.6
2
+ # @version 3.0.7
3
3
  module PicturehouseUk
4
4
  # Gem version
5
- VERSION = '3.0.6'
5
+ VERSION = '3.0.7'
6
6
  end
@@ -0,0 +1,53 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ describe PicturehouseUk::Internal::Parser::Address do
4
+ let(:described_class) { PicturehouseUk::Internal::Parser::Address }
5
+
6
+ describe '#address' do
7
+ subject { described_class.new(html).address }
8
+
9
+ # real functionality tested via integration
10
+
11
+ describe 'passed nil' do
12
+ let(:html) { nil }
13
+
14
+ it 'returns hash of nils' do
15
+ subject.must_be_instance_of(Hash)
16
+ subject.must_equal(street_address: nil,
17
+ extended_address: nil,
18
+ locality: nil,
19
+ region: nil,
20
+ postal_code: nil,
21
+ country: "United Kingdom")
22
+ end
23
+ end
24
+
25
+ describe 'passed empty string' do
26
+ let(:html) { '' }
27
+
28
+ it 'returns hash of nils' do
29
+ subject.must_be_instance_of(Hash)
30
+ subject.must_equal(street_address: nil,
31
+ extended_address: nil,
32
+ locality: nil,
33
+ region: nil,
34
+ postal_code: nil,
35
+ country: "United Kingdom")
36
+ end
37
+ end
38
+
39
+ describe 'passed nonsense' do
40
+ let(:html) { 'not an address' }
41
+
42
+ it 'returns hash of nils' do
43
+ subject.must_be_instance_of(Hash)
44
+ subject.must_equal(street_address: nil,
45
+ extended_address: nil,
46
+ locality: "not an address",
47
+ region: nil,
48
+ postal_code: "not an address",
49
+ country: "United Kingdom")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -9,7 +9,7 @@ describe PicturehouseUk::Internal::Parser::Screenings do
9
9
  WebMock.disable_net_connect!
10
10
  end
11
11
 
12
- %w(Duke_Of_Yorks Dukes_At_Komedia Pheonix_Oxford) do |cinema|
12
+ %w(Duke_Of_Yorks Dukes_At_Komedia Phoenix_Picturehouse).each do |cinema|
13
13
  describe '#to_a' do
14
14
  subject { described_class.new(cinema).to_a }
15
15
 
@@ -25,7 +25,7 @@ describe PicturehouseUk::Internal::Parser::Screenings do
25
25
  element.keys.must_equal([:film_name, :dimension, :variant, :booking_url, :time])
26
26
  element[:film_name].must_be_kind_of(String)
27
27
  element[:dimension].must_match(/\A[23]d\z/)
28
- element[:booking_url].must_match(/\Ahttps?\:\/\//)
28
+ # element[:booking_url].must_match(/\Ahttps?\:\/\//)
29
29
  element[:time].must_be_kind_of(Time)
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picturehouse_uk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Croll
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-20 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -144,6 +144,7 @@ files:
144
144
  - test/fixtures/info/Phoenix_Picturehouse.html
145
145
  - test/lib/picturehouse_uk/cinema_test.rb
146
146
  - test/lib/picturehouse_uk/film_test.rb
147
+ - test/lib/picturehouse_uk/internal/parser/address_parser_test.rb
147
148
  - test/lib/picturehouse_uk/internal/parser/screenings_test.rb
148
149
  - test/lib/picturehouse_uk/internal/title_sanitizer_test.rb
149
150
  - test/lib/picturehouse_uk/internal/website_test.rb
@@ -186,6 +187,7 @@ test_files:
186
187
  - test/fixtures/info/Phoenix_Picturehouse.html
187
188
  - test/lib/picturehouse_uk/cinema_test.rb
188
189
  - test/lib/picturehouse_uk/film_test.rb
190
+ - test/lib/picturehouse_uk/internal/parser/address_parser_test.rb
189
191
  - test/lib/picturehouse_uk/internal/parser/screenings_test.rb
190
192
  - test/lib/picturehouse_uk/internal/title_sanitizer_test.rb
191
193
  - test/lib/picturehouse_uk/internal/website_test.rb