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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Rakefile +2 -1
- data/lib/picturehouse_uk/cinema.rb +1 -1
- data/lib/picturehouse_uk/internal/parser/address.rb +28 -26
- data/lib/picturehouse_uk/internal/website.rb +2 -0
- data/lib/picturehouse_uk/version.rb +2 -2
- data/test/lib/picturehouse_uk/internal/parser/address_parser_test.rb +53 -0
- data/test/lib/picturehouse_uk/internal/parser/screenings_test.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3309c319847ba5789dd2836342f99ebfb635bc0c
|
4
|
+
data.tar.gz: db0322dc4951aeb778d15f6f8f0bef744630f3b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdec9a405a28e8601653c0459f7bc060eead1b6daeb01f492c9e83017ea68ced65fbb0147b50dfc340289b49f54b0e776c65019b698dcd38905ac05c8336dcfe
|
7
|
+
data.tar.gz: 3ec01f064dce248f89045591858967e0775533f9ac347fe5738c477a677a94273577ddb11fcbf7c81c276b963ef4099984adb3d9f0b494460761d9e09788d68c
|
data/CHANGELOG.md
CHANGED
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::
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
27
|
+
private
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
def town
|
30
|
+
@town ||= array[0].to_s.split(', ')[-1]
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
def array
|
34
|
+
@array ||= Array(@html.gsub(/\<.?p.?\>/, '').split('<br>'))
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
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
|
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.
|
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-
|
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
|