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.
Files changed (83) hide show
  1. data/.rspec +1 -0
  2. data/Gemfile +3 -2
  3. data/Gemfile.lock +40 -35
  4. data/VERSION +1 -1
  5. data/app/models/rea/categories_entity.rb +7 -0
  6. data/app/models/rea/category.rb +18 -7
  7. data/app/models/rea/classification.rb +7 -0
  8. data/app/models/rea/entities_group.rb +7 -0
  9. data/app/models/rea/group.rb +5 -17
  10. data/app/models/rea/rea.rb +7 -0
  11. data/config/locales/en.yml +2 -0
  12. data/config/locales/zh-CN.yml +16 -17
  13. data/db/migrate/20121129100245_create_rea_groups.rb +18 -0
  14. data/db/migrate/20121129100748_create_rea_categories.rb +19 -0
  15. data/db/migrate/20121129101744_create_rea_classifications.rb +29 -0
  16. data/db/migrate/20121130051633_create_rea_entities_groups.rb +13 -0
  17. data/db/migrate/20121130100600_create_rea_categories_entities.rb +13 -0
  18. data/engine-rea.gemspec +27 -59
  19. data/lib/generators/rea/install/install_generator.rb +4 -4
  20. data/lib/rea/active_record_ext.rb +82 -0
  21. data/lib/rea/application.rb +55 -21
  22. data/lib/rea/engine.rb +8 -2
  23. data/lib/rea.rb +5 -10
  24. data/spec/dummy/db/schema.rb +61 -1
  25. data/spec/models/rea/categories_entity_spec.rb +7 -0
  26. data/spec/models/rea/category_spec.rb +10 -19
  27. data/spec/models/rea/classification_spec.rb +6 -0
  28. data/spec/models/rea/entities_group_spec.rb +7 -0
  29. data/spec/models/rea/group_spec.rb +3 -35
  30. data/spec/rea/active_record_ext_spec.rb +35 -0
  31. data/spec/rea/application_spec.rb +17 -0
  32. data/spec/spec_helper.rb +3 -0
  33. metadata +40 -59
  34. data/app/models/rea/category_member.rb +0 -8
  35. data/app/models/rea/category_type.rb +0 -7
  36. data/app/models/rea/group_type.rb +0 -7
  37. data/app/models/rea/identifier.rb +0 -51
  38. data/app/views/layouts/rea/application.html.erb +0 -14
  39. data/db/migrate/20120601074531_create_rea_category_types.rb +0 -11
  40. data/db/migrate/20120601074540_create_rea_categories.rb +0 -12
  41. data/db/migrate/20120605023205_create_rea_category_members.rb +0 -12
  42. data/db/migrate/20120605030658_create_rea_groups.rb +0 -20
  43. data/db/migrate/20120605082028_create_rea_identifiers.rb +0 -11
  44. data/db/migrate/20120717080004_create_rea_group_types.rb +0 -7
  45. data/lib/rea/aspect_type/base.rb +0 -10
  46. data/lib/rea/aspect_type/classification.rb +0 -142
  47. data/lib/rea/aspect_type/description.rb +0 -8
  48. data/lib/rea/aspect_type/due_date.rb +0 -34
  49. data/lib/rea/aspect_type/identification.rb +0 -38
  50. data/lib/rea/aspect_type.rb +0 -33
  51. data/lib/rea/meta_type/agent.rb +0 -10
  52. data/lib/rea/meta_type/commitment.rb +0 -26
  53. data/lib/rea/meta_type/contract.rb +0 -32
  54. data/lib/rea/meta_type/conversion.rb +0 -6
  55. data/lib/rea/meta_type/entity.rb +0 -91
  56. data/lib/rea/meta_type/event.rb +0 -39
  57. data/lib/rea/meta_type/exchange.rb +0 -6
  58. data/lib/rea/meta_type/group.rb +0 -25
  59. data/lib/rea/meta_type/process.rb +0 -28
  60. data/lib/rea/meta_type/resource.rb +0 -14
  61. data/lib/rea/meta_type/schedule.rb +0 -0
  62. data/lib/rea/meta_type/type.rb +0 -0
  63. data/lib/rea/meta_type.rb +0 -8
  64. data/lib/rea/model.rb +0 -65
  65. data/lib/rea/plugins/active_model.rb +0 -18
  66. data/spec/models/rea/category_member_spec.rb +0 -9
  67. data/spec/models/rea/category_type_spec.rb +0 -28
  68. data/spec/models/rea/group_type_spec.rb +0 -8
  69. data/spec/models/rea/identifier_spec.rb +0 -48
  70. data/spec/rea/aspect_type/classification_spec.rb +0 -107
  71. data/spec/rea/aspect_type/due_date_spec.rb +0 -75
  72. data/spec/rea/aspect_type/identification_spec.rb +0 -64
  73. data/spec/rea/aspect_type_spec.rb +0 -44
  74. data/spec/rea/meta_type/agent_spec.rb +0 -28
  75. data/spec/rea/meta_type/commitment_spec.rb +0 -45
  76. data/spec/rea/meta_type/contract_spec.rb +0 -42
  77. data/spec/rea/meta_type/entity_spec.rb +0 -58
  78. data/spec/rea/meta_type/event_spec.rb +0 -21
  79. data/spec/rea/meta_type/group_spec.rb +0 -55
  80. data/spec/rea/meta_type/process_spec.rb +0 -5
  81. data/spec/rea/meta_type/resource_spec.rb +0 -65
  82. data/spec/rea/meta_type_spec.rb +0 -11
  83. 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,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Rea::MetaType::Process do
4
-
5
- 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
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Rea::MetaType do
4
-
5
- context :autoload do
6
-
7
- subject { described_class }
8
-
9
- it(:auto_loaded) { Rea::MetaType::Event.should be_a_kind_of Module }
10
- end
11
- end
@@ -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