Class: Sredder::GithubAuth
- Inherits:
-
Object
- Object
- Sredder::GithubAuth
- Extended by:
- Forwardable
- Defined in:
- lib/sredder/github_auth.rb
Instance Attribute Summary collapse
-
#consumer ⇒ Object
writeonly
Sets the attribute consumer.
-
#sredderc ⇒ Object
Returns the value of attribute sredderc.
Instance Method Summary collapse
- #authorized? ⇒ Boolean
-
#initialize(sredderc = Sredderc.new) ⇒ GithubAuth
constructor
A new instance of GithubAuth.
- #run_oauth_procedure ⇒ Object
- #token ⇒ Object
Constructor Details
#initialize(sredderc = Sredderc.new) ⇒ GithubAuth
Returns a new instance of GithubAuth.
16 17 18 19 |
# File 'lib/sredder/github_auth.rb', line 16 def initialize(sredderc = Sredderc.new) @sredderc = sredderc @sredderc.load end |
Instance Attribute Details
#consumer=(value) ⇒ Object (writeonly)
Sets the attribute consumer
12 13 14 |
# File 'lib/sredder/github_auth.rb', line 12 def consumer=(value) @consumer = value end |
#sredderc ⇒ Object
Returns the value of attribute sredderc.
11 12 13 |
# File 'lib/sredder/github_auth.rb', line 11 def sredderc @sredderc end |
Instance Method Details
#authorized? ⇒ Boolean
28 29 30 |
# File 'lib/sredder/github_auth.rb', line 28 def !!credentials[:github_token] end |
#run_oauth_procedure ⇒ Object
21 22 23 24 25 26 |
# File 'lib/sredder/github_auth.rb', line 21 def run_oauth_procedure print "Please enter your github username: " username = $stdin.gets.strip val = `curl -u '#{username}' -d '{"scopes":["repo"],"client_id":"#{client_id}","client_secret":"#{client_secret}"}' https://api.github.com/authorizations` store_tokens(JSON.parse(val)["token"]) end |
#token ⇒ Object
32 33 34 |
# File 'lib/sredder/github_auth.rb', line 32 def token credentials[:github_token] end |