Class: Consolle::Config
- Inherits:
-
Object
- Object
- Consolle::Config
- Defined in:
- lib/consolle/config.rb
Overview
Configuration loader for .consolle.yml
Constant Summary collapse
- CONFIG_FILENAME =
'.consolle.yml'- DEFAULT_PROMPT_PATTERN =
Default prompt pattern that matches various console prompts
-
Custom sentinel: u001Eu001F<CONSOLLE>u001Fu001E
-
Rails app prompts: app(env)> or app(env):001>
-
IRB prompts: irb(main):001:0> or irb(main):001>
-
Generic prompts: >> or >
-
/^[^\w]*(\u001E\u001F<CONSOLLE>\u001F\u001E|\w+[-_]?\w*\([^)]*\)(:\d+)?>|irb\([^)]+\):\d+:?\d*[>*]|>>|>)\s*$/- VALID_MODES =
Valid supervisor modes
-
pty: PTY-based, supports custom command (local/remote)
-
embed-irb: Pure IRB embedding (Ruby 3.3+, local only)
-
embed-rails: Rails console embedding (Ruby 3.3+, local only)
-
%w[pty embed-irb embed-rails].freeze
- DEFAULT_MODE =
:pty- DEFAULT_COMMAND =
'bin/rails console'
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#prompt_pattern ⇒ Object
readonly
Returns the value of attribute prompt_pattern.
-
#rails_root ⇒ Object
readonly
Returns the value of attribute rails_root.
-
#raw_prompt_pattern ⇒ Object
readonly
Returns the value of attribute raw_prompt_pattern.
Class Method Summary collapse
Instance Method Summary collapse
-
#custom_prompt_pattern? ⇒ Boolean
Check if a custom prompt pattern is configured.
-
#initialize(rails_root) ⇒ Config
constructor
A new instance of Config.
-
#prompt_pattern_description ⇒ Object
Get human-readable description of expected prompt patterns.
Constructor Details
#initialize(rails_root) ⇒ Config
Returns a new instance of Config.
27 28 29 30 31 32 33 34 |
# File 'lib/consolle/config.rb', line 27 def initialize(rails_root) @rails_root = rails_root @config = load_config @raw_prompt_pattern = @config['prompt_pattern'] @prompt_pattern = parse_prompt_pattern(@raw_prompt_pattern) @mode = parse_mode(@config['mode']) @command = @config['command'] || DEFAULT_COMMAND end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
25 26 27 |
# File 'lib/consolle/config.rb', line 25 def command @command end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
25 26 27 |
# File 'lib/consolle/config.rb', line 25 def mode @mode end |
#prompt_pattern ⇒ Object (readonly)
Returns the value of attribute prompt_pattern.
25 26 27 |
# File 'lib/consolle/config.rb', line 25 def prompt_pattern @prompt_pattern end |
#rails_root ⇒ Object (readonly)
Returns the value of attribute rails_root.
25 26 27 |
# File 'lib/consolle/config.rb', line 25 def rails_root @rails_root end |
#raw_prompt_pattern ⇒ Object (readonly)
Returns the value of attribute raw_prompt_pattern.
25 26 27 |
# File 'lib/consolle/config.rb', line 25 def raw_prompt_pattern @raw_prompt_pattern end |
Class Method Details
.load(rails_root) ⇒ Object
36 37 38 |
# File 'lib/consolle/config.rb', line 36 def self.load(rails_root) new(rails_root) end |
Instance Method Details
#custom_prompt_pattern? ⇒ Boolean
Check if a custom prompt pattern is configured
41 42 43 |
# File 'lib/consolle/config.rb', line 41 def custom_prompt_pattern? !@raw_prompt_pattern.nil? end |
#prompt_pattern_description ⇒ Object
Get human-readable description of expected prompt patterns
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/consolle/config.rb', line 46 def prompt_pattern_description if custom_prompt_pattern? "Custom pattern: #{@raw_prompt_pattern}" else " Default patterns:\n - app(env)> or app(env):001> (Rails console)\n - irb(main):001:0> (IRB)\n - >> or > (Generic)\n DESC\n end\nend\n".strip |