Module: Dbviewer

Defined in:
lib/dbviewer.rb,
lib/dbviewer/engine.rb,
lib/dbviewer/logger.rb,
lib/dbviewer/version.rb,
lib/dbviewer/query_parser.rb,
lib/dbviewer/storage/base.rb,
lib/dbviewer/cache_manager.rb,
lib/dbviewer/configuration.rb,
lib/dbviewer/error_handler.rb,
lib/dbviewer/sql_validator.rb,
lib/dbviewer/query_analyzer.rb,
lib/dbviewer/query_executor.rb,
lib/dbviewer/database_manager.rb,
lib/dbviewer/query_collection.rb,
lib/dbviewer/table_query_params.rb,
app/jobs/dbviewer/application_job.rb,
lib/dbviewer/storage/file_storage.rb,
lib/dbviewer/dynamic_model_factory.rb,
lib/dbviewer/table_metadata_manager.rb,
lib/dbviewer/table_query_operations.rb,
app/models/dbviewer/application_record.rb,
lib/dbviewer/storage/in_memory_storage.rb,
app/helpers/dbviewer/application_helper.rb,
app/mailers/dbviewer/application_mailer.rb,
app/controllers/dbviewer/home_controller.rb,
app/controllers/dbviewer/logs_controller.rb,
app/controllers/dbviewer/tables_controller.rb,
app/controllers/dbviewer/api/base_controller.rb,
lib/generators/dbviewer/initializer_generator.rb,
app/controllers/dbviewer/api/tables_controller.rb,
app/controllers/dbviewer/api/queries_controller.rb,
app/controllers/dbviewer/application_controller.rb,
app/controllers/concerns/dbviewer/error_handling.rb,
app/controllers/dbviewer/api/database_controller.rb,
app/controllers/concerns/dbviewer/pagination_concern.rb,
app/controllers/concerns/dbviewer/database_operations.rb,
app/controllers/dbviewer/entity_relationship_diagrams_controller.rb

Defined Under Namespace

Modules: Api, ApplicationHelper, DatabaseOperations, ErrorHandling, Generators, PaginationConcern, Storage Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, CacheManager, Configuration, DatabaseManager, DynamicModelFactory, Engine, EntityRelationshipDiagramsController, ErrorHandler, HomeController, Logger, LogsController, QueryAnalyzer, QueryCollection, QueryExecutor, QueryParser, SqlValidator, TableMetadataManager, TableQueryOperations, TableQueryParams, TablesController

Constant Summary collapse

VERSION =
"0.5.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Get configuration settings



21
22
23
# File 'lib/dbviewer.rb', line 21

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Configure the engine with a block

Examples:

Dbviewer.configure do |config|
  config.per_page_options = [10, 25, 50]
  config.default_per_page = 25
end

Yields:



32
33
34
# File 'lib/dbviewer.rb', line 32

def configure
  yield(configuration) if block_given?
end

.initObject

Initialize engine with default values or user-provided configuration



50
51
52
53
54
55
56
57
58
59
# File 'lib/dbviewer.rb', line 50

def init
  # Define class methods to access configuration
  Dbviewer::SqlValidator.singleton_class.class_eval do
    define_method(:configuration) { Dbviewer.configuration }
    define_method(:max_query_length) { Dbviewer.configuration.max_query_length }
  end

  # Log initialization
  Rails.logger.info("[DBViewer] Initialized with configuration: #{configuration.inspect}")
end

.reset_configurationObject

Reset configuration to defaults



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

def reset_configuration
  @configuration = Configuration.new
end

.setupObject

This class method will be called by the engine when it’s appropriate



42
43
44
45
46
47
# File 'lib/dbviewer.rb', line 42

def setup
  ActiveRecord::Base.connection
  Rails.logger.info "DBViewer successfully connected to database"
rescue => e
  Rails.logger.error "DBViewer could not connect to database: #{e.message}"
end