ripl-rc 0.1.2 → 0.1.3
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/.gitignore +1 -0
- data/CHANGES +11 -0
- data/CONTRIBUTORS +1 -0
- data/README +109 -0
- data/README.md +109 -0
- data/Rakefile +12 -107
- data/bin/ripl-rc +8 -0
- data/lib/ripl/rc/anchor.rb +16 -7
- data/lib/ripl/rc/color.rb +41 -16
- data/lib/ripl/rc/noirbrc.rb +2 -0
- data/lib/ripl/rc/squeeze_history.rb +2 -1
- data/lib/ripl/rc/strip_backtrace.rb +8 -2
- data/lib/ripl/rc/version.rb +1 -1
- data/lib/ripl/rc.rb +3 -0
- data/ripl-rc.gemspec +11 -8
- data/screenshot.png +0 -0
- data/task/gemgem.rb +155 -0
- metadata +29 -18
- data/README.rdoc +0 -58
data/.gitignore
CHANGED
data/CHANGES
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= ripl-rc changes history
|
2
2
|
|
3
|
+
== ripl-rc 0.1.3 -- 2011-02-28
|
4
|
+
|
5
|
+
* [ bin] added `ripl rc` and `ripl rc rails` commands
|
6
|
+
* [noirbrc] added that don't read ~/.irbrc by default
|
7
|
+
* [ anchor] use short_inspect
|
8
|
+
* [ anchor] fixed a bug that cannot display nil
|
9
|
+
* [ color] fixed a bug that displaying some values as Object. see [9a64495]
|
10
|
+
* [ color] colorize error output as well
|
11
|
+
* [squeeze_history] max 500 items
|
12
|
+
* [strip_backtrace] fixed cwd, don't trace if it's a syntax error
|
13
|
+
|
3
14
|
== ripl-rc 0.1.2 -- 2011-02-25
|
4
15
|
|
5
16
|
* [ rc] rearranged require order
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Lin Jen-Shin (godfat)
|
data/README
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# ripl-rc
|
2
|
+
by Lin Jen-Shin ([godfat](http://godfat.org))
|
3
|
+
|
4
|
+
## LINKS:
|
5
|
+
|
6
|
+
* [github](http://github.com/godfat/ripl-rc)
|
7
|
+
* [rubygems](http://rubygems.org/gems/ripl-rc)
|
8
|
+
|
9
|
+
## DESCRIPTION:
|
10
|
+
|
11
|
+
ripl plugins collection, take you want, leave you don't.
|
12
|
+
|
13
|
+
## SYNOPSIS:
|
14
|
+
|
15
|
+
If you don't know what is __ripl__, or just want to have an
|
16
|
+
overview of what does __ripl-rc__ do, then you can use it as
|
17
|
+
a command line tool:
|
18
|
+
|
19
|
+
ripl rc
|
20
|
+
|
21
|
+
This can be used to run rails console, too. First install
|
22
|
+
_ripl-rails_ by `gem install ripl-rails` then run this:
|
23
|
+
|
24
|
+
ripl rc rails
|
25
|
+
|
26
|
+
Then you'll have a _ripl-rc_ flavored rails console without
|
27
|
+
setting anything (i.e. `~/.riplrc`)
|
28
|
+
|
29
|
+
If you already know what is _ripl_, you might want to setup
|
30
|
+
yourself, to be better control what you might want and what
|
31
|
+
you might not want. Then checkout FEATURES for all plugins
|
32
|
+
you can put in `~/.riplrc`.
|
33
|
+
|
34
|
+
If you want to enable all plugins, the use this:
|
35
|
+
|
36
|
+
require 'ripl/rc'
|
37
|
+
|
38
|
+
Another thing which might worth to be mentioned is
|
39
|
+
`ripl/rc/anchor`, which is a _pry_ like feature built into
|
40
|
+
ripl. You can embed two things into ripl, one is any object:
|
41
|
+
|
42
|
+
Ripl.anchor your_object_want_to_be_viewed_as_self
|
43
|
+
|
44
|
+
Another one is local binding inside a method:
|
45
|
+
|
46
|
+
Ripl.anchor binding
|
47
|
+
|
48
|
+
Then you can look through local variables inside a method
|
49
|
+
with an interactive environment. Anchor could be nested, too.
|
50
|
+
You can anchor another object inside a _ripl_ session. The number
|
51
|
+
shown in prompt is the level of anchors, started from 1.
|
52
|
+
|
53
|
+

|
54
|
+
|
55
|
+
## FEATURES:
|
56
|
+
|
57
|
+
when session ends
|
58
|
+
|
59
|
+
* require 'ripl/rc/squeeze_history'
|
60
|
+
* require 'ripl/rc/mkdir_history'
|
61
|
+
* require 'ripl/rc/ctrld_newline'
|
62
|
+
|
63
|
+
result format
|
64
|
+
|
65
|
+
* require 'ripl/rc/strip_backtrace'
|
66
|
+
* require 'ripl/rc/color'
|
67
|
+
|
68
|
+
input modification
|
69
|
+
|
70
|
+
* require 'ripl/rc/multiline' # work better with anchor...
|
71
|
+
* require 'ripl/rc/eat_whites'
|
72
|
+
|
73
|
+
speical tool
|
74
|
+
|
75
|
+
* require 'ripl/rc/anchor' # pry like, use: Ripl.anchor(binding) # or obj
|
76
|
+
|
77
|
+
config
|
78
|
+
|
79
|
+
* require 'ripl/rc/noirbrc'
|
80
|
+
|
81
|
+
for lazies
|
82
|
+
|
83
|
+
* require 'ripl/rc' # for all of above
|
84
|
+
|
85
|
+
## REQUIREMENTS:
|
86
|
+
|
87
|
+
* ripl
|
88
|
+
|
89
|
+
## INSTALL:
|
90
|
+
|
91
|
+
gem install ripl-rc
|
92
|
+
|
93
|
+
## LICENSE:
|
94
|
+
|
95
|
+
Apache License 2.0
|
96
|
+
|
97
|
+
Copyright (c) 2010, Lin Jen-Shin (godfat)
|
98
|
+
|
99
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
100
|
+
you may not use this file except in compliance with the License.
|
101
|
+
You may obtain a copy of the License at
|
102
|
+
|
103
|
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
104
|
+
|
105
|
+
Unless required by applicable law or agreed to in writing, software
|
106
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
107
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
108
|
+
See the License for the specific language governing permissions and
|
109
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# ripl-rc
|
2
|
+
by Lin Jen-Shin ([godfat](http://godfat.org))
|
3
|
+
|
4
|
+
## LINKS:
|
5
|
+
|
6
|
+
* [github](http://github.com/godfat/ripl-rc)
|
7
|
+
* [rubygems](http://rubygems.org/gems/ripl-rc)
|
8
|
+
|
9
|
+
## DESCRIPTION:
|
10
|
+
|
11
|
+
ripl plugins collection, take you want, leave you don't.
|
12
|
+
|
13
|
+
## SYNOPSIS:
|
14
|
+
|
15
|
+
If you don't know what is __ripl__, or just want to have an
|
16
|
+
overview of what does __ripl-rc__ do, then you can use it as
|
17
|
+
a command line tool:
|
18
|
+
|
19
|
+
ripl rc
|
20
|
+
|
21
|
+
This can be used to run rails console, too. First install
|
22
|
+
_ripl-rails_ by `gem install ripl-rails` then run this:
|
23
|
+
|
24
|
+
ripl rc rails
|
25
|
+
|
26
|
+
Then you'll have a _ripl-rc_ flavored rails console without
|
27
|
+
setting anything (i.e. `~/.riplrc`)
|
28
|
+
|
29
|
+
If you already know what is _ripl_, you might want to setup
|
30
|
+
yourself, to be better control what you might want and what
|
31
|
+
you might not want. Then checkout FEATURES for all plugins
|
32
|
+
you can put in `~/.riplrc`.
|
33
|
+
|
34
|
+
If you want to enable all plugins, the use this:
|
35
|
+
|
36
|
+
require 'ripl/rc'
|
37
|
+
|
38
|
+
Another thing which might worth to be mentioned is
|
39
|
+
`ripl/rc/anchor`, which is a _pry_ like feature built into
|
40
|
+
ripl. You can embed two things into ripl, one is any object:
|
41
|
+
|
42
|
+
Ripl.anchor your_object_want_to_be_viewed_as_self
|
43
|
+
|
44
|
+
Another one is local binding inside a method:
|
45
|
+
|
46
|
+
Ripl.anchor binding
|
47
|
+
|
48
|
+
Then you can look through local variables inside a method
|
49
|
+
with an interactive environment. Anchor could be nested, too.
|
50
|
+
You can anchor another object inside a _ripl_ session. The number
|
51
|
+
shown in prompt is the level of anchors, started from 1.
|
52
|
+
|
53
|
+

|
54
|
+
|
55
|
+
## FEATURES:
|
56
|
+
|
57
|
+
when session ends
|
58
|
+
|
59
|
+
* require 'ripl/rc/squeeze_history'
|
60
|
+
* require 'ripl/rc/mkdir_history'
|
61
|
+
* require 'ripl/rc/ctrld_newline'
|
62
|
+
|
63
|
+
result format
|
64
|
+
|
65
|
+
* require 'ripl/rc/strip_backtrace'
|
66
|
+
* require 'ripl/rc/color'
|
67
|
+
|
68
|
+
input modification
|
69
|
+
|
70
|
+
* require 'ripl/rc/multiline' # work better with anchor...
|
71
|
+
* require 'ripl/rc/eat_whites'
|
72
|
+
|
73
|
+
speical tool
|
74
|
+
|
75
|
+
* require 'ripl/rc/anchor' # pry like, use: Ripl.anchor(binding) # or obj
|
76
|
+
|
77
|
+
config
|
78
|
+
|
79
|
+
* require 'ripl/rc/noirbrc'
|
80
|
+
|
81
|
+
for lazies
|
82
|
+
|
83
|
+
* require 'ripl/rc' # for all of above
|
84
|
+
|
85
|
+
## REQUIREMENTS:
|
86
|
+
|
87
|
+
* ripl
|
88
|
+
|
89
|
+
## INSTALL:
|
90
|
+
|
91
|
+
gem install ripl-rc
|
92
|
+
|
93
|
+
## LICENSE:
|
94
|
+
|
95
|
+
Apache License 2.0
|
96
|
+
|
97
|
+
Copyright (c) 2010, Lin Jen-Shin (godfat)
|
98
|
+
|
99
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
100
|
+
you may not use this file except in compliance with the License.
|
101
|
+
You may obtain a copy of the License at
|
102
|
+
|
103
|
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
104
|
+
|
105
|
+
Unless required by applicable law or agreed to in writing, software
|
106
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
107
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
108
|
+
See the License for the specific language governing permissions and
|
109
|
+
limitations under the License.
|
data/Rakefile
CHANGED
@@ -1,115 +1,20 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
require "#{dir = File.dirname(__FILE__)}/task/gemgem"
|
3
|
+
Gemgem.dir = dir
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
if File.exist?(gemspec) && File.read(gemspec).strip != ''
|
7
|
-
require 'bundler'
|
8
|
-
# please do me a favor, don't use thor!!
|
9
|
-
b = Bundler::GemHelper.new(File.dirname(__FILE__))
|
10
|
-
Bundler::GemHelper.send(:public, :name, :version, :version_tag)
|
11
|
-
|
12
|
-
desc "Build #{b.name}-#{b.version}.gem into the pkg directory"
|
13
|
-
task :build => [:gemspec] do
|
14
|
-
b.build_gem
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Build and install #{b.name}-#{b.version}.gem into system gems"
|
18
|
-
task :install => [:gemspec] do
|
19
|
-
b.install_gem
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "Create tag #{b.version_tag} and build and push " \
|
23
|
-
"#{b.name}-#{b.version}.gem to Rubygems"
|
24
|
-
task :release => [:gemspec, :check_version] do
|
25
|
-
b.release_gem
|
26
|
-
end
|
27
|
-
|
28
|
-
task :check_version do
|
29
|
-
if ENV['VERSION'].nil?
|
30
|
-
puts("\x1b[32mPlease provide " \
|
31
|
-
"\x1b[36mVERSION\x1b[32m=\x1b[36mx.y.z\x1b[m")
|
32
|
-
exit(1)
|
33
|
-
|
34
|
-
elsif ENV['VERSION'] != b.version.to_s
|
35
|
-
puts("\x1b[32mYou gave \x1b[36mVERSION\x1b[32m=\x1b[36m#{b.version} " \
|
36
|
-
"\x1b[32mbut got\n \x1b[36m" \
|
37
|
-
"VERSION\x1b[32m=\x1b[36m#{ENV['VERSION']}\x1b[m")
|
38
|
-
exit(2)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
desc 'Generate rdoc'
|
44
|
-
task :rdoc do
|
45
|
-
sh('rdoc --output rdoc --main README.rdoc')
|
46
|
-
end
|
47
|
-
|
48
|
-
desc 'Run tests'
|
49
|
-
task :test do
|
50
|
-
sh("#{Gem.ruby} -I lib -S bacon test/test_*.rb")
|
51
|
-
end
|
5
|
+
($LOAD_PATH << File.expand_path("#{Gemgem.dir}/lib" )).uniq!
|
52
6
|
|
53
7
|
desc 'Generate gemspec'
|
54
|
-
task :
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
def to_regexpes pathes
|
63
|
-
pathes.map{ |ignore|
|
64
|
-
if ignore =~ /\*/
|
65
|
-
to_regexpes(Dir["**/#{ignore}"])
|
66
|
-
else
|
67
|
-
Regexp.new("^#{Regexp.escape(ignore)}")
|
68
|
-
end
|
69
|
-
}.flatten
|
70
|
-
end
|
71
|
-
|
72
|
-
def ignore_files
|
73
|
-
@ignore_files ||= to_regexpes(
|
74
|
-
File.read("#{dir}/.gitignore").split("\n") + ['.git/'])
|
75
|
-
end
|
8
|
+
task 'gem:spec' do
|
9
|
+
Gemgem.spec = Gemgem.create do |s|
|
10
|
+
require 'ripl/rc/version'
|
11
|
+
s.name = 'ripl-rc'
|
12
|
+
s.version = Ripl::Rc::VERSION
|
13
|
+
s.executables = [s.name]
|
76
14
|
|
77
|
-
|
78
|
-
|
15
|
+
%w[ripl] .each{ |g| s.add_runtime_dependency(g) }
|
16
|
+
%w[bacon rr].each{ |g| s.add_development_dependency(g) }
|
79
17
|
end
|
80
18
|
|
81
|
-
|
82
|
-
path.children.select(&:file?).map{ |file| file.to_s[(dir.size+1)..-1] }.
|
83
|
-
reject{ |file| ignore_files.find{ |ignore| file.to_s =~ ignore }} +
|
84
|
-
|
85
|
-
path.children.select(&:directory?).map{ |dir| gem_files_find(dir)}.flatten
|
86
|
-
end
|
87
|
-
|
88
|
-
File.open('ripl-rc.gemspec', 'w'){ |f|
|
89
|
-
f <<
|
90
|
-
Gem::Specification.new do |s|
|
91
|
-
s.name = 'ripl-rc'
|
92
|
-
s.version = Ripl::Rc::VERSION
|
93
|
-
|
94
|
-
s.add_dependency('ripl')
|
95
|
-
%w[bacon rr].each{ |g|
|
96
|
-
s.add_development_dependency(g)
|
97
|
-
}
|
98
|
-
|
99
|
-
s.authors = ['Lin Jen-Shin (godfat)']
|
100
|
-
s.email = ['godfat (XD) godfat.org']
|
101
|
-
s.homepage = "http://github.com/godfat/#{s.name}"
|
102
|
-
s.summary = File.read("#{File.dirname(__FILE__)}/README.rdoc").
|
103
|
-
match(/== DESCRIPTION:\n\n(.+)?\n\n== FEATURES:/m)[1]
|
104
|
-
s.description = s.summary
|
105
|
-
|
106
|
-
s.date = Time.now.strftime('%Y-%m-%d')
|
107
|
-
s.rubygems_version = Gem::VERSION
|
108
|
-
s.files = gem_files
|
109
|
-
s.test_files = gem_files.grep(/test_.+?\.rb$/)
|
110
|
-
s.extra_rdoc_files = []
|
111
|
-
s.rdoc_options = ['--main', 'README.rdoc']
|
112
|
-
s.require_paths = ['lib']
|
113
|
-
end.to_ruby
|
114
|
-
}
|
19
|
+
Gemgem.write
|
115
20
|
end
|
data/bin/ripl-rc
ADDED
data/lib/ripl/rc/anchor.rb
CHANGED
@@ -21,7 +21,7 @@ module Ripl::Rc::Anchor
|
|
21
21
|
if Ripl::Rc.const_defined?(:Color) && kind_of?(Ripl::Rc::Color) &&
|
22
22
|
obj_or_binding = (config[:rc_anchor] ||= []).last
|
23
23
|
|
24
|
-
super.sub(
|
24
|
+
super.sub(@name, format_result(obj_or_binding, @name))
|
25
25
|
else
|
26
26
|
super
|
27
27
|
end
|
@@ -30,10 +30,17 @@ module Ripl::Rc::Anchor
|
|
30
30
|
# if the object is the same, then we're exiting from an anchor,
|
31
31
|
# so don't print anything.
|
32
32
|
def print_result result
|
33
|
-
super unless result
|
33
|
+
super unless result != nil &&
|
34
|
+
result.object_id == Ripl.config[:rc_anchor_last].object_id
|
34
35
|
end
|
35
36
|
|
36
37
|
module Imp
|
38
|
+
def short_inspect obj_or_binding
|
39
|
+
obj_or_binding.inspect[0..9]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module AnchorImp
|
37
44
|
def anchor obj_or_binding
|
38
45
|
if Ripl.config[:rc_init].nil?
|
39
46
|
Ripl::Runner.load_rc(Ripl.config[:riplrc])
|
@@ -41,10 +48,10 @@ module Ripl::Rc::Anchor
|
|
41
48
|
end
|
42
49
|
|
43
50
|
(Ripl.config[:rc_anchor] ||= []) << obj_or_binding
|
51
|
+
name = Ripl::Rc::U.short_inspect(obj_or_binding)
|
44
52
|
Ripl::Shell.create(Ripl.config.merge(
|
45
|
-
:name =>
|
46
|
-
:prompt =>
|
47
|
-
"(#{Ripl.config[:rc_anchor].size})" +
|
53
|
+
:name => name,
|
54
|
+
:prompt => "#{name}(#{Ripl.config[:rc_anchor].size})" +
|
48
55
|
Ripl.config[:prompt])).loop
|
49
56
|
|
50
57
|
# stores to check if we're exiting from an anchor
|
@@ -53,7 +60,9 @@ module Ripl::Rc::Anchor
|
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
56
|
-
Ripl::
|
63
|
+
module Ripl::Rc::U; extend Ripl::Rc::Anchor::Imp; end
|
57
64
|
|
58
|
-
Ripl.
|
65
|
+
Ripl::Shell.include(Ripl::Rc::Anchor)
|
59
66
|
Ripl.config[:prompt] ||= Ripl::Shell::OPTIONS[:prompt]
|
67
|
+
|
68
|
+
Ripl.extend(Ripl::Rc::Anchor::AnchorImp) # define Ripl.anchor
|
data/lib/ripl/rc/color.rb
CHANGED
@@ -5,30 +5,54 @@ module Ripl::Rc; end
|
|
5
5
|
module Ripl::Rc::Color
|
6
6
|
include Ripl::Rc # makes U avaliable
|
7
7
|
|
8
|
-
def format_result result
|
8
|
+
def format_result result, display=result.inspect
|
9
9
|
case result
|
10
|
-
when String ; U.send(U.colors[String ]){
|
11
|
-
when Numeric; U.send(U.colors[Numeric ]){
|
12
|
-
when Symbol ; U.send(U.colors[Symbol ]){
|
13
|
-
|
10
|
+
when String ; U.send(U.colors[String ]){ display }
|
11
|
+
when Numeric; U.send(U.colors[Numeric ]){ display }
|
12
|
+
when Symbol ; U.send(U.colors[Symbol ]){ display }
|
13
|
+
|
14
|
+
when Array ; U.send(U.colors[Array ]){ '[' } +
|
14
15
|
result.map{ |e| format_result(e) }.join(
|
15
|
-
U.send(U.colors[Array ]){ ', '
|
16
|
-
U.send(U.colors[Array ]){ ']'
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
U.send(U.colors[Array ]){ ', ' }) +
|
17
|
+
U.send(U.colors[Array ]){ ']' }
|
18
|
+
|
19
|
+
when Hash ; U.send(U.colors[Hash ]){ '{' } +
|
20
|
+
result.map{ |k, v| format_result(k) +
|
21
|
+
U.send(U.colors[Hash ]){ '=>' } +
|
20
22
|
format_result(v) }.join(
|
21
|
-
U.send(U.colors[Hash ]){ ', '
|
22
|
-
U.send(U.colors[Hash ]){ '}'
|
23
|
-
|
24
|
-
|
23
|
+
U.send(U.colors[Hash ]){ ', ' }) +
|
24
|
+
U.send(U.colors[Hash ]){ '}' }
|
25
|
+
|
26
|
+
# TODO: this find should preserve order!
|
27
|
+
else ; if color = U.find_color(result)
|
28
|
+
U.send(color){ display }
|
25
29
|
else
|
26
|
-
U.send(U.colors[Object ]){
|
30
|
+
U.send(U.colors[Object ]){ display }
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
35
|
+
def get_error e, backtrace=e.backtrace
|
36
|
+
[format_result(e, "#{e.class.to_s}: #{e.message}"),
|
37
|
+
backtrace.map{ |b|
|
38
|
+
path, rest = File.split(b)
|
39
|
+
name, msgs = rest.split(':', 2)
|
40
|
+
msg = msgs.sub(/(\d+):/){U.red{$1}+':'}.sub(/`.+?'/){U.green{$&}}
|
41
|
+
|
42
|
+
"#{path+'/'}#{U.yellow{name}}:#{msg}"
|
43
|
+
}]
|
44
|
+
end
|
45
|
+
|
31
46
|
module Imp
|
47
|
+
def find_color value
|
48
|
+
(colors.sort{ |(k1, v1), (k2, v2)|
|
49
|
+
# Class <=> Class
|
50
|
+
if k1 < k2 then -1
|
51
|
+
elsif k1 > k2 then 1
|
52
|
+
else then 0
|
53
|
+
end}.find{ |(klass, _)| value.kind_of?(klass) } || []).last
|
54
|
+
end
|
55
|
+
|
32
56
|
def colors
|
33
57
|
Ripl.config[:rc_color]
|
34
58
|
end
|
@@ -53,13 +77,14 @@ module Ripl::Rc::U; extend Ripl::Rc::Color::Imp; end
|
|
53
77
|
|
54
78
|
Ripl::Shell.include(Ripl::Rc::Color)
|
55
79
|
Ripl.config[:rc_color] ||= {
|
56
|
-
String => :green ,
|
57
80
|
Numeric => :red ,
|
81
|
+
String => :green ,
|
58
82
|
Symbol => :cyan ,
|
59
83
|
Array => :blue ,
|
60
84
|
Hash => :blue ,
|
61
85
|
NilClass => :magenta,
|
62
86
|
TrueClass => :magenta,
|
63
87
|
FalseClass => :magenta,
|
88
|
+
Exception => :magenta,
|
64
89
|
Object => :yellow
|
65
90
|
}
|
@@ -31,7 +31,7 @@ module Ripl::Rc::SqueezeHistory
|
|
31
31
|
else
|
32
32
|
result << item
|
33
33
|
end
|
34
|
-
}.last(Ripl.config[:rc_squeeze_history_size]
|
34
|
+
}.last(Ripl.config[:rc_squeeze_history_size])
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -39,3 +39,4 @@ end
|
|
39
39
|
module Ripl::Rc::U; extend Ripl::Rc::SqueezeHistory::Imp; end
|
40
40
|
|
41
41
|
Ripl::Shell.include(Ripl::Rc::SqueezeHistory)
|
42
|
+
Ripl.config[:rc_squeeze_history_size] ||= 500
|
@@ -7,7 +7,12 @@ module Ripl::Rc::StripBacktrace
|
|
7
7
|
|
8
8
|
# strip backtrace until ripl
|
9
9
|
def format_error e
|
10
|
-
|
10
|
+
message, backtrace = get_error(e, U.strip_backtrace(e, @name))
|
11
|
+
"#{message}\n #{backtrace.join("\n ")}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_error e, backtrace=e.backtrace
|
15
|
+
["#{e.class}: #{e.message}", backtrace]
|
11
16
|
end
|
12
17
|
|
13
18
|
module Imp
|
@@ -20,10 +25,11 @@ module Ripl::Rc::StripBacktrace
|
|
20
25
|
end
|
21
26
|
|
22
27
|
def cwd b
|
23
|
-
b.map{ |p| p.sub(Dir.pwd, '
|
28
|
+
b.map{ |p| p.sub(Dir.pwd, '.') }
|
24
29
|
end
|
25
30
|
|
26
31
|
def snip e, name
|
32
|
+
return [] if e.kind_of?(SyntaxError)
|
27
33
|
e.backtrace[
|
28
34
|
0..
|
29
35
|
e.backtrace.rindex{ |l| l =~ /\(#{name}\):\d+:in `.+?'/ } || -1]
|
data/lib/ripl/rc/version.rb
CHANGED
data/lib/ripl/rc.rb
CHANGED
data/ripl-rc.gemspec
CHANGED
@@ -2,19 +2,22 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ripl-rc}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
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-02-
|
10
|
-
s.
|
9
|
+
s.date = %q{2011-02-28}
|
10
|
+
s.default_executable = %q{ripl-rc}
|
11
|
+
s.description = %q{ripl plugins collection, take you want, leave you don't.}
|
11
12
|
s.email = ["godfat (XD) godfat.org"]
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
13
|
+
s.executables = ["ripl-rc"]
|
14
|
+
s.extra_rdoc_files = ["CHANGES", "CONTRIBUTORS", "LICENSE", "TODO"]
|
15
|
+
s.files = [".gitignore", "CHANGES", "CONTRIBUTORS", "Gemfile", "LICENSE", "README", "README.md", "Rakefile", "TODO", "bin/ripl-rc", "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"]
|
16
|
+
s.homepage = %q{http://github.com/godfat/}
|
17
|
+
s.rdoc_options = ["--main", "README"]
|
15
18
|
s.require_paths = ["lib"]
|
16
|
-
s.rubygems_version = %q{1.5.
|
17
|
-
s.summary = %q{ripl plugins collection}
|
19
|
+
s.rubygems_version = %q{1.5.3}
|
20
|
+
s.summary = %q{ripl plugins collection, take you want, leave you don't.}
|
18
21
|
s.test_files = ["test/test_squeeze_history.rb"]
|
19
22
|
|
20
23
|
if s.respond_to? :specification_version then
|
data/screenshot.png
ADDED
Binary file
|
data/task/gemgem.rb
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Gemgem
|
5
|
+
class << self
|
6
|
+
attr_accessor :dir, :spec
|
7
|
+
end
|
8
|
+
|
9
|
+
module_function
|
10
|
+
def create
|
11
|
+
yield(spec = Gem::Specification.new{ |s|
|
12
|
+
s.authors = ['Lin Jen-Shin (godfat)']
|
13
|
+
s.email = ['godfat (XD) godfat.org']
|
14
|
+
s.homepage = "http://github.com/godfat/#{s.name}"
|
15
|
+
|
16
|
+
s.summary = File.read("#{Gemgem.dir}/README").
|
17
|
+
match(/DESCRIPTION:\n\n(.+?)\n\n/m)[1]
|
18
|
+
s.description = s.summary
|
19
|
+
|
20
|
+
s.extra_rdoc_files = %w[CHANGES CONTRIBUTORS LICENSE TODO]
|
21
|
+
s.rdoc_options = %w[--main README]
|
22
|
+
s.rubygems_version = Gem::VERSION
|
23
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
24
|
+
s.files = gem_files
|
25
|
+
s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
|
26
|
+
s.require_paths = %w[lib]
|
27
|
+
})
|
28
|
+
spec
|
29
|
+
end
|
30
|
+
|
31
|
+
def gem_tag
|
32
|
+
"#{spec.name}-#{spec.version}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def write
|
36
|
+
File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f| f << spec.to_ruby }
|
37
|
+
end
|
38
|
+
|
39
|
+
def all_files
|
40
|
+
@all_files ||= find_files(Pathname.new(dir)).map{ |file|
|
41
|
+
if file.to_s =~ %r{\.git/}
|
42
|
+
nil
|
43
|
+
else
|
44
|
+
file.to_s
|
45
|
+
end
|
46
|
+
}.compact.sort
|
47
|
+
end
|
48
|
+
|
49
|
+
def gem_files
|
50
|
+
@gem_files ||= all_files - ignored_files
|
51
|
+
end
|
52
|
+
|
53
|
+
def ignored_files
|
54
|
+
@ignored_file ||= all_files.select{ |path| ignore_patterns.find{ |ignore|
|
55
|
+
path =~ ignore && !git_files.include?(path)}}
|
56
|
+
end
|
57
|
+
|
58
|
+
def git_files
|
59
|
+
@git_files ||= if File.exist?("#{dir}/.git")
|
60
|
+
`git ls-files`.split("\n")
|
61
|
+
else
|
62
|
+
[]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# protected
|
67
|
+
def find_files path
|
68
|
+
path.children.select(&:file?).map{|file| file.to_s[(dir.size+1)..-1]} +
|
69
|
+
path.children.select(&:directory?).map{|dir| find_files(dir)}.flatten
|
70
|
+
end
|
71
|
+
|
72
|
+
def ignore_patterns
|
73
|
+
@ignore_files ||= expand_patterns(
|
74
|
+
File.read("#{dir}/.gitignore").split("\n").reject{ |pattern|
|
75
|
+
pattern.strip == ''
|
76
|
+
}).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
|
77
|
+
end
|
78
|
+
|
79
|
+
def expand_patterns pathes
|
80
|
+
pathes.map{ |path|
|
81
|
+
if path !~ /\*/
|
82
|
+
path
|
83
|
+
else
|
84
|
+
expand_patterns(
|
85
|
+
Dir[path] +
|
86
|
+
Pathname.new(File.dirname(path)).children.select(&:directory?).
|
87
|
+
map{ |prefix| "#{prefix}/#{File.basename(path)}" })
|
88
|
+
end
|
89
|
+
}.flatten
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
namespace :gem do
|
94
|
+
|
95
|
+
desc 'Install gem'
|
96
|
+
task :install => [:build] do
|
97
|
+
sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}")
|
98
|
+
end
|
99
|
+
|
100
|
+
desc 'Build gem'
|
101
|
+
task :build => [:spec] do
|
102
|
+
sh("#{Gem.ruby} -S gem build #{Gemgem.spec.name}.gemspec")
|
103
|
+
sh("mkdir -p pkg")
|
104
|
+
sh("mv #{Gemgem.gem_tag}.gem pkg/")
|
105
|
+
end
|
106
|
+
|
107
|
+
desc 'Release gem'
|
108
|
+
task :release => [:spec, :check, :build] do
|
109
|
+
sh("git tag #{Gemgem.gem_tag}")
|
110
|
+
sh("git push")
|
111
|
+
sh("git push --tags")
|
112
|
+
sh("#{Gem.ruby} -S gem push pkg/#{Gemgem.gem_tag}.gem")
|
113
|
+
end
|
114
|
+
|
115
|
+
task :check do
|
116
|
+
ver = Gemgem.spec.version.to_s
|
117
|
+
|
118
|
+
if ENV['VERSION'].nil?
|
119
|
+
puts("\x1b[35mExpected " \
|
120
|
+
"\x1b[33mVERSION\x1b[35m=\x1b[33m#{ver}\x1b[m")
|
121
|
+
exit(1)
|
122
|
+
|
123
|
+
elsif ENV['VERSION'] != ver
|
124
|
+
puts("\x1b[35mExpected \x1b[33mVERSION\x1b[35m=\x1b[33m#{ver} " \
|
125
|
+
"\x1b[35mbut got\n " \
|
126
|
+
"\x1b[33mVERSION\x1b[35m=\x1b[33m#{ENV['VERSION']}\x1b[m")
|
127
|
+
exit(2)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end # of gem namespace
|
132
|
+
|
133
|
+
desc 'Run tests'
|
134
|
+
task :test do
|
135
|
+
sh("#{Gem.ruby} -I lib -S bacon test/test_*.rb")
|
136
|
+
end
|
137
|
+
|
138
|
+
desc 'Generate rdoc'
|
139
|
+
task :doc => ['gem:spec'] do
|
140
|
+
sh("yardoc -o rdoc --main README.md" \
|
141
|
+
" --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
|
142
|
+
end
|
143
|
+
|
144
|
+
desc 'Removed ignored files'
|
145
|
+
task :clean => ['gem:spec'] do
|
146
|
+
trash = "~/.Trash/#{Gemgem.spec.name}/"
|
147
|
+
sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
|
148
|
+
Gemgem.ignored_files.each{ |file| sh "mv #{file} #{trash}" }
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
task :default do
|
153
|
+
Rake.application.options.show_task_pattern = /./
|
154
|
+
Rake.application.display_tasks_and_comments
|
155
|
+
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-02-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-02-28 00:00:00.000000000 +08:00
|
13
|
+
default_executable: ripl-rc
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ripl
|
17
|
-
requirement: &
|
17
|
+
requirement: &2151890980 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2151890980
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bacon
|
28
|
-
requirement: &
|
28
|
+
requirement: &2151890220 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2151890220
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rr
|
39
|
-
requirement: &
|
39
|
+
requirement: &2151889520 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,22 +44,29 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
48
|
-
description: ripl plugins collection
|
47
|
+
version_requirements: *2151889520
|
48
|
+
description: ripl plugins collection, take you want, leave you don't.
|
49
49
|
email:
|
50
50
|
- godfat (XD) godfat.org
|
51
|
-
executables:
|
51
|
+
executables:
|
52
|
+
- ripl-rc
|
52
53
|
extensions: []
|
53
|
-
extra_rdoc_files:
|
54
|
+
extra_rdoc_files:
|
55
|
+
- CHANGES
|
56
|
+
- CONTRIBUTORS
|
57
|
+
- LICENSE
|
58
|
+
- TODO
|
54
59
|
files:
|
55
60
|
- .gitignore
|
56
61
|
- CHANGES
|
62
|
+
- CONTRIBUTORS
|
57
63
|
- Gemfile
|
58
64
|
- LICENSE
|
59
|
-
- README
|
65
|
+
- README
|
66
|
+
- README.md
|
60
67
|
- Rakefile
|
61
68
|
- TODO
|
62
|
-
- ripl-rc
|
69
|
+
- bin/ripl-rc
|
63
70
|
- lib/ripl/rc.rb
|
64
71
|
- lib/ripl/rc/anchor.rb
|
65
72
|
- lib/ripl/rc/color.rb
|
@@ -67,17 +74,21 @@ files:
|
|
67
74
|
- lib/ripl/rc/eat_whites.rb
|
68
75
|
- lib/ripl/rc/mkdir_history.rb
|
69
76
|
- lib/ripl/rc/multiline.rb
|
77
|
+
- lib/ripl/rc/noirbrc.rb
|
70
78
|
- lib/ripl/rc/squeeze_history.rb
|
71
79
|
- lib/ripl/rc/strip_backtrace.rb
|
72
80
|
- lib/ripl/rc/version.rb
|
81
|
+
- ripl-rc.gemspec
|
82
|
+
- screenshot.png
|
83
|
+
- task/gemgem.rb
|
73
84
|
- test/test_squeeze_history.rb
|
74
85
|
has_rdoc: true
|
75
|
-
homepage: http://github.com/godfat/
|
86
|
+
homepage: http://github.com/godfat/
|
76
87
|
licenses: []
|
77
88
|
post_install_message:
|
78
89
|
rdoc_options:
|
79
90
|
- --main
|
80
|
-
- README
|
91
|
+
- README
|
81
92
|
require_paths:
|
82
93
|
- lib
|
83
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -94,9 +105,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
105
|
version: '0'
|
95
106
|
requirements: []
|
96
107
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.5.
|
108
|
+
rubygems_version: 1.5.3
|
98
109
|
signing_key:
|
99
110
|
specification_version: 3
|
100
|
-
summary: ripl plugins collection
|
111
|
+
summary: ripl plugins collection, take you want, leave you don't.
|
101
112
|
test_files:
|
102
113
|
- test/test_squeeze_history.rb
|
data/README.rdoc
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
= ripl-rc 0.1.1
|
2
|
-
by Lin Jen-Shin (godfat[http://godfat.org])
|
3
|
-
|
4
|
-
== LINKS:
|
5
|
-
|
6
|
-
* {github}[http://github.com/godfat/ripl-rc]
|
7
|
-
* {rubygems}[http://rubygems.org/gems/ripl-rc]
|
8
|
-
|
9
|
-
== DESCRIPTION:
|
10
|
-
|
11
|
-
ripl plugins collection
|
12
|
-
|
13
|
-
== FEATURES:
|
14
|
-
|
15
|
-
# when session ends
|
16
|
-
* require 'ripl/rc/squeeze_history'
|
17
|
-
* require 'ripl/rc/mkdir_history'
|
18
|
-
* require 'ripl/rc/ctrld_newline'
|
19
|
-
|
20
|
-
# result format
|
21
|
-
* require 'ripl/rc/strip_backtrace'
|
22
|
-
* require 'ripl/rc/color'
|
23
|
-
|
24
|
-
# input modification
|
25
|
-
* require 'ripl/rc/multiline' # work better with anchor...
|
26
|
-
* require 'ripl/rc/eat_whites'
|
27
|
-
|
28
|
-
# speical tool
|
29
|
-
* require 'ripl/rc/anchor' # pry like, use: Ripl.anchor(binding) # or obj
|
30
|
-
|
31
|
-
# for lazies
|
32
|
-
* require 'ripl/rc' # for all of above
|
33
|
-
|
34
|
-
== REQUIREMENTS:
|
35
|
-
|
36
|
-
* ripl
|
37
|
-
|
38
|
-
== INSTALL:
|
39
|
-
|
40
|
-
gem install ripl-rc
|
41
|
-
|
42
|
-
== LICENSE:
|
43
|
-
|
44
|
-
Apache License 2.0
|
45
|
-
|
46
|
-
Copyright (c) 2010, Lin Jen-Shin (godfat)
|
47
|
-
|
48
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
49
|
-
you may not use this file except in compliance with the License.
|
50
|
-
You may obtain a copy of the License at
|
51
|
-
|
52
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
53
|
-
|
54
|
-
Unless required by applicable law or agreed to in writing, software
|
55
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
56
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
57
|
-
See the License for the specific language governing permissions and
|
58
|
-
limitations under the License.
|