blinkbox_films 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blinkbox_films/search.rb +13 -1
- data/spec/feature/search_spec.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 473ae721f46a03e80dcbbd541c65d5eba2b86c31
|
4
|
+
data.tar.gz: e0a1422c50e3d237cdc800837789354f849dbdf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a851e8361e2bc1e9c75cc4cb3322b1b9a5a2a1e884f9c05186a4a0a5f32a5c88fc54260c5eed808e308ec723b681e295fb85cc4511db3b61f7718f2e44a80857
|
7
|
+
data.tar.gz: aa19ba80560622d0790a057767042577f0fce21f6508f3aa1e7392d082f5181bab94b7b37b9b099c25c6e1a6c1363e50d6f0c95f766a8935b9e5af7f610b3b3a
|
@@ -10,7 +10,9 @@ module BlinkboxFilms
|
|
10
10
|
{
|
11
11
|
:title => rental_title(f),
|
12
12
|
:url => rental_url(f),
|
13
|
-
:image_url => rental_image_url(f)
|
13
|
+
:image_url => rental_image_url(f),
|
14
|
+
:certificate => rental_certificate(f),
|
15
|
+
:running_time_in_minutes => rental_running_time_in_minutes(f)
|
14
16
|
}
|
15
17
|
}
|
16
18
|
|
@@ -52,5 +54,15 @@ module BlinkboxFilms
|
|
52
54
|
def rental_image_url(fragment)
|
53
55
|
fragment.css('noscript img').first.attributes['src'].value
|
54
56
|
end
|
57
|
+
|
58
|
+
def rental_certificate(fragment)
|
59
|
+
match = fragment.css('.c-assetCollectionItem__metaDataItem').map { |n| %r{CERT (\S+)}.match(n.content) }.compact.first
|
60
|
+
match && match[1]
|
61
|
+
end
|
62
|
+
|
63
|
+
def rental_running_time_in_minutes(fragment)
|
64
|
+
match = fragment.css('.c-assetCollectionItem__metaDataItem').map { |n| %r{(\d+) HRS? (\d+) MINS?}.match(n.content) }.compact.first
|
65
|
+
match && (match[1].to_i * 60 + match[2].to_i)
|
66
|
+
end
|
55
67
|
end
|
56
68
|
end
|
data/spec/feature/search_spec.rb
CHANGED
@@ -13,6 +13,8 @@ describe 'A search' do
|
|
13
13
|
it { expect(subject.first[:title]).to eq('The Dark Knight') }
|
14
14
|
it { expect(subject.first[:url]).to eq('http://www.blinkbox.com/movies/the-dark-knight-(28710)') }
|
15
15
|
it { expect(subject.first[:image_url]).to eq('http://cdn2.blinkboxmedia.com/i/contentasset31/000/028/710/1gkiab4e/v=316/w=234;h=132;rm=Crop;q=85/image.jpg') }
|
16
|
+
it { expect(subject.first[:certificate]).to eq('12') }
|
17
|
+
it { expect(subject.first[:running_time_in_minutes]).to eq(152) }
|
16
18
|
end
|
17
19
|
|
18
20
|
context 'with unrecognised page format returned' do
|
@@ -26,7 +28,7 @@ describe 'A search' do
|
|
26
28
|
after do
|
27
29
|
VCR.turn_on!
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
it do
|
31
33
|
expect {
|
32
34
|
BlinkboxFilms::Search.new.search('dark knight')
|