Class: Guard::Inch

Inherits:
Plugin
  • Object
show all
Defined in:
lib/guard/inch.rb

Overview

A guard plugin for the Inch documentation lint tool

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Inch

configure a new instance of the plugin

Parameters:

  • options (Hash) (defaults to: {})

    the guard plugin options



11
12
13
14
15
16
# File 'lib/guard/inch.rb', line 11

def initialize(options = {})
  super
  @options = options
  @all_on_start
  @all_type = options[:all_type] || :none
end

Instance Method Details

#run_allObject

Run all of the documentation lints



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/guard/inch.rb', line 28

def run_all
  return unless options[:all_type]
  args = case options[:all_type]
         when :stats
           'stats'
         when :list
           'list'
         when :suggest
           'suggest'
         end
  args << ' .'
  run_inch args
end

#run_on_changes(paths) ⇒ Object

Run the lints for changes files

Parameters:

  • paths (Array<String>)

    the paths of changed files



44
45
46
47
48
49
# File 'lib/guard/inch.rb', line 44

def run_on_changes(paths)
  flags = ''
  flags << '--pedantic ' if options[:pedantic]
  flags << '--private ' if options[:private]
  run_inch "#{flags} #{paths.join(' ')}"
end

#startObject

On start, display a message and optionally run the documentation lint



19
20
21
22
23
24
25
# File 'lib/guard/inch.rb', line 19

def start
  message = 'Guard::Inch is running'
  message << ' in pedantic mode' if options[:pedantic]
  message << ' and inspecting private fields' if options[:private]
  ::Guard::UI.info message
  run_all if options[:all_on_start]
end