Module: Nachos::Github
- Included in:
- Main
- Defined in:
- lib/nachos/github.rb
Constant Summary collapse
- LGHCONF =
"http://github.com/guides/local-github-config"
- GIT_CONFIG =
Hash.new do |cache, cmd| result = %x{git #{cmd}}.chomp cache[cmd] = $?.success? && !result.empty? ? result : nil end
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #github_summary ⇒ Object
- #github_token(fatal = true) ⇒ Object
-
#github_user(fatal = true) ⇒ Object
Either returns the GitHub user as set by git-config(1) or aborts with an error message.
- #watched ⇒ Object
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/nachos/github.rb', line 10 def client @client end |
Instance Method Details
#github_summary ⇒ Object
36 37 38 |
# File 'lib/nachos/github.rb', line 36 def github_summary "You have #{watched.size} watched repos, and #{client.list_repos.size} owned repos." end |
#github_token(fatal = true) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/nachos/github.rb', line 28 def github_token(fatal = true) if token = GIT_CONFIG['config github.token'] token elsif fatal abort("** No GitHub token set. See #{LGHCONF}") end end |
#github_user(fatal = true) ⇒ Object
Either returns the GitHub user as set by git-config(1) or aborts with an error message.
20 21 22 23 24 25 26 |
# File 'lib/nachos/github.rb', line 20 def github_user(fatal = true) if user = GIT_CONFIG['config github.user'] user elsif fatal abort("** No GitHub user set. See #{LGHCONF}") end end |
#watched ⇒ Object
12 13 14 15 16 |
# File 'lib/nachos/github.rb', line 12 def watched client.watched.sort_by do |repo| [repo["owner"], repo["name"]].join("/") end end |