{"action":"created","issue":{"url":"https://api.github.com/repos/everypolitician/everypolitician-data/issues/16587","repository_url":"https://api.github.com/repos/everypolitician/everypolitician-data","labels_url":"https://api.github.com/repos/everypolitician/everypolitician-data/issues/16587/labels{/name}","comments_url":"https://api.github.com/repos/everypolitician/everypolitician-data/issues/16587/comments","events_url":"https://api.github.com/repos/everypolitician/everypolitician-data/issues/16587/events","html_url":"https://github.com/everypolitician/everypolitician-data/pull/16587","id":175294630,"number":16587,"title":"Update mapping method in the UuidMapFile class","user":{"login":"octopusinvitro","id":2157089,"avatar_url":"https://avatars.githubusercontent.com/u/2157089?v=3","gravatar_id":"","url":"https://api.github.com/users/octopusinvitro","html_url":"https://github.com/octopusinvitro","followers_url":"https://api.github.com/users/octopusinvitro/followers","following_url":"https://api.github.com/users/octopusinvitro/following{/other_user}","gists_url":"https://api.github.com/users/octopusinvitro/gists{/gist_id}","starred_url":"https://api.github.com/users/octopusinvitro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octopusinvitro/subscriptions","organizations_url":"https://api.github.com/users/octopusinvitro/orgs","repos_url":"https://api.github.com/users/octopusinvitro/repos","events_url":"https://api.github.com/users/octopusinvitro/events{/privacy}","received_events_url":"https://api.github.com/users/octopusinvitro/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/everypolitician/everypolitician-data/labels/4%20%E2%80%94%C2%A0Done%20(ready%20for%20Review)","name":"4 — Done (ready for Review)","color":"CCCCCC"}],"state":"open","locked":false,"assignee":{"login":"chrismytton","id":22996,"avatar_url":"https://avatars.githubusercontent.com/u/22996?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismytton","html_url":"https://github.com/chrismytton","followers_url":"https://api.github.com/users/chrismytton/followers","following_url":"https://api.github.com/users/chrismytton/following{/other_user}","gists_url":"https://api.github.com/users/chrismytton/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismytton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismytton/subscriptions","organizations_url":"https://api.github.com/users/chrismytton/orgs","repos_url":"https://api.github.com/users/chrismytton/repos","events_url":"https://api.github.com/users/chrismytton/events{/privacy}","received_events_url":"https://api.github.com/users/chrismytton/received_events","type":"User","site_admin":false},"assignees":[{"login":"chrismytton","id":22996,"avatar_url":"https://avatars.githubusercontent.com/u/22996?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismytton","html_url":"https://github.com/chrismytton","followers_url":"https://api.github.com/users/chrismytton/followers","following_url":"https://api.github.com/users/chrismytton/following{/other_user}","gists_url":"https://api.github.com/users/chrismytton/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismytton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismytton/subscriptions","organizations_url":"https://api.github.com/users/chrismytton/orgs","repos_url":"https://api.github.com/users/chrismytton/repos","events_url":"https://api.github.com/users/chrismytton/events{/privacy}","received_events_url":"https://api.github.com/users/chrismytton/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-09-06T16:40:49Z","updated_at":"2016-09-06T16:59:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/everypolitician/everypolitician-data/pulls/16587","html_url":"https://github.com/everypolitician/everypolitician-data/pull/16587","diff_url":"https://github.com/everypolitician/everypolitician-data/pull/16587.diff","patch_url":"https://github.com/everypolitician/everypolitician-data/pull/16587.patch"},"body":"The code that was used to migrate the id map files from `data-ids.csv`\r\nto `idmap/data.csv` was throwing a rake error when adding a new\r\nsource and rebuilding the data with rake clean default, since there\r\nwas no @oldfile or @ newfile. Moving the .read down to the\r\nRcsv.parse call seemed to fix the error.\r\n\r\nThanks @chrismytton for the tip :D"},"comment":{"url":"https://api.github.com/repos/everypolitician/everypolitician-data/issues/comments/245017150","html_url":"https://github.com/everypolitician/everypolitician-data/pull/16587#issuecomment-245017150","issue_url":"https://api.github.com/repos/everypolitician/everypolitician-data/issues/16587","id":245017150,"user":{"login":"chrismytton","id":22996,"avatar_url":"https://avatars.githubusercontent.com/u/22996?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismytton","html_url":"https://github.com/chrismytton","followers_url":"https://api.github.com/users/chrismytton/followers","following_url":"https://api.github.com/users/chrismytton/following{/other_user}","gists_url":"https://api.github.com/users/chrismytton/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismytton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismytton/subscriptions","organizations_url":"https://api.github.com/users/chrismytton/orgs","repos_url":"https://api.github.com/users/chrismytton/repos","events_url":"https://api.github.com/users/chrismytton/events{/privacy}","received_events_url":"https://api.github.com/users/chrismytton/received_events","type":"User","site_admin":false},"created_at":"2016-09-06T16:59:17Z","updated_at":"2016-09-06T16:59:17Z","body":"Ah, I take it back! It looks like the tests are failing because the tests pass an existing `Tempfile` with no data in to the class. The following seems to fix the issue, though it's not pretty:\r\n\r\n```diff\r\ndiff --git a/lib/uuid_map.rb b/lib/uuid_map.rb\r\nindex 67814ab..18d5352 100644\r\n--- a/lib/uuid_map.rb\r\n+++ b/lib/uuid_map.rb\r\n@@ -17,9 +17,11 @@ class UuidMapFile\r\n   end\r\n \r\n   def mapping\r\n-    raw = [@newfile, @oldfile].find(&:exist?)\r\n-    return {} if raw.nil?\r\n-    Hash[Rcsv.parse(raw.read, row_as_hash: true, columns: {}).map { |r| [r['id'], r['uuid']] }]\r\n+    file = [@newfile, @oldfile].find(&:exist?)\r\n+    return {} if file.nil?\r\n+    raw = file.read\r\n+    return {} if raw.empty?\r\n+    Hash[Rcsv.parse(raw, row_as_hash: true, columns: {}).map { |r| [r['id'], r['uuid']] }]\r\n   end\r\n \r\n   def rewrite(data)\r\ndiff --git a/test/uuid_map_test.rb b/test/uuid_map_test.rb\r\nindex 0c43ee6..55b4114 100644\r\n--- a/test/uuid_map_test.rb\r\n+++ b/test/uuid_map_test.rb\r\n@@ -14,6 +14,10 @@ def new_tempfile\r\n end\r\n \r\n describe 'UUID Mapper' do\r\n+  it \"has nothing if the file doesn't exist\" do\r\n+    UuidMapFile.new(Pathname.new('not/a/file')).mapping.must_be_empty\r\n+  end\r\n+\r\n   it 'has nothing in an empty tempfile' do\r\n     UuidMapFile.new(new_tempfile).mapping.must_be_empty\r\n   end\r\n```"}}
{"actor":{"display_login":"chrismytton"}}