Module: Travis::Client::Methods
- Included in:
- Travis::CLI::ApiCommand, Namespace, Session
- Defined in:
- lib/travis/client/methods.rb
Instance Method Summary collapse
- #access_token ⇒ Object
- #access_token=(token) ⇒ Object
- #account(name) ⇒ Object
- #accounts ⇒ Object
- #api_endpoint ⇒ Object
- #api_endpoint=(uri) ⇒ Object
- #artifact(id) ⇒ Object (also: #log)
- #broadcasts ⇒ Object
- #build(id) ⇒ Object
- #cancel(entity) ⇒ Object
- #explicit_api_endpoint? ⇒ Boolean
- #github_auth(github_token) ⇒ Object
- #job(id) ⇒ Object
- #listen(*entities, &block) ⇒ Object
- #repo(id_or_slug) ⇒ Object
- #repos(params = {}) ⇒ Object
- #restart(entity) ⇒ Object
- #user ⇒ Object
- #worker(id) ⇒ Object
- #workers(params = {}) ⇒ Object
Instance Method Details
#access_token ⇒ Object
6 7 8 |
# File 'lib/travis/client/methods.rb', line 6 def access_token session.access_token end |
#access_token=(token) ⇒ Object
10 11 12 |
# File 'lib/travis/client/methods.rb', line 10 def access_token=(token) session.access_token = token end |
#account(name) ⇒ Object
68 69 70 |
# File 'lib/travis/client/methods.rb', line 68 def account(name) session.find_one(Account, name) end |
#accounts ⇒ Object
72 73 74 |
# File 'lib/travis/client/methods.rb', line 72 def accounts session.find_many(Account, :all => true) end |
#api_endpoint ⇒ Object
14 15 16 |
# File 'lib/travis/client/methods.rb', line 14 def api_endpoint session.uri end |
#api_endpoint=(uri) ⇒ Object
27 28 29 30 |
# File 'lib/travis/client/methods.rb', line 27 def api_endpoint=(uri) @explicit_api_endpoint = true session.uri = uri end |
#artifact(id) ⇒ Object Also known as: log
56 57 58 |
# File 'lib/travis/client/methods.rb', line 56 def artifact(id) session.find_one(Artifact, id) end |
#broadcasts ⇒ Object
76 77 78 |
# File 'lib/travis/client/methods.rb', line 76 def broadcasts session.find_many(Broadcast) end |
#build(id) ⇒ Object
48 49 50 |
# File 'lib/travis/client/methods.rb', line 48 def build(id) session.find_one(Build, id) end |
#cancel(entity) ⇒ Object
88 89 90 91 92 |
# File 'lib/travis/client/methods.rb', line 88 def cancel(entity) raise Error, "cannot cancel a #{entity.class.one}" unless entity.cancelable? session.post_raw("/#{entity.class.many}/#{entity.id}/cancel") entity.reload end |
#explicit_api_endpoint? ⇒ Boolean
23 24 25 |
# File 'lib/travis/client/methods.rb', line 23 def explicit_api_endpoint? @explicit_api_endpoint ||= false end |
#github_auth(github_token) ⇒ Object
18 19 20 21 |
# File 'lib/travis/client/methods.rb', line 18 def github_auth(github_token) reply = session.post_raw("/auth/github", :github_token => github_token) session.access_token = reply["access_token"] end |
#job(id) ⇒ Object
52 53 54 |
# File 'lib/travis/client/methods.rb', line 52 def job(id) session.find_one(Job, id) end |
#listen(*entities, &block) ⇒ Object
94 95 96 97 98 |
# File 'lib/travis/client/methods.rb', line 94 def listen(*entities, &block) listener = Listener.new(session) listener.subscribe(*entities, &block) listener.listen end |
#repo(id_or_slug) ⇒ Object
36 37 38 |
# File 'lib/travis/client/methods.rb', line 36 def repo(id_or_slug) session.find_one(Repository, id_or_slug) end |
#repos(params = {}) ⇒ Object
32 33 34 |
# File 'lib/travis/client/methods.rb', line 32 def repos(params = {}) session.find_many(Repository, params) end |
#restart(entity) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/travis/client/methods.rb', line 80 def restart(entity) # btw, internally we call this reset, not restart, as it resets the state machine # but we thought that would be too confusing raise Error, "cannot restart a #{entity.class.one}" unless entity.restartable? session.post_raw('/requests', "#{entity.class.one}_id" => entity.id) entity.reload end |
#user ⇒ Object
62 63 64 65 66 |
# File 'lib/travis/client/methods.rb', line 62 def user session.find_one(User) rescue NotFound raise NotLoggedIn, 'currently not logged in' end |
#worker(id) ⇒ Object
40 41 42 |
# File 'lib/travis/client/methods.rb', line 40 def worker(id) session.find_one(Worker, id) end |
#workers(params = {}) ⇒ Object
44 45 46 |
# File 'lib/travis/client/methods.rb', line 44 def workers(params = {}) session.find_many(Worker, params) end |