| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
| |
This is not perfect but this reset `Pry.line_buffer`. `pry_eval` writes to it
and makes some tests fail randomly. This should probably be rewritten properly
but this hack will do to make the tests pass.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
A bunch of tests were order-dependent and weren't cleaning up properly after
they're executed. This results in complications with #2055 where we want to
randomise our test suite.
With this change every test defines what it needs and then cleans up properly,
instead of relying on the global space and fixtures.
P.S. The specs are still quite messy but this change is a step in the right
direction.
|
|
|
|
|
|
| |
This spec was failing for me locally (but worked well on Circle). The reason
is that `XDG_CONFIG_HOME` is set for me and takes precedence. Therefore, the fix
would be to unset it for the test.
|
| |
|
|
|
|
| |
Env is a helper module to work with environment variables.
|
|
|
|
|
|
|
|
|
| |
References #2054
Using XDG_* paths (if set) with preference higher than the
home dir, for pry config and history files.
Testing: ran `bundle exec rspec`, observed the tests pass.
|
|
|
|
| |
I moved the existing `subject` into the test because it didn't make sense for the second test I added.
|
|
|
|
|
| |
These tests would fail on my machine.
I think it is because I have a ~/.pry_history file.
I modified them to not depend on the state of my machine.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #1991 (Pry in a non-stdin/stdout PTY uses incorrect window size on
non-JRuby platforms)
`Pry::Terminal` was built without custom outputs in mind. We would always assume
that `$stdout` is what the user wants. This contradicted the `output` config
option.
Thanks to `Pry::Output`, which we use internally, we can decorate the output
that the user passes us with "size" methods. If we do that, we get improved
output support for free, so that PTY's `slave` can be passed to Pry and would be
able to determine its size correctly (example from #1991).
I do suspect that there are still some gotchas. Some commands or portions of
code may still be assuming that `$stdout` is the only possible option. This has
to be addressed separately, in the scope of
https://github.com/pry/pry/issues/1988. The more tests we add, the easier it
will be to uncover those spots.
|
| |
|
|
|
|
| |
Fixes #1876 (Make `wtf` show code)
|
|
|
|
|
| |
Although this is more verbose now, it looks more like proper unit tests. The
tester API needs to be revamped because `tester.eval` is *not* unit testing.
|
|
|
|
|
| |
Fixes #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most
operations)
|
|
|
|
| |
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).
|
|
|
|
|
|
| |
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 #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.
|
|
|
|
|
| |
The new command state implementation returns an OpenStruct. On Ruby 1.9
OpenStruct doesn't support `#[]`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
In this change we:
* Used modern RSpec API
* Deleted unused methods
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Some code paths were not covered by unit tests.
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|