GitHub PullRequestReviewCommentEvent at 2014-06-11 10:18:46
Repository: barclamp-crowbar
Actor: tboerger
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/comments/13642157","id":13642157,"diff_hunk":"@@ -0,0 +1,111 @@\n+module ChefFinders\n+  class RecordNotFound < StandardError; end\n+  class NotImplemented < StandardError; end\n+\n+  # Chef::Node, Chef::Role, Chef::DataBag...\n+  def chef_class\n+    raise NotImplemented.new\n+  end\n+\n+  # 'node', 'role', 'data_bag'...\n+  def chef_type\n+    raise NotImplemented.new\n+  end\n+\n+  def after_find_filter(results)\n+    results\n+  end\n+\n+  def method_missing(m, *a, &block)\n+    return super unless m.to_s =~ /^find_(all_)?by_(.*?)(!)?$/\n+\n+    find_or_fail = !$3.blank?\n+    find_first   =  $1.blank?\n+    params       =  $2.split(\"_and_\").map(&:to_sym)\n+\n+    unless params.count == a.count\n+      raise ArgumentError.new(\"Wrong number of arguments (#{a.count} for #{params.count})\")\n+    end\n+\n+    args       = a.slice(0, params.count)\n+    conditions = Hash[params.zip(args)]\n+    result     = where(conditions)\n+\n+    if find_first && result\n+      result = result.first\n+    end\n+\n+    if find_or_fail\n+      if (find_first && result.nil?) || (!find_first && result.empty?)\n+        raise RecordNotFound.new(\"Cannot find any records matching query #{build_query(conditions)}\")\n+      end\n+    end\n+\n+    result\n+  end\n+\n+  def load(id)\n+    begin\n+      result = benchmark_query(id) do\n+        chef_class.load(id)\n+      end\n+      new(result)\n+    rescue Net::HTTPServerException => e\n+      if e.response.code == \"404\"\n+        Rails.logger.warn(\"[chef search] #{chef_type} #{id} not found.\")\n+        nil\n+      else\n+        raise e\n+      end\n+    end\n+  end\n+\n+  def all\n+    where\n+  end\n+\n+  def where(conditions = {})\n+    results, offset, count = raw_search(conditions)\n+    results.map! { |r| new(r) }\n+    after_find_filter(results)\n+  end\n+\n+  def chef_escape(str)","path":"crowbar_framework/lib/chef_finders.rb","position":73,"original_position":73,"commit_id":"ee281a0868532ba63e3b1c0388d5b055c680af80","original_commit_id":"ee281a0868532ba63e3b1c0388d5b055c680af80","user":{"login":"tboerger","id":156964,"avatar_url":"https://avatars.githubusercontent.com/u/156964?","gravatar_id":"6df4df5c7a529f45372596c370d20026","url":"https://api.github.com/users/tboerger","html_url":"https://github.com/tboerger","followers_url":"https://api.github.com/users/tboerger/followers","following_url":"https://api.github.com/users/tboerger/following{/other_user}","gists_url":"https://api.github.com/users/tboerger/gists{/gist_id}","starred_url":"https://api.github.com/users/tboerger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tboerger/subscriptions","organizations_url":"https://api.github.com/users/tboerger/orgs","repos_url":"https://api.github.com/users/tboerger/repos","events_url":"https://api.github.com/users/tboerger/events{/privacy}","received_events_url":"https://api.github.com/users/tboerger/received_events","type":"User","site_admin":false},"body":"I agree with @bkutil ","created_at":"2014-06-11T10:18:46Z","updated_at":"2014-06-11T10:18:46Z","html_url":"https://github.com/crowbar/barclamp-crowbar/pull/1054#discussion_r13642157","pull_request_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/1054","_links":{"self":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/comments/13642157"},"html":{"href":"https://github.com/crowbar/barclamp-crowbar/pull/1054#discussion_r13642157"},"pull_request":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/1054"}}},"pull_request":{"url":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/1054","id":16654752,"html_url":"https://github.com/crowbar/barclamp-crowbar/pull/1054","diff_url":"https://github.com/crowbar/barclamp-crowbar/pull/1054.diff","patch_url":"https://github.com/crowbar/barclamp-crowbar/pull/1054.patch","issue_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/issues/1054","number":1054,"state":"open","title":"[WIP] Refactor chef finder methods into a single module","user":{"login":"bkutil","id":696026,"avatar_url":"https://avatars.githubusercontent.com/u/696026?","gravatar_id":"ada99ec6c79780471edd2bfe1ac2eb9a","url":"https://api.github.com/users/bkutil","html_url":"https://github.com/bkutil","followers_url":"https://api.github.com/users/bkutil/followers","following_url":"https://api.github.com/users/bkutil/following{/other_user}","gists_url":"https://api.github.com/users/bkutil/gists{/gist_id}","starred_url":"https://api.github.com/users/bkutil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkutil/subscriptions","organizations_url":"https://api.github.com/users/bkutil/orgs","repos_url":"https://api.github.com/users/bkutil/repos","events_url":"https://api.github.com/users/bkutil/events{/privacy}","received_events_url":"https://api.github.com/users/bkutil/received_events","type":"User","site_admin":false},"body":"Refactor the chef finders into a single module, then include them into *Objects.\r\n\r\nThis can help in debugging and profiling the chef queries, and keeps the syntax consistent across the *Object classes.\r\n\r\nThe existing methods were covered by tests (#1041), to ensure the API won't change. Also, they now emit a deprecation warning to help in transitioning to the new syntax.\r\n\r\nThe patch set is currently not field tested, which is why its marked WIP.","created_at":"2014-06-03T14:11:35Z","updated_at":"2014-06-11T10:18:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9d43053444f10ef9bf956ded8d726d7ed9590a3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/1054/commits","review_comments_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/1054/comments","review_comment_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/comments/{number}","comments_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/issues/1054/comments","statuses_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/statuses/ee281a0868532ba63e3b1c0388d5b055c680af80","head":{"label":"bkutil:finders","ref":"finders","sha":"ee281a0868532ba63e3b1c0388d5b055c680af80","user":{"login":"bkutil","id":696026,"avatar_url":"https://avatars.githubusercontent.com/u/696026?","gravatar_id":"ada99ec6c79780471edd2bfe1ac2eb9a","url":"https://api.github.com/users/bkutil","html_url":"https://github.com/bkutil","followers_url":"https://api.github.com/users/bkutil/followers","following_url":"https://api.github.com/users/bkutil/following{/other_user}","gists_url":"https://api.github.com/users/bkutil/gists{/gist_id}","starred_url":"https://api.github.com/users/bkutil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkutil/subscriptions","organizations_url":"https://api.github.com/users/bkutil/orgs","repos_url":"https://api.github.com/users/bkutil/repos","events_url":"https://api.github.com/users/bkutil/events{/privacy}","received_events_url":"https://api.github.com/users/bkutil/received_events","type":"User","site_admin":false},"repo":{"id":14868638,"name":"barclamp-crowbar","full_name":"bkutil/barclamp-crowbar","owner":{"login":"bkutil","id":696026,"avatar_url":"https://avatars.githubusercontent.com/u/696026?","gravatar_id":"ada99ec6c79780471edd2bfe1ac2eb9a","url":"https://api.github.com/users/bkutil","html_url":"https://github.com/bkutil","followers_url":"https://api.github.com/users/bkutil/followers","following_url":"https://api.github.com/users/bkutil/following{/other_user}","gists_url":"https://api.github.com/users/bkutil/gists{/gist_id}","starred_url":"https://api.github.com/users/bkutil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkutil/subscriptions","organizations_url":"https://api.github.com/users/bkutil/orgs","repos_url":"https://api.github.com/users/bkutil/repos","events_url":"https://api.github.com/users/bkutil/events{/privacy}","received_events_url":"https://api.github.com/users/bkutil/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bkutil/barclamp-crowbar","description":"Crowbar Core Barclamp","fork":true,"url":"https://api.github.com/repos/bkutil/barclamp-crowbar","forks_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/forks","keys_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/teams","hooks_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/hooks","issue_events_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/issues/events{/number}","events_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/events","assignees_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/assignees{/user}","branches_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/branches{/branch}","tags_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/tags","blobs_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/git/refs{/sha}","trees_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/statuses/{sha}","languages_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/languages","stargazers_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/stargazers","contributors_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/contributors","subscribers_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/subscribers","subscription_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/subscription","commits_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/commits{/sha}","git_commits_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/git/commits{/sha}","comments_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/comments{/number}","issue_comment_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/issues/comments/{number}","contents_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/contents/{+path}","compare_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/merges","archive_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/downloads","issues_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/issues{/number}","pulls_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/pulls{/number}","milestones_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/milestones{/number}","notifications_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/labels{/name}","releases_url":"https://api.github.com/repos/bkutil/barclamp-crowbar/releases{/id}","created_at":"2013-12-02T16:54:48Z","updated_at":"2014-06-11T09:16:52Z","pushed_at":"2014-06-11T09:13:45Z","git_url":"git://github.com/bkutil/barclamp-crowbar.git","ssh_url":"git@github.com:bkutil/barclamp-crowbar.git","clone_url":"https://github.com/bkutil/barclamp-crowbar.git","svn_url":"https://github.com/bkutil/barclamp-crowbar","homepage":"https://github.com/crowbar/crowbar","size":41663,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"crowbar:master","ref":"master","sha":"b65fc33aaedd292f52c613eb294ca8e4b5a3a7e8","user":{"login":"crowbar","id":2910205,"avatar_url":"https://avatars.githubusercontent.com/u/2910205?","gravatar_id":"36825f9798aaf5d8795156f057fcf4a4","url":"https://api.github.com/users/crowbar","html_url":"https://github.com/crowbar","followers_url":"https://api.github.com/users/crowbar/followers","following_url":"https://api.github.com/users/crowbar/following{/other_user}","gists_url":"https://api.github.com/users/crowbar/gists{/gist_id}","starred_url":"https://api.github.com/users/crowbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crowbar/subscriptions","organizations_url":"https://api.github.com/users/crowbar/orgs","repos_url":"https://api.github.com/users/crowbar/repos","events_url":"https://api.github.com/users/crowbar/events{/privacy}","received_events_url":"https://api.github.com/users/crowbar/received_events","type":"Organization","site_admin":false},"repo":{"id":2351384,"name":"barclamp-crowbar","full_name":"crowbar/barclamp-crowbar","owner":{"login":"crowbar","id":2910205,"avatar_url":"https://avatars.githubusercontent.com/u/2910205?","gravatar_id":"36825f9798aaf5d8795156f057fcf4a4","url":"https://api.github.com/users/crowbar","html_url":"https://github.com/crowbar","followers_url":"https://api.github.com/users/crowbar/followers","following_url":"https://api.github.com/users/crowbar/following{/other_user}","gists_url":"https://api.github.com/users/crowbar/gists{/gist_id}","starred_url":"https://api.github.com/users/crowbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crowbar/subscriptions","organizations_url":"https://api.github.com/users/crowbar/orgs","repos_url":"https://api.github.com/users/crowbar/repos","events_url":"https://api.github.com/users/crowbar/events{/privacy}","received_events_url":"https://api.github.com/users/crowbar/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crowbar/barclamp-crowbar","description":"Crowbar Core: Core application","fork":false,"url":"https://api.github.com/repos/crowbar/barclamp-crowbar","forks_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/forks","keys_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/teams","hooks_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/hooks","issue_events_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/issues/events{/number}","events_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/events","assignees_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/assignees{/user}","branches_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/branches{/branch}","tags_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/tags","blobs_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/git/refs{/sha}","trees_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/statuses/{sha}","languages_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/languages","stargazers_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/stargazers","contributors_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/contributors","subscribers_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/subscribers","subscription_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/subscription","commits_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/commits{/sha}","git_commits_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/git/commits{/sha}","comments_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/comments{/number}","issue_comment_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/issues/comments/{number}","contents_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/contents/{+path}","compare_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/merges","archive_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/downloads","issues_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/issues{/number}","pulls_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls{/number}","milestones_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/milestones{/number}","notifications_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/labels{/name}","releases_url":"https://api.github.com/repos/crowbar/barclamp-crowbar/releases{/id}","created_at":"2011-09-08T20:47:56Z","updated_at":"2014-06-06T20:03:19Z","pushed_at":"2014-06-06T20:03:19Z","git_url":"git://github.com/crowbar/barclamp-crowbar.git","ssh_url":"git@github.com:crowbar/barclamp-crowbar.git","clone_url":"https://github.com/crowbar/barclamp-crowbar.git","svn_url":"https://github.com/crowbar/barclamp-crowbar","homepage":"https://github.com/crowbar/crowbar","size":50039,"stargazers_count":72,"watchers_count":72,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":198,"mirror_url":null,"open_issues_count":11,"forks":198,"open_issues":11,"watchers":72,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/1054"},"html":{"href":"https://github.com/crowbar/barclamp-crowbar/pull/1054"},"issue":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/issues/1054"},"comments":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/issues/1054/comments"},"review_comments":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/1054/comments"},"review_comment":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/pulls/1054/commits"},"statuses":{"href":"https://api.github.com/repos/crowbar/barclamp-crowbar/statuses/ee281a0868532ba63e3b1c0388d5b055c680af80"}}}}