{"action":"created","comment":{"url":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments/33677415","id":33677415,"diff_hunk":"@@ -0,0 +1,158 @@\n+'use strict';\n+var _ = require('lodash'),\n+    GeminiError = require('../errors/gemini-error'),\n+    util = require('./util'),\n+\n+    option = require('@gemini/configparser').option,\n+    is = util.is,\n+    resolveWithProjectRoot = util.resolveWithProjectRoot,\n+    booleanOption = util.booleanOption;\n+\n+function getTopLevel() {\n+    var defaults = {\n+        calibrate: true,\n+        httpTimeout: 'default',\n+        screenshotsDir: 'gemini/screens',\n+        tolerance: 2.3,\n+        strictComparison: false,\n+        windowSize: null\n+    };\n+\n+    function provideDefault(key) {\n+        return defaults[key];\n+    }\n+\n+    return buildBrowserOptions(provideDefault, {\n+        desiredCapabilities: option({\n+            defaultValue: null,\n+            parseEnv: JSON.parse,\n+            parseCli: JSON.parse,\n+            validate: function(value) {\n+                if (!isOptionalObject(value)) {\n+                    throw new GeminiError('Top-level desiredCapabilities should be null or object');\n+                }\n+            }\n+        })\n+    });\n+}\n+\n+function getPerBrowser() {\n+    return buildBrowserOptions(provideTopLevelDefault, {\n+        desiredCapabilities: option({\n+            parseEnv: JSON.parse,\n+            parseCli: JSON.parse,\n+            defaultValue: null,\n+            validate: function(value, config) {\n+                if (value === null && config.desiredCapabilities === null) {\n+                    throw new GeminiError('Browser must have desired capabilities set');\n+                }\n+\n+                if (!isOptionalObject(value)) {\n+                    throw new GeminiError('desiredCapabilities should be null or object');\n+                }\n+            },\n+            map: function(value, config) {\n+                return _.extend({}, config.desiredCapabilities, value);\n+            }\n+        })\n+    });\n+}\n+\n+function isOptionalObject(value) {\n+    return value === null || _.isPlainObject(value);\n+}\n+\n+function provideTopLevelDefault(name) {\n+    return function(config) {\n+        var value = config[name];\n+        if (_.isUndefined(value)) {\n+            throw new GeminiError(name + ' should be set at top level or per-broser option');\n+        }\n+        return value;\n+    };\n+}\n+\n+function buildBrowserOptions(defaultFactory, extra) {\n+    return _.extend(extra, {\n+        rootUrl: option({\n+            validate: is('string'),\n+            defaultValue: defaultFactory('rootUrl')\n+        }),\n+\n+        gridUrl: option({\n+            validate: is('string'),\n+            defaultValue: defaultFactory('gridUrl')\n+        }),\n+\n+        calibrate: booleanOption(defaultFactory('calibrate')),\n+\n+        httpTimeout: option({\n+            parseEnv: parseTimeout,\n+            parseCli: parseTimeout,\n+            validate: function(value) {\n+                if (value === 'default') {\n+                    return;\n+                }\n+                is('number')(value);\n+                if (value < 0) {\n+                    throw new GeminiError('\"httpTimeout\" must be non-negative');\n+                }\n+            },\n+            defaultValue: defaultFactory('httpTimeout')\n+        }),\n+\n+        screenshotsDir: option({\n+            validate: is('string'),\n+            defaultValue: defaultFactory('screenshotsDir'),\n+            map: resolveWithProjectRoot\n+        }),\n+\n+        tolerance: option({\n+            defaultValue: defaultFactory('tolerance'),\n+            parseEnv: Number,\n+            parseCli: Number,\n+            validate: is('number')\n+        }),\n+\n+        strictComparison: booleanOption(defaultFactory('strictComparison')),\n+\n+        windowSize: option({\n+            defaultValue: defaultFactory('windowSize'),\n+            validate: function(value) {\n+                if (value === null) {\n+                    //null is valid value for this option, skip any other checks\n+                    return;\n+                }\n+\n+                if (typeof value !== 'string') {\n+                    throw new GeminiError('\"windowSize\" must be string or null');\n+                }\n+\n+                if (!/^\\d+x\\d+$/.test(value)) {\n+                    throw new GeminiError('\"windowSize\" should have form of <width>x<height> (i.e. 1600x1200)');\n+                }\n+            },\n+\n+            map: function(value) {\n+                if (value === null) {\n+                    return null;\n+                }\n+                var size = value.split('x');\n+                return {\n+                    width: parseInt(size[0], 10),\n+                    height: parseInt(size[1], 10)\n+                };\n+            }\n+        })\n+    });\n+}\n+\n+function parseTimeout(value) {\n+    if (value === 'default') {","path":"lib/config/browser-options.js","position":151,"original_position":151,"commit_id":"62208d80ae32610de6d20e66152b2c405328dd78","original_commit_id":"62208d80ae32610de6d20e66152b2c405328dd78","user":{"login":"SevInf","id":603056,"avatar_url":"https://avatars.githubusercontent.com/u/603056?v=3","gravatar_id":"","url":"https://api.github.com/users/SevInf","html_url":"https://github.com/SevInf","followers_url":"https://api.github.com/users/SevInf/followers","following_url":"https://api.github.com/users/SevInf/following{/other_user}","gists_url":"https://api.github.com/users/SevInf/gists{/gist_id}","starred_url":"https://api.github.com/users/SevInf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SevInf/subscriptions","organizations_url":"https://api.github.com/users/SevInf/orgs","repos_url":"https://api.github.com/users/SevInf/repos","events_url":"https://api.github.com/users/SevInf/events{/privacy}","received_events_url":"https://api.github.com/users/SevInf/received_events","type":"User","site_admin":false},"body":"А в чем отличие от `default`?","created_at":"2015-07-01T13:27:46Z","updated_at":"2015-07-01T13:27:46Z","html_url":"https://github.com/gemini-testing/gemini/pull/180#discussion_r33677415","pull_request_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/180","_links":{"self":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments/33677415"},"html":{"href":"https://github.com/gemini-testing/gemini/pull/180#discussion_r33677415"},"pull_request":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/180"}}},"pull_request":{"url":"https://api.github.com/repos/gemini-testing/gemini/pulls/180","id":38953433,"html_url":"https://github.com/gemini-testing/gemini/pull/180","diff_url":"https://github.com/gemini-testing/gemini/pull/180.diff","patch_url":"https://github.com/gemini-testing/gemini/pull/180.patch","issue_url":"https://api.github.com/repos/gemini-testing/gemini/issues/180","number":180,"state":"open","locked":false,"title":"New config: allows to set of options per-browser","user":{"login":"SevInf","id":603056,"avatar_url":"https://avatars.githubusercontent.com/u/603056?v=3","gravatar_id":"","url":"https://api.github.com/users/SevInf","html_url":"https://github.com/SevInf","followers_url":"https://api.github.com/users/SevInf/followers","following_url":"https://api.github.com/users/SevInf/following{/other_user}","gists_url":"https://api.github.com/users/SevInf/gists{/gist_id}","starred_url":"https://api.github.com/users/SevInf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SevInf/subscriptions","organizations_url":"https://api.github.com/users/SevInf/orgs","repos_url":"https://api.github.com/users/SevInf/repos","events_url":"https://api.github.com/users/SevInf/events{/privacy}","received_events_url":"https://api.github.com/users/SevInf/received_events","type":"User","site_admin":false},"body":"Options that can not be set per-browser are grouped\r\ninto system section. Additional changes:\r\n\r\n- capabilities option is renamed to desriedCapabilties to match\r\nthe spec.\r\n- \"--noCalibrate\" flag is gone, calibration now can be disabled with\r\n\"calibrate: no\" option.\r\n- http section is removed, only timeout can now be set (\"httpTimeout\"\r\n  option).","created_at":"2015-07-01T07:00:12Z","updated_at":"2015-07-01T13:27:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6573f82bc7f1d88a78bdec452a17cf48d471452","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/180/commits","review_comments_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/180/comments","review_comment_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/issues/180/comments","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/62208d80ae32610de6d20e66152b2c405328dd78","head":{"label":"gemini-testing:feature/config2","ref":"feature/config2","sha":"62208d80ae32610de6d20e66152b2c405328dd78","user":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"repo":{"id":16734168,"name":"gemini","full_name":"gemini-testing/gemini","owner":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gemini-testing/gemini","description":"Utility for regression testing of web pages using screenshots","fork":false,"url":"https://api.github.com/repos/gemini-testing/gemini","forks_url":"https://api.github.com/repos/gemini-testing/gemini/forks","keys_url":"https://api.github.com/repos/gemini-testing/gemini/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gemini-testing/gemini/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gemini-testing/gemini/teams","hooks_url":"https://api.github.com/repos/gemini-testing/gemini/hooks","issue_events_url":"https://api.github.com/repos/gemini-testing/gemini/issues/events{/number}","events_url":"https://api.github.com/repos/gemini-testing/gemini/events","assignees_url":"https://api.github.com/repos/gemini-testing/gemini/assignees{/user}","branches_url":"https://api.github.com/repos/gemini-testing/gemini/branches{/branch}","tags_url":"https://api.github.com/repos/gemini-testing/gemini/tags","blobs_url":"https://api.github.com/repos/gemini-testing/gemini/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gemini-testing/gemini/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gemini-testing/gemini/git/refs{/sha}","trees_url":"https://api.github.com/repos/gemini-testing/gemini/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/{sha}","languages_url":"https://api.github.com/repos/gemini-testing/gemini/languages","stargazers_url":"https://api.github.com/repos/gemini-testing/gemini/stargazers","contributors_url":"https://api.github.com/repos/gemini-testing/gemini/contributors","subscribers_url":"https://api.github.com/repos/gemini-testing/gemini/subscribers","subscription_url":"https://api.github.com/repos/gemini-testing/gemini/subscription","commits_url":"https://api.github.com/repos/gemini-testing/gemini/commits{/sha}","git_commits_url":"https://api.github.com/repos/gemini-testing/gemini/git/commits{/sha}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/comments{/number}","issue_comment_url":"https://api.github.com/repos/gemini-testing/gemini/issues/comments{/number}","contents_url":"https://api.github.com/repos/gemini-testing/gemini/contents/{+path}","compare_url":"https://api.github.com/repos/gemini-testing/gemini/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gemini-testing/gemini/merges","archive_url":"https://api.github.com/repos/gemini-testing/gemini/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gemini-testing/gemini/downloads","issues_url":"https://api.github.com/repos/gemini-testing/gemini/issues{/number}","pulls_url":"https://api.github.com/repos/gemini-testing/gemini/pulls{/number}","milestones_url":"https://api.github.com/repos/gemini-testing/gemini/milestones{/number}","notifications_url":"https://api.github.com/repos/gemini-testing/gemini/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gemini-testing/gemini/labels{/name}","releases_url":"https://api.github.com/repos/gemini-testing/gemini/releases{/id}","created_at":"2014-02-11T14:58:41Z","updated_at":"2015-07-01T03:37:45Z","pushed_at":"2015-07-01T07:00:13Z","git_url":"git://github.com/gemini-testing/gemini.git","ssh_url":"git@github.com:gemini-testing/gemini.git","clone_url":"https://github.com/gemini-testing/gemini.git","svn_url":"https://github.com/gemini-testing/gemini","homepage":null,"size":3460,"stargazers_count":380,"watchers_count":380,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":35,"mirror_url":null,"open_issues_count":34,"forks":35,"open_issues":34,"watchers":380,"default_branch":"master"}},"base":{"label":"gemini-testing:master","ref":"master","sha":"eda560df261c81aa91552153bfabc24def4038db","user":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"repo":{"id":16734168,"name":"gemini","full_name":"gemini-testing/gemini","owner":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gemini-testing/gemini","description":"Utility for regression testing of web pages using screenshots","fork":false,"url":"https://api.github.com/repos/gemini-testing/gemini","forks_url":"https://api.github.com/repos/gemini-testing/gemini/forks","keys_url":"https://api.github.com/repos/gemini-testing/gemini/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gemini-testing/gemini/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gemini-testing/gemini/teams","hooks_url":"https://api.github.com/repos/gemini-testing/gemini/hooks","issue_events_url":"https://api.github.com/repos/gemini-testing/gemini/issues/events{/number}","events_url":"https://api.github.com/repos/gemini-testing/gemini/events","assignees_url":"https://api.github.com/repos/gemini-testing/gemini/assignees{/user}","branches_url":"https://api.github.com/repos/gemini-testing/gemini/branches{/branch}","tags_url":"https://api.github.com/repos/gemini-testing/gemini/tags","blobs_url":"https://api.github.com/repos/gemini-testing/gemini/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gemini-testing/gemini/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gemini-testing/gemini/git/refs{/sha}","trees_url":"https://api.github.com/repos/gemini-testing/gemini/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/{sha}","languages_url":"https://api.github.com/repos/gemini-testing/gemini/languages","stargazers_url":"https://api.github.com/repos/gemini-testing/gemini/stargazers","contributors_url":"https://api.github.com/repos/gemini-testing/gemini/contributors","subscribers_url":"https://api.github.com/repos/gemini-testing/gemini/subscribers","subscription_url":"https://api.github.com/repos/gemini-testing/gemini/subscription","commits_url":"https://api.github.com/repos/gemini-testing/gemini/commits{/sha}","git_commits_url":"https://api.github.com/repos/gemini-testing/gemini/git/commits{/sha}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/comments{/number}","issue_comment_url":"https://api.github.com/repos/gemini-testing/gemini/issues/comments{/number}","contents_url":"https://api.github.com/repos/gemini-testing/gemini/contents/{+path}","compare_url":"https://api.github.com/repos/gemini-testing/gemini/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gemini-testing/gemini/merges","archive_url":"https://api.github.com/repos/gemini-testing/gemini/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gemini-testing/gemini/downloads","issues_url":"https://api.github.com/repos/gemini-testing/gemini/issues{/number}","pulls_url":"https://api.github.com/repos/gemini-testing/gemini/pulls{/number}","milestones_url":"https://api.github.com/repos/gemini-testing/gemini/milestones{/number}","notifications_url":"https://api.github.com/repos/gemini-testing/gemini/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gemini-testing/gemini/labels{/name}","releases_url":"https://api.github.com/repos/gemini-testing/gemini/releases{/id}","created_at":"2014-02-11T14:58:41Z","updated_at":"2015-07-01T03:37:45Z","pushed_at":"2015-07-01T07:00:13Z","git_url":"git://github.com/gemini-testing/gemini.git","ssh_url":"git@github.com:gemini-testing/gemini.git","clone_url":"https://github.com/gemini-testing/gemini.git","svn_url":"https://github.com/gemini-testing/gemini","homepage":null,"size":3460,"stargazers_count":380,"watchers_count":380,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":35,"mirror_url":null,"open_issues_count":34,"forks":35,"open_issues":34,"watchers":380,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/180"},"html":{"href":"https://github.com/gemini-testing/gemini/pull/180"},"issue":{"href":"https://api.github.com/repos/gemini-testing/gemini/issues/180"},"comments":{"href":"https://api.github.com/repos/gemini-testing/gemini/issues/180/comments"},"review_comments":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/180/comments"},"review_comment":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/180/commits"},"statuses":{"href":"https://api.github.com/repos/gemini-testing/gemini/statuses/62208d80ae32610de6d20e66152b2c405328dd78"}}}}