Class: RubyLint::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RubyLint::RakeTask
- Defined in:
- lib/ruby-lint/rake_task.rb
Overview
Instance Attribute Summary collapse
-
#configuration ⇒ String
Path to the configuration file to use.
-
#debug ⇒ TrueClass|FalseClass
Enables/disables debugging mode.
-
#description ⇒ String
The description of the task.
-
#files ⇒ Array
The files to check.
-
#name ⇒ String
The name of the task.
Instance Method Summary collapse
- #create_configuration ⇒ RubyLint::Configuration
-
#initialize(options = {}) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
-
#run_task ⇒ Object
Processes a list of files and writes the output to STDOUT.
-
#validate! ⇒ Object
Checks if the task is configured properly, exists with code 1 if this isn't the case.
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ruby-lint/rake_task.rb', line 39 def initialize( = {}) @name = 'lint' @description = 'Check source code using ruby-lint' .each do |key, value| instance_variable_set("@#{key}", value) if respond_to?(key) end yield self if block_given? desc(description) task(name) do validate! run_task end end |
Instance Attribute Details
#configuration ⇒ String
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ruby-lint/rake_task.rb', line 33 class RakeTask < Rake::TaskLib attr_accessor :name, :description, :debug, :files, :configuration ## # @param [Hash] options # def initialize( = {}) @name = 'lint' @description = 'Check source code using ruby-lint' .each do |key, value| instance_variable_set("@#{key}", value) if respond_to?(key) end yield self if block_given? desc(description) task(name) do validate! run_task end end ## # Checks if the task is configured properly, exists with code 1 if this # isn't the case. # def validate! if configuration and !File.file?(configuration) abort "The configuration file #{configuration} does not exist" end if files.empty? abort 'No files to check were specified' end end ## # Processes a list of files and writes the output to STDOUT. # def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end ## # @return [RubyLint::Configuration] # def create_configuration config_files = RubyLint::Configuration.configuration_files if configuration config_files = [configuration] end config = RubyLint::Configuration.load_from_file(config_files) config.debug = debug return config end end |
#debug ⇒ TrueClass|FalseClass
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ruby-lint/rake_task.rb', line 33 class RakeTask < Rake::TaskLib attr_accessor :name, :description, :debug, :files, :configuration ## # @param [Hash] options # def initialize( = {}) @name = 'lint' @description = 'Check source code using ruby-lint' .each do |key, value| instance_variable_set("@#{key}", value) if respond_to?(key) end yield self if block_given? desc(description) task(name) do validate! run_task end end ## # Checks if the task is configured properly, exists with code 1 if this # isn't the case. # def validate! if configuration and !File.file?(configuration) abort "The configuration file #{configuration} does not exist" end if files.empty? abort 'No files to check were specified' end end ## # Processes a list of files and writes the output to STDOUT. # def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end ## # @return [RubyLint::Configuration] # def create_configuration config_files = RubyLint::Configuration.configuration_files if configuration config_files = [configuration] end config = RubyLint::Configuration.load_from_file(config_files) config.debug = debug return config end end |
#description ⇒ String
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ruby-lint/rake_task.rb', line 33 class RakeTask < Rake::TaskLib attr_accessor :name, :description, :debug, :files, :configuration ## # @param [Hash] options # def initialize( = {}) @name = 'lint' @description = 'Check source code using ruby-lint' .each do |key, value| instance_variable_set("@#{key}", value) if respond_to?(key) end yield self if block_given? desc(description) task(name) do validate! run_task end end ## # Checks if the task is configured properly, exists with code 1 if this # isn't the case. # def validate! if configuration and !File.file?(configuration) abort "The configuration file #{configuration} does not exist" end if files.empty? abort 'No files to check were specified' end end ## # Processes a list of files and writes the output to STDOUT. # def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end ## # @return [RubyLint::Configuration] # def create_configuration config_files = RubyLint::Configuration.configuration_files if configuration config_files = [configuration] end config = RubyLint::Configuration.load_from_file(config_files) config.debug = debug return config end end |
#files ⇒ Array
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ruby-lint/rake_task.rb', line 33 class RakeTask < Rake::TaskLib attr_accessor :name, :description, :debug, :files, :configuration ## # @param [Hash] options # def initialize( = {}) @name = 'lint' @description = 'Check source code using ruby-lint' .each do |key, value| instance_variable_set("@#{key}", value) if respond_to?(key) end yield self if block_given? desc(description) task(name) do validate! run_task end end ## # Checks if the task is configured properly, exists with code 1 if this # isn't the case. # def validate! if configuration and !File.file?(configuration) abort "The configuration file #{configuration} does not exist" end if files.empty? abort 'No files to check were specified' end end ## # Processes a list of files and writes the output to STDOUT. # def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end ## # @return [RubyLint::Configuration] # def create_configuration config_files = RubyLint::Configuration.configuration_files if configuration config_files = [configuration] end config = RubyLint::Configuration.load_from_file(config_files) config.debug = debug return config end end |
#name ⇒ String
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ruby-lint/rake_task.rb', line 33 class RakeTask < Rake::TaskLib attr_accessor :name, :description, :debug, :files, :configuration ## # @param [Hash] options # def initialize( = {}) @name = 'lint' @description = 'Check source code using ruby-lint' .each do |key, value| instance_variable_set("@#{key}", value) if respond_to?(key) end yield self if block_given? desc(description) task(name) do validate! run_task end end ## # Checks if the task is configured properly, exists with code 1 if this # isn't the case. # def validate! if configuration and !File.file?(configuration) abort "The configuration file #{configuration} does not exist" end if files.empty? abort 'No files to check were specified' end end ## # Processes a list of files and writes the output to STDOUT. # def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end ## # @return [RubyLint::Configuration] # def create_configuration config_files = RubyLint::Configuration.configuration_files if configuration config_files = [configuration] end config = RubyLint::Configuration.load_from_file(config_files) config.debug = debug return config end end |
Instance Method Details
#create_configuration ⇒ RubyLint::Configuration
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ruby-lint/rake_task.rb', line 85 def create_configuration config_files = RubyLint::Configuration.configuration_files if configuration config_files = [configuration] end config = RubyLint::Configuration.load_from_file(config_files) config.debug = debug return config end |
#run_task ⇒ Object
Processes a list of files and writes the output to STDOUT.
73 74 75 76 77 78 79 80 |
# File 'lib/ruby-lint/rake_task.rb', line 73 def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end |
#validate! ⇒ Object
Checks if the task is configured properly, exists with code 1 if this isn't the case.
60 61 62 63 64 65 66 67 68 |
# File 'lib/ruby-lint/rake_task.rb', line 60 def validate! if configuration and !File.file?(configuration) abort "The configuration file #{configuration} does not exist" end if files.empty? abort 'No files to check were specified' end end |