{"action":"created","comment":{"url":"https://api.github.com/repos/benbalter/licensee/pulls/comments/158838233","pull_request_review_id":85698228,"id":158838233,"diff_hunk":"@@ -0,0 +1,43 @@\n+# Github project\n+#\n+# Analyses a remote Github repository for license information\n+#\n+# Only the root folder of a repository will be scanned for performance reasons!\n+\n+require 'octokit'\n+\n+module Licensee\n+  module Projects\n+    class GithubProject < Licensee::Projects::Project\n+      # If there's any trailing data (e.g. `.git`) this pattern will ignore it:\n+      # we're going to use the API rather than clone the repo.\n+      GITHUB_REPO_PATTERN = %r{https://github.com/([^\\/]+\\/[^\\/\\.]+).*}\n+\n+      def initialize(github_url, **args)\n+        @repo_name = github_url[GITHUB_REPO_PATTERN, 1]\n+        raise ArgumentError, \"Not a github URL: #{github_url}\" unless @repo_name\n+        super(**args)\n+      end\n+\n+      private\n+\n+      def files\n+        @files ||= fetch_files.map do |data|\n+          {\n+            name:         data[:name],\n+            contents_url: data[:download_url],\n+            dir:          '/'\n+          }\n+        end\n+      end\n+\n+      def load_file(file)\n+        Octokit.get URI(file[:contents_url])","path":"lib/licensee/projects/github_project.rb","position":35,"original_position":35,"commit_id":"750c1d1b4ae741222a813076caf1b5fa99ae7138","original_commit_id":"750c1d1b4ae741222a813076caf1b5fa99ae7138","user":{"login":"benbalter","id":282759,"avatar_url":"https://avatars3.githubusercontent.com/u/282759?v=4","gravatar_id":"","url":"https://api.github.com/users/benbalter","html_url":"https://github.com/benbalter","followers_url":"https://api.github.com/users/benbalter/followers","following_url":"https://api.github.com/users/benbalter/following{/other_user}","gists_url":"https://api.github.com/users/benbalter/gists{/gist_id}","starred_url":"https://api.github.com/users/benbalter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbalter/subscriptions","organizations_url":"https://api.github.com/users/benbalter/orgs","repos_url":"https://api.github.com/users/benbalter/repos","events_url":"https://api.github.com/users/benbalter/events{/privacy}","received_events_url":"https://api.github.com/users/benbalter/received_events","type":"User","site_admin":true},"body":"I believe we can use `Octokit.contents @repo_name, path: file[:name]` here to rely on Octokit internals a bit more (and save us from needing to store the `contents_url` in the hash).","created_at":"2017-12-27T16:31:51Z","updated_at":"2017-12-27T16:36:44Z","html_url":"https://github.com/benbalter/licensee/pull/251#discussion_r158838233","pull_request_url":"https://api.github.com/repos/benbalter/licensee/pulls/251","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/benbalter/licensee/pulls/comments/158838233"},"html":{"href":"https://github.com/benbalter/licensee/pull/251#discussion_r158838233"},"pull_request":{"href":"https://api.github.com/repos/benbalter/licensee/pulls/251"}}},"pull_request":{"url":"https://api.github.com/repos/benbalter/licensee/pulls/251","id":160002240,"html_url":"https://github.com/benbalter/licensee/pull/251","diff_url":"https://github.com/benbalter/licensee/pull/251.diff","patch_url":"https://github.com/benbalter/licensee/pull/251.patch","issue_url":"https://api.github.com/repos/benbalter/licensee/issues/251","number":251,"state":"open","locked":false,"title":"Add support for scanning Github projects","user":{"login":"nickcampbell18","id":661795,"avatar_url":"https://avatars2.githubusercontent.com/u/661795?v=4","gravatar_id":"","url":"https://api.github.com/users/nickcampbell18","html_url":"https://github.com/nickcampbell18","followers_url":"https://api.github.com/users/nickcampbell18/followers","following_url":"https://api.github.com/users/nickcampbell18/following{/other_user}","gists_url":"https://api.github.com/users/nickcampbell18/gists{/gist_id}","starred_url":"https://api.github.com/users/nickcampbell18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickcampbell18/subscriptions","organizations_url":"https://api.github.com/users/nickcampbell18/orgs","repos_url":"https://api.github.com/users/nickcampbell18/repos","events_url":"https://api.github.com/users/nickcampbell18/events{/privacy}","received_events_url":"https://api.github.com/users/nickcampbell18/received_events","type":"User","site_admin":false},"body":"I had a requirement to scan remote Github projects to try and find their license.\r\n\r\nSo I took inspiration from the filesystem implementation (`Licensee::Projects::FSProject`) and built one which uses the Github API to resolve each of the files just in the root directory.\r\n\r\nIs this something you might be interesting in having in the main library? If so, I can add some tests, error handling and probably a better HTTP adapter that can make requests in parallel. It would definitely be worth considering what the public interface would look like (I'm currently just using this gem from within another Ruby application, not sure if/how the CLI would change).","created_at":"2017-12-24T14:58:54Z","updated_at":"2017-12-27T16:36:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"291b2521be4c7b8b4f0f03915f65174e792c7aed","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/benbalter/licensee/pulls/251/commits","review_comments_url":"https://api.github.com/repos/benbalter/licensee/pulls/251/comments","review_comment_url":"https://api.github.com/repos/benbalter/licensee/pulls/comments{/number}","comments_url":"https://api.github.com/repos/benbalter/licensee/issues/251/comments","statuses_url":"https://api.github.com/repos/benbalter/licensee/statuses/750c1d1b4ae741222a813076caf1b5fa99ae7138","head":{"label":"nickcampbell18:master","ref":"master","sha":"750c1d1b4ae741222a813076caf1b5fa99ae7138","user":{"login":"nickcampbell18","id":661795,"avatar_url":"https://avatars2.githubusercontent.com/u/661795?v=4","gravatar_id":"","url":"https://api.github.com/users/nickcampbell18","html_url":"https://github.com/nickcampbell18","followers_url":"https://api.github.com/users/nickcampbell18/followers","following_url":"https://api.github.com/users/nickcampbell18/following{/other_user}","gists_url":"https://api.github.com/users/nickcampbell18/gists{/gist_id}","starred_url":"https://api.github.com/users/nickcampbell18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickcampbell18/subscriptions","organizations_url":"https://api.github.com/users/nickcampbell18/orgs","repos_url":"https://api.github.com/users/nickcampbell18/repos","events_url":"https://api.github.com/users/nickcampbell18/events{/privacy}","received_events_url":"https://api.github.com/users/nickcampbell18/received_events","type":"User","site_admin":false},"repo":{"id":115266080,"name":"licensee","full_name":"nickcampbell18/licensee","owner":{"login":"nickcampbell18","id":661795,"avatar_url":"https://avatars2.githubusercontent.com/u/661795?v=4","gravatar_id":"","url":"https://api.github.com/users/nickcampbell18","html_url":"https://github.com/nickcampbell18","followers_url":"https://api.github.com/users/nickcampbell18/followers","following_url":"https://api.github.com/users/nickcampbell18/following{/other_user}","gists_url":"https://api.github.com/users/nickcampbell18/gists{/gist_id}","starred_url":"https://api.github.com/users/nickcampbell18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickcampbell18/subscriptions","organizations_url":"https://api.github.com/users/nickcampbell18/orgs","repos_url":"https://api.github.com/users/nickcampbell18/repos","events_url":"https://api.github.com/users/nickcampbell18/events{/privacy}","received_events_url":"https://api.github.com/users/nickcampbell18/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nickcampbell18/licensee","description":"A Ruby Gem to detect under what license a project is distributed.","fork":true,"url":"https://api.github.com/repos/nickcampbell18/licensee","forks_url":"https://api.github.com/repos/nickcampbell18/licensee/forks","keys_url":"https://api.github.com/repos/nickcampbell18/licensee/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nickcampbell18/licensee/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nickcampbell18/licensee/teams","hooks_url":"https://api.github.com/repos/nickcampbell18/licensee/hooks","issue_events_url":"https://api.github.com/repos/nickcampbell18/licensee/issues/events{/number}","events_url":"https://api.github.com/repos/nickcampbell18/licensee/events","assignees_url":"https://api.github.com/repos/nickcampbell18/licensee/assignees{/user}","branches_url":"https://api.github.com/repos/nickcampbell18/licensee/branches{/branch}","tags_url":"https://api.github.com/repos/nickcampbell18/licensee/tags","blobs_url":"https://api.github.com/repos/nickcampbell18/licensee/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nickcampbell18/licensee/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nickcampbell18/licensee/git/refs{/sha}","trees_url":"https://api.github.com/repos/nickcampbell18/licensee/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nickcampbell18/licensee/statuses/{sha}","languages_url":"https://api.github.com/repos/nickcampbell18/licensee/languages","stargazers_url":"https://api.github.com/repos/nickcampbell18/licensee/stargazers","contributors_url":"https://api.github.com/repos/nickcampbell18/licensee/contributors","subscribers_url":"https://api.github.com/repos/nickcampbell18/licensee/subscribers","subscription_url":"https://api.github.com/repos/nickcampbell18/licensee/subscription","commits_url":"https://api.github.com/repos/nickcampbell18/licensee/commits{/sha}","git_commits_url":"https://api.github.com/repos/nickcampbell18/licensee/git/commits{/sha}","comments_url":"https://api.github.com/repos/nickcampbell18/licensee/comments{/number}","issue_comment_url":"https://api.github.com/repos/nickcampbell18/licensee/issues/comments{/number}","contents_url":"https://api.github.com/repos/nickcampbell18/licensee/contents/{+path}","compare_url":"https://api.github.com/repos/nickcampbell18/licensee/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nickcampbell18/licensee/merges","archive_url":"https://api.github.com/repos/nickcampbell18/licensee/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nickcampbell18/licensee/downloads","issues_url":"https://api.github.com/repos/nickcampbell18/licensee/issues{/number}","pulls_url":"https://api.github.com/repos/nickcampbell18/licensee/pulls{/number}","milestones_url":"https://api.github.com/repos/nickcampbell18/licensee/milestones{/number}","notifications_url":"https://api.github.com/repos/nickcampbell18/licensee/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nickcampbell18/licensee/labels{/name}","releases_url":"https://api.github.com/repos/nickcampbell18/licensee/releases{/id}","deployments_url":"https://api.github.com/repos/nickcampbell18/licensee/deployments","created_at":"2017-12-24T13:54:14Z","updated_at":"2017-12-24T13:54:17Z","pushed_at":"2017-12-27T14:24:32Z","git_url":"git://github.com/nickcampbell18/licensee.git","ssh_url":"git@github.com:nickcampbell18/licensee.git","clone_url":"https://github.com/nickcampbell18/licensee.git","svn_url":"https://github.com/nickcampbell18/licensee","homepage":"http://ben.balter.com/licensee/","size":1006,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"benbalter:master","ref":"master","sha":"69a67f055b4085eed5290dbedfab231472199eed","user":{"login":"benbalter","id":282759,"avatar_url":"https://avatars3.githubusercontent.com/u/282759?v=4","gravatar_id":"","url":"https://api.github.com/users/benbalter","html_url":"https://github.com/benbalter","followers_url":"https://api.github.com/users/benbalter/followers","following_url":"https://api.github.com/users/benbalter/following{/other_user}","gists_url":"https://api.github.com/users/benbalter/gists{/gist_id}","starred_url":"https://api.github.com/users/benbalter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbalter/subscriptions","organizations_url":"https://api.github.com/users/benbalter/orgs","repos_url":"https://api.github.com/users/benbalter/repos","events_url":"https://api.github.com/users/benbalter/events{/privacy}","received_events_url":"https://api.github.com/users/benbalter/received_events","type":"User","site_admin":true},"repo":{"id":23022377,"name":"licensee","full_name":"benbalter/licensee","owner":{"login":"benbalter","id":282759,"avatar_url":"https://avatars3.githubusercontent.com/u/282759?v=4","gravatar_id":"","url":"https://api.github.com/users/benbalter","html_url":"https://github.com/benbalter","followers_url":"https://api.github.com/users/benbalter/followers","following_url":"https://api.github.com/users/benbalter/following{/other_user}","gists_url":"https://api.github.com/users/benbalter/gists{/gist_id}","starred_url":"https://api.github.com/users/benbalter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbalter/subscriptions","organizations_url":"https://api.github.com/users/benbalter/orgs","repos_url":"https://api.github.com/users/benbalter/repos","events_url":"https://api.github.com/users/benbalter/events{/privacy}","received_events_url":"https://api.github.com/users/benbalter/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/benbalter/licensee","description":"A Ruby Gem to detect under what license a project is distributed.","fork":false,"url":"https://api.github.com/repos/benbalter/licensee","forks_url":"https://api.github.com/repos/benbalter/licensee/forks","keys_url":"https://api.github.com/repos/benbalter/licensee/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benbalter/licensee/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benbalter/licensee/teams","hooks_url":"https://api.github.com/repos/benbalter/licensee/hooks","issue_events_url":"https://api.github.com/repos/benbalter/licensee/issues/events{/number}","events_url":"https://api.github.com/repos/benbalter/licensee/events","assignees_url":"https://api.github.com/repos/benbalter/licensee/assignees{/user}","branches_url":"https://api.github.com/repos/benbalter/licensee/branches{/branch}","tags_url":"https://api.github.com/repos/benbalter/licensee/tags","blobs_url":"https://api.github.com/repos/benbalter/licensee/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benbalter/licensee/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benbalter/licensee/git/refs{/sha}","trees_url":"https://api.github.com/repos/benbalter/licensee/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benbalter/licensee/statuses/{sha}","languages_url":"https://api.github.com/repos/benbalter/licensee/languages","stargazers_url":"https://api.github.com/repos/benbalter/licensee/stargazers","contributors_url":"https://api.github.com/repos/benbalter/licensee/contributors","subscribers_url":"https://api.github.com/repos/benbalter/licensee/subscribers","subscription_url":"https://api.github.com/repos/benbalter/licensee/subscription","commits_url":"https://api.github.com/repos/benbalter/licensee/commits{/sha}","git_commits_url":"https://api.github.com/repos/benbalter/licensee/git/commits{/sha}","comments_url":"https://api.github.com/repos/benbalter/licensee/comments{/number}","issue_comment_url":"https://api.github.com/repos/benbalter/licensee/issues/comments{/number}","contents_url":"https://api.github.com/repos/benbalter/licensee/contents/{+path}","compare_url":"https://api.github.com/repos/benbalter/licensee/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benbalter/licensee/merges","archive_url":"https://api.github.com/repos/benbalter/licensee/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benbalter/licensee/downloads","issues_url":"https://api.github.com/repos/benbalter/licensee/issues{/number}","pulls_url":"https://api.github.com/repos/benbalter/licensee/pulls{/number}","milestones_url":"https://api.github.com/repos/benbalter/licensee/milestones{/number}","notifications_url":"https://api.github.com/repos/benbalter/licensee/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benbalter/licensee/labels{/name}","releases_url":"https://api.github.com/repos/benbalter/licensee/releases{/id}","deployments_url":"https://api.github.com/repos/benbalter/licensee/deployments","created_at":"2014-08-16T16:39:56Z","updated_at":"2017-12-25T19:48:29Z","pushed_at":"2017-12-27T14:24:33Z","git_url":"git://github.com/benbalter/licensee.git","ssh_url":"git@github.com:benbalter/licensee.git","clone_url":"https://github.com/benbalter/licensee.git","svn_url":"https://github.com/benbalter/licensee","homepage":"http://ben.balter.com/licensee/","size":1015,"stargazers_count":201,"watchers_count":201,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":69,"mirror_url":null,"archived":false,"open_issues_count":13,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":69,"open_issues":13,"watchers":201,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/benbalter/licensee/pulls/251"},"html":{"href":"https://github.com/benbalter/licensee/pull/251"},"issue":{"href":"https://api.github.com/repos/benbalter/licensee/issues/251"},"comments":{"href":"https://api.github.com/repos/benbalter/licensee/issues/251/comments"},"review_comments":{"href":"https://api.github.com/repos/benbalter/licensee/pulls/251/comments"},"review_comment":{"href":"https://api.github.com/repos/benbalter/licensee/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/benbalter/licensee/pulls/251/commits"},"statuses":{"href":"https://api.github.com/repos/benbalter/licensee/statuses/750c1d1b4ae741222a813076caf1b5fa99ae7138"}},"author_association":"NONE"}}
{"actor":{"display_login":"benbalter"}}