engine-rea 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.watchr +55 -0
- data/Gemfile +29 -0
- data/Gemfile.lock +165 -0
- data/MIT-LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/app/assets/images/rea/.gitkeep +0 -0
- data/app/assets/javascripts/rea/application.js +15 -0
- data/app/assets/stylesheets/rea/application.css +13 -0
- data/app/controllers/rea/application_controller.rb +4 -0
- data/app/helpers/rea/application_helper.rb +4 -0
- data/app/models/rea/category.rb +8 -0
- data/app/models/rea/category_member.rb +7 -0
- data/app/models/rea/category_type.rb +7 -0
- data/app/models/rea/group.rb +11 -0
- data/app/models/rea/group_entity.rb +7 -0
- data/app/models/rea/identifier.rb +42 -0
- data/app/views/layouts/rea/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20120601074531_create_rea_category_types.rb +13 -0
- data/db/migrate/20120601074540_create_rea_categories.rb +12 -0
- data/db/migrate/20120605023205_create_rea_category_members.rb +12 -0
- data/db/migrate/20120605030658_create_rea_groups.rb +9 -0
- data/db/migrate/20120605030708_create_rea_group_entities.rb +9 -0
- data/db/migrate/20120605082028_create_rea_identifiers.rb +11 -0
- data/lib/generators/rea/install/USAGE +8 -0
- data/lib/generators/rea/install/install_generator.rb +20 -0
- data/lib/rea/dsl/behavioral.rb +40 -0
- data/lib/rea/dsl/structural.rb +70 -0
- data/lib/rea/dsl.rb +20 -0
- data/lib/rea/engine.rb +11 -0
- data/lib/rea.rb +7 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/rea_tasks.rake +4 -0
- data/lib/tasks/watchr.rake +4 -0
- data/rea.gemspec +169 -0
- data/script/cucumber +10 -0
- data/script/rails +8 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +61 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +71 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/rea_resources.rb +6 -0
- data/spec/generators/rea/install/install_generator_spec.rb +27 -0
- data/spec/models/rea/category_member_spec.rb +5 -0
- data/spec/models/rea/category_spec.rb +5 -0
- data/spec/models/rea/category_type_spec.rb +5 -0
- data/spec/models/rea/group_entity_spec.rb +5 -0
- data/spec/models/rea/group_spec.rb +5 -0
- data/spec/models/rea/identifier_spec.rb +48 -0
- data/spec/rea/dsl/behavioral_spec.rb +81 -0
- data/spec/rea/dsl/structural_spec.rb +141 -0
- data/spec/rea/dsl_spec.rb +11 -0
- data/spec/rea/engine_spec.rb +10 -0
- data/spec/spec_helper.rb +35 -0
- metadata +391 -0
data/.watchr
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
def run(cmd)
|
2
|
+
puts(cmd)
|
3
|
+
`#{cmd}`
|
4
|
+
end
|
5
|
+
|
6
|
+
def growl(first, result)
|
7
|
+
passed = result.include?(' 0 failures')
|
8
|
+
title = "RSpec Test #{ passed ? "Successful!" : "Failed..."}"
|
9
|
+
image = passed ? "info" : "error"
|
10
|
+
severity = passed ? "low" : "critical"
|
11
|
+
body = result[/(Finished.+\n.+)+/]
|
12
|
+
options = "-i #{image} -u #{severity} '#{title}' '#{body}'"
|
13
|
+
system "notify-send #{options} &"
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_spec(file)
|
17
|
+
unless File.exist?(file)
|
18
|
+
puts "#{file} does not exist"
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
puts "Running #{file}"
|
23
|
+
result = run("bundle exec rspec #{file}")
|
24
|
+
growl(result.split("\n").first, result) rescue nil
|
25
|
+
puts result
|
26
|
+
end
|
27
|
+
|
28
|
+
watch("lib/(.*/.*)\.rb") do |match|
|
29
|
+
run_spec %{spec/#{match[1]}_spec.rb}
|
30
|
+
end
|
31
|
+
|
32
|
+
watch("lib/(.*/.*/.*)\.rb") do |match|
|
33
|
+
run_spec %{spec/#{match[1]}_spec.rb}
|
34
|
+
end
|
35
|
+
|
36
|
+
watch("lib/(.*/.*/.*/.*)\.rb") do |match|
|
37
|
+
run_spec %{spec/#{match[1]}_spec.rb}
|
38
|
+
end
|
39
|
+
|
40
|
+
watch("app/(.*/.*)\.rb") do |match|
|
41
|
+
run_spec %{spec/#{match[1]}_spec.rb}
|
42
|
+
end
|
43
|
+
|
44
|
+
watch("spec/.*/*_spec\.rb") do |match|
|
45
|
+
run_spec match[0]
|
46
|
+
end
|
47
|
+
|
48
|
+
watch("spec/.*/.*/*_spec\.rb") do |match|
|
49
|
+
run_spec match[0]
|
50
|
+
end
|
51
|
+
|
52
|
+
watch("spec/.*/.*/.*/*_spec\.rb") do |match|
|
53
|
+
run_spec match[0]
|
54
|
+
end
|
55
|
+
|
data/Gemfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
source "http://ruby.taobao.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "rails", ">=3.2.0"
|
7
|
+
gem "capybara", ">= 0.4.0"
|
8
|
+
|
9
|
+
group :development,:test do
|
10
|
+
gem "database_cleaner"
|
11
|
+
gem "sqlite3"
|
12
|
+
gem 'factory_girl_rails'
|
13
|
+
gem 'minitest'
|
14
|
+
gem "rspec-rails", ">= 2.8.0"
|
15
|
+
gem "sqlite3-ruby"
|
16
|
+
gem "with_model", '>= 0.1.5'
|
17
|
+
gem "generator_spec"
|
18
|
+
gem "rdoc", "~> 3.12"
|
19
|
+
gem "bundler", ">= 1.0.0"
|
20
|
+
gem "jeweler", ">= 1.8.3"
|
21
|
+
gem "simplecov", ">= 0"
|
22
|
+
gem 'spork', '~> 1.0rc'
|
23
|
+
gem 'watchr'
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
28
|
+
# gem 'ruby-debug'
|
29
|
+
# gem 'ruby-debug19'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://ruby.taobao.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.2.3)
|
5
|
+
actionpack (= 3.2.3)
|
6
|
+
mail (~> 2.4.4)
|
7
|
+
actionpack (3.2.3)
|
8
|
+
activemodel (= 3.2.3)
|
9
|
+
activesupport (= 3.2.3)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.1)
|
13
|
+
rack (~> 1.4.0)
|
14
|
+
rack-cache (~> 1.2)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.1.2)
|
17
|
+
activemodel (3.2.3)
|
18
|
+
activesupport (= 3.2.3)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.3)
|
21
|
+
activemodel (= 3.2.3)
|
22
|
+
activesupport (= 3.2.3)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.3)
|
26
|
+
activemodel (= 3.2.3)
|
27
|
+
activesupport (= 3.2.3)
|
28
|
+
activesupport (3.2.3)
|
29
|
+
i18n (~> 0.6)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
addressable (2.2.8)
|
32
|
+
arel (3.0.2)
|
33
|
+
builder (3.0.0)
|
34
|
+
capybara (1.1.2)
|
35
|
+
mime-types (>= 1.16)
|
36
|
+
nokogiri (>= 1.3.3)
|
37
|
+
rack (>= 1.0.0)
|
38
|
+
rack-test (>= 0.5.4)
|
39
|
+
selenium-webdriver (~> 2.0)
|
40
|
+
xpath (~> 0.1.4)
|
41
|
+
childprocess (0.3.2)
|
42
|
+
ffi (~> 1.0.6)
|
43
|
+
database_cleaner (0.7.2)
|
44
|
+
diff-lcs (1.1.3)
|
45
|
+
erubis (2.7.0)
|
46
|
+
factory_girl (3.3.0)
|
47
|
+
activesupport (>= 3.0.0)
|
48
|
+
factory_girl_rails (3.3.0)
|
49
|
+
factory_girl (~> 3.3.0)
|
50
|
+
railties (>= 3.0.0)
|
51
|
+
ffi (1.0.11)
|
52
|
+
generator_spec (0.8.5)
|
53
|
+
rails (>= 3.0, < 4.0)
|
54
|
+
rspec-rails
|
55
|
+
git (1.2.5)
|
56
|
+
hike (1.2.1)
|
57
|
+
i18n (0.6.0)
|
58
|
+
jeweler (1.8.3)
|
59
|
+
bundler (~> 1.0)
|
60
|
+
git (>= 1.2.5)
|
61
|
+
rake
|
62
|
+
rdoc
|
63
|
+
journey (1.0.3)
|
64
|
+
json (1.7.3)
|
65
|
+
libwebsocket (0.1.3)
|
66
|
+
addressable
|
67
|
+
mail (2.4.4)
|
68
|
+
i18n (>= 0.4.0)
|
69
|
+
mime-types (~> 1.16)
|
70
|
+
treetop (~> 1.4.8)
|
71
|
+
mime-types (1.18)
|
72
|
+
minitest (3.0.0)
|
73
|
+
multi_json (1.3.6)
|
74
|
+
nokogiri (1.5.2)
|
75
|
+
polyglot (0.3.3)
|
76
|
+
rack (1.4.1)
|
77
|
+
rack-cache (1.2)
|
78
|
+
rack (>= 0.4)
|
79
|
+
rack-ssl (1.3.2)
|
80
|
+
rack
|
81
|
+
rack-test (0.6.1)
|
82
|
+
rack (>= 1.0)
|
83
|
+
rails (3.2.3)
|
84
|
+
actionmailer (= 3.2.3)
|
85
|
+
actionpack (= 3.2.3)
|
86
|
+
activerecord (= 3.2.3)
|
87
|
+
activeresource (= 3.2.3)
|
88
|
+
activesupport (= 3.2.3)
|
89
|
+
bundler (~> 1.0)
|
90
|
+
railties (= 3.2.3)
|
91
|
+
railties (3.2.3)
|
92
|
+
actionpack (= 3.2.3)
|
93
|
+
activesupport (= 3.2.3)
|
94
|
+
rack-ssl (~> 1.3.2)
|
95
|
+
rake (>= 0.8.7)
|
96
|
+
rdoc (~> 3.4)
|
97
|
+
thor (~> 0.14.6)
|
98
|
+
rake (0.9.2.2)
|
99
|
+
rdoc (3.12)
|
100
|
+
json (~> 1.4)
|
101
|
+
rspec (2.10.0)
|
102
|
+
rspec-core (~> 2.10.0)
|
103
|
+
rspec-expectations (~> 2.10.0)
|
104
|
+
rspec-mocks (~> 2.10.0)
|
105
|
+
rspec-core (2.10.1)
|
106
|
+
rspec-expectations (2.10.0)
|
107
|
+
diff-lcs (~> 1.1.3)
|
108
|
+
rspec-mocks (2.10.1)
|
109
|
+
rspec-rails (2.10.1)
|
110
|
+
actionpack (>= 3.0)
|
111
|
+
activesupport (>= 3.0)
|
112
|
+
railties (>= 3.0)
|
113
|
+
rspec (~> 2.10.0)
|
114
|
+
rubyzip (0.9.8)
|
115
|
+
selenium-webdriver (2.21.2)
|
116
|
+
childprocess (>= 0.2.5)
|
117
|
+
ffi (~> 1.0)
|
118
|
+
libwebsocket (~> 0.1.3)
|
119
|
+
multi_json (~> 1.0)
|
120
|
+
rubyzip
|
121
|
+
simplecov (0.6.2)
|
122
|
+
multi_json (~> 1.3)
|
123
|
+
simplecov-html (~> 0.5.3)
|
124
|
+
simplecov-html (0.5.3)
|
125
|
+
spork (1.0.0rc3)
|
126
|
+
sprockets (2.1.3)
|
127
|
+
hike (~> 1.2)
|
128
|
+
rack (~> 1.0)
|
129
|
+
tilt (~> 1.1, != 1.3.0)
|
130
|
+
sqlite3 (1.3.6)
|
131
|
+
sqlite3-ruby (1.3.3)
|
132
|
+
sqlite3 (>= 1.3.3)
|
133
|
+
thor (0.14.6)
|
134
|
+
tilt (1.3.3)
|
135
|
+
treetop (1.4.10)
|
136
|
+
polyglot
|
137
|
+
polyglot (>= 0.3.1)
|
138
|
+
tzinfo (0.3.33)
|
139
|
+
watchr (0.7)
|
140
|
+
with_model (0.2.6)
|
141
|
+
activerecord (>= 2.3.5, < 4.0.0)
|
142
|
+
rspec (< 3)
|
143
|
+
xpath (0.1.4)
|
144
|
+
nokogiri (~> 1.3)
|
145
|
+
|
146
|
+
PLATFORMS
|
147
|
+
ruby
|
148
|
+
|
149
|
+
DEPENDENCIES
|
150
|
+
bundler (>= 1.0.0)
|
151
|
+
capybara (>= 0.4.0)
|
152
|
+
database_cleaner
|
153
|
+
factory_girl_rails
|
154
|
+
generator_spec
|
155
|
+
jeweler (>= 1.8.3)
|
156
|
+
minitest
|
157
|
+
rails (>= 3.2.0)
|
158
|
+
rdoc (~> 3.12)
|
159
|
+
rspec-rails (>= 2.8.0)
|
160
|
+
simplecov
|
161
|
+
spork (~> 1.0rc)
|
162
|
+
sqlite3
|
163
|
+
sqlite3-ruby
|
164
|
+
watchr
|
165
|
+
with_model (>= 0.1.5)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rdoc/task'
|
11
|
+
|
12
|
+
require 'rspec/core'
|
13
|
+
require 'rspec/core/rake_task'
|
14
|
+
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
|
17
|
+
task :default => :spec
|
18
|
+
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'REA'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README.md')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
26
|
+
|
27
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
28
|
+
load 'rails/tasks/engine.rake'
|
29
|
+
|
30
|
+
Bundler::GemHelper.install_tasks
|
31
|
+
|
32
|
+
task :default => :spec
|
33
|
+
|
34
|
+
require 'jeweler'
|
35
|
+
Jeweler::Tasks.new do |gem|
|
36
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
37
|
+
gem.name = "engine-rea"
|
38
|
+
gem.homepage = "http://github.com/lazing/rea"
|
39
|
+
gem.license = "MIT"
|
40
|
+
gem.summary = %Q{Rails Engine for MDA pattern Resource Event Agent}
|
41
|
+
gem.description = %Q{
|
42
|
+
follow REA model
|
43
|
+
}
|
44
|
+
gem.email = "lazing@gmail.com"
|
45
|
+
gem.authors = ["Ryan Wong"]
|
46
|
+
# dependencies defined in Gemfile
|
47
|
+
end
|
48
|
+
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'thread'
|
2
|
+
module Rea
|
3
|
+
class Identifier < ActiveRecord::Base
|
4
|
+
attr_accessible :name, :value_reset_rule, :id_rule
|
5
|
+
SEM = Mutex.new
|
6
|
+
|
7
|
+
validates_presence_of :name, :id_rule
|
8
|
+
validate :instance_validations
|
9
|
+
|
10
|
+
def generate
|
11
|
+
SEM.synchronize do
|
12
|
+
self.class.transaction do
|
13
|
+
if value_reset_rule
|
14
|
+
self.last_value = 0 if self.instance_eval(value_reset_rule)
|
15
|
+
end
|
16
|
+
self.last_value = (self.last_value) || 0
|
17
|
+
self.last_value = self.last_value + 1
|
18
|
+
self.save!
|
19
|
+
self.instance_eval "\"#{id_rule}\""
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def instance_validations
|
26
|
+
if id_rule
|
27
|
+
begin
|
28
|
+
self.instance_eval "\"#{id_rule}\""
|
29
|
+
rescue Exception => e
|
30
|
+
errors.add :id_rule, :malformed, :error_message=> e.message
|
31
|
+
end
|
32
|
+
end
|
33
|
+
if value_reset_rule
|
34
|
+
begin
|
35
|
+
self.instance_eval value_reset_rule
|
36
|
+
rescue Exception => e
|
37
|
+
errors.add :value_reset_rule, :malformed, :error_message=> e.message
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Rea</title>
|
5
|
+
<%= stylesheet_link_tag "rea/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "rea/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateReaCategoryTypes < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :rea_category_types do |t|
|
4
|
+
t.string :name
|
5
|
+
t.references :group
|
6
|
+
t.string :group_type
|
7
|
+
t.boolean :system
|
8
|
+
t.boolean :automatic
|
9
|
+
t.boolean :multiple
|
10
|
+
end
|
11
|
+
add_index :rea_category_types, [:group_id, :group_type]
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateReaCategories < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :rea_categories do |t|
|
4
|
+
t.string :name
|
5
|
+
t.references :category_type
|
6
|
+
t.references :category
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :rea_categories, :category_type_id
|
10
|
+
add_index :rea_categories, :category_id
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateReaCategoryMembers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :rea_category_members do |t|
|
4
|
+
t.references :entity
|
5
|
+
t.string :entity_type
|
6
|
+
t.references :category
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :rea_category_members, [:entity_id, :entity_type]
|
10
|
+
add_index :rea_category_members, :category_id
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Rea::InstallGenerator < Rails::Generators::Base
|
2
|
+
include Rails::Generators::Migration
|
3
|
+
source_root File.expand_path('../../../../../db/migrate', __FILE__)
|
4
|
+
def self.next_migration_number(path)
|
5
|
+
unless @prev_migration_nr
|
6
|
+
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
7
|
+
else
|
8
|
+
@prev_migration_nr += 1
|
9
|
+
end
|
10
|
+
@prev_migration_nr.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
def copy_migrations
|
14
|
+
base_path = Pathname.new(self.class.source_root)
|
15
|
+
Dir[File.join(self.class.source_root, '*.rb')].each do |full_path|
|
16
|
+
path = Pathname.new(full_path).relative_path_from(base_path).to_s
|
17
|
+
migration_template path, "db/migrate/"+path.gsub(/\d+_([\w\d\.]+)/, '\1')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Rea
|
2
|
+
module Dsl
|
3
|
+
module Behavioral
|
4
|
+
def self.included base
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_id_string
|
9
|
+
self.send("#{self.class.identifier_field}=", Rea::Identifier.find_last_by_name(self.class.identifier).try(:generate))
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def classification name, options={}, &block
|
14
|
+
precontext = @context
|
15
|
+
@context = @context.category_types.find_or_create_by_name name, options
|
16
|
+
block.call if block_given?
|
17
|
+
@context = precontext
|
18
|
+
end
|
19
|
+
|
20
|
+
def category *category_names, &block
|
21
|
+
options = category_names.extract_options!
|
22
|
+
category_names.flatten.each do |name|
|
23
|
+
attr_name = @context.is_a?(Rea::Category) ? :child_categories : :categories
|
24
|
+
precontext = @context
|
25
|
+
@context = @context.send(attr_name).find_or_create_by_name name, options
|
26
|
+
block.call if block_given?
|
27
|
+
@context = precontext
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def identification name, options={}
|
32
|
+
cattr_accessor :identifier, :identifier_field
|
33
|
+
self.identifier = name
|
34
|
+
self.identifier_field = options.delete(:identifier_field) || :sn
|
35
|
+
self.before_create :create_id_string
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|