class Lumise::Commands::Rubocop::UpdateFiles
Attributes
plugins[R]
Public Class Methods
call(plugins:)
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 11 def self.call(plugins:) new(plugins: plugins).send :perform end
new(plugins:)
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 15 def initialize(plugins:) @plugins = plugins end
Private Instance Methods
files()
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 51 def files if l.repo repo_files else template_files end end
mustacho(file)
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 36 def mustacho(file) Mustache.render File.read(file), require: plugins?, plugins: plugins_list, rspec: plugins.include?('rspec'), sorbet: plugins.include?('sorbet') end
parse_template(file)
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 31 def parse_template(file) generator.create_file File.basename(file), mustacho(file), force: l.force end
perform()
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 23 def perform if yes? files.each do |file| parse_template file end end end
plugins?()
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 73 def plugins? !plugins&.first.nil? end
plugins_list()
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 43 def plugins_list plugins.map do |plugin| " - rubocop-#{plugin}" end.join("\n") rescue NoMethodError [] end
repo_files()
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 65 def repo_files RepoFiles.call end
template_files()
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 59 def template_files Dir[templates_path + '**/{*,.*}'].reject do |file| file.scan(/\.$/).first end end
templates_path()
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 69 def templates_path File.expand_path('../../../templates/rubocop', __dir__) end
yes?()
click to toggle source
# File lib/lumise/services/commands/rubocop/update_files.rb, line 77 def yes? if l.update_files.nil? prompt.yes? 'Update .rubocop files?', suffix: 'Yeah/nah' else l.update_files end end