Module: Docks::Helpers::Github

Defined in:
lib/docks/helpers/github_helper.rb

Instance Method Summary collapse

Instance Method Details

#github_issue_messageObject



12
13
14
15
16
17
18
# File 'lib/docks/helpers/github_helper.rb', line 12

def github_issue_message
  root = Docks.config.root.to_s
  files = @pattern.files.map { |file| file.sub(root, "") }

  file_checklist = relative_pattern_files.map { |file| "- [#{@pattern.files.length == 1 ? "x" : " "}] [#{file}](#{github_url(file)})" }.join("\n")
  "\n\n\n---\n\nThis issue is related to the following files:\n\n#{file_checklist}"
end

#github_root_urlObject



24
25
26
# File 'lib/docks/helpers/github_helper.rb', line 24

def github_root_url
  @github_root_url ||= Docks.config.github_repo.sub(/(.)\/?$/, '\1')
end

#github_url(file) ⇒ Object



8
9
10
# File 'lib/docks/helpers/github_helper.rb', line 8

def github_url(file)
  "#{github_root_url}/blob/master/#{url_encode(file).gsub("%2F", "/").sub(/^\//, "")}"
end

#has_github?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/docks/helpers/github_helper.rb', line 4

def has_github?
  !(Docks.config.github_repo.nil? || Docks.config.github_repo.empty? || @pattern.files.empty?)
end

#relative_pattern_filesObject



20
21
22
# File 'lib/docks/helpers/github_helper.rb', line 20

def relative_pattern_files
  @relative_pattern_files ||= @pattern.files.map { |file| file.sub(Docks.config.root.to_s, "") }
end