Module: RailsLens

Extended by:
Configuration
Defined in:
lib/rails_lens.rb,
lib/rails_lens/cli.rb,
lib/rails_lens/errors.rb,
lib/rails_lens/parsers.rb,
lib/rails_lens/railtie.rb,
lib/rails_lens/version.rb,
lib/rails_lens/commands.rb,
lib/rails_lens/connection.rb,
lib/rails_lens/note_codes.rb,
lib/rails_lens/toml_format.rb,
lib/rails_lens/model_source.rb,
lib/rails_lens/route/parser.rb,
lib/rails_lens/configuration.rb,
lib/rails_lens/view_metadata.rb,
lib/rails_lens/analyzers/base.rb,
lib/rails_lens/erd/visualizer.rb,
lib/rails_lens/model_detector.rb,
lib/rails_lens/providers/base.rb,
lib/rails_lens/analyzers/enums.rb,
lib/rails_lens/analyzers/notes.rb,
lib/rails_lens/extensions/base.rb,
lib/rails_lens/route/annotator.rb,
lib/rails_lens/route/extractor.rb,
lib/rails_lens/extension_loader.rb,
lib/rails_lens/mailer/annotator.rb,
lib/rails_lens/mailer/extractor.rb,
lib/rails_lens/cli_error_handler.rb,
lib/rails_lens/parsers/node_info.rb,
lib/rails_lens/rake_bootstrapper.rb,
lib/rails_lens/schema/annotation.rb,
lib/rails_lens/parsers/class_info.rb,
lib/rails_lens/analyzers/callbacks.rb,
lib/rails_lens/annotation_pipeline.rb,
lib/rails_lens/model_source_loader.rb,
lib/rails_lens/parsers/module_info.rb,
lib/rails_lens/parsers/prism_parser.rb,
lib/rails_lens/schema/adapters/base.rb,
lib/rails_lens/analyzers/inheritance.rb,
lib/rails_lens/file_insertion_helper.rb,
lib/rails_lens/parsers/parser_result.rb,
lib/rails_lens/schema/adapters/mysql.rb,
lib/rails_lens/erd/domain_color_mapper.rb,
lib/rails_lens/providers/view_provider.rb,
lib/rails_lens/schema/adapters/sqlite3.rb,
lib/rails_lens/analyzers/composite_keys.rb,
lib/rails_lens/analyzers/error_handling.rb,
lib/rails_lens/analyzers/index_analyzer.rb,
lib/rails_lens/providers/enums_provider.rb,
lib/rails_lens/analyzers/column_analyzer.rb,
lib/rails_lens/analyzers/delegated_types.rb,
lib/rails_lens/erd/column_type_formatter.rb,
lib/rails_lens/providers/schema_provider.rb,
lib/rails_lens/schema/annotation_manager.rb,
lib/rails_lens/schema/annotation_removal.rb,
lib/rails_lens/schema/database_annotator.rb,
lib/rails_lens/schema/adapters/postgresql.rb,
lib/rails_lens/analyzers/generated_columns.rb,
lib/rails_lens/extensions/closure_tree_ext.rb,
lib/rails_lens/providers/callbacks_provider.rb,
lib/rails_lens/providers/extensions_provider.rb,
lib/rails_lens/providers/notes_provider_base.rb,
lib/rails_lens/providers/view_notes_provider.rb,
lib/rails_lens/schema/adapters/database_info.rb,
lib/rails_lens/analyzers/association_analyzer.rb,
lib/rails_lens/analyzers/database_constraints.rb,
lib/rails_lens/analyzers/foreign_key_analyzer.rb,
lib/rails_lens/analyzers/performance_analyzer.rb,
lib/rails_lens/providers/index_notes_provider.rb,
lib/rails_lens/providers/inheritance_provider.rb,
lib/rails_lens/erd/mysql_column_type_formatter.rb,
lib/rails_lens/providers/column_notes_provider.rb,
lib/rails_lens/providers/section_provider_base.rb,
lib/rails_lens/analyzers/best_practices_analyzer.rb,
lib/rails_lens/providers/composite_keys_provider.rb,
lib/rails_lens/model_sources/active_record_source.rb,
lib/rails_lens/providers/delegated_types_provider.rb,
lib/rails_lens/providers/extension_notes_provider.rb,
lib/rails_lens/erd/postgresql_column_type_formatter.rb,
lib/rails_lens/providers/association_notes_provider.rb,
lib/rails_lens/providers/foreign_key_notes_provider.rb,
lib/rails_lens/providers/generated_columns_provider.rb,
lib/rails_lens/providers/performance_notes_provider.rb,
lib/rails_lens/providers/best_practices_notes_provider.rb,
lib/rails_lens/providers/database_constraints_provider.rb

Defined Under Namespace

Modules: Analyzers, CLIErrorHandler, Configuration, ERD, Extensions, Mailer, ModelSources, NoteCodes, Parsers, Providers, Route, Schema, TomlFormat Classes: AnalysisError, AnalyzerError, AnnotationError, AnnotationPipeline, CLI, Commands, Config, ConfigurationError, Connection, ConnectionError, DatabaseError, ERDError, Error, ErrorReporter, ExtensionConfigError, ExtensionError, ExtensionLoadError, ExtensionLoader, FileInsertionHelper, FileNotFoundError, InsertionError, InvalidModelError, ModelDetectionError, ModelDetector, ModelNotFoundError, ModelSource, ModelSourceLoader, ParseError, Railtie, RakeBootstrapper, SchemaError, TableNotFoundError, UnsupportedAdapterError, ViewMetadata, VisualizationError

Constant Summary collapse

VERSION =
'0.10.0'

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Configuration

config, configure

Class Attribute Details

.config_fileObject (readonly)

Path of the loaded config file, nil when running on defaults.



35
36
37
# File 'lib/rails_lens.rb', line 35

def config_file
  @config_file
end

Class Method Details

.annotate_models(options = {}) ⇒ Object

Schema annotation methods



86
87
88
# File 'lib/rails_lens.rb', line 86

def annotate_models(options = {})
  Schema::AnnotationManager.annotate_all(options)
end

.default_loggerObject



46
47
48
49
50
51
52
53
# File 'lib/rails_lens.rb', line 46

def default_logger
  if defined?(Rails.logger) && Rails.logger
    Rails.logger
  else
    require 'logger'
    Logger.new($stdout)
  end
end

.excluded_tablesObject

Get tables to exclude



75
76
77
78
79
80
81
82
83
# File 'lib/rails_lens.rb', line 75

def excluded_tables
  custom_excludes = config.schema[:exclude_tables]
  if custom_excludes.nil?
    # Use ActiveRecord's default ignore tables
    ActiveRecord::SchemaDumper.ignore_tables.to_a
  else
    Array(custom_excludes)
  end
end

.load_config_file(path = '.rails-lens.yml') ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rails_lens.rb', line 55

def load_config_file(path = '.rails-lens.yml')
  return unless File.exist?(path)

  @config_file = path
  yaml = YAML.load_file(path)

  yaml.each do |section, settings|
    next unless config.respond_to?("#{section}=")
    next unless settings.is_a?(Hash)

    current_value = config.send(section)
    if current_value.is_a?(Hash)
      config.send("#{section}=", current_value.deep_merge(settings.symbolize_keys))
    else
      config.send("#{section}=", settings.symbolize_keys)
    end
  end
end

.loggerObject



37
38
39
# File 'lib/rails_lens.rb', line 37

def logger
  @logger ||= config.logger || default_logger
end

.logger=(new_logger) ⇒ Object



41
42
43
44
# File 'lib/rails_lens.rb', line 41

def logger=(new_logger)
  @logger = new_logger
  config.logger = new_logger
end

.remove_annotations(options = {}) ⇒ Object



90
91
92
# File 'lib/rails_lens.rb', line 90

def remove_annotations(options = {})
  Schema::AnnotationManager.remove_all(options)
end