class ActiveRecord::DataIntegrity::CLI
CLI
application class
Attributes
options[R]
Public Instance Methods
check(_args = ARGV)
click to toggle source
# File lib/active_record/data_integrity/cli.rb, line 17 def check(_args = ARGV) @options = Options.new(options) require_rails results = cops.map do |cop_class| ActiveRecord::Base.descendants.each do |model| cop_class.new(model).call end end ActiveRecord::DataIntegrity::Collector.render exit(1) if results.include?(false) end
version()
click to toggle source
# File lib/active_record/data_integrity/cli.rb, line 34 def version puts ActiveRecord::DataIntegrity::VERSION end
Private Instance Methods
cops()
click to toggle source
# File lib/active_record/data_integrity/cli.rb, line 41 def cops @cops ||= begin ActiveRecord::DataIntegrity::Cop.descendants.select do |cop| options.only.empty? || cop.cop_name.in?(options.only) end end end
require_rails()
click to toggle source
# File lib/active_record/data_integrity/cli.rb, line 49 def require_rails # Rails load ugly hack :) require File.expand_path('config/environment', Dir.pwd) Kernel.const_set(:APP_PATH, File.expand_path('config/application', Dir.pwd)) Rails.application.eager_load! Rails.logger.level = 0 end