ripl-multi_line 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/.gemspec +1 -1
  2. data/README.rdoc +1 -3
  3. data/lib/ripl/multi_line.rb +26 -26
  4. metadata +7 -7
data/.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.summary = "A ripl plugin for multi-line eval."
12
12
  s.description = "This ripl plugin allows you to evaluate multiple lines of Ruby code."
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
- s.add_dependency 'ripl', '>= 0.2.0'
14
+ s.add_dependency 'ripl', '>= 0.2.1'
15
15
  s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
16
16
  s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
17
17
  s.license = 'MIT'
data/README.rdoc CHANGED
@@ -12,8 +12,6 @@ Add to your ~/.riplrc
12
12
 
13
13
  require 'ripl/multi_line'
14
14
 
15
- == Todo
16
-
17
- * Hook in more cleanly (future ripl version may break functionality of this plugin)
15
+ You can customize your multi-line prompt with the <tt>multi_line_prompt</tt> option.
18
16
 
19
17
  J-_-L
@@ -1,35 +1,35 @@
1
1
  module Ripl
2
2
  module MultiLine
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
 
5
- def during_loop
6
- input = ''
7
- while true do
8
- @error_raised = nil
9
- input = catch :multiline do
10
- new_input = get_input
11
- exit if !new_input
12
- input += new_input
13
- exit if input == 'exit'
14
- loop_once(input)
15
- puts(format_result(@last_result)) unless @error_raised
16
- input = ''
17
- end
5
+ def before_loop
6
+ super
7
+ @buffer = nil
8
+ config[:multi_line_prompt] ||= ' > '
9
+ end
10
+
11
+ def prompt
12
+ @buffer ? config[:multi_line_prompt] : super
13
+ end
14
+
15
+ def loop_once
16
+ catch(:multiline) do
17
+ super
18
+ @buffer = nil
19
+ end
20
+ end
21
+
22
+ def print_eval_error(e)
23
+ if e.is_a?(SyntaxError) && e.message =~ /unexpected \$end|unterminated string meets end of file/
24
+ (@buffer ||= '') << @input+"\n"
25
+ throw :multiline
26
+ else
27
+ super
18
28
  end
19
29
  end
20
30
 
21
- def loop_once(input)
22
- @last_result = loop_eval(input)
23
- eval("_ = Ripl.shell.last_result", @binding)
24
- rescue Exception => e
25
- if e.is_a?(SyntaxError) && e.message =~ /unexpected \$end|unterminated string meets end of file/
26
- throw :multiline, input + "\n"
27
- else
28
- @error_raised = true
29
- print_eval_error(e)
30
- end
31
- ensure
32
- @line += 1
31
+ def eval_input(input)
32
+ super(@buffer ? @buffer + input : input)
33
33
  end
34
34
  end
35
35
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripl-multi_line
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jan Lelis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-09 00:00:00 +01:00
18
+ date: 2010-11-12 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 23
29
+ hash: 21
30
30
  segments:
31
31
  - 0
32
32
  - 2
33
- - 0
34
- version: 0.2.0
33
+ - 1
34
+ version: 0.2.1
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  description: This ripl plugin allows you to evaluate multiple lines of Ruby code.