rib 1.3.0 → 1.3.1

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: 1076f17c46a51eb9e569ab5f7471f42dd3b1c3cc
4
- data.tar.gz: 7d9af36e6f5b15a18a01cde080ebbb4cb93023c8
3
+ metadata.gz: e2cc6e3966230aac382f90352549a7545c8e27ff
4
+ data.tar.gz: 6bb97f019cc41dffbc900fa2d5aa1f44024d65a8
5
5
  SHA512:
6
- metadata.gz: 18c8aba3e10d59143db113e3d2cb95c1a77764ad82f3b420994e3fd5d032998eb6280681a6f34247db699635f2641d1d34d2373600be5d7b7fdda5cc0e9c161e
7
- data.tar.gz: 5838f68537399c9981d81540be7deb0bb537ea00ce529e68b114f286dd3094d08b06dbd1fbc8b805e113f32dd7e7fc58c4402a95d3bbe23432ef5bd258c8fb77
6
+ metadata.gz: 0a0519f630b28351cf2d6f636c976eea2d904b1703fbf63c9ad1824944cb204dd5490f39d7d3ebffa1ffe81e994324135e8c5176eb3f905172d259bb3902a76b
7
+ data.tar.gz: 87d41ae852dfb60039bd785fcc9b141fd01cc1bfc304f5b2047891d29ab04ccc05d989075cbec8068b6b35c1a2e7c6bf2a0013c489290b4322d9c132ce639e20
data/.travis.yml CHANGED
@@ -1,8 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.1
5
- - 2.2
4
+ - 2.2.5
6
5
  - 2.3.1
7
6
  - rbx
8
7
  - jruby-9
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGES
2
2
 
3
+ ## Rib 1.3.1 -- 2016-11-03
4
+
5
+ * [core/strip_backtrace], [more/color] No longer show `./` for current path.
6
+ This would be more friendly to some editors like Sublime.
7
+
3
8
  ## Rib 1.3.0 -- 2016-06-28
4
9
 
5
10
  * Now `rib` would accept `-p` or `--prefix` to allow setting where we want to
@@ -45,8 +45,8 @@ module Rib::History
45
45
  # Write #history into config[:history_file], handled in history_file plugin
46
46
  def write_history
47
47
  return super if History.disabled?
48
- File.open(history_file_path, 'w'){ |f|
49
- f.puts(history.to_a.last(history_size).join("\n")) }
48
+ history_text = "#{history.to_a.last(history_size).join("\n")}\n"
49
+ File.write(history_file_path, history_text)
50
50
  end
51
51
 
52
52
 
@@ -22,19 +22,23 @@ module Rib::StripBacktrace
22
22
 
23
23
  module_function
24
24
  def strip_backtrace backtrace
25
- strip_home_backtrace(strip_cwd_backtrace(strip_lib_backtrace(backtrace)))
25
+ strip_home_backtrace(strip_cwd_backtrace(strip_rib_backtrace(backtrace)))
26
26
  end
27
27
 
28
28
  def strip_home_backtrace backtrace
29
- backtrace.map{ |path| path.sub(ENV['HOME'], '~') }
29
+ backtrace.map(&method(:replace_path_prefix).curry[ENV['HOME'], '~/'])
30
30
  end
31
31
 
32
32
  def strip_cwd_backtrace backtrace
33
- backtrace.map{ |path| path.sub(Dir.pwd, '.') }
33
+ backtrace.map(&method(:replace_path_prefix).curry[Dir.pwd, ''])
34
34
  end
35
35
 
36
- def strip_lib_backtrace backtrace
36
+ def strip_rib_backtrace backtrace
37
37
  backtrace[
38
38
  0..backtrace.rindex{ |l| l =~ /\(#{name}\):\d+:in `.+?'/ } || -1]
39
39
  end
40
+
41
+ def replace_path_prefix prefix, substitute, path
42
+ path.sub(/\A#{Regexp.escape(prefix)}\//, substitute)
43
+ end
40
44
  end
@@ -77,10 +77,10 @@ module Rib::Color
77
77
  def colorize_backtrace backtrace
78
78
  backtrace.map{ |b|
79
79
  path, msgs = b.split(':', 2)
80
- dir , file = ::File.split(path)
80
+ dir, sep, file = path.rpartition('/')
81
81
  msg = msgs.sub(/(\d+):/){red{$1}+':'}.sub(/`.+?'/){green{$&}}
82
82
 
83
- "#{dir+'/'}#{yellow{file}}:#{msg}"
83
+ "#{dir+sep}#{yellow{file}}:#{msg}"
84
84
  }
85
85
  end
86
86
 
data/lib/rib/test.rb CHANGED
@@ -1,9 +1,8 @@
1
1
 
2
2
  require 'pork/auto'
3
3
  require 'muack'
4
- require 'fileutils'
5
4
 
6
- Pork::Executor.__send__(:include, Muack::API)
5
+ Pork::Suite.include(Muack::API)
7
6
 
8
7
  require 'rib'
9
8
 
data/lib/rib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rib
3
- VERSION = '1.3.0'
3
+ VERSION = '1.3.1'
4
4
  end
data/rib.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rib 1.3.0 ruby lib
2
+ # stub: rib 1.3.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rib".freeze
6
- s.version = "1.3.0"
6
+ s.version = "1.3.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Lin Jen-Shin (godfat)".freeze]
11
- s.date = "2016-06-28"
11
+ s.date = "2016-11-03"
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".freeze
13
13
  s.email = ["godfat (XD) godfat.org".freeze]
14
14
  s.executables = [
@@ -78,6 +78,7 @@ Gem::Specification.new do |s|
78
78
  "test/core/test_multiline.rb".freeze,
79
79
  "test/core/test_readline.rb".freeze,
80
80
  "test/core/test_squeeze_history.rb".freeze,
81
+ "test/core/test_strip_backtrace.rb".freeze,
81
82
  "test/core/test_underscore.rb".freeze,
82
83
  "test/extra/test_autoindent.rb".freeze,
83
84
  "test/more/test_color.rb".freeze,
@@ -88,7 +89,7 @@ Gem::Specification.new do |s|
88
89
  "test/test_shell.rb".freeze]
89
90
  s.homepage = "https://github.com/godfat/rib".freeze
90
91
  s.licenses = ["Apache License 2.0".freeze]
91
- s.rubygems_version = "2.6.4".freeze
92
+ s.rubygems_version = "2.6.7".freeze
92
93
  s.summary = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell".freeze
93
94
  s.test_files = [
94
95
  "test/core/test_completion.rb".freeze,
@@ -96,6 +97,7 @@ Gem::Specification.new do |s|
96
97
  "test/core/test_multiline.rb".freeze,
97
98
  "test/core/test_readline.rb".freeze,
98
99
  "test/core/test_squeeze_history.rb".freeze,
100
+ "test/core/test_strip_backtrace.rb".freeze,
99
101
  "test/core/test_underscore.rb".freeze,
100
102
  "test/extra/test_autoindent.rb".freeze,
101
103
  "test/more/test_color.rb".freeze,
@@ -1,6 +1,7 @@
1
1
 
2
2
  require 'rib/test'
3
3
  require 'rib/core/history'
4
+ require 'tempfile'
4
5
 
5
6
  copy :history do
6
7
  would '#after_loop save history' do
@@ -13,7 +14,7 @@ copy :history do
13
14
  end
14
15
 
15
16
  would '#before_loop load previous history' do
16
- File.open(@history_file, 'w'){ |f| f.write "check\nthe\nmike" }
17
+ File.write(@history_file, "check\nthe\nmike")
17
18
  @shell.before_loop
18
19
  @shell.history.to_a.should.eq %w[check the mike]
19
20
  end
@@ -55,13 +56,14 @@ describe Rib::History do
55
56
  ::Readline::HISTORY.clear
56
57
  stub_readline
57
58
  end
58
- @history_file = "/tmp/test_rib_#{rand}"
59
+ @tempfile = Tempfile.new('rib')
60
+ @history_file = @tempfile.path
59
61
  @shell = Rib::Shell.new(
60
62
  :history_file => @history_file).before_loop
61
63
  end
62
64
 
63
65
  after do
64
- FileUtils.rm_f(@history_file)
66
+ @tempfile.unlink
65
67
  end
66
68
 
67
69
  paste :history
@@ -1,6 +1,7 @@
1
1
 
2
2
  require 'rib/test'
3
3
  require 'rib/core/squeeze_history'
4
+ require 'tempfile'
4
5
 
5
6
  copy :squeeze_history do
6
7
  would 'after_loop saves squeezed history' do
@@ -34,14 +35,15 @@ describe Rib::SqueezeHistory do
34
35
 
35
36
  test_for Rib::History, Rib::SqueezeHistory do
36
37
  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]
38
+ @tempfile = Tempfile.new('rib')
39
+ @history = @tempfile.path
40
+ @shell = Rib::Shell.new(:history_file => @history).before_loop
41
+ @input = %w[foo bar bar foo bar]
40
42
  @shell.history.clear
41
43
  end
42
44
 
43
45
  after do
44
- FileUtils.rm_f(@history) if Rib::History.enabled?
46
+ @tempfile.unlink
45
47
  end
46
48
 
47
49
  paste :squeeze_history
@@ -0,0 +1,19 @@
1
+
2
+ require 'rib/test'
3
+ require 'rib/core/strip_backtrace'
4
+
5
+ describe Rib::StripBacktrace do
6
+ would 'strip home' do
7
+ backtrace = ["#{ENV['HOME']}/test", "/prefix/#{ENV['HOME']}/test"]
8
+
9
+ expect(Rib::StripBacktrace.strip_home_backtrace(backtrace)).
10
+ eq ['~/test', "/prefix/#{ENV['HOME']}/test"]
11
+ end
12
+
13
+ would 'strip current working directory' do
14
+ backtrace = [File.expand_path(__FILE__)]
15
+
16
+ expect(Rib::StripBacktrace.strip_cwd_backtrace(backtrace)).
17
+ eq ['test/core/test_strip_backtrace.rb']
18
+ end
19
+ end
@@ -37,18 +37,14 @@ describe Rib::Color do
37
37
 
38
38
  # regression test
39
39
  would "colorize errors with `/' inside" do
40
- i = if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
41
- 1
42
- else
43
- 0
44
- end
40
+ error = Class.new(Exception)
45
41
 
46
42
  begin
47
- line = __LINE__; 1/0
48
- rescue ZeroDivisionError => e
43
+ line = __LINE__; raise error
44
+ rescue error => e
49
45
  msg = "test/more/#{Rib::Color.yellow{'test_color.rb'}}:" \
50
46
  "#{Rib::Color.red{line}}:in #{Rib::Color.green}"
51
- Rib::Color.colorize_backtrace(e.backtrace)[i].should =~ \
47
+ Rib::Color.colorize_backtrace(e.backtrace).first.should =~ \
52
48
  Regexp.new(
53
49
  "#{Regexp.escape(msg)}`.+'#{Regexp.escape(Rib::Color.reset)}")
54
50
  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.3.0
4
+ version: 1.3.1
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: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2016-11-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
@@ -92,6 +92,7 @@ files:
92
92
  - test/core/test_multiline.rb
93
93
  - test/core/test_readline.rb
94
94
  - test/core/test_squeeze_history.rb
95
+ - test/core/test_strip_backtrace.rb
95
96
  - test/core/test_underscore.rb
96
97
  - test/extra/test_autoindent.rb
97
98
  - test/more/test_color.rb
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  version: '0'
121
122
  requirements: []
122
123
  rubyforge_project:
123
- rubygems_version: 2.6.4
124
+ rubygems_version: 2.6.7
124
125
  signing_key:
125
126
  specification_version: 4
126
127
  summary: Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
@@ -130,6 +131,7 @@ test_files:
130
131
  - test/core/test_multiline.rb
131
132
  - test/core/test_readline.rb
132
133
  - test/core/test_squeeze_history.rb
134
+ - test/core/test_strip_backtrace.rb
133
135
  - test/core/test_underscore.rb
134
136
  - test/extra/test_autoindent.rb
135
137
  - test/more/test_color.rb