rib 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Rib CHANGES
2
2
 
3
+ ## Rib 0.9.1 -- 2011-08-19
4
+
5
+ * [extra/autoindent] Autoindent plugin help you indent multiline editing.
6
+ Note: This plugin is depending on [readline_buffer][], thus GNU Readline.
7
+
8
+ * [ripl] After `require 'rib/ripl'`, ripl plugins should be usable for rib.
9
+
10
+ * [rib] Introduce `ENV['RIB_HOME']` to set where to store config and history.
11
+ By default, it's `~/.rib` now, but it would first search for existing
12
+ config or history, which would first try to see `~/.rib/config.rb`, and
13
+ then `~/.rib/history.rb`. If Rib can find anything there, then `RIB_HOME`
14
+ would be set to `~/.rib`, the same goes to `~/.config/rib`.
15
+ In short, by default `RIB_HOME` is `~/.rib`, but the old `~/.config/rib`
16
+ still works.
17
+
18
+ [readline_buffer]: https://github.com/godfat/readline_buffer
19
+
3
20
  ## Rib 0.9.0 -- 2011-08-14
4
21
 
5
22
  * First serious release!
data/README.md CHANGED
@@ -6,6 +6,7 @@ by Lin Jen-Shin ([godfat](http://godfat.org))
6
6
 
7
7
  * [github](https://github.com/godfat/rib)
8
8
  * [rubygems](http://rubygems.org/gems/rib)
9
+ * [rdoc](http://rdoc.info/github/godfat/rib)
9
10
 
10
11
  ## DESCRIPTION:
11
12
 
@@ -38,7 +39,7 @@ be simple, lightweight and modular so that everyone could customize Rib.
38
39
 
39
40
  ### As an interactive shell
40
41
 
41
- As IRB (reads `~/.config/rib/config.rb` writes `~/.config/rib/history.rb`)
42
+ As IRB (reads `~/.rib/config.rb` writes `~/.rib/history.rb`)
42
43
 
43
44
  rib
44
45
 
@@ -63,18 +64,23 @@ As a fully featured app console (yes, some commands could be used together)
63
64
 
64
65
  rib all auto # or `rib auto all`, the order doesn't really matter
65
66
 
66
- You can customize Rib's behaviour by setting `~/.config/rib/config.rb` (by
67
- default). Since it's merely a Ruby script which would be loaded into memory
68
- before launching Rib shell session, You can put any customization or monkey
69
- patch there. Personally, I use all plugins provided by Rib.
67
+ You can customize Rib's behaviour by setting a config file located at
68
+ `~/.rib/config.rb` or `~/.config/rib/config.rb`, or `$RIB_HOME/config.rb` by
69
+ setting `$RIB_HOME` environment variable. Since it's merely a Ruby script
70
+ which would be loaded into memory before launching Rib shell session, You can
71
+ put any customization or monkey patch there. Personally, I use all plugins
72
+ provided by Rib.
70
73
 
71
74
  <https://github.com/godfat/dev-tool/blob/master/.config/rib/config.rb>
72
75
 
73
76
  As you can see, putting `require 'rib/all'` into config file is exactly the
74
77
  same as running `rib all` without a config file. What `rib all` would do is
75
- merely require the file, and that file is also merely requiring all plugins.
76
- Suppose you only want to use the core plugins and color plugin, you'll put
77
- this into your config file:
78
+ merely require the file, and that file is also merely requiring all plugins,
79
+ but without **extra plugins**, which you should enable them one by one. This
80
+ is because most extra plugins are depending on other gems, or hard to work
81
+ with other plugins, or having strong personal tastes, so you won't want to
82
+ enable them all. Suppose you only want to use the core plugins and color
83
+ plugin, you'll put this into your config file:
78
84
 
79
85
  require 'rib/core'
80
86
  require 'rib/more/color'
@@ -97,27 +103,43 @@ So that we override the original format_result to pretty_inspect the result.
97
103
  You can also build your own gem and then simply require it in your config
98
104
  file. To see a list of overridable API, please read [api.rb][]
99
105
 
106
+ Currently, there are two **extra plugins**.
107
+
108
+ * `require 'rib/extra/autoindent'` This plugin is depending on:
109
+
110
+ 1. [readline_buffer][]
111
+ 2. readline plugin
112
+ 3. multiline plugin
113
+
114
+ * `require 'rib/extra/hirb'` This plugin is depending on:
115
+
116
+ 1. [hirb][]
117
+
100
118
  [api.rb]: https://github.com/godfat/rib/blob/master/lib/rib/api.rb
119
+ [readline_buffer]: https://github.com/godfat/readline_buffer
120
+ [hirb]: https://github.com/cldwalker/hirb
101
121
 
102
122
  #### Basic configuration
103
123
 
104
- <pre>
124
+ Rib.config | Functionality
125
+ -------------------------- | -------------------------------------------------
126
+ ENV['RIB_HOME'] | Specify where Rib should store config and history
105
127
  Rib.config[:config] | The path where config should be located
106
128
  Rib.config[:name] | The name of this shell
107
129
  Rib.config[:result_prompt] | Default is "=>"
108
130
  Rib.config[:prompt] | Default is ">>"
109
131
  Rib.config[:binding] | Context, default: TOPLEVEL_BINDING
110
132
  Rib.config[:exit] | Commands to exit, default [nil, 'exit', 'quit']
111
- </pre>
112
133
 
113
134
  #### Plugin specific configuration
114
135
 
115
- <pre>
116
- Rib.config[:completion] | Completion: Bond config
117
- Rib.config[:history_file] | Default is "~/.rib/config/history.rb"
118
- Rib.config[:history_size] | Default is 500
119
- Rib.config[:color] | A hash of Class => :color mapping
120
- </pre>
136
+ Rib.config | Functionality
137
+ ------------------------------ | ---------------------------------------------
138
+ Rib.config[:completion] | Completion: Bond config
139
+ Rib.config[:history_file] | Default is "~/.rib/config/history.rb"
140
+ Rib.config[:history_size] | Default is 500
141
+ Rib.config[:color] | A hash of Class => :color mapping
142
+ Rib.config[:autoindent_spaces] | How to indent? Default is two spaces: ' '
121
143
 
122
144
  ### As a debugging/interacting tool
123
145
 
data/Rakefile CHANGED
@@ -14,8 +14,10 @@ task 'gem:spec' do
14
14
  %w[].each{ |g| s.add_runtime_dependency(g) }
15
15
  %w[bond
16
16
  hirb
17
+ readline_buffer
17
18
  bacon
18
- rr] .each{ |g| s.add_development_dependency(g) }
19
+ rr
20
+ rake].each{ |g| s.add_development_dependency(g) }
19
21
  end
20
22
 
21
23
  Gemgem.write
data/TODO.md CHANGED
@@ -2,5 +2,4 @@
2
2
 
3
3
  * Runner tests
4
4
  * Documentation
5
- * Fix Rubinius weird Runtime BOOM error
6
5
  * Implement exception_spy
@@ -10,16 +10,18 @@ module Rib::History
10
10
 
11
11
  def before_loop
12
12
  return super if History.disabled?
13
- config[:history_file] ||= '~/.config/rib/history.rb'
13
+ config[:history_file] ||= File.join(Rib.home, 'history.rb')
14
14
  config[:history_size] ||= 500
15
15
  FileUtils.mkdir_p(File.dirname(history_file_path))
16
16
  read_history
17
+ Rib.say("History read from: #{history_file_path}") if $VERBOSE
17
18
  super
18
19
  end
19
20
 
20
21
  def after_loop
21
22
  return super if History.disabled?
22
23
  write_history
24
+ Rib.say("History wrote to: #{history_file_path}") if $VERBOSE
23
25
  super
24
26
  end
25
27
 
@@ -1,5 +1,5 @@
1
1
 
2
- require 'rib/core/history'
2
+ require 'rib/core/history' # dependency
3
3
 
4
4
  module Rib::SqueezeHistory
5
5
  include Rib::Plugin
@@ -11,6 +11,7 @@ module Rib::SqueezeHistory
11
11
  def loop_once
12
12
  return super if SqueezeHistory.disabled?
13
13
  begin
14
+ # TODO: history[-1] is MRI 1.9+
14
15
  input, last_input = history[-1], history[-2]
15
16
  rescue IndexError # EditLine is really broken, to_a is needed for it
16
17
  array = history.to_a
@@ -34,6 +35,7 @@ module Rib::SqueezeHistory
34
35
 
35
36
  private
36
37
  def squeezed_history
38
+ # TODO: history.inject is MRI 1.9+
37
39
  history.to_a.inject([]){ |result, item|
38
40
  if result.last == item || item.strip == ''
39
41
  result
@@ -0,0 +1,123 @@
1
+
2
+ require 'rib/core/readline' # dependency
3
+ require 'rib/core/multiline' # dependency
4
+
5
+ module Rib::Autoindent
6
+ include Rib::Plugin
7
+ Shell.use(self)
8
+
9
+ # begin block could be simpler, because it should also trigger
10
+ # SyntaxError, otherwise indention would be wiped out.
11
+ # but end block should be exactly match, because we don't have
12
+ # SyntaxError information, also triggering SyntaxError doesn't
13
+ # mean it's not an end block, thinking about nested multiline!
14
+ BLOCK_REGEXP = {
15
+ # rescue Expression? (=> VariableName)?
16
+ # consider cases:
17
+ # rescue
18
+ # rescue=>e
19
+ # rescue => e
20
+ # rescue =>e
21
+ # rescue E=>e
22
+ # rescue E
23
+ # rescue E => e
24
+ # rescue E=> e
25
+ # rescue E =>e
26
+ /^begin$/ => /^(end)\b|^else$|^rescue *((\w+)? *(=> *\w+)?)?$/,
27
+ # elsif Expression
28
+ # consider cases:
29
+ # elsif(true)
30
+ # elsif true
31
+ # elsif true == true
32
+ # elsif (a = true) && false
33
+ /^if/ => /^(end)\b|^else$|^elsif\b/,
34
+ /^unless/ => /^(end)\b|^else$|^elsif\b/,
35
+ /^case/ => /^(end)\b|^when\b/ ,
36
+ /^def/ => /^(end)\b/ ,
37
+ /^class/ => /^(end)\b/ ,
38
+ /^module/ => /^(end)\b/ ,
39
+ /^while/ => /^(end)\b/ ,
40
+ /^until/ => /^(end)\b/ ,
41
+ # consider cases:
42
+ # 'do
43
+ # "do
44
+ # /do
45
+ # '{
46
+ # "{
47
+ # /{
48
+ /[^'"\/]do( *\|.*\|)?$/ => /^(end)\b/ ,
49
+ /[^'"\/]\{( *\|.*\|)?$/ => /^(\})\B/ ,
50
+ }
51
+
52
+ # --------------- Rib API ---------------
53
+
54
+ def before_loop
55
+ return super if Autoindent.disabled?
56
+ config[:autoindent_spaces] ||= ' '
57
+ super
58
+ end
59
+
60
+ def get_input
61
+ return super if Autoindent.disabled?
62
+ autoindent_stack.clear if multiline_buffer.empty?
63
+ Thread.new do
64
+ sleep(0.01)
65
+ # this should be called after ::Readline.readline, but it's blocking,
66
+ # and i don't know if there's any hook to do this, so here we use thread
67
+ ::Readline.line_buffer = current_autoindent
68
+ end
69
+ super
70
+ end
71
+
72
+ def loop_eval input
73
+ return super if Autoindent.disabled?
74
+ if indented = handle_autoindent(input.strip)
75
+ super(indented)
76
+ else
77
+ super
78
+ end
79
+ end
80
+
81
+ # --------------- Plugin API ---------------
82
+
83
+ def handle_autoindent input
84
+ _, up = BLOCK_REGEXP.find{ |key, _| input =~ key }
85
+ if up
86
+ autoindent_stack << up
87
+ nil
88
+ elsif input =~ autoindent_stack.last
89
+ if $1 # e.g. end, }, etc
90
+ autoindent_stack.pop
91
+ handle_last_line(input)
92
+ else # e.g. elsif, rescue, etc
93
+ handle_last_line(input, current_autoindent(autoindent_stack.size-1))
94
+ end
95
+ end
96
+ end
97
+
98
+ def handle_last_line input, indent=current_autoindent
99
+ new_input = "#{indent}#{input}"
100
+ puts("\e[1A\e[K#{prompt}#{new_input}")
101
+ new_input
102
+ end
103
+
104
+
105
+
106
+ private
107
+ def current_autoindent size=autoindent_stack.size
108
+ config[:autoindent_spaces] * size
109
+ end
110
+
111
+ def autoindent_stack
112
+ @autoindent_stack ||= []
113
+ end
114
+ end
115
+
116
+ begin
117
+ require 'readline_buffer'
118
+ rescue LoadError
119
+ Rib.warn("Please install readline_buffer to use autoindent plugin:\n",
120
+ " gem install readline_buffer\n",
121
+ "Or add readline_buffer to Gemfile if that's the case")
122
+ Rib::Autoindent.disable
123
+ end
@@ -5,6 +5,8 @@ module Rib::Hirb
5
5
  include Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
+ # --------------- Rib API ---------------
9
+
8
10
  def format_result result
9
11
  return super if Hirb.disabled?
10
12
  ::Hirb::View.view_or_page_output(result) || super
@@ -36,6 +36,7 @@ module Rib::MultilineHistory
36
36
  def handle_multiline
37
37
  if multiline_buffer.size > 1
38
38
  # so multiline editing is considering done here
39
+ # TODO: there's no history.pop(size)
39
40
  (multiline_buffer.size + @multiline_trash).times{ history.pop }
40
41
  history << "\n" + multiline_buffer.join("\n")
41
42
  end
@@ -33,6 +33,7 @@ module Rib::MultilineHistoryFile
33
33
 
34
34
  def write_history
35
35
  return super if MultilineHistoryFile.disabled?
36
+ # TODO: hisotroy.map is MRI 1.9+
36
37
  config[:history] = history.to_a.map{ |line|
37
38
  line.gsub("\n", "#{config[:multiline_history_file_token]}\n")
38
39
  }
data/lib/rib/ripl.rb ADDED
@@ -0,0 +1,3 @@
1
+
2
+ Ripl = Rib
3
+ Ripl::Shell.singleton_class.send(:public, :include)
data/lib/rib/test.rb CHANGED
@@ -69,6 +69,15 @@ shared :rib do
69
69
  (::Readline::HISTORY << str.chomp)[-1]
70
70
  }
71
71
  end
72
+
73
+ # TODO: history.clear is MRI 1.9+
74
+ def clear_history history
75
+ if history.respond_to?(:clear)
76
+ history.clear
77
+ else
78
+ history.pop until history.empty?
79
+ end
80
+ end
72
81
  end
73
82
 
74
83
  module Kernel
data/lib/rib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rib
3
- VERSION = '0.9.0'
3
+ VERSION = '0.9.1'
4
4
  end
data/lib/rib.rb CHANGED
@@ -6,7 +6,7 @@ module Rib
6
6
  # All default Rib configs, would be passed to Shell.new in Rib.shell,
7
7
  # but calling Shell.new directly won't bring this in.
8
8
  def config
9
- @config ||= {:config => '~/.config/rib/config.rb', :name => 'rib'}
9
+ @config ||= {:config => File.join(home, 'config.rb'), :name => 'rib'}
10
10
  end
11
11
 
12
12
  # All shells in the memory
@@ -19,6 +19,17 @@ module Rib
19
19
  @vars ||= {}
20
20
  end
21
21
 
22
+ # Rib.home is where Rib storing things
23
+ def home
24
+ ENV['RIB_HOME'] ||= begin
25
+ ['~/.rib', '~/.config/rib'].find{ |path|
26
+ p = File.expand_path(path)
27
+ File.exist?(File.join(p, 'config.rb')) ||
28
+ File.exist?(File.join(p, 'history.rb'))
29
+ } || '~/.rib'
30
+ end
31
+ end
32
+
22
33
  # Convenient shell accessor, which would just give you current last shell
23
34
  # or create one and load ~/.config/rib/config.rb if non has existed. If you
24
35
  # need a clean shell which does not load rc file, use Shell.new instead.
@@ -54,7 +65,10 @@ module Rib
54
65
  # Load (actually require) ~/.config/rib/config.rb if exists.
55
66
  # This might emit warnings if there's some error while loading it.
56
67
  def require_config
57
- config_path && require(config_path)
68
+ return unless config_path
69
+ result = require(config_path)
70
+ Rib.say("Config loaded from: #{config_path}") if $VERBOSE && result
71
+ result
58
72
  rescue Exception => e
59
73
  Rib.warn("Error loading #{config[:config]}\n" \
60
74
  " #{Rib::API.format_error(e)}")
data/rib.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rib}
5
- s.version = "0.9.0"
5
+ s.version = "0.9.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Lin Jen-Shin (godfat)}]
9
- s.date = %q{2011-08-14}
9
+ s.date = %q{2011-08-19}
10
10
  s.description = %q{Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
11
11
 
12
12
  Rib is based on the design of [ripl][] and the work of [ripl-rc][], some of
@@ -25,12 +25,6 @@ be simple, lightweight and modular so that everyone could customize Rib.
25
25
  %q{rib-min},
26
26
  %q{rib-rails},
27
27
  %q{rib-ramaze}]
28
- s.extra_rdoc_files = [
29
- %q{CONTRIBUTORS},
30
- %q{LICENSE},
31
- %q{CHANGES.md},
32
- %q{TODO.md},
33
- %q{CONTRIBUTORS}]
34
28
  s.files = [
35
29
  %q{.gitignore},
36
30
  %q{.gitmodules},
@@ -39,7 +33,6 @@ be simple, lightweight and modular so that everyone could customize Rib.
39
33
  %q{CONTRIBUTORS},
40
34
  %q{Gemfile},
41
35
  %q{LICENSE},
42
- %q{README},
43
36
  %q{README.md},
44
37
  %q{Rakefile},
45
38
  %q{TODO.md},
@@ -65,7 +58,8 @@ be simple, lightweight and modular so that everyone could customize Rib.
65
58
  %q{lib/rib/core/strip_backtrace.rb},
66
59
  %q{lib/rib/core/underscore.rb},
67
60
  %q{lib/rib/debug.rb},
68
- %q{lib/rib/dep/hirb.rb},
61
+ %q{lib/rib/extra/autoindent.rb},
62
+ %q{lib/rib/extra/hirb.rb},
69
63
  %q{lib/rib/more.rb},
70
64
  %q{lib/rib/more/anchor.rb},
71
65
  %q{lib/rib/more/color.rb},
@@ -73,6 +67,7 @@ be simple, lightweight and modular so that everyone could customize Rib.
73
67
  %q{lib/rib/more/multiline_history.rb},
74
68
  %q{lib/rib/more/multiline_history_file.rb},
75
69
  %q{lib/rib/plugin.rb},
70
+ %q{lib/rib/ripl.rb},
76
71
  %q{lib/rib/runner.rb},
77
72
  %q{lib/rib/shell.rb},
78
73
  %q{lib/rib/test.rb},
@@ -94,9 +89,6 @@ be simple, lightweight and modular so that everyone could customize Rib.
94
89
  %q{test/test_plugin.rb},
95
90
  %q{test/test_shell.rb}]
96
91
  s.homepage = %q{https://github.com/godfat/rib}
97
- s.rdoc_options = [
98
- %q{--main},
99
- %q{README}]
100
92
  s.require_paths = [%q{lib}]
101
93
  s.rubygems_version = %q{1.8.7}
102
94
  s.summary = %q{Ruby-Interactive-ruBy -- Yet another interactive Ruby shell}
@@ -119,18 +111,24 @@ be simple, lightweight and modular so that everyone could customize Rib.
119
111
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
120
112
  s.add_development_dependency(%q<bond>, [">= 0"])
121
113
  s.add_development_dependency(%q<hirb>, [">= 0"])
114
+ s.add_development_dependency(%q<readline_buffer>, [">= 0"])
122
115
  s.add_development_dependency(%q<bacon>, [">= 0"])
123
116
  s.add_development_dependency(%q<rr>, [">= 0"])
117
+ s.add_development_dependency(%q<rake>, [">= 0"])
124
118
  else
125
119
  s.add_dependency(%q<bond>, [">= 0"])
126
120
  s.add_dependency(%q<hirb>, [">= 0"])
121
+ s.add_dependency(%q<readline_buffer>, [">= 0"])
127
122
  s.add_dependency(%q<bacon>, [">= 0"])
128
123
  s.add_dependency(%q<rr>, [">= 0"])
124
+ s.add_dependency(%q<rake>, [">= 0"])
129
125
  end
130
126
  else
131
127
  s.add_dependency(%q<bond>, [">= 0"])
132
128
  s.add_dependency(%q<hirb>, [">= 0"])
129
+ s.add_dependency(%q<readline_buffer>, [">= 0"])
133
130
  s.add_dependency(%q<bacon>, [">= 0"])
134
131
  s.add_dependency(%q<rr>, [">= 0"])
132
+ s.add_dependency(%q<rake>, [">= 0"])
135
133
  end
136
134
  end
data/task/gemgem.rb CHANGED
@@ -12,17 +12,13 @@ module Gemgem
12
12
  s.authors = ['Lin Jen-Shin (godfat)']
13
13
  s.email = ['godfat (XD) godfat.org']
14
14
 
15
- description = File.read("#{Gemgem.dir}/README").
15
+ description = readme.
16
16
  match(/DESCRIPTION:\n\n(.+?)(?=\n\n[^\n]+:\n)/m)[1].
17
17
  lines.to_a
18
18
 
19
19
  s.description = description.join
20
20
  s.summary = description.first
21
21
 
22
- s.extra_rdoc_files = %w[CHANGES TODO CONTRIBUTORS LICENSE
23
- CHANGES.md TODO.md CONTRIBUTORS].select{ |f|
24
- File.exist?(f) }
25
- s.rdoc_options = %w[--main README]
26
22
  s.rubygems_version = Gem::VERSION
27
23
  s.date = Time.now.strftime('%Y-%m-%d')
28
24
  s.files = gem_files
@@ -34,6 +30,17 @@ module Gemgem
34
30
  spec
35
31
  end
36
32
 
33
+ def readme
34
+ path = %w[README.md README].find{ |name|
35
+ File.exist?("#{Gemgem.dir}/#{name}")
36
+ }
37
+ if path
38
+ File.read(path)
39
+ else
40
+ "DESCRIPTION:\n\n \n\nEND:\n"
41
+ end
42
+ end
43
+
37
44
  def gem_tag
38
45
  "#{spec.name}-#{spec.version}"
39
46
  end
@@ -5,8 +5,10 @@ require 'rib/core/history'
5
5
  shared :history do
6
6
  should '#after_loop save history' do
7
7
  inputs = %w[blih blah]
8
- @shell.history.clear
8
+ # TODO: history.replace(input) is MRI 1.9+
9
+ clear_history(@shell.history)
9
10
  @shell.history.push(*inputs)
11
+
10
12
  @shell.after_loop
11
13
  File.read(@history_file).should.eq "#{inputs.join("\n")}\n"
12
14
  end
@@ -50,7 +52,7 @@ describe Rib::History do
50
52
 
51
53
  before do
52
54
  if readline?
53
- ::Readline::HISTORY.clear
55
+ clear_history(::Readline::HISTORY)
54
56
  stub_readline
55
57
  end
56
58
  @history_file = "/tmp/test_rib_#{rand}"
@@ -36,7 +36,7 @@ describe Rib::SqueezeHistory do
36
36
  @history = "/tmp/test_rib_#{rand}"
37
37
  @shell = Rib::Shell.new(:history_file => @history).before_loop
38
38
  @input = %w[foo bar bar foo bar]
39
- @shell.history.clear
39
+ clear_history(@shell.history)
40
40
  end
41
41
 
42
42
  after do
@@ -8,12 +8,12 @@ describe Rib::MultilineHistory do
8
8
  behaves_like :setup_multiline
9
9
 
10
10
  def check str, err=nil
11
- @shell.history.clear
11
+ clear_history(@shell.history)
12
12
  with_history(str, err)
13
13
 
14
14
  setup_shell
15
15
 
16
- @shell.history.clear
16
+ clear_history(@shell.history)
17
17
  @shell.history << 'old history'
18
18
  with_history(str, err, 'old history')
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-14 00:00:00.000000000Z
12
+ date: 2011-08-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bond
16
- requirement: &2169075740 !ruby/object:Gem::Requirement
16
+ requirement: &2166446500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2169075740
24
+ version_requirements: *2166446500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hirb
27
- requirement: &2169075260 !ruby/object:Gem::Requirement
27
+ requirement: &2166446020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,21 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2169075260
35
+ version_requirements: *2166446020
36
+ - !ruby/object:Gem::Dependency
37
+ name: readline_buffer
38
+ requirement: &2166445540 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2166445540
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: bacon
38
- requirement: &2169074780 !ruby/object:Gem::Requirement
49
+ requirement: &2166445060 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,21 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *2169074780
57
+ version_requirements: *2166445060
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rr
49
- requirement: &2169074300 !ruby/object:Gem::Requirement
60
+ requirement: &2166444580 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2166444580
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &2166444100 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
74
  - - ! '>='
@@ -54,7 +76,7 @@ dependencies:
54
76
  version: '0'
55
77
  type: :development
56
78
  prerelease: false
57
- version_requirements: *2169074300
79
+ version_requirements: *2166444100
58
80
  description: ! 'Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
59
81
 
60
82
 
@@ -82,11 +104,7 @@ executables:
82
104
  - rib-rails
83
105
  - rib-ramaze
84
106
  extensions: []
85
- extra_rdoc_files:
86
- - CONTRIBUTORS
87
- - LICENSE
88
- - CHANGES.md
89
- - TODO.md
107
+ extra_rdoc_files: []
90
108
  files:
91
109
  - .gitignore
92
110
  - .gitmodules
@@ -95,7 +113,6 @@ files:
95
113
  - CONTRIBUTORS
96
114
  - Gemfile
97
115
  - LICENSE
98
- - README
99
116
  - README.md
100
117
  - Rakefile
101
118
  - TODO.md
@@ -121,7 +138,8 @@ files:
121
138
  - lib/rib/core/strip_backtrace.rb
122
139
  - lib/rib/core/underscore.rb
123
140
  - lib/rib/debug.rb
124
- - lib/rib/dep/hirb.rb
141
+ - lib/rib/extra/autoindent.rb
142
+ - lib/rib/extra/hirb.rb
125
143
  - lib/rib/more.rb
126
144
  - lib/rib/more/anchor.rb
127
145
  - lib/rib/more/color.rb
@@ -129,6 +147,7 @@ files:
129
147
  - lib/rib/more/multiline_history.rb
130
148
  - lib/rib/more/multiline_history_file.rb
131
149
  - lib/rib/plugin.rb
150
+ - lib/rib/ripl.rb
132
151
  - lib/rib/runner.rb
133
152
  - lib/rib/shell.rb
134
153
  - lib/rib/test.rb
@@ -152,9 +171,7 @@ files:
152
171
  homepage: https://github.com/godfat/rib
153
172
  licenses: []
154
173
  post_install_message:
155
- rdoc_options:
156
- - --main
157
- - README
174
+ rdoc_options: []
158
175
  require_paths:
159
176
  - lib
160
177
  required_ruby_version: !ruby/object:Gem::Requirement
data/README DELETED
@@ -1,184 +0,0 @@
1
- # Rib
2
-
3
- by Lin Jen-Shin ([godfat](http://godfat.org))
4
-
5
- ## LINKS:
6
-
7
- * [github](https://github.com/godfat/rib)
8
- * [rubygems](http://rubygems.org/gems/rib)
9
-
10
- ## DESCRIPTION:
11
-
12
- Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
13
-
14
- Rib is based on the design of [ripl][] and the work of [ripl-rc][], some of
15
- the features are also inspired by [pry][]. The aim of Rib is to be fully
16
- featured and yet very easy to opt-out or opt-in other features. It shall
17
- be simple, lightweight and modular so that everyone could customize Rib.
18
-
19
- [ripl]: https://github.com/cldwalker/ripl
20
- [ripl-rc]: https://github.com/godfat/ripl-rc
21
- [pry]: https://github.com/pry/pry
22
-
23
- ## REQUIREMENTS:
24
-
25
- * Tested with MRI 1.8.7, 1.9.2 and Rubinius 1.2, JRuby 1.6
26
- * All gem dependencies are optional, but it's highly recommended to use
27
- Rib with [bond][] for tab completion.
28
-
29
- [bond]: https://github.com/cldwalker/bond
30
-
31
- ## INSTALLATION:
32
-
33
- gem install rib
34
-
35
- ## SYNOPSIS:
36
-
37
- ![Screenshot](https://github.com/godfat/rib/raw/master/screenshot.png)
38
-
39
- ### As an interactive shell
40
-
41
- As IRB (reads `~/.config/rib/config.rb` writes `~/.config/rib/history.rb`)
42
-
43
- rib
44
-
45
- As Rails console
46
-
47
- rib rails
48
-
49
- As Ramaze console
50
-
51
- rib ramaze
52
-
53
- As a console for whichever the app in the current path
54
- it should be (for now, it's either Rails or Ramaze)
55
-
56
- rib auto
57
-
58
- As a fully featured interactive Ruby shell (as ripl-rc)
59
-
60
- rib all
61
-
62
- As a fully featured app console (yes, some commands could be used together)
63
-
64
- rib all auto # or `rib auto all`, the order doesn't really matter
65
-
66
- You can customize Rib's behaviour by setting `~/.config/rib/config.rb` (by
67
- default). Since it's merely a Ruby script which would be loaded into memory
68
- before launching Rib shell session, You can put any customization or monkey
69
- patch there. Personally, I use all plugins provided by Rib.
70
-
71
- <https://github.com/godfat/dev-tool/blob/master/.config/rib/config.rb>
72
-
73
- As you can see, putting `require 'rib/all'` into config file is exactly the
74
- same as running `rib all` without a config file. What `rib all` would do is
75
- merely require the file, and that file is also merely requiring all plugins.
76
- Suppose you only want to use the core plugins and color plugin, you'll put
77
- this into your config file:
78
-
79
- require 'rib/core'
80
- require 'rib/more/color'
81
-
82
- You can also write your plugins there. Here's another example:
83
-
84
- require 'rib/core'
85
- require 'pp'
86
- Rib.config[:prompt] = '$ '
87
-
88
- module RibPP
89
- Rib::Shell.send(:include, self)
90
-
91
- def format_result result
92
- result_prompt + result.pretty_inspect
93
- end
94
- end
95
-
96
- So that we override the original format_result to pretty_inspect the result.
97
- You can also build your own gem and then simply require it in your config
98
- file. To see a list of overridable API, please read [api.rb][]
99
-
100
- [api.rb]: https://github.com/godfat/rib/blob/master/lib/rib/api.rb
101
-
102
- #### Basic configuration
103
-
104
- <pre>
105
- Rib.config[:config] | The path where config should be located
106
- Rib.config[:name] | The name of this shell
107
- Rib.config[:result_prompt] | Default is "=>"
108
- Rib.config[:prompt] | Default is ">>"
109
- Rib.config[:binding] | Context, default: TOPLEVEL_BINDING
110
- Rib.config[:exit] | Commands to exit, default [nil, 'exit', 'quit']
111
- </pre>
112
-
113
- #### Plugin specific configuration
114
-
115
- <pre>
116
- Rib.config[:completion] | Completion: Bond config
117
- Rib.config[:history_file] | Default is "~/.rib/config/history.rb"
118
- Rib.config[:history_size] | Default is 500
119
- Rib.config[:color] | A hash of Class => :color mapping
120
- </pre>
121
-
122
- ### As a debugging/interacting tool
123
-
124
- Rib could be used as a kind of debugging tool which you can set break point
125
- in the source program.
126
-
127
- require 'rib/config' # This would load your ~/.config/rib/config.rb
128
- require 'rib/anchor' # If you enabled this in config, then needed not.
129
- Rib.anchor binding # This would give you an interactive shell
130
- # when your program has been executed here.
131
- Rib.anchor 123 # You can also anchor on an object.
132
-
133
- But this might be called in a loop, you might only want to
134
- enter the shell under certain circumstance, then you'll do:
135
-
136
- require 'rib/debug'
137
- Rib.enable_anchor do
138
- # Only `Rib.anchor` called in the block would launch a shell
139
- end
140
-
141
- Rib.anchor binding # No effect (no-op) outside the block
142
-
143
- Anchor could also be nested. The level would be shown on the prompt,
144
- starting from 1.
145
-
146
- ### In place editing
147
-
148
- Whenever you called:
149
-
150
- Rib.edit
151
-
152
- Rib would open an editor according to $EDITOR (`ENV['EDITOR']`) for you.
153
- After save and leave the editor, Rib would evaluate what you had input.
154
- This also works inside an anchor. To use it, require either rib/more/edit
155
- or rib/more or rib/all.
156
-
157
- ### As a shell framework
158
-
159
- The essence is:
160
-
161
- require 'rib'
162
-
163
- All others are optional. The core plugins are lying in `rib/core/*.rb`, and
164
- more plugins are lying in `rib/more/*.rb`. You can read `rib/app/ramaze.rb`
165
- and `bin/rib-ramaze` as a Rib App reference implementation, because it's very
166
- simple, simpler than rib-rails.
167
-
168
- ## LICENSE:
169
-
170
- Apache License 2.0
171
-
172
- Copyright (c) 2010-2011, Lin Jen-Shin (godfat)
173
-
174
- Licensed under the Apache License, Version 2.0 (the "License");
175
- you may not use this file except in compliance with the License.
176
- You may obtain a copy of the License at
177
-
178
- <http://www.apache.org/licenses/LICENSE-2.0>
179
-
180
- Unless required by applicable law or agreed to in writing, software
181
- distributed under the License is distributed on an "AS IS" BASIS,
182
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183
- See the License for the specific language governing permissions and
184
- limitations under the License.