class Object

Public Instance Methods

check_files(erbs, options) click to toggle source
# File lib/rails-erb-lint/linter/check_validity.rb, line 28
def check_files(erbs, options)
  files = {}

  erbs.each do |f|
    checker = RailsErbCheck::Checker.new(f)

    if checker.valid_syntax?
      puts Rainbow("#{f} => valid").green if options[:valid]
      files[f] = { invalid: false }
    else
      puts Rainbow("#{f} => invalid").red
      puts checker.error.message if options[:error]
      files[f] = {
        invalid: true,
        error: checker.error.message,
        backtrace: checker.error.backtrace
      }
    end
  end

  files
end
export_json(hash, path) click to toggle source
# File lib/rails-erb-lint/linter/check_validity.rb, line 51
def export_json(hash, path)
  File.open(path, 'w') do |file|
    JSON.dump(hash, file)
  end
end
get_erb_list(path) click to toggle source
# File lib/rails-erb-lint/linter/check_validity.rb, line 15
def get_erb_list(path)
  erb_files = []

  Find.find(path.to_s) do |f|
    next if FileTest.directory?(f)
    if /.*\.erb/.match(File.basename(f))
      erb_files << f
    end
  end

  erb_files
end