bfi_player_search 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb3485213ce0966d67e48e710b21139558dc9354
4
- data.tar.gz: 932e718ec4dccb5e6a8f3d571d8d72f727002370
3
+ metadata.gz: 1720bc250f6881e64c64249df35ba6d4442b06c6
4
+ data.tar.gz: 0b62081df2424d1ce0074915fdbec9b3560d5beb
5
5
  SHA512:
6
- metadata.gz: 43b6362b34288678f810c0bae5be57427531788d4e046fc80dc7cbc57e150e1c839af345739552ecd07bca42f9cf796539949e3a7712f49237617d629e20d64d
7
- data.tar.gz: cc5089280d6dc96eca3bfe0e7ee6b7a2d16e33b83ff15b341b982a92bbe7769a7f3d851c881511bdab8fa3d126058fc58e651f53a19e230d2ab61bf1ed329d57
6
+ metadata.gz: d2c042c104b1343826837e349d89612a5ce90abd3784f4f2d2a624082cec1518432d8f4b232bd72fe357a4d1448997b1e6b60c4f129f9f517249af9f3d25b084
7
+ data.tar.gz: d804ed0470879024ab4c5c7e0225cde7ab6a4582df0424e2764e4073c1b6ed56c3abfbbd0a2e4b3ca08bdd89b522f341ad22b8c3e82f0ec490f2db9e13849039
@@ -34,6 +34,16 @@ module BFIPlayerSearch
34
34
  convert_to_url(path)
35
35
  end
36
36
 
37
+ def running_time_in_minutes
38
+ match = fragment.css('.metrics span').map { |n| %r{(\d+) mins}.match(n.content) }.compact.first
39
+ match && match[1].to_i
40
+ end
41
+
42
+ def director
43
+ match = fragment.css('.metrics span').map { |n| %r{Director\. (.*)\Z}.match(n.content) }.compact.first
44
+ match && match[1].strip
45
+ end
46
+
37
47
  private
38
48
  attr_reader :fragment
39
49
 
@@ -14,7 +14,9 @@ module BFIPlayerSearch
14
14
  :image_url => rp.image_url,
15
15
  :year => rp.year,
16
16
  :certificate => rp.certificate,
17
- :free => rp.free?
17
+ :free => rp.free?,
18
+ :running_time_in_minutes => rp.running_time_in_minutes,
19
+ :director => rp.director
18
20
  }
19
21
  end
20
22
 
@@ -6,12 +6,16 @@ describe 'A search' do
6
6
  end
7
7
 
8
8
  context 'with some results', :vcr do
9
- subject { BFIPlayerSearch::Search.new.search('girl') }
9
+ subject { BFIPlayerSearch::Search.new.search('wild tales') }
10
10
 
11
11
  it { expect(subject).to_not be_empty }
12
- it { expect(subject.first[:title]).to_not be_empty }
12
+ it { expect(subject.first[:title]).to eq 'Wild Tales' }
13
13
  it { expect(subject.first[:url]).to match(%r{^http://player.bfi.org.uk/film/watch-.*}) }
14
14
  it { expect(subject.first[:image_url]).to match(%r{^http://player.bfi.org.uk//media/images/stills/film/.*\.jpg}) }
15
+ it { expect(subject.first[:free]).to be_falsey }
16
+ it { expect(subject.first[:certificate]).to eq('15') }
17
+ it { expect(subject.first[:running_time_in_minutes]).to eq(122) }
18
+ it { expect(subject.first[:director]).to eq('Damian Szifron') }
15
19
  end
16
20
 
17
21
  context 'with unrecognised page format returned' do
@@ -94,4 +94,48 @@ describe BFIPlayerSearch::ResultParser do
94
94
  it { expect(subject).to be_free }
95
95
  end
96
96
  end
97
+
98
+ describe '#running_time_in_minutes' do
99
+ context 'no running time given' do
100
+ it { expect(subject.running_time_in_minutes).to be_nil }
101
+ end
102
+
103
+ context 'running time given' do
104
+ let(:fragment) {
105
+ Nokogiri::HTML::DocumentFragment.parse("<article class='film'>
106
+ <div class='film-preview'>
107
+ <p class='film-info metrics'>
108
+ <span>95 mins</span>
109
+ <span>United Kingdom</span>
110
+ <span>Director. Andrew Haigh</span>
111
+ </p>
112
+ </div>
113
+ </article>")
114
+ }
115
+
116
+ it { expect(subject.running_time_in_minutes).to eq(95) }
117
+ end
118
+ end
119
+
120
+ describe '#director' do
121
+ context 'no director given' do
122
+ it { expect(subject.director).to be_nil }
123
+ end
124
+
125
+ context 'director given' do
126
+ let(:fragment) {
127
+ Nokogiri::HTML::DocumentFragment.parse("<article class='film'>
128
+ <div class='film-preview'>
129
+ <p class='film-info metrics'>
130
+ <span>95 mins</span>
131
+ <span>United Kingdom</span>
132
+ <span>Director. Andrew Haigh</span>
133
+ </p>
134
+ </div>
135
+ </article>")
136
+ }
137
+
138
+ it { expect(subject.director).to eq('Andrew Haigh') }
139
+ end
140
+ end
97
141
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfi_player_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Chippindale