phenomenal 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,19 +1,171 @@
1
1
  Copyright (C) 2011 Thibault Poncelet <thibault.poncelet@student.uclouvain.be>
2
2
  Copyright (C) 2011 Loic Vigneron <loic.vigneron@student.uclouvain.be>
3
3
 
4
- This program is free software; you can redistribute it and/or modify
5
- it under the terms of the GNU General Public License as published by
6
- the Free Software Foundation; either version 2 of the License, or
7
- (at your option) any later version.
8
-
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
- GNU General Public License for more details.
13
-
14
- You should have received a copy of the GNU General Public License
15
- along with this program; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4
+ GNU LESSER GENERAL PUBLIC LICENSE
5
+ Version 3, 29 June 2007
6
+
7
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
8
+ Everyone is permitted to copy and distribute verbatim copies
9
+ of this license document, but changing it is not allowed.
10
+
11
+
12
+ This version of the GNU Lesser General Public License incorporates
13
+ the terms and conditions of version 3 of the GNU General Public
14
+ License, supplemented by the additional permissions listed below.
15
+
16
+ 0. Additional Definitions.
17
+
18
+ As used herein, "this License" refers to version 3 of the GNU Lesser
19
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
20
+ General Public License.
21
+
22
+ "The Library" refers to a covered work governed by this License,
23
+ other than an Application or a Combined Work as defined below.
24
+
25
+ An "Application" is any work that makes use of an interface provided
26
+ by the Library, but which is not otherwise based on the Library.
27
+ Defining a subclass of a class defined by the Library is deemed a mode
28
+ of using an interface provided by the Library.
29
+
30
+ A "Combined Work" is a work produced by combining or linking an
31
+ Application with the Library. The particular version of the Library
32
+ with which the Combined Work was made is also called the "Linked
33
+ Version".
34
+
35
+ The "Minimal Corresponding Source" for a Combined Work means the
36
+ Corresponding Source for the Combined Work, excluding any source code
37
+ for portions of the Combined Work that, considered in isolation, are
38
+ based on the Application, and not on the Linked Version.
39
+
40
+ The "Corresponding Application Code" for a Combined Work means the
41
+ object code and/or source code for the Application, including any data
42
+ and utility programs needed for reproducing the Combined Work from the
43
+ Application, but excluding the System Libraries of the Combined Work.
44
+
45
+ 1. Exception to Section 3 of the GNU GPL.
46
+
47
+ You may convey a covered work under sections 3 and 4 of this License
48
+ without being bound by section 3 of the GNU GPL.
49
+
50
+ 2. Conveying Modified Versions.
51
+
52
+ If you modify a copy of the Library, and, in your modifications, a
53
+ facility refers to a function or data to be supplied by an Application
54
+ that uses the facility (other than as an argument passed when the
55
+ facility is invoked), then you may convey a copy of the modified
56
+ version:
57
+
58
+ a) under this License, provided that you make a good faith effort to
59
+ ensure that, in the event an Application does not supply the
60
+ function or data, the facility still operates, and performs
61
+ whatever part of its purpose remains meaningful, or
62
+
63
+ b) under the GNU GPL, with none of the additional permissions of
64
+ this License applicable to that copy.
65
+
66
+ 3. Object Code Incorporating Material from Library Header Files.
67
+
68
+ The object code form of an Application may incorporate material from
69
+ a header file that is part of the Library. You may convey such object
70
+ code under terms of your choice, provided that, if the incorporated
71
+ material is not limited to numerical parameters, data structure
72
+ layouts and accessors, or small macros, inline functions and templates
73
+ (ten or fewer lines in length), you do both of the following:
74
+
75
+ a) Give prominent notice with each copy of the object code that the
76
+ Library is used in it and that the Library and its use are
77
+ covered by this License.
78
+
79
+ b) Accompany the object code with a copy of the GNU GPL and this license
80
+ document.
81
+
82
+ 4. Combined Works.
83
+
84
+ You may convey a Combined Work under terms of your choice that,
85
+ taken together, effectively do not restrict modification of the
86
+ portions of the Library contained in the Combined Work and reverse
87
+ engineering for debugging such modifications, if you also do each of
88
+ the following:
89
+
90
+ a) Give prominent notice with each copy of the Combined Work that
91
+ the Library is used in it and that the Library and its use are
92
+ covered by this License.
93
+
94
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
95
+ document.
96
+
97
+ c) For a Combined Work that displays copyright notices during
98
+ execution, include the copyright notice for the Library among
99
+ these notices, as well as a reference directing the user to the
100
+ copies of the GNU GPL and this license document.
101
+
102
+ d) Do one of the following:
103
+
104
+ 0) Convey the Minimal Corresponding Source under the terms of this
105
+ License, and the Corresponding Application Code in a form
106
+ suitable for, and under terms that permit, the user to
107
+ recombine or relink the Application with a modified version of
108
+ the Linked Version to produce a modified Combined Work, in the
109
+ manner specified by section 6 of the GNU GPL for conveying
110
+ Corresponding Source.
111
+
112
+ 1) Use a suitable shared library mechanism for linking with the
113
+ Library. A suitable mechanism is one that (a) uses at run time
114
+ a copy of the Library already present on the user's computer
115
+ system, and (b) will operate properly with a modified version
116
+ of the Library that is interface-compatible with the Linked
117
+ Version.
118
+
119
+ e) Provide Installation Information, but only if you would otherwise
120
+ be required to provide such information under section 6 of the
121
+ GNU GPL, and only to the extent that such information is
122
+ necessary to install and execute a modified version of the
123
+ Combined Work produced by recombining or relinking the
124
+ Application with a modified version of the Linked Version. (If
125
+ you use option 4d0, the Installation Information must accompany
126
+ the Minimal Corresponding Source and Corresponding Application
127
+ Code. If you use option 4d1, you must provide the Installation
128
+ Information in the manner specified by section 6 of the GNU GPL
129
+ for conveying Corresponding Source.)
130
+
131
+ 5. Combined Libraries.
132
+
133
+ You may place library facilities that are a work based on the
134
+ Library side by side in a single library together with other library
135
+ facilities that are not Applications and are not covered by this
136
+ License, and convey such a combined library under terms of your
137
+ choice, if you do both of the following:
138
+
139
+ a) Accompany the combined library with a copy of the same work based
140
+ on the Library, uncombined with any other library facilities,
141
+ conveyed under the terms of this License.
142
+
143
+ b) Give prominent notice with the combined library that part of it
144
+ is a work based on the Library, and explaining where to find the
145
+ accompanying uncombined form of the same work.
146
+
147
+ 6. Revised Versions of the GNU Lesser General Public License.
148
+
149
+ The Free Software Foundation may publish revised and/or new versions
150
+ of the GNU Lesser General Public License from time to time. Such new
151
+ versions will be similar in spirit to the present version, but may
152
+ differ in detail to address new problems or concerns.
153
+
154
+ Each version is given a distinguishing version number. If the
155
+ Library as you received it specifies that a certain numbered version
156
+ of the GNU Lesser General Public License "or any later version"
157
+ applies to it, you have the option of following the terms and
158
+ conditions either of that published version or of any later version
159
+ published by the Free Software Foundation. If the Library as you
160
+ received it does not specify a version number of the GNU Lesser
161
+ General Public License, you may choose any version of the GNU Lesser
162
+ General Public License ever published by the Free Software Foundation.
163
+
164
+ If the Library as you received it specifies that a proxy can decide
165
+ whether future versions of the GNU Lesser General Public License shall
166
+ apply, that proxy's public statement of acceptance of any version is
167
+ permanent authorization for you to choose that version for the
168
+ Library.
17
169
 
18
170
  ========================
19
171
 
@@ -2,20 +2,20 @@
2
2
  module Phenomenal::ConflictPolicies
3
3
 
4
4
  # Prefer not default adaptation, error if two not default ones
5
- def no_resolution_conflict_policy(adaptation1,adaptation2)
6
- if adaptation1.context==default_context()
5
+ def no_resolution_conflict_policy(context1,context2)
6
+ if context1==default_context()
7
7
  1
8
- elsif adaptation2.context.name==default_context()
8
+ elsif context2==default_context()
9
9
  -1
10
10
  else #Fail if two non default adaptations
11
11
  Phenomenal::Logger.instance.error(
12
- "Illegal duplicate adapation of #{adaptation1.to_s}"
12
+ "Illegal duplicate adapation between contexts #{context1} and #{context2} "
13
13
  )
14
14
  end
15
15
  end
16
16
 
17
17
  # Age based conflict resolution
18
- def age_conflict_policy(adaptation1, adaptation2)
19
- adaptation1.context.age <=> adaptation2.context.age
18
+ def age_conflict_policy(context1, context2)
19
+ context1.age <=> context2.age
20
20
  end
21
21
  end
@@ -4,7 +4,7 @@ class Phenomenal::Context
4
4
  @@total_activations = 0
5
5
 
6
6
  attr_accessor :activation_age, :activation_frequency, :adaptations,
7
- :activation_count, :parent,:forgotten
7
+ :activation_count, :parent, :forgotten
8
8
  attr_reader :manager,:name
9
9
 
10
10
  def self.create(context,*contexts,nested,closest_feature,&block)
@@ -106,7 +106,7 @@ class Phenomenal::Manager
106
106
 
107
107
  # Call the old implementation of the method 'caller.caller_method'
108
108
  def proceed(calling_stack,instance,*args,&block)
109
- calling_adaptation = find_adapatation(calling_stack)
109
+ calling_adaptation = find_adaptation(calling_stack)
110
110
  # IMPROVE Problems will appears if proceed called in a file where
111
111
  # adaptations are defined but not in one of them=> how to check?
112
112
  # IMPROVE Problems will also appears if two adaptations are defined on the same
@@ -150,6 +150,12 @@ class Phenomenal::Manager
150
150
  end
151
151
  return c
152
152
  end
153
+
154
+
155
+ # Resolution policy
156
+ def conflict_policy(context1, context2)
157
+ age_conflict_policy(context1, context2)
158
+ end
153
159
 
154
160
  private
155
161
  def find_simple_context(context)
@@ -253,7 +259,7 @@ class Phenomenal::Manager
253
259
  # Return the adaptation that math the calling_stack, on the basis of the
254
260
  # file and the line number --> proceed is always called under an
255
261
  # adaptation definition
256
- def find_adapatation(calling_stack)
262
+ def find_adaptation(calling_stack)
257
263
  source = calling_stack[0]
258
264
  source_info = source.scan(/(.+\.rb):(\d+)/)[0]
259
265
  call_file = source_info[0]
@@ -288,12 +294,7 @@ class Phenomenal::Manager
288
294
  def sorted_adaptations_for(klass,method_name,instance)
289
295
  relevant_adaptations =
290
296
  active_adaptations.find_all { |i| i.concern?(klass, method_name,instance) }
291
- relevant_adaptations.sort!{|a,b| conflict_policy(a,b)}
292
- end
293
-
294
- # Resolution policy
295
- def conflict_policy(adaptation1, adaptation2)
296
- age_conflict_policy(adaptation1, adaptation2)
297
+ relevant_adaptations.sort!{|a,b| conflict_policy(a.context,b.context)}
297
298
  end
298
299
 
299
300
  # Set the default context
@@ -1,3 +1,3 @@
1
1
  module Phenomenal
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -49,6 +49,8 @@ describe "Simple adaptations" do
49
49
  force_forget_context(context(:test))
50
50
  force_forget_context(context(:test_2))
51
51
  force_forget_context(context(:test_3))
52
+
53
+ phen_change_conflict_policy { |a,b| age_conflict_policy(a,b) }
52
54
  end
53
55
 
54
56
  it "should override default behavior" do
metadata CHANGED
@@ -1,127 +1,120 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: phenomenal
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
4
5
  prerelease:
5
- version: 1.0.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
- date: 2011-11-24 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70279300835880 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
18
+ requirements:
21
19
  - - ~>
22
- - !ruby/object:Gem::Version
23
- version: "2.5"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.5'
24
22
  type: :development
25
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: *70279300835880
26
25
  description: A context oriented programming framework for Ruby
27
26
  email: team@phenomenal-gem.com
28
27
  executables: []
29
-
30
28
  extensions: []
31
-
32
29
  extra_rdoc_files: []
33
-
34
- files:
35
- - lib/phenomenal/manager.rb
36
- - lib/phenomenal/feature.rb
37
- - lib/phenomenal/proc.rb
30
+ files:
31
+ - lib/phenomenal/adaptation.rb
38
32
  - lib/phenomenal/conflict_policies.rb
39
- - lib/phenomenal/viewer/graphical.rb
40
- - lib/phenomenal/viewer/textual.rb
41
- - lib/phenomenal/viewer/dsl.rb
33
+ - lib/phenomenal/context.rb
42
34
  - lib/phenomenal/dsl.rb
43
- - lib/phenomenal/version.rb
35
+ - lib/phenomenal/feature.rb
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
44
42
  - lib/phenomenal/relationships/implication.rb
45
- - lib/phenomenal/relationships/relationships_store.rb
46
43
  - lib/phenomenal/relationships/relationship.rb
47
- - lib/phenomenal/relationships/requirement.rb
48
- - lib/phenomenal/relationships/dsl.rb
49
44
  - lib/phenomenal/relationships/relationships_manager.rb
50
- - lib/phenomenal/relationships/context_relationships.rb
45
+ - lib/phenomenal/relationships/relationships_store.rb
46
+ - lib/phenomenal/relationships/requirement.rb
51
47
  - lib/phenomenal/relationships/suggestion.rb
52
- - lib/phenomenal/relationships/feature_relationships.rb
53
- - lib/phenomenal/context.rb
54
- - lib/phenomenal/logger.rb
55
- - lib/phenomenal/adaptation.rb
48
+ - lib/phenomenal/version.rb
49
+ - lib/phenomenal/viewer/dsl.rb
50
+ - lib/phenomenal/viewer/graphical.rb
51
+ - lib/phenomenal/viewer/textual.rb
56
52
  - lib/phenomenal.rb
57
53
  - LICENSE
58
54
  - Rakefile
59
55
  - README
60
- - spec/spec_helper.rb
61
- - spec/feature_spec.rb
62
- - spec/context_spec.rb
63
- - spec/test_classes.rb
64
- - spec/manager_spec.rb
65
56
  - spec/adaptation_spec.rb
66
- - spec/relationships/relationships_store_spec.rb
67
- - spec/relationships/relationship_spec.rb
68
- - spec/relationships/feature_relationships_spec.rb
69
- - spec/relationships/dsl_spec.rb
70
- - spec/relationships/context_relationships_spec.rb
71
- - spec/relationships/relationships_manager_spec.rb
57
+ - spec/context_spec.rb
72
58
  - spec/dsl_spec.rb
73
- - spec/proc_spec.rb
74
- - spec/integration/composition_spec.rb
75
- - spec/integration/combined_contexts_spec.rb
59
+ - spec/feature_spec.rb
76
60
  - spec/integration/adaptation_spec.rb
77
- - spec/integration/open_context.rb
61
+ - spec/integration/combined_contexts_spec.rb
62
+ - spec/integration/composition_spec.rb
78
63
  - spec/integration/conflict_policy_spec.rb
64
+ - spec/integration/open_context.rb
79
65
  - 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
80
76
  homepage: http://www.phenomenal-gem.com
81
77
  licenses: []
82
-
83
78
  post_install_message:
84
79
  rdoc_options: []
85
-
86
- require_paths:
80
+ require_paths:
87
81
  - lib
88
- required_ruby_version: !ruby/object:Gem::Requirement
82
+ required_ruby_version: !ruby/object:Gem::Requirement
89
83
  none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
93
87
  version: 1.9.2
94
- required_rubygems_version: !ruby/object:Gem::Requirement
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
89
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
100
94
  requirements: []
101
-
102
95
  rubyforge_project:
103
- rubygems_version: 1.8.11
96
+ rubygems_version: 1.8.15
104
97
  signing_key:
105
98
  specification_version: 3
106
99
  summary: A context oriented programming framework for Ruby
107
- test_files:
108
- - spec/spec_helper.rb
109
- - spec/feature_spec.rb
110
- - spec/context_spec.rb
111
- - spec/test_classes.rb
112
- - spec/manager_spec.rb
100
+ test_files:
113
101
  - spec/adaptation_spec.rb
114
- - spec/relationships/relationships_store_spec.rb
115
- - spec/relationships/relationship_spec.rb
116
- - spec/relationships/feature_relationships_spec.rb
117
- - spec/relationships/dsl_spec.rb
118
- - spec/relationships/context_relationships_spec.rb
119
- - spec/relationships/relationships_manager_spec.rb
102
+ - spec/context_spec.rb
120
103
  - spec/dsl_spec.rb
121
- - spec/proc_spec.rb
122
- - spec/integration/composition_spec.rb
123
- - spec/integration/combined_contexts_spec.rb
104
+ - spec/feature_spec.rb
124
105
  - spec/integration/adaptation_spec.rb
125
- - spec/integration/open_context.rb
106
+ - spec/integration/combined_contexts_spec.rb
107
+ - spec/integration/composition_spec.rb
126
108
  - spec/integration/conflict_policy_spec.rb
109
+ - spec/integration/open_context.rb
127
110
  - 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