{"action":"created","comment":{"url":"https://api.github.com/repos/jonmagic/arca/pulls/comments/34796682","id":34796682,"diff_hunk":"@@ -0,0 +1,96 @@\n+module Arca\n+  class Report\n+\n+    # Arca::Report takes an Arca::Model and compiles the analyzed callback data\n+    # into a short overview report for the model.\n+    def initialize(model)\n+      @model = model\n+    end\n+\n+    # Public: Arca::Model representing the ActiveRecord class being reported.\n+    attr_reader :model\n+\n+    # Public: Hash representation of the object for interactive consoles.\n+    def inspect\n+      to_hash.to_s\n+    end\n+\n+    # Public: Hash of compiled report data.\n+    def to_hash\n+      {\n+        :model_class         => model_class,\n+        :model_file_path     => Arca.relative_path(model_file_path),\n+        :number_of_callbacks => number_of_callbacks,\n+        :lines_between       => lines_between_callbacks,\n+        :externals           => externals,\n+        :conditionals        => conditionals,\n+        :permutations        => permutations\n+      }\n+    end\n+\n+    # Public: String class name of model.\n+    def model_class\n+      model.name\n+    end\n+\n+    # Public: String file path of model.\n+    def model_file_path\n+      model.file_path\n+    end\n+\n+    # Public: Integer representing the number of callbacks used in this model.\n+    def number_of_callbacks\n+      model.analyzed_callbacks_array.size\n+    end\n+\n+    # Public: Integer representing the total number of lines between callbacks\n+    # called for this class from files other than the one where the class is\n+    # defined.\n+    def lines_between_callbacks\n+      lines_between = 0\n+      line_numbers = model.analyzed_callbacks_array.map &:callback_line_number\n+      sorted_line_numbers = line_numbers.sort {|a,b| b <=> a }\n+      sorted_line_numbers.each_with_index do |line_number, index|\n+        lines_between += line_number - (sorted_line_numbers[index + 1] || 0)\n+      end\n+      lines_between\n+    end\n+\n+    # Public: Integer representing the number of callbacks called for this class\n+    # from files other than the one where the class is defined.\n+    def externals\n+      model.analyzed_callbacks_array.select do |analysis|\n+        analysis.external_callback? || analysis.external_target? || analysis.external_conditional_target?\n+      end.size\n+    end\n+\n+    # Public: Integer representing the number of conditionals used in callback\n+    # for the model being reported.\n+    def conditionals\n+      number_of_unique_conditionals(model.analyzed_callbacks_array)\n+    end\n+\n+    # Public: Integer representing the possible number of permutations stemming\n+    # from conditionals for an instance of the model being reported during the\n+    # lifecycle of the object.\n+    def permutations\n+      permutations = model.analyzed_callbacks.inject([]) do |results, (key, analyzed_callbacks)|\n+        results << 2**number_of_unique_conditionals(analyzed_callbacks)","path":"lib/arca/report.rb","position":78,"original_position":78,"commit_id":"366fb937d176002d0903f4ef59468ec69459cbd8","original_commit_id":"366fb937d176002d0903f4ef59468ec69459cbd8","user":{"login":"jnunemaker","id":235,"avatar_url":"https://avatars.githubusercontent.com/u/235?v=3","gravatar_id":"","url":"https://api.github.com/users/jnunemaker","html_url":"https://github.com/jnunemaker","followers_url":"https://api.github.com/users/jnunemaker/followers","following_url":"https://api.github.com/users/jnunemaker/following{/other_user}","gists_url":"https://api.github.com/users/jnunemaker/gists{/gist_id}","starred_url":"https://api.github.com/users/jnunemaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnunemaker/subscriptions","organizations_url":"https://api.github.com/users/jnunemaker/orgs","repos_url":"https://api.github.com/users/jnunemaker/repos","events_url":"https://api.github.com/users/jnunemaker/events{/privacy}","received_events_url":"https://api.github.com/users/jnunemaker/received_events","type":"User","site_admin":true},"body":"2 can't breathe yo. Perhaps some spaces would help. 2 ** number...","created_at":"2015-07-16T14:59:48Z","updated_at":"2015-07-16T14:59:48Z","html_url":"https://github.com/jonmagic/arca/pull/1#discussion_r34796682","pull_request_url":"https://api.github.com/repos/jonmagic/arca/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/jonmagic/arca/pulls/comments/34796682"},"html":{"href":"https://github.com/jonmagic/arca/pull/1#discussion_r34796682"},"pull_request":{"href":"https://api.github.com/repos/jonmagic/arca/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/jonmagic/arca/pulls/1","id":39885189,"html_url":"https://github.com/jonmagic/arca/pull/1","diff_url":"https://github.com/jonmagic/arca/pull/1.diff","patch_url":"https://github.com/jonmagic/arca/pull/1.patch","issue_url":"https://api.github.com/repos/jonmagic/arca/issues/1","number":1,"state":"open","locked":false,"title":"First implementation","user":{"login":"jonmagic","id":623,"avatar_url":"https://avatars.githubusercontent.com/u/623?v=3","gravatar_id":"","url":"https://api.github.com/users/jonmagic","html_url":"https://github.com/jonmagic","followers_url":"https://api.github.com/users/jonmagic/followers","following_url":"https://api.github.com/users/jonmagic/following{/other_user}","gists_url":"https://api.github.com/users/jonmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/jonmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonmagic/subscriptions","organizations_url":"https://api.github.com/users/jonmagic/orgs","repos_url":"https://api.github.com/users/jonmagic/repos","events_url":"https://api.github.com/users/jonmagic/events{/privacy}","received_events_url":"https://api.github.com/users/jonmagic/received_events","type":"User","site_admin":true},"body":"@bkeepers @spraints this is the implementation for the [README](https://github.com/jonmagic/arca/blob/502cecdb57eb1f9253215a1fcafcc3a69f909d00/README.md) I showed you guys earlier today.\r\n\r\nI haven't done any class or method documentation yet but I wanted to get a first version out so I could try it on some real projects and get a feel for how it works. I'd love feedback on the code if you have time to review at some point.\r\n\r\n- [x] TomDoc methods\r\n- [x] Add tests for:\r\n  - [x] https://github.com/jonmagic/arca/commit/9798e1f8ced1b444569c6deef52603eef8301086\r\n  - [x] https://github.com/jonmagic/arca/commit/8c3b8f347d7e7868dbe2660f8c2b89e54818a0f9\r\n  - [x] https://github.com/jonmagic/arca/commit/3a00466c07044d5c949200a5763803b811c5dee3\r\n  - [x] https://github.com/jonmagic/arca/commit/2f61776323cf39fd42a6c51c1647d7c15371af3a\r\n  - [x] https://github.com/jonmagic/arca/commit/cdc1d9d6367689efcf57406a6177bad5e9124eaf\r\n- [ ] Get code review and iterate\r\n- [ ] Merge this PR\r\n- [ ] Cut v1.0.0 and publish to rubygems.org\r\n\r\n/cc @kevinsawicki","created_at":"2015-07-14T06:24:47Z","updated_at":"2015-07-16T14:59:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"882ca86cd08373c255db62f30df137bc041e0e54","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jonmagic/arca/pulls/1/commits","review_comments_url":"https://api.github.com/repos/jonmagic/arca/pulls/1/comments","review_comment_url":"https://api.github.com/repos/jonmagic/arca/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jonmagic/arca/issues/1/comments","statuses_url":"https://api.github.com/repos/jonmagic/arca/statuses/366fb937d176002d0903f4ef59468ec69459cbd8","head":{"label":"jonmagic:first-implementation","ref":"first-implementation","sha":"366fb937d176002d0903f4ef59468ec69459cbd8","user":{"login":"jonmagic","id":623,"avatar_url":"https://avatars.githubusercontent.com/u/623?v=3","gravatar_id":"","url":"https://api.github.com/users/jonmagic","html_url":"https://github.com/jonmagic","followers_url":"https://api.github.com/users/jonmagic/followers","following_url":"https://api.github.com/users/jonmagic/following{/other_user}","gists_url":"https://api.github.com/users/jonmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/jonmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonmagic/subscriptions","organizations_url":"https://api.github.com/users/jonmagic/orgs","repos_url":"https://api.github.com/users/jonmagic/repos","events_url":"https://api.github.com/users/jonmagic/events{/privacy}","received_events_url":"https://api.github.com/users/jonmagic/received_events","type":"User","site_admin":true},"repo":{"id":38952574,"name":"arca","full_name":"jonmagic/arca","owner":{"login":"jonmagic","id":623,"avatar_url":"https://avatars.githubusercontent.com/u/623?v=3","gravatar_id":"","url":"https://api.github.com/users/jonmagic","html_url":"https://github.com/jonmagic","followers_url":"https://api.github.com/users/jonmagic/followers","following_url":"https://api.github.com/users/jonmagic/following{/other_user}","gists_url":"https://api.github.com/users/jonmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/jonmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonmagic/subscriptions","organizations_url":"https://api.github.com/users/jonmagic/orgs","repos_url":"https://api.github.com/users/jonmagic/repos","events_url":"https://api.github.com/users/jonmagic/events{/privacy}","received_events_url":"https://api.github.com/users/jonmagic/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/jonmagic/arca","description":"Arca is a callback analyzer for ActiveRecord ideally suited for digging yourself out of callback hell","fork":false,"url":"https://api.github.com/repos/jonmagic/arca","forks_url":"https://api.github.com/repos/jonmagic/arca/forks","keys_url":"https://api.github.com/repos/jonmagic/arca/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonmagic/arca/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonmagic/arca/teams","hooks_url":"https://api.github.com/repos/jonmagic/arca/hooks","issue_events_url":"https://api.github.com/repos/jonmagic/arca/issues/events{/number}","events_url":"https://api.github.com/repos/jonmagic/arca/events","assignees_url":"https://api.github.com/repos/jonmagic/arca/assignees{/user}","branches_url":"https://api.github.com/repos/jonmagic/arca/branches{/branch}","tags_url":"https://api.github.com/repos/jonmagic/arca/tags","blobs_url":"https://api.github.com/repos/jonmagic/arca/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonmagic/arca/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonmagic/arca/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonmagic/arca/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonmagic/arca/statuses/{sha}","languages_url":"https://api.github.com/repos/jonmagic/arca/languages","stargazers_url":"https://api.github.com/repos/jonmagic/arca/stargazers","contributors_url":"https://api.github.com/repos/jonmagic/arca/contributors","subscribers_url":"https://api.github.com/repos/jonmagic/arca/subscribers","subscription_url":"https://api.github.com/repos/jonmagic/arca/subscription","commits_url":"https://api.github.com/repos/jonmagic/arca/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonmagic/arca/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonmagic/arca/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonmagic/arca/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonmagic/arca/contents/{+path}","compare_url":"https://api.github.com/repos/jonmagic/arca/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonmagic/arca/merges","archive_url":"https://api.github.com/repos/jonmagic/arca/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonmagic/arca/downloads","issues_url":"https://api.github.com/repos/jonmagic/arca/issues{/number}","pulls_url":"https://api.github.com/repos/jonmagic/arca/pulls{/number}","milestones_url":"https://api.github.com/repos/jonmagic/arca/milestones{/number}","notifications_url":"https://api.github.com/repos/jonmagic/arca/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonmagic/arca/labels{/name}","releases_url":"https://api.github.com/repos/jonmagic/arca/releases{/id}","created_at":"2015-07-12T06:35:51Z","updated_at":"2015-07-14T06:31:39Z","pushed_at":"2015-07-15T19:16:16Z","git_url":"git://github.com/jonmagic/arca.git","ssh_url":"git@github.com:jonmagic/arca.git","clone_url":"https://github.com/jonmagic/arca.git","svn_url":"https://github.com/jonmagic/arca","homepage":"","size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"jonmagic:master","ref":"master","sha":"8aadfde419d1f713485c109001b9575c2017d906","user":{"login":"jonmagic","id":623,"avatar_url":"https://avatars.githubusercontent.com/u/623?v=3","gravatar_id":"","url":"https://api.github.com/users/jonmagic","html_url":"https://github.com/jonmagic","followers_url":"https://api.github.com/users/jonmagic/followers","following_url":"https://api.github.com/users/jonmagic/following{/other_user}","gists_url":"https://api.github.com/users/jonmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/jonmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonmagic/subscriptions","organizations_url":"https://api.github.com/users/jonmagic/orgs","repos_url":"https://api.github.com/users/jonmagic/repos","events_url":"https://api.github.com/users/jonmagic/events{/privacy}","received_events_url":"https://api.github.com/users/jonmagic/received_events","type":"User","site_admin":true},"repo":{"id":38952574,"name":"arca","full_name":"jonmagic/arca","owner":{"login":"jonmagic","id":623,"avatar_url":"https://avatars.githubusercontent.com/u/623?v=3","gravatar_id":"","url":"https://api.github.com/users/jonmagic","html_url":"https://github.com/jonmagic","followers_url":"https://api.github.com/users/jonmagic/followers","following_url":"https://api.github.com/users/jonmagic/following{/other_user}","gists_url":"https://api.github.com/users/jonmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/jonmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonmagic/subscriptions","organizations_url":"https://api.github.com/users/jonmagic/orgs","repos_url":"https://api.github.com/users/jonmagic/repos","events_url":"https://api.github.com/users/jonmagic/events{/privacy}","received_events_url":"https://api.github.com/users/jonmagic/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/jonmagic/arca","description":"Arca is a callback analyzer for ActiveRecord ideally suited for digging yourself out of callback hell","fork":false,"url":"https://api.github.com/repos/jonmagic/arca","forks_url":"https://api.github.com/repos/jonmagic/arca/forks","keys_url":"https://api.github.com/repos/jonmagic/arca/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonmagic/arca/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonmagic/arca/teams","hooks_url":"https://api.github.com/repos/jonmagic/arca/hooks","issue_events_url":"https://api.github.com/repos/jonmagic/arca/issues/events{/number}","events_url":"https://api.github.com/repos/jonmagic/arca/events","assignees_url":"https://api.github.com/repos/jonmagic/arca/assignees{/user}","branches_url":"https://api.github.com/repos/jonmagic/arca/branches{/branch}","tags_url":"https://api.github.com/repos/jonmagic/arca/tags","blobs_url":"https://api.github.com/repos/jonmagic/arca/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonmagic/arca/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonmagic/arca/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonmagic/arca/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonmagic/arca/statuses/{sha}","languages_url":"https://api.github.com/repos/jonmagic/arca/languages","stargazers_url":"https://api.github.com/repos/jonmagic/arca/stargazers","contributors_url":"https://api.github.com/repos/jonmagic/arca/contributors","subscribers_url":"https://api.github.com/repos/jonmagic/arca/subscribers","subscription_url":"https://api.github.com/repos/jonmagic/arca/subscription","commits_url":"https://api.github.com/repos/jonmagic/arca/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonmagic/arca/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonmagic/arca/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonmagic/arca/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonmagic/arca/contents/{+path}","compare_url":"https://api.github.com/repos/jonmagic/arca/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonmagic/arca/merges","archive_url":"https://api.github.com/repos/jonmagic/arca/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonmagic/arca/downloads","issues_url":"https://api.github.com/repos/jonmagic/arca/issues{/number}","pulls_url":"https://api.github.com/repos/jonmagic/arca/pulls{/number}","milestones_url":"https://api.github.com/repos/jonmagic/arca/milestones{/number}","notifications_url":"https://api.github.com/repos/jonmagic/arca/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonmagic/arca/labels{/name}","releases_url":"https://api.github.com/repos/jonmagic/arca/releases{/id}","created_at":"2015-07-12T06:35:51Z","updated_at":"2015-07-14T06:31:39Z","pushed_at":"2015-07-15T19:16:16Z","git_url":"git://github.com/jonmagic/arca.git","ssh_url":"git@github.com:jonmagic/arca.git","clone_url":"https://github.com/jonmagic/arca.git","svn_url":"https://github.com/jonmagic/arca","homepage":"","size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jonmagic/arca/pulls/1"},"html":{"href":"https://github.com/jonmagic/arca/pull/1"},"issue":{"href":"https://api.github.com/repos/jonmagic/arca/issues/1"},"comments":{"href":"https://api.github.com/repos/jonmagic/arca/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/jonmagic/arca/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/jonmagic/arca/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jonmagic/arca/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/jonmagic/arca/statuses/366fb937d176002d0903f4ef59468ec69459cbd8"}}}}