Class: Quandl::Utility::ThorTasks::Lint

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/quandl/utility/thor_tasks/lint.rb

Overview

Linting Tasks

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



13
14
15
# File 'lib/quandl/utility/thor_tasks/lint.rb', line 13

def self.source_root
  File.expand_path('../../../../../support/templates', __FILE__)
end

Instance Method Details

#cookbookObject



18
19
20
# File 'lib/quandl/utility/thor_tasks/lint.rb', line 18

def cookbook
  invoke 'foodcritic:lint'
end

#init_rubyObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/quandl/utility/thor_tasks/lint.rb', line 44

def init_ruby
  return unless yes?('Do you want to setup Rubocop linting?', :yellow)
  # Get directory and file for base rubocop
  dir = options[:default_directory]
  file_path = File.join(dir, '.rubocop.yml')
  # Create empty directory if it does not exist
  empty_directory(dir)
  # Create base rubocop with common rules. Let Thor handle conflicts.
  template('quandl.rubocop.yml', file_path)
  # Create project template. Let Thor handle conflicts
  @base_directory = dir
  template('project.rubocop.yml.erb', '.rubocop.yml')
end

#rubyObject



28
29
30
31
32
33
34
35
# File 'lib/quandl/utility/thor_tasks/lint.rb', line 28

def ruby
  result = RuboCop::CLI.new.run(options[:paths])
  if result == 0
    say('No Rubocop warnings', :green)
  else
    exit(result)
  end
end