Permalink
Browse files

extract show_name function in show loader

  • Loading branch information...
1 parent c19ae69 commit 21c3a95611aa62c0f67d7622511c669cc99838d0 @tardate committed Dec 30, 2011
Showing with 13 additions and 2 deletions.
  1. +7 −2 lib/navd/scraper/show_loader.rb
  2. +6 −0 spec/lib/scraper/show_loader_spec.rb
@@ -1,7 +1,7 @@
module ::Navd::Scraper
class ShowLoader
attr_accessor :number, :spider, :uri, :found, :published, :errors
- attr_reader :attributes, :show_notes
+ attr_reader :attributes, :show_notes, :format_version
attr_reader :p_shownotes_main # Nokogiri::HTML::Document of the main shownotes page being processed
@@ -44,7 +44,7 @@ def scan_show_assets
:assets_url => assets_url,
:url => episode_url,
:credits => credits,
- :name => credits_list.try(:first)
+ :name => show_name
})
show_notes
errors.empty?
@@ -95,6 +95,11 @@ def credits_list
end
protected :credits, :credits_list
+ # Returns the human name of the show
+ def show_name
+ credits_list.try(:first)
+ end
+
# Returns the show date (as extracted from the audio file name)
# Dodgy approach, but seems the most reliable way of automatically getting the show date
def published_date
@@ -38,4 +38,10 @@
its(:errors) { should_not be_empty }
end
+ describe "#show_name" do
+ let(:expected) { 'show name' }
+ subject { show_loader.show_name }
+ before { show_loader.stub(:credits_list).and_return([expected,'','']) }
+ it { should eql(expected) }
+ end
end

0 comments on commit 21c3a95

Please sign in to comment.