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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8928be83c7ac5d9f86cff1b129b95ba970bc0c6
4
- data.tar.gz: 21c97b32025427979226899acdc5d48827c3a97f
3
+ metadata.gz: 473ae721f46a03e80dcbbd541c65d5eba2b86c31
4
+ data.tar.gz: e0a1422c50e3d237cdc800837789354f849dbdf2
5
5
  SHA512:
6
- metadata.gz: 0192210b4779c8f3b241f155b33a5df83782688646efaa849d68f4a86b414c2c1fe2d7817dd002c1470f665e96f180ab20b659529d2c3251561a6f55d57011b5
7
- data.tar.gz: c648e6c07bc7f0393788353bcd5f5b61124d4da29aa81c4feefd4fbfa5f077a393230440ee57aa30f5aa8eed50643cc403ea28e4ead00335d2f6283544a2c3e8
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
@@ -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')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blinkbox_films
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Chippindale