Module: Travis::Client::Methods

Included in:
Travis::CLI::ApiCommand, Namespace, Session
Defined in:
lib/travis/client/methods.rb

Instance Method Summary collapse

Instance Method Details

#access_tokenObject



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



60
61
62
# File 'lib/travis/client/methods.rb', line 60

def (name)
  session.find_one(Account, name)
end

#accountsObject



64
65
66
# File 'lib/travis/client/methods.rb', line 64

def accounts
  session.find_many(Account, :all => true)
end

#api_endpointObject



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



48
49
50
# File 'lib/travis/client/methods.rb', line 48

def artifact(id)
  session.find_one(Artifact, id)
end

#broadcastsObject



68
69
70
# File 'lib/travis/client/methods.rb', line 68

def broadcasts
  session.find_many(Broadcast)
end

#build(id) ⇒ Object



40
41
42
# File 'lib/travis/client/methods.rb', line 40

def build(id)
  session.find_one(Build, id)
end

#cancel(entity) ⇒ Object

Raises:



80
81
82
83
84
# File 'lib/travis/client/methods.rb', line 80

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

Returns:

  • (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

#hooksObject



92
93
94
# File 'lib/travis/client/methods.rb', line 92

def hooks
  session.get('hooks')['hooks']
end

#job(id) ⇒ Object



44
45
46
# File 'lib/travis/client/methods.rb', line 44

def job(id)
  session.find_one(Job, id)
end

#listen(*entities, &block) ⇒ Object



86
87
88
89
90
# File 'lib/travis/client/methods.rb', line 86

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

Raises:



72
73
74
75
76
77
78
# File 'lib/travis/client/methods.rb', line 72

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

#userObject



54
55
56
57
58
# File 'lib/travis/client/methods.rb', line 54

def user
  session.find_one(User)
rescue NotFound
  raise NotLoggedIn, 'currently not logged in'
end