Skip to content

Commit

Permalink
Rename find_all to find_published for documents
Browse files Browse the repository at this point in the history
  • Loading branch information
octopusinvitro committed Apr 20, 2017
1 parent 8c93dc2 commit b9b6439
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@
'/position/representative/'
)
]
@page = Page::Homepage.new(posts: posts_finder.find_all, events: events_finder.find_all, featured_people: people)
@page = Page::Homepage.new(
posts: posts_finder.find_published, events: events_finder.find_published, featured_people: people
)
erb :homepage
end

get '/blog/' do
finder = Document::Finder.new(pattern: posts_pattern, baseurl: '/blog/')
@page = Page::Posts.new(posts: finder.find_all, title: 'Blog')
@page = Page::Posts.new(posts: finder.find_published, title: 'Blog')
erb :posts
end

Expand All @@ -116,7 +118,7 @@

get '/events/' do
finder = Document::Finder.new(pattern: events_pattern, baseurl: '/events/')
@page = Page::Posts.new(posts: finder.find_all, title: 'Events')
@page = Page::Posts.new(posts: finder.find_published, title: 'Events')
erb :posts
end

Expand Down Expand Up @@ -287,6 +289,6 @@
finder = Document::Finder.new(pattern: events_pattern, baseurl: '/events/')
@events = finder.find_unpublished
finder = Document::Finder.new(pattern: "#{info_dir}/*.md", baseurl: '/info/')
@infopages = finder.find_all
@infopages = finder.find_published
erb :scraper_start_page, layout: false
end
6 changes: 3 additions & 3 deletions lib/document/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def initialize(pattern:, baseurl:)
def find_single
raise_error_if_multiple_files_found
raise_error_if_no_files_found
find_all.first
find_published.first
end

def find_or_empty
none? ? create_empty_document : find_all.first
none? ? create_empty_document : find_published.first
end

def find_all
def find_published
create_documents.select(&:published?)
end

Expand Down
6 changes: 3 additions & 3 deletions tests/document/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

it 'finds several documents' do
Dir.stub :glob, [new_tempfile(''), new_tempfile('')] do
finder.find_all.count.must_equal(2)
finder.find_published.count.must_equal(2)
end
end

Expand All @@ -29,7 +29,7 @@
---'
filenames = [new_tempfile(published), new_tempfile(nofield), new_tempfile(unpublished)]
Dir.stub :glob, filenames do
finder.find_all.count.must_equal(2)
finder.find_published.count.must_equal(2)
end
end

Expand All @@ -56,7 +56,7 @@

it 'sorts the found filenames alphabetically' do
Dir.stub :glob, [new_tempfile('', 'zed'), new_tempfile('', 'be')] do
finder.find_all.first.send(:basename).start_with?('be').must_equal(true)
finder.find_published.first.send(:basename).start_with?('be').must_equal(true)
end
end

Expand Down

0 comments on commit b9b6439

Please sign in to comment.