Class: Capistrano::Github::API
- Inherits:
-
Object
- Object
- Capistrano::Github::API
- Defined in:
- lib/capistrano/github/api.rb
Defined Under Namespace
Classes: Deployment
Constant Summary collapse
- REPO_FORMAT =
/[email protected]:([\S]*)\/([\S]*).git/
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #create_deployment(branch, options = {}) ⇒ Object
- #create_deployment_status(id, state) ⇒ Object
- #deployments(options = {}) ⇒ Object
-
#initialize(repo_url, token) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(repo_url, token) ⇒ API
Returns a new instance of API.
18 19 20 21 22 |
# File 'lib/capistrano/github/api.rb', line 18 def initialize(repo_url, token) raise MissingAccessToken unless token @client = Octokit::Client.new(access_token: token) @repo = parse_repo_url(repo_url) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
16 17 18 |
# File 'lib/capistrano/github/api.rb', line 16 def client @client end |
Instance Method Details
#create_deployment(branch, options = {}) ⇒ Object
24 25 26 |
# File 'lib/capistrano/github/api.rb', line 24 def create_deployment(branch, = {}) @client.create_deployment(@repo, branch, ).id end |
#create_deployment_status(id, state) ⇒ Object
28 29 30 |
# File 'lib/capistrano/github/api.rb', line 28 def create_deployment_status(id, state) @client.create_deployment_status(deployment_url(id), state) end |
#deployments(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/capistrano/github/api.rb', line 32 def deployments( = {}) @client.deployments(@repo, ).map do |d| Deployment.new.tap do |dep| dep.created_at = d.created_at dep.sha = d.sha dep.ref = d.ref dep.creator_login = d.creator.login dep.payload = d.payload dep.id = d.id dep.environment = d.environment dep.statuses = deployment_statuses(d.id) end end end |