class Danger::DangerPronto
Lints files via Pronto
through specified runners Results are displayed as a table in markdown
[Runners](github.com/mmozuras/pronto#runners)
@example Lint files with Pronto
and specified Pronto
Runners
pronto.lint
@see RestlessThinker/danger-pronto @tags pronto, linter
Public Instance Methods
lint(commit = nil)
click to toggle source
Runs files through Pronto
. Generates a `markdown` list of warnings.
# File lib/danger_pronto/plugin.rb, line 17 def lint(commit = nil) files = pronto(commit) return if files.empty? markdown offenses_message(files) end
Private Instance Methods
offenses_message(offending_files)
click to toggle source
Builds the message
# File lib/danger_pronto/plugin.rb, line 37 def offenses_message(offending_files) require 'terminal-table' message = "### Pronto violations\n\n" table = Terminal::Table.new( headings: %w(File Line Reason Runner), style: { border_i: '|' }, rows: offending_files.map do |file| [file['path'], file['line'], file['message'], file['runner']] end ).to_s message + table.split("\n")[1..-2].join("\n") end
pronto(specified_commit = nil)
click to toggle source
Executes pronto command @param commit [String] hash/branch/tag @return [Hash] Converted hash from pronto json output
# File lib/danger_pronto/plugin.rb, line 29 def pronto(specified_commit = nil) commit = "origin/master" commit = specified_commit if !specified_commit.nil? pronto_output = `#{'bundle exec ' if File.exists?('Gemfile')}pronto run -f json -c #{commit}` JSON.parse(pronto_output) end