Class: Readiness::GitLab::Markdown

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/gitlab/markdown.rb

Overview

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

Author:

  • Jason Colyer

Since:

  • 1.0.12

Class Method Summary collapse

Methods inherited from Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Class Method Details

.convert(client, text, gfm = false, project = 'gitlab-org/gitlab') ⇒ String

Renders text using Markdown

Examples:

require 'support_readiness'
config = Readiness::GitLab::Configuration.new
config.token = ENV.fetch('GL_TOKEN')
client = Readiness::GitLab::Client.new(config)
pp Readiness::GitLab::Markdown.convert(client, 'This is a test')
# => "<p data-sourcepos=\"1:1-1:14\">This is a test</p>"

Parameters:

  • client (Object)

    An instance of Client

  • text (String)

    The text to render

  • gfm (Boolean) (defaults to: false)

    If this should render as GitLab Flavored Markdown or not

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

    The project slug to use as a template

Returns:

  • (String)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



31
32
33
34
# File 'lib/support_readiness/gitlab/markdown.rb', line 31

def self.convert(client, text, gfm = false, project = 'gitlab-org/gitlab')
  response = client.connection.post 'markdown', { text: text, gfm: gfm, project: project }.to_json
  Oj.load(response.body)['html']
end