activefacts-api 0.9.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,8 +14,8 @@ describe "In a vocabulary" do
14
14
 
15
15
  ObjectType_methods = [
16
16
  :has_one, :maybe, :one_to_one,
17
- :roles, :subtypes, :supertypes, :vocabulary,
18
- :all_roles,
17
+ :add_role, :all_role, :subtypes, :supertypes, :vocabulary,
18
+ :all_role_transitive,
19
19
  # To make private:
20
20
  :check_identifying_role_has_valid_cardinality, :realise_role, :supertypes_transitive,
21
21
  ]
@@ -57,7 +57,6 @@ describe "In a vocabulary" do
57
57
 
58
58
  Cases =
59
59
  ValueClasses.map do |klass| # [String, Date, DateTime, Int, Real, AutoCounter, Decimal, Guid]
60
- x=
61
60
  { :name => "a #{klass}",
62
61
  :definition => %Q{
63
62
  class T < #{klass}
@@ -82,8 +81,6 @@ describe "In a vocabulary" do
82
81
  end
83
82
  ).compact
84
83
  }
85
- debugger if x[:constructor_args].empty?
86
- x
87
84
  end + [
88
85
  { :name => "a Value Sub Type",
89
86
  :definition => %q{
@@ -49,30 +49,30 @@ describe "Entity Type class definitions" do
49
49
  vocabulary.object_type.has_key?("Person").should be_true
50
50
  end
51
51
 
52
- it "should respond to roles()" do
53
- Mod::Person.respond_to?(:roles).should be_true
52
+ it "should respond to all_role()" do
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
57
- Mod::Person.roles.size.should == 1
57
+ Mod::Person.all_role.size.should == 1
58
58
  end
59
59
 
60
60
  it "should return the role definition" do
61
61
  # Check the role definition may be accessed by passing an index:
62
- Mod::Person.roles(0).should be_nil
62
+ Mod::Person.all_role(0).should be_nil
63
63
 
64
- role = Mod::Person.roles(:name)
64
+ role = Mod::Person.all_role(:name)
65
65
  role.should_not be_nil
66
66
 
67
- role = Mod::Person.roles("name")
67
+ role = Mod::Person.all_role("name")
68
68
  role.should_not be_nil
69
69
 
70
70
  # Check the role definition may be accessed by indexing the returned hash:
71
- role = Mod::Person.roles[:name]
71
+ role = Mod::Person.all_role[:name]
72
72
  role.should_not be_nil
73
73
 
74
74
  # Check the role definition array by .include?
75
- Mod::Person.roles.include?(:name).should be_true
75
+ Mod::Person.all_role.include?(:name).should be_true
76
76
  end
77
77
 
78
78
  it "should fail on a ValueType" do
@@ -47,14 +47,6 @@ describe "Multi-part identifiers" do
47
47
  @p.all_child.size.should == 3
48
48
  end
49
49
 
50
- it "should allow children to be found in the instance index by the residual key" do
51
- pending "RoleValues use the whole key, not the residual key" do
52
- @c.Child[[0]].should == @c0
53
- @c.Child[[1]].should == @c1
54
- @c.Child[[2]].should == @c2
55
- end
56
- end
57
-
58
50
  it "should allow children to be found in the instance index by the whole key" do
59
51
  @c.Child[[[@p.parent_id], 0]].should == @c0
60
52
  @c.Child[[[@p.parent_id], 1]].should == @c1
@@ -68,10 +60,23 @@ describe "Multi-part identifiers" do
68
60
  @p.all_child.to_a[2].should == @c2
69
61
  end
70
62
 
71
- it "should have a correct key for each child in the parent's RoleValues" do
72
- pending "Key sorting is not supported in this version" if @p.all_child.instance_variable_get("@a").kind_of? Array
73
- @p.all_child.keys[0].should == [[@p.parent_id], 0]
74
- @p.all_child.keys[1].should == [[@p.parent_id], 1]
75
- @p.all_child.keys[2].should == [[@p.parent_id], 2]
63
+ it "should allow children to be found in an identifying partner's RoleValues by the residual key" do
64
+ @p.all_child[0].should == @c0
65
+ @p.all_child[1].should == @c1
66
+ @p.all_child[2].should == @c2
67
+ end
68
+
69
+ it "should use the correct residual key for each child in an identifying partner's RoleValues" do
70
+ if @p.all_child.instance_variable_get("@a").kind_of? Array
71
+ pending "Key sorting is not supported in this version"
72
+ end
73
+
74
+ @p.all_child.keys[0].should == [0]
75
+ @p.all_child.keys[1].should == [1]
76
+ @p.all_child.keys[2].should == [2]
77
+
78
+ # @p.all_child.keys[0].should == [[@p.parent_id], 0]
79
+ # @p.all_child.keys[1].should == [[@p.parent_id], 1]
80
+ # @p.all_child.keys[2].should == [[@p.parent_id], 2]
76
81
  end
77
82
  end
@@ -19,10 +19,12 @@ describe "Value Type class definitions" do
19
19
  value_type
20
20
  has_one :name
21
21
  end
22
+ class GivenName < Name
23
+ end
22
24
  end
23
25
 
24
- @classes = [Mod::Name, Mod::Year, Mod::Weight]
25
- @attrs = [:name, :name, :name]
26
+ @classes = [Mod::Name, Mod::GivenName, Mod::Year, Mod::Weight]
27
+ @attrs = [:name, :name, :name, :name]
26
28
 
27
29
  end
28
30
 
@@ -34,7 +36,9 @@ describe "Value Type class definitions" do
34
36
 
35
37
  it "should not pollute the value class" do
36
38
  @classes.each { |klass|
37
- klass.superclass.respond_to?(:verbalise).should_not be_true
39
+ if !@classes.include?(klass.superclass)
40
+ klass.superclass.respond_to?(:verbalise).should_not be_true
41
+ end
38
42
  }
39
43
  end
40
44
 
@@ -69,28 +73,36 @@ describe "Value Type class definitions" do
69
73
 
70
74
  it "should respond to roles()" do
71
75
  @classes.each { |klass|
72
- klass.respond_to?(:roles).should be_true
76
+ klass.respond_to?(:all_role).should be_true
73
77
  }
74
78
  end
75
79
 
76
80
  it "should contain only the added role definitions" do
77
- Mod::Name.roles.size.should == 4
78
- (@classes-[Mod::Name]).each { |klass|
79
- klass.roles.size.should == 1
81
+ @classes.each { |klass|
82
+ num_roles = klass.all_role.size
83
+ if klass == Mod::GivenName
84
+ num_roles.should == 1
85
+ elsif klass == Mod::Name
86
+ num_roles.should == 5
87
+ else
88
+ num_roles.should == 1
89
+ end
80
90
  }
81
91
  end
82
92
 
83
93
  it "should return the role definition" do
84
94
  # Check the role definition may not be accessed by passing an index:
85
- Mod::Name.roles(0).should be_nil
95
+ Mod::Name.all_role(0).should be_nil
86
96
 
87
97
  @classes.zip(@attrs).each { |klass, attr|
88
- klass.roles(attr).should_not be_nil
89
- klass.roles(attr.to_s).should_not be_nil
98
+ klass.all_role(attr).should_not be_nil
99
+ klass.all_role(attr.to_s).should_not be_nil
90
100
  # Check the role definition may be accessed by indexing the returned array:
91
- klass.roles[attr].should_not be_nil
92
- # Check the role definition array by .include?
93
- klass.roles.include?(attr).should be_true
101
+ unless @classes.include?(klass.superclass)
102
+ klass.all_role(attr).should_not be_nil
103
+ # Check the role definition array by .include?
104
+ klass.all_role.include?(attr).should be_true
105
+ end
94
106
  }
95
107
  end
96
108
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefacts-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 1.0.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-02-14 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree-pure
@@ -56,7 +56,7 @@ dependencies:
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
  - - ~>
@@ -66,7 +66,7 @@ dependencies:
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
  - - ~>
@@ -114,13 +114,21 @@ dependencies:
114
114
  - - ~>
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
- description: |2
117
+ description: ! '
118
118
 
119
119
  The ActiveFacts API is a Ruby DSL for managing constellations of elementary facts.
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
120
+
121
+ Each fact is either existential (a value or an entity), characteristic (boolean)
122
+ or
123
+
124
+ binary relational (A rel B). Relational facts are consistently co-referenced, so
125
+ you
126
+
122
127
  can traverse them efficiently in any direction. Each constellation maintains constraints
128
+
123
129
  over the fact population.
130
+
131
+ '
124
132
  email: clifford.heath@gmail.com
125
133
  executables: []
126
134
  extensions: []
@@ -187,17 +195,17 @@ require_paths:
187
195
  - lib
188
196
  required_ruby_version: !ruby/object:Gem::Requirement
189
197
  requirements:
190
- - - '>='
198
+ - - ! '>='
191
199
  - !ruby/object:Gem::Version
192
200
  version: '0'
193
201
  required_rubygems_version: !ruby/object:Gem::Requirement
194
202
  requirements:
195
- - - '>='
203
+ - - ! '>='
196
204
  - !ruby/object:Gem::Version
197
205
  version: '0'
198
206
  requirements: []
199
207
  rubyforge_project:
200
- rubygems_version: 2.2.1
208
+ rubygems_version: 2.2.2
201
209
  signing_key:
202
210
  specification_version: 4
203
211
  summary: A fact-based data model DSL and API