Module: Idxfence
- Defined in:
- lib/idxfence.rb,
lib/idxfence/cli.rb,
lib/idxfence/render.rb,
lib/idxfence/checker.rb,
lib/idxfence/finding.rb,
lib/idxfence/version.rb,
lib/idxfence/inflector.rb,
lib/idxfence/model_parser.rb,
lib/idxfence/schema_parser.rb
Defined Under Namespace
Modules: CLI, Inflector, Render Classes: Checker, Finding, ModelParser, SchemaParser
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.check(project_dir:) ⇒ Array(Array<Finding>, String, nil)
Scans a Rails project root for ActiveRecord
uniqueness: true/uniqueness: { ... }/validates_uniqueness_ofvalidations underapp/models/**/*.rbwith no matching unique index indb/schema.rb. -
.check_paths(model_paths:, schema_path:) ⇒ Array(Array<Finding>, String, nil)
Lower-level entry point: an explicit list of model file paths and one schema.rb path, for callers that already know their own layout (or for testing against fixtures that aren't laid out as a full Rails project).
Class Method Details
.check(project_dir:) ⇒ Array(Array<Finding>, String, nil)
Scans a Rails project root for ActiveRecord uniqueness: true /
uniqueness: { ... } / validates_uniqueness_of validations under
app/models/**/*.rb with no matching unique index in
db/schema.rb.
21 22 23 24 25 26 |
# File 'lib/idxfence.rb', line 21 def check(project_dir:) model_paths = Dir.glob(File.join(project_dir, "app", "models", "**", "*.rb")) schema_path = File.join(project_dir, "db", "schema.rb") check_paths(model_paths: model_paths, schema_path: schema_path) end |
.check_paths(model_paths:, schema_path:) ⇒ Array(Array<Finding>, String, nil)
Lower-level entry point: an explicit list of model file paths and one schema.rb path, for callers that already know their own layout (or for testing against fixtures that aren't laid out as a full Rails project).
36 37 38 |
# File 'lib/idxfence.rb', line 36 def check_paths(model_paths:, schema_path:) Checker.new(model_paths: model_paths, schema_path: schema_path).call end |