{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/addons-validator/pulls/comments/44905535","id":44905535,"diff_hunk":"@@ -22,45 +28,125 @@ describe('InstallRdfParser.getMetaData()', function() {\n   it('should collect an error on invalid type value', () => {\n     var addonValidator = new Validator({_: ['bar']});\n     var rdf = validRDF('<em:type>whatevs</em:type>');\n-    var installRdfParser = new InstallRdfParser(rdf, addonValidator.collector);\n-    return installRdfParser.getMetaData()\n+    var rdfScanner = new RDFScanner(rdf, INSTALL_RDF);\n+    return rdfScanner.getContents()\n+      .then((xmlDoc) => {\n+        var installRdfParser = new InstallRdfParser(xmlDoc,\n+                                                    addonValidator.collector);\n+        return installRdfParser._getAddonType();\n+      })\n       .then(() => {\n         var errors = addonValidator.collector.errors;\n         assert.equal(errors.length, 1);\n-        assert.equal(errors[0].code, messages.TYPE_INVALID.code);\n+        assert.equal(errors[0].code, messages.RDF_TYPE_INVALID.code);\n       });\n   });\n \n   it('should resolve with mapped type value', () => {\n     var rdf = validRDF('<em:type>2</em:type>');\n-    var installRdfParser = new InstallRdfParser(rdf);\n-    return installRdfParser.getMetaData()\n-      .then((addonMetaData) => {\n+    var rdfScanner = new RDFScanner(rdf, INSTALL_RDF);\n+    return rdfScanner.getContents()\n+      .then((xmlDoc) => {\n+        var installRdfParser = new InstallRdfParser(xmlDoc);\n+        return installRdfParser._getAddonType();\n+      })\n+      .then((type) => {\n         // Type 2 maps to 1 PACKAGE_EXTENSION\n-        assert.equal(addonMetaData.type, constants.PACKAGE_EXTENSION);\n+        assert.equal(type, constants.PACKAGE_EXTENSION);\n       });\n   });\n \n   it('should resolve with mapped type value for experiments', () => {\n     var rdf = validRDF('<em:type>128</em:type>');\n-    var installRdfParser = new InstallRdfParser(rdf);\n-    return installRdfParser.getMetaData()\n-      .then((addonMetaData) => {\n+    var rdfScanner = new RDFScanner(rdf, INSTALL_RDF);\n+    return rdfScanner.getContents()\n+      .then((xmlDoc) => {\n+        var installRdfParser = new InstallRdfParser(xmlDoc);\n+        return installRdfParser._getAddonType();\n+      })\n+      .then((type) => {\n         // Type 128 (experiments) maps to 1 PACKAGE_EXTENSION\n-        assert.equal(addonMetaData.type, constants.PACKAGE_EXTENSION);\n+        assert.equal(type, constants.PACKAGE_EXTENSION);\n       });\n   });\n \n   it('should collect a notice if type is missing', () => {\n     var addonValidator = new Validator({_: ['bar']});\n-    var installRdfParser = new InstallRdfParser(validRDF(''),\n-                                                addonValidator.collector);\n-    return installRdfParser.getMetaData()\n+    var rdfScanner = new RDFScanner(validRDF(''), INSTALL_RDF);\n+    return rdfScanner.getContents()\n+      .then((xmlDoc) => {\n+        var installRdfParser = new InstallRdfParser(xmlDoc,\n+                                                    addonValidator.collector);\n+        return installRdfParser._getAddonType();\n+      })\n       .then(() => {\n         var notices = addonValidator.collector.notices;\n         assert.equal(notices.length, 1);\n-        assert.equal(notices[0].code, messages.TYPE_MISSING.code);\n+        assert.equal(notices[0].code, messages.RDF_TYPE_MISSING.code);\n+      });\n+  });\n+});\n+\n+\n+describe('InstallRdfParser._getName()', function() {\n+\n+  it('should extract a name', () => {\n+    var rdf = validRDF('<em:name>my-awesome-ext</em:name>');\n+    var rdfScanner = new RDFScanner(rdf, INSTALL_RDF);\n+    return rdfScanner.getContents()\n+      .then((xmlDoc) => {\n+        var installRdfParser = new InstallRdfParser(xmlDoc);\n+        return installRdfParser._getName();\n+      })\n+      .then((name) => {\n+        assert.equal(name, 'my-awesome-ext');\n       });\n   });\n \n+  it('should collect a notice if name is missing', () => {\n+    var addonValidator = new Validator({_: ['bar']});\n+    var rdf = validRDF('<em:type>1</em:type>');\n+    var rdfScanner = new RDFScanner(rdf, INSTALL_RDF);\n+    return rdfScanner.getContents()\n+      .then((xmlDoc) => {\n+        var installRdfParser = new InstallRdfParser(xmlDoc,\n+                                                    addonValidator.collector);\n+        return installRdfParser._getName();\n+      })\n+      .then(() => {\n+        var notices = addonValidator.collector.notices;\n+        assert.equal(notices.length, 1);\n+        assert.equal(notices[0].code, messages.RDF_NAME_MISSING.code);\n+      });\n+  });\n+});\n+\n+describe('InstallRdfParser._getGUID()', function() {\n+\n+  it('should extract a guid', () => {\n+    var rdf = validRDF('<em:id>myid</em:id>');\n+    var rdfScanner = new RDFScanner(rdf, INSTALL_RDF);\n+    return rdfScanner.getContents()\n+      .then((xmlDoc) => {\n+        var installRdfParser = new InstallRdfParser(xmlDoc);\n+        return installRdfParser._getGUID();\n+      })\n+      .then((guid) => {\n+        assert.equal(guid, 'myid');\n+      });\n+  });\n+\n+  it('should return null for guid if not defined', () => {","path":"tests/parsers/test.installrdf.js","position":153,"original_position":153,"commit_id":"907822c548055237923d7d6bf6d8cc6f5c7cf4a8","original_commit_id":"907822c548055237923d7d6bf6d8cc6f5c7cf4a8","user":{"login":"tofumatt","id":90871,"avatar_url":"https://avatars.githubusercontent.com/u/90871?v=3","gravatar_id":"","url":"https://api.github.com/users/tofumatt","html_url":"https://github.com/tofumatt","followers_url":"https://api.github.com/users/tofumatt/followers","following_url":"https://api.github.com/users/tofumatt/following{/other_user}","gists_url":"https://api.github.com/users/tofumatt/gists{/gist_id}","starred_url":"https://api.github.com/users/tofumatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tofumatt/subscriptions","organizations_url":"https://api.github.com/users/tofumatt/orgs","repos_url":"https://api.github.com/users/tofumatt/repos","events_url":"https://api.github.com/users/tofumatt/events{/privacy}","received_events_url":"https://api.github.com/users/tofumatt/received_events","type":"User","site_admin":false},"body":"Oh wait, sorry, I confused this with something else entirely. Never mind!","created_at":"2015-11-16T10:04:12Z","updated_at":"2015-11-16T10:04:12Z","html_url":"https://github.com/mozilla/addons-validator/pull/262#discussion_r44905535","pull_request_url":"https://api.github.com/repos/mozilla/addons-validator/pulls/262","_links":{"self":{"href":"https://api.github.com/repos/mozilla/addons-validator/pulls/comments/44905535"},"html":{"href":"https://github.com/mozilla/addons-validator/pull/262#discussion_r44905535"},"pull_request":{"href":"https://api.github.com/repos/mozilla/addons-validator/pulls/262"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/addons-validator/pulls/262","id":50690785,"html_url":"https://github.com/mozilla/addons-validator/pull/262","diff_url":"https://github.com/mozilla/addons-validator/pull/262.diff","patch_url":"https://github.com/mozilla/addons-validator/pull/262.patch","issue_url":"https://api.github.com/repos/mozilla/addons-validator/issues/262","number":262,"state":"open","locked":false,"title":"Refactor metadata extraction and expose name","user":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"body":"Fixes #258 \r\nFixes #255\r\n\r\n* Bit more refactoring to make manifest parsers simpler and easier to test each field in isolation.\r\n* Expose name + validation of it in each case.","created_at":"2015-11-13T20:55:59Z","updated_at":"2015-11-16T10:04:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b07292b8c38018aa6c4b17cea5068f6e207f2d34","assignee":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/addons-validator/pulls/262/commits","review_comments_url":"https://api.github.com/repos/mozilla/addons-validator/pulls/262/comments","review_comment_url":"https://api.github.com/repos/mozilla/addons-validator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/addons-validator/issues/262/comments","statuses_url":"https://api.github.com/repos/mozilla/addons-validator/statuses/907822c548055237923d7d6bf6d8cc6f5c7cf4a8","head":{"label":"muffinresearch:extract-name","ref":"extract-name","sha":"907822c548055237923d7d6bf6d8cc6f5c7cf4a8","user":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"repo":{"id":42520293,"name":"addons-validator","full_name":"muffinresearch/addons-validator","owner":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/muffinresearch/addons-validator","description":"The amo-validator, JS edition.","fork":true,"url":"https://api.github.com/repos/muffinresearch/addons-validator","forks_url":"https://api.github.com/repos/muffinresearch/addons-validator/forks","keys_url":"https://api.github.com/repos/muffinresearch/addons-validator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/muffinresearch/addons-validator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/muffinresearch/addons-validator/teams","hooks_url":"https://api.github.com/repos/muffinresearch/addons-validator/hooks","issue_events_url":"https://api.github.com/repos/muffinresearch/addons-validator/issues/events{/number}","events_url":"https://api.github.com/repos/muffinresearch/addons-validator/events","assignees_url":"https://api.github.com/repos/muffinresearch/addons-validator/assignees{/user}","branches_url":"https://api.github.com/repos/muffinresearch/addons-validator/branches{/branch}","tags_url":"https://api.github.com/repos/muffinresearch/addons-validator/tags","blobs_url":"https://api.github.com/repos/muffinresearch/addons-validator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/muffinresearch/addons-validator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/muffinresearch/addons-validator/git/refs{/sha}","trees_url":"https://api.github.com/repos/muffinresearch/addons-validator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/muffinresearch/addons-validator/statuses/{sha}","languages_url":"https://api.github.com/repos/muffinresearch/addons-validator/languages","stargazers_url":"https://api.github.com/repos/muffinresearch/addons-validator/stargazers","contributors_url":"https://api.github.com/repos/muffinresearch/addons-validator/contributors","subscribers_url":"https://api.github.com/repos/muffinresearch/addons-validator/subscribers","subscription_url":"https://api.github.com/repos/muffinresearch/addons-validator/subscription","commits_url":"https://api.github.com/repos/muffinresearch/addons-validator/commits{/sha}","git_commits_url":"https://api.github.com/repos/muffinresearch/addons-validator/git/commits{/sha}","comments_url":"https://api.github.com/repos/muffinresearch/addons-validator/comments{/number}","issue_comment_url":"https://api.github.com/repos/muffinresearch/addons-validator/issues/comments{/number}","contents_url":"https://api.github.com/repos/muffinresearch/addons-validator/contents/{+path}","compare_url":"https://api.github.com/repos/muffinresearch/addons-validator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/muffinresearch/addons-validator/merges","archive_url":"https://api.github.com/repos/muffinresearch/addons-validator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/muffinresearch/addons-validator/downloads","issues_url":"https://api.github.com/repos/muffinresearch/addons-validator/issues{/number}","pulls_url":"https://api.github.com/repos/muffinresearch/addons-validator/pulls{/number}","milestones_url":"https://api.github.com/repos/muffinresearch/addons-validator/milestones{/number}","notifications_url":"https://api.github.com/repos/muffinresearch/addons-validator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/muffinresearch/addons-validator/labels{/name}","releases_url":"https://api.github.com/repos/muffinresearch/addons-validator/releases{/id}","created_at":"2015-09-15T13:14:50Z","updated_at":"2015-09-14T22:18:36Z","pushed_at":"2015-11-16T09:14:13Z","git_url":"git://github.com/muffinresearch/addons-validator.git","ssh_url":"git@github.com:muffinresearch/addons-validator.git","clone_url":"https://github.com/muffinresearch/addons-validator.git","svn_url":"https://github.com/muffinresearch/addons-validator","homepage":null,"size":553,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"e05f6414f085ffc552c7d579847ddb43e6638c52","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":42436885,"name":"addons-validator","full_name":"mozilla/addons-validator","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/addons-validator","description":"The new Firefox Add-ons validator, written in ES6/JavaScript.","fork":false,"url":"https://api.github.com/repos/mozilla/addons-validator","forks_url":"https://api.github.com/repos/mozilla/addons-validator/forks","keys_url":"https://api.github.com/repos/mozilla/addons-validator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/addons-validator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/addons-validator/teams","hooks_url":"https://api.github.com/repos/mozilla/addons-validator/hooks","issue_events_url":"https://api.github.com/repos/mozilla/addons-validator/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/addons-validator/events","assignees_url":"https://api.github.com/repos/mozilla/addons-validator/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/addons-validator/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/addons-validator/tags","blobs_url":"https://api.github.com/repos/mozilla/addons-validator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/addons-validator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/addons-validator/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/addons-validator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/addons-validator/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/addons-validator/languages","stargazers_url":"https://api.github.com/repos/mozilla/addons-validator/stargazers","contributors_url":"https://api.github.com/repos/mozilla/addons-validator/contributors","subscribers_url":"https://api.github.com/repos/mozilla/addons-validator/subscribers","subscription_url":"https://api.github.com/repos/mozilla/addons-validator/subscription","commits_url":"https://api.github.com/repos/mozilla/addons-validator/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/addons-validator/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/addons-validator/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/addons-validator/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/addons-validator/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/addons-validator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/addons-validator/merges","archive_url":"https://api.github.com/repos/mozilla/addons-validator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/addons-validator/downloads","issues_url":"https://api.github.com/repos/mozilla/addons-validator/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/addons-validator/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/addons-validator/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/addons-validator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/addons-validator/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/addons-validator/releases{/id}","created_at":"2015-09-14T08:34:44Z","updated_at":"2015-10-24T03:57:22Z","pushed_at":"2015-11-16T09:15:17Z","git_url":"git://github.com/mozilla/addons-validator.git","ssh_url":"git@github.com:mozilla/addons-validator.git","clone_url":"https://github.com/mozilla/addons-validator.git","svn_url":"https://github.com/mozilla/addons-validator","homepage":"","size":1607,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4,"mirror_url":null,"open_issues_count":41,"forks":4,"open_issues":41,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/addons-validator/pulls/262"},"html":{"href":"https://github.com/mozilla/addons-validator/pull/262"},"issue":{"href":"https://api.github.com/repos/mozilla/addons-validator/issues/262"},"comments":{"href":"https://api.github.com/repos/mozilla/addons-validator/issues/262/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/addons-validator/pulls/262/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/addons-validator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/addons-validator/pulls/262/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/addons-validator/statuses/907822c548055237923d7d6bf6d8cc6f5c7cf4a8"}}}}