ichverstehe-soma 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +18 -0
- data/lib/soma.rb +38 -0
- data/soma.gemspec +17 -0
- metadata +55 -0
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= Soma
|
2
|
+
A shot at implementing a REPL-like feature for vim (and everything else able to write to text files).
|
3
|
+
|
4
|
+
== Use It!
|
5
|
+
Add the following to your <tt>~/.irbrc</tt>:
|
6
|
+
|
7
|
+
require 'soma'
|
8
|
+
Soma.start
|
9
|
+
|
10
|
+
When you start IRB Soma will listen on a file named <tt>/tmp/username_somarepl_buffer</tt> and execute everything added there in your IRB session.
|
11
|
+
|
12
|
+
(And for the sake of God, use Wirble for a prettier IRB!)
|
13
|
+
|
14
|
+
== Vim plugin
|
15
|
+
Copy <tt>plugins/soma.vim</tt> to <tt>~/.vim/plugin/</tt>. The default mapping is <tt>Ctrl-c Ctrl-c</tt>, which sends the current paragraph or visual selection to IRB.
|
16
|
+
|
17
|
+
== Quirks & Annoyances
|
18
|
+
* Commands are added to IRB history, but you have to go one item back in your history or invoke some command before it's updated.
|
data/lib/soma.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
|
3
|
+
Thread.abort_on_exception = true
|
4
|
+
|
5
|
+
class IRB::Irb
|
6
|
+
attr_writer :context
|
7
|
+
end
|
8
|
+
|
9
|
+
module Soma
|
10
|
+
extend self
|
11
|
+
def start
|
12
|
+
@thread || @thread = Thread.start { tail }
|
13
|
+
end
|
14
|
+
|
15
|
+
def erase_and_open_buffer
|
16
|
+
@file = File.open(File.join(Dir::tmpdir, "#{`whoami`.strip}_somarepl_buffer"), 'w+')
|
17
|
+
end
|
18
|
+
|
19
|
+
def tail
|
20
|
+
erase_and_open_buffer
|
21
|
+
loop do
|
22
|
+
while (line = @file.readlines) && !line.empty?
|
23
|
+
line.each {|l| Readline::HISTORY.push(l.strip) }
|
24
|
+
# Get the current IRB
|
25
|
+
irb = IRB.CurrentContext.irb
|
26
|
+
# We save the IRB context that takes STDIN as input
|
27
|
+
stdin_context = irb.context
|
28
|
+
# .. replace it with a context that takes our buffer file as input
|
29
|
+
irb.context = IRB::Context.new(irb, stdin_context.workspace, @file.path)
|
30
|
+
irb.eval_input
|
31
|
+
# and finally puts back the STDIN context so control is handled back to the IRB session again
|
32
|
+
irb.context = stdin_context
|
33
|
+
erase_and_open_buffer
|
34
|
+
end
|
35
|
+
sleep 0.2
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/soma.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "soma"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.date = "2008-11-15"
|
5
|
+
s.summary = "Send Ruby to IRB from _teh outside_!"
|
6
|
+
s.email = "ichverstehe@gmail.com"
|
7
|
+
s.homepage = "http://github.com/ichverstehe/soma"
|
8
|
+
s.description = "Send Ruby to IRB from _teh outside_!"
|
9
|
+
#s.rubyforge_project = "soma"
|
10
|
+
#s.has_rdoc = true
|
11
|
+
s.authors = ["Harry Vangberg"]
|
12
|
+
s.files = ["README.rdoc",
|
13
|
+
"soma.gemspec",
|
14
|
+
"lib/soma.rb"]
|
15
|
+
#s.rdoc_options = ["--main", "README.rdoc"]
|
16
|
+
#s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ichverstehe-soma
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Harry Vangberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-15 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Send Ruby to IRB from _teh outside_!
|
17
|
+
email: ichverstehe@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.rdoc
|
26
|
+
- soma.gemspec
|
27
|
+
- lib/soma.rb
|
28
|
+
has_rdoc: false
|
29
|
+
homepage: http://github.com/ichverstehe/soma
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
version:
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.2.0
|
51
|
+
signing_key:
|
52
|
+
specification_version: 2
|
53
|
+
summary: Send Ruby to IRB from _teh outside_!
|
54
|
+
test_files: []
|
55
|
+
|