phenomenal 0.11.11.24.4 → 0.99.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README +3 -4
- data/Rakefile +3 -0
- data/lib/phenomenal.rb +15 -2
- data/lib/phenomenal/adaptation.rb +22 -12
- data/lib/phenomenal/context.rb +127 -134
- data/lib/phenomenal/dsl.rb +41 -14
- data/lib/phenomenal/feature.rb +8 -0
- data/lib/phenomenal/logger.rb +0 -1
- data/lib/phenomenal/manager.rb +117 -35
- data/lib/phenomenal/relationships/context_relationships.rb +22 -0
- data/lib/phenomenal/relationships/dsl.rb +18 -0
- data/lib/phenomenal/relationships/feature_relationships.rb +42 -0
- data/lib/phenomenal/relationships/implication.rb +35 -0
- data/lib/phenomenal/relationships/relationship.rb +42 -0
- data/lib/phenomenal/relationships/relationships_manager.rb +63 -0
- data/lib/phenomenal/relationships/relationships_store.rb +73 -0
- data/lib/phenomenal/relationships/requirement.rb +26 -0
- data/lib/phenomenal/relationships/suggestion.rb +41 -0
- data/lib/phenomenal/version.rb +3 -0
- data/spec/adaptation_spec.rb +64 -0
- data/spec/behavior/adaptation_spec.rb +5 -0
- data/spec/behavior/combined_contexts_spec.rb +5 -0
- data/spec/behavior/composition_spec.rb +5 -0
- data/spec/behavior/conflict_policy_spec.rb +5 -0
- data/spec/behavior/open_context.rb +5 -0
- data/spec/behavior/relationships_spec.rb +249 -0
- data/spec/context_spec.rb +268 -0
- data/spec/dsl_spec.rb +181 -0
- data/spec/feature_spec.rb +5 -0
- data/spec/manager_spec.rb +84 -0
- data/spec/proc_spec.rb +20 -0
- data/spec/relationships/context_relationships_spec.rb +13 -0
- data/spec/relationships/dsl_spec.rb +13 -0
- data/spec/relationships/feature_relationships_spec.rb +13 -0
- data/spec/relationships/relationship_spec.rb +31 -0
- data/spec/relationships/relationships_manager_spec.rb +15 -0
- data/spec/relationships/relationships_store_spec.rb +19 -0
- data/spec/spec_helper.rb +18 -0
- data/{test → spec}/test_classes.rb +3 -0
- metadata +69 -24
- data/demo.rb +0 -24
- data/demo_age.rb +0 -89
- data/demo_dsl.rb +0 -28
- data/phenomenal-0.11.11.24.3.gem +0 -0
- data/phenomenal.gemspec +0 -15
- data/test/test_cop_adaptation.rb +0 -168
- data/test/test_cop_composition.rb +0 -84
- data/test/test_cop_conflictpolicy.rb +0 -177
- data/test/test_cop_infrastructure.rb +0 -129
- data/test_declaration.rb +0 -18
@@ -0,0 +1,84 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Phenomenal::Manager do
|
4
|
+
before :each do
|
5
|
+
@context = Phenomenal::Context.new(:test)
|
6
|
+
@context2 = Phenomenal::Context.new(:test2)
|
7
|
+
@combined = context :test,:test2
|
8
|
+
@manager = Phenomenal::Manager.instance
|
9
|
+
end
|
10
|
+
|
11
|
+
after :each do
|
12
|
+
force_forget_context(@context)
|
13
|
+
force_forget_context(@context2)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#register_context" do
|
17
|
+
pending "TODO"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#unregister_context" do
|
21
|
+
pending "TODO"
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#register_adaptation" do
|
25
|
+
pending "unregister_adaptation"
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#activate_context" do
|
29
|
+
pending "TODO"
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#deactivate_context" do
|
33
|
+
pending "TODO"
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#proceed" do
|
37
|
+
pending "TODO"
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#change_conflict_policy" do
|
41
|
+
pending "TODO"
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#find_context" do
|
45
|
+
it "should return the simple context with the name passed as parameter" do
|
46
|
+
@manager.find_context(:test).should==@context
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should raise an error if the context wasn't found" do
|
50
|
+
expect {@manager.find_context(:unknown)}.to raise_error Phenomenal::Error
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should return the context immediatly if the argument is a context an is known by the manager" do
|
54
|
+
@manager.find_context(@context).should==@context
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return the combined context matching the list of names passed as parameters" do
|
58
|
+
@manager.find_context(:test,:test2).should==@combined
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#context_defined?" do
|
63
|
+
it "should return the context if the context exist" do
|
64
|
+
@manager.context_defined?(:test).should==@context
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return nil if the context doesn't exist" do
|
68
|
+
context = Phenomenal::Context.new(:context)
|
69
|
+
@manager.context_defined?(:context).should==context
|
70
|
+
context.forget
|
71
|
+
@manager.context_defined?(:context).should be_nil
|
72
|
+
@manager.context_defined?(:unknown).should be_nil
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should work with context references" do
|
76
|
+
@manager.context_defined?(@context).should==@context
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should work with combined contexts" do
|
80
|
+
@manager.context_defined?(:test,:test2).should==@combined
|
81
|
+
@manager.context_defined?(:test,:unknown).should be_nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/spec/proc_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Proc do
|
4
|
+
describe "#phenomenal_bind" do
|
5
|
+
it "should be possible to bind proc as instance methods" do
|
6
|
+
p = Proc.new{"Proc"}
|
7
|
+
p.should respond_to :phenomenal_bind
|
8
|
+
o = BasicObject.new
|
9
|
+
p.phenomenal_bind(o).call.should == "Proc"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#phenomenal_class_bind" do
|
14
|
+
it "should be possible to bind proc as class methods" do
|
15
|
+
p = Proc.new{"Proc"}
|
16
|
+
p.should respond_to :phenomenal_class_bind
|
17
|
+
p.phenomenal_bind(BasicObject).call.should == "Proc"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Phenomenal::Relationship do
|
4
|
+
describe "#==" do
|
5
|
+
it "should be true for two relationships with the same source and target" do
|
6
|
+
a = Phenomenal::Relationship.new(:source,:target,nil)
|
7
|
+
b = Phenomenal::Relationship.new(:source,:target,nil)
|
8
|
+
a.should == b
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be false for relationships concerning different contexts" do
|
12
|
+
a = Phenomenal::Relationship.new(:source,:target,nil)
|
13
|
+
c = Phenomenal::Relationship.new(:source,:other_target,nil)
|
14
|
+
a.should_not == c
|
15
|
+
d = Phenomenal::Relationship.new(:other_source,:other_target,nil)
|
16
|
+
a.should_not == d
|
17
|
+
e = Phenomenal::Relationship.new(:other_source,:target,nil)
|
18
|
+
a.should_not == e
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be false for relationships of different types" do
|
22
|
+
a = Phenomenal::Implication.new(:source,:target,nil)
|
23
|
+
b = Phenomenal::Requirement.new(:source,:target,nil)
|
24
|
+
a.should_not == b
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#refresh" do
|
29
|
+
pending "TODO"
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Phenomenal::RelationshipsManager do
|
4
|
+
describe "#activate_relationships" do
|
5
|
+
pending "TODO"
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#deactivate_relationships" do
|
9
|
+
pending "TODO"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#update_relationships_references" do
|
13
|
+
pending "TODO"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Phenomenal::RelationshipsStore do
|
4
|
+
describe "#add" do
|
5
|
+
pending "TODO"
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#remove" do
|
9
|
+
pending "TODO"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#update_references" do
|
13
|
+
pending "TODO"
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#get_for" do
|
17
|
+
pending "TODO"
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require "phenomenal"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.color_enabled = true
|
6
|
+
config.formatter = 'progress'
|
7
|
+
end
|
8
|
+
|
9
|
+
def force_forget_context(context)
|
10
|
+
while phen_context_active?(context) do
|
11
|
+
phen_deactivate_context(context)
|
12
|
+
end
|
13
|
+
phen_forget_context(context)
|
14
|
+
end
|
15
|
+
|
16
|
+
def define_test_classes
|
17
|
+
load "test_classes.rb"
|
18
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: phenomenal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.99.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Loic Vigneron - Thibault Poncelet
|
@@ -11,10 +11,20 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
|
13
13
|
date: 2011-11-24 00:00:00 Z
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "2.5"
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
description: A context oriented programming framework for Ruby
|
27
|
+
email: team@phenomenal-gem.com
|
18
28
|
executables: []
|
19
29
|
|
20
30
|
extensions: []
|
@@ -22,28 +32,48 @@ extensions: []
|
|
22
32
|
extra_rdoc_files: []
|
23
33
|
|
24
34
|
files:
|
25
|
-
- test/test_cop_conflictpolicy.rb
|
26
|
-
- test/test_cop_infrastructure.rb
|
27
|
-
- test/test_classes.rb
|
28
|
-
- test/test_cop_composition.rb
|
29
|
-
- test/test_cop_adaptation.rb
|
30
|
-
- README
|
31
|
-
- phenomenal.gemspec
|
32
|
-
- phenomenal-0.11.11.24.3.gem
|
33
|
-
- LICENSE
|
34
|
-
- test_declaration.rb
|
35
|
-
- demo_dsl.rb
|
36
|
-
- demo_age.rb
|
37
|
-
- demo.rb
|
38
35
|
- lib/phenomenal/manager.rb
|
36
|
+
- lib/phenomenal/feature.rb
|
39
37
|
- lib/phenomenal/proc.rb
|
40
38
|
- lib/phenomenal/conflict_policies.rb
|
41
39
|
- lib/phenomenal/dsl.rb
|
40
|
+
- lib/phenomenal/version.rb
|
41
|
+
- lib/phenomenal/relationships/implication.rb
|
42
|
+
- lib/phenomenal/relationships/relationships_store.rb
|
43
|
+
- lib/phenomenal/relationships/relationship.rb
|
44
|
+
- lib/phenomenal/relationships/requirement.rb
|
45
|
+
- lib/phenomenal/relationships/dsl.rb
|
46
|
+
- lib/phenomenal/relationships/relationships_manager.rb
|
47
|
+
- lib/phenomenal/relationships/context_relationships.rb
|
48
|
+
- lib/phenomenal/relationships/suggestion.rb
|
49
|
+
- lib/phenomenal/relationships/feature_relationships.rb
|
42
50
|
- lib/phenomenal/context.rb
|
43
51
|
- lib/phenomenal/logger.rb
|
44
52
|
- lib/phenomenal/adaptation.rb
|
45
53
|
- lib/phenomenal.rb
|
54
|
+
- LICENSE
|
46
55
|
- Rakefile
|
56
|
+
- README
|
57
|
+
- spec/spec_helper.rb
|
58
|
+
- spec/feature_spec.rb
|
59
|
+
- spec/context_spec.rb
|
60
|
+
- spec/behavior/composition_spec.rb
|
61
|
+
- spec/behavior/combined_contexts_spec.rb
|
62
|
+
- spec/behavior/adaptation_spec.rb
|
63
|
+
- spec/behavior/open_context.rb
|
64
|
+
- spec/behavior/conflict_policy_spec.rb
|
65
|
+
- spec/behavior/relationships_spec.rb
|
66
|
+
- spec/test_classes.rb
|
67
|
+
- spec/manager_spec.rb
|
68
|
+
- spec/adaptation_spec.rb
|
69
|
+
- spec/relationships/relationships_store_spec.rb
|
70
|
+
- spec/relationships/relationship_spec.rb
|
71
|
+
- spec/relationships/feature_relationships_spec.rb
|
72
|
+
- spec/relationships/dsl_spec.rb
|
73
|
+
- spec/relationships/context_relationships_spec.rb
|
74
|
+
- spec/relationships/relationships_manager_spec.rb
|
75
|
+
- spec/dsl_spec.rb
|
76
|
+
- spec/proc_spec.rb
|
47
77
|
homepage: http://www.phenomenal-gem.com
|
48
78
|
licenses: []
|
49
79
|
|
@@ -70,10 +100,25 @@ rubyforge_project:
|
|
70
100
|
rubygems_version: 1.8.11
|
71
101
|
signing_key:
|
72
102
|
specification_version: 3
|
73
|
-
summary: A context oriented
|
103
|
+
summary: A context oriented programming framework for Ruby
|
74
104
|
test_files:
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
- spec/feature_spec.rb
|
107
|
+
- spec/context_spec.rb
|
108
|
+
- spec/behavior/composition_spec.rb
|
109
|
+
- spec/behavior/combined_contexts_spec.rb
|
110
|
+
- spec/behavior/adaptation_spec.rb
|
111
|
+
- spec/behavior/open_context.rb
|
112
|
+
- spec/behavior/conflict_policy_spec.rb
|
113
|
+
- spec/behavior/relationships_spec.rb
|
114
|
+
- spec/test_classes.rb
|
115
|
+
- spec/manager_spec.rb
|
116
|
+
- spec/adaptation_spec.rb
|
117
|
+
- spec/relationships/relationships_store_spec.rb
|
118
|
+
- spec/relationships/relationship_spec.rb
|
119
|
+
- spec/relationships/feature_relationships_spec.rb
|
120
|
+
- spec/relationships/dsl_spec.rb
|
121
|
+
- spec/relationships/context_relationships_spec.rb
|
122
|
+
- spec/relationships/relationships_manager_spec.rb
|
123
|
+
- spec/dsl_spec.rb
|
124
|
+
- spec/proc_spec.rb
|
data/demo.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative 'lib/phenomenal.rb'
|
2
|
-
class Foo
|
3
|
-
def initialize
|
4
|
-
@inst_var = "bar"
|
5
|
-
end
|
6
|
-
def print
|
7
|
-
"Base: " +@inst_var
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
pnml_define_context(:demo)
|
12
|
-
pnml_add_adaptation(:demo, Foo, :print) do
|
13
|
-
pnml_proceed + " adaptation: "+ @inst_var
|
14
|
-
end
|
15
|
-
|
16
|
-
f = Foo.new
|
17
|
-
puts f.print
|
18
|
-
|
19
|
-
pnml_activate_context(:demo)
|
20
|
-
puts f.print
|
21
|
-
|
22
|
-
pnml_deactivate_context(:demo)
|
23
|
-
puts f.print
|
24
|
-
|
data/demo_age.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
require_relative "./lib/phenomenal.rb"
|
2
|
-
|
3
|
-
pnml_change_conflict_policy { |a,b| age_conflict_policy(a,b) }
|
4
|
-
|
5
|
-
class Plop
|
6
|
-
@@klass_var = "PPPP"
|
7
|
-
@klass_inst_var = "xD"
|
8
|
-
attr_accessor :test
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@test = ">BOR<"
|
12
|
-
end
|
13
|
-
|
14
|
-
def print(arg)
|
15
|
-
"0 -> Test: #{self.test} default Plop.print(arg): ARG: #{arg.to_s}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.plop(arg)
|
19
|
-
"SELF 0 #{arg} KlassVar: #{@@klass_var} INSTKLS #{@klass_inst_var}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
pnml_define_context(:level1)
|
24
|
-
|
25
|
-
pnml_add_adaptation(:level1,Plop,:print) do |arg|
|
26
|
-
pnml_proceed(arg) + "\n" + "1 -> level1 ARG1: #{arg.to_s}"
|
27
|
-
end
|
28
|
-
|
29
|
-
pnml_add_adaptation(:level1,Plop,:plop) do |arg|
|
30
|
-
pnml_proceed(arg) + "\n" + "1 -> SELF level1 ARG1: #{arg.to_s} INSTKLS #{@kls_var}"
|
31
|
-
end
|
32
|
-
|
33
|
-
pnml_define_context(:level2)
|
34
|
-
|
35
|
-
pnml_add_adaptation(:level2,Plop,:print) do |arg|
|
36
|
-
pnml_proceed(arg) + "\n" + "2 -> level2 ARG2: #{arg.to_s}"
|
37
|
-
end
|
38
|
-
|
39
|
-
pnml_add_adaptation(:level2,Plop,:plop) do |arg|
|
40
|
-
pnml_proceed(arg) + "\n" + "2 -> SELF level2 ARG2: #{arg.to_s} INSTKLS #{@kls_inst_var}"
|
41
|
-
end
|
42
|
-
|
43
|
-
pnml_define_context(:level3)
|
44
|
-
|
45
|
-
pnml_add_adaptation(:level3,Plop,:print) do |arg|
|
46
|
-
pnml_proceed(arg) + "\n" + "3 -> level3 ARG3: #{arg.to_s}"
|
47
|
-
end
|
48
|
-
|
49
|
-
pnml_define_context(:level4)
|
50
|
-
|
51
|
-
pnml_add_adaptation(:level4,Plop,:print) do |arg|
|
52
|
-
pnml_proceed(arg) + "\n" + "4 -> TEST4: #{@test} level4 ARG4: #{arg.to_s}"
|
53
|
-
end
|
54
|
-
|
55
|
-
p = Plop.new
|
56
|
-
|
57
|
-
puts "=============> LEVEL 0 <===============\n"+
|
58
|
-
p.print("foo")+
|
59
|
-
"\n======================================="
|
60
|
-
|
61
|
-
pnml_activate_context(:level1)
|
62
|
-
puts "=============> LEVEL 1 <===============\n"+
|
63
|
-
p.print("foo1")+
|
64
|
-
"\n======================================="
|
65
|
-
|
66
|
-
pnml_activate_context(:level2)
|
67
|
-
puts "=============> LEVEL 2 <===============\n"+
|
68
|
-
p.print("foo2")+
|
69
|
-
"\n======================================="
|
70
|
-
|
71
|
-
pnml_activate_context(:level3)
|
72
|
-
puts "=============> LEVEL 3 <===============\n"+
|
73
|
-
p.print("foo3")+
|
74
|
-
"\n======================================="
|
75
|
-
p.test=">BAR<"
|
76
|
-
pnml_activate_context(:level4)
|
77
|
-
puts "=============> LEVEL 4 <===============\n"+
|
78
|
-
p.print("foo4")+
|
79
|
-
"\n======================================="
|
80
|
-
|
81
|
-
pnml_deactivate_context(:level3)
|
82
|
-
puts "=============> LEVEL 4 -3 <===============\n"+
|
83
|
-
p.print("foo4-2")+
|
84
|
-
"\n======================================="
|
85
|
-
|
86
|
-
puts "\n\n========> LEVEL 4 -3 KLASS METH<===========\n"+
|
87
|
-
Plop.plop(">KLASS_METH_ARG<") +
|
88
|
-
"\n======================================="
|
89
|
-
|