Class: GerminateGist::GistPublisher
- Inherits:
-
Germinate::Publisher
- Object
- Germinate::Publisher
- GerminateGist::GistPublisher
- Defined in:
- lib/germinate-gist/gist_publisher.rb
Constant Summary collapse
- GISTS_URL =
'http://gist.github.com/gists'
- NEW_GIST_URL =
'http://gist.github.com/api/v1/xml/new'
- EXISTING_GIST_URL =
'http://gist.github.com/api/v1/xml/'
- PUBLIC_GIST_URL =
'http://gist.github.com/'
Instance Method Summary collapse
- #github_login ⇒ Object
- #github_token ⇒ Object
-
#initialize(name, librarian, options = {}) ⇒ GistPublisher
constructor
A new instance of GistPublisher.
- #publish!(output, extra_options = {}) ⇒ Object
Constructor Details
#initialize(name, librarian, options = {}) ⇒ GistPublisher
Returns a new instance of GistPublisher.
14 15 16 17 18 19 |
# File 'lib/germinate-gist/gist_publisher.rb', line 14 def initialize(name, librarian, ={}) @resource_class = .delete(:resource_class) { RestClient::Resource } super @git = Git.init self.selector = "$SOURCE" end |
Instance Method Details
#github_login ⇒ Object
34 35 36 |
# File 'lib/germinate-gist/gist_publisher.rb', line 34 def github_login @git.config('github.user') or raise GerminateGist::GithubConfigError end |
#github_token ⇒ Object
38 39 40 |
# File 'lib/germinate-gist/gist_publisher.rb', line 38 def github_token @git.config('github.token') or raise GerminateGist::GithubConfigError end |
#publish!(output, extra_options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/germinate-gist/gist_publisher.rb', line 21 def publish!(output, ={}) if librarian.variables.key?('GIST_ID') put_gist!(librarian.variables['GIST_ID']) else post_gist! end rescue RestClient::ExceptionWithResponse => error log.error "Error posting to gist: #{error.}" log.debug "Response from Gist: #{error.response.}\n#{error.response.body}" raise UserError, error. end |