Module: GitlabToDoap::Utilities

Included in:
GitlabToDoap
Defined in:
lib/gitlab-to-doap/utilities.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gitlab_api_tokenObject (readonly)

Returns the value of attribute gitlab_api_token.



11
12
13
# File 'lib/gitlab-to-doap/utilities.rb', line 11

def gitlab_api_token
  @gitlab_api_token
end

#gitlab_endpointObject (readonly)

Returns the value of attribute gitlab_endpoint.



10
11
12
# File 'lib/gitlab-to-doap/utilities.rb', line 10

def gitlab_endpoint
  @gitlab_endpoint
end

Instance Method Details

#gitlabObject

Build a Gitlab API client, if one does not exist already



20
21
22
23
24
25
# File 'lib/gitlab-to-doap/utilities.rb', line 20

def gitlab
  @gitlab ||= Gitlab.client(
    endpoint: @gitlab_endpoint,
    private_token: @gitlab_api_token
  )
end

#gitlab_project(project_id) ⇒ Object



27
28
29
# File 'lib/gitlab-to-doap/utilities.rb', line 27

def gitlab_project(project_id)
  gitlab.get("/projects/#{gitlab.url_encode project_id}?license=true&statistics=true")
end

#strip_markdown(text) ⇒ Object

Given some markdown formatted plain text, remove all of the formatting



14
15
16
17
# File 'lib/gitlab-to-doap/utilities.rb', line 14

def strip_markdown(text)
  markdown = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
  markdown.render(text).strip
end