{"action":"created","comment":{"url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/comments/30977816","id":30977816,"diff_hunk":"@@ -229,135 +231,114 @@ def legislatures\n       legislative_memberships.count.zero? ? [] : [\n         {\n           id: 'legislature',\n-          name: 'Legislature', \n+          name: 'Legislature',\n           classification: 'legislature',\n-          legislative_periods: terms,\n-        }.select { |_, v| !v.nil? } \n+          legislative_periods: terms\n+        }.select { |_, v| !v.nil? }\n       ]\n     end\n \n     def executive\n       executive_memberships.count.zero? ? [] : [{\n         id: 'executive',\n-        name: 'Executive', \n-        classification: 'executive',\n+        name: 'Executive',\n+        classification: 'executive'\n       }]\n     end\n \n-    def legislative_memberships \n-      @_lmems ||= @csv.find_all { |r| r.has_key? :group }.map do |r|\n-        mem = { \n+    def legislative_memberships\n+      @_lmems ||= @csv.select { |r| r.key? :group }.map do |r|\n+        mem = {\n           person_id:          r[:id],\n-          organization_id:    find_chamber_id(r[:chamber]) || \"legislature\",\n+          organization_id:    find_chamber_id(r[:chamber]) || 'legislature',\n           role:               'member',\n           on_behalf_of_id:    r[:group_id] || find_party_id(r[:group]),\n           start_date:         r[:start_date],\n-          end_date:           r[:end_date],\n-        }.select { |_, v| !v.nil? } \n-        mem[:area] = { name: r[:area] } if r.has_key? :area and !r[:area].nil?\n-        mem[:legislative_period_id] = \"term/#{r[:term].downcase.gsub(/\\s+/,'_')}\" if r.has_key? :term\n+          end_date:           r[:end_date]\n+        }.select { |_, v| !v.nil? }\n+        mem[:area] = { name: r[:area] } if r.key?(:area) && !r[:area].nil?\n+        mem[:legislative_period_id] = \"term/#{_idify(r[:term])}\" if r.key? :term\n         mem\n       end\n     end\n \n-    def executive_memberships \n-      @_emems ||= @csv.find_all { |r| r.has_key? :executive and !r[:executive].nil? }.map do |r|\n-        mem = { \n+    def executive_memberships\n+      @_emems ||= @csv.select { |r| r.key?(:executive) && !r[:executive].nil? }.map do |r|\n+        mem = {\n           person_id:          r[:id],\n           organization_id:    'executive',\n-          role:               r[:executive],\n+          role:               r[:executive]\n         }\n-        mem[:legislative_period] = \"term/#{r[:term].downcase.gsub(/\\s+/,'_')}\" if r.has_key? :term\n+        mem[:legislative_period] = \"term/#{_idify(r[:term])}\" if r.key? :term\n         mem\n       end\n     end\n \n-\n     def warnings\n-      handled = @raw_csv.headers.partition { |got| Popolo.model.has_key? got }\n+      handled = @raw_csv.headers.partition { |got| MODEL.key? got }\n       # Ruby 2.1+ seems to return nil for empty headers; 2.0- returns \"\"\n-      blank = @raw_csv.headers.find_all { |h| h.nil? or h.empty? }.count\n-      dupes = @raw_csv.headers.group_by { |h| h }.find_all { |h, hs| hs.size > 1 }\n+      blank = @raw_csv.headers.count    { |h| h.nil? || h.empty? }\n+      dupes = @raw_csv.headers.group_by { |h| h }.select { |_, hs| hs.size > 1 }\n \n       warnings = {\n         skipped: handled.last,\n-        dupes: dupes.map { |h, hs| h }\n-      }.reject { |_,v| v.nil? or v.empty? }\n+        dupes: dupes.map { |h, _| h }\n+      }.reject { |_, v| v.nil? || v.empty? }\n       warnings[:blank] = blank unless blank.zero?\n-      return if warnings.empty?\n-      return warnings\n+      warnings.empty? ? nil : warnings\n     end\n \n     private\n \n     def find_party_id(name)\n-      (parties.find { |p| p[:name] == name } or return)[:id]\n+      (parties.find { |p| p[:name] == name } || return)[:id]\n     end\n \n     def find_chamber_id(name)\n-      (chambers.find { |p| p[:name] == name } or return)[:id]\n+      (chambers.find { |p| p[:name] == name } || return)[:id]","path":"lib/csv_to_popolo.rb","position":438,"original_position":438,"commit_id":"e5f8241eab04e3163f9d845557ae0e72e3f09e3c","original_commit_id":"e5f8241eab04e3163f9d845557ae0e72e3f09e3c","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Prefer `detect` over `find`.","created_at":"2015-05-25T12:41:45Z","updated_at":"2015-05-25T12:41:45Z","html_url":"https://github.com/tmtmtmtm/csv_to_popolo/pull/63#discussion_r30977816","pull_request_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/comments/30977816"},"html":{"href":"https://github.com/tmtmtmtm/csv_to_popolo/pull/63#discussion_r30977816"},"pull_request":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/63","id":36137333,"html_url":"https://github.com/tmtmtmtm/csv_to_popolo/pull/63","diff_url":"https://github.com/tmtmtmtm/csv_to_popolo/pull/63.diff","patch_url":"https://github.com/tmtmtmtm/csv_to_popolo/pull/63.patch","issue_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues/63","number":63,"state":"open","locked":false,"title":"Rubocop tidying #1","user":{"login":"tmtmtmtm","id":57483,"avatar_url":"https://avatars.githubusercontent.com/u/57483?v=3","gravatar_id":"","url":"https://api.github.com/users/tmtmtmtm","html_url":"https://github.com/tmtmtmtm","followers_url":"https://api.github.com/users/tmtmtmtm/followers","following_url":"https://api.github.com/users/tmtmtmtm/following{/other_user}","gists_url":"https://api.github.com/users/tmtmtmtm/gists{/gist_id}","starred_url":"https://api.github.com/users/tmtmtmtm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmtmtmtm/subscriptions","organizations_url":"https://api.github.com/users/tmtmtmtm/orgs","repos_url":"https://api.github.com/users/tmtmtmtm/repos","events_url":"https://api.github.com/users/tmtmtmtm/events{/privacy}","received_events_url":"https://api.github.com/users/tmtmtmtm/received_events","type":"User","site_admin":false},"body":"Lots of tidying suggested by Rubocop","created_at":"2015-05-25T12:41:37Z","updated_at":"2015-05-25T12:41:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9dec7603c1e05b2cf86d36f43702a88d4d65785f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/63/commits","review_comments_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/63/comments","review_comment_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues/63/comments","statuses_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/statuses/e5f8241eab04e3163f9d845557ae0e72e3f09e3c","head":{"label":"tmtmtmtm:rubocop","ref":"rubocop","sha":"e5f8241eab04e3163f9d845557ae0e72e3f09e3c","user":{"login":"tmtmtmtm","id":57483,"avatar_url":"https://avatars.githubusercontent.com/u/57483?v=3","gravatar_id":"","url":"https://api.github.com/users/tmtmtmtm","html_url":"https://github.com/tmtmtmtm","followers_url":"https://api.github.com/users/tmtmtmtm/followers","following_url":"https://api.github.com/users/tmtmtmtm/following{/other_user}","gists_url":"https://api.github.com/users/tmtmtmtm/gists{/gist_id}","starred_url":"https://api.github.com/users/tmtmtmtm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmtmtmtm/subscriptions","organizations_url":"https://api.github.com/users/tmtmtmtm/orgs","repos_url":"https://api.github.com/users/tmtmtmtm/repos","events_url":"https://api.github.com/users/tmtmtmtm/events{/privacy}","received_events_url":"https://api.github.com/users/tmtmtmtm/received_events","type":"User","site_admin":false},"repo":{"id":30541798,"name":"csv_to_popolo","full_name":"tmtmtmtm/csv_to_popolo","owner":{"login":"tmtmtmtm","id":57483,"avatar_url":"https://avatars.githubusercontent.com/u/57483?v=3","gravatar_id":"","url":"https://api.github.com/users/tmtmtmtm","html_url":"https://github.com/tmtmtmtm","followers_url":"https://api.github.com/users/tmtmtmtm/followers","following_url":"https://api.github.com/users/tmtmtmtm/following{/other_user}","gists_url":"https://api.github.com/users/tmtmtmtm/gists{/gist_id}","starred_url":"https://api.github.com/users/tmtmtmtm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmtmtmtm/subscriptions","organizations_url":"https://api.github.com/users/tmtmtmtm/orgs","repos_url":"https://api.github.com/users/tmtmtmtm/repos","events_url":"https://api.github.com/users/tmtmtmtm/events{/privacy}","received_events_url":"https://api.github.com/users/tmtmtmtm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tmtmtmtm/csv_to_popolo","description":null,"fork":false,"url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo","forks_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/forks","keys_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/teams","hooks_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/hooks","issue_events_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues/events{/number}","events_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/events","assignees_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/assignees{/user}","branches_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/branches{/branch}","tags_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/tags","blobs_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/refs{/sha}","trees_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/statuses/{sha}","languages_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/languages","stargazers_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/stargazers","contributors_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/contributors","subscribers_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/subscribers","subscription_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/subscription","commits_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/commits{/sha}","git_commits_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/commits{/sha}","comments_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/comments{/number}","issue_comment_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues/comments{/number}","contents_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/contents/{+path}","compare_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/merges","archive_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/downloads","issues_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues{/number}","pulls_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls{/number}","milestones_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/milestones{/number}","notifications_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/labels{/name}","releases_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/releases{/id}","created_at":"2015-02-09T15:14:06Z","updated_at":"2015-05-07T11:44:56Z","pushed_at":"2015-05-25T12:41:37Z","git_url":"git://github.com/tmtmtmtm/csv_to_popolo.git","ssh_url":"git@github.com:tmtmtmtm/csv_to_popolo.git","clone_url":"https://github.com/tmtmtmtm/csv_to_popolo.git","svn_url":"https://github.com/tmtmtmtm/csv_to_popolo","homepage":null,"size":724,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"base":{"label":"tmtmtmtm:master","ref":"master","sha":"c22cc654a99aefbb09a53105cb8dcb6ed04dc739","user":{"login":"tmtmtmtm","id":57483,"avatar_url":"https://avatars.githubusercontent.com/u/57483?v=3","gravatar_id":"","url":"https://api.github.com/users/tmtmtmtm","html_url":"https://github.com/tmtmtmtm","followers_url":"https://api.github.com/users/tmtmtmtm/followers","following_url":"https://api.github.com/users/tmtmtmtm/following{/other_user}","gists_url":"https://api.github.com/users/tmtmtmtm/gists{/gist_id}","starred_url":"https://api.github.com/users/tmtmtmtm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmtmtmtm/subscriptions","organizations_url":"https://api.github.com/users/tmtmtmtm/orgs","repos_url":"https://api.github.com/users/tmtmtmtm/repos","events_url":"https://api.github.com/users/tmtmtmtm/events{/privacy}","received_events_url":"https://api.github.com/users/tmtmtmtm/received_events","type":"User","site_admin":false},"repo":{"id":30541798,"name":"csv_to_popolo","full_name":"tmtmtmtm/csv_to_popolo","owner":{"login":"tmtmtmtm","id":57483,"avatar_url":"https://avatars.githubusercontent.com/u/57483?v=3","gravatar_id":"","url":"https://api.github.com/users/tmtmtmtm","html_url":"https://github.com/tmtmtmtm","followers_url":"https://api.github.com/users/tmtmtmtm/followers","following_url":"https://api.github.com/users/tmtmtmtm/following{/other_user}","gists_url":"https://api.github.com/users/tmtmtmtm/gists{/gist_id}","starred_url":"https://api.github.com/users/tmtmtmtm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmtmtmtm/subscriptions","organizations_url":"https://api.github.com/users/tmtmtmtm/orgs","repos_url":"https://api.github.com/users/tmtmtmtm/repos","events_url":"https://api.github.com/users/tmtmtmtm/events{/privacy}","received_events_url":"https://api.github.com/users/tmtmtmtm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tmtmtmtm/csv_to_popolo","description":null,"fork":false,"url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo","forks_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/forks","keys_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/teams","hooks_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/hooks","issue_events_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues/events{/number}","events_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/events","assignees_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/assignees{/user}","branches_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/branches{/branch}","tags_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/tags","blobs_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/refs{/sha}","trees_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/statuses/{sha}","languages_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/languages","stargazers_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/stargazers","contributors_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/contributors","subscribers_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/subscribers","subscription_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/subscription","commits_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/commits{/sha}","git_commits_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/git/commits{/sha}","comments_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/comments{/number}","issue_comment_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues/comments{/number}","contents_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/contents/{+path}","compare_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/merges","archive_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/downloads","issues_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues{/number}","pulls_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls{/number}","milestones_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/milestones{/number}","notifications_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/labels{/name}","releases_url":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/releases{/id}","created_at":"2015-02-09T15:14:06Z","updated_at":"2015-05-07T11:44:56Z","pushed_at":"2015-05-25T12:41:37Z","git_url":"git://github.com/tmtmtmtm/csv_to_popolo.git","ssh_url":"git@github.com:tmtmtmtm/csv_to_popolo.git","clone_url":"https://github.com/tmtmtmtm/csv_to_popolo.git","svn_url":"https://github.com/tmtmtmtm/csv_to_popolo","homepage":null,"size":724,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/63"},"html":{"href":"https://github.com/tmtmtmtm/csv_to_popolo/pull/63"},"issue":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues/63"},"comments":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/tmtmtmtm/csv_to_popolo/statuses/e5f8241eab04e3163f9d845557ae0e72e3f09e3c"}}}}