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 +4 -0
- data/lib/repl.rb +13 -7
- data/test/repl_test.rb +7 -0
- data/test/test_helper.rb +7 -0
- metadata +11 -7
data/VERSION.yml
ADDED
data/lib/repl.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
|
-
DEFAULT_STARTING_SELF
|
2
|
-
|
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
|
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 (
|
12
|
-
DEFAULT_STARTING_SELF.cb(
|
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
data/test/test_helper.rb
ADDED
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
|
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:
|
12
|
+
date: 2009-03-05 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
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
|
-
|
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
|
|