rib 1.1.3 → 1.1.4

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: f9c0da1c91b42793b8e4383b923c4a10f127d11a
4
- data.tar.gz: 9bc65bd697acdd2bd8639a490a059d46a7099c1b
3
+ metadata.gz: 43ddc0849b3347414bbcfbc53aff7a503bae5e02
4
+ data.tar.gz: d95887a92dd06ad68e42bd0d035eb1b4bed1d155
5
5
  SHA512:
6
- metadata.gz: 1246de926465360d9179a61d703c8b53d2ff4df11d9ba9bbd1b6df4457d62c670b4af3ef3b6b4492e565c89b0e66a071e3f38005bdc37b6c59cb9512ba072161
7
- data.tar.gz: d2ba9ba0d7b1944fd82558b574655687af2137ce261845e69d8e1130cadf2bc897e0313673376fe9e6810089c8f67ccb3336deeaa38ebdc059968a840d06d438
6
+ metadata.gz: d51943449c9303867341e4ce231b93f23f933813740761da232c4eeb9619bac28ddf1fae3fcba8d24cb539e35b53bf5febf98d2e5baea9fe03a75afedc11ef83
7
+ data.tar.gz: f1db5967d2549ddddd5d522dded9c93cd092583300bc1bc2221c1be4c3b4f0840d499c055616ff6eefd4191ee384def6971809a60e2e2cf8a14ca209018db949
data/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGES
2
2
 
3
+ ## Rib 1.1.4 -- 2013-07-11
4
+
5
+ * Further fixed a bug for displaying a BasicObject. Rib should never crash.
6
+ * Added `rib-rack` executable which could load the app in config.ru,
7
+ accessible from calling `app` in the console. Also works for `rib-auto`
8
+
3
9
  ## Rib 1.1.3 -- 2013-05-08
4
10
 
5
11
  * Fixed a bug where if user input doesn't respond to `==` would crash rib.
data/Gemfile CHANGED
@@ -1,11 +1,11 @@
1
1
 
2
- source 'http://rubygems.org'
2
+ source 'https://rubygems.org'
3
3
 
4
4
  gemspec
5
5
 
6
6
  gem 'rake'
7
7
  gem 'bacon'
8
- gem 'rr'
8
+ gem 'muack'
9
9
 
10
10
  gem 'bond'
11
11
  gem 'hirb'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rib
1
+ # Rib [![Build Status](https://secure.travis-ci.org/godfat/rib.png?branch=master)](http://travis-ci.org/godfat/rib)
2
2
 
3
3
  by Lin Jen-Shin ([godfat](http://godfat.org))
4
4
 
@@ -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.9.2, 1.9.3, Rubinius and JRuby.
26
+ * Tested with MRI (official CRuby) 1.9.3, 2.0.0, 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
 
@@ -59,8 +59,12 @@ As Ramaze console
59
59
 
60
60
  rib ramaze
61
61
 
62
+ As Rack console
63
+
64
+ rib rack
65
+
62
66
  As a console for whichever the app in the current path
63
- it should be (for now, it's either Rails or Ramaze)
67
+ it should be (for now, it's either Rails, Ramaze or Rack)
64
68
 
65
69
  rib auto
66
70
 
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rib/runner'
4
+ # create the shell before app to prvent your bundler (if any) kicks in
5
+ Rib.shell
6
+ # we need to require anything before loading the app,
7
+ # and both `rib auto` (true) and `rib-auto` (nil) should work
8
+ require 'rib/core' if Rib.config.delete(:mimic_irb) != false
9
+ require 'rib/app/rack'
10
+ # load the app
11
+ Rib::Rack.load
12
+ Rib::Runner.run(ARGV)
@@ -41,10 +41,10 @@ module Rib::API
41
41
  result, err = eval_input(input)
42
42
  if err
43
43
  print_eval_error(err)
44
- elsif input.strip != ''
44
+ elsif input.strip != '' && !equal_rib_skip(result)
45
45
  print_result(result)
46
46
  else
47
- # print nothing for blank input
47
+ # print nothing for blank input or Rib::Skip
48
48
  end
49
49
  [result, err]
50
50
  rescue Interrupt
@@ -79,7 +79,7 @@ module Rib::API
79
79
 
80
80
  # Print result using #format_result
81
81
  def print_result result
82
- puts(format_result(result)) if result != Rib::Skip
82
+ puts(format_result(result))
83
83
  rescue StandardError, SyntaxError => e
84
84
  Rib.warn("Error while printing result:\n #{format_error(e)}")
85
85
  end
@@ -100,4 +100,11 @@ module Rib::API
100
100
  def format_error err
101
101
  "#{err.class}: #{err.message}\n #{err.backtrace.join("\n ")}"
102
102
  end
103
+
104
+ private
105
+ def equal_rib_skip result
106
+ result == Rib::Skip
107
+ rescue Exception
108
+ # do nothing, it cannot respond to == correctly, it can't be Rib::Skip
109
+ end
103
110
  end
@@ -3,7 +3,7 @@ module Rib; end
3
3
  module Rib::Auto
4
4
  module_function
5
5
  def load
6
- app, name = %w[ramaze rails].find{ |name|
6
+ app, name = %w[ramaze rails rack].find{ |name|
7
7
  require "rib/app/#{name}"
8
8
  app = Rib.const_get(name.capitalize)
9
9
  if app.send("#{name}?")
@@ -0,0 +1,25 @@
1
+
2
+ module Rib; end
3
+ module Rib::Rack
4
+ singleton_class.module_eval{ attr_accessor :app }
5
+
6
+ module_function
7
+ def load
8
+ load_rack
9
+ rescue LoadError => e
10
+ Rib.abort("Error: #{e}", "Is this a Rack app?")
11
+ end
12
+
13
+ def load_rack
14
+ require 'rack'
15
+ Rib.abort("Error: Cannot find config.ru") unless rack?
16
+ app, _ = Rack::Builder.parse_file('config.ru')
17
+ self.app = app
18
+ Rib.shell.config[:binding].eval('def app; Rib::Rack.app; end')
19
+ Rib.say("Access your app via :app method")
20
+ end
21
+
22
+ def rack?
23
+ File.exist?('config.ru')
24
+ end
25
+ end
@@ -1,9 +1,9 @@
1
1
 
2
2
  require 'bacon'
3
- require 'rr'
3
+ require 'muack'
4
4
  require 'fileutils'
5
5
  Bacon.summary_on_exit
6
- include RR::Adapters::RRMethods
6
+ include Muack::API
7
7
 
8
8
  require 'rib'
9
9
 
@@ -12,7 +12,7 @@ shared :rib do
12
12
  end
13
13
 
14
14
  after do
15
- RR.verify
15
+ Muack.verify
16
16
  end
17
17
 
18
18
  def test_for *plugins, &block
@@ -3,8 +3,8 @@ shared :setup_multiline do
3
3
  def setup_shell
4
4
  @shell = Rib::Shell.new(
5
5
  :binding => Object.new.instance_eval{binding}).before_loop
6
- stub(@shell).print
7
- stub(@shell).puts
6
+ stub(@shell).print.with_any_args
7
+ stub(@shell).puts .with_any_args
8
8
  end
9
9
 
10
10
  def setup_input str
@@ -19,7 +19,7 @@ shared :setup_multiline do
19
19
 
20
20
  def input str
21
21
  setup_input(str)
22
- mock.proxy(@shell).throw(:rib_multiline)
22
+ mock(@shell).throw(:rib_multiline).proxy
23
23
  end
24
24
 
25
25
  def input_done str, err=nil
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rib
3
- VERSION = '1.1.3'
3
+ VERSION = '1.1.4'
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.1.3"
5
+ s.version = "1.1.4"
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 = "2013-05-08"
9
+ s.date = "2013-07-11"
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 = [
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  "rib-all",
15
15
  "rib-auto",
16
16
  "rib-min",
17
+ "rib-rack",
17
18
  "rib-rails",
18
19
  "rib-ramaze"]
19
20
  s.files = [
@@ -30,12 +31,14 @@ Gem::Specification.new do |s|
30
31
  "bin/rib-all",
31
32
  "bin/rib-auto",
32
33
  "bin/rib-min",
34
+ "bin/rib-rack",
33
35
  "bin/rib-rails",
34
36
  "bin/rib-ramaze",
35
37
  "lib/rib.rb",
36
38
  "lib/rib/all.rb",
37
39
  "lib/rib/api.rb",
38
40
  "lib/rib/app/auto.rb",
41
+ "lib/rib/app/rack.rb",
39
42
  "lib/rib/app/rails.rb",
40
43
  "lib/rib/app/ramaze.rb",
41
44
  "lib/rib/config.rb",
@@ -82,7 +85,7 @@ Gem::Specification.new do |s|
82
85
  s.homepage = "https://github.com/godfat/rib"
83
86
  s.licenses = ["Apache License 2.0"]
84
87
  s.require_paths = ["lib"]
85
- s.rubygems_version = "2.0.3"
88
+ s.rubygems_version = "2.0.4"
86
89
  s.summary = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell"
87
90
  s.test_files = [
88
91
  "test/core/test_completion.rb",
@@ -12,7 +12,7 @@ shared :squeeze_history do
12
12
  should 'loop_once squeeze history' do
13
13
  times = @input.size
14
14
  stub(@shell).get_input{ (@shell.history << "'#{@input.shift}'")[-1] }
15
- stub(@shell).print_result
15
+ stub(@shell).print_result.with_any_args
16
16
  times.times{ @shell.loop_once }
17
17
  @shell.history.to_a.should.eq %w[foo bar foo bar].map{ |i| "'#{i}'" }
18
18
  end
@@ -22,7 +22,7 @@ shared :squeeze_history do
22
22
  times = @input.size
23
23
  input = @input.dup
24
24
  stub(@shell).get_input{ (@shell.history << "'#{@input.shift}'")[-1] }
25
- stub(@shell).print_result
25
+ stub(@shell).print_result.with_any_args
26
26
  times.times{ @shell.loop_once }
27
27
  @shell.history.to_a.should.eq input.map{ |i| "'#{i}'" }
28
28
  Rib::SqueezeHistory.enable
@@ -29,7 +29,7 @@ shared :underscore do
29
29
 
30
30
  should 'set __' do
31
31
  setup
32
- stub(@shell).puts
32
+ stub(@shell).puts.with_any_args
33
33
  mock(@shell).get_input{'XD'}
34
34
  mock(@shell).get_input{'__'}
35
35
  @shell.loop_once
@@ -43,7 +43,7 @@ describe Rib::Underscore do
43
43
  def setup bound=Object.new
44
44
  @shell = Rib::Shell.new(
45
45
  :binding => bound.instance_eval{binding}).before_loop
46
- stub(@shell).puts
46
+ stub(@shell).puts(is_a(String))
47
47
  end
48
48
 
49
49
  test_for Rib::Underscore do
@@ -45,17 +45,17 @@ describe Rib::Shell do
45
45
  end
46
46
 
47
47
  should 'error in print_result' do
48
- mock(Rib).warn(/Error while printing result.*BOOM/m)
48
+ mock(Rib).warn(match(/Error while printing result.*BOOM/m))
49
49
  input('obj = Object.new; def obj.inspect; raise "BOOM"; end; obj')
50
50
  end
51
51
 
52
52
  should 'not crash if user input is a blackhole' do
53
- mock(Rib).warn(/Error while printing result/)
53
+ mock(Rib).warn(match(/Error while printing result/))
54
54
  input('Rib::Blackhole')
55
55
  end
56
56
 
57
57
  should 'print error from eval' do
58
- mock(@shell).puts(/RuntimeError/)
58
+ mock(@shell).puts(match(/RuntimeError/))
59
59
  input('raise "blah"')
60
60
  end
61
61
  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.1.3
4
+ version: 1.1.4
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: 2013-05-08 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
@@ -28,6 +28,7 @@ executables:
28
28
  - rib-all
29
29
  - rib-auto
30
30
  - rib-min
31
+ - rib-rack
31
32
  - rib-rails
32
33
  - rib-ramaze
33
34
  extensions: []
@@ -46,12 +47,14 @@ files:
46
47
  - bin/rib-all
47
48
  - bin/rib-auto
48
49
  - bin/rib-min
50
+ - bin/rib-rack
49
51
  - bin/rib-rails
50
52
  - bin/rib-ramaze
51
53
  - lib/rib.rb
52
54
  - lib/rib/all.rb
53
55
  - lib/rib/api.rb
54
56
  - lib/rib/app/auto.rb
57
+ - lib/rib/app/rack.rb
55
58
  - lib/rib/app/rails.rb
56
59
  - lib/rib/app/ramaze.rb
57
60
  - lib/rib/config.rb
@@ -115,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
118
  version: '0'
116
119
  requirements: []
117
120
  rubyforge_project:
118
- rubygems_version: 2.0.3
121
+ rubygems_version: 2.0.4
119
122
  signing_key:
120
123
  specification_version: 4
121
124
  summary: Ruby-Interactive-ruBy -- Yet another interactive Ruby shell