Module: Ghstars
- Defined in:
- lib/ghstars.rb,
lib/ghstars/cli.rb,
lib/ghstars/version.rb
Defined Under Namespace
Classes: CLI, Error, GitHubAccessTokenError, GitHubBadCredentialsError, InvalidOwnerError
Constant Summary
collapse
- VERSION =
"0.1.6"
- @@client =
nil
Class Method Summary
collapse
Class Method Details
.check_github_credentials ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/ghstars.rb', line 16
def self.check_github_credentials
begin
@@client.user
rescue Octokit::Unauthorized => error_message
puts error_message
raise ::Ghstars::GitHubBadCredentialsError, "Bad GitHub credentials."
end
end
|
.check_github_token_defined ⇒ Object
12
13
14
|
# File 'lib/ghstars.rb', line 12
def self.check_github_token_defined
raise ::Ghstars::GitHubAccessTokenError, "Please define GITHUB_TOKEN environment variable." unless ENV['GITHUB_TOKEN']
end
|
.get_repos(options) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/ghstars.rb', line 45
def self.get_repos(options)
if ::Ghstars.github_access_available?
query = options[:query]
repos = @@client.repos({}, query: query)
.reject{|r| r[:stargazers_count] == 0}
.reject{|r| r[:fork]}
.sort_by{|r| r[:stargazers_count]}
.reverse
repos
end
end
|
.github_access_available? ⇒ Boolean