Module: Solidstats

Defined in:
lib/solidstats/asset_manifest.rb,
lib/solidstats.rb,
lib/solidstats/engine.rb,
lib/solidstats/version.rb,
lib/solidstats/asset_compatibility.rb,
app/jobs/solidstats/application_job.rb,
app/services/solidstats/todo_service.rb,
app/services/solidstats/audit_service.rb,
app/components/solidstats/base_component.rb,
app/models/solidstats/application_record.rb,
app/helpers/solidstats/application_helper.rb,
app/mailers/solidstats/application_mailer.rb,
lib/generators/solidstats/install_generator.rb,
app/services/solidstats/data_collector_service.rb,
app/controllers/solidstats/dashboard_controller.rb,
app/services/solidstats/log_size_monitor_service.rb,
app/components/solidstats/tasks_section_component.rb,
app/components/solidstats/ui/navigation_component.rb,
app/controllers/solidstats/application_controller.rb,
app/controllers/solidstats/gem_metadata_controller.rb,
app/components/solidstats/ui/status_badge_component.rb,
app/components/solidstats/ui/summary_card_component.rb,
lib/generators/solidstats/feature/feature_generator.rb,
lib/generators/solidstats/install/install_generator.rb,
app/components/solidstats/dashboard_header_component.rb,
app/components/solidstats/quick_navigation_component.rb,
app/components/solidstats/security/section_component.rb,
app/components/solidstats/ui/action_button_component.rb,
app/services/solidstats/gem_metadata/fetcher_service.rb,
app/components/solidstats/security/overview_component.rb,
app/components/solidstats/security/timeline_component.rb,
app/components/solidstats/ui/stats_overview_component.rb,
app/components/solidstats/ui/tab_navigation_component.rb,
app/components/solidstats/ui/dashboard_layout_component.rb,
app/components/solidstats/code_quality/section_component.rb,
app/components/solidstats/previews/navigation_component_preview.rb,
app/components/solidstats/security/gem_impact_analysis_component.rb,
app/components/solidstats/previews/status_badge_component_preview.rb,
app/components/solidstats/previews/summary_card_component_preview.rb,
app/components/solidstats/previews/action_button_component_preview.rb,
app/components/solidstats/previews/stats_overview_component_preview.rb

Overview

Solidstats Asset Manifest This file defines all assets that should be precompiled for production deployment Compatible with Sprockets, Webpacker, and Importmap

Defined Under Namespace

Modules: ApplicationHelper, AssetCompatibility, CodeQuality, GemMetadata, Generators, Previews, Security, Ui Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, AssetManifest, AuditService, BaseComponent, ComponentError, Configuration, ConfigurationError, DashboardController, DashboardHeaderComponent, DataCollectorService, Engine, Error, GemMetadataController, LogSizeMonitorService, QuickNavigationComponent, ServiceError, TasksSectionComponent, TodoService

Constant Summary collapse

VERSION =
"2.0.0"

Class Method Summary collapse

Class Method Details

.app_pathPathname

Returns the gem’s app directory

Returns:

  • (Pathname)

    App directory path



36
37
38
# File 'lib/solidstats.rb', line 36

def app_path
  @app_path ||= root.join("app")
end

.asset_fingerprinting?Boolean

Check if assets should be fingerprinted

Returns:

  • (Boolean)

    True if fingerprinting is enabled



188
189
190
# File 'lib/solidstats.rb', line 188

def asset_fingerprinting?
  configuration.assets[:fingerprint] && !Rails.env.development?
end

.asset_prefixString

Get the asset prefix for engine assets

Returns:

  • (String)

    Asset prefix



194
195
196
197
198
199
200
201
202
203
# File 'lib/solidstats.rb', line 194

def asset_prefix
  case asset_strategy
  when :importmap, :sprockets
    "solidstats"
  when :webpacker
    "solidstats"
  else
    "solidstats"
  end
end

.asset_strategySymbol

Get asset strategy for current application

Returns:

  • (Symbol)

    Asset strategy (:sprockets, :webpacker, :importmap, :auto)



171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/solidstats.rb', line 171

def asset_strategy
  return configuration.assets[:strategy] if configuration.assets[:strategy] != :auto

  # Auto-detect asset strategy
  if defined?(Importmap) && File.exist?(Rails.root.join("config/importmap.rb"))
    :importmap
  elsif defined?(Webpacker) && File.exist?(Rails.root.join("config/webpacker.yml"))
    :webpacker
  elsif defined?(Sprockets)
    :sprockets
  else
    :none
  end
end

.components_pathPathname

Returns the components directory

Returns:

  • (Pathname)

    Components directory path



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

def components_path
  @components_path ||= app_path.join("components", "solidstats")
end

.configurationConfiguration

Configuration object for the gem

Returns:



117
118
119
# File 'lib/solidstats.rb', line 117

def configuration
  @configuration ||= Configuration.new
end

.configure {|Configuration| ... } ⇒ Object

Configure the gem with a block

Examples:

Solidstats.configure do |config|
  config.cache_duration = 30.minutes
  config.enable_components = true
end

Yields:



128
129
130
131
# File 'lib/solidstats.rb', line 128

def configure
  yield(configuration) if block_given?
  configuration
end

.development?Boolean

Check if running in development mode

Returns:

  • (Boolean)

    True if in development



93
94
95
# File 'lib/solidstats.rb', line 93

def development?
  defined?(Rails) && Rails.env.development?
end

.engineSolidstats::Engine

Get engine instance

Returns:



165
166
167
# File 'lib/solidstats.rb', line 165

def engine
  Engine
end

.ensure_view_component!Boolean

Safely load ViewComponent if not already loaded

Returns:

  • (Boolean)

    True if ViewComponent was loaded successfully



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/solidstats.rb', line 62

def ensure_view_component!
  return true if view_component_available?

  unless defined?(Rails)
    logger.warn "[Solidstats] Rails not available - ViewComponent cannot be loaded"
    return false
  end

  begin
    require "view_component"
    require "view_component/engine"

    # Verify it loaded correctly
    if view_component_available?
      logger.info "[Solidstats] ViewComponent loaded successfully"
      true
    else
      logger.error "[Solidstats] ViewComponent loaded but not properly initialized"
      false
    end
  rescue LoadError => e
    logger.warn "[Solidstats] ViewComponent not available: #{e.message}"
    false
  rescue StandardError => e
    logger.error "[Solidstats] Failed to load ViewComponent: #{e.message}"
    false
  end
end

.environmentString?

Current Rails environment

Returns:

  • (String, nil)

    Environment name or nil if Rails not available



111
112
113
# File 'lib/solidstats.rb', line 111

def environment
  Rails.env if defined?(Rails)
end

.environment_suitable?Boolean

Check if Solidstats can run in current environment

Returns:

  • (Boolean)

    True if environment is suitable

Raises:



154
155
156
157
158
159
160
161
# File 'lib/solidstats.rb', line 154

def environment_suitable?
  unless development?
    raise ConfigurationError,
          "Solidstats can only be used in development mode. Current: #{environment || 'unknown'}"
  end

  true
end

.loggerLogger

Logger instance with fallback

Returns:

  • (Logger)

    Logger instance



141
142
143
# File 'lib/solidstats.rb', line 141

def logger
  @logger ||= build_logger
end

.logger=(custom_logger) ⇒ Object

Set a custom logger

Parameters:

  • custom_logger (Logger)

    Custom logger instance



147
148
149
# File 'lib/solidstats.rb', line 147

def logger=(custom_logger)
  @logger = custom_logger
end

.production?Boolean

Check if running in production mode

Returns:

  • (Boolean)

    True if in production



99
100
101
# File 'lib/solidstats.rb', line 99

def production?
  defined?(Rails) && Rails.env.production?
end

.reset_configuration!Configuration

Reset configuration to defaults

Returns:



135
136
137
# File 'lib/solidstats.rb', line 135

def reset_configuration!
  @configuration = Configuration.new
end

.rootPathname

Returns the absolute path to this gem’s root directory

Returns:

  • (Pathname)

    Gem root path



24
25
26
# File 'lib/solidstats.rb', line 24

def root
  @root ||= Pathname.new(File.dirname(__dir__))
end

.services_pathPathname

Returns the services directory

Returns:

  • (Pathname)

    Services directory path



48
49
50
# File 'lib/solidstats.rb', line 48

def services_path
  @services_path ||= app_path.join("services", "solidstats")
end

.test?Boolean

Check if running in test mode

Returns:

  • (Boolean)

    True if in test



105
106
107
# File 'lib/solidstats.rb', line 105

def test?
  defined?(Rails) && Rails.env.test?
end

.versionString

Returns version string

Returns:

  • (String)

    Version



30
31
32
# File 'lib/solidstats.rb', line 30

def version
  VERSION
end

.view_component_available?Boolean

Check if ViewComponent is available and properly loaded

Returns:

  • (Boolean)

    True if ViewComponent is loaded and usable



54
55
56
57
58
# File 'lib/solidstats.rb', line 54

def view_component_available?
  defined?(ViewComponent::Base) &&
    ViewComponent::Base.respond_to?(:new) &&
    defined?(Rails)
end