contextr 0.1.9 → 1.0.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.tar.gz.sig +0 -0
- data/History.txt +8 -0
- data/Manifest.txt +12 -17
- data/README.txt +0 -1
- data/examples/employer.rb +229 -0
- data/examples/node.rb +213 -0
- data/lib/contextr/class_methods.rb +14 -6
- data/lib/contextr/core_ext/module.rb +3 -2
- data/lib/contextr/event_machine.rb +12 -12
- data/lib/contextr/inner_class.rb +7 -3
- data/lib/contextr/layer.rb +17 -7
- data/lib/contextr/public_api.rb +44 -3
- data/lib/contextr/version.rb +3 -3
- data/lib/ext/active_support_subset.rb +0 -45
- data/spec/contextr_spec.rb +97 -7
- data/test/{test_class_side.mkd → class_side.mkd} +6 -13
- data/test/{test_dynamic_scope.mkd → dynamic_scope.mkd} +2 -2
- data/test/{test_dynamics.mkd → dynamics.mkd} +3 -3
- data/test/{test_hello_world.mkd → hello_world.mkd} +1 -1
- data/test/{test_introduction.mkd → introduction.mkd} +4 -4
- data/test/{test_layer_state.mkd → layer_state.mkd} +2 -2
- data/test/lib/example_test.rb +2 -2
- data/test/lib/literate_maruku_test.rb +11 -9
- data/test/{test_meta_api.mkd → meta_api.mkd} +1 -1
- data/test/method_missing.mkd +40 -0
- data/test/{test_ordering.mkd → ordering.mkd} +8 -8
- data/test/restrictions.mkd +177 -0
- data/test/test_contextr.rb +7 -0
- data/test/test_plain.rb +92 -0
- metadata +17 -29
- metadata.gz.sig +0 -0
- data/test/lib/literate_markaby_test.rb +0 -97
- data/test/test_class_side.rb +0 -4
- data/test/test_dynamic_scope.rb +0 -4
- data/test/test_dynamics.rb +0 -4
- data/test/test_hello_world.rb +0 -4
- data/test/test_introduction.rb +0 -4
- data/test/test_layer_state.rb +0 -3
- data/test/test_meta_api.rb +0 -4
- data/test/test_ordering.rb +0 -3
data/test/test_plain.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/contextr'
|
3
|
+
|
4
|
+
class C1 < Struct.new(:a, :b)
|
5
|
+
def to_s
|
6
|
+
a
|
7
|
+
end
|
8
|
+
end
|
9
|
+
class C2 < Struct.new(:a, :b, :c1)
|
10
|
+
def to_s
|
11
|
+
a
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class C1
|
16
|
+
in_layer :b do
|
17
|
+
def to_s
|
18
|
+
"#{super} (#{yield(:receiver).b})"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
class C2
|
23
|
+
in_layer :b do
|
24
|
+
def to_s
|
25
|
+
"#{super} (#{yield(:receiver).b})"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
in_layer :c do
|
29
|
+
def to_s
|
30
|
+
"#{super}; #{yield(:receiver).c1}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
$c1 = C1.new("a1", "b1")
|
36
|
+
$c2 = C2.new("a2", "b2", $c1)
|
37
|
+
|
38
|
+
class TestPlain < Test::Unit::TestCase
|
39
|
+
def test_001
|
40
|
+
assert_equal("a1", $c1.to_s)
|
41
|
+
assert_equal("a2", $c2.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_002
|
45
|
+
ContextR.with_layer :b do
|
46
|
+
assert_equal("a1 (b1)", $c1.to_s)
|
47
|
+
assert_equal("a2 (b2)", $c2.to_s)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_003
|
52
|
+
assert_equal("a1", $c1.to_s)
|
53
|
+
assert_equal("a2", $c2.to_s)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_004
|
57
|
+
ContextR.with_layer :c do
|
58
|
+
assert_equal("a2; a1", $c2.to_s)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_005
|
63
|
+
ContextR.with_layer :b, :c do
|
64
|
+
assert_equal("a2 (b2); a1 (b1)", $c2.to_s)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_006
|
69
|
+
ContextR::with_layer :b do
|
70
|
+
ContextR.with_layer :c do
|
71
|
+
assert_equal("a2 (b2); a1 (b1)", $c2.to_s)
|
72
|
+
|
73
|
+
ContextR.without_layer :c do
|
74
|
+
assert_equal("a2 (b2)", $c2.to_s)
|
75
|
+
end
|
76
|
+
|
77
|
+
assert_equal("a2 (b2); a1 (b1)", $c2.to_s)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
if RUBY_VERSION =~ /1\.8/
|
83
|
+
def test_007
|
84
|
+
assert_equal(["to_s"], C1.in_layer(:b).instance_methods)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
if RUBY_VERSION =~ /1\.9/
|
88
|
+
def test_007
|
89
|
+
assert_equal([:to_s], C1.in_layer(:b).instance_methods)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contextr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
platform:
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregor Schmidt
|
8
8
|
autorequire:
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
y3O9DT3o4BiyPe77
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date:
|
33
|
+
date: 2008-03-29 23:00:00 +01:00
|
34
34
|
default_executable:
|
35
35
|
dependencies: []
|
36
36
|
|
@@ -54,6 +54,8 @@ files:
|
|
54
54
|
- README.txt
|
55
55
|
- Rakefile
|
56
56
|
- examples/README
|
57
|
+
- examples/employer.rb
|
58
|
+
- examples/node.rb
|
57
59
|
- lib/contextr.rb
|
58
60
|
- lib/contextr/class_methods.rb
|
59
61
|
- lib/contextr/core_ext.rb
|
@@ -73,27 +75,20 @@ files:
|
|
73
75
|
- spec/contextr_spec.rb
|
74
76
|
- spec/spec.opts
|
75
77
|
- spec/spec_helper.rb
|
78
|
+
- test/class_side.mkd
|
79
|
+
- test/dynamic_scope.mkd
|
80
|
+
- test/dynamics.mkd
|
81
|
+
- test/hello_world.mkd
|
82
|
+
- test/introduction.mkd
|
83
|
+
- test/layer_state.mkd
|
76
84
|
- test/lib/example_test.rb
|
77
|
-
- test/lib/literate_markaby_test.rb
|
78
85
|
- test/lib/literate_maruku_test.rb
|
79
|
-
- test/
|
80
|
-
- test/
|
86
|
+
- test/meta_api.mkd
|
87
|
+
- test/method_missing.mkd
|
88
|
+
- test/ordering.mkd
|
89
|
+
- test/restrictions.mkd
|
81
90
|
- test/test_contextr.rb
|
82
|
-
- test/test_dynamic_scope.mkd
|
83
|
-
- test/test_dynamic_scope.rb
|
84
|
-
- test/test_dynamics.mkd
|
85
|
-
- test/test_dynamics.rb
|
86
|
-
- test/test_hello_world.mkd
|
87
|
-
- test/test_hello_world.rb
|
88
91
|
- test/test_helper.rb
|
89
|
-
- test/test_introduction.mkd
|
90
|
-
- test/test_introduction.rb
|
91
|
-
- test/test_layer_state.mkd
|
92
|
-
- test/test_layer_state.rb
|
93
|
-
- test/test_meta_api.mkd
|
94
|
-
- test/test_meta_api.rb
|
95
|
-
- test/test_ordering.mkd
|
96
|
-
- test/test_ordering.rb
|
97
92
|
has_rdoc: true
|
98
93
|
homepage: http://contextr.rubyforge.org
|
99
94
|
post_install_message:
|
@@ -117,18 +112,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
112
|
requirements: []
|
118
113
|
|
119
114
|
rubyforge_project: contextr
|
120
|
-
rubygems_version: 0.
|
115
|
+
rubygems_version: 1.0.1
|
121
116
|
signing_key:
|
122
117
|
specification_version: 2
|
123
118
|
summary: The goal is to equip Ruby with an API to allow context-oriented programming.
|
124
119
|
test_files:
|
125
|
-
- test/test_class_side.rb
|
126
120
|
- test/test_contextr.rb
|
127
|
-
- test/test_dynamic_scope.rb
|
128
|
-
- test/test_dynamics.rb
|
129
|
-
- test/test_hello_world.rb
|
130
121
|
- test/test_helper.rb
|
131
|
-
- test/
|
132
|
-
- test/test_layer_state.rb
|
133
|
-
- test/test_meta_api.rb
|
134
|
-
- test/test_ordering.rb
|
122
|
+
- test/test_plain.rb
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'markaby'
|
2
|
-
if PLATFORM == "java"
|
3
|
-
class Markaby::Builder
|
4
|
-
def pre_block(block)
|
5
|
-
end
|
6
|
-
end
|
7
|
-
else
|
8
|
-
require 'ruby2ruby'
|
9
|
-
end
|
10
|
-
|
11
|
-
module LiterateMarkabyTest
|
12
|
-
TARGET_DIR = File.dirname(__FILE__) + "/../../website/test/"
|
13
|
-
module ObjectExtension
|
14
|
-
def test(name, &block)
|
15
|
-
mab = Markaby::Builder.new
|
16
|
-
|
17
|
-
mab.test_class = Class.new(Test::Unit::TestCase)
|
18
|
-
mab.latest_test_case = 0
|
19
|
-
|
20
|
-
Object.const_set(name, mab.test_class)
|
21
|
-
mab.xhtml_strict do
|
22
|
-
head do
|
23
|
-
title { name }
|
24
|
-
end
|
25
|
-
body do
|
26
|
-
h1 { name }
|
27
|
-
div(&block)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Dir.mkdir(TARGET_DIR) unless File.directory?(TARGET_DIR)
|
32
|
-
File.open(TARGET_DIR + name.to_s.underscore + ".html", "w") do |f|
|
33
|
-
f.puts mab.to_s
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
module MarkabyBuilderExtension
|
39
|
-
attr_accessor :test_class, :latest_test_case
|
40
|
-
def pre_block(block)
|
41
|
-
self.pre(block.to_ruby.gsub(/^proc \{\n(.*)\n\}$/m, '\1'))
|
42
|
-
end
|
43
|
-
|
44
|
-
def output(&block)
|
45
|
-
block.call
|
46
|
-
pre_block(block)
|
47
|
-
end
|
48
|
-
def example(&block)
|
49
|
-
name = "test_%03d" % (self.latest_test_case += 1)
|
50
|
-
test_class.class_eval do
|
51
|
-
define_method(name, &block)
|
52
|
-
end
|
53
|
-
pre_block(block)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
module TestExtension
|
58
|
-
def assert_to_s(expected, actual)
|
59
|
-
assert_equal(expected, actual.to_s)
|
60
|
-
end
|
61
|
-
|
62
|
-
def result_of(object)
|
63
|
-
Result.new(object, self)
|
64
|
-
end
|
65
|
-
|
66
|
-
def output_of(object)
|
67
|
-
Output.new(object, self)
|
68
|
-
end
|
69
|
-
|
70
|
-
class Result
|
71
|
-
attr_accessor :object, :test_class
|
72
|
-
def initialize(object, test_class)
|
73
|
-
self.object = object
|
74
|
-
self.test_class = test_class
|
75
|
-
end
|
76
|
-
def ==(string)
|
77
|
-
test_class.assert_equal(string, object)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
class Output < Result
|
81
|
-
def ==(string)
|
82
|
-
test_class.assert_equal(string, object.to_s)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
#class Test::Unit::TestCase
|
89
|
-
# include LiterateMarkabyTest::TestExtension
|
90
|
-
#end
|
91
|
-
class Object
|
92
|
-
include LiterateMarkabyTest::ObjectExtension
|
93
|
-
end
|
94
|
-
class Markaby::Builder
|
95
|
-
include LiterateMarkabyTest::MarkabyBuilderExtension
|
96
|
-
end
|
97
|
-
|
data/test/test_class_side.rb
DELETED
data/test/test_dynamic_scope.rb
DELETED
data/test/test_dynamics.rb
DELETED
data/test/test_hello_world.rb
DELETED
data/test/test_introduction.rb
DELETED
data/test/test_layer_state.rb
DELETED
data/test/test_meta_api.rb
DELETED
data/test/test_ordering.rb
DELETED