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.
15 16 17 18 |
# File 'lib/sredder/github_auth.rb', line 15 def initialize(sredderc = Sredderc.new) @sredderc = sredderc @sredderc.load end |
Instance Attribute Details
#consumer=(value) ⇒ Object (writeonly)
Sets the attribute consumer
11 12 13 |
# File 'lib/sredder/github_auth.rb', line 11 def consumer=(value) @consumer = value end |
#sredderc ⇒ Object
Returns the value of attribute sredderc.
10 11 12 |
# File 'lib/sredder/github_auth.rb', line 10 def sredderc @sredderc end |
Instance Method Details
#authorized? ⇒ Boolean
27 28 29 |
# File 'lib/sredder/github_auth.rb', line 27 def !!credentials[:github_token] end |
#run_oauth_procedure ⇒ Object
20 21 22 23 24 25 |
# File 'lib/sredder/github_auth.rb', line 20 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
31 32 33 |
# File 'lib/sredder/github_auth.rb', line 31 def token credentials[:github_token] end |