{"action":"created","comment":{"url":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/comments/54761568","id":54761568,"diff_hunk":"@@ -0,0 +1,56 @@\n+# Generate default values based on an element type and its path in the\n+# element tree. This method tries to be smart about generating a sample data\n+# structure that makes sense when no samples or defaults were given.\n+faker = require 'faker'\n+\n+endsWith = (input, search) ->\n+  if not input then return false\n+  position = input.length - search.length\n+  lastIndex = input.indexOf search, position\n+  lastIndex isnt -1 and lastIndex is position\n+\n+module.exports = (item, path) ->","path":"src/default-value.coffee","position":12,"original_position":12,"commit_id":"b9e18a6101ea685af8028cd94a90be404c84c1ef","original_commit_id":"b9e18a6101ea685af8028cd94a90be404c84c1ef","user":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"body":"Good point, let me update it.","created_at":"2016-03-02T17:49:28Z","updated_at":"2016-03-02T17:49:28Z","html_url":"https://github.com/danielgtaylor/eidolon/pull/7#discussion_r54761568","pull_request_url":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/comments/54761568"},"html":{"href":"https://github.com/danielgtaylor/eidolon/pull/7#discussion_r54761568"},"pull_request":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/7","id":61283339,"html_url":"https://github.com/danielgtaylor/eidolon/pull/7","diff_url":"https://github.com/danielgtaylor/eidolon/pull/7.diff","patch_url":"https://github.com/danielgtaylor/eidolon/pull/7.patch","issue_url":"https://api.github.com/repos/danielgtaylor/eidolon/issues/7","number":7,"state":"open","locked":false,"title":"Generate smart random default values for examples","user":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"body":"For example, given the following MSON input with no samples or default values:\r\n\r\n```mson\r\n# Customer\r\n- id\r\n- name\r\n- email\r\n- country\r\n- lastLoginDate\r\n- plan\r\n  - cost (number)\r\n  - enabled (boolean)\r\n```\r\n\r\nYou would get something like:\r\n\r\n```js\r\n{\r\n  id: 'ae29f4d3-8954-4972-ab72-053d082a3fd6',\r\n  name: 'Haven Kuhlman',\r\n  email: 'Kristina.Koch@yahoo.com',\r\n  country: 'DE',\r\n  lastLoginDate: 'Thu May 07 2015 14:27:18 GMT-0700 (PDT)',\r\n  plan: {\r\n    cost: 826.13,\r\n    enabled: true\r\n  }\r\n}\r\n```\r\n\r\nOf course, providing your own sample or default value will override the generated default, so this is only going to show up in the case with no sample. If no information about context can be guessed for a particular `string` element, then a simple Lorem Ipsum nonsense word or words will be used.\r\n\r\nIn order to provide consistent output, there is now a `seed` option for the `example` method that sets the Mersenne twister seed value. The tests are written to *not* depend on this, as the order of returned items may change with subsequent faker.js releases.\r\n\r\nAlso, you can still manually override all of this magic by providing your own default generator function. For example, this replaces each generated default value with the name of the refract element:\r\n\r\n```js\r\nimport eidolon from 'eidolon';\r\n\r\nfunction myDefaultValue(refract, path) {\r\n  return refract.element;\r\n}\r\n\r\neidolon.example({ /* ... some refract structure ... */}, [], {\r\n  defaultValue: myDefaultValue\r\n});\r\n```\r\n\r\ncc @Baggz ","created_at":"2016-03-01T18:07:56Z","updated_at":"2016-03-02T17:49:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a4b8e9792f83422464b5a91728a612f8f1197fc","assignee":{"login":"Baggz","id":95191,"avatar_url":"https://avatars.githubusercontent.com/u/95191?v=3","gravatar_id":"","url":"https://api.github.com/users/Baggz","html_url":"https://github.com/Baggz","followers_url":"https://api.github.com/users/Baggz/followers","following_url":"https://api.github.com/users/Baggz/following{/other_user}","gists_url":"https://api.github.com/users/Baggz/gists{/gist_id}","starred_url":"https://api.github.com/users/Baggz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Baggz/subscriptions","organizations_url":"https://api.github.com/users/Baggz/orgs","repos_url":"https://api.github.com/users/Baggz/repos","events_url":"https://api.github.com/users/Baggz/events{/privacy}","received_events_url":"https://api.github.com/users/Baggz/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/7/commits","review_comments_url":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/7/comments","review_comment_url":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/danielgtaylor/eidolon/issues/7/comments","statuses_url":"https://api.github.com/repos/danielgtaylor/eidolon/statuses/b9e18a6101ea685af8028cd94a90be404c84c1ef","head":{"label":"danielgtaylor:daniel/default-values","ref":"daniel/default-values","sha":"b9e18a6101ea685af8028cd94a90be404c84c1ef","user":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"repo":{"id":50625349,"name":"eidolon","full_name":"danielgtaylor/eidolon","owner":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danielgtaylor/eidolon","description":"Generate JSON or JSON Schema from Refract & MSON data structures","fork":false,"url":"https://api.github.com/repos/danielgtaylor/eidolon","forks_url":"https://api.github.com/repos/danielgtaylor/eidolon/forks","keys_url":"https://api.github.com/repos/danielgtaylor/eidolon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danielgtaylor/eidolon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danielgtaylor/eidolon/teams","hooks_url":"https://api.github.com/repos/danielgtaylor/eidolon/hooks","issue_events_url":"https://api.github.com/repos/danielgtaylor/eidolon/issues/events{/number}","events_url":"https://api.github.com/repos/danielgtaylor/eidolon/events","assignees_url":"https://api.github.com/repos/danielgtaylor/eidolon/assignees{/user}","branches_url":"https://api.github.com/repos/danielgtaylor/eidolon/branches{/branch}","tags_url":"https://api.github.com/repos/danielgtaylor/eidolon/tags","blobs_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/refs{/sha}","trees_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danielgtaylor/eidolon/statuses/{sha}","languages_url":"https://api.github.com/repos/danielgtaylor/eidolon/languages","stargazers_url":"https://api.github.com/repos/danielgtaylor/eidolon/stargazers","contributors_url":"https://api.github.com/repos/danielgtaylor/eidolon/contributors","subscribers_url":"https://api.github.com/repos/danielgtaylor/eidolon/subscribers","subscription_url":"https://api.github.com/repos/danielgtaylor/eidolon/subscription","commits_url":"https://api.github.com/repos/danielgtaylor/eidolon/commits{/sha}","git_commits_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/commits{/sha}","comments_url":"https://api.github.com/repos/danielgtaylor/eidolon/comments{/number}","issue_comment_url":"https://api.github.com/repos/danielgtaylor/eidolon/issues/comments{/number}","contents_url":"https://api.github.com/repos/danielgtaylor/eidolon/contents/{+path}","compare_url":"https://api.github.com/repos/danielgtaylor/eidolon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danielgtaylor/eidolon/merges","archive_url":"https://api.github.com/repos/danielgtaylor/eidolon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danielgtaylor/eidolon/downloads","issues_url":"https://api.github.com/repos/danielgtaylor/eidolon/issues{/number}","pulls_url":"https://api.github.com/repos/danielgtaylor/eidolon/pulls{/number}","milestones_url":"https://api.github.com/repos/danielgtaylor/eidolon/milestones{/number}","notifications_url":"https://api.github.com/repos/danielgtaylor/eidolon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danielgtaylor/eidolon/labels{/name}","releases_url":"https://api.github.com/repos/danielgtaylor/eidolon/releases{/id}","deployments_url":"https://api.github.com/repos/danielgtaylor/eidolon/deployments","created_at":"2016-01-29T00:39:18Z","updated_at":"2016-02-21T00:39:28Z","pushed_at":"2016-03-01T18:07:58Z","git_url":"git://github.com/danielgtaylor/eidolon.git","ssh_url":"git@github.com:danielgtaylor/eidolon.git","clone_url":"https://github.com/danielgtaylor/eidolon.git","svn_url":"https://github.com/danielgtaylor/eidolon","homepage":null,"size":36,"stargazers_count":3,"watchers_count":3,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"danielgtaylor:master","ref":"master","sha":"a01c5bc608cb541f070cc270cc2af7542480faac","user":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"repo":{"id":50625349,"name":"eidolon","full_name":"danielgtaylor/eidolon","owner":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danielgtaylor/eidolon","description":"Generate JSON or JSON Schema from Refract & MSON data structures","fork":false,"url":"https://api.github.com/repos/danielgtaylor/eidolon","forks_url":"https://api.github.com/repos/danielgtaylor/eidolon/forks","keys_url":"https://api.github.com/repos/danielgtaylor/eidolon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danielgtaylor/eidolon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danielgtaylor/eidolon/teams","hooks_url":"https://api.github.com/repos/danielgtaylor/eidolon/hooks","issue_events_url":"https://api.github.com/repos/danielgtaylor/eidolon/issues/events{/number}","events_url":"https://api.github.com/repos/danielgtaylor/eidolon/events","assignees_url":"https://api.github.com/repos/danielgtaylor/eidolon/assignees{/user}","branches_url":"https://api.github.com/repos/danielgtaylor/eidolon/branches{/branch}","tags_url":"https://api.github.com/repos/danielgtaylor/eidolon/tags","blobs_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/refs{/sha}","trees_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danielgtaylor/eidolon/statuses/{sha}","languages_url":"https://api.github.com/repos/danielgtaylor/eidolon/languages","stargazers_url":"https://api.github.com/repos/danielgtaylor/eidolon/stargazers","contributors_url":"https://api.github.com/repos/danielgtaylor/eidolon/contributors","subscribers_url":"https://api.github.com/repos/danielgtaylor/eidolon/subscribers","subscription_url":"https://api.github.com/repos/danielgtaylor/eidolon/subscription","commits_url":"https://api.github.com/repos/danielgtaylor/eidolon/commits{/sha}","git_commits_url":"https://api.github.com/repos/danielgtaylor/eidolon/git/commits{/sha}","comments_url":"https://api.github.com/repos/danielgtaylor/eidolon/comments{/number}","issue_comment_url":"https://api.github.com/repos/danielgtaylor/eidolon/issues/comments{/number}","contents_url":"https://api.github.com/repos/danielgtaylor/eidolon/contents/{+path}","compare_url":"https://api.github.com/repos/danielgtaylor/eidolon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danielgtaylor/eidolon/merges","archive_url":"https://api.github.com/repos/danielgtaylor/eidolon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danielgtaylor/eidolon/downloads","issues_url":"https://api.github.com/repos/danielgtaylor/eidolon/issues{/number}","pulls_url":"https://api.github.com/repos/danielgtaylor/eidolon/pulls{/number}","milestones_url":"https://api.github.com/repos/danielgtaylor/eidolon/milestones{/number}","notifications_url":"https://api.github.com/repos/danielgtaylor/eidolon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danielgtaylor/eidolon/labels{/name}","releases_url":"https://api.github.com/repos/danielgtaylor/eidolon/releases{/id}","deployments_url":"https://api.github.com/repos/danielgtaylor/eidolon/deployments","created_at":"2016-01-29T00:39:18Z","updated_at":"2016-02-21T00:39:28Z","pushed_at":"2016-03-01T18:07:58Z","git_url":"git://github.com/danielgtaylor/eidolon.git","ssh_url":"git@github.com:danielgtaylor/eidolon.git","clone_url":"https://github.com/danielgtaylor/eidolon.git","svn_url":"https://github.com/danielgtaylor/eidolon","homepage":null,"size":36,"stargazers_count":3,"watchers_count":3,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/7"},"html":{"href":"https://github.com/danielgtaylor/eidolon/pull/7"},"issue":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/issues/7"},"comments":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/danielgtaylor/eidolon/statuses/b9e18a6101ea685af8028cd94a90be404c84c1ef"}}}}