stonepath 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +26 -0
- data/PostInstall.txt +2 -0
- data/README.rdoc +58 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/lib/stonepath/acl/controller.rb +86 -0
- data/lib/stonepath/acl/role.rb +53 -0
- data/lib/stonepath/acl/state.rb +20 -0
- data/lib/stonepath/acl.rb +3 -0
- data/lib/stonepath/config.rb +6 -0
- data/lib/stonepath/controller_hooks.rb +11 -0
- data/lib/stonepath/extensions/activerecordbase.rb +7 -0
- data/lib/stonepath/group.rb +9 -0
- data/lib/stonepath/role.rb +9 -0
- data/lib/stonepath/task.rb +76 -0
- data/lib/stonepath/work_bench.rb +11 -0
- data/lib/stonepath/work_item.rb +52 -0
- data/lib/stonepath/work_owner.rb +11 -0
- data/lib/stonepath.rb +50 -0
- data/rails_generators/stonepath/stonepath_audit_table_generator.rb +3 -0
- data/rails_generators/stonepath/stonepath_task_generator.rb +3 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/stonepath.gemspec +117 -0
- data/test/acl_test.rb +17 -0
- data/test/app_root/app/controllers/application_controller.rb +2 -0
- data/test/app_root/app/models/assignment.rb +11 -0
- data/test/app_root/app/models/case.rb +67 -0
- data/test/app_root/app/models/user.rb +10 -0
- data/test/app_root/config/boot.rb +114 -0
- data/test/app_root/config/database.yml +21 -0
- data/test/app_root/config/environment.rb +14 -0
- data/test/app_root/config/environments/in_memory.rb +0 -0
- data/test/app_root/config/environments/mysql.rb +0 -0
- data/test/app_root/config/environments/postgresql.rb +0 -0
- data/test/app_root/config/environments/sqlite.rb +0 -0
- data/test/app_root/config/environments/sqlite3.rb +0 -0
- data/test/app_root/config/routes.rb +4 -0
- data/test/app_root/db/migrate/01_create_users.rb +15 -0
- data/test/app_root/db/migrate/02_create_assignments.rb +13 -0
- data/test/app_root/db/migrate/03_create_cases.rb +15 -0
- data/test/app_root/lib/console_with_fixtures.rb +4 -0
- data/test/app_root/log/.gitignore +1 -0
- data/test/app_root/script/console +9 -0
- data/test/fixtures/users.yml +7 -0
- data/test/group_test.rb +20 -0
- data/test/role_test.rb +20 -0
- data/test/stonepath_test.rb +11 -0
- data/test/test_helper.rb +31 -0
- data/test/workitem_test.rb +11 -0
- data/test/workowner_test.rb +25 -0
- metadata +138 -0
data/stonepath.gemspec
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{stonepath}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["David Bock"]
|
12
|
+
s.date = %q{2009-12-17}
|
13
|
+
s.description = %q{Stateful workflow modeling for Rails}
|
14
|
+
s.email = %q{dbock@codesherpas.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"History.txt",
|
20
|
+
"Manifest.txt",
|
21
|
+
"PostInstall.txt",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/stonepath.rb",
|
26
|
+
"lib/stonepath/acl.rb",
|
27
|
+
"lib/stonepath/acl/controller.rb",
|
28
|
+
"lib/stonepath/acl/role.rb",
|
29
|
+
"lib/stonepath/acl/state.rb",
|
30
|
+
"lib/stonepath/config.rb",
|
31
|
+
"lib/stonepath/controller_hooks.rb",
|
32
|
+
"lib/stonepath/extensions/activerecordbase.rb",
|
33
|
+
"lib/stonepath/group.rb",
|
34
|
+
"lib/stonepath/role.rb",
|
35
|
+
"lib/stonepath/task.rb",
|
36
|
+
"lib/stonepath/work_bench.rb",
|
37
|
+
"lib/stonepath/work_item.rb",
|
38
|
+
"lib/stonepath/work_owner.rb",
|
39
|
+
"rails_generators/stonepath/stonepath_audit_table_generator.rb",
|
40
|
+
"rails_generators/stonepath/stonepath_task_generator.rb",
|
41
|
+
"script/console",
|
42
|
+
"script/destroy",
|
43
|
+
"script/generate",
|
44
|
+
"stonepath.gemspec",
|
45
|
+
"test/acl_test.rb",
|
46
|
+
"test/app_root/app/controllers/application_controller.rb",
|
47
|
+
"test/app_root/app/models/assignment.rb",
|
48
|
+
"test/app_root/app/models/case.rb",
|
49
|
+
"test/app_root/app/models/user.rb",
|
50
|
+
"test/app_root/config/boot.rb",
|
51
|
+
"test/app_root/config/database.yml",
|
52
|
+
"test/app_root/config/environment.rb",
|
53
|
+
"test/app_root/config/environments/in_memory.rb",
|
54
|
+
"test/app_root/config/environments/mysql.rb",
|
55
|
+
"test/app_root/config/environments/postgresql.rb",
|
56
|
+
"test/app_root/config/environments/sqlite.rb",
|
57
|
+
"test/app_root/config/environments/sqlite3.rb",
|
58
|
+
"test/app_root/config/routes.rb",
|
59
|
+
"test/app_root/db/migrate/01_create_users.rb",
|
60
|
+
"test/app_root/db/migrate/02_create_assignments.rb",
|
61
|
+
"test/app_root/db/migrate/03_create_cases.rb",
|
62
|
+
"test/app_root/lib/console_with_fixtures.rb",
|
63
|
+
"test/app_root/log/.gitignore",
|
64
|
+
"test/app_root/script/console",
|
65
|
+
"test/fixtures/users.yml",
|
66
|
+
"test/group_test.rb",
|
67
|
+
"test/role_test.rb",
|
68
|
+
"test/stonepath_test.rb",
|
69
|
+
"test/test_helper.rb",
|
70
|
+
"test/workitem_test.rb",
|
71
|
+
"test/workowner_test.rb"
|
72
|
+
]
|
73
|
+
s.homepage = %q{http://github.com/bokmann/stonepath}
|
74
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
75
|
+
s.require_paths = ["lib"]
|
76
|
+
s.rubygems_version = %q{1.3.5}
|
77
|
+
s.summary = %q{Stonepath: stateful workflow modeling for rails}
|
78
|
+
s.test_files = [
|
79
|
+
"test/acl_test.rb",
|
80
|
+
"test/app_root/app/controllers/application_controller.rb",
|
81
|
+
"test/app_root/app/models/assignment.rb",
|
82
|
+
"test/app_root/app/models/case.rb",
|
83
|
+
"test/app_root/app/models/user.rb",
|
84
|
+
"test/app_root/config/boot.rb",
|
85
|
+
"test/app_root/config/environment.rb",
|
86
|
+
"test/app_root/config/environments/in_memory.rb",
|
87
|
+
"test/app_root/config/environments/mysql.rb",
|
88
|
+
"test/app_root/config/environments/postgresql.rb",
|
89
|
+
"test/app_root/config/environments/sqlite.rb",
|
90
|
+
"test/app_root/config/environments/sqlite3.rb",
|
91
|
+
"test/app_root/config/routes.rb",
|
92
|
+
"test/app_root/db/migrate/01_create_users.rb",
|
93
|
+
"test/app_root/db/migrate/02_create_assignments.rb",
|
94
|
+
"test/app_root/db/migrate/03_create_cases.rb",
|
95
|
+
"test/app_root/lib/console_with_fixtures.rb",
|
96
|
+
"test/group_test.rb",
|
97
|
+
"test/role_test.rb",
|
98
|
+
"test/stonepath_test.rb",
|
99
|
+
"test/test_helper.rb",
|
100
|
+
"test/workitem_test.rb",
|
101
|
+
"test/workowner_test.rb"
|
102
|
+
]
|
103
|
+
|
104
|
+
if s.respond_to? :specification_version then
|
105
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
106
|
+
s.specification_version = 3
|
107
|
+
|
108
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
109
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 2.0.0"])
|
110
|
+
else
|
111
|
+
s.add_dependency(%q<activerecord>, [">= 2.0.0"])
|
112
|
+
end
|
113
|
+
else
|
114
|
+
s.add_dependency(%q<activerecord>, [">= 2.0.0"])
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
data/test/acl_test.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
class TestACL < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
end
|
9
|
+
|
10
|
+
context "our sample rails app" do
|
11
|
+
|
12
|
+
should "include the Group module when declared as a stonepath_group" do
|
13
|
+
assert true
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class Case < ActiveRecord::Base
|
2
|
+
include StonePath
|
3
|
+
|
4
|
+
stonepath_workitem
|
5
|
+
|
6
|
+
aasm_initial_state :pending
|
7
|
+
|
8
|
+
aasm_state :pending
|
9
|
+
aasm_state :in_process
|
10
|
+
aasm_state :completed
|
11
|
+
|
12
|
+
aasm_event :complete do
|
13
|
+
transitions :to => :completed, :from => :in_process
|
14
|
+
end
|
15
|
+
|
16
|
+
aasm_event :activate do
|
17
|
+
transitions :to => :in_process, :from => :pending
|
18
|
+
end
|
19
|
+
|
20
|
+
owned_by :user
|
21
|
+
subject_of :assignment
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
stonepath_acl do |acl|
|
26
|
+
|
27
|
+
acl.guard_method :save
|
28
|
+
acl.guard_method :name=
|
29
|
+
acl.guard_method :name
|
30
|
+
acl.guard_method :regarding=
|
31
|
+
acl.guard_method :regarding
|
32
|
+
|
33
|
+
acl.method_group :modifiers, [:save, :name=, :regarding=]
|
34
|
+
acl.method_group :accessors, [:name, :regarding]
|
35
|
+
|
36
|
+
acl.for_state :in_process do |state|
|
37
|
+
state.access_for_role :manager do |role|
|
38
|
+
role.allow_method :name
|
39
|
+
end
|
40
|
+
|
41
|
+
state.access_for_role :peon do |role|
|
42
|
+
role.deny_method :name=
|
43
|
+
role.deny_method :regarding=
|
44
|
+
end
|
45
|
+
|
46
|
+
state.access_for_role :assistant_manager do |role|
|
47
|
+
role.check_method_access :method_symbol do
|
48
|
+
return false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
acl.for_state :completed do |state|
|
54
|
+
state.access_for_role :manager do |role|
|
55
|
+
role.deny_method_group :modifiers
|
56
|
+
end
|
57
|
+
|
58
|
+
state.access_for_role :peon do |role|
|
59
|
+
role.deny_method_group :modifiers
|
60
|
+
role.deny_method_group :accessors
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# Allow customization of the rails framework path
|
2
|
+
RAILS_FRAMEWORK_ROOT = (ENV['RAILS_FRAMEWORK_ROOT'] || "#{File.dirname(__FILE__)}/../../../../../../vendor/rails") unless defined?(RAILS_FRAMEWORK_ROOT)
|
3
|
+
|
4
|
+
# Don't change this file!
|
5
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
6
|
+
|
7
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
8
|
+
|
9
|
+
module Rails
|
10
|
+
class << self
|
11
|
+
def boot!
|
12
|
+
unless booted?
|
13
|
+
preinitialize
|
14
|
+
pick_boot.run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def booted?
|
19
|
+
defined? Rails::Initializer
|
20
|
+
end
|
21
|
+
|
22
|
+
def pick_boot
|
23
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
24
|
+
end
|
25
|
+
|
26
|
+
def vendor_rails?
|
27
|
+
File.exist?(RAILS_FRAMEWORK_ROOT)
|
28
|
+
end
|
29
|
+
|
30
|
+
def preinitialize
|
31
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def preinitializer_path
|
35
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Boot
|
40
|
+
def run
|
41
|
+
load_initializer
|
42
|
+
Rails::Initializer.run(:set_load_path)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class VendorBoot < Boot
|
47
|
+
def load_initializer
|
48
|
+
require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/initializer"
|
49
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class GemBoot < Boot
|
54
|
+
def load_initializer
|
55
|
+
self.class.load_rubygems
|
56
|
+
load_rails_gem
|
57
|
+
require 'initializer'
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_rails_gem
|
61
|
+
if version = self.class.gem_version
|
62
|
+
gem 'rails', version
|
63
|
+
else
|
64
|
+
gem 'rails'
|
65
|
+
end
|
66
|
+
rescue Gem::LoadError => load_error
|
67
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
68
|
+
exit 1
|
69
|
+
end
|
70
|
+
|
71
|
+
class << self
|
72
|
+
def rubygems_version
|
73
|
+
Gem::RubyGemsVersion rescue nil
|
74
|
+
end
|
75
|
+
|
76
|
+
def gem_version
|
77
|
+
if defined? RAILS_GEM_VERSION
|
78
|
+
RAILS_GEM_VERSION
|
79
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
80
|
+
ENV['RAILS_GEM_VERSION']
|
81
|
+
else
|
82
|
+
parse_gem_version(read_environment_rb)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def load_rubygems
|
87
|
+
require 'rubygems'
|
88
|
+
min_version = '1.1.1'
|
89
|
+
unless rubygems_version >= min_version
|
90
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
91
|
+
exit 1
|
92
|
+
end
|
93
|
+
|
94
|
+
rescue LoadError
|
95
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
96
|
+
exit 1
|
97
|
+
end
|
98
|
+
|
99
|
+
def parse_gem_version(text)
|
100
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
def read_environment_rb
|
105
|
+
environment_rb = "#{RAILS_ROOT}/config/environment.rb"
|
106
|
+
environment_rb = "#{HELPER_RAILS_ROOT}/config/environment.rb" unless File.exists?(environment_rb)
|
107
|
+
File.read(environment_rb)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# All that for this:
|
114
|
+
Rails.boot!
|
@@ -0,0 +1,21 @@
|
|
1
|
+
in_memory:
|
2
|
+
adapter: sqlite3
|
3
|
+
database: ":memory:"
|
4
|
+
verbosity: quiet
|
5
|
+
sqlite:
|
6
|
+
adapter: sqlite
|
7
|
+
dbfile: plugin_test.sqlite.db
|
8
|
+
sqlite3:
|
9
|
+
adapter: sqlite3
|
10
|
+
dbfile: plugin_test.sqlite3.db
|
11
|
+
postgresql:
|
12
|
+
adapter: postgresql
|
13
|
+
username: postgres
|
14
|
+
password: postgres
|
15
|
+
database: plugin_test
|
16
|
+
mysql:
|
17
|
+
adapter: mysql
|
18
|
+
host: localhost
|
19
|
+
username: root
|
20
|
+
password:
|
21
|
+
database: plugin_test
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
2
|
+
|
3
|
+
Rails::Initializer.run do |config|
|
4
|
+
config.cache_classes = false
|
5
|
+
config.whiny_nils = true
|
6
|
+
config.action_controller.session = { :key => "_myapp_session", :secret => "gwirofjweroijger8924rt2zfwehfuiwehb1378rifowenfoqwphf23" }
|
7
|
+
config.plugin_locators.unshift(
|
8
|
+
Class.new(Rails::Plugin::Locator) do
|
9
|
+
def plugins
|
10
|
+
[Rails::Plugin.new(File.expand_path('.'))]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
) unless defined?(PluginTestHelper::PluginLocator)
|
14
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,4 @@
|
|
1
|
+
# Loads fixtures into the database when running the test app via the console
|
2
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, '../fixtures/*.{yml,csv}'))).each do |fixture_file|
|
3
|
+
Fixtures.create_fixtures(File.join(Rails.root, '../fixtures'), File.basename(fixture_file, '.*'))
|
4
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
data/test/group_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
class GroupTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
end
|
9
|
+
|
10
|
+
should "include the Group module when declared as a stonepath_group" do
|
11
|
+
assert Group.included_modules.include?(StonePath::Group)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
class Group
|
17
|
+
include StonePath
|
18
|
+
|
19
|
+
stonepath_group
|
20
|
+
end
|
data/test/role_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
class RoleTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
end
|
9
|
+
|
10
|
+
should "include the Role module when declared as a stonepath_role" do
|
11
|
+
assert Role.included_modules.include?(StonePath::Role)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
class Role
|
17
|
+
include StonePath
|
18
|
+
|
19
|
+
stonepath_role
|
20
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Set the default environment to sqlite3's in_memory database
|
2
|
+
ENV['RAILS_ENV'] ||= 'in_memory'
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'stringio'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'flexmock/test_unit'
|
8
|
+
require 'AASM'
|
9
|
+
require File.dirname(__FILE__) + '/../lib/stonepath'
|
10
|
+
|
11
|
+
|
12
|
+
# Load the Rails environment and testing framework
|
13
|
+
require "#{File.dirname(__FILE__)}/app_root/config/environment"
|
14
|
+
require 'test_help'
|
15
|
+
require 'action_view/test_case' # Load additional test classes not done automatically by < Rails 2.2.2
|
16
|
+
|
17
|
+
require "shoulda"
|
18
|
+
|
19
|
+
# Undo changes to RAILS_ENV
|
20
|
+
silence_warnings {RAILS_ENV = ENV['RAILS_ENV']}
|
21
|
+
|
22
|
+
# Run the migrations
|
23
|
+
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
|
24
|
+
|
25
|
+
# Set default fixture loading properties
|
26
|
+
ActiveSupport::TestCase.class_eval do
|
27
|
+
self.use_transactional_fixtures = true
|
28
|
+
self.use_instantiated_fixtures = false
|
29
|
+
self.fixture_path = "#{File.dirname(__FILE__)}/fixtures"
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class WorkownerTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
should "include the WorkOwner module when declared as a stonepath_workowner" do
|
9
|
+
assert Workowner.included_modules.include?(StonePath::WorkOwner)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "create a new user successfully" do
|
13
|
+
u = User.create
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
class Workowner < ActiveRecord::Base
|
19
|
+
include StonePath
|
20
|
+
|
21
|
+
stonepath_workowner
|
22
|
+
|
23
|
+
workowner_for :work_items
|
24
|
+
|
25
|
+
end
|