Class: LintTrappings::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/lint_trappings/rake_task.rb

Overview

Rake task interface factory for a LintTrappings application.

In your application, define your Rake task factory class as:

require 'lint_trappings/rake_task'
require 'my_app'

module MyApp
  class RakeTask < LintTrappings::RakeTask
    def initialize(name = :my_app)
      @application_class = MyApp::Application
      super
    end
  end
end

Then developers can follow the instructions below (swapping out MyApp/my_app with the appropriate name of your application) to invoke your application via Rake.

You can also specify the list of files as explicit task arguments:

Examples:

# Add the following to your Rakefile...
require 'my_app/rake_task'

MyApp::RakeTask.new do |t|
  t.config = 'path/to/custom/config.yml'
  t.files = %w[app/views/**/*.txt custom/*.txt]
  t.quiet = true # Don't display output from app
end

# ...and then execute from the command line:
rake my_app
# Add the following to your Rakefile...
require 'my_app/rake_task'

MyApp::RakeTask.new

# ...and then execute from the command line:
rake my_app[some/directory, some/specific/file.txt]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) {|_self| ... } ⇒ RakeTask

Create the task so it exists in the current namespace.

Parameters:

  • name (Symbol)

    task name

Yields:

  • (_self)

Yield Parameters:



73
74
75
76
77
78
79
80
81
82
# File 'lib/lint_trappings/rake_task.rb', line 73

def initialize(name)
  @name = name
  @files = []
  @quiet = false

  # Allow custom configuration to be defined in a block passed to constructor
  yield self if block_given?

  define
end

Instance Attribute Details

#configString

Path of the configuration file to use.

Returns:

  • (String)


56
57
58
# File 'lib/lint_trappings/rake_task.rb', line 56

def config
  @config
end

#filesArray<String>

List of files to lint.

Note that this will be ignored if you explicitly pass a list of files as task arguments via the command line.

Returns:

  • (Array<String>)


63
64
65
# File 'lib/lint_trappings/rake_task.rb', line 63

def files
  @files
end

#nameString

Name of the task.

Returns:

  • (String)


52
53
54
# File 'lib/lint_trappings/rake_task.rb', line 52

def name
  @name
end

#quiettrue, false

Whether output from application should not be displayed to the standard out stream.

Returns:

  • (true, false)


68
69
70
# File 'lib/lint_trappings/rake_task.rb', line 68

def quiet
  @quiet
end