{"action":"created","issue":{"url":"https://api.github.com/repos/manastech/crystal/issues/1487","labels_url":"https://api.github.com/repos/manastech/crystal/issues/1487/labels{/name}","comments_url":"https://api.github.com/repos/manastech/crystal/issues/1487/comments","events_url":"https://api.github.com/repos/manastech/crystal/issues/1487/events","html_url":"https://github.com/manastech/crystal/pull/1487","id":106597371,"number":1487,"title":"Reimplementation of glob in Crystal","user":{"login":"pgkos","id":11692818,"avatar_url":"https://avatars.githubusercontent.com/u/11692818?v=3","gravatar_id":"","url":"https://api.github.com/users/pgkos","html_url":"https://github.com/pgkos","followers_url":"https://api.github.com/users/pgkos/followers","following_url":"https://api.github.com/users/pgkos/following{/other_user}","gists_url":"https://api.github.com/users/pgkos/gists{/gist_id}","starred_url":"https://api.github.com/users/pgkos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgkos/subscriptions","organizations_url":"https://api.github.com/users/pgkos/orgs","repos_url":"https://api.github.com/users/pgkos/repos","events_url":"https://api.github.com/users/pgkos/events{/privacy}","received_events_url":"https://api.github.com/users/pgkos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-09-15T16:42:45Z","updated_at":"2015-09-19T20:29:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/manastech/crystal/pulls/1487","html_url":"https://github.com/manastech/crystal/pull/1487","diff_url":"https://github.com/manastech/crystal/pull/1487.diff","patch_url":"https://github.com/manastech/crystal/pull/1487.patch"},"body":"This is an attempt to reimplement glob in Crystal. I have tried to make it behave exactly like in Ruby, therefore it also supports recursive glob. So, it should fix #1433.\r\n\r\nIt works by converting the glob pattern into a regex, traversing the directory recursively and matching the relative paths.\r\n\r\nThere are still some issues which we have to consider:\r\n* should we recurse into paths pointed to by symbolic links?\r\n* should the file read/access errors be raised (now they are rescued silently)?\r\n* improve and test the glob's syntax on Windows (of course after implementing the other methods using Windows API)\r\n* should there be an instance glob method? (so it is not required to use `chdir`)\r\n\r\nSorry for the wordy `scandir` method. Please consider supporting recursive `yield` (it would simplify the code very much)!"},"comment":{"url":"https://api.github.com/repos/manastech/crystal/issues/comments/141703337","html_url":"https://github.com/manastech/crystal/pull/1487#issuecomment-141703337","issue_url":"https://api.github.com/repos/manastech/crystal/issues/1487","id":141703337,"user":{"login":"pgkos","id":11692818,"avatar_url":"https://avatars.githubusercontent.com/u/11692818?v=3","gravatar_id":"","url":"https://api.github.com/users/pgkos","html_url":"https://github.com/pgkos","followers_url":"https://api.github.com/users/pgkos/followers","following_url":"https://api.github.com/users/pgkos/following{/other_user}","gists_url":"https://api.github.com/users/pgkos/gists{/gist_id}","starred_url":"https://api.github.com/users/pgkos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgkos/subscriptions","organizations_url":"https://api.github.com/users/pgkos/orgs","repos_url":"https://api.github.com/users/pgkos/repos","events_url":"https://api.github.com/users/pgkos/events{/privacy}","received_events_url":"https://api.github.com/users/pgkos/received_events","type":"User","site_admin":false},"created_at":"2015-09-19T20:29:41Z","updated_at":"2015-09-19T20:29:41Z","body":"Your examples should work - the glob pattern gets converted into a regex, so in your last example:\r\n```\r\nrc/i{?,{terable,iterator}}.cr\r\n```\r\nis converted into:\r\n```\r\nrc/i(?:.|(?:terable|iterator)).cr\r\n```\r\nThe curly braces are converted into non-capturing groups, `?`s are converted into `.` and `,` are converted (only if inside curly braces) into `|`.\r\nAlso:\r\n* `*` are converted into `[^\\\\/]*`\r\n* `**` into `.*` and\r\n* `**/` into `(?:.*/)`"}}