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:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 1720bc250f6881e64c64249df35ba6d4442b06c6
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0b62081df2424d1ce0074915fdbec9b3560d5beb
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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 
     | 
    
         | 
    
        data/spec/feature/search_spec.rb
    CHANGED
    
    | 
         @@ -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(' 
     | 
| 
      
 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]). 
     | 
| 
      
 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
         
     |