-
Notifications
You must be signed in to change notification settings - Fork 0
Add custom package support to RelinePac configuration #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5f37f3f
Add custom package support to RelinePac configuration
Syati af0e41e
Update lib/reline_pac/config.rb
Syati 7e87010
Update spec/reline_pac/config_spec.rb
Syati ed2e3b6
Merge branch 'main' into custom_package
Syati 8999900
Enhance .irbrc and README with detailed configuration options for Rel…
Syati bf4b5b9
Refactor add_package method to simplify block presence check
Syati 4b88473
Update config_spec to raise ArgumentError when no block is given to a…
Syati File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module RelinePac | ||
| module Packages | ||
| # Custom holds user-defined packages added via Config#add_package. | ||
| module Custom | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'spec_helper' | ||
|
|
||
| RSpec.describe RelinePac::Config do | ||
| describe '#add_package' do | ||
| it 'adds a custom method to Reline::LineEditor' do | ||
| config = described_class.new | ||
|
|
||
| config.add_package(:test_method) do |_key| | ||
| 'test result' | ||
| end | ||
|
|
||
| # Verify the method was added | ||
| line_editor = Reline::LineEditor.allocate | ||
| expect(line_editor).to respond_to(:test_method) | ||
| end | ||
|
|
||
| it 'allows calling the custom method' do | ||
| config = described_class.new | ||
|
|
||
| config.add_package(:custom_insert) do |_key| | ||
| insert_text('custom') if respond_to?(:insert_text) | ||
| end | ||
|
|
||
| line_editor_class = Class.new do | ||
| prepend(Reline::LineEditor.ancestors.find { |m| m.method_defined?(:custom_insert, false) }) | ||
|
|
||
| def insert_text(text) | ||
| @inserted = text | ||
| end | ||
|
|
||
| attr_reader :inserted | ||
| end | ||
|
|
||
| instance = line_editor_class.new | ||
| instance.custom_insert(nil) | ||
| expect(instance.inserted).to eq('custom') | ||
| end | ||
|
|
||
| it 'allows overriding methods with later definitions' do | ||
| config = described_class.new | ||
|
|
||
| # Add first package | ||
| config.add_package(:shared_method) do |_key| | ||
| 'first' | ||
| end | ||
|
|
||
| # Add second package with same method name | ||
| config.add_package(:shared_method) do |_key| | ||
| 'second' | ||
| end | ||
|
|
||
| # The second one should take precedence (prepend behavior) | ||
| line_editor = Reline::LineEditor.allocate | ||
| expect(line_editor.shared_method(nil)).to eq('second') | ||
| end | ||
|
|
||
| it 'raise ArgumentError when no block is given' do | ||
| config = described_class.new | ||
| expect { config.add_package(:no_block_method) }.to raise_error(ArgumentError) | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.