ripl 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +2 -0
- data/CHANGELOG.rdoc +8 -0
- data/README.rdoc +3 -0
- data/deps.rip +1 -0
- data/lib/ripl/shell.rb +23 -18
- data/lib/ripl/version.rb +1 -1
- metadata +24 -8
data/.gemspec
CHANGED
@@ -12,6 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = "Ruby Interactive Print Loop - A light, modular alternative to irb"
|
13
13
|
s.required_rubygems_version = ">= 1.3.6"
|
14
14
|
s.rubyforge_project = 'tagaholic'
|
15
|
+
s.executables = %w(ripl)
|
16
|
+
s.add_dependency 'bond', '~> 0.3.1'
|
15
17
|
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
16
18
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
17
19
|
s.license = 'MIT'
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
data/deps.rip
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bond ~>0.3.1
|
data/lib/ripl/shell.rb
CHANGED
@@ -7,28 +7,19 @@ module Ripl
|
|
7
7
|
def initialize(options={})
|
8
8
|
@options = OPTIONS.merge options
|
9
9
|
@name, @binding, @line = @options.values_at(:name, :binding, :line)
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def before_loop
|
14
|
-
load_rc
|
15
|
-
end
|
16
|
-
|
17
|
-
def load_rc
|
18
|
-
load @options[:irbrc] if File.exists?(File.expand_path(@options[:irbrc]))
|
10
|
+
@irbrc = @options[:irbrc]
|
19
11
|
end
|
20
12
|
|
21
13
|
def loop
|
14
|
+
before_loop
|
22
15
|
while true do
|
23
16
|
input = get_input
|
24
|
-
break if input == 'exit'
|
17
|
+
break if !input || input == 'exit'
|
25
18
|
puts loop_once(input)
|
26
19
|
end
|
27
20
|
after_loop
|
28
21
|
end
|
29
22
|
|
30
|
-
def after_loop; end
|
31
|
-
|
32
23
|
def get_input
|
33
24
|
print @options[:prompt]
|
34
25
|
$stdin.gets.chomp
|
@@ -36,26 +27,40 @@ module Ripl
|
|
36
27
|
|
37
28
|
def loop_once(input)
|
38
29
|
begin
|
39
|
-
result =
|
30
|
+
result = loop_eval(input)
|
40
31
|
rescue Exception => e
|
41
32
|
print_eval_error(e)
|
42
33
|
end
|
43
34
|
|
44
|
-
eval("_ = #{result.inspect}", @binding) rescue nil
|
45
35
|
@line += 1
|
46
36
|
format_result result
|
47
37
|
end
|
48
38
|
|
49
|
-
def
|
50
|
-
|
39
|
+
def print_eval_error(e)
|
40
|
+
warn format_error(e)
|
51
41
|
end
|
52
42
|
|
53
|
-
def
|
54
|
-
|
43
|
+
def format_error(e)
|
44
|
+
"#{e.class}: #{e.message}\n\t#{e.backtrace.join("\n\t")}"
|
55
45
|
end
|
56
46
|
|
57
47
|
def format_result(result)
|
58
48
|
@options[:result_prompt] + result.inspect
|
59
49
|
end
|
60
50
|
end
|
51
|
+
|
52
|
+
module Hooks
|
53
|
+
def before_loop
|
54
|
+
load @irbrc if @irbrc && File.exists?(File.expand_path(@irbrc))
|
55
|
+
rescue StandardError, SyntaxError
|
56
|
+
warn "Error while loading #{@irbrc}:\n"+ format_error($!)
|
57
|
+
end
|
58
|
+
|
59
|
+
def loop_eval(str)
|
60
|
+
eval('_ = '+str, @binding, "(#{@name})", @line)
|
61
|
+
end
|
62
|
+
|
63
|
+
def after_loop; end
|
64
|
+
end
|
65
|
+
Shell.send :include, Hooks
|
61
66
|
end
|
data/lib/ripl/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ripl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gabriel Horner
|
@@ -15,14 +15,29 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-28 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bond
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 17
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 3
|
33
|
+
- 1
|
34
|
+
version: 0.3.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
22
37
|
description: Ruby Interactive Print Loop - A light, modular alternative to irb
|
23
38
|
email: gabriel.horner@gmail.com
|
24
|
-
executables:
|
25
|
-
|
39
|
+
executables:
|
40
|
+
- ripl
|
26
41
|
extensions: []
|
27
42
|
|
28
43
|
extra_rdoc_files:
|
@@ -38,6 +53,7 @@ files:
|
|
38
53
|
- LICENSE.txt
|
39
54
|
- CHANGELOG.rdoc
|
40
55
|
- README.rdoc
|
56
|
+
- deps.rip
|
41
57
|
- Rakefile
|
42
58
|
- .gemspec
|
43
59
|
has_rdoc: true
|