{"action":"created","comment":{"url":"https://api.github.com/repos/dpla/KriKri/pulls/comments/28072178","id":28072178,"diff_hunk":"@@ -0,0 +1,73 @@\n+module Krikri::Enrichments\n+  ##\n+  # Splits a string given in `lat' or `long' in an edm:Place object and\n+  # assigns `lat' and `long' with the split values.\n+  #\n+  # @example\n+  #\n+  #   Where val is a DPLA::MAP::Place,\n+  #   and val.lat == '40.7127,74.0059',\n+  #   assign val.lat = '40.7127' and val.long = '74.0059'\n+  #\n+  #   If long is filled in instead of lat, the values will be assigned in the\n+  #   reverse order, with lat taking '74.0059' and long taking '40.7127'.\n+  #\n+  class SplitCoordinates\n+    include Krikri::FieldEnrichment\n+\n+    ##\n+    # Enrich a `DPLA::MAP::Place' object by splitting the string given\n+    # in its `lat' or `long'.\n+    #\n+    # @param place [DPLA::MAP::Place]\n+    # @return [DPLA::MAP::Place]\n+    #\n+    def enrich_value(place)\n+      return place if !place.is_a? DPLA::MAP::Place\n+\n+      # place.lat and place.long are arrays of one value if they are assigned.\n+\n+      return place if place.lat.first && place.long.first  # no split required\n+\n+      if place.lat.first\n+        latlong = coord_values(place.lat.first)\n+        assign_latlong!(place, latlong.first, latlong.last)\n+      elsif place.long.first\n+        latlong = coord_values(place.long.first)\n+        assign_latlong!(place, latlong.last, latlong.first)\n+      end\n+\n+      place\n+    end\n+\n+    def assign_latlong!(place, lat, long)\n+      # We have to assign these one at a time because we can't do this:\n+      # place.lat, place.long = [[nil], [nil]]\n+      # ... which results in:\n+      #     \"value must be an RDF URI, Node, Literal, or a valid datatype.\n+      #     See RDF::Literal. You provided nil\"\n+      # ... although this works fine:\n+      # place.lat, place.long = [['10.0'], ['11.1']]\n+      place.lat = lat","path":"lib/krikri/enrichments/split_coordinates.rb","position":51,"original_position":51,"commit_id":"42bfe0f624c1cc5493365723d32b501c8fb346ec","original_commit_id":"42bfe0f624c1cc5493365723d32b501c8fb346ec","user":{"login":"no-reply","id":1361776,"avatar_url":"https://avatars.githubusercontent.com/u/1361776?v=3","gravatar_id":"","url":"https://api.github.com/users/no-reply","html_url":"https://github.com/no-reply","followers_url":"https://api.github.com/users/no-reply/followers","following_url":"https://api.github.com/users/no-reply/following{/other_user}","gists_url":"https://api.github.com/users/no-reply/gists{/gist_id}","starred_url":"https://api.github.com/users/no-reply/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/no-reply/subscriptions","organizations_url":"https://api.github.com/users/no-reply/orgs","repos_url":"https://api.github.com/users/no-reply/repos","events_url":"https://api.github.com/users/no-reply/events{/privacy}","received_events_url":"https://api.github.com/users/no-reply/received_events","type":"User","site_admin":false},"body":"I haven't verified, but I think `place.lat, place.long = ['10.0', '11.1']` and `place.lat, place.long = [nil, nil]` will both work fine.  This already seems to be assuming that you're only working with the value of `ActiveTriples::Term#first`. ","created_at":"2015-04-09T15:28:08Z","updated_at":"2015-04-09T15:28:08Z","html_url":"https://github.com/dpla/KriKri/pull/144#discussion_r28072178","pull_request_url":"https://api.github.com/repos/dpla/KriKri/pulls/144","_links":{"self":{"href":"https://api.github.com/repos/dpla/KriKri/pulls/comments/28072178"},"html":{"href":"https://github.com/dpla/KriKri/pull/144#discussion_r28072178"},"pull_request":{"href":"https://api.github.com/repos/dpla/KriKri/pulls/144"}}},"pull_request":{"url":"https://api.github.com/repos/dpla/KriKri/pulls/144","id":32901409,"html_url":"https://github.com/dpla/KriKri/pull/144","diff_url":"https://github.com/dpla/KriKri/pull/144.diff","patch_url":"https://github.com/dpla/KriKri/pull/144.patch","issue_url":"https://api.github.com/repos/dpla/KriKri/issues/144","number":144,"state":"open","locked":false,"title":"Split geographic coordinate strings","user":{"login":"markbreedlove","id":5550828,"avatar_url":"https://avatars.githubusercontent.com/u/5550828?v=3","gravatar_id":"","url":"https://api.github.com/users/markbreedlove","html_url":"https://github.com/markbreedlove","followers_url":"https://api.github.com/users/markbreedlove/followers","following_url":"https://api.github.com/users/markbreedlove/following{/other_user}","gists_url":"https://api.github.com/users/markbreedlove/gists{/gist_id}","starred_url":"https://api.github.com/users/markbreedlove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markbreedlove/subscriptions","organizations_url":"https://api.github.com/users/markbreedlove/orgs","repos_url":"https://api.github.com/users/markbreedlove/repos","events_url":"https://api.github.com/users/markbreedlove/events{/privacy}","received_events_url":"https://api.github.com/users/markbreedlove/received_events","type":"User","site_admin":false},"body":"Split strings given in edm:Place (`DPLA::MAP::Place`) into latitude and longitude.\r\n","created_at":"2015-04-08T20:59:17Z","updated_at":"2015-04-09T15:28:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d4121c370b3a64b3eeca1d6c2790ff00dcd8fc1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dpla/KriKri/pulls/144/commits","review_comments_url":"https://api.github.com/repos/dpla/KriKri/pulls/144/comments","review_comment_url":"https://api.github.com/repos/dpla/KriKri/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dpla/KriKri/issues/144/comments","statuses_url":"https://api.github.com/repos/dpla/KriKri/statuses/42bfe0f624c1cc5493365723d32b501c8fb346ec","head":{"label":"dpla:feature/split-latlong","ref":"feature/split-latlong","sha":"42bfe0f624c1cc5493365723d32b501c8fb346ec","user":{"login":"dpla","id":1252916,"avatar_url":"https://avatars.githubusercontent.com/u/1252916?v=3","gravatar_id":"","url":"https://api.github.com/users/dpla","html_url":"https://github.com/dpla","followers_url":"https://api.github.com/users/dpla/followers","following_url":"https://api.github.com/users/dpla/following{/other_user}","gists_url":"https://api.github.com/users/dpla/gists{/gist_id}","starred_url":"https://api.github.com/users/dpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpla/subscriptions","organizations_url":"https://api.github.com/users/dpla/orgs","repos_url":"https://api.github.com/users/dpla/repos","events_url":"https://api.github.com/users/dpla/events{/privacy}","received_events_url":"https://api.github.com/users/dpla/received_events","type":"Organization","site_admin":false},"repo":{"id":25104780,"name":"KriKri","full_name":"dpla/KriKri","owner":{"login":"dpla","id":1252916,"avatar_url":"https://avatars.githubusercontent.com/u/1252916?v=3","gravatar_id":"","url":"https://api.github.com/users/dpla","html_url":"https://github.com/dpla","followers_url":"https://api.github.com/users/dpla/followers","following_url":"https://api.github.com/users/dpla/following{/other_user}","gists_url":"https://api.github.com/users/dpla/gists{/gist_id}","starred_url":"https://api.github.com/users/dpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpla/subscriptions","organizations_url":"https://api.github.com/users/dpla/orgs","repos_url":"https://api.github.com/users/dpla/repos","events_url":"https://api.github.com/users/dpla/events{/privacy}","received_events_url":"https://api.github.com/users/dpla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dpla/KriKri","description":"A Rails engine for metadata aggregation, enhancement, and quality control.","fork":false,"url":"https://api.github.com/repos/dpla/KriKri","forks_url":"https://api.github.com/repos/dpla/KriKri/forks","keys_url":"https://api.github.com/repos/dpla/KriKri/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dpla/KriKri/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dpla/KriKri/teams","hooks_url":"https://api.github.com/repos/dpla/KriKri/hooks","issue_events_url":"https://api.github.com/repos/dpla/KriKri/issues/events{/number}","events_url":"https://api.github.com/repos/dpla/KriKri/events","assignees_url":"https://api.github.com/repos/dpla/KriKri/assignees{/user}","branches_url":"https://api.github.com/repos/dpla/KriKri/branches{/branch}","tags_url":"https://api.github.com/repos/dpla/KriKri/tags","blobs_url":"https://api.github.com/repos/dpla/KriKri/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dpla/KriKri/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dpla/KriKri/git/refs{/sha}","trees_url":"https://api.github.com/repos/dpla/KriKri/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dpla/KriKri/statuses/{sha}","languages_url":"https://api.github.com/repos/dpla/KriKri/languages","stargazers_url":"https://api.github.com/repos/dpla/KriKri/stargazers","contributors_url":"https://api.github.com/repos/dpla/KriKri/contributors","subscribers_url":"https://api.github.com/repos/dpla/KriKri/subscribers","subscription_url":"https://api.github.com/repos/dpla/KriKri/subscription","commits_url":"https://api.github.com/repos/dpla/KriKri/commits{/sha}","git_commits_url":"https://api.github.com/repos/dpla/KriKri/git/commits{/sha}","comments_url":"https://api.github.com/repos/dpla/KriKri/comments{/number}","issue_comment_url":"https://api.github.com/repos/dpla/KriKri/issues/comments{/number}","contents_url":"https://api.github.com/repos/dpla/KriKri/contents/{+path}","compare_url":"https://api.github.com/repos/dpla/KriKri/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dpla/KriKri/merges","archive_url":"https://api.github.com/repos/dpla/KriKri/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dpla/KriKri/downloads","issues_url":"https://api.github.com/repos/dpla/KriKri/issues{/number}","pulls_url":"https://api.github.com/repos/dpla/KriKri/pulls{/number}","milestones_url":"https://api.github.com/repos/dpla/KriKri/milestones{/number}","notifications_url":"https://api.github.com/repos/dpla/KriKri/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dpla/KriKri/labels{/name}","releases_url":"https://api.github.com/repos/dpla/KriKri/releases{/id}","created_at":"2014-10-12T02:41:01Z","updated_at":"2015-04-09T15:01:18Z","pushed_at":"2015-04-09T15:01:17Z","git_url":"git://github.com/dpla/KriKri.git","ssh_url":"git@github.com:dpla/KriKri.git","clone_url":"https://github.com/dpla/KriKri.git","svn_url":"https://github.com/dpla/KriKri","homepage":null,"size":5515,"stargazers_count":17,"watchers_count":17,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":17,"default_branch":"develop"}},"base":{"label":"dpla:develop","ref":"develop","sha":"ab8ec1fd2aca1a35a5c07c012d6a1b13599cdd07","user":{"login":"dpla","id":1252916,"avatar_url":"https://avatars.githubusercontent.com/u/1252916?v=3","gravatar_id":"","url":"https://api.github.com/users/dpla","html_url":"https://github.com/dpla","followers_url":"https://api.github.com/users/dpla/followers","following_url":"https://api.github.com/users/dpla/following{/other_user}","gists_url":"https://api.github.com/users/dpla/gists{/gist_id}","starred_url":"https://api.github.com/users/dpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpla/subscriptions","organizations_url":"https://api.github.com/users/dpla/orgs","repos_url":"https://api.github.com/users/dpla/repos","events_url":"https://api.github.com/users/dpla/events{/privacy}","received_events_url":"https://api.github.com/users/dpla/received_events","type":"Organization","site_admin":false},"repo":{"id":25104780,"name":"KriKri","full_name":"dpla/KriKri","owner":{"login":"dpla","id":1252916,"avatar_url":"https://avatars.githubusercontent.com/u/1252916?v=3","gravatar_id":"","url":"https://api.github.com/users/dpla","html_url":"https://github.com/dpla","followers_url":"https://api.github.com/users/dpla/followers","following_url":"https://api.github.com/users/dpla/following{/other_user}","gists_url":"https://api.github.com/users/dpla/gists{/gist_id}","starred_url":"https://api.github.com/users/dpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpla/subscriptions","organizations_url":"https://api.github.com/users/dpla/orgs","repos_url":"https://api.github.com/users/dpla/repos","events_url":"https://api.github.com/users/dpla/events{/privacy}","received_events_url":"https://api.github.com/users/dpla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dpla/KriKri","description":"A Rails engine for metadata aggregation, enhancement, and quality control.","fork":false,"url":"https://api.github.com/repos/dpla/KriKri","forks_url":"https://api.github.com/repos/dpla/KriKri/forks","keys_url":"https://api.github.com/repos/dpla/KriKri/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dpla/KriKri/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dpla/KriKri/teams","hooks_url":"https://api.github.com/repos/dpla/KriKri/hooks","issue_events_url":"https://api.github.com/repos/dpla/KriKri/issues/events{/number}","events_url":"https://api.github.com/repos/dpla/KriKri/events","assignees_url":"https://api.github.com/repos/dpla/KriKri/assignees{/user}","branches_url":"https://api.github.com/repos/dpla/KriKri/branches{/branch}","tags_url":"https://api.github.com/repos/dpla/KriKri/tags","blobs_url":"https://api.github.com/repos/dpla/KriKri/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dpla/KriKri/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dpla/KriKri/git/refs{/sha}","trees_url":"https://api.github.com/repos/dpla/KriKri/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dpla/KriKri/statuses/{sha}","languages_url":"https://api.github.com/repos/dpla/KriKri/languages","stargazers_url":"https://api.github.com/repos/dpla/KriKri/stargazers","contributors_url":"https://api.github.com/repos/dpla/KriKri/contributors","subscribers_url":"https://api.github.com/repos/dpla/KriKri/subscribers","subscription_url":"https://api.github.com/repos/dpla/KriKri/subscription","commits_url":"https://api.github.com/repos/dpla/KriKri/commits{/sha}","git_commits_url":"https://api.github.com/repos/dpla/KriKri/git/commits{/sha}","comments_url":"https://api.github.com/repos/dpla/KriKri/comments{/number}","issue_comment_url":"https://api.github.com/repos/dpla/KriKri/issues/comments{/number}","contents_url":"https://api.github.com/repos/dpla/KriKri/contents/{+path}","compare_url":"https://api.github.com/repos/dpla/KriKri/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dpla/KriKri/merges","archive_url":"https://api.github.com/repos/dpla/KriKri/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dpla/KriKri/downloads","issues_url":"https://api.github.com/repos/dpla/KriKri/issues{/number}","pulls_url":"https://api.github.com/repos/dpla/KriKri/pulls{/number}","milestones_url":"https://api.github.com/repos/dpla/KriKri/milestones{/number}","notifications_url":"https://api.github.com/repos/dpla/KriKri/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dpla/KriKri/labels{/name}","releases_url":"https://api.github.com/repos/dpla/KriKri/releases{/id}","created_at":"2014-10-12T02:41:01Z","updated_at":"2015-04-09T15:01:18Z","pushed_at":"2015-04-09T15:01:17Z","git_url":"git://github.com/dpla/KriKri.git","ssh_url":"git@github.com:dpla/KriKri.git","clone_url":"https://github.com/dpla/KriKri.git","svn_url":"https://github.com/dpla/KriKri","homepage":null,"size":5515,"stargazers_count":17,"watchers_count":17,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":17,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/dpla/KriKri/pulls/144"},"html":{"href":"https://github.com/dpla/KriKri/pull/144"},"issue":{"href":"https://api.github.com/repos/dpla/KriKri/issues/144"},"comments":{"href":"https://api.github.com/repos/dpla/KriKri/issues/144/comments"},"review_comments":{"href":"https://api.github.com/repos/dpla/KriKri/pulls/144/comments"},"review_comment":{"href":"https://api.github.com/repos/dpla/KriKri/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dpla/KriKri/pulls/144/commits"},"statuses":{"href":"https://api.github.com/repos/dpla/KriKri/statuses/42bfe0f624c1cc5493365723d32b501c8fb346ec"}}}}