interactive_editor 0.0.1 → 0.0.2
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/README.md +23 -2
- data/Rakefile +1 -0
- data/interactive_editor.gemspec +1 -1
- data/lib/interactive_editor.rb +23 -21
- metadata +42 -31
data/README.md
CHANGED
@@ -3,7 +3,28 @@
|
|
3
3
|
|
4
4
|
cf. my blog post: [Integrating vim and irb](http://zegoggl.es/2009/04/integrating-vim-and-irb.html).
|
5
5
|
|
6
|
+
## Usage
|
6
7
|
|
7
|
-
|
8
|
+
$ gem install interactive_editor
|
8
9
|
|
9
|
-
|
10
|
+
Put the following in your .irbrc:
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'interactive_editor'
|
14
|
+
|
15
|
+
Then, from within irb:
|
16
|
+
|
17
|
+
$ irb
|
18
|
+
> vi
|
19
|
+
> vi 'filename.rb'
|
20
|
+
> [emacs|vim|nano|mate] ...
|
21
|
+
|
22
|
+
To try it out without installing the gem:
|
23
|
+
|
24
|
+
$ git clone git://github.com/jberkel/interactive_editor.git
|
25
|
+
$ cd interactive_editor
|
26
|
+
$ rake console
|
27
|
+
|
28
|
+
## Credits
|
29
|
+
|
30
|
+
Giles Bowkett, Greg Brown, and several audience members from Giles' Ruby East presentation: [Use vi or any text editor from within IRB](http://gilesbowkett.blogspot.com/2007/10/use-vi-or-any-text-editor-from-within.html).
|
data/Rakefile
CHANGED
data/interactive_editor.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'interactive_editor'
|
10
|
-
s.version = '0.0.
|
10
|
+
s.version = '0.0.2'
|
11
11
|
s.date = '2010-05-16'
|
12
12
|
s.rubyforge_project = 'interactive_editor'
|
13
13
|
|
data/lib/interactive_editor.rb
CHANGED
@@ -7,7 +7,7 @@ require 'fileutils'
|
|
7
7
|
require 'tempfile'
|
8
8
|
|
9
9
|
class InteractiveEditor
|
10
|
-
VERSION = '0.0.
|
10
|
+
VERSION = '0.0.2'
|
11
11
|
|
12
12
|
attr_accessor :editor
|
13
13
|
|
@@ -23,7 +23,12 @@ class InteractiveEditor
|
|
23
23
|
(@file && File.exist?(@file.path)) ? @file : Tempfile.new(["irb_tempfile", ".rb"])
|
24
24
|
end
|
25
25
|
mtime = File.stat(@file.path).mtime
|
26
|
-
|
26
|
+
|
27
|
+
if (args = @editor.split(/\s+/)).size > 1
|
28
|
+
Exec.system(args[0], *(args[1..-1] << @file.path))
|
29
|
+
else
|
30
|
+
Exec.system(@editor, @file.path)
|
31
|
+
end
|
27
32
|
|
28
33
|
execute if mtime < File.stat(@file.path).mtime
|
29
34
|
end
|
@@ -33,30 +38,28 @@ class InteractiveEditor
|
|
33
38
|
end
|
34
39
|
|
35
40
|
def self.edit(editor, file=nil)
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
IRB.conf[:interactive_editors][editor] = InteractiveEditor.new(editor)
|
40
|
-
end
|
41
|
-
IRB.conf[:interactive_editors][editor].edit(file)
|
41
|
+
#maybe serialise last file to disk, for recovery
|
42
|
+
(IRB.conf[:interactive_editors] ||=
|
43
|
+
Hash.new { |h,k| h[k] = InteractiveEditor.new(k) })[editor].edit(file)
|
42
44
|
end
|
43
45
|
|
44
46
|
module Exec
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
def system(*args)
|
53
|
-
Process.waitpid(Spoon.spawnp(*args))
|
47
|
+
module Java
|
48
|
+
def system(file, *args)
|
49
|
+
require 'spoon'
|
50
|
+
Process.waitpid(Spoon.spawnp(file, *args))
|
51
|
+
rescue Errno::ECHILD => e
|
52
|
+
raise "error exec'ing #{file}: #{e}"
|
54
53
|
end
|
55
|
-
|
54
|
+
end
|
55
|
+
|
56
|
+
module MRI
|
56
57
|
def system(file, *args)
|
57
|
-
Kernel::system(file, *args)
|
58
|
+
Kernel::system(file, *args) or raise "error exec'ing #{file}: #{$?}"
|
58
59
|
end
|
59
60
|
end
|
61
|
+
|
62
|
+
extend RUBY_PLATFORM =~ /java/ ? Java : MRI
|
60
63
|
end
|
61
64
|
|
62
65
|
module Editors
|
@@ -74,5 +77,4 @@ class InteractiveEditor
|
|
74
77
|
end
|
75
78
|
end
|
76
79
|
|
77
|
-
|
78
|
-
|
80
|
+
include InteractiveEditor::Editors
|
metadata
CHANGED
@@ -1,27 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interactive_editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
|
-
|
12
|
+
- Jan Berkel
|
8
13
|
autorequire:
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-05-16 00:00:00 +
|
17
|
+
date: 2010-05-16 00:00:00 +01:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: spoon
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 0
|
30
|
+
- 1
|
31
|
+
version: 0.0.1
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
description: Use vim (or any other text editor) from inside irb to quickly test & write new code.
|
26
35
|
email: jan.berkel@gmail.com
|
27
36
|
executables: []
|
@@ -29,39 +38,41 @@ executables: []
|
|
29
38
|
extensions: []
|
30
39
|
|
31
40
|
extra_rdoc_files:
|
32
|
-
|
33
|
-
|
41
|
+
- README.md
|
42
|
+
- LICENSE
|
34
43
|
files:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
44
|
+
- LICENSE
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- interactive_editor.gemspec
|
48
|
+
- lib/interactive_editor.rb
|
40
49
|
has_rdoc: true
|
41
50
|
homepage: http://github.com/jberkel/interactive_editor
|
42
51
|
licenses: []
|
43
52
|
|
44
53
|
post_install_message:
|
45
54
|
rdoc_options:
|
46
|
-
|
55
|
+
- --charset=UTF-8
|
47
56
|
require_paths:
|
48
|
-
|
57
|
+
- lib
|
49
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
59
|
requirements:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
55
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
66
|
requirements:
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
61
72
|
requirements: []
|
62
73
|
|
63
74
|
rubyforge_project: interactive_editor
|
64
|
-
rubygems_version: 1.3.
|
75
|
+
rubygems_version: 1.3.6
|
65
76
|
signing_key:
|
66
77
|
specification_version: 2
|
67
78
|
summary: Interactive editing in irb.
|