Class: Kotoshu::Tasks::CheckTask

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/kotoshu/tasks/check_task.rb,
sig/kotoshu.rbs

Overview

Rake task checking a repository text files with the plan-88 file selection (plan 89, item 3).

Examples:

Default task via require

# Rakefile
require "kotoshu/tasks"
# provides rake kotoshu:check over the repo text files

Configured

Kotoshu::Tasks::CheckTask.new do |t|
  t.files = FileList["_posts/**/*.md"]
  t.language = "en"
  t.fail_on_error = true
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :check) {|task| ... } ⇒ CheckTask

Returns a new instance of CheckTask.

Parameters:

  • name (Symbol) (defaults to: :check) —

    task name under the kotoshu namespace

Yield Parameters:

  • task (CheckTask) —

    self for configuration



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kotoshu/tasks/check_task.rb', line 27

def initialize(name = :check, &block)
  @name = name
  @files = nil
  @root = Dir.pwd
  @language = nil
  @fail_on_error = true
  @baseline_path = nil
  yield self if block

  define
end

Instance Attribute Details

#baseline_path ⇒ Object

Returns the value of attribute baseline_path.



39
40
41
# File 'lib/kotoshu/tasks/check_task.rb', line 39

def baseline_path
  @baseline_path
end

#fail_on_error ⇒ Object

Returns the value of attribute fail_on_error.



39
40
41
# File 'lib/kotoshu/tasks/check_task.rb', line 39

def fail_on_error
  @fail_on_error
end

#files ⇒ Object

Returns the value of attribute files.



39
40
41
# File 'lib/kotoshu/tasks/check_task.rb', line 39

def files
  @files
end

#language ⇒ Object

Returns the value of attribute language.



39
40
41
# File 'lib/kotoshu/tasks/check_task.rb', line 39

def language
  @language
end

#name ⇒ Object

Returns the value of attribute name.



39
40
41
# File 'lib/kotoshu/tasks/check_task.rb', line 39

def name
  @name
end

#root ⇒ Object

Returns the value of attribute root.



39
40
41
# File 'lib/kotoshu/tasks/check_task.rb', line 39

def root
  @root
end

Instance Method Details

#target_files ⇒ Array<String>

The files the task will check: the configured list, or the plan-88 selection over the root.

Returns:

  • (Array<String>)


45
46
47
48
49
# File 'lib/kotoshu/tasks/check_task.rb', line 45

def target_files
  return Array(files) if files

  Cli::DirectoryWalker.new.files(root)
end