| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
This will greatly ease Pry support on Ruby 3.0 (when it's out).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a preparational step for #1824
(Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most operations)
Alternative to https://github.com/pry/pry/pull/2030
(config: delete the `control_d_handler` option)
We had to jump a few hoops to change how the handler works. The problem is that
mutation is the default expected behaviour. Therefore, we had to change its
API. There's no need to pass `eval_string` because `pry_instance` already has it
as an attribute.
`config.control_d_handler` is a proxy proc, to preserve backwards compatibility
with users of old signature (one known user is Pry Byebug). The handler will
emit a warning if the old signature is used.
|
|
|
|
|
|
| |
We want to print the calling frame, so we can point out who exactly triggered
it. The current behaviour is less useful (we print the line that called the
warning).
|
|\
| |
| | |
Add Pry::Warning
|
| |
| |
| |
| |
| |
| | |
Quite often, when we deprecate APIs, we want to print a warning. Such a warning
would be hard to track without a file and line location. We are trying to be a
good citizen and print warnings like Ruby does it.
|
|/ |
|
|
|
|
|
|
| |
Keeping this in a constant makes it really hard to test. Moving it to the config
and making it configurable seems to be sensible. Now we have a new option and a
lot of tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #2006 (show-source formatting bug in From)
In order to test this I had to build Pry from master locally and install
it. When I ran `String#initialize` I saw an error that `has_pry_doc` is
undefined on the Config class. This makes sense. This option is defined in the
pry-doc plugin.
As a workaround, I had to change the check to `defined?`. However, in the
future, we should make Pry plugin-agnostic - strictly no plugin checks in the
code.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #2007 (Performance slowdown on entering lines)
By default, when we call `@history.count`, we actually call
`Readline::HISTORY.count`. It turns out this is a very expensive call (probably
`O(n)`). My history file has over 50k lines and calling `count` makes the
problem noticeable by spamming `Enter` as demostrated in the GIF in the issue.
We fix this issue by caching history line count and incrementing/resetting when
needed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #1843 (Rework the Pry config)
There are a few breaking changes. They are mostly minor, so I decided not to
indroduce deprecations because it will considerable slow things down.
Key changes:
* `Pry.lazy` was replaced with `Pry::Configuration::LazyValue`
The config accepts three values now `LazyValue`, `MemoizedValue` and simply
`Value`. The main difference is that:
- `Value` is any value, including procs (so that an option returns a raw
proc)
- `LazyValue` is a proc that is call on every invocation of an option
- `MemoizedValue` is a value that is called only once (and then the option
always returns the return value of the )
* `Pry.config.history` was a meta-option that held suboptions. However, the new
config doesn't permit that (unless you know what you do)
Instead, we introduce a few options. For example:
- `Pry.config.history.histignore` becomes `Pry.config.history_ignorelist`
- `Pry.config.history.file` becomes `Pry.config.history_file`
- and so on
This was done so we can simplify configuration merging. Inlining option makes
configuration implementation simpler, without losing much. The rule is that
you want to keep your options under your prefix (if you are a
plugin). Therefore, say, `Pry.config.pry_rescue.*` should be
`Pry.config.pry_rescue_*` if you need merging.
The rest should behave in a similar fashion (and I rely heavily on our test
suite to claim so).
|
|
|
|
|
|
|
| |
This is one of preliminary steps for #1843 (Rework the Pry config).
In this commit we replace calls to `Pry::Config` where possible, therefore we
reduce coupling between the config and other components.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change is aimed to simplify #1843 (Rework the Pry config).
Current command state implementation gets in the way. We would like to simplify
the Config class. The current implementation penetrates Pry codebase everywhere,
and during my rework of the config I discovered that `watch` uses global command
state.
It means the state should survive `Pry.new` calls. With my (unpublished yet)
implementation, the `watch` command fails to do so. I realised that we can
refactor command state implementation to be global. It makes sense to me and
also helps with the Config refactoring.
With help of a dedicated class we can easily manage the command
state (resetting).
|
|
|
|
|
|
| |
It seems like this command defines options on the config as the user uses
Pry. This is wrong. We have command state API for this purpose. Configuration
should be done before Pry is initialized.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
This makes `Pry::Config` a bit cleaner and history code is better off in
`Pry::History`, since it's probably the most expected location.
|
|
|
|
|
| |
The name strongly suggests that this method belongs to `Pry::Editor` and it
makes no sense to have it on `Pry` class.
|
| |
|
|
|
|
| |
We also refactor it to use `case` instead of `if`.
|
|
|
|
|
|
| |
This has been "backwards compatible" for 8 years or so, so it's time to drop it
to reduce complexity of the codebase. I am not even sure what this is about and
it's likely not relevant.
|
|
|
|
|
| |
This order makes more sense to me because it follows traditional scheme: class
methods first, instance methods next.
|
| |
|
| |
|
|
|
|
| |
This was deprecated 4 years ago, so I guess it's time to remove it.
|
|
|
|
|
|
|
| |
In this change we:
* Used modern RSpec API
* Deleted unused methods
|
|
|
|
|
|
|
|
|
| |
* the name of the method is not a verb, which is confusing
* commands have aliases
* we can deprecate commands at the place where they are defined. We would've
avoided this case with `edit-method` where the command was deprecated for
years but never removed. This is because it was deprecated using
`#disabled_commands` at an unexpected location.
|
|
|
|
| |
These comands were 'disabled' 6 years ago, it's about damn time to delete them.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
First of all, we move the spec file from `spec` to `spec/helpers`. This is where
it is supposed to be.
Next, we add tests for all the methods that the module defines. During this
process I had to change `module_function` to `extend self`. Rubocop doesn't like
it for some unknown to me reason, so I had to disable the rule. There's no harm
in doing so.
Finally, I refactored some methods (low-hanging fruits only) and discovered that
the `command_error` method is not necessary at all.
All in all, this module is a lot better now but I feel like it shouldn't exist
at all, since almost all methods are very specific to certain Pry commands. It's
hardly a general purpose module for Pry plugins.
|
|
|
|
|
|
|
|
|
| |
Changes:
* method extractions
* indentation fixes
* brackets for methods
* clearer variable names
|
| |
|
|
|
|
| |
This is needed for $DEFAULT_OUTPUT to work. Otherwise it's equal to `nil`.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
This moves all the code related syntax highlighting and tokenization to a
wrapper class of CodeRay. Benefits:
* we reduce duplication (no need to call `scan(code, :ruby).term` everywhere)
* swapping CodeRay becomes easier because it's isolated in one class
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|