Skip to content

Commit

Permalink
Fix a RuboCop Metrics/BlockLength error by reducing repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
mhl committed Jun 28, 2017
1 parent 52485c7 commit d7d9988
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,19 @@
summaries_finder = Document::Finder.new(pattern: summaries_pattern, baseurl: '')
quote_finder = Document::Finder.new(pattern: info_pattern('quote-of-the-week'), baseurl: '')
featured_summaries = summaries_finder.find_featured
people = [
featured_people = [
[governors, 'Governors', '/position/executive-governor/'],
[senators, 'Senators', '/position/senator/'],
[representatives, 'Representatives', '/position/representative/']
].map do |collection, display_text, url|
PageFragment::FeaturedPerson.new(
governors.featured_person(featured_summaries),
'Governors',
'/position/executive-governor/'
),
PageFragment::FeaturedPerson.new(
senators.featured_person(featured_summaries),
'Senators',
'/position/senator/'
),
PageFragment::FeaturedPerson.new(
representatives.featured_person(featured_summaries),
'Representatives',
'/position/representative/'
collection.featured_person(featured_summaries), display_text, url
)
]
end
@page = Page::Homepage.new(
posts: posts_finder.find_all,
events: events_finder.find_all,
featured_people: people,
featured_people: featured_people,
quote: quote_finder.find_single
)
erb :homepage
Expand Down

0 comments on commit d7d9988

Please sign in to comment.