rib 1.2.6 → 1.2.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2150377cb877771f501f288373ccf7750a786be5
4
- data.tar.gz: 72a3bc6e08131e09ede6e1b81b16a904e8080244
3
+ metadata.gz: 4b1e243240afca72f22b64e717397285a0b6f6a1
4
+ data.tar.gz: 233ea57325b8e3ae24d950e552920685081bc961
5
5
  SHA512:
6
- metadata.gz: f9a3ac832fc847890ca41e7fbcf4760e0c1a1b46d1f07d71135bf5bc1e117af114be038319cb18a85bd348b074845e86bcf8d300ab260662f10239dca96229ca
7
- data.tar.gz: 60f6eeeee1bb056cd56ca103c198c7cf7fcf0cfe1d288dcafe5ac2b8658ea75d96aad163dd735defd59af5065c30abd45b15ebd5e530edb2136d154d1efef21b
6
+ metadata.gz: 03e4a3bd4e9d4ba2b4cfacc66c2eb8ad1d8a3cf7e5beb9551648ce5a419ab8eaf54d5b7e4b2c94f0aceeecab2213097495811485c2cea60ded54c96aee671085
7
+ data.tar.gz: 9bbde220dc6b6d69e07c3cc5b8e9faf52369ae2f582eb3880a3d659f71b7b1fa73da3a63ae7022fcf72d3cd5c84d232873fbf9c5c68ff2b803ee3fff91476791
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  /pkg/
2
+ /coverage/
@@ -1,15 +1,11 @@
1
1
 
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9
5
4
  - 2.0
6
5
  - 2.1
6
+ - 2.2
7
7
  - rbx-2
8
8
  - jruby
9
9
 
10
- matrix:
11
- allow_failures:
12
- - rvm: jruby
13
-
10
+ install: 'bundle install --retry=3'
14
11
  script: 'ruby -r bundler/setup -S rake test'
15
- sudo: false
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGES
2
2
 
3
+ ## Rib 1.2.7 -- 2015-01-28
4
+
5
+ * [more/bottomup_backtrace] A new plugin which prints the backtrace bottom-up.
6
+ Ref: <http://yellerapp.com/posts/2015-01-22-upside-down-stacktraces.html>
7
+
3
8
  ## Rib 1.2.6 -- 2014-11-07
4
9
 
5
10
  * [extra/autoindent] Now `module_function` would indent correctly.
data/Gemfile CHANGED
@@ -10,6 +10,9 @@ gem 'muack'
10
10
  gem 'bond'
11
11
  gem 'hirb'
12
12
 
13
+ gem 'simplecov', :require => false if ENV['COV']
14
+ gem 'coveralls', :require => false if ENV['CI']
15
+
13
16
  platforms :ruby do
14
17
  gem 'readline_buffer'
15
18
  end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rib [![Build Status](https://secure.travis-ci.org/godfat/rib.png?branch=master)](http://travis-ci.org/godfat/rib)
1
+ # Rib [![Build Status](https://secure.travis-ci.org/godfat/rib.png?branch=master)](http://travis-ci.org/godfat/rib) [![Coverage Status](https://coveralls.io/repos/godfat/rib/badge.png)](https://coveralls.io/r/godfat/rib)
2
2
 
3
3
  by Lin Jen-Shin ([godfat](http://godfat.org))
4
4
 
@@ -193,6 +193,10 @@ require 'rib/more' # You get all of the followings:
193
193
 
194
194
  Not only readline could have multiline history, but also the history file.
195
195
 
196
+ * `require 'rib/more/bottomup_backtrace'`
197
+
198
+ Show backtrace bottom-up instead of the regular top-down.
199
+
196
200
  * `require 'rib/more/color'`
197
201
 
198
202
  Class based colorizing.
@@ -324,7 +328,7 @@ simple, simpler than rib-rails.
324
328
 
325
329
  Apache License 2.0
326
330
 
327
- Copyright (c) 2011-2014, Lin Jen-Shin (godfat)
331
+ Copyright (c) 2011-2015, Lin Jen-Shin (godfat)
328
332
 
329
333
  Licensed under the Apache License, Version 2.0 (the "License");
330
334
  you may not use this file except in compliance with the License.
@@ -96,12 +96,19 @@ module Rib::API
96
96
  result_prompt + result.inspect
97
97
  end
98
98
 
99
- # Format error raised in #loop_eval
99
+ # Format error raised in #loop_eval with #get_error
100
100
  def format_error err
101
- "#{err.class}: #{err.message}\n #{err.backtrace.join("\n ")}"
101
+ message, backtrace = get_error(err)
102
+ "#{message}\n #{backtrace.join("\n ")}"
102
103
  end
103
104
  module_function :format_error
104
105
 
106
+ # Get error message and backtrace from a particular error
107
+ def get_error err
108
+ ["#{err.class}: #{err.message}", err.backtrace]
109
+ end
110
+ module_function :get_error
111
+
105
112
  private
106
113
  def equal_rib_skip result
107
114
  result == Rib::Skip
@@ -7,23 +7,15 @@ module Rib::StripBacktrace
7
7
 
8
8
  # --------------- Rib API ---------------
9
9
 
10
- # strip backtrace until rib
11
10
  def format_error err
12
11
  return super if StripBacktrace.disabled?
13
- backtrace = if err.kind_of?(SyntaxError)
14
- []
15
- else
16
- err.backtrace
17
- end
18
- message, backtrace = get_error(err, strip_backtrace(backtrace))
12
+ message, backtrace = get_error(err)
19
13
  "#{message}\n #{backtrace.join("\n ")}"
20
14
  end
21
15
 
22
- # --------------- Plugin API ---------------
23
-
24
- def get_error err, backtrace=err.backtrace
16
+ def get_error err
25
17
  return super if StripBacktrace.disabled?
26
- ["#{err.class}: #{err.message}", backtrace]
18
+ ["#{err.class}: #{err.message}", strip_backtrace(err.backtrace)]
27
19
  end
28
20
 
29
21
 
@@ -3,6 +3,7 @@
3
3
  require 'rib/more/multiline_history_file'
4
4
 
5
5
  # upon formatting output
6
+ require 'rib/more/bottomup_backtrace'
6
7
  require 'rib/more/color'
7
8
 
8
9
  # upon input
@@ -0,0 +1,15 @@
1
+
2
+ require 'rib'
3
+
4
+ module Rib::BottomupBacktrace
5
+ extend Rib::Plugin
6
+ Shell.use(self)
7
+
8
+ # --------------- Rib API ---------------
9
+
10
+ def format_error err
11
+ return super if BottomupBacktrace.disabled?
12
+ message, backtrace = get_error(err)
13
+ " #{backtrace.reverse.join("\n ")}\n#{message}"
14
+ end
15
+ end
@@ -17,6 +17,12 @@ module Rib::Color
17
17
  config[:result_prompt] + format_color(result)
18
18
  end
19
19
 
20
+ def get_error err
21
+ return super if Color.disabled?
22
+ message, backtrace = super
23
+ [format_color(err, message), colorize_backtrace(backtrace)]
24
+ end
25
+
20
26
  # --------------- Plugin API ---------------
21
27
 
22
28
  def colors
@@ -65,13 +71,6 @@ module Rib::Color
65
71
  end
66
72
  end
67
73
 
68
- # override StripBacktrace#get_error
69
- def get_error err, backtrace=err.backtrace
70
- return super if Color.disabled?
71
- [format_color(err, "#{err.class.to_s}: #{err.message}"),
72
- colorize_backtrace(backtrace)]
73
- end
74
-
75
74
 
76
75
 
77
76
  module_function
@@ -19,8 +19,12 @@ copy :rib do
19
19
  def test_for *plugins, &block
20
20
  require 'rib/all' # exhaustive tests
21
21
  rest = Rib.plugins - plugins
22
- Rib.enable_plugins(plugins)
23
- Rib.disable_plugins(rest)
22
+
23
+ before do
24
+ Rib.enable_plugins(plugins)
25
+ Rib.disable_plugins(rest)
26
+ end
27
+
24
28
  yield
25
29
 
26
30
  case ENV['TEST_LEVEL']
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rib
3
- VERSION = '1.2.6'
3
+ VERSION = '1.2.7'
4
4
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rib 1.2.6 ruby lib
2
+ # stub: rib 1.2.7 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rib"
6
- s.version = "1.2.6"
6
+ s.version = "1.2.7"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Lin Jen-Shin (godfat)"]
11
- s.date = "2014-11-07"
11
+ s.date = "2015-01-28"
12
12
  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"
13
13
  s.email = ["godfat (XD) godfat.org"]
14
14
  s.executables = [
@@ -58,6 +58,7 @@ Gem::Specification.new do |s|
58
58
  "lib/rib/extra/paging.rb",
59
59
  "lib/rib/more.rb",
60
60
  "lib/rib/more/anchor.rb",
61
+ "lib/rib/more/bottomup_backtrace.rb",
61
62
  "lib/rib/more/color.rb",
62
63
  "lib/rib/more/edit.rb",
63
64
  "lib/rib/more/multiline_history.rb",
@@ -87,7 +88,7 @@ Gem::Specification.new do |s|
87
88
  "test/test_shell.rb"]
88
89
  s.homepage = "https://github.com/godfat/rib"
89
90
  s.licenses = ["Apache License 2.0"]
90
- s.rubygems_version = "2.4.2"
91
+ s.rubygems_version = "2.4.5"
91
92
  s.summary = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell"
92
93
  s.test_files = [
93
94
  "test/core/test_completion.rb",
@@ -38,6 +38,99 @@ module Gemgem
38
38
  self.spec = spec
39
39
  end
40
40
 
41
+ def gem_install
42
+ require 'rubygems/commands/install_command'
43
+ # read ~/.gemrc
44
+ Gem.use_paths(Gem.configuration[:gemhome], Gem.configuration[:gempath])
45
+ Gem::Command.extra_args = Gem.configuration[:gem]
46
+
47
+ # setup install options
48
+ cmd = Gem::Commands::InstallCommand.new
49
+ cmd.handle_options([])
50
+
51
+ # install
52
+ install = Gem::Installer.new(gem_path, cmd.options)
53
+ install.install
54
+ puts "\e[35mGem installed: \e[33m#{strip_path(install.gem_dir)}\e[0m"
55
+ end
56
+
57
+ def gem_spec
58
+ create
59
+ write
60
+ end
61
+
62
+ def gem_build
63
+ require 'fileutils'
64
+ require 'rubygems/package'
65
+ gem = nil
66
+ Dir.chdir(dir) do
67
+ gem = Gem::Package.build(Gem::Specification.load(spec_path))
68
+ FileUtils.mkdir_p(pkg_dir)
69
+ FileUtils.mv(gem, pkg_dir) # gem is relative path, but might be ok
70
+ end
71
+ puts "\e[35mGem built: \e[33m#{strip_path("#{pkg_dir}/#{gem}")}\e[0m"
72
+ end
73
+
74
+ def gem_release
75
+ sh_git('tag', gem_tag)
76
+ sh_git('push')
77
+ sh_git('push', '--tags')
78
+ sh_gem('push', gem_path)
79
+ end
80
+
81
+ def gem_check
82
+ ver = spec.version.to_s
83
+
84
+ if ENV['VERSION'].nil?
85
+ puts("\e[35mExpected " \
86
+ "\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
87
+ exit(1)
88
+
89
+ elsif ENV['VERSION'] != ver
90
+ puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
91
+ "\e[35mbut got\n " \
92
+ "\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
93
+ exit(2)
94
+ end
95
+ end
96
+
97
+ def test
98
+ return if test_files.empty?
99
+
100
+ if ENV['COV'] || ENV['CI']
101
+ require 'simplecov'
102
+ if ENV['CI']
103
+ require 'coveralls'
104
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
105
+ end
106
+ SimpleCov.start do
107
+ add_filter('test/')
108
+ add_filter('test.rb')
109
+ end
110
+ end
111
+
112
+ test_files.each{ |file| require "#{dir}/#{file[0..-4]}" }
113
+ end
114
+
115
+ def clean
116
+ return if ignored_files.empty?
117
+
118
+ require 'fileutils'
119
+ trash = File.expand_path("~/.Trash/#{spec.name}")
120
+ puts "Move the following files into: \e[35m#{strip_path(trash)}\e[33m"
121
+
122
+ ignored_files.each do |file|
123
+ from = "#{dir}/#{file}"
124
+ to = "#{trash}/#{File.dirname(file)}"
125
+ puts strip_path(from)
126
+
127
+ FileUtils.mkdir_p(to)
128
+ FileUtils.mv(from, to)
129
+ end
130
+
131
+ print "\e[0m"
132
+ end
133
+
41
134
  def write
42
135
  File.open(spec_path, 'w'){ |f| f << split_lines(spec.to_ruby) }
43
136
  end
@@ -173,82 +266,38 @@ namespace :gem do
173
266
 
174
267
  desc 'Install gem'
175
268
  task :install => [:build] do
176
- Gemgem.sh_gem('install', Gemgem.gem_path)
269
+ Gemgem.gem_install
177
270
  end
178
271
 
179
272
  desc 'Build gem'
180
273
  task :build => [:spec] do
181
- require 'fileutils'
182
- require 'rubygems/package'
183
- gem = nil
184
- Dir.chdir(Gemgem.dir) do
185
- gem = Gem::Package.build(Gem::Specification.load(Gemgem.spec_path))
186
- FileUtils.mkdir_p(Gemgem.pkg_dir)
187
- FileUtils.mv(gem, Gemgem.pkg_dir) # gem is relative path, but might be ok
188
- end
189
- puts "\e[35mGem built: \e[33m" \
190
- "#{Gemgem.strip_path("#{Gemgem.pkg_dir}/#{gem}")}\e[0m"
274
+ Gemgem.gem_build
191
275
  end
192
276
 
193
277
  desc 'Generate gemspec'
194
278
  task :spec do
195
- Gemgem.create
196
- Gemgem.write
279
+ Gemgem.gem_spec
197
280
  end
198
281
 
199
282
  desc 'Release gem'
200
283
  task :release => [:spec, :check, :build] do
201
- Gemgem.module_eval do
202
- sh_git('tag', Gemgem.gem_tag)
203
- sh_git('push')
204
- sh_git('push', '--tags')
205
- sh_gem('push', Gemgem.gem_path)
206
- end
284
+ Gemgem.gem_release
207
285
  end
208
286
 
209
287
  task :check do
210
- ver = Gemgem.spec.version.to_s
211
-
212
- if ENV['VERSION'].nil?
213
- puts("\e[35mExpected " \
214
- "\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
215
- exit(1)
216
-
217
- elsif ENV['VERSION'] != ver
218
- puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
219
- "\e[35mbut got\n " \
220
- "\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
221
- exit(2)
222
- end
288
+ Gemgem.gem_check
223
289
  end
224
290
 
225
291
  end # of gem namespace
226
292
 
227
293
  desc 'Run tests'
228
294
  task :test do
229
- next if Gemgem.test_files.empty?
230
- Gemgem.test_files.each{ |file| require "#{Gemgem.dir}/#{file[0..-4]}" }
295
+ Gemgem.test
231
296
  end
232
297
 
233
298
  desc 'Trash ignored files'
234
299
  task :clean => ['gem:spec'] do
235
- next if Gemgem.ignored_files.empty?
236
-
237
- require 'fileutils'
238
- trash = File.expand_path("~/.Trash/#{Gemgem.spec.name}")
239
- puts "Move the following files into:" \
240
- " \e[35m#{Gemgem.strip_path(trash)}\e[33m"
241
-
242
- Gemgem.ignored_files.each do |file|
243
- from = "#{Gemgem.dir}/#{file}"
244
- to = "#{trash}/#{File.dirname(file)}"
245
- puts Gemgem.strip_path(from)
246
-
247
- FileUtils.mkdir_p(to)
248
- FileUtils.mv(from, to)
249
- end
250
-
251
- print "\e[0m"
300
+ Gemgem.clean
252
301
  end
253
302
 
254
303
  task :default do
@@ -49,20 +49,21 @@ end
49
49
  describe Rib::History do
50
50
  paste :rib
51
51
 
52
- before do
53
- if readline?
54
- ::Readline::HISTORY.clear
55
- stub_readline
52
+ test_for Rib::History do
53
+ before do
54
+ if readline?
55
+ ::Readline::HISTORY.clear
56
+ stub_readline
57
+ end
58
+ @history_file = "/tmp/test_rib_#{rand}"
59
+ @shell = Rib::Shell.new(
60
+ :history_file => @history_file).before_loop
56
61
  end
57
- @history_file = "/tmp/test_rib_#{rand}"
58
- @shell = Rib::Shell.new(:history_file => @history_file).before_loop
59
- end
60
62
 
61
- after do
62
- FileUtils.rm_f(@history_file)
63
- end
63
+ after do
64
+ FileUtils.rm_f(@history_file)
65
+ end
64
66
 
65
- test_for Rib::History do
66
67
  paste :history
67
68
  end
68
69
  end
@@ -16,11 +16,11 @@ end
16
16
  describe Rib::Readline do
17
17
  paste :rib
18
18
 
19
- before do
20
- @shell = Rib::Shell.new.before_loop
21
- end
22
-
23
19
  test_for Rib::Readline do
20
+ before do
21
+ @shell = Rib::Shell.new.before_loop
22
+ end
23
+
24
24
  paste :readline
25
25
  end
26
26
  end
@@ -32,18 +32,18 @@ end
32
32
  describe Rib::SqueezeHistory do
33
33
  paste :rib
34
34
 
35
- before do
36
- @history = "/tmp/test_rib_#{rand}"
37
- @shell = Rib::Shell.new(:history_file => @history).before_loop
38
- @input = %w[foo bar bar foo bar]
39
- @shell.history.clear
40
- end
35
+ test_for Rib::History, Rib::SqueezeHistory do
36
+ before do
37
+ @history = "/tmp/test_rib_#{rand}"
38
+ @shell = Rib::Shell.new(:history_file => @history).before_loop
39
+ @input = %w[foo bar bar foo bar]
40
+ @shell.history.clear
41
+ end
41
42
 
42
- after do
43
- FileUtils.rm_f(@history)
44
- end
43
+ after do
44
+ FileUtils.rm_f(@history)
45
+ end
45
46
 
46
- test_for Rib::History, Rib::SqueezeHistory do
47
47
  paste :squeeze_history
48
48
  end
49
49
  end
@@ -5,9 +5,6 @@ require 'rib/extra/autoindent'
5
5
  describe Rib::Autoindent do
6
6
  paste :rib
7
7
 
8
- Rib::Multiline.enable
9
- Rib::Autoindent.enable
10
-
11
8
  autoindent = Class.new do
12
9
  include Rib::Autoindent, Rib::Multiline, Rib::API
13
10
  def config
@@ -19,6 +16,8 @@ describe Rib::Autoindent do
19
16
  end
20
17
 
21
18
  before do
19
+ Rib::Multiline.enable
20
+ Rib::Autoindent.enable
22
21
  @indent = autoindent.new
23
22
  mock(@indent).puts(match(/^\e/)).times(0)
24
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
@@ -72,6 +72,7 @@ files:
72
72
  - lib/rib/extra/paging.rb
73
73
  - lib/rib/more.rb
74
74
  - lib/rib/more/anchor.rb
75
+ - lib/rib/more/bottomup_backtrace.rb
75
76
  - lib/rib/more/color.rb
76
77
  - lib/rib/more/edit.rb
77
78
  - lib/rib/more/multiline_history.rb
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  version: '0'
120
121
  requirements: []
121
122
  rubyforge_project:
122
- rubygems_version: 2.4.2
123
+ rubygems_version: 2.4.5
123
124
  signing_key:
124
125
  specification_version: 4
125
126
  summary: Ruby-Interactive-ruBy -- Yet another interactive Ruby shell