Class: SupportOps::GitLab::Markdown

Inherits:
Base
  • Object
show all
Defined in:
lib/support_ops_gitlab/gitlab/markdown.rb

Overview

Defines the class Markdown within the module SupportOps::GitLab.

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #delete!, #diffs, #disable_2fa!, #discussions, #emails, #encoded_path, #events, #find, #find!, #gpg_keys, #hard_delete!, #impersonations, #initialize, #issues, #jobs, #latest_pipeline, #members, #memberships, #merge_requests, #move!, #notes, #paid?, #pats, #pipeline_variables, #pipelines, #preferences, #projects, readonly_attributes, #reject!, #revoke!, #rotate!, #save!, #ssh_keys, #status, #store_original_attributes, #subscribe!, #support_pin, to_hash, #tokens, #unban!, #unblock!, #unsubscribe!, #webhooks

Constructor Details

This class inherits a constructor from SupportOps::GitLab::Base

Instance Attribute Details

#allowed_email_domains_listArray

Comma-separated list of email address domains to allow group access

Returns:

  • (Array)

    the current value of allowed_email_domains_list



13
14
15
# File 'lib/support_ops_gitlab/gitlab/markdown.rb', line 13

def allowed_email_domains_list
  @allowed_email_domains_list
end

Class Method Details

.render(text, gfm = false, project = 'gitlab-org/gitlab') ⇒ Object

Renders text using Markdown

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.url = 'https://gitlab.com/api/v4'
  config.token = 'abc123'
end

markdown = SupportOps::GitLab::Markdown.convert('This is a test')
pp markdown.html
# => "<p data-sourcepos=\"1:1-1:14\">This is a test</p>"

Parameters:

  • text (String)

    The text to render

  • gfm (Boolean optional) (defaults to: false)

    If this should render as GitLab Flavored Markdown or not (defaults to false)

  • project (String optiona) (defaults to: 'gitlab-org/gitlab')

    The project slug to use as a template (defaults to gitlab-org/gitlab)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/support_ops_gitlab/gitlab/markdown.rb', line 39

def self.render(text, gfm = false, project = 'gitlab-org/gitlab')
  data = {
    text: text,
    gfm: gfm,
    project: project
  }.to_json
  response = client.connection.post('markdown', data)
  body = Oj.load(response.body)
  raise "Unable to render markdown => #{body}" unless response.status == 201
  Markdown.new(body)
end