engine-rea 0.2.2 → 0.3.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/.rspec +1 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +40 -35
- data/VERSION +1 -1
- data/app/models/rea/categories_entity.rb +7 -0
- data/app/models/rea/category.rb +18 -7
- data/app/models/rea/classification.rb +7 -0
- data/app/models/rea/entities_group.rb +7 -0
- data/app/models/rea/group.rb +5 -17
- data/app/models/rea/rea.rb +7 -0
- data/config/locales/en.yml +2 -0
- data/config/locales/zh-CN.yml +16 -17
- data/db/migrate/20121129100245_create_rea_groups.rb +18 -0
- data/db/migrate/20121129100748_create_rea_categories.rb +19 -0
- data/db/migrate/20121129101744_create_rea_classifications.rb +29 -0
- data/db/migrate/20121130051633_create_rea_entities_groups.rb +13 -0
- data/db/migrate/20121130100600_create_rea_categories_entities.rb +13 -0
- data/engine-rea.gemspec +27 -59
- data/lib/generators/rea/install/install_generator.rb +4 -4
- data/lib/rea/active_record_ext.rb +82 -0
- data/lib/rea/application.rb +55 -21
- data/lib/rea/engine.rb +8 -2
- data/lib/rea.rb +5 -10
- data/spec/dummy/db/schema.rb +61 -1
- data/spec/models/rea/categories_entity_spec.rb +7 -0
- data/spec/models/rea/category_spec.rb +10 -19
- data/spec/models/rea/classification_spec.rb +6 -0
- data/spec/models/rea/entities_group_spec.rb +7 -0
- data/spec/models/rea/group_spec.rb +3 -35
- data/spec/rea/active_record_ext_spec.rb +35 -0
- data/spec/rea/application_spec.rb +17 -0
- data/spec/spec_helper.rb +3 -0
- metadata +40 -59
- data/app/models/rea/category_member.rb +0 -8
- data/app/models/rea/category_type.rb +0 -7
- data/app/models/rea/group_type.rb +0 -7
- data/app/models/rea/identifier.rb +0 -51
- data/app/views/layouts/rea/application.html.erb +0 -14
- data/db/migrate/20120601074531_create_rea_category_types.rb +0 -11
- data/db/migrate/20120601074540_create_rea_categories.rb +0 -12
- data/db/migrate/20120605023205_create_rea_category_members.rb +0 -12
- data/db/migrate/20120605030658_create_rea_groups.rb +0 -20
- data/db/migrate/20120605082028_create_rea_identifiers.rb +0 -11
- data/db/migrate/20120717080004_create_rea_group_types.rb +0 -7
- data/lib/rea/aspect_type/base.rb +0 -10
- data/lib/rea/aspect_type/classification.rb +0 -142
- data/lib/rea/aspect_type/description.rb +0 -8
- data/lib/rea/aspect_type/due_date.rb +0 -34
- data/lib/rea/aspect_type/identification.rb +0 -38
- data/lib/rea/aspect_type.rb +0 -33
- data/lib/rea/meta_type/agent.rb +0 -10
- data/lib/rea/meta_type/commitment.rb +0 -26
- data/lib/rea/meta_type/contract.rb +0 -32
- data/lib/rea/meta_type/conversion.rb +0 -6
- data/lib/rea/meta_type/entity.rb +0 -91
- data/lib/rea/meta_type/event.rb +0 -39
- data/lib/rea/meta_type/exchange.rb +0 -6
- data/lib/rea/meta_type/group.rb +0 -25
- data/lib/rea/meta_type/process.rb +0 -28
- data/lib/rea/meta_type/resource.rb +0 -14
- data/lib/rea/meta_type/schedule.rb +0 -0
- data/lib/rea/meta_type/type.rb +0 -0
- data/lib/rea/meta_type.rb +0 -8
- data/lib/rea/model.rb +0 -65
- data/lib/rea/plugins/active_model.rb +0 -18
- data/spec/models/rea/category_member_spec.rb +0 -9
- data/spec/models/rea/category_type_spec.rb +0 -28
- data/spec/models/rea/group_type_spec.rb +0 -8
- data/spec/models/rea/identifier_spec.rb +0 -48
- data/spec/rea/aspect_type/classification_spec.rb +0 -107
- data/spec/rea/aspect_type/due_date_spec.rb +0 -75
- data/spec/rea/aspect_type/identification_spec.rb +0 -64
- data/spec/rea/aspect_type_spec.rb +0 -44
- data/spec/rea/meta_type/agent_spec.rb +0 -28
- data/spec/rea/meta_type/commitment_spec.rb +0 -45
- data/spec/rea/meta_type/contract_spec.rb +0 -42
- data/spec/rea/meta_type/entity_spec.rb +0 -58
- data/spec/rea/meta_type/event_spec.rb +0 -21
- data/spec/rea/meta_type/group_spec.rb +0 -55
- data/spec/rea/meta_type/process_spec.rb +0 -5
- data/spec/rea/meta_type/resource_spec.rb +0 -65
- data/spec/rea/meta_type_spec.rb +0 -11
- data/spec/rea/model_spec.rb +0 -79
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rea::MetaType::Entity do
|
4
|
-
|
5
|
-
with_model :agent do
|
6
|
-
table do |t|
|
7
|
-
t.string :name
|
8
|
-
t.references :group
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
with_model :group do
|
13
|
-
table do |t|
|
14
|
-
t.string :name
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
before :each do
|
19
|
-
Rea.model do
|
20
|
-
entities do
|
21
|
-
group :group
|
22
|
-
agent :agent do
|
23
|
-
grouping :group
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context :syntax do
|
30
|
-
subject { Rea.context.symbol_table[:agent] }
|
31
|
-
it { should == Agent }
|
32
|
-
context :group_reflect do
|
33
|
-
subject { Agent.reflect_on_association(:group) }
|
34
|
-
it { should_not be_nil }
|
35
|
-
its(:macro) { should == :belongs_to }
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
context :model do
|
41
|
-
before :each do
|
42
|
-
Agent.delete_all
|
43
|
-
Group.delete_all
|
44
|
-
Group.create! :name=>:group
|
45
|
-
2.times do
|
46
|
-
Agent.create! :name=>:agent, :group_id=>Group.last.id
|
47
|
-
end
|
48
|
-
end
|
49
|
-
context :class do
|
50
|
-
subject { Agent }
|
51
|
-
it :groups_for do
|
52
|
-
subject.groups_for(:group).should have(1).items
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rea::MetaType::Event do
|
4
|
-
with_model :event do
|
5
|
-
table do |t|
|
6
|
-
end
|
7
|
-
model do
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
before(:each) do
|
12
|
-
Rea.model do
|
13
|
-
entities do
|
14
|
-
event :event, :type=>:increment
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
subject { Rea.context.symbol_table[:event] }
|
20
|
-
its(:type) { should == :increment }
|
21
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rea::MetaType::Group do
|
4
|
-
|
5
|
-
with_model :agent do
|
6
|
-
table do |t|
|
7
|
-
t.string :name
|
8
|
-
t.references :group
|
9
|
-
end
|
10
|
-
model do
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
with_model :group do
|
15
|
-
table do |t|
|
16
|
-
t.string :name
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
before :each do
|
21
|
-
|
22
|
-
Rea.model do
|
23
|
-
entities do
|
24
|
-
group :group do
|
25
|
-
grouped :agent
|
26
|
-
end
|
27
|
-
agent :agent do
|
28
|
-
grouping :group, :class_name=>Group.name
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context :syntax do
|
35
|
-
context :symbol do
|
36
|
-
context :group do
|
37
|
-
subject { Rea.context.symbol_table[:group] }
|
38
|
-
it { should == Group }
|
39
|
-
its(:entity_types) { should include :agent }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context :model do
|
45
|
-
before :each do
|
46
|
-
Agent.delete_all
|
47
|
-
Group.delete_all
|
48
|
-
Group.create! :name=>:group
|
49
|
-
2.times do
|
50
|
-
Agent.create! :name=>:agent, :group_id=>Group.last.id
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class SimpleResource
|
4
|
-
end
|
5
|
-
|
6
|
-
describe Rea::MetaType::Resource do
|
7
|
-
|
8
|
-
context :simple_resource_define do
|
9
|
-
with_model :event do
|
10
|
-
table do |t|
|
11
|
-
t.references :resource
|
12
|
-
t.references :provider
|
13
|
-
t.decimal :amount
|
14
|
-
end
|
15
|
-
model do
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
Rea.model do
|
21
|
-
entities do
|
22
|
-
resource :simple_resource, :entity_type=>:simple do
|
23
|
-
item :rp, :id=>1, :value=>1
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context :class do
|
30
|
-
subject { SimpleResource }
|
31
|
-
its(:rp) { should be_a_kind_of SimpleResource }
|
32
|
-
its(:entity_type) { should == :simple }
|
33
|
-
it { subject.find(1).should be_a_kind_of SimpleResource }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context :active_record_resource_define do
|
38
|
-
with_model :resource do
|
39
|
-
table do |t|
|
40
|
-
t.string :name
|
41
|
-
t.decimal :value
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
before(:each) do
|
46
|
-
Rea.model do
|
47
|
-
entities do
|
48
|
-
resource :resource
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
subject { Resource.new :name=>:name, :value=>1 }
|
54
|
-
it { should be_valid }
|
55
|
-
it :name_not_nil do
|
56
|
-
subject.name = nil
|
57
|
-
should_not be_valid
|
58
|
-
end
|
59
|
-
it :value_not_nil do
|
60
|
-
subject.value = nil
|
61
|
-
should_not be_valid
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
data/spec/rea/meta_type_spec.rb
DELETED
data/spec/rea/model_spec.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rea::Model do
|
4
|
-
|
5
|
-
context Rea do
|
6
|
-
subject { Rea }
|
7
|
-
its(:context) { should be_a_kind_of Rea::Model::Context }
|
8
|
-
its(:public_methods) { should include :model }
|
9
|
-
it :call_model do
|
10
|
-
expect { |b|
|
11
|
-
Rea.model &b
|
12
|
-
}.to yield_control
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context Rea::Model::Context do
|
17
|
-
with_model :resource do
|
18
|
-
table do |t|
|
19
|
-
end
|
20
|
-
model do
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
with_model :event do
|
25
|
-
table do |t|
|
26
|
-
end
|
27
|
-
model do
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
with_model :agent do
|
32
|
-
table do |t|
|
33
|
-
end
|
34
|
-
model do
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
with_model :commitment do
|
39
|
-
table do |t|
|
40
|
-
end
|
41
|
-
model do
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
with_model :contract do
|
46
|
-
table do |t|
|
47
|
-
end
|
48
|
-
model do
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
before(:each) do
|
53
|
-
Rea.model do
|
54
|
-
entities do
|
55
|
-
resource :resource
|
56
|
-
event :event
|
57
|
-
agent :agent
|
58
|
-
commitment :commitment
|
59
|
-
contract Contract
|
60
|
-
end
|
61
|
-
|
62
|
-
processes do
|
63
|
-
exchange :process_trade do
|
64
|
-
outflow :event,:resource=>:resource, :provider=>:agent
|
65
|
-
inflow :event, :resource=>:resource, :recipient=>:agent
|
66
|
-
end
|
67
|
-
conversion :process_produce do
|
68
|
-
outflow :event,:resource=>:resource, :provider=>:agent
|
69
|
-
inflow :event, :resource=>:resource, :recipient=>:agent
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
subject { Rea.context }
|
75
|
-
its("symbol_table.keys") { should include *%W{resource event agent
|
76
|
-
commitment contract process_trade process_produce} }
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|