mattknox-repl 0.0.6 → 0.1.0

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/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 0
3
+ :major: 0
4
+ :minor: 1
data/lib/repl.rb CHANGED
@@ -1,19 +1,25 @@
1
- DEFAULT_STARTING_SELF = self
2
- REPL_CONTEXT_STACK = [binding]
1
+ DEFAULT_STARTING_SELF = self
2
+ DEFAULT_STARTING_BINDING = []
3
+ REPL_CONTEXT_STACK = []
3
4
 
4
5
  module Repl
5
6
  def repl
6
- DEFAULT_STARTING_SELF.cb binding
7
- REPL_CONTEXT_STACK.push(binding)
7
+ DEFAULT_STARTING_SELF.cb self
8
+ REPL_CONTEXT_STACK.push([binding, self])
8
9
  end
9
10
 
10
11
  def stop_repl
11
- REPL_CONTEXT_STACK.pop if (binding == REPL_CONTEXT_STACK.last)
12
- DEFAULT_STARTING_SELF.cb( REPL_CONTEXT_STACK.empty? ? DEFAULT_STARTING_SELF : REPL_CONTEXT_STACK.pop )
12
+ REPL_CONTEXT_STACK.pop if (self == REPL_CONTEXT_STACK.last[1])
13
+ DEFAULT_STARTING_SELF.cb((REPL_CONTEXT_STACK.pop.first or DEFAULT_STARTING_BINDING.first ))
13
14
  end
14
15
  end
15
16
 
16
- module HookRepl # FIXME: not everything unterstands class_eval. Maybe need an "eval in this thing method?"
17
+ module HookRepl # FIXME: not everything unterstands class_eval. Maybe need an "'eval in this thing' method?"
18
+ def self.init(binding)
19
+ DEFAULT_STARTING_BINDING.push(binding)
20
+ REPL_CONTEXT_STACK.push([binding, self])
21
+ end
22
+
17
23
  def self.replize_object(obj, class_or_instance_or_both = :both)
18
24
  obj.class_eval "extend Repl" if [:class, :both].member?(class_or_instance_or_both)
19
25
  obj.class_eval "include Repl" if [:object, :both].member?(class_or_instance_or_both)
data/test/repl_test.rb ADDED
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ReplTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ class Test::Unit::TestCase
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mattknox-repl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - matt knox
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-16 00:00:00 -08:00
12
+ date: 2009-03-05 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Repl makes it possible to change IRB's notion of self to be any object or class.
16
+ description: TODO
17
17
  email: matthewknox@gmail.com
18
18
  executables: []
19
19
 
@@ -22,12 +22,16 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - VERSION.yml
25
26
  - lib/repl.rb
26
- has_rdoc: false
27
+ - test/repl_test.rb
28
+ - test/test_helper.rb
29
+ has_rdoc: true
27
30
  homepage: http://github.com/mattknox/repl
28
31
  post_install_message:
29
- rdoc_options: []
30
-
32
+ rdoc_options:
33
+ - --inline-source
34
+ - --charset=UTF-8
31
35
  require_paths:
32
36
  - lib
33
37
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -48,6 +52,6 @@ rubyforge_project:
48
52
  rubygems_version: 1.2.0
49
53
  signing_key:
50
54
  specification_version: 2
51
- summary: ""
55
+ summary: TODO
52
56
  test_files: []
53
57