pry-yes 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/lib/pry-yes.rb +37 -0
- data/pry-yes.gemspec +23 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a4f8d429a38ff10c172a58bcac591621233c760e
|
4
|
+
data.tar.gz: 9dc14efae94705fc24dbb640071df854a9e1e368
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ef3d47b724ba995f03bfe75245a6b5224caa43cd8d4d24a59a1af3a6dfdcf5d86f4d5add16748ac2c48b5148b3441577f62904517d1f2c5279734679b7c1d09
|
7
|
+
data.tar.gz: f2d8f162a40072b70297ea290bbcec7e2a7ae99a005fd5b83aedaecf23cc4f7ece3aff291f026052cd072ca7dbbe903830a2f1e0a351f556e811927e2821ec34
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Christoffer Hamberg
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# pry-yes
|
2
|
+
|
3
|
+
Pry plugin for re-running the previous command with corrected typos.
|
4
|
+
Based on "Did you mean?" (ships with Ruby > 2.3 or as standalone gem) and inspired by https://github.com/nvbn/thefuck
|
5
|
+
|
6
|
+
[](https://asciinema.org/a/85918)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
$ gem install pry-yes
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
```
|
15
|
+
[1] pry(main)> class Application
|
16
|
+
[1] pry(main)* def self.status
|
17
|
+
[1] pry(main)* "OK!"
|
18
|
+
[1] pry(main)* end
|
19
|
+
[1] pry(main)* end
|
20
|
+
=> :status
|
21
|
+
[2] pry(main)> Aplication.stats
|
22
|
+
NameError: uninitialized constant Aplication
|
23
|
+
Did you mean? Application
|
24
|
+
from (pry):6:in `__pry__'
|
25
|
+
[4] pry(main)> Application.stats
|
26
|
+
NoMethodError: undefined method `stats' for Application:Class
|
27
|
+
Did you mean? status
|
28
|
+
from (pry):7:in `__pry__'
|
29
|
+
[6] pry(main)> Application.status
|
30
|
+
=> "OK!"
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/christofferh/pry-yes.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/pry-yes.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Pry::Commands.create_command "yes" do
|
2
|
+
description 'Re-runs previous command with "Did you mean?" suggestion.'
|
3
|
+
def options(opt)
|
4
|
+
opt.on :d, :debug, 'Debug mode.'
|
5
|
+
end
|
6
|
+
|
7
|
+
def process
|
8
|
+
ex = target.eval("defined?(_ex_) and _ex_")
|
9
|
+
return unless ex && ex.message.include?("Did you mean?")
|
10
|
+
|
11
|
+
matched_exception = ex.message.match(
|
12
|
+
/undefined.*`(.*)'|uninitialized constant (.*)\n/)
|
13
|
+
return unless matched_exception
|
14
|
+
|
15
|
+
typo = matched_exception.captures.compact.first
|
16
|
+
return unless typo
|
17
|
+
|
18
|
+
typo_guess = ex.message.split('Did you mean? ').last.split.first
|
19
|
+
last_command = Pry.history.to_a[-2]
|
20
|
+
guessed_command = last_command.gsub(typo, typo_guess)
|
21
|
+
|
22
|
+
_pry_.input = StringIO.new(guessed_command)
|
23
|
+
rescue => e
|
24
|
+
# Schhh
|
25
|
+
raise e if opts.present?(:debug)
|
26
|
+
ensure
|
27
|
+
if opts.present?(:debug)
|
28
|
+
puts "matched_exception: #{matched_exception}"
|
29
|
+
puts "typo: #{typo}"
|
30
|
+
puts "typo_guess: #{typo_guess}"
|
31
|
+
puts "last_command: #{last_command}"
|
32
|
+
puts "guessed_command: #{guessed_command}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module PryYes; end
|
data/pry-yes.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "pry-yes"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Christoffer Hamberg"]
|
9
|
+
spec.email = ["christoffer.hamberg@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Pry plugin for re-running the previous command with "Did you mean?" suggestion.}
|
12
|
+
spec.homepage = "https://github.com/christofferh/pry-yes"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency 'pry', '~> 0.10.0'
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-yes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christoffer Hamberg
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.10.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- christoffer.hamberg@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/pry-yes.rb
|
68
|
+
- pry-yes.gemspec
|
69
|
+
homepage: https://github.com/christofferh/pry-yes
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.5.1
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Pry plugin for re-running the previous command with "Did you mean?" suggestion.
|
93
|
+
test_files: []
|