pry-editline 1.0.0

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.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /.bundle
2
+ /Gemfile.lock
3
+ /pkg/*
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) Tim Pope
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,91 @@
1
+ pry-editline
2
+ ------------
3
+
4
+ Whenever I'm using IRB or [Pry][], my editor always feels too far away.
5
+ Yes, there are [various gems](http://utilitybelt.rubyforge.org/) out
6
+ there that will let me spawn an editor and evaluate the result, but
7
+ that's not what I need. Usually I'm about 80 characters or so into a
8
+ hairy one-liner when I think, "you know, I really wish I was in Vim
9
+ right about now." In Bash, one can load the current command line into
10
+ an editor with `C-x C-e`. And now, you can do so in IRB and Pry.
11
+
12
+ The gem is named after [Pry][] so that it will be automatically loaded
13
+ as a Pry plugin (and because, let's face it, that's a good train to
14
+ hitch our wagon to). But it also works in IRB if you add `require
15
+ 'pry-editline'` to your `.irbrc`.
16
+
17
+ [Pry]: http://pry.github.com/
18
+
19
+ FAQ
20
+ ---
21
+
22
+ > `C-x C-e` is too hard to type.
23
+
24
+ You can add an alias for it in `~/.inputrc`. Observe:
25
+
26
+ $if Ruby
27
+ "\C-o": "\C-x\C-e"
28
+ $endif
29
+
30
+ Actually, I already added `C-o` for you. So don't add that one. It
31
+ already works. It stands for "open".
32
+
33
+ > It's not working on OS X.
34
+
35
+ By default, readline on OS X uses libedit. I don't know what that means
36
+ exactly other than it leaves you with a horribly crippled readline that
37
+ doesn't work with pry-editline. To link against a different readline,
38
+ pass the `--with-readline-dir=` flag to `./configure`. If you're using
39
+ RVM, pass it to `rvm install`. Or better yet, make it the default:
40
+
41
+ echo rvm_configure_flags=--with-readline-dir=/usr/local >> ~/.rvmrc
42
+
43
+ To *install* a readline to `/usr/local`, you might consider using
44
+ Homebrew. After installing, you need instruct it to link that readline
45
+ into `/usr/local`:
46
+
47
+ brew install readline
48
+ brew link readline
49
+
50
+ Actually for me, it went more like:
51
+
52
+ $ brew install readline
53
+ ...
54
+ $ brew link readline
55
+ Error: readline has multiple installed versions
56
+ $ brew link readline 6.2.1
57
+ Error: readline has multiple installed versions
58
+ $ brew link readline -v6.2.1
59
+ Error: readline has multiple installed versions
60
+ $ brew link -v6.2.1 readline
61
+ Error: readline has multiple installed versions
62
+ $ brew remove readline
63
+ Error: readline has multiple installed versions
64
+ Use `brew remove --force readline` to remove all versions.
65
+ $ brew remove -v6.1 readline
66
+ Error: readline has multiple installed versions
67
+ Use `brew remove --force readline` to remove all versions.
68
+ $ brew remove --force readline
69
+ Uninstalling readline...
70
+ $ brew install readline
71
+ ...
72
+ $ brew link readline
73
+
74
+ Yeah, it's a bit of a pain. Sorry your OS hates you. :(
75
+
76
+ > It's not working with `rails console`/my Bundler setup.
77
+
78
+ [Here's one potential workaround][workaround]. You might have to
79
+ explicitly `require 'pry-editline'` in your `.pryrc`, too.
80
+
81
+ [workaround]: https://github.com/carlhuda/bundler/issues/183#issuecomment-1149953
82
+
83
+ > How does it work?
84
+
85
+ Well first, it overrides `ENV['INPUTRC']` so it can do some magic. And
86
+ then, it does some magic!
87
+
88
+ License
89
+ -------
90
+
91
+ Copyright (c) Tim Pope. MIT License.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :build
3
+
4
+ include_path = "-I#{File.expand_path('../lib', __FILE__)}"
5
+
6
+ task :pry do
7
+ exec 'pry', include_path, '-rpry-editline'
8
+ end
9
+
10
+ task :irb do
11
+ exec 'irb', include_path, '-rpry-editline'
12
+ end
@@ -0,0 +1,60 @@
1
+ module PryEditline
2
+
3
+ def self.editor
4
+ if defined?(Pry)
5
+ Pry.editor
6
+ else
7
+ ENV.values_at('VISUAL', 'EDITOR').compact.first || 'vi'
8
+ end
9
+ end
10
+
11
+ def self.hijack_inputrc
12
+ inputrc = [
13
+ ENV['INPUTRC'],
14
+ (File.expand_path('~/.inputrc') rescue nil),
15
+ '/etc/inputrc'
16
+ ].compact.detect { |x| File.exist?(x) }
17
+
18
+ require 'tempfile'
19
+ file = Tempfile.new('inputrc')
20
+ file.puts '"\C-x\C-l": redraw-current-line'
21
+ file.puts '"\C-x\C-e": " \C-a\t\C-k\C-x\C-l"'
22
+ file.puts '"\C-o": " \C-a\t\C-k\C-x\C-l"'
23
+ file.puts "$include #{inputrc}" if inputrc
24
+ file.close
25
+ ENV['INPUTRC'] = file.path
26
+ end
27
+
28
+ def self.completion_proc
29
+ lambda do |s|
30
+ if Readline.point == 0 && Readline.line_buffer =~ / $/
31
+ require 'tempfile'
32
+ Tempfile.open(['readline-','.rb']) do |f|
33
+ f.puts(Readline.line_buffer[0..-3])
34
+ f.close
35
+ system("#{editor} #{f.path}")
36
+ File.read(f.path).chomp
37
+ end
38
+ else
39
+ yield s
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ if defined?(Pry::InputCompleter)
47
+ PryEditline.hijack_inputrc
48
+ class <<Pry::InputCompleter
49
+ unless method_defined?(:build_completion_proc_without_edit)
50
+ alias build_completion_proc_without_edit build_completion_proc
51
+
52
+ def build_completion_proc(*args)
53
+ PryEditline.completion_proc(&build_completion_proc_without_edit(*args))
54
+ end
55
+ end
56
+ end
57
+ elsif defined?(IRB) && defined?(Readline)
58
+ PryEditline.hijack_inputrc
59
+ Readline.completion_proc = PryEditline.completion_proc(&Readline.completion_proc)
60
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'pry-editline'
6
+ s.version = '1.0.0'
7
+ s.authors = ['Tim Pope']
8
+ s.email = ["ruby@tpop"+'e.org']
9
+ s.homepage = 'https://github.com/tpope/pry-editline'
10
+ s.summary = 'C-x C-e to invoke an editor on the current pry (or irb) line'
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
15
+ s.require_paths = ['lib']
16
+
17
+ s.add_development_dependency 'rake'
18
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pry-editline
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tim Pope
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &83510940 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *83510940
25
+ description:
26
+ email:
27
+ - ruby@tpope.org
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - MIT-LICENSE
35
+ - README.markdown
36
+ - Rakefile
37
+ - lib/pry-editline.rb
38
+ - pry-editline.gemspec
39
+ homepage: https://github.com/tpope/pry-editline
40
+ licenses: []
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 1.8.6
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: C-x C-e to invoke an editor on the current pry (or irb) line
63
+ test_files: []