activefacts-api 1.8.5 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/activefacts-api.gemspec +1 -2
- data/lib/activefacts/api/constellation.rb +21 -0
- data/lib/activefacts/api/version.rb +1 -1
- data/lib/activefacts/tracer.rb +18 -6
- metadata +1 -3
- data/TODO +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21a02e9269652ab77d07c778444ba5c502c94c98
|
4
|
+
data.tar.gz: 6df79ce9c7f637ba80471e3661fc64145b2d3686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7039e5fe1a242951fc967ee84e098b1eae9bea18bd2cfdf16d9f914ded12977cf1f72f0bbb75f1a31d4a51aeb268e92e1e9ba2b8e61dae77919605206aaa9724
|
7
|
+
data.tar.gz: 22f0cf6fa9189e7908fbd81b4a433e8206bee09abfe25f6dd9dc58d669a49daf88ca4a257eb3a31897a98e5182802d75964d587b55c84c4172edb686b6449b36
|
data/activefacts-api.gemspec
CHANGED
@@ -236,6 +236,27 @@ module ActiveFacts
|
|
236
236
|
end.compact*"\n"
|
237
237
|
end
|
238
238
|
|
239
|
+
# Make a new instance like "instance", but with some new attributes assigned.
|
240
|
+
# All identifiers should overall be different from the forked instance, and
|
241
|
+
# all one-to-ones must be assigned new values (otherwise we change old objects)
|
242
|
+
def fork instance, attrs = {}
|
243
|
+
object_type = instance.class
|
244
|
+
|
245
|
+
role_value_map =
|
246
|
+
object_type.all_role_transitive.inject({}) do |hash, (role_name, role)|
|
247
|
+
next hash if !role.unique
|
248
|
+
next hash if role.fact_type.class == ActiveFacts::API::TypeInheritanceFactType
|
249
|
+
if role.counterpart && role.counterpart.unique && !attrs.include?(role.name) && instance.send(role.getter) != nil
|
250
|
+
raise "#{object_type.basename} cannot be forked unless a replacement value for #{role.name} is provided"
|
251
|
+
end
|
252
|
+
value = attrs[role_name] || instance.send(role.getter)
|
253
|
+
hash[role_name] = value if value != nil
|
254
|
+
hash
|
255
|
+
end
|
256
|
+
|
257
|
+
assert(object_type, role_value_map)
|
258
|
+
end
|
259
|
+
|
239
260
|
def clone
|
240
261
|
remaining_object_types = vocabulary.object_type.clone
|
241
262
|
constellation = self.class.new(vocabulary, @options)
|
data/lib/activefacts/tracer.rb
CHANGED
@@ -50,6 +50,10 @@ module ActiveFacts
|
|
50
50
|
|
51
51
|
class Tracer
|
52
52
|
def initialize
|
53
|
+
reinitialize
|
54
|
+
end
|
55
|
+
|
56
|
+
def reinitialize
|
53
57
|
@indent = 0 # Current nesting level of enabled trace blocks
|
54
58
|
@nested = false # Set when a block enables all enclosed tracing
|
55
59
|
@available = {} # Hash of available trace keys, accumulated during the run
|
@@ -79,6 +83,10 @@ module ActiveFacts
|
|
79
83
|
!key.empty? && @keys[key.to_sym]
|
80
84
|
end
|
81
85
|
|
86
|
+
def enabled
|
87
|
+
@keys.keys
|
88
|
+
end
|
89
|
+
|
82
90
|
def enable key
|
83
91
|
if !key.empty? && !@keys[s = key.to_sym]
|
84
92
|
@keys[s] = true
|
@@ -190,9 +198,13 @@ module ActiveFacts
|
|
190
198
|
end
|
191
199
|
end
|
192
200
|
|
201
|
+
def display key, msg
|
202
|
+
puts msg
|
203
|
+
end
|
204
|
+
|
193
205
|
private
|
194
206
|
def show(*args)
|
195
|
-
enabled_prefix = selected?(args)
|
207
|
+
key, enabled_prefix = *selected?(args)
|
196
208
|
|
197
209
|
# Emit the message if enabled or a parent is:
|
198
210
|
if enabled_prefix && args.size > 0
|
@@ -206,11 +218,11 @@ module ActiveFacts
|
|
206
218
|
if @delayed == true
|
207
219
|
@delayed = message # Arrange to display this message later, if necessary
|
208
220
|
elsif @delayed
|
209
|
-
|
221
|
+
display key, @delayed # Display a delayed message, then the current one
|
210
222
|
@delayed = nil
|
211
|
-
|
223
|
+
display key, message
|
212
224
|
else
|
213
|
-
|
225
|
+
display key, message
|
214
226
|
end
|
215
227
|
end
|
216
228
|
@indent += (enabled_prefix ? 1 : 0)
|
@@ -237,7 +249,6 @@ module ActiveFacts
|
|
237
249
|
end
|
238
250
|
|
239
251
|
@available[key] ||= key # Remember that this trace was requested, for help
|
240
|
-
@nested ||= nested # Activate nesting, if requested
|
241
252
|
if @nested || # This trace is enabled because it's in a nested block
|
242
253
|
@keys[key] || # This trace is enabled in its own right
|
243
254
|
@keys[:all] # This trace is enabled because all are
|
@@ -247,9 +258,10 @@ module ActiveFacts
|
|
247
258
|
else
|
248
259
|
enabled_prefix = ''
|
249
260
|
end
|
261
|
+
@nested ||= nested # Activate nesting, if requested
|
250
262
|
end
|
251
263
|
|
252
|
-
enabled_prefix
|
264
|
+
[key, enabled_prefix]
|
253
265
|
end
|
254
266
|
|
255
267
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activefacts-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clifford Heath
|
@@ -106,7 +106,6 @@ extensions: []
|
|
106
106
|
extra_rdoc_files:
|
107
107
|
- LICENSE.txt
|
108
108
|
- README.rdoc
|
109
|
-
- TODO
|
110
109
|
files:
|
111
110
|
- ".document"
|
112
111
|
- ".gitignore"
|
@@ -116,7 +115,6 @@ files:
|
|
116
115
|
- LICENSE.txt
|
117
116
|
- README.rdoc
|
118
117
|
- Rakefile
|
119
|
-
- TODO
|
120
118
|
- VERSION
|
121
119
|
- activefacts-api.gemspec
|
122
120
|
- lib/activefacts/api.rb
|