{"action":"created","comment":{"url":"https://api.github.com/repos/premailer/css_parser/pulls/comments/105594110","pull_request_review_id":26480221,"id":105594110,"diff_hunk":"@@ -289,9 +305,16 @@ def parse_block_into_rule_sets!(block, options = {}) # :nodoc:\n       current_media_query = ''\n       current_declarations = ''\n \n-      block.scan(/(([\\\\]{2,})|([\\\\]?[{}\\s\"])|(.[^\\s\"{}\\\\]*))/).each do |matches|\n+      # once we are in a rule, we will use this to store where we started if we are capturing offsets\n+      rule_start = nil\n+      offset = nil\n+\n+      block.scan(/(([\\\\]{2,})|([\\\\]?[{}\\s\"])|(.[^\\s\"{}\\\\]*))/) do |matches|\n         token = matches[0]\n \n+        # save the regex offset so that we know where in the file we are\n+        offset = Regexp.last_match.offset(0) if options[:capture_offsets]","path":"lib/css_parser/parser.rb","position":75,"original_position":75,"commit_id":"e3a71daeb56d257b6901b359520d322c214b88b4","original_commit_id":"e3a71daeb56d257b6901b359520d322c214b88b4","user":{"login":"grosser","id":11367,"avatar_url":"https://avatars0.githubusercontent.com/u/11367?v=3","gravatar_id":"","url":"https://api.github.com/users/grosser","html_url":"https://github.com/grosser","followers_url":"https://api.github.com/users/grosser/followers","following_url":"https://api.github.com/users/grosser/following{/other_user}","gists_url":"https://api.github.com/users/grosser/gists{/gist_id}","starred_url":"https://api.github.com/users/grosser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grosser/subscriptions","organizations_url":"https://api.github.com/users/grosser/orgs","repos_url":"https://api.github.com/users/grosser/repos","events_url":"https://api.github.com/users/grosser/events{/privacy}","received_events_url":"https://api.github.com/users/grosser/received_events","type":"User","site_admin":false},"body":"might be worth extracting that into a local variable if this code is used a lot","created_at":"2017-03-13T05:54:04Z","updated_at":"2017-03-13T05:54:04Z","html_url":"https://github.com/premailer/css_parser/pull/85#discussion_r105594110","pull_request_url":"https://api.github.com/repos/premailer/css_parser/pulls/85","_links":{"self":{"href":"https://api.github.com/repos/premailer/css_parser/pulls/comments/105594110"},"html":{"href":"https://github.com/premailer/css_parser/pull/85#discussion_r105594110"},"pull_request":{"href":"https://api.github.com/repos/premailer/css_parser/pulls/85"}}},"pull_request":{"url":"https://api.github.com/repos/premailer/css_parser/pulls/85","id":109837817,"html_url":"https://github.com/premailer/css_parser/pull/85","diff_url":"https://github.com/premailer/css_parser/pull/85.diff","patch_url":"https://github.com/premailer/css_parser/pull/85.patch","issue_url":"https://api.github.com/repos/premailer/css_parser/issues/85","number":85,"state":"open","locked":false,"title":"Added byte offsets to rule sets","user":{"login":"G0dwin","id":1109252,"avatar_url":"https://avatars3.githubusercontent.com/u/1109252?v=3","gravatar_id":"","url":"https://api.github.com/users/G0dwin","html_url":"https://github.com/G0dwin","followers_url":"https://api.github.com/users/G0dwin/followers","following_url":"https://api.github.com/users/G0dwin/following{/other_user}","gists_url":"https://api.github.com/users/G0dwin/gists{/gist_id}","starred_url":"https://api.github.com/users/G0dwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/G0dwin/subscriptions","organizations_url":"https://api.github.com/users/G0dwin/orgs","repos_url":"https://api.github.com/users/G0dwin/repos","events_url":"https://api.github.com/users/G0dwin/events{/privacy}","received_events_url":"https://api.github.com/users/G0dwin/received_events","type":"User","site_admin":false},"body":"I have added some basic logic to the parser to capture byte offsets when scanning for rule sets and added a field to `RuleSet` to retain them. This will allow code coverage and lint utilities (for example) to report where in a file a particular rule was found (see the CSS code coverage utility I'm working on here: [lingua-franca/marmara](https://github.com/lingua-franca/marmara)).\r\n\r\nThere is still more work that needs to be done, primarily when it comes to differentiating files (from `@import` statement or otherwise), and when urls are expanded.","created_at":"2017-03-09T04:16:48Z","updated_at":"2017-03-13T05:54:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6756575603aaae3c6dfe992c16fc9b36533a46f8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/premailer/css_parser/pulls/85/commits","review_comments_url":"https://api.github.com/repos/premailer/css_parser/pulls/85/comments","review_comment_url":"https://api.github.com/repos/premailer/css_parser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/premailer/css_parser/issues/85/comments","statuses_url":"https://api.github.com/repos/premailer/css_parser/statuses/e3a71daeb56d257b6901b359520d322c214b88b4","head":{"label":"lingua-franca:master","ref":"master","sha":"e3a71daeb56d257b6901b359520d322c214b88b4","user":{"login":"lingua-franca","id":10481870,"avatar_url":"https://avatars3.githubusercontent.com/u/10481870?v=3","gravatar_id":"","url":"https://api.github.com/users/lingua-franca","html_url":"https://github.com/lingua-franca","followers_url":"https://api.github.com/users/lingua-franca/followers","following_url":"https://api.github.com/users/lingua-franca/following{/other_user}","gists_url":"https://api.github.com/users/lingua-franca/gists{/gist_id}","starred_url":"https://api.github.com/users/lingua-franca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lingua-franca/subscriptions","organizations_url":"https://api.github.com/users/lingua-franca/orgs","repos_url":"https://api.github.com/users/lingua-franca/repos","events_url":"https://api.github.com/users/lingua-franca/events{/privacy}","received_events_url":"https://api.github.com/users/lingua-franca/received_events","type":"Organization","site_admin":false},"repo":{"id":84384557,"name":"css_parser","full_name":"lingua-franca/css_parser","owner":{"login":"lingua-franca","id":10481870,"avatar_url":"https://avatars3.githubusercontent.com/u/10481870?v=3","gravatar_id":"","url":"https://api.github.com/users/lingua-franca","html_url":"https://github.com/lingua-franca","followers_url":"https://api.github.com/users/lingua-franca/followers","following_url":"https://api.github.com/users/lingua-franca/following{/other_user}","gists_url":"https://api.github.com/users/lingua-franca/gists{/gist_id}","starred_url":"https://api.github.com/users/lingua-franca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lingua-franca/subscriptions","organizations_url":"https://api.github.com/users/lingua-franca/orgs","repos_url":"https://api.github.com/users/lingua-franca/repos","events_url":"https://api.github.com/users/lingua-franca/events{/privacy}","received_events_url":"https://api.github.com/users/lingua-franca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lingua-franca/css_parser","description":"Ruby CSS Parser","fork":true,"url":"https://api.github.com/repos/lingua-franca/css_parser","forks_url":"https://api.github.com/repos/lingua-franca/css_parser/forks","keys_url":"https://api.github.com/repos/lingua-franca/css_parser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lingua-franca/css_parser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lingua-franca/css_parser/teams","hooks_url":"https://api.github.com/repos/lingua-franca/css_parser/hooks","issue_events_url":"https://api.github.com/repos/lingua-franca/css_parser/issues/events{/number}","events_url":"https://api.github.com/repos/lingua-franca/css_parser/events","assignees_url":"https://api.github.com/repos/lingua-franca/css_parser/assignees{/user}","branches_url":"https://api.github.com/repos/lingua-franca/css_parser/branches{/branch}","tags_url":"https://api.github.com/repos/lingua-franca/css_parser/tags","blobs_url":"https://api.github.com/repos/lingua-franca/css_parser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lingua-franca/css_parser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lingua-franca/css_parser/git/refs{/sha}","trees_url":"https://api.github.com/repos/lingua-franca/css_parser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lingua-franca/css_parser/statuses/{sha}","languages_url":"https://api.github.com/repos/lingua-franca/css_parser/languages","stargazers_url":"https://api.github.com/repos/lingua-franca/css_parser/stargazers","contributors_url":"https://api.github.com/repos/lingua-franca/css_parser/contributors","subscribers_url":"https://api.github.com/repos/lingua-franca/css_parser/subscribers","subscription_url":"https://api.github.com/repos/lingua-franca/css_parser/subscription","commits_url":"https://api.github.com/repos/lingua-franca/css_parser/commits{/sha}","git_commits_url":"https://api.github.com/repos/lingua-franca/css_parser/git/commits{/sha}","comments_url":"https://api.github.com/repos/lingua-franca/css_parser/comments{/number}","issue_comment_url":"https://api.github.com/repos/lingua-franca/css_parser/issues/comments{/number}","contents_url":"https://api.github.com/repos/lingua-franca/css_parser/contents/{+path}","compare_url":"https://api.github.com/repos/lingua-franca/css_parser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lingua-franca/css_parser/merges","archive_url":"https://api.github.com/repos/lingua-franca/css_parser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lingua-franca/css_parser/downloads","issues_url":"https://api.github.com/repos/lingua-franca/css_parser/issues{/number}","pulls_url":"https://api.github.com/repos/lingua-franca/css_parser/pulls{/number}","milestones_url":"https://api.github.com/repos/lingua-franca/css_parser/milestones{/number}","notifications_url":"https://api.github.com/repos/lingua-franca/css_parser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lingua-franca/css_parser/labels{/name}","releases_url":"https://api.github.com/repos/lingua-franca/css_parser/releases{/id}","deployments_url":"https://api.github.com/repos/lingua-franca/css_parser/deployments","created_at":"2017-03-09T01:39:08Z","updated_at":"2017-03-09T01:39:09Z","pushed_at":"2017-03-13T02:08:23Z","git_url":"git://github.com/lingua-franca/css_parser.git","ssh_url":"git@github.com:lingua-franca/css_parser.git","clone_url":"https://github.com/lingua-franca/css_parser.git","svn_url":"https://github.com/lingua-franca/css_parser","homepage":"","size":366,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"premailer:master","ref":"master","sha":"613650a8309335ef5ad5548d1b9cb9503a7a5d51","user":{"login":"premailer","id":5750522,"avatar_url":"https://avatars0.githubusercontent.com/u/5750522?v=3","gravatar_id":"","url":"https://api.github.com/users/premailer","html_url":"https://github.com/premailer","followers_url":"https://api.github.com/users/premailer/followers","following_url":"https://api.github.com/users/premailer/following{/other_user}","gists_url":"https://api.github.com/users/premailer/gists{/gist_id}","starred_url":"https://api.github.com/users/premailer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/premailer/subscriptions","organizations_url":"https://api.github.com/users/premailer/orgs","repos_url":"https://api.github.com/users/premailer/repos","events_url":"https://api.github.com/users/premailer/events{/privacy}","received_events_url":"https://api.github.com/users/premailer/received_events","type":"Organization","site_admin":false},"repo":{"id":408234,"name":"css_parser","full_name":"premailer/css_parser","owner":{"login":"premailer","id":5750522,"avatar_url":"https://avatars0.githubusercontent.com/u/5750522?v=3","gravatar_id":"","url":"https://api.github.com/users/premailer","html_url":"https://github.com/premailer","followers_url":"https://api.github.com/users/premailer/followers","following_url":"https://api.github.com/users/premailer/following{/other_user}","gists_url":"https://api.github.com/users/premailer/gists{/gist_id}","starred_url":"https://api.github.com/users/premailer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/premailer/subscriptions","organizations_url":"https://api.github.com/users/premailer/orgs","repos_url":"https://api.github.com/users/premailer/repos","events_url":"https://api.github.com/users/premailer/events{/privacy}","received_events_url":"https://api.github.com/users/premailer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/premailer/css_parser","description":"Ruby CSS Parser","fork":false,"url":"https://api.github.com/repos/premailer/css_parser","forks_url":"https://api.github.com/repos/premailer/css_parser/forks","keys_url":"https://api.github.com/repos/premailer/css_parser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/premailer/css_parser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/premailer/css_parser/teams","hooks_url":"https://api.github.com/repos/premailer/css_parser/hooks","issue_events_url":"https://api.github.com/repos/premailer/css_parser/issues/events{/number}","events_url":"https://api.github.com/repos/premailer/css_parser/events","assignees_url":"https://api.github.com/repos/premailer/css_parser/assignees{/user}","branches_url":"https://api.github.com/repos/premailer/css_parser/branches{/branch}","tags_url":"https://api.github.com/repos/premailer/css_parser/tags","blobs_url":"https://api.github.com/repos/premailer/css_parser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/premailer/css_parser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/premailer/css_parser/git/refs{/sha}","trees_url":"https://api.github.com/repos/premailer/css_parser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/premailer/css_parser/statuses/{sha}","languages_url":"https://api.github.com/repos/premailer/css_parser/languages","stargazers_url":"https://api.github.com/repos/premailer/css_parser/stargazers","contributors_url":"https://api.github.com/repos/premailer/css_parser/contributors","subscribers_url":"https://api.github.com/repos/premailer/css_parser/subscribers","subscription_url":"https://api.github.com/repos/premailer/css_parser/subscription","commits_url":"https://api.github.com/repos/premailer/css_parser/commits{/sha}","git_commits_url":"https://api.github.com/repos/premailer/css_parser/git/commits{/sha}","comments_url":"https://api.github.com/repos/premailer/css_parser/comments{/number}","issue_comment_url":"https://api.github.com/repos/premailer/css_parser/issues/comments{/number}","contents_url":"https://api.github.com/repos/premailer/css_parser/contents/{+path}","compare_url":"https://api.github.com/repos/premailer/css_parser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/premailer/css_parser/merges","archive_url":"https://api.github.com/repos/premailer/css_parser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/premailer/css_parser/downloads","issues_url":"https://api.github.com/repos/premailer/css_parser/issues{/number}","pulls_url":"https://api.github.com/repos/premailer/css_parser/pulls{/number}","milestones_url":"https://api.github.com/repos/premailer/css_parser/milestones{/number}","notifications_url":"https://api.github.com/repos/premailer/css_parser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/premailer/css_parser/labels{/name}","releases_url":"https://api.github.com/repos/premailer/css_parser/releases{/id}","deployments_url":"https://api.github.com/repos/premailer/css_parser/deployments","created_at":"2009-12-08T17:22:24Z","updated_at":"2017-02-13T10:30:47Z","pushed_at":"2017-03-13T02:08:24Z","git_url":"git://github.com/premailer/css_parser.git","ssh_url":"git@github.com:premailer/css_parser.git","clone_url":"https://github.com/premailer/css_parser.git","svn_url":"https://github.com/premailer/css_parser","homepage":"","size":361,"stargazers_count":176,"watchers_count":176,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"open_issues_count":14,"forks":81,"open_issues":14,"watchers":176,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/premailer/css_parser/pulls/85"},"html":{"href":"https://github.com/premailer/css_parser/pull/85"},"issue":{"href":"https://api.github.com/repos/premailer/css_parser/issues/85"},"comments":{"href":"https://api.github.com/repos/premailer/css_parser/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/premailer/css_parser/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/premailer/css_parser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/premailer/css_parser/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/premailer/css_parser/statuses/e3a71daeb56d257b6901b359520d322c214b88b4"}}}}
{"actor":{"display_login":"grosser"}}