phenomenal 1.0.1 → 1.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/{README → README.md} +6 -0
- data/lib/phenomenal.rb +0 -1
- data/lib/phenomenal/adaptation.rb +2 -2
- data/lib/phenomenal/context.rb +6 -0
- data/lib/phenomenal/relationships/dsl.rb +9 -3
- data/lib/phenomenal/relationships/feature_relationships.rb +3 -0
- data/lib/phenomenal/version.rb +1 -1
- metadata +76 -72
- data/lib/phenomenal/proc.rb +0 -34
- data/spec/proc_spec.rb +0 -20
data/{README → README.md}
RENAMED
@@ -1,3 +1,9 @@
|
|
1
|
+
Phenomenal Gem
|
2
|
+
===
|
1
3
|
Phenomenal Gem is a context-oriented framework implemented in Ruby that allows context-oriented programming in Ruby and Ruby on Rails applications.
|
2
4
|
|
3
5
|
See www.phenomenal-gem.com for more details
|
6
|
+
|
7
|
+
Architecture
|
8
|
+
===
|
9
|
+

|
data/lib/phenomenal.rb
CHANGED
@@ -19,7 +19,6 @@ require_relative "./phenomenal/context.rb"
|
|
19
19
|
require_relative "./phenomenal/feature.rb"
|
20
20
|
require_relative "./phenomenal/logger.rb"
|
21
21
|
require_relative "./phenomenal/manager.rb"
|
22
|
-
require_relative "./phenomenal/proc.rb"
|
23
22
|
|
24
23
|
# Viewer
|
25
24
|
require_relative "./phenomenal/viewer/graphical.rb"
|
@@ -39,13 +39,13 @@ class Phenomenal::Adaptation
|
|
39
39
|
def bind(instance,*args,&block)
|
40
40
|
if instance_adaptation?
|
41
41
|
if implementation.class==Proc
|
42
|
-
|
42
|
+
instance.instance_exec(*args,block,&implementation)
|
43
43
|
else
|
44
44
|
implementation.bind(instance).call(*args,&block)
|
45
45
|
end
|
46
46
|
else
|
47
47
|
if implementation.class==Proc
|
48
|
-
|
48
|
+
klass.instance_exec(*args,block,&implementation)
|
49
49
|
else
|
50
50
|
implementation.call(*args,&block)
|
51
51
|
end
|
data/lib/phenomenal/context.rb
CHANGED
@@ -87,6 +87,11 @@ class Phenomenal::Context
|
|
87
87
|
# Add a new method adaptation to the context
|
88
88
|
# Return the adaptation just created
|
89
89
|
def add_adaptation(klass, method_name,instance,umeth=nil, &implementation)
|
90
|
+
if klass.nil? # Not defined class
|
91
|
+
Phenomenal::Logger.instance.error(
|
92
|
+
"The class to be adapted wasn't specified. Don't forget to use 'adaptations_for(Klass)' before adapting a method"
|
93
|
+
)
|
94
|
+
end
|
90
95
|
if umeth
|
91
96
|
implementation = umeth
|
92
97
|
instance = klass.instance_methods.include?(method_name)
|
@@ -142,6 +147,7 @@ class Phenomenal::Context
|
|
142
147
|
# Add multiple adaptations at definition time
|
143
148
|
def add_adaptations(&block)
|
144
149
|
instance_eval(&block) if block
|
150
|
+
@current_adapted_class=nil #Reset adapted class after context closed
|
145
151
|
end
|
146
152
|
|
147
153
|
# Set the current adapted class for the next adapt calls
|
@@ -3,17 +3,23 @@ module Phenomenal::DSL
|
|
3
3
|
def self.define_relationships(klass)
|
4
4
|
klass.class_eval do
|
5
5
|
# Requirements
|
6
|
-
def
|
6
|
+
def phen_requirements_for(source,targets)
|
7
7
|
Phenomenal::Manager.instance.default_context.requirements_for(source,targets)
|
8
8
|
end
|
9
|
+
Phenomenal::DSL.phen_alias(:requirements_for,klass)
|
10
|
+
|
9
11
|
# Implications
|
10
|
-
def
|
12
|
+
def phen_implications_for(source,targets)
|
11
13
|
Phenomenal::Manager.instance.default_context.implications_for(source,targets)
|
12
14
|
end
|
15
|
+
Phenomenal::DSL.phen_alias(:implications_for,klass)
|
16
|
+
|
13
17
|
# Suggestions
|
14
|
-
def
|
18
|
+
def phen_suggestions_for(source,targets)
|
15
19
|
Phenomenal::Manager.instance.default_context.suggestions_for(source,targets)
|
16
20
|
end
|
21
|
+
Phenomenal::DSL.phen_alias(:suggestions_for,klass)
|
22
|
+
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
@@ -10,14 +10,17 @@ module Phenomenal::FeatureRelationships
|
|
10
10
|
def requirements_for(source,targets)
|
11
11
|
add_relationship(source,targets,Phenomenal::Requirement)
|
12
12
|
end
|
13
|
+
alias_method :phen_requirements_for,:requirements_for
|
13
14
|
|
14
15
|
def implications_for(source,targets)
|
15
16
|
add_relationship(source,targets,Phenomenal::Implication)
|
16
17
|
end
|
18
|
+
alias_method :phen_implications_for,:implications_for
|
17
19
|
|
18
20
|
def suggestions_for(source,targets)
|
19
21
|
add_relationship(source,targets,Phenomenal::Suggestion)
|
20
22
|
end
|
23
|
+
alias_method :phen_suggestions_for,:suggestions_for
|
21
24
|
|
22
25
|
private
|
23
26
|
def add_relationship(source,targets,type)
|
data/lib/phenomenal/version.rb
CHANGED
metadata
CHANGED
@@ -1,120 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: phenomenal
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 1.1.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Loic Vigneron - Thibault Poncelet
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2012-04-17 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: rspec
|
16
|
-
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
19
|
none: false
|
18
|
-
requirements:
|
20
|
+
requirements:
|
19
21
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "2.5"
|
22
24
|
type: :development
|
23
|
-
|
24
|
-
version_requirements: *70279300835880
|
25
|
+
version_requirements: *id001
|
25
26
|
description: A context oriented programming framework for Ruby
|
26
27
|
email: team@phenomenal-gem.com
|
27
28
|
executables: []
|
29
|
+
|
28
30
|
extensions: []
|
31
|
+
|
29
32
|
extra_rdoc_files: []
|
30
|
-
|
31
|
-
|
33
|
+
|
34
|
+
files:
|
35
|
+
- lib/phenomenal/manager.rb
|
36
|
+
- lib/phenomenal/feature.rb
|
32
37
|
- lib/phenomenal/conflict_policies.rb
|
33
|
-
- lib/phenomenal/
|
38
|
+
- lib/phenomenal/viewer/graphical.rb
|
39
|
+
- lib/phenomenal/viewer/textual.rb
|
40
|
+
- lib/phenomenal/viewer/dsl.rb
|
34
41
|
- lib/phenomenal/dsl.rb
|
35
|
-
- lib/phenomenal/
|
36
|
-
- lib/phenomenal/logger.rb
|
37
|
-
- lib/phenomenal/manager.rb
|
38
|
-
- lib/phenomenal/proc.rb
|
39
|
-
- lib/phenomenal/relationships/context_relationships.rb
|
40
|
-
- lib/phenomenal/relationships/dsl.rb
|
41
|
-
- lib/phenomenal/relationships/feature_relationships.rb
|
42
|
+
- lib/phenomenal/version.rb
|
42
43
|
- lib/phenomenal/relationships/implication.rb
|
43
|
-
- lib/phenomenal/relationships/relationship.rb
|
44
|
-
- lib/phenomenal/relationships/relationships_manager.rb
|
45
44
|
- lib/phenomenal/relationships/relationships_store.rb
|
45
|
+
- lib/phenomenal/relationships/relationship.rb
|
46
46
|
- lib/phenomenal/relationships/requirement.rb
|
47
|
+
- lib/phenomenal/relationships/dsl.rb
|
48
|
+
- lib/phenomenal/relationships/relationships_manager.rb
|
49
|
+
- lib/phenomenal/relationships/context_relationships.rb
|
47
50
|
- lib/phenomenal/relationships/suggestion.rb
|
48
|
-
- lib/phenomenal/
|
49
|
-
- lib/phenomenal/
|
50
|
-
- lib/phenomenal/
|
51
|
-
- lib/phenomenal/
|
51
|
+
- lib/phenomenal/relationships/feature_relationships.rb
|
52
|
+
- lib/phenomenal/context.rb
|
53
|
+
- lib/phenomenal/logger.rb
|
54
|
+
- lib/phenomenal/adaptation.rb
|
52
55
|
- lib/phenomenal.rb
|
53
56
|
- LICENSE
|
54
57
|
- Rakefile
|
55
|
-
- README
|
56
|
-
- spec/
|
58
|
+
- README.md
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
- spec/feature_spec.rb
|
57
61
|
- spec/context_spec.rb
|
62
|
+
- spec/test_classes.rb
|
63
|
+
- spec/manager_spec.rb
|
64
|
+
- spec/adaptation_spec.rb
|
65
|
+
- spec/relationships/relationships_store_spec.rb
|
66
|
+
- spec/relationships/relationship_spec.rb
|
67
|
+
- spec/relationships/feature_relationships_spec.rb
|
68
|
+
- spec/relationships/dsl_spec.rb
|
69
|
+
- spec/relationships/context_relationships_spec.rb
|
70
|
+
- spec/relationships/relationships_manager_spec.rb
|
58
71
|
- spec/dsl_spec.rb
|
59
|
-
- spec/feature_spec.rb
|
60
|
-
- spec/integration/adaptation_spec.rb
|
61
|
-
- spec/integration/combined_contexts_spec.rb
|
62
72
|
- spec/integration/composition_spec.rb
|
63
|
-
- spec/integration/
|
73
|
+
- spec/integration/combined_contexts_spec.rb
|
74
|
+
- spec/integration/adaptation_spec.rb
|
64
75
|
- spec/integration/open_context.rb
|
76
|
+
- spec/integration/conflict_policy_spec.rb
|
65
77
|
- spec/integration/relationships_spec.rb
|
66
|
-
- spec/manager_spec.rb
|
67
|
-
- spec/proc_spec.rb
|
68
|
-
- spec/relationships/context_relationships_spec.rb
|
69
|
-
- spec/relationships/dsl_spec.rb
|
70
|
-
- spec/relationships/feature_relationships_spec.rb
|
71
|
-
- spec/relationships/relationship_spec.rb
|
72
|
-
- spec/relationships/relationships_manager_spec.rb
|
73
|
-
- spec/relationships/relationships_store_spec.rb
|
74
|
-
- spec/spec_helper.rb
|
75
|
-
- spec/test_classes.rb
|
76
78
|
homepage: http://www.phenomenal-gem.com
|
77
79
|
licenses: []
|
80
|
+
|
78
81
|
post_install_message:
|
79
82
|
rdoc_options: []
|
80
|
-
|
83
|
+
|
84
|
+
require_paths:
|
81
85
|
- lib
|
82
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
87
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
87
91
|
version: 1.9.2
|
88
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
93
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version:
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
94
98
|
requirements: []
|
99
|
+
|
95
100
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.8.
|
101
|
+
rubygems_version: 1.8.17
|
97
102
|
signing_key:
|
98
103
|
specification_version: 3
|
99
104
|
summary: A context oriented programming framework for Ruby
|
100
|
-
test_files:
|
101
|
-
- spec/
|
105
|
+
test_files:
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
- spec/feature_spec.rb
|
102
108
|
- spec/context_spec.rb
|
109
|
+
- spec/test_classes.rb
|
110
|
+
- spec/manager_spec.rb
|
111
|
+
- spec/adaptation_spec.rb
|
112
|
+
- spec/relationships/relationships_store_spec.rb
|
113
|
+
- spec/relationships/relationship_spec.rb
|
114
|
+
- spec/relationships/feature_relationships_spec.rb
|
115
|
+
- spec/relationships/dsl_spec.rb
|
116
|
+
- spec/relationships/context_relationships_spec.rb
|
117
|
+
- spec/relationships/relationships_manager_spec.rb
|
103
118
|
- spec/dsl_spec.rb
|
104
|
-
- spec/feature_spec.rb
|
105
|
-
- spec/integration/adaptation_spec.rb
|
106
|
-
- spec/integration/combined_contexts_spec.rb
|
107
119
|
- spec/integration/composition_spec.rb
|
108
|
-
- spec/integration/
|
120
|
+
- spec/integration/combined_contexts_spec.rb
|
121
|
+
- spec/integration/adaptation_spec.rb
|
109
122
|
- spec/integration/open_context.rb
|
123
|
+
- spec/integration/conflict_policy_spec.rb
|
110
124
|
- spec/integration/relationships_spec.rb
|
111
|
-
- spec/manager_spec.rb
|
112
|
-
- spec/proc_spec.rb
|
113
|
-
- spec/relationships/context_relationships_spec.rb
|
114
|
-
- spec/relationships/dsl_spec.rb
|
115
|
-
- spec/relationships/feature_relationships_spec.rb
|
116
|
-
- spec/relationships/relationship_spec.rb
|
117
|
-
- spec/relationships/relationships_manager_spec.rb
|
118
|
-
- spec/relationships/relationships_store_spec.rb
|
119
|
-
- spec/spec_helper.rb
|
120
|
-
- spec/test_classes.rb
|
data/lib/phenomenal/proc.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# Add methods to Proc classe
|
2
|
-
class Proc
|
3
|
-
# Define a bind method on Proc object,
|
4
|
-
# This allow to execute a Proc as it was an instance method of reciever
|
5
|
-
# Used for composition of instance methods adaptations
|
6
|
-
# Src: http://www.ruby-forum.com/topic/173699
|
7
|
-
def phenomenal_bind(receiver)
|
8
|
-
block, time = self, Time.now
|
9
|
-
(class << receiver; self end).class_eval do
|
10
|
-
method_name = "__bind_#{time.to_i}_#{time.usec}-#{rand(100000)}"
|
11
|
-
define_method(method_name, &block)
|
12
|
-
method = instance_method(method_name)
|
13
|
-
remove_method(method_name)
|
14
|
-
method
|
15
|
-
end.bind(receiver)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Define a bind_class method on Proc object,
|
19
|
-
# This allow to execute a Proc as it was an class method of klass
|
20
|
-
# Used for composition of class methods adaptations
|
21
|
-
def phenomenal_class_bind(klass)
|
22
|
-
block, time = self, Time.now
|
23
|
-
method_name = "__bind_#{time.to_i}_#{time.usec}-#{rand(100000)}"
|
24
|
-
method = nil
|
25
|
-
klass.instance_eval do
|
26
|
-
define_singleton_method(method_name, &block)
|
27
|
-
method = method(method_name)
|
28
|
-
(class << self; self end).instance_eval do
|
29
|
-
remove_method(method_name)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
method
|
33
|
-
end
|
34
|
-
end
|
data/spec/proc_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
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
|