ripl-rc 0.1.5 → 0.2.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/CHANGES +11 -0
- data/README +22 -11
- data/README.md +22 -11
- data/TODO +2 -0
- data/lib/ripl/rc.rb +10 -4
- data/lib/ripl/rc/anchor.rb +7 -4
- data/lib/ripl/rc/color.rb +4 -3
- data/lib/ripl/rc/ctrld_newline.rb +4 -2
- data/lib/ripl/rc/eat_whites.rb +4 -2
- data/lib/ripl/rc/last_exception.rb +24 -0
- data/lib/ripl/rc/mkdir_history.rb +4 -2
- data/lib/ripl/rc/multiline.rb +22 -7
- data/lib/ripl/rc/squeeze_history.rb +10 -3
- data/lib/ripl/rc/strip_backtrace.rb +4 -3
- data/lib/ripl/rc/test.rb +11 -0
- data/lib/ripl/rc/u.rb +47 -0
- data/lib/ripl/rc/version.rb +1 -1
- data/ripl-rc.gemspec +5 -6
- data/test/test_disable_shortcut.rb +41 -0
- data/test/test_squeeze_history.rb +15 -7
- metadata +14 -11
data/CHANGES
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= ripl-rc changes history
|
2
2
|
|
3
|
+
== ripl-rc 0.2.0 -- 2011-04-10
|
4
|
+
|
5
|
+
* [ ripl-rc] tested with MRI 1.8.7, 1.9.2 and Rubinius 1.2.3, JRuby 1.6.0
|
6
|
+
* [ ripl-rc] fixed some conflicts with bundler
|
7
|
+
* [ ripl-rc] internal structure rearrangement
|
8
|
+
* [ ripl-rc] all plugins now have runtime enable/disable ability
|
9
|
+
e.g. run `Ripl.disable_color` to disable coloring,
|
10
|
+
`Ripl.enable_color` to enable again.
|
11
|
+
* [multiline] some tweak to make it more accurate
|
12
|
+
* [last_exception] save last exception in Ripl.last_exception
|
13
|
+
|
3
14
|
== ripl-rc 0.1.5 -- 2011-03-26
|
4
15
|
|
5
16
|
* [ bin] shows a better error message when ripl-rails can't be found
|
data/README
CHANGED
@@ -10,6 +10,15 @@ by Lin Jen-Shin ([godfat](http://godfat.org))
|
|
10
10
|
|
11
11
|
ripl plugins collection, take you want, leave you don't.
|
12
12
|
|
13
|
+
## REQUIREMENTS:
|
14
|
+
|
15
|
+
* Tested with MRI 1.8.7, 1.9.2 and Rubinius 1.2.3, JRuby 1.6.0
|
16
|
+
* ripl
|
17
|
+
|
18
|
+
## INSTALLATION:
|
19
|
+
|
20
|
+
gem install ripl-rc
|
21
|
+
|
13
22
|
## SYNOPSIS:
|
14
23
|
|
15
24
|
If you don't know what is __ripl__, or just want to have an
|
@@ -58,21 +67,31 @@ upon session ends:
|
|
58
67
|
|
59
68
|
* `require 'ripl/rc/squeeze_history'`
|
60
69
|
|
61
|
-
|
70
|
+
Which squeezes the same input in history, both in memory
|
62
71
|
and history file.
|
63
72
|
|
64
73
|
* `require 'ripl/rc/mkdir_history'`
|
65
74
|
|
66
|
-
|
75
|
+
Which calls `mkdir -p` on directory which contains history
|
67
76
|
file. For example, I put my irb_history in an directory
|
68
77
|
might not exist before use: `~/.config/irb/irb_history`
|
69
78
|
|
70
79
|
* `require 'ripl/rc/ctrld_newline'`
|
71
80
|
|
72
|
-
|
81
|
+
Ruby 1.9.2 has no this problem in irb, but 1.8 and ripl do.
|
73
82
|
When hitting ctrl+d to exit ripl, it would print a newline
|
74
83
|
instead of messing up with shell prompt.
|
75
84
|
|
85
|
+
upon exception occurs:
|
86
|
+
|
87
|
+
* `require 'ripl/rc/last_exception'`
|
88
|
+
|
89
|
+
We can't access $! for last exception because input evaluation
|
90
|
+
is not in the block which rescues the exception, neither can we
|
91
|
+
update $! because it's a read only pseudo global variable.
|
92
|
+
|
93
|
+
This plugin makes last rescued exception stored in `Ripl.last_exception`
|
94
|
+
|
76
95
|
upon formatting output:
|
77
96
|
|
78
97
|
* `require 'ripl/rc/strip_backtrace'`
|
@@ -146,14 +165,6 @@ for lazies:
|
|
146
165
|
This requires anything above for you, and is what `ripl rc`
|
147
166
|
and `ripl rc rails` shell commands did.
|
148
167
|
|
149
|
-
## REQUIREMENTS:
|
150
|
-
|
151
|
-
* ripl
|
152
|
-
|
153
|
-
## INSTALL:
|
154
|
-
|
155
|
-
gem install ripl-rc
|
156
|
-
|
157
168
|
## LICENSE:
|
158
169
|
|
159
170
|
Apache License 2.0
|
data/README.md
CHANGED
@@ -10,6 +10,15 @@ by Lin Jen-Shin ([godfat](http://godfat.org))
|
|
10
10
|
|
11
11
|
ripl plugins collection, take you want, leave you don't.
|
12
12
|
|
13
|
+
## REQUIREMENTS:
|
14
|
+
|
15
|
+
* Tested with MRI 1.8.7, 1.9.2 and Rubinius 1.2.3, JRuby 1.6.0
|
16
|
+
* ripl
|
17
|
+
|
18
|
+
## INSTALLATION:
|
19
|
+
|
20
|
+
gem install ripl-rc
|
21
|
+
|
13
22
|
## SYNOPSIS:
|
14
23
|
|
15
24
|
If you don't know what is __ripl__, or just want to have an
|
@@ -58,21 +67,31 @@ upon session ends:
|
|
58
67
|
|
59
68
|
* `require 'ripl/rc/squeeze_history'`
|
60
69
|
|
61
|
-
|
70
|
+
Which squeezes the same input in history, both in memory
|
62
71
|
and history file.
|
63
72
|
|
64
73
|
* `require 'ripl/rc/mkdir_history'`
|
65
74
|
|
66
|
-
|
75
|
+
Which calls `mkdir -p` on directory which contains history
|
67
76
|
file. For example, I put my irb_history in an directory
|
68
77
|
might not exist before use: `~/.config/irb/irb_history`
|
69
78
|
|
70
79
|
* `require 'ripl/rc/ctrld_newline'`
|
71
80
|
|
72
|
-
|
81
|
+
Ruby 1.9.2 has no this problem in irb, but 1.8 and ripl do.
|
73
82
|
When hitting ctrl+d to exit ripl, it would print a newline
|
74
83
|
instead of messing up with shell prompt.
|
75
84
|
|
85
|
+
upon exception occurs:
|
86
|
+
|
87
|
+
* `require 'ripl/rc/last_exception'`
|
88
|
+
|
89
|
+
We can't access $! for last exception because input evaluation
|
90
|
+
is not in the block which rescues the exception, neither can we
|
91
|
+
update $! because it's a read only pseudo global variable.
|
92
|
+
|
93
|
+
This plugin makes last rescued exception stored in `Ripl.last_exception`
|
94
|
+
|
76
95
|
upon formatting output:
|
77
96
|
|
78
97
|
* `require 'ripl/rc/strip_backtrace'`
|
@@ -146,14 +165,6 @@ for lazies:
|
|
146
165
|
This requires anything above for you, and is what `ripl rc`
|
147
166
|
and `ripl rc rails` shell commands did.
|
148
167
|
|
149
|
-
## REQUIREMENTS:
|
150
|
-
|
151
|
-
* ripl
|
152
|
-
|
153
|
-
## INSTALL:
|
154
|
-
|
155
|
-
gem install ripl-rc
|
156
|
-
|
157
168
|
## LICENSE:
|
158
169
|
|
159
170
|
Apache License 2.0
|
data/TODO
CHANGED
data/lib/ripl/rc.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
|
2
|
-
#
|
2
|
+
# upon session ends
|
3
3
|
require 'ripl/rc/squeeze_history'
|
4
4
|
require 'ripl/rc/mkdir_history'
|
5
5
|
require 'ripl/rc/ctrld_newline'
|
6
6
|
|
7
|
-
#
|
7
|
+
# upon exception occurs
|
8
|
+
require 'ripl/rc/last_exception'
|
9
|
+
|
10
|
+
# upon formatting output
|
8
11
|
require 'ripl/rc/strip_backtrace'
|
9
12
|
require 'ripl/rc/color'
|
10
13
|
|
11
|
-
# input
|
14
|
+
# upon input
|
12
15
|
require 'ripl/rc/multiline'
|
13
16
|
require 'ripl/rc/eat_whites'
|
14
17
|
|
15
18
|
# speical tool
|
16
19
|
require 'ripl/rc/anchor'
|
17
20
|
|
18
|
-
# config
|
21
|
+
# about config
|
19
22
|
require 'ripl/rc/noirbrc'
|
23
|
+
|
24
|
+
# to force ripl to load everything before bundler kicks in!
|
25
|
+
Ripl.shell
|
data/lib/ripl/rc/anchor.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
|
2
|
-
require 'ripl'
|
2
|
+
require 'ripl/rc/u'
|
3
3
|
|
4
|
-
module Ripl::Rc; end
|
5
4
|
module Ripl::Rc::Anchor
|
5
|
+
include Ripl::Rc::U
|
6
|
+
|
6
7
|
def loop_eval(str)
|
7
8
|
case obj_or_binding = (config[:rc_anchor] ||= []).last
|
8
9
|
when NilClass
|
@@ -42,6 +43,7 @@ module Ripl::Rc::Anchor
|
|
42
43
|
|
43
44
|
module AnchorImp
|
44
45
|
def anchor obj_or_binding
|
46
|
+
return if Ripl::Rc::Anchor.disabled?
|
45
47
|
if Ripl.config[:rc_init].nil?
|
46
48
|
Ripl::Runner.load_rc(Ripl.config[:riplrc])
|
47
49
|
Ripl.config[:rc_init] = true
|
@@ -64,5 +66,6 @@ module Ripl::Rc::U; extend Ripl::Rc::Anchor::Imp; end
|
|
64
66
|
|
65
67
|
Ripl::Shell.include(Ripl::Rc::Anchor)
|
66
68
|
Ripl.config[:prompt] ||= Ripl::Shell::OPTIONS[:prompt]
|
67
|
-
|
68
|
-
Ripl.extend(Ripl::Rc::Anchor::AnchorImp)
|
69
|
+
# define Ripl.anchor
|
70
|
+
Ripl .extend(Ripl::Rc::Anchor::AnchorImp)
|
71
|
+
Ripl::Rc.extend(Ripl::Rc::Anchor::AnchorImp)
|
data/lib/ripl/rc/color.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
|
2
|
-
require 'ripl'
|
2
|
+
require 'ripl/rc/u'
|
3
3
|
|
4
|
-
module Ripl::Rc; end
|
5
4
|
module Ripl::Rc::Color
|
6
|
-
include Ripl::Rc
|
5
|
+
include Ripl::Rc::U
|
7
6
|
|
8
7
|
def format_result result, display=result.inspect
|
8
|
+
return super(result) if Color.disabled?
|
9
9
|
case result
|
10
10
|
when String ; U.send(U.colors[String ]){ display }
|
11
11
|
when Numeric; U.send(U.colors[Numeric ]){ display }
|
@@ -32,6 +32,7 @@ module Ripl::Rc::Color
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def get_error e, backtrace=e.backtrace
|
35
|
+
return super if Color.disabled?
|
35
36
|
[format_result(e, "#{e.class.to_s}: #{e.message}"),
|
36
37
|
backtrace.map{ |b|
|
37
38
|
path, rest = File.split(b)
|
data/lib/ripl/rc/eat_whites.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
|
2
|
-
require 'ripl'
|
2
|
+
require 'ripl/rc/u'
|
3
3
|
|
4
|
-
module Ripl::Rc; end
|
5
4
|
module Ripl::Rc::EatWhites
|
5
|
+
include Ripl::Rc::U
|
6
|
+
|
6
7
|
# don't print empty input
|
7
8
|
def print_result result
|
9
|
+
return super if EatWhites.disabled?
|
8
10
|
super unless @input.strip == ''
|
9
11
|
end
|
10
12
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
require 'ripl/rc/u'
|
3
|
+
|
4
|
+
module Ripl::Rc::LastException
|
5
|
+
include Ripl::Rc::U
|
6
|
+
|
7
|
+
def print_eval_error(e)
|
8
|
+
Ripl.config[:rc_last_exception] = nil
|
9
|
+
return super if LastException.disabled?
|
10
|
+
Ripl.config[:rc_last_exception] = e
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
module LastExceptionImp
|
15
|
+
def last_exception
|
16
|
+
Ripl.config[:rc_last_exception]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Ripl::Shell.include(Ripl::Rc::LastException)
|
22
|
+
# define Ripl.last_exception
|
23
|
+
Ripl .extend(Ripl::Rc::LastException::LastExceptionImp)
|
24
|
+
Ripl::Rc.extend(Ripl::Rc::LastException::LastExceptionImp)
|
@@ -1,10 +1,12 @@
|
|
1
1
|
|
2
|
-
require 'ripl'
|
2
|
+
require 'ripl/rc/u'
|
3
3
|
|
4
|
-
module Ripl::Rc; end
|
5
4
|
module Ripl::Rc::MkdirHistory
|
5
|
+
include Ripl::Rc::U
|
6
|
+
|
6
7
|
# ensure path existed
|
7
8
|
def write_history
|
9
|
+
return super if MkdirHistory.disabled?
|
8
10
|
require 'fileutils'
|
9
11
|
FileUtils.mkdir_p(File.dirname(history_file))
|
10
12
|
super
|
data/lib/ripl/rc/multiline.rb
CHANGED
@@ -1,26 +1,37 @@
|
|
1
1
|
|
2
|
-
require 'ripl'
|
2
|
+
require 'ripl/rc/u'
|
3
3
|
|
4
4
|
# from https://github.com/janlelis/ripl-multi_line
|
5
|
-
module Ripl::Rc; end
|
6
5
|
module Ripl::Rc::Multiline
|
6
|
+
include Ripl::Rc::U
|
7
|
+
|
8
|
+
# test those:
|
9
|
+
# ruby -e '"'
|
10
|
+
# ruby -e '{'
|
11
|
+
# ruby -e '['
|
12
|
+
# ruby -e '('
|
13
|
+
# ruby -e 'class C'
|
14
|
+
# ruby -e 'def f'
|
15
|
+
# ruby -e 'begin'
|
7
16
|
ERROR_REGEXP = Regexp.new(
|
8
|
-
[
|
9
|
-
"unterminated
|
17
|
+
[ # string
|
18
|
+
"unterminated string meets end of file",
|
19
|
+
# mri and rubinius
|
20
|
+
"syntax error, unexpected \\$end",
|
10
21
|
# rubinius
|
11
|
-
"expecting '
|
12
|
-
"missing 'end'",
|
13
|
-
"expecting '}'",
|
22
|
+
"expecting '.+'( or '.+')*",
|
14
23
|
# jruby
|
15
24
|
"syntax error, unexpected end-of-file",
|
16
25
|
].join('|'))
|
17
26
|
|
18
27
|
def before_loop
|
28
|
+
return super if Multiline.disabled?
|
19
29
|
@rc_multiline_buffer = []
|
20
30
|
super
|
21
31
|
end
|
22
32
|
|
23
33
|
def prompt
|
34
|
+
return super if Multiline.disabled?
|
24
35
|
if @rc_multiline_buffer.empty?
|
25
36
|
super
|
26
37
|
else
|
@@ -29,6 +40,7 @@ module Ripl::Rc::Multiline
|
|
29
40
|
end
|
30
41
|
|
31
42
|
def loop_once
|
43
|
+
return super if Multiline.disabled?
|
32
44
|
catch(:rc_multiline_cont) do
|
33
45
|
super
|
34
46
|
@rc_multiline_buffer.clear
|
@@ -36,6 +48,7 @@ module Ripl::Rc::Multiline
|
|
36
48
|
end
|
37
49
|
|
38
50
|
def print_eval_error(e)
|
51
|
+
return super if Multiline.disabled?
|
39
52
|
if e.is_a?(SyntaxError) && e.message =~ ERROR_REGEXP
|
40
53
|
@rc_multiline_buffer << @input if @rc_multiline_buffer.empty?
|
41
54
|
history.pop
|
@@ -46,6 +59,7 @@ module Ripl::Rc::Multiline
|
|
46
59
|
end
|
47
60
|
|
48
61
|
def loop_eval(input)
|
62
|
+
return super if Multiline.disabled?
|
49
63
|
if @rc_multiline_buffer.empty?
|
50
64
|
super
|
51
65
|
else
|
@@ -57,6 +71,7 @@ module Ripl::Rc::Multiline
|
|
57
71
|
end
|
58
72
|
|
59
73
|
def handle_interrupt
|
74
|
+
return super if Multiline.disabled?
|
60
75
|
if @rc_multiline_buffer.empty?
|
61
76
|
super
|
62
77
|
else
|
@@ -1,12 +1,17 @@
|
|
1
1
|
|
2
|
-
require 'ripl'
|
2
|
+
require 'ripl/rc/u'
|
3
3
|
|
4
|
-
module Ripl::Rc; end
|
5
4
|
module Ripl::Rc::SqueezeHistory
|
6
|
-
include Ripl::Rc
|
5
|
+
include Ripl::Rc::U
|
6
|
+
|
7
|
+
# avoid some complicated conditions...
|
8
|
+
def history
|
9
|
+
super || (@history ||= [])
|
10
|
+
end
|
7
11
|
|
8
12
|
# write squeezed history
|
9
13
|
def write_history
|
14
|
+
return super if SqueezeHistory.disabled?
|
10
15
|
File.open(history_file, 'w'){ |f|
|
11
16
|
f.puts U.squeeze_history(history).join("\n")
|
12
17
|
}
|
@@ -14,12 +19,14 @@ module Ripl::Rc::SqueezeHistory
|
|
14
19
|
|
15
20
|
# squeeze history on memory too
|
16
21
|
def eval_input input
|
22
|
+
return super if SqueezeHistory.disabled?
|
17
23
|
history.pop if input.strip == '' ||
|
18
24
|
(history.size > 1 && input == history[-2])
|
19
25
|
super
|
20
26
|
end
|
21
27
|
|
22
28
|
def before_loop
|
29
|
+
return super if SqueezeHistory.disabled?
|
23
30
|
super if history.empty?
|
24
31
|
end
|
25
32
|
|
@@ -1,17 +1,18 @@
|
|
1
1
|
|
2
|
-
require 'ripl'
|
2
|
+
require 'ripl/rc/u'
|
3
3
|
|
4
|
-
module Ripl::Rc; end
|
5
4
|
module Ripl::Rc::StripBacktrace
|
6
|
-
include Ripl::Rc
|
5
|
+
include Ripl::Rc::U
|
7
6
|
|
8
7
|
# strip backtrace until ripl
|
9
8
|
def format_error e
|
9
|
+
return super if StripBacktrace.disabled?
|
10
10
|
message, backtrace = get_error(e, U.strip_backtrace(e, @name))
|
11
11
|
"#{message}\n #{backtrace.join("\n ")}"
|
12
12
|
end
|
13
13
|
|
14
14
|
def get_error e, backtrace=e.backtrace
|
15
|
+
return super if StripBacktrace.disabled?
|
15
16
|
["#{e.class}: #{e.message}", backtrace]
|
16
17
|
end
|
17
18
|
|
data/lib/ripl/rc/test.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
require 'ripl'
|
3
|
+
require 'readline'
|
4
|
+
Ripl.config.merge!(:readline => nil) unless
|
5
|
+
Readline::HISTORY.respond_to?(:clear) # EditLine is broken
|
6
|
+
|
7
|
+
require 'bacon'
|
8
|
+
require 'rr'
|
9
|
+
require 'fileutils'
|
10
|
+
Bacon.summary_on_exit
|
11
|
+
include RR::Adapters::RRMethods
|
data/lib/ripl/rc/u.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
require 'ripl'
|
3
|
+
|
4
|
+
module Ripl::Rc; end
|
5
|
+
module Ripl::Rc::U
|
6
|
+
def self.included mod
|
7
|
+
mod.send(:include, Ripl::Rc)
|
8
|
+
class << mod
|
9
|
+
attr_accessor :disabled
|
10
|
+
|
11
|
+
def enable
|
12
|
+
self.disabled = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def disable
|
16
|
+
self.disabled = true
|
17
|
+
end
|
18
|
+
|
19
|
+
def enabled?
|
20
|
+
!disabled
|
21
|
+
end
|
22
|
+
|
23
|
+
def disabled?
|
24
|
+
!!disabled
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
snake_name = mod.name[/::\w+$/].tr(':', ''). # remove namespaces
|
29
|
+
gsub(/([A-Z][a-z]*)/, '\\1_').downcase[0..-2]
|
30
|
+
code = (%w[enable disable].map{ |meth|
|
31
|
+
<<-RUBY
|
32
|
+
def #{meth}_#{snake_name}
|
33
|
+
#{mod.name}.#{meth}
|
34
|
+
end
|
35
|
+
RUBY
|
36
|
+
} + %w[enabled? disabled?].map{ |meth|
|
37
|
+
<<-RUBY
|
38
|
+
def #{snake_name}_#{meth}
|
39
|
+
#{mod.name}.#{meth}
|
40
|
+
end
|
41
|
+
RUBY
|
42
|
+
}).join("\n")
|
43
|
+
module_eval(code)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
Ripl.extend(Ripl::Rc::U)
|
data/lib/ripl/rc/version.rb
CHANGED
data/ripl-rc.gemspec
CHANGED
@@ -2,23 +2,22 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ripl-rc}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
9
|
-
s.date = %q{2011-
|
10
|
-
s.default_executable = %q{ripl-rc}
|
9
|
+
s.date = %q{2011-04-10}
|
11
10
|
s.description = %q{ripl plugins collection, take you want, leave you don't.}
|
12
11
|
s.email = ["godfat (XD) godfat.org"]
|
13
12
|
s.executables = ["ripl-rc"]
|
14
13
|
s.extra_rdoc_files = ["CHANGES", "CONTRIBUTORS", "LICENSE", "TODO"]
|
15
|
-
s.files = [".gitignore", "2011-02-28.md", "CHANGES", "CONTRIBUTORS", "Gemfile", "LICENSE", "README", "README.md", "Rakefile", "TODO", "bin/ripl-rc", "lib/ripl-rc.rb", "lib/ripl/rc.rb", "lib/ripl/rc/anchor.rb", "lib/ripl/rc/color.rb", "lib/ripl/rc/ctrld_newline.rb", "lib/ripl/rc/eat_whites.rb", "lib/ripl/rc/mkdir_history.rb", "lib/ripl/rc/multiline.rb", "lib/ripl/rc/noirbrc.rb", "lib/ripl/rc/squeeze_history.rb", "lib/ripl/rc/strip_backtrace.rb", "lib/ripl/rc/version.rb", "ripl-rc.gemspec", "screenshot.png", "task/gemgem.rb", "test/test_squeeze_history.rb"]
|
14
|
+
s.files = [".gitignore", "2011-02-28.md", "CHANGES", "CONTRIBUTORS", "Gemfile", "LICENSE", "README", "README.md", "Rakefile", "TODO", "bin/ripl-rc", "lib/ripl-rc.rb", "lib/ripl/rc.rb", "lib/ripl/rc/anchor.rb", "lib/ripl/rc/color.rb", "lib/ripl/rc/ctrld_newline.rb", "lib/ripl/rc/eat_whites.rb", "lib/ripl/rc/last_exception.rb", "lib/ripl/rc/mkdir_history.rb", "lib/ripl/rc/multiline.rb", "lib/ripl/rc/noirbrc.rb", "lib/ripl/rc/squeeze_history.rb", "lib/ripl/rc/strip_backtrace.rb", "lib/ripl/rc/test.rb", "lib/ripl/rc/u.rb", "lib/ripl/rc/version.rb", "ripl-rc.gemspec", "screenshot.png", "task/gemgem.rb", "test/test_disable_shortcut.rb", "test/test_squeeze_history.rb"]
|
16
15
|
s.homepage = %q{http://github.com/godfat/}
|
17
16
|
s.rdoc_options = ["--main", "README"]
|
18
17
|
s.require_paths = ["lib"]
|
19
|
-
s.rubygems_version = %q{1.
|
18
|
+
s.rubygems_version = %q{1.7.2}
|
20
19
|
s.summary = %q{ripl plugins collection, take you want, leave you don't.}
|
21
|
-
s.test_files = ["test/test_squeeze_history.rb"]
|
20
|
+
s.test_files = ["test/test_disable_shortcut.rb", "test/test_squeeze_history.rb"]
|
22
21
|
|
23
22
|
if s.respond_to? :specification_version then
|
24
23
|
s.specification_version = 3
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
require 'ripl/rc/test'
|
3
|
+
require 'ripl/rc'
|
4
|
+
|
5
|
+
describe Ripl::Rc::U do
|
6
|
+
before do
|
7
|
+
@names = Dir[File.expand_path(
|
8
|
+
"#{File.dirname(__FILE__)}/../lib/ripl/rc/*.rb")].
|
9
|
+
map { |path| File.basename(path)[0..-4] }.
|
10
|
+
reject{ |name| %w[version u noirbrc test].include?(name) }
|
11
|
+
@mods = Ripl::Shell.ancestors[1..-1].select{ |mod| mod < Ripl::Rc }
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
@mods.each(&:enable)
|
16
|
+
end
|
17
|
+
|
18
|
+
should 'have shortcut methods' do
|
19
|
+
@names.each{ |name|
|
20
|
+
%w[enable disable].each{ |meth|
|
21
|
+
Ripl.should.respond_to?("#{meth}_#{name}") == true
|
22
|
+
}
|
23
|
+
%w[enabled? disabled?].each{ |meth|
|
24
|
+
Ripl.should.respond_to?("#{name}_#{meth}") == true
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
should 'be the same as mod methods' do
|
30
|
+
@mods.shuffle.take(@mods.size/2).each(&:disable)
|
31
|
+
@names.each{ |name|
|
32
|
+
%w[enabled? disabled?].each{ |meth|
|
33
|
+
Ripl.send("#{name}_#{meth}").should ==
|
34
|
+
@mods.find{ |mod|
|
35
|
+
mod.name[/::\w+$/].tr(':', '') ==
|
36
|
+
name.gsub(/([^_]+)/){$1.capitalize}.tr('_', '') }.
|
37
|
+
send(meth)
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
@@ -1,20 +1,18 @@
|
|
1
1
|
|
2
|
-
require '
|
3
|
-
require 'rr'
|
4
|
-
require 'fileutils'
|
2
|
+
require 'ripl/rc/test'
|
5
3
|
require 'ripl/rc/squeeze_history'
|
6
|
-
Bacon.summary_on_exit
|
7
|
-
include RR::Adapters::RRMethods
|
8
4
|
|
9
5
|
describe Ripl::Rc::SqueezeHistory do
|
10
6
|
before do
|
11
7
|
@history = '/tmp/test_ripl_history'
|
12
|
-
|
8
|
+
Ripl.config.merge!(:history => @history, :irbrc => nil)
|
9
|
+
@shell = Ripl::Shell.create(Ripl.config)
|
13
10
|
@input = %w[foo bar bar foo bar]
|
11
|
+
@shell.before_loop
|
14
12
|
@shell.history.clear
|
15
13
|
end
|
16
14
|
|
17
|
-
after do; FileUtils.rm_f(@history); end
|
15
|
+
after do; FileUtils.rm_f(@history); Ripl.enable_squeeze_history; end
|
18
16
|
|
19
17
|
should 'after_loop saves squeezed history' do
|
20
18
|
@shell.history.push(*@input)
|
@@ -30,4 +28,14 @@ describe Ripl::Rc::SqueezeHistory do
|
|
30
28
|
times.times{ @shell.loop_once }
|
31
29
|
@shell.history.to_a.should == %w[foo bar foo bar].map{ |i| "'#{i}'" }
|
32
30
|
end
|
31
|
+
|
32
|
+
should 'be disabled if disabled' do
|
33
|
+
Ripl.disable_squeeze_history
|
34
|
+
times = @input.size
|
35
|
+
input = @input.dup
|
36
|
+
stub(@shell).get_input{ (@shell.history << "'#{@input.shift}'")[-1] }
|
37
|
+
stub(@shell).print_result(anything)
|
38
|
+
times.times{ @shell.loop_once }
|
39
|
+
@shell.history.to_a.should == input.map{ |i| "'#{i}'" }
|
40
|
+
end
|
33
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ripl-rc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
default_executable: ripl-rc
|
12
|
+
date: 2011-04-10 00:00:00.000000000Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: ripl
|
17
|
-
requirement: &
|
16
|
+
requirement: &2156866000 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
@@ -22,10 +21,10 @@ dependencies:
|
|
22
21
|
version: '0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156866000
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: bacon
|
28
|
-
requirement: &
|
27
|
+
requirement: &2156865520 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ! '>='
|
@@ -33,10 +32,10 @@ dependencies:
|
|
33
32
|
version: '0'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156865520
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: rr
|
39
|
-
requirement: &
|
38
|
+
requirement: &2156865040 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ! '>='
|
@@ -44,7 +43,7 @@ dependencies:
|
|
44
43
|
version: '0'
|
45
44
|
type: :development
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156865040
|
48
47
|
description: ripl plugins collection, take you want, leave you don't.
|
49
48
|
email:
|
50
49
|
- godfat (XD) godfat.org
|
@@ -74,17 +73,20 @@ files:
|
|
74
73
|
- lib/ripl/rc/color.rb
|
75
74
|
- lib/ripl/rc/ctrld_newline.rb
|
76
75
|
- lib/ripl/rc/eat_whites.rb
|
76
|
+
- lib/ripl/rc/last_exception.rb
|
77
77
|
- lib/ripl/rc/mkdir_history.rb
|
78
78
|
- lib/ripl/rc/multiline.rb
|
79
79
|
- lib/ripl/rc/noirbrc.rb
|
80
80
|
- lib/ripl/rc/squeeze_history.rb
|
81
81
|
- lib/ripl/rc/strip_backtrace.rb
|
82
|
+
- lib/ripl/rc/test.rb
|
83
|
+
- lib/ripl/rc/u.rb
|
82
84
|
- lib/ripl/rc/version.rb
|
83
85
|
- ripl-rc.gemspec
|
84
86
|
- screenshot.png
|
85
87
|
- task/gemgem.rb
|
88
|
+
- test/test_disable_shortcut.rb
|
86
89
|
- test/test_squeeze_history.rb
|
87
|
-
has_rdoc: true
|
88
90
|
homepage: http://github.com/godfat/
|
89
91
|
licenses: []
|
90
92
|
post_install_message:
|
@@ -107,9 +109,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
109
|
version: '0'
|
108
110
|
requirements: []
|
109
111
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.
|
112
|
+
rubygems_version: 1.7.2
|
111
113
|
signing_key:
|
112
114
|
specification_version: 3
|
113
115
|
summary: ripl plugins collection, take you want, leave you don't.
|
114
116
|
test_files:
|
117
|
+
- test/test_disable_shortcut.rb
|
115
118
|
- test/test_squeeze_history.rb
|