Class: Gem::Release::Context::Github

Inherits:
Object
  • Object
show all
Includes:
Helper::Http
Defined in:
lib/gem/release/context/github.rb

Constant Summary collapse

URL =
'https://api.github.com/repos/%s/releases'
MSGS =
{
  error: 'GitHub returned %s (body: %p)'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::Http

#post

Constructor Details

#initialize(repo, data) ⇒ Github

Returns a new instance of Github.



19
20
21
22
# File 'lib/gem/release/context/github.rb', line 19

def initialize(repo, data)
  @repo = repo
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



17
18
19
# File 'lib/gem/release/context/github.rb', line 17

def data
  @data
end

#repoObject (readonly)

Returns the value of attribute repo.



17
18
19
# File 'lib/gem/release/context/github.rb', line 17

def repo
  @repo
end

Instance Method Details

#releaseObject

Raises:



24
25
26
27
28
29
30
31
# File 'lib/gem/release/context/github.rb', line 24

def release
  # Create a release
  # https://developer.github.com/v3/repos/releases/#create-a-release
  resp = post(url, body, headers)
  status, body = resp
  # success status code is 201 (created) not 200 (ok)
  raise Abort, MSGS.fetch(:error) % [status, body] unless status == 201
end