rib 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,8 @@
1
- script: 'git submodule update --init; bundle exec rake test'
1
+ before_install: 'git submodule update --init'
2
+ script: 'ruby -r bundler/setup -S rake test'
3
+
2
4
  rvm:
3
- - 1.8.7
4
5
  - 1.9.2
5
6
  - 1.9.3
6
- - rbx-18mode
7
7
  - rbx-19mode
8
- - jruby-18mode
9
8
  - jruby-19mode
data/CHANGES.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGES
2
2
 
3
+ ## Rib 1.1.0 -- 2012-07-18
4
+
5
+ * Support for Ruby 1.8 is dropped.
6
+ * Now `Rib::Plugin` should be extended to the module, instead of included.
7
+ This fits more naturally with Ruby, but not really compatible with Ruby 1.8?
8
+ * [more/anchor] Fixed a bug where you run rib in top level while anchor in
9
+ the other source, exit from the inner shell would break from the original
10
+ call. Now you can safely exit from the inner shell and keep doing the
11
+ original work.
12
+
3
13
  ## Rib 1.0.5 -- 2012-05-15
4
14
 
5
15
  * [app/rails] Fixed SystemStackError issue. It's because ConsoleMethods
data/README.md CHANGED
@@ -23,7 +23,7 @@ be simple, lightweight and modular so that everyone could customize Rib.
23
23
 
24
24
  ## REQUIREMENTS:
25
25
 
26
- * Tested with MRI (official CRuby) 1.8.7, 1.9.2, 1.9.3, Rubinius and JRuby
26
+ * Tested with MRI (official CRuby) 1.9.2, 1.9.3, Rubinius and JRuby.
27
27
  * All gem dependencies are optional, but it's highly recommended to use
28
28
  Rib with [bond][] for tab completion.
29
29
 
data/lib/rib.rb CHANGED
@@ -3,6 +3,7 @@ require 'rib/shell'
3
3
 
4
4
  module Rib
5
5
  autoload :VERSION, 'rib/version'
6
+ Skip = Object.new
6
7
 
7
8
  module_function
8
9
  # All default Rib configs, would be passed to Shell.new in Rib.shell,
@@ -45,7 +46,7 @@ module Rib
45
46
  # All plugins which have been loaded into the memory regardless
46
47
  # it's enabled or not.
47
48
  def plugins
48
- Shell.ancestors[1..-1].select{ |a| a < Plugin }
49
+ Shell.ancestors[1..-1].select{ |a| a.singleton_class < Plugin }
49
50
  end
50
51
 
51
52
  # Convenient way to disable all plugins in the memory.
@@ -36,15 +36,13 @@ module Rib::API
36
36
  def loop_once
37
37
  input, result, err = get_input, nil, nil
38
38
  throw(:rib_exit, input) if config[:exit].include?(input)
39
- catch(:rib_skip) do
40
- result, err = eval_input(input)
41
- if err
42
- print_eval_error(err)
43
- elsif input.strip != ''
44
- print_result(result)
45
- else
46
- # print nothing for blank input
47
- end
39
+ result, err = eval_input(input)
40
+ if err
41
+ print_eval_error(err)
42
+ elsif input.strip != '' && result != Rib::Skip
43
+ print_result(result)
44
+ else
45
+ # print nothing for blank input
48
46
  end
49
47
  [result, err]
50
48
  rescue Interrupt
@@ -2,7 +2,7 @@
2
2
  require 'rib'
3
3
 
4
4
  module Rib::Completion
5
- include Rib::Plugin
5
+ extend Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
8
  # --------------- Rib API ---------------
@@ -3,7 +3,7 @@ require 'rib'
3
3
  require 'fileutils'
4
4
 
5
5
  module Rib::History
6
- include Rib::Plugin
6
+ extend Rib::Plugin
7
7
  Shell.use(self)
8
8
 
9
9
  # --------------- Rib API ---------------
@@ -3,7 +3,7 @@ require 'rib'
3
3
 
4
4
  # from https://github.com/janlelis/ripl-multi_line
5
5
  module Rib::Multiline
6
- include Rib::Plugin
6
+ extend Rib::Plugin
7
7
  Shell.use(self)
8
8
 
9
9
  engine = if Object.const_defined?(:RUBY_ENGINE)
@@ -3,7 +3,7 @@ require 'rib'
3
3
  require 'readline'
4
4
 
5
5
  module Rib::Readline
6
- include Rib::Plugin
6
+ extend Rib::Plugin
7
7
  Shell.use(self)
8
8
 
9
9
  # --------------- Rib API ---------------
@@ -2,7 +2,7 @@
2
2
  require 'rib/core/history' # dependency
3
3
 
4
4
  module Rib::SqueezeHistory
5
- include Rib::Plugin
5
+ extend Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
8
  # --------------- Rib API ---------------
@@ -2,7 +2,7 @@
2
2
  require 'rib'
3
3
 
4
4
  module Rib::StripBacktrace
5
- include Rib::Plugin
5
+ extend Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
8
  # --------------- Rib API ---------------
@@ -2,7 +2,7 @@
2
2
  require 'rib'
3
3
 
4
4
  module Rib::Underscore
5
- include Rib::Plugin
5
+ extend Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
8
  IVAR = {:_ => :@__rib_result__,
@@ -4,7 +4,7 @@ require 'rib/core/readline' # dependency
4
4
  require 'rib/core/multiline' # dependency
5
5
 
6
6
  module Rib::Autoindent
7
- include Rib::Plugin
7
+ extend Rib::Plugin
8
8
  Shell.use(self)
9
9
 
10
10
  # begin block could be simpler, because it should also trigger
@@ -2,7 +2,7 @@
2
2
  require 'rib'
3
3
 
4
4
  module Rib::Hirb
5
- include Rib::Plugin
5
+ extend Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
8
  # --------------- Rib API ---------------
@@ -2,7 +2,7 @@
2
2
  require 'rib'
3
3
 
4
4
  module Rib::Anchor
5
- include Rib::Plugin
5
+ extend Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
8
  # --------------- Rib API ---------------
@@ -68,18 +68,10 @@ module Rib::Anchor
68
68
  end
69
69
 
70
70
  Rib.shell.loop
71
+ Rib::Skip
71
72
 
72
- # we can't use ensure block here because we need to do something
73
- # (i.e. throw :rib_skip) if there's no exception. this can't be
74
- # done via ensure because then we don't know if there's an
75
- # exception or not, and ensure block is always executed last
76
- rescue
73
+ ensure
77
74
  Rib.shells.pop
78
- raise
79
- else
80
- # only skip printing anchor result while there's another shell running
81
- Rib.shells.pop
82
- throw :rib_skip if Rib.shell.running?
83
75
  end
84
76
  end
85
77
 
@@ -2,7 +2,7 @@
2
2
  require 'rib'
3
3
 
4
4
  module Rib::Color
5
- include Rib::Plugin
5
+ extend Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
8
  # --------------- Rib API ---------------
@@ -80,7 +80,7 @@ module Rib::Color
80
80
  end
81
81
 
82
82
  def find_color colors, value
83
- (colors.sort{ |(k1, v1), (k2, v2)|
83
+ (colors.sort{ |(k1, _), (k2, _)|
84
84
  # Class <=> Class
85
85
  if k1 < k2 then -1
86
86
  elsif k1 > k2 then 1
@@ -3,7 +3,7 @@ require 'rib'
3
3
  require 'tempfile'
4
4
 
5
5
  module Rib::Edit
6
- include Rib::Plugin
6
+ extend Rib::Plugin
7
7
  Shell.use(self)
8
8
 
9
9
  module Imp
@@ -3,7 +3,7 @@ require 'rib/core/history' # dependency
3
3
  require 'rib/core/multiline' # dependency
4
4
 
5
5
  module Rib::MultilineHistory
6
- include Rib::Plugin
6
+ extend Rib::Plugin
7
7
  Shell.use(self)
8
8
 
9
9
  # --------------- Rib API ---------------
@@ -2,7 +2,7 @@
2
2
  require 'rib/more/multiline_history'
3
3
 
4
4
  module Rib::MultilineHistoryFile
5
- include Rib::Plugin
5
+ extend Rib::Plugin
6
6
  Shell.use(self)
7
7
 
8
8
  # --------------- Rib API ---------------
@@ -1,30 +1,32 @@
1
1
 
2
2
  module Rib; end
3
3
  module Rib::Plugin
4
- def self.included mod
5
- mod.send(:include, Rib)
4
+ attr_accessor :disabled
6
5
 
7
- class << mod
8
- attr_accessor :disabled
6
+ def enable
7
+ self.disabled = false
8
+ if block_given? then yield else enabled? end
9
+ ensure
10
+ self.disabled = true if block_given?
11
+ end
9
12
 
10
- def enable
11
- self.disabled = false
12
- if block_given? then yield else enabled? end
13
- end
13
+ def disable
14
+ self.disabled = true
15
+ if block_given? then yield else enabled? end
16
+ ensure
17
+ self.disabled = false if block_given?
18
+ end
14
19
 
15
- def disable
16
- self.disabled = true
17
- if block_given? then yield else enabled? end
18
- end
20
+ def enabled?
21
+ !disabled
22
+ end
19
23
 
20
- def enabled?
21
- !disabled
22
- end
24
+ def disabled?
25
+ !!disabled
26
+ end
23
27
 
24
- def disabled?
25
- !!disabled
26
- end
27
- end
28
+ def self.extended mod
29
+ mod.send(:include, Rib)
28
30
 
29
31
  snake_name = mod.name.sub(/(\w+::)+?(\w+)$/, '\2').
30
32
  gsub(/([A-Z][a-z]*)/, '\\1_').downcase[0..-2]
@@ -43,12 +45,6 @@ module Rib::Plugin
43
45
  RUBY
44
46
  }).join("\n")
45
47
 
46
- meta_rib = if respond_to?(:singleton_class)
47
- Rib.singleton_class
48
- else
49
- class << Rib; self; end
50
- end
51
-
52
- meta_rib.module_eval(code, __FILE__, __LINE__)
48
+ Rib.singleton_class.module_eval(code, __FILE__, __LINE__)
53
49
  end
54
50
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rib
3
- VERSION = '1.0.5'
3
+ VERSION = '1.1.0'
4
4
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rib"
5
- s.version = "1.0.5"
5
+ s.version = "1.1.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 = "2012-05-15"
9
+ s.date = "2012-07-18"
10
10
  s.description = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell\n\nRib is based on the design of [ripl][] and the work of [ripl-rc][], some of\nthe features are also inspired by [pry][]. The aim of Rib is to be fully\nfeatured and yet very easy to opt-out or opt-in other features. It shall\nbe simple, lightweight and modular so that everyone could customize Rib.\n\n[ripl]: https://github.com/cldwalker/ripl\n[ripl-rc]: https://github.com/godfat/ripl-rc\n[pry]: https://github.com/pry/pry"
11
11
  s.email = ["godfat (XD) godfat.org"]
12
12
  s.executables = [
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: 1.0.5
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-15 00:00:00.000000000 Z
12
+ date: 2012-07-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
15
15