class RubocopChallenger::Github::PrTemplate
To generate Pull Request template as markdown
Constants
- FOOTER_TEXT
Attributes
rule[R]
template[R]
Public Class Methods
new(rule, template_path = nil)
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 9 def initialize(rule, template_path = nil) template_path ||= default_template_path @template = File.read(template_path) @rule = rule end
Public Instance Methods
generate()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 15 def generate <<~TEMPLATE #{ERB.new(template, nil, '-').result(binding)} #{FOOTER_TEXT} TEMPLATE rescue StandardError => e error_template = File.read(error_template_path) <<~TEMPLATE #{ERB.new(error_template, nil, '-').result(binding)} #{FOOTER_TEXT} TEMPLATE end
Private Instance Methods
default_template_path()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 32 def default_template_path File.expand_path('../../templates/default.md.erb', __dir__) end
description()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 48 def description yardoc.description end
error_template_path()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 36 def error_template_path File.expand_path('../../templates/error.md.erb', __dir__) end
examples()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 52 def examples yardoc.examples end
rubydoc_url()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 44 def rubydoc_url rule.rubydoc_url end
safe_autocorrect?()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 56 def safe_autocorrect? yardoc.safe_autocorrect? end
title()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 40 def title rule.title end
yardoc()
click to toggle source
# File lib/rubocop_challenger/github/pr_template.rb, line 60 def yardoc @yardoc ||= Rubocop::Yardoc.new(title) end