Skip to content

Commit

Permalink
Merge pull request #9 from everypolitician-scrapers/separate-honorifi…
Browse files Browse the repository at this point in the history
…c-prefixes

Add honorific_prefix field
  • Loading branch information
tmtmtmtm committed Feb 17, 2017
2 parents 0e83df9 + 4d05676 commit 9323d0a
Show file tree
Hide file tree
Showing 5 changed files with 580 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lib/member_div.rb
@@ -1,13 +1,18 @@
# frozen_string_literal: true
require 'scraped'
require 'execjs'

class MemberDiv < Scraped::HTML
field :id do
email.sub(/@.*/, '')
end

field :name do
noko.css('#org_title').text.tidy
name_parts.reject { |part| titles.include? part }.map(&:tidy).join(' ')
end

field :honorific_prefix do
name_parts.select { |part| titles.include? part }.map(&:tidy).join(';')
end

field :image do
Expand All @@ -27,4 +32,14 @@ class MemberDiv < Scraped::HTML
field :source do
url
end

private

def titles
%(drs.)
end

def name_parts
noko.css('#org_title').text.split(' ')
end
end
1 change: 1 addition & 0 deletions lib/members_page.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'scraped'
require_relative 'member_div'

class MembersPage < Scraped::HTML
decorator Scraped::Response::Decorator::AbsoluteUrls
Expand Down
1 change: 0 additions & 1 deletion scraper.rb
Expand Up @@ -2,7 +2,6 @@
# encoding: utf-8
# frozen_string_literal: true

require 'execjs'
require 'pry'
require 'require_all'
require 'scraped'
Expand Down

0 comments on commit 9323d0a

Please sign in to comment.