{"action":"created","issue":{"url":"https://api.github.com/repos/tfausak/erudite/issues/6","labels_url":"https://api.github.com/repos/tfausak/erudite/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/tfausak/erudite/issues/6/comments","events_url":"https://api.github.com/repos/tfausak/erudite/issues/6/events","html_url":"https://github.com/tfausak/erudite/pull/6","id":55287246,"number":6,"title":"Extract example code from comments","user":{"login":"tfausak","id":408753,"avatar_url":"https://avatars.githubusercontent.com/u/408753?v=3","gravatar_id":"","url":"https://api.github.com/users/tfausak","html_url":"https://github.com/tfausak","followers_url":"https://api.github.com/users/tfausak/followers","following_url":"https://api.github.com/users/tfausak/following{/other_user}","gists_url":"https://api.github.com/users/tfausak/gists{/gist_id}","starred_url":"https://api.github.com/users/tfausak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfausak/subscriptions","organizations_url":"https://api.github.com/users/tfausak/orgs","repos_url":"https://api.github.com/users/tfausak/repos","events_url":"https://api.github.com/users/tfausak/events{/privacy}","received_events_url":"https://api.github.com/users/tfausak/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tfausak/erudite/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"tfausak","id":408753,"avatar_url":"https://avatars.githubusercontent.com/u/408753?v=3","gravatar_id":"","url":"https://api.github.com/users/tfausak","html_url":"https://github.com/tfausak","followers_url":"https://api.github.com/users/tfausak/followers","following_url":"https://api.github.com/users/tfausak/following{/other_user}","gists_url":"https://api.github.com/users/tfausak/gists{/gist_id}","starred_url":"https://api.github.com/users/tfausak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfausak/subscriptions","organizations_url":"https://api.github.com/users/tfausak/orgs","repos_url":"https://api.github.com/users/tfausak/repos","events_url":"https://api.github.com/users/tfausak/events{/privacy}","received_events_url":"https://api.github.com/users/tfausak/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-01-23T14:32:12Z","updated_at":"2015-01-23T15:11:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tfausak/erudite/pulls/6","html_url":"https://github.com/tfausak/erudite/pull/6","diff_url":"https://github.com/tfausak/erudite/pull/6.diff","patch_url":"https://github.com/tfausak/erudite/pull/6.patch"},"body":"Fixes #5. "},"comment":{"url":"https://api.github.com/repos/tfausak/erudite/issues/comments/71206777","html_url":"https://github.com/tfausak/erudite/pull/6#issuecomment-71206777","issue_url":"https://api.github.com/repos/tfausak/erudite/issues/6","id":71206777,"user":{"login":"tfausak","id":408753,"avatar_url":"https://avatars.githubusercontent.com/u/408753?v=3","gravatar_id":"","url":"https://api.github.com/users/tfausak","html_url":"https://github.com/tfausak","followers_url":"https://api.github.com/users/tfausak/followers","following_url":"https://api.github.com/users/tfausak/following{/other_user}","gists_url":"https://api.github.com/users/tfausak/gists{/gist_id}","starred_url":"https://api.github.com/users/tfausak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfausak/subscriptions","organizations_url":"https://api.github.com/users/tfausak/orgs","repos_url":"https://api.github.com/users/tfausak/repos","events_url":"https://api.github.com/users/tfausak/events{/privacy}","received_events_url":"https://api.github.com/users/tfausak/received_events","type":"User","site_admin":false},"created_at":"2015-01-23T15:11:41Z","updated_at":"2015-01-23T15:11:41Z","body":"Here's a version that passes the example given in #5. \r\n\r\n``` rb\r\nrequire 'erudite'\r\nrequire 'parser/current'\r\n\r\nsource = ARGF.read\r\nbinding = TOPLEVEL_BINDING.dup\r\nbinding.eval(source)\r\n\r\nParser::CurrentRuby\r\n  .parse_with_comments(source)\r\n  .last\r\n  .map(&:text)\r\n  .select { |e| e.start_with?('#') }\r\n  .map { |e| e[1..-1] }\r\n  .map { |e| e.gsub(/^\\s+/, '') }\r\n  .each_with_object([[]]) { |e, a| e.empty? ? a << [] : a.last << e }\r\n  .reject(&:empty?)\r\n  .select { |e| e.first.start_with?('>> ') }\r\n  .map { |e| e.join(\"\\n\") }\r\n  .map { |e| Erudite::Example::Parser.parse(e) }\r\n  .map do |es|\r\n    b = binding.dup\r\n    es.map do |e|\r\n      e.binding = b\r\n      e.pass?\r\n    end\r\n  end\r\n```"}}