Class: Templatecop::Cli
- Inherits:
-
Object
- Object
- Templatecop::Cli
- Defined in:
- lib/templatecop/cli.rb
Overview
Call this from your executable.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv:, default_configuration_path:, default_path_patterns:, executable_name:, implicit_configuration_paths:, ruby_extractor:) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(argv:, default_configuration_path:, default_path_patterns:, executable_name:, implicit_configuration_paths:, ruby_extractor:) ⇒ Cli
Returns a new instance of Cli.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/templatecop/cli.rb', line 42 def initialize( argv:, default_configuration_path:, default_path_patterns:, executable_name:, implicit_configuration_paths:, ruby_extractor: ) @argv = argv @default_configuration_path = default_configuration_path @default_path_patterns = default_path_patterns @executable_name = executable_name @ruby_extractor = ruby_extractor @implicit_configuration_paths = implicit_configuration_paths end |
Class Method Details
.call(executable_name:, ruby_extractor:, implicit_configuration_paths:, argv: ::ARGV.dup, default_configuration_path: nil, default_path_patterns: []) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/templatecop/cli.rb', line 23 def call( executable_name:, ruby_extractor:, implicit_configuration_paths:, argv: ::ARGV.dup, default_configuration_path: nil, default_path_patterns: [] ) new( argv: argv, default_configuration_path: default_configuration_path, default_path_patterns: default_path_patterns, executable_name: executable_name, implicit_configuration_paths: implicit_configuration_paths, ruby_extractor: ruby_extractor ).call end |
Instance Method Details
#call ⇒ Object
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 |
# File 'lib/templatecop/cli.rb', line 58 def call = formatter = ::RuboCop::Formatter::ProgressFormatter.new($stdout, color: [:color]) rubocop_config = RuboCopConfigGenerator.new( default_configuration_path: @default_configuration_path, forced_configuration_path: [:forced_configuration_path], implicit_configuration_paths: @implicit_configuration_paths ).call file_paths = PathFinder.new( default_patterns: @default_path_patterns, exclude_patterns: rubocop_config.for_all_cops['Exclude'], patterns: @argv ).call offenses = Runner.new( autocorrect: [:autocorrect], debug: [:debug], file_paths: file_paths, formatter: formatter, rubocop_config: rubocop_config, ruby_extractor: @ruby_extractor ).call exit(offenses.empty? ? 0 : 1) end |