activefacts-api 1.4.0 → 1.5.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.
- checksums.yaml +5 -13
- data/VERSION +1 -1
- data/activefacts-api.gemspec +3 -3
- data/lib/activefacts/api/object_type.rb +64 -51
- data/lib/activefacts/api/role.rb +13 -4
- data/spec/constellation/constellation_spec.rb +1 -1
- data/spec/constellation/instance_spec.rb +5 -5
- data/spec/fact_type/role_values_spec.rb +1 -1
- data/spec/fact_type/roles_spec.rb +6 -6
- data/spec/object_type/entity_type/entity_type_spec.rb +8 -8
- data/spec/object_type/value_type/autocounter_spec.rb +3 -3
- data/spec/object_type/value_type/guid_spec.rb +3 -3
- data/spec/object_type/value_type/numeric_spec.rb +6 -6
- data/spec/object_type/value_type/value_type_spec.rb +7 -7
- metadata +26 -34
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Nzg3NGZmNGZhMzhmYzYwM2E2ZWVlNDc4ZTE0Njc2ODI4N2UxMzI4NA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 316e9f376011c7c35dbb2193672ddf50c1f342a3
|
4
|
+
data.tar.gz: 7c2ffcd17765293e1e6068bc16b6421b567352c4
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NThlYzNlYmEyZmNiNjAwMzhlMTU3MTJlZDJmOGMyODBmZDJlNDA2ZTg5MzFm
|
11
|
-
NzIwMDhhZjVmYzQzN2UwN2I1ZWI0MjdmNWNlZjIzMTRlOGU1MWQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZTAxOGM3YTY2YjFiZTMyMzIxNzU3N2VmMGI0NTQ5MjBlMTFjMWRjYTFjNDli
|
14
|
-
ZWNlYjNhM2RiNTY1NTQ2MTM1MjJiYzllNDllYzliM2VjZTJjN2M3ZTRjNGUy
|
15
|
-
ZDZlYzM0Y2ExMDI3MDYyZWUxZGIwNzMxMGY0MTAxZjQ5MDRmNjY=
|
6
|
+
metadata.gz: a1231d0cc4b62f96cbce91002ec62fa8ac3f92cb76c31966527213b897deeb3d1c3bf2721b5bad087baa1a007b0b6fe23ae96bcf903ba5c862a2035ec3385bdb
|
7
|
+
data.tar.gz: 62029a7903f490202b09aef180abcdc291923385efb05708ea25b8b3351ea3689eaf5025b9b07ce191a0caa3f6f013f50e6a3f5238578f38deae5b2e26bb76cd
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.0
|
data/activefacts-api.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: activefacts-api 1.
|
5
|
+
# stub: activefacts-api 1.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "activefacts-api"
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.5.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Clifford Heath"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-12-09"
|
15
15
|
s.description = "\nThe ActiveFacts API is a Ruby DSL for managing constellations of elementary facts.\nEach fact is either existential (a value or an entity), characteristic (boolean) or\nbinary relational (A rel B). Relational facts are consistently co-referenced, so you\ncan traverse them efficiently in any direction. Each constellation maintains constraints\nover the fact population.\n"
|
16
16
|
s.email = "clifford.heath@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -83,9 +83,9 @@ module ActiveFacts
|
|
83
83
|
# * :reading - for verbalisation. Not used yet.
|
84
84
|
# * :restrict - a list of values or ranges which this role may take. Not used yet.
|
85
85
|
def has_one(role_name, options = {})
|
86
|
-
role_name, related, mandatory, related_role_name = extract_binary_params(
|
86
|
+
role_name, related, mandatory, related_role_name, restrict = extract_binary_params(role_name, false, options)
|
87
87
|
check_identifying_role_has_valid_cardinality(:has_one, role_name)
|
88
|
-
define_binary_fact_type(false, role_name, related, mandatory, related_role_name)
|
88
|
+
define_binary_fact_type(false, role_name, related, mandatory, related_role_name, restrict)
|
89
89
|
end
|
90
90
|
|
91
91
|
# Define a binary fact type joining this object_type to another,
|
@@ -99,10 +99,10 @@ module ActiveFacts
|
|
99
99
|
# * :reading - for verbalisation. Not used yet.
|
100
100
|
# * :restrict - a list of values or ranges which this role may take. Not used yet.
|
101
101
|
def one_to_one(role_name, options = {})
|
102
|
-
role_name, related, mandatory, related_role_name =
|
103
|
-
extract_binary_params(
|
102
|
+
role_name, related, mandatory, related_role_name, restrict =
|
103
|
+
extract_binary_params(role_name, true, options)
|
104
104
|
check_identifying_role_has_valid_cardinality(:one_to_one, role_name)
|
105
|
-
define_binary_fact_type(true, role_name, related, mandatory, related_role_name)
|
105
|
+
define_binary_fact_type(true, role_name, related, mandatory, related_role_name, restrict)
|
106
106
|
end
|
107
107
|
|
108
108
|
def check_identifying_role_has_valid_cardinality(type, role)
|
@@ -217,12 +217,25 @@ module ActiveFacts
|
|
217
217
|
end
|
218
218
|
|
219
219
|
# Shared code for both kinds of binary fact type (has_one and one_to_one)
|
220
|
-
def define_binary_fact_type(one_to_one, role_name, related, mandatory, related_role_name)
|
221
|
-
if all_role_transitive[role_name]
|
220
|
+
def define_binary_fact_type(one_to_one, role_name, related, mandatory, related_role_name, restrict)
|
221
|
+
if r = all_role_transitive[role_name]
|
222
|
+
# Allow a one-to-one to be defined identically from both ends:
|
223
|
+
if one_to_one and
|
224
|
+
r.unique and
|
225
|
+
!r.unary? and
|
226
|
+
r.object_type == self and # Cannot be an inherited role
|
227
|
+
r.counterpart.unique and
|
228
|
+
related == r.counterpart.object_type
|
229
|
+
# and related_role_name == r.counterpart.name
|
230
|
+
# REVISIT: Cannot add a value constraint here yet
|
231
|
+
r.make_mandatory if mandatory && !r.mandatory # This was impossible
|
232
|
+
return
|
233
|
+
end
|
234
|
+
|
222
235
|
raise DuplicateRoleException.new("#{name} cannot have more than one role named #{role_name}")
|
223
236
|
end
|
224
237
|
fact_type = FactType.new
|
225
|
-
role = Role.new(fact_type, self, role_name, mandatory, true)
|
238
|
+
role = Role.new(fact_type, self, role_name, mandatory, true, restrict)
|
226
239
|
|
227
240
|
# There may be a forward reference here where role_name is a Symbol,
|
228
241
|
# and the block runs later when that Symbol is bound to the object_type.
|
@@ -421,13 +434,10 @@ module ActiveFacts
|
|
421
434
|
# :counterpart => Symbol/String. The name of the counterpart role. Will be to_s.snakecase'd and maybe augmented with "all_" and/or "_as_<role_name>"
|
422
435
|
# LATER:
|
423
436
|
# :order => :local_role OR lambda{} (for sort_by)
|
424
|
-
# :restrict => Range or Array of Range/value or respond_to?(include?)
|
437
|
+
# :restrict => Range or Array of Range/value/Regexp or respond_to?(include?)
|
425
438
|
#
|
426
439
|
# This function returns an array:
|
427
|
-
# [ role_name,
|
428
|
-
# related,
|
429
|
-
# mandatory,
|
430
|
-
# related_role_name ]
|
440
|
+
# [ role_name, related, mandatory, related_role_name, restrict ]
|
431
441
|
#
|
432
442
|
# Role naming rule:
|
433
443
|
# "all_" if there may be more than one (only ever on related end)
|
@@ -439,55 +449,57 @@ module ActiveFacts
|
|
439
449
|
# Role counterpart object_type name (not role name)
|
440
450
|
# Trailing Adjective
|
441
451
|
# "_as_<other_role_name>" if other_role_name != this role's counterpart' object_type name, and not other_player_this_player
|
442
|
-
def extract_binary_params(
|
443
|
-
|
444
|
-
|
445
|
-
#
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
related = role_name # No :class provided, assume it matches the role_name
|
458
|
-
related_name ||= role_name.to_s
|
459
|
-
when Class
|
460
|
-
related = related_name
|
461
|
-
related_name = related_name.basename.to_s.snakecase
|
462
|
-
when Symbol, String
|
463
|
-
related = related_name
|
464
|
-
related_name = related_name.to_s.snakecase
|
452
|
+
def extract_binary_params(role_name, one_to_one, options)
|
453
|
+
role_name = role_name.to_sym
|
454
|
+
|
455
|
+
# The counterpart class (type) might be forward-referenced, so handle a Symbol/String instead of a Class.
|
456
|
+
specified_class = options.delete(:class)
|
457
|
+
case specified_class
|
458
|
+
when Class # Preferred and most common case
|
459
|
+
counterpart_type_or_name = specified_class
|
460
|
+
counterpart_type_default_role_name = specified_class.basename.to_s.snakecase
|
461
|
+
when Symbol, String # Use this to handle forward references
|
462
|
+
counterpart_type_or_name = specified_class.to_s.camelcase
|
463
|
+
counterpart_type_default_role_name = specified_class.to_s.snakecase
|
464
|
+
when nil # No :class provided, assume it matches the role_name
|
465
|
+
counterpart_type_or_name = role_name.to_s.camelcase
|
466
|
+
counterpart_type_default_role_name = role_name.to_s
|
465
467
|
else
|
466
|
-
raise ArgumentError.new("Invalid type #{
|
468
|
+
raise ArgumentError.new("Invalid type #{counterpart_type_default_role_name.class} for :class option on :#{role_name}, must be a Class, Symbol or String")
|
467
469
|
end
|
468
470
|
|
469
|
-
# resolve the Symbol to a Class now if possible:
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
471
|
+
# resolve the Symbol or String to a Class now if possible:
|
472
|
+
unless counterpart_type_or_name.is_a?(Class)
|
473
|
+
resolved = vocabulary.object_type(counterpart_type_or_name)
|
474
|
+
counterpart_type_or_name = resolved if resolved
|
475
|
+
end
|
476
|
+
|
477
|
+
# If the role is played by a known Class, check it's in the same vocabulary:
|
478
|
+
if counterpart_type_or_name.is_a?(Class)
|
479
|
+
unless counterpart_type_or_name.respond_to?(:vocabulary) and counterpart_type_or_name.vocabulary == self.vocabulary
|
480
|
+
raise CrossVocabularyRoleException.new(counterpart_type_or_name, vocabulary)
|
475
481
|
end
|
476
482
|
end
|
477
483
|
|
484
|
+
mandatory = false
|
478
485
|
if options.delete(:mandatory) == true
|
479
486
|
mandatory = true
|
480
487
|
end
|
481
488
|
|
482
|
-
|
489
|
+
restrict = options.delete(:restrict) # REVISIT: Stored but not used yet
|
490
|
+
|
491
|
+
default_role_name = self.basename.snakecase # Default name of counterpart role (played by self)
|
492
|
+
counterpart_role_name = options.delete(:counterpart)
|
493
|
+
counterpart_role_name = counterpart_role_name.to_s if counterpart_role_name
|
494
|
+
counterpart_role_name ||= default_role_name
|
483
495
|
|
484
496
|
raise UnrecognisedOptionsException.new("role", role_name, options.keys) unless options.empty?
|
485
497
|
|
486
498
|
# If you have a role "supervisor" and a sub-class "Supervisor", this'll bitch.
|
487
499
|
if !specified_class and # No specified :class was provided
|
488
|
-
|
500
|
+
counterpart_type_or_name.is_a?(Class) and
|
489
501
|
(indicated = vocabulary.object_type(role_name)) and
|
490
|
-
indicated !=
|
502
|
+
indicated != counterpart_type_or_name
|
491
503
|
raise "Role name #{role_name} indicates a different counterpart object_type #{indicated} than specified"
|
492
504
|
end
|
493
505
|
|
@@ -497,16 +509,17 @@ module ActiveFacts
|
|
497
509
|
# Note that oo.rb names things from the opposite end, so you wind up in a maze of mirrors.
|
498
510
|
other_role_method =
|
499
511
|
(one_to_one ? "" : "all_") +
|
500
|
-
|
501
|
-
if
|
502
|
-
|
512
|
+
counterpart_role_name
|
513
|
+
if counterpart_role_name == default_role_name and
|
514
|
+
role_name.to_s != counterpart_type_default_role_name
|
503
515
|
other_role_method += "_as_#{role_name}"
|
504
516
|
end
|
505
517
|
|
506
518
|
[ role_name,
|
507
|
-
|
519
|
+
counterpart_type_or_name,
|
508
520
|
mandatory,
|
509
|
-
other_role_method.to_sym
|
521
|
+
other_role_method.to_sym,
|
522
|
+
restrict
|
510
523
|
]
|
511
524
|
end
|
512
525
|
|
data/lib/activefacts/api/role.rb
CHANGED
@@ -20,16 +20,20 @@ module ActiveFacts
|
|
20
20
|
attr_reader :unique # Is this role played by at most one instance, or more?
|
21
21
|
attr_reader :mandatory # In a valid fact population, is this role required to be played?
|
22
22
|
attr_reader :value_constraint # Counterpart Instances playing this role must meet this constraint
|
23
|
-
attr_reader :is_identifying # Is this an identifying role for object_type?
|
24
23
|
|
25
|
-
def
|
24
|
+
def is_identifying # Is this an identifying role for object_type?
|
25
|
+
return @is_identifying unless @is_identifying == nil
|
26
|
+
@is_identifying = !!(@object_type.is_entity_type && @object_type.identifying_role_names.include?(@name))
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(fact_type, object_type, role_name, mandatory, unique, restrict = nil)
|
26
30
|
@fact_type = fact_type
|
27
31
|
@fact_type.all_role << self
|
28
32
|
@object_type = object_type
|
29
33
|
@name = role_name
|
30
34
|
@mandatory = mandatory
|
31
35
|
@unique = unique
|
32
|
-
|
36
|
+
@value_constraint = restrict
|
33
37
|
object_type.add_role(self)
|
34
38
|
associate_role(@object_type)
|
35
39
|
end
|
@@ -40,6 +44,11 @@ module ActiveFacts
|
|
40
44
|
@fact_type.all_role.size == 1
|
41
45
|
end
|
42
46
|
|
47
|
+
def make_mandatory
|
48
|
+
# Sometimes a role has already been defined from the other end
|
49
|
+
@mandatory = true
|
50
|
+
end
|
51
|
+
|
43
52
|
def counterpart
|
44
53
|
@counterpart ||= (@fact_type.all_role - [self])[0]
|
45
54
|
end
|
@@ -70,7 +79,7 @@ module ActiveFacts
|
|
70
79
|
|
71
80
|
private
|
72
81
|
# Create a class method to access the Role object.
|
73
|
-
# This seems to add *significantly* to the runtime of the tests,
|
82
|
+
# This seems to add *significantly* to the runtime of the tests (method cache flushing?),
|
74
83
|
# but it's load-time, not execution-time, so it's staying!
|
75
84
|
def associate_role(klass)
|
76
85
|
role = self
|
@@ -295,7 +295,7 @@ describe "A Constellation instance" do
|
|
295
295
|
|
296
296
|
it "should support detect" do
|
297
297
|
baz = @constellation.Name("baz")
|
298
|
-
@constellation.Name.detect { |rv| true }.should
|
298
|
+
@constellation.Name.detect { |rv| true }.should be_truthy
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
@@ -279,7 +279,7 @@ describe "An instance of every type of ObjectType" do
|
|
279
279
|
it "if a value type, should verbalise" do
|
280
280
|
@value_types.each do |value_type|
|
281
281
|
#puts "#{value_type} verbalises as #{value_type.verbalise}"
|
282
|
-
value_type.respond_to?(:verbalise).should
|
282
|
+
value_type.respond_to?(:verbalise).should be true
|
283
283
|
verbalisation = value_type.verbalise
|
284
284
|
verbalisation.should =~ %r{\b#{value_type.basename}\b}
|
285
285
|
verbalisation.should =~ %r{\b#{value_type.superclass.basename}\b}
|
@@ -289,7 +289,7 @@ describe "An instance of every type of ObjectType" do
|
|
289
289
|
it "if an entity type, should verbalise" do
|
290
290
|
@entity_types.each do |entity_type|
|
291
291
|
#puts entity_type.verbalise
|
292
|
-
entity_type.respond_to?(:verbalise).should
|
292
|
+
entity_type.respond_to?(:verbalise).should be true
|
293
293
|
verbalisation = entity_type.verbalise
|
294
294
|
verbalisation.should =~ %r{\b#{entity_type.basename}\b}
|
295
295
|
|
@@ -318,7 +318,7 @@ describe "An instance of every type of ObjectType" do
|
|
318
318
|
it "if a value, should verbalise" do
|
319
319
|
@value_instances.each do |value|
|
320
320
|
#puts value.verbalise
|
321
|
-
value.respond_to?(:verbalise).should
|
321
|
+
value.respond_to?(:verbalise).should be true
|
322
322
|
verbalisation = value.verbalise
|
323
323
|
verbalisation.should =~ %r{\b#{value.class.basename}\b}
|
324
324
|
end
|
@@ -326,7 +326,7 @@ describe "An instance of every type of ObjectType" do
|
|
326
326
|
|
327
327
|
it "if an entity, should respond to verbalise" do
|
328
328
|
(@entities+@entities_by_entity).each do |entity|
|
329
|
-
entity.respond_to?(:verbalise).should
|
329
|
+
entity.respond_to?(:verbalise).should be true
|
330
330
|
verbalisation = entity.verbalise
|
331
331
|
verbalisation.should =~ %r{\b#{entity.class.basename}\b}
|
332
332
|
entity.class.identifying_role_names.each do |ir|
|
@@ -342,7 +342,7 @@ describe "An instance of every type of ObjectType" do
|
|
342
342
|
it "should respond to constellation" do
|
343
343
|
(@value_instances+@entities+@entities_by_entity).each do |instance|
|
344
344
|
next if instance == nil
|
345
|
-
instance.respond_to?(:constellation).should
|
345
|
+
instance.respond_to?(:constellation).should be true
|
346
346
|
end
|
347
347
|
end
|
348
348
|
|
@@ -268,7 +268,7 @@ describe "Object type role values" do
|
|
268
268
|
@object.has_a_unary = 23
|
269
269
|
@object.has_a_unary.should == true
|
270
270
|
@object.has_a_unary = false
|
271
|
-
@object.has_a_unary.should
|
271
|
+
@object.has_a_unary.should be false
|
272
272
|
@object.has_a_unary = nil
|
273
273
|
@object.has_a_unary.should be_nil
|
274
274
|
end
|
@@ -193,9 +193,9 @@ describe "Roles" do
|
|
193
193
|
c = ActiveFacts::API::Constellation.new(Mod)
|
194
194
|
foo = c.Name("Foo")
|
195
195
|
le = c.LegalEntity(foo)
|
196
|
-
le.respond_to?(:name).should
|
196
|
+
le.respond_to?(:name).should be true
|
197
197
|
name = le.name
|
198
|
-
name.respond_to?(:legal_entity).should
|
198
|
+
name.respond_to?(:legal_entity).should be true
|
199
199
|
|
200
200
|
#pending
|
201
201
|
[name.legal_entity].should === [le]
|
@@ -268,10 +268,10 @@ describe "Roles" do
|
|
268
268
|
subtype_role = supertype.all_role[subtype_role_name]
|
269
269
|
|
270
270
|
# Check uniqueness and mandatory:
|
271
|
-
supertype_role.unique.should
|
272
|
-
subtype_role.unique.should
|
273
|
-
supertype_role.mandatory.should
|
274
|
-
subtype_role.mandatory.should
|
271
|
+
supertype_role.unique.should be true
|
272
|
+
subtype_role.unique.should be true
|
273
|
+
supertype_role.mandatory.should be true
|
274
|
+
subtype_role.mandatory.should be false
|
275
275
|
|
276
276
|
# Check they belong to the same TypeInheritanceFactType:
|
277
277
|
subtype_role.fact_type.class.should be(ActiveFacts::API::TypeInheritanceFactType)
|
@@ -20,12 +20,12 @@ describe "Entity Type class definitions" do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should respond_to verbalise" do
|
23
|
-
Mod::Person.respond_to?(:verbalise).should
|
23
|
+
Mod::Person.respond_to?(:verbalise).should be true
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should not pollute the superclass" do
|
27
|
-
Mod::LegalEntity.respond_to?(:verbalise).should_not
|
28
|
-
Class.respond_to?(:verbalise).should_not
|
27
|
+
Mod::LegalEntity.respond_to?(:verbalise).should_not be true
|
28
|
+
Class.respond_to?(:verbalise).should_not be true
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should return a string from verbalise" do
|
@@ -35,7 +35,7 @@ describe "Entity Type class definitions" do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should respond_to vocabulary" do
|
38
|
-
Mod::Person.respond_to?(:vocabulary).should
|
38
|
+
Mod::Person.respond_to?(:vocabulary).should be true
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should return the parent module as the vocabulary" do
|
@@ -45,12 +45,12 @@ describe "Entity Type class definitions" do
|
|
45
45
|
|
46
46
|
it "should return a vocabulary that knows about this object_type" do
|
47
47
|
vocabulary = Mod::Person.vocabulary
|
48
|
-
vocabulary.respond_to?(:object_type).should
|
49
|
-
vocabulary.object_type.has_key?("Person").should
|
48
|
+
vocabulary.respond_to?(:object_type).should be true
|
49
|
+
vocabulary.object_type.has_key?("Person").should be_truthy
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should respond to all_role()" do
|
53
|
-
Mod::Person.respond_to?(:all_role).should
|
53
|
+
Mod::Person.respond_to?(:all_role).should be true
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should contain only the added role definition" do
|
@@ -72,7 +72,7 @@ describe "Entity Type class definitions" do
|
|
72
72
|
role.should_not be_nil
|
73
73
|
|
74
74
|
# Check the role definition array by .include?
|
75
|
-
Mod::Person.all_role.include?(:name).should
|
75
|
+
Mod::Person.all_role.include?(:name).should be true
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should fail on a ValueType" do
|
@@ -29,7 +29,7 @@ describe "AutoCounter Value Type instances" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should respond to verbalise" do
|
32
|
-
@thing_id.respond_to?(:verbalise).should
|
32
|
+
@thing_id.respond_to?(:verbalise).should be true
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should verbalise correctly" do
|
@@ -37,11 +37,11 @@ describe "AutoCounter Value Type instances" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should respond to constellation" do
|
40
|
-
@thing_id.respond_to?(:constellation).should
|
40
|
+
@thing_id.respond_to?(:constellation).should be true
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should respond to its roles" do
|
44
|
-
@thing_id.respond_to?(:thing).should
|
44
|
+
@thing_id.respond_to?(:thing).should be true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should allow prevent invalid role assignment" do
|
@@ -29,7 +29,7 @@ describe "Guid Value Type instances" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should respond to verbalise" do
|
32
|
-
@thing_id.respond_to?(:verbalise).should
|
32
|
+
@thing_id.respond_to?(:verbalise).should be true
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should verbalise correctly" do
|
@@ -37,11 +37,11 @@ describe "Guid Value Type instances" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should respond to constellation" do
|
40
|
-
@thing_id.respond_to?(:constellation).should
|
40
|
+
@thing_id.respond_to?(:constellation).should be true
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should respond to its roles" do
|
44
|
-
@thing_id.respond_to?(:thing).should
|
44
|
+
@thing_id.respond_to?(:thing).should be true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should allow prevent invalid role assignment" do
|
@@ -21,8 +21,8 @@ describe Int do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should also know that it's a delegator" do
|
24
|
-
@i.is_a?(SimpleDelegator).should
|
25
|
-
@i.is_a?(Int).should
|
24
|
+
@i.is_a?(SimpleDelegator).should be true
|
25
|
+
@i.is_a?(Int).should be true
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -39,13 +39,13 @@ describe Real do
|
|
39
39
|
1.0.should == @r
|
40
40
|
@r.should == 1.0
|
41
41
|
@r.to_s.should == "1.0"
|
42
|
-
@r.eql?(1.0).should
|
43
|
-
@r.is_a?(Float).should
|
42
|
+
@r.eql?(1.0).should be true
|
43
|
+
@r.is_a?(Float).should be true
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should also know that it's a delegator" do
|
47
|
-
@r.is_a?(SimpleDelegator).should
|
48
|
-
@r.is_a?(Real).should
|
47
|
+
@r.is_a?(SimpleDelegator).should be true
|
48
|
+
@r.is_a?(Real).should be true
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -30,14 +30,14 @@ describe "Value Type class definitions" do
|
|
30
30
|
|
31
31
|
it "should respond_to verbalise" do
|
32
32
|
@classes.each { |klass|
|
33
|
-
klass.respond_to?(:verbalise).should
|
33
|
+
klass.respond_to?(:verbalise).should be true
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should not pollute the value class" do
|
38
38
|
@classes.each { |klass|
|
39
39
|
if !@classes.include?(klass.superclass)
|
40
|
-
klass.superclass.respond_to?(:verbalise).should_not
|
40
|
+
klass.superclass.respond_to?(:verbalise).should_not be true
|
41
41
|
end
|
42
42
|
}
|
43
43
|
end
|
@@ -52,7 +52,7 @@ describe "Value Type class definitions" do
|
|
52
52
|
|
53
53
|
it "should respond_to vocabulary" do
|
54
54
|
@classes.each { |klass|
|
55
|
-
klass.respond_to?(:vocabulary).should
|
55
|
+
klass.respond_to?(:vocabulary).should be true
|
56
56
|
}
|
57
57
|
end
|
58
58
|
|
@@ -66,14 +66,14 @@ describe "Value Type class definitions" do
|
|
66
66
|
it "should return a vocabulary that knows about this object_type" do
|
67
67
|
@classes.each { |klass|
|
68
68
|
vocabulary = klass.vocabulary
|
69
|
-
vocabulary.respond_to?(:object_type).should
|
70
|
-
vocabulary.object_type.has_key?(klass.basename).should
|
69
|
+
vocabulary.respond_to?(:object_type).should be true
|
70
|
+
vocabulary.object_type.has_key?(klass.basename).should be true
|
71
71
|
}
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should respond to roles()" do
|
75
75
|
@classes.each { |klass|
|
76
|
-
klass.respond_to?(:all_role).should
|
76
|
+
klass.respond_to?(:all_role).should be true
|
77
77
|
}
|
78
78
|
end
|
79
79
|
|
@@ -101,7 +101,7 @@ describe "Value Type class definitions" do
|
|
101
101
|
unless @classes.include?(klass.superclass)
|
102
102
|
klass.all_role(attr).should_not be_nil
|
103
103
|
# Check the role definition array by .include?
|
104
|
-
klass.all_role.include?(attr).should
|
104
|
+
klass.all_role.include?(attr).should be true
|
105
105
|
end
|
106
106
|
}
|
107
107
|
end
|
metadata
CHANGED
@@ -1,134 +1,126 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activefacts-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clifford Heath
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree-pure
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jeweler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.6.0
|
62
|
-
- - ~>
|
62
|
+
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '2.6'
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 2.6.0
|
72
|
-
- - ~>
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '2.6'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: ruby-debug
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - ~>
|
79
|
+
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- - ~>
|
86
|
+
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: debugger
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - ~>
|
93
|
+
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '1'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - ~>
|
100
|
+
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '1'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: pry
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- - ~>
|
107
|
+
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - ~>
|
114
|
+
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
-
description:
|
117
|
+
description: |2
|
118
118
|
|
119
119
|
The ActiveFacts API is a Ruby DSL for managing constellations of elementary facts.
|
120
|
-
|
121
|
-
|
122
|
-
or
|
123
|
-
|
124
|
-
binary relational (A rel B). Relational facts are consistently co-referenced, so
|
125
|
-
you
|
126
|
-
|
120
|
+
Each fact is either existential (a value or an entity), characteristic (boolean) or
|
121
|
+
binary relational (A rel B). Relational facts are consistently co-referenced, so you
|
127
122
|
can traverse them efficiently in any direction. Each constellation maintains constraints
|
128
|
-
|
129
123
|
over the fact population.
|
130
|
-
|
131
|
-
'
|
132
124
|
email: clifford.heath@gmail.com
|
133
125
|
executables: []
|
134
126
|
extensions: []
|
@@ -137,9 +129,9 @@ extra_rdoc_files:
|
|
137
129
|
- README.rdoc
|
138
130
|
- TODO
|
139
131
|
files:
|
140
|
-
- .document
|
141
|
-
- .rspec
|
142
|
-
- .travis.yml
|
132
|
+
- ".document"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
143
135
|
- Gemfile
|
144
136
|
- LICENSE.txt
|
145
137
|
- README.rdoc
|
@@ -195,12 +187,12 @@ require_paths:
|
|
195
187
|
- lib
|
196
188
|
required_ruby_version: !ruby/object:Gem::Requirement
|
197
189
|
requirements:
|
198
|
-
- -
|
190
|
+
- - ">="
|
199
191
|
- !ruby/object:Gem::Version
|
200
192
|
version: '0'
|
201
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
194
|
requirements:
|
203
|
-
- -
|
195
|
+
- - ">="
|
204
196
|
- !ruby/object:Gem::Version
|
205
197
|
version: '0'
|
206
198
|
requirements: []
|