lib/iblinter/plugin.rb in danger-iblinter-0.0.1 vs lib/iblinter/plugin.rb in danger-iblinter-0.0.2

- old
+ new

@@ -12,20 +12,20 @@ # iblinter.lint # # @see IBDecodable/IBLinter # @tags swift # - class DangerIBLinter < Plugin + class DangerIblinter < Plugin # The path to IBLinter"s execution # @return [void] attr_accessor :binary_path # Lints IB files. Will fail if `iblinter` cannot be installed correctly. # @return [void] # def lint(path = Dir.pwd, fail_on_warning: false, inline_mode: true, options: {}) - raise "iblinter is not installed" unless File.exist? @binary_path + raise "iblinter is not installed" unless iblinter_installed? issues = iblinter.lint(path, options) return if issues.empty? errors = issues.select { |v| v["level"] == "error" } @@ -47,15 +47,23 @@ fail "Failed due to IBLinter warnings" end end # Instantiate iblinter - # @return [IBLinter] + # @return [IBLinterRunner] def iblinter - IBLinter.new(@binary_path) + IBLinterRunner.new(@binary_path) end private + + def iblinter_installed? + if !@binary_path.nil? && File.exist?(@binary_path) + return true + end + + !`which iblinter`.empty? + end def markdown_issues(results, heading, emoji) message = "#### #{heading}\n\n" message << "| | File | Hint |\n"