Class: RailsConsolePro::Configuration
- Inherits:
-
Object
- Object
- RailsConsolePro::Configuration
- Defined in:
- lib/rails_console_pro/configuration.rb
Overview
Configuration class for Enhanced Console Printer
Constant Summary collapse
- COLOR_SCHEMES =
Color scheme presets
{ dark: { header: :bright_blue, footer: :bright_blue, border: :dim, attribute_key: :blue, attribute_value_nil: :white, attribute_value_numeric: :bright_blue, attribute_value_boolean: :green, attribute_value_time: :blue, attribute_value_string: :white, error: :red, success: :green, warning: :yellow, info: :cyan }, light: { header: :bright_cyan, footer: :bright_cyan, border: :dim, attribute_key: :bright_blue, attribute_value_nil: :black, attribute_value_numeric: :blue, attribute_value_boolean: :green, attribute_value_time: :cyan, attribute_value_string: :black, error: :red, success: :green, warning: :yellow, info: :cyan }, custom: {} # Will be populated by user }.freeze
Instance Attribute Summary collapse
-
#active_record_printer_enabled ⇒ Object
Returns the value of attribute active_record_printer_enabled.
-
#border_char ⇒ Object
Returns the value of attribute border_char.
-
#collection_printer_enabled ⇒ Object
Returns the value of attribute collection_printer_enabled.
-
#color_scheme ⇒ Object
Color customization.
-
#colors ⇒ Object
Returns the value of attribute colors.
-
#compare_command_enabled ⇒ Object
Returns the value of attribute compare_command_enabled.
-
#diff_command_enabled ⇒ Object
Returns the value of attribute diff_command_enabled.
-
#enabled ⇒ Object
Feature toggles.
-
#explain_command_enabled ⇒ Object
Returns the value of attribute explain_command_enabled.
-
#export_enabled ⇒ Object
Returns the value of attribute export_enabled.
-
#header_width ⇒ Object
Returns the value of attribute header_width.
-
#introspect_command_enabled ⇒ Object
Returns the value of attribute introspect_command_enabled.
-
#max_depth ⇒ Object
Style customization.
-
#navigate_command_enabled ⇒ Object
Returns the value of attribute navigate_command_enabled.
-
#pagination_enabled ⇒ Object
Pagination settings.
-
#pagination_page_size ⇒ Object
Returns the value of attribute pagination_page_size.
-
#pagination_threshold ⇒ Object
Returns the value of attribute pagination_threshold.
-
#profile_command_enabled ⇒ Object
Returns the value of attribute profile_command_enabled.
-
#profile_duplicate_query_threshold ⇒ Object
Returns the value of attribute profile_duplicate_query_threshold.
-
#profile_max_saved_queries ⇒ Object
Returns the value of attribute profile_max_saved_queries.
-
#profile_slow_query_threshold ⇒ Object
Profiling settings.
-
#query_builder_command_enabled ⇒ Object
Returns the value of attribute query_builder_command_enabled.
-
#queue_command_enabled ⇒ Object
Returns the value of attribute queue_command_enabled.
-
#relation_printer_enabled ⇒ Object
Returns the value of attribute relation_printer_enabled.
-
#schema_command_enabled ⇒ Object
Returns the value of attribute schema_command_enabled.
-
#show_sql_by_default ⇒ Object
Returns the value of attribute show_sql_by_default.
-
#show_welcome_message ⇒ Object
Returns the value of attribute show_welcome_message.
-
#snippet_store_path ⇒ Object
Returns the value of attribute snippet_store_path.
-
#snippets_command_enabled ⇒ Object
Returns the value of attribute snippets_command_enabled.
-
#stats_command_enabled ⇒ Object
Returns the value of attribute stats_command_enabled.
-
#stats_large_table_threshold ⇒ Object
Stats calculation settings.
-
#stats_skip_distinct_threshold ⇒ Object
Returns the value of attribute stats_skip_distinct_threshold.
-
#type_colors ⇒ Object
Type-specific colors (for schema printer).
-
#validator_colors ⇒ Object
Validator colors (for schema printer).
Instance Method Summary collapse
-
#disable_all ⇒ Object
Disable all features.
-
#enable_all ⇒ Object
Enable all features.
-
#get_color(key) ⇒ Object
Get a color value.
-
#get_type_color(type) ⇒ Object
Get type color.
-
#get_validator_color(validator_type) ⇒ Object
Get validator color.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#reset ⇒ Object
Reset to defaults.
-
#set_color(key, value) ⇒ Object
Set a custom color.
-
#set_type_color(type, color) ⇒ Object
Set type color.
-
#set_validator_color(validator_type, color) ⇒ Object
Set validator color.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/rails_console_pro/configuration.rb', line 94 def initialize # Default feature toggles - all enabled @enabled = true @schema_command_enabled = true @explain_command_enabled = true @navigate_command_enabled = true @stats_command_enabled = true @diff_command_enabled = true @snippets_command_enabled = true @profile_command_enabled = true @queue_command_enabled = true @introspect_command_enabled = true @compare_command_enabled = true @query_builder_command_enabled = true @active_record_printer_enabled = true @relation_printer_enabled = true @collection_printer_enabled = true @export_enabled = true @snippet_store_path = default_snippet_store_path # Default color scheme @color_scheme = :dark @colors = COLOR_SCHEMES[:dark].dup # Default style options @max_depth = 10 @show_sql_by_default = false = true @border_char = "─" @header_width = 60 # Default type colors @type_colors = { integer: :bright_blue, bigint: :bright_blue, decimal: :bright_blue, float: :bright_blue, string: :green, text: :green, datetime: :cyan, timestamp: :cyan, date: :cyan, time: :cyan, boolean: :magenta, json: :yellow, jsonb: :yellow } # Default validator colors @validator_colors = { 'PresenceValidator' => :red, 'UniquenessValidator' => :magenta, 'LengthValidator' => :cyan, 'FormatValidator' => :yellow, 'NumericalityValidator' => :blue, 'InclusionValidator' => :green, 'ExclusionValidator' => :red, 'ConfirmationValidator' => :cyan, 'AcceptanceValidator' => :green } # Default pagination settings @pagination_enabled = true @pagination_threshold = 10 # Automatically paginate collections with 10+ items @pagination_page_size = 5 # Show 5 records per page # Default stats calculation settings @stats_large_table_threshold = 10_000 # Consider table large if it has 10k+ records @stats_skip_distinct_threshold = 10_000 # Skip distinct count for tables with 10k+ records # Default profiling settings @profile_slow_query_threshold = 100.0 # milliseconds @profile_duplicate_query_threshold = 2 @profile_max_saved_queries = 10 end |
Instance Attribute Details
#active_record_printer_enabled ⇒ Object
Returns the value of attribute active_record_printer_enabled.
57 58 59 |
# File 'lib/rails_console_pro/configuration.rb', line 57 def active_record_printer_enabled @active_record_printer_enabled end |
#border_char ⇒ Object
Returns the value of attribute border_char.
71 72 73 |
# File 'lib/rails_console_pro/configuration.rb', line 71 def border_char @border_char end |
#collection_printer_enabled ⇒ Object
Returns the value of attribute collection_printer_enabled.
59 60 61 |
# File 'lib/rails_console_pro/configuration.rb', line 59 def collection_printer_enabled @collection_printer_enabled end |
#color_scheme ⇒ Object
Color customization
64 65 66 |
# File 'lib/rails_console_pro/configuration.rb', line 64 def color_scheme @color_scheme end |
#colors ⇒ Object
Returns the value of attribute colors.
65 66 67 |
# File 'lib/rails_console_pro/configuration.rb', line 65 def colors @colors end |
#compare_command_enabled ⇒ Object
Returns the value of attribute compare_command_enabled.
55 56 57 |
# File 'lib/rails_console_pro/configuration.rb', line 55 def compare_command_enabled @compare_command_enabled end |
#diff_command_enabled ⇒ Object
Returns the value of attribute diff_command_enabled.
50 51 52 |
# File 'lib/rails_console_pro/configuration.rb', line 50 def diff_command_enabled @diff_command_enabled end |
#enabled ⇒ Object
Feature toggles
45 46 47 |
# File 'lib/rails_console_pro/configuration.rb', line 45 def enabled @enabled end |
#explain_command_enabled ⇒ Object
Returns the value of attribute explain_command_enabled.
47 48 49 |
# File 'lib/rails_console_pro/configuration.rb', line 47 def explain_command_enabled @explain_command_enabled end |
#export_enabled ⇒ Object
Returns the value of attribute export_enabled.
60 61 62 |
# File 'lib/rails_console_pro/configuration.rb', line 60 def export_enabled @export_enabled end |
#header_width ⇒ Object
Returns the value of attribute header_width.
72 73 74 |
# File 'lib/rails_console_pro/configuration.rb', line 72 def header_width @header_width end |
#introspect_command_enabled ⇒ Object
Returns the value of attribute introspect_command_enabled.
54 55 56 |
# File 'lib/rails_console_pro/configuration.rb', line 54 def introspect_command_enabled @introspect_command_enabled end |
#max_depth ⇒ Object
Style customization
68 69 70 |
# File 'lib/rails_console_pro/configuration.rb', line 68 def max_depth @max_depth end |
#navigate_command_enabled ⇒ Object
Returns the value of attribute navigate_command_enabled.
48 49 50 |
# File 'lib/rails_console_pro/configuration.rb', line 48 def navigate_command_enabled @navigate_command_enabled end |
#pagination_enabled ⇒ Object
Pagination settings
81 82 83 |
# File 'lib/rails_console_pro/configuration.rb', line 81 def pagination_enabled @pagination_enabled end |
#pagination_page_size ⇒ Object
Returns the value of attribute pagination_page_size.
83 84 85 |
# File 'lib/rails_console_pro/configuration.rb', line 83 def pagination_page_size @pagination_page_size end |
#pagination_threshold ⇒ Object
Returns the value of attribute pagination_threshold.
82 83 84 |
# File 'lib/rails_console_pro/configuration.rb', line 82 def pagination_threshold @pagination_threshold end |
#profile_command_enabled ⇒ Object
Returns the value of attribute profile_command_enabled.
52 53 54 |
# File 'lib/rails_console_pro/configuration.rb', line 52 def profile_command_enabled @profile_command_enabled end |
#profile_duplicate_query_threshold ⇒ Object
Returns the value of attribute profile_duplicate_query_threshold.
91 92 93 |
# File 'lib/rails_console_pro/configuration.rb', line 91 def profile_duplicate_query_threshold @profile_duplicate_query_threshold end |
#profile_max_saved_queries ⇒ Object
Returns the value of attribute profile_max_saved_queries.
92 93 94 |
# File 'lib/rails_console_pro/configuration.rb', line 92 def profile_max_saved_queries @profile_max_saved_queries end |
#profile_slow_query_threshold ⇒ Object
Profiling settings
90 91 92 |
# File 'lib/rails_console_pro/configuration.rb', line 90 def profile_slow_query_threshold @profile_slow_query_threshold end |
#query_builder_command_enabled ⇒ Object
Returns the value of attribute query_builder_command_enabled.
56 57 58 |
# File 'lib/rails_console_pro/configuration.rb', line 56 def query_builder_command_enabled @query_builder_command_enabled end |
#queue_command_enabled ⇒ Object
Returns the value of attribute queue_command_enabled.
53 54 55 |
# File 'lib/rails_console_pro/configuration.rb', line 53 def queue_command_enabled @queue_command_enabled end |
#relation_printer_enabled ⇒ Object
Returns the value of attribute relation_printer_enabled.
58 59 60 |
# File 'lib/rails_console_pro/configuration.rb', line 58 def relation_printer_enabled @relation_printer_enabled end |
#schema_command_enabled ⇒ Object
Returns the value of attribute schema_command_enabled.
46 47 48 |
# File 'lib/rails_console_pro/configuration.rb', line 46 def schema_command_enabled @schema_command_enabled end |
#show_sql_by_default ⇒ Object
Returns the value of attribute show_sql_by_default.
69 70 71 |
# File 'lib/rails_console_pro/configuration.rb', line 69 def show_sql_by_default @show_sql_by_default end |
#show_welcome_message ⇒ Object
Returns the value of attribute show_welcome_message.
70 71 72 |
# File 'lib/rails_console_pro/configuration.rb', line 70 def end |
#snippet_store_path ⇒ Object
Returns the value of attribute snippet_store_path.
61 62 63 |
# File 'lib/rails_console_pro/configuration.rb', line 61 def snippet_store_path @snippet_store_path end |
#snippets_command_enabled ⇒ Object
Returns the value of attribute snippets_command_enabled.
51 52 53 |
# File 'lib/rails_console_pro/configuration.rb', line 51 def snippets_command_enabled @snippets_command_enabled end |
#stats_command_enabled ⇒ Object
Returns the value of attribute stats_command_enabled.
49 50 51 |
# File 'lib/rails_console_pro/configuration.rb', line 49 def stats_command_enabled @stats_command_enabled end |
#stats_large_table_threshold ⇒ Object
Stats calculation settings
86 87 88 |
# File 'lib/rails_console_pro/configuration.rb', line 86 def stats_large_table_threshold @stats_large_table_threshold end |
#stats_skip_distinct_threshold ⇒ Object
Returns the value of attribute stats_skip_distinct_threshold.
87 88 89 |
# File 'lib/rails_console_pro/configuration.rb', line 87 def stats_skip_distinct_threshold @stats_skip_distinct_threshold end |
#type_colors ⇒ Object
Type-specific colors (for schema printer)
75 76 77 |
# File 'lib/rails_console_pro/configuration.rb', line 75 def type_colors @type_colors end |
#validator_colors ⇒ Object
Validator colors (for schema printer)
78 79 80 |
# File 'lib/rails_console_pro/configuration.rb', line 78 def validator_colors @validator_colors end |
Instance Method Details
#disable_all ⇒ Object
Disable all features
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/rails_console_pro/configuration.rb', line 213 def disable_all @enabled = false @schema_command_enabled = false @explain_command_enabled = false @navigate_command_enabled = false @stats_command_enabled = false @diff_command_enabled = false @queue_command_enabled = false @introspect_command_enabled = false @compare_command_enabled = false @query_builder_command_enabled = false @active_record_printer_enabled = false @relation_printer_enabled = false @collection_printer_enabled = false @export_enabled = false end |
#enable_all ⇒ Object
Enable all features
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/rails_console_pro/configuration.rb', line 231 def enable_all @enabled = true @schema_command_enabled = true @explain_command_enabled = true @navigate_command_enabled = true @stats_command_enabled = true @diff_command_enabled = true @queue_command_enabled = true @introspect_command_enabled = true @compare_command_enabled = true @query_builder_command_enabled = true @active_record_printer_enabled = true @relation_printer_enabled = true @collection_printer_enabled = true @export_enabled = true end |
#get_color(key) ⇒ Object
Get a color value
186 187 188 |
# File 'lib/rails_console_pro/configuration.rb', line 186 def get_color(key) @colors[key.to_sym] || :white end |
#get_type_color(type) ⇒ Object
Get type color
197 198 199 |
# File 'lib/rails_console_pro/configuration.rb', line 197 def get_type_color(type) @type_colors[type.to_sym] || :white end |
#get_validator_color(validator_type) ⇒ Object
Get validator color
208 209 210 |
# File 'lib/rails_console_pro/configuration.rb', line 208 def get_validator_color(validator_type) @validator_colors[validator_type.to_s] || :white end |
#reset ⇒ Object
Reset to defaults
249 250 251 |
# File 'lib/rails_console_pro/configuration.rb', line 249 def reset initialize end |
#set_color(key, value) ⇒ Object
Set a custom color
179 180 181 182 183 |
# File 'lib/rails_console_pro/configuration.rb', line 179 def set_color(key, value) @colors = @colors.dup unless @colors.frozen? @colors[key.to_sym] = value.to_sym @color_scheme = :custom end |
#set_type_color(type, color) ⇒ Object
Set type color
191 192 193 194 |
# File 'lib/rails_console_pro/configuration.rb', line 191 def set_type_color(type, color) @type_colors = @type_colors.dup if @type_colors.frozen? @type_colors[type.to_sym] = color.to_sym end |
#set_validator_color(validator_type, color) ⇒ Object
Set validator color
202 203 204 205 |
# File 'lib/rails_console_pro/configuration.rb', line 202 def set_validator_color(validator_type, color) @validator_colors = @validator_colors.dup if @validator_colors.frozen? @validator_colors[validator_type.to_s] = color.to_sym end |