orb 0.0.1 → 0.0.2

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.
data/lib/orb.rb CHANGED
@@ -1,51 +1,43 @@
1
1
  require 'readline'
2
+ require 'orb/adapters/rspec'
2
3
 
3
- # TODO: load rspec or something.
4
+ module ORB
5
+
6
+ def self.capture(bind)
7
+ buf, line, last = [], "", ""
4
8
 
5
- module Spec
6
- module Example
7
- module Pending
8
- # alias __orb_original_pending pending
9
- def pending(message = "TODO")
10
- Binding.of_caller do |b|
11
- buf, line, last = [], "", ""
12
-
13
- while line = Readline.readline("ORB >> ", true)
14
-
15
- case line
16
- when "a"
17
- buf << last
18
- next
19
- when "p"
20
- puts buf
21
- next
22
- when "q"
23
- __orb_original_pending(message)
24
- break
25
- when "s"
26
- line, file = bind.eval("[__LINE__, __FILE__]")
27
- ORB.write_buf_to_file(buf, line, file)
28
- break
29
- else
30
- begin
31
- ctx = bind.eval("self")
32
- ret = ctx.send(:eval, line, ctx.send(:binding))
33
- rescue => e
34
- puts e.message
35
- else
36
- puts ret.inspect
37
- end
38
- end
39
-
40
- last = line
41
- end
42
- end
9
+ puts ORB::Adapter.header(bind)
10
+
11
+ while line = Readline.readline("ORB >> ", true)
12
+
13
+ case line
14
+ when "a"
15
+ buf << last
16
+ next
17
+ when "p"
18
+ puts buf
19
+ next
20
+ when "q"
21
+ __orb_original_pending(message)
22
+ break
23
+ when "s"
24
+ line, file = bind.eval("[__LINE__, __FILE__]")
25
+ ORB.write_buf_to_file(buf, line, file)
26
+ break
27
+ else
28
+ begin
29
+ this = bind.eval("self")
30
+ ret = this.send(:eval, line, this.send(:binding))
31
+ rescue => e
32
+ puts e.message
33
+ else
34
+ puts ret.inspect
35
+ end
43
36
  end
37
+
38
+ last = line
44
39
  end
45
40
  end
46
- end
47
-
48
- module ORB
49
41
 
50
42
  def self.write_buf_to_file(buf, line_num, file)
51
43
  lines = File.read(file).lines.to_a
@@ -0,0 +1,25 @@
1
+ require 'spec/example/pending'
2
+
3
+ module ORB
4
+ module Adapters
5
+ module RSpec
6
+ def self.header(bind)
7
+ this = bind.eval("self")
8
+ ancestry = [this.class, this]
9
+ ancestry.map(&:description).join(" ")
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ module Spec
16
+ module Example
17
+ module Pending
18
+ def ORB(&block)
19
+ ORB.capture(block.binding)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ ORB::Adapter = ORB::Adapters::RSpec
@@ -2,9 +2,9 @@ def Binding.of_caller(&block)
2
2
  old_critical, Thread.critical = Thread.critical, true
3
3
  count = 0
4
4
  cc = nil
5
- result, error = callcc{|c|cc=c}
5
+ result, error = callcc{|c|cc=c;nil}
6
6
  error.call if error
7
-
7
+
8
8
  tracer = lambda do |*args|
9
9
  type, _, _, _, context = args
10
10
  if ["return", "c-return"].include?(type)
@@ -1,11 +1,11 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'orb'
3
- gem.version = "0.0.1"
3
+ gem.version = "0.0.2"
4
4
 
5
5
  gem.author, gem.email = 'Burke Libbey', "burke@burkelibbey.org"
6
6
 
7
7
  gem.summary = "Interactive Testing"
8
- gem.description = "Description pending. Also does not work yet. Just want to save the name on rubygems.org..."
8
+ gem.description = "Description pending."
9
9
 
10
10
  # gem.required_ruby_version = '>= 1.8.7'
11
11
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Burke Libbey
@@ -18,7 +18,7 @@ date: 2010-04-30 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
- description: Description pending. Also does not work yet. Just want to save the name on rubygems.org...
21
+ description: Description pending.
22
22
  email: burke@burkelibbey.org
23
23
  executables: []
24
24
 
@@ -30,6 +30,7 @@ files:
30
30
  - LICENSE
31
31
  - README.md
32
32
  - orb.gemspec
33
+ - lib/orb/adapters/rspec.rb
33
34
  - lib/orb/binding.rb
34
35
  - lib/orb.rb
35
36
  has_rdoc: true