Module: Octopi
- Included in:
- KeySet, BranchSet, IssueSet, RepositorySet
- Defined in:
- lib/octopi.rb,
lib/octopi/api.rb,
lib/octopi/key.rb,
lib/octopi/tag.rb,
lib/octopi/base.rb,
lib/octopi/blob.rb,
lib/octopi/gist.rb,
lib/octopi/plan.rb,
lib/octopi/self.rb,
lib/octopi/user.rb,
lib/octopi/error.rb,
lib/octopi/issue.rb,
lib/octopi/branch.rb,
lib/octopi/commit.rb,
lib/octopi/comment.rb,
lib/octopi/resource.rb,
lib/octopi/repository.rb,
lib/octopi/file_object.rb,
lib/octopi/issue_comment.rb
Overview
Include this into your app so you can access the child classes easier. This is the root of all things Octopi.
Defined Under Namespace
Modules: Resource, Self Classes: APIError, AnonymousApi, Api, ArgumentMustBeHash, AuthApi, AuthenticationRequired, Base, Blob, Branch, BranchSet, Comment, Commit, FileObject, FormatError, Gist, InvalidLogin, Issue, IssueComment, IssueSet, Key, NotFound, Plan, Repository, RepositorySet, RetryableAPIError, Tag, User
Instance Method Summary collapse
-
#authenticated(options = {}, &block) ⇒ Object
The authenticated methods are all very similar.
- #authenticated_with(options, &block) ⇒ Object
Instance Method Details
#authenticated(options = {}, &block) ⇒ Object
The authenticated methods are all very similar. TODO: Find a way to merge them into something… better.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/octopi.rb', line 23 def authenticated(={}, &block) begin config = config = File.open([:config]) { |yf| YAML::load(yf) } if [:config] config = read_gitconfig [:login] = config["github"]["user"] [:token] = config["github"]["token"] authenticated_with() do yield end ensure # Reset authenticated so if we were to do an anonymous call it would Just Work(tm) Api.authenticated = false Api.api = AnonymousApi.instance end end |
#authenticated_with(options, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/octopi.rb', line 40 def authenticated_with(, &block) begin Api.api.trace_level = [:trace] if [:trace] raise "This version of octopi requires a token be set" if [:token].nil? begin User.find([:login]) # If the user cannot see themselves then they are not logged in, tell them so rescue Octopi::NotFound raise Octopi::InvalidLogin end trace("=> Trace on: #{[:trace]}") Api.api = AuthApi.instance Api.api.login = [:login] Api.api.token = [:token] yield ensure # Reset authenticated so if we were to do an anonymous call it would Just Work(tm) Api.authenticated = false Api.api = AnonymousApi.instance end end |