Class: Prettier::Rake::Task

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/prettier/rake/task.rb

Overview

A Rake task that runs prettier on a set of source files.

Example:

require 'prettier/rake/task'

Prettier::Rake::Task.new do |t|
  t.source_files = '{app,config,lib}/**/*.rb'
end

This will create a task that can be run with:

rake prettier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :prettier) {|_self| ... } ⇒ Task

Returns a new instance of Task.

Yields:

  • (_self)

Yield Parameters:


35
36
37
38
39
40
41
42
# File 'lib/prettier/rake/task.rb', line 35

def initialize(name = :prettier)
  @name = name
  @write = true
  @source_files = 'lib/**/*.rb'

  yield self if block_given?
  define_task
end

Instance Attribute Details

#nameObject

Name of prettier task. Defaults to :prettier.


25
26
27
# File 'lib/prettier/rake/task.rb', line 25

def name
  @name
end

#source_filesObject

Glob pattern to match source files. Defaults to 'lib/*/.rb'.


33
34
35
# File 'lib/prettier/rake/task.rb', line 33

def source_files
  @source_files
end

#writeObject

Whether or not to overwrite the source files with the prettier output. Defaults to true.


29
30
31
# File 'lib/prettier/rake/task.rb', line 29

def write
  @write
end