forked from mantor/floristry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit de9fc36
Showing
83 changed files
with
2,233 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Gemfile.lock | ||
.bundle/ | ||
log/*.log | ||
pkg/ | ||
spec/dummy/db/*.sqlite3 | ||
spec/dummy/log/*.log | ||
spec/dummy/tmp/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
source "http://rubygems.org" | ||
|
||
# Declare your gem's dependencies in ruote-trail-on-rails.gemspec. | ||
# Bundler will treat runtime dependencies like base dependencies, and | ||
# development dependencies will be added by default to the :development group. | ||
gemspec | ||
|
||
# jquery-rails is used by the dummy application | ||
gem "jquery-rails" | ||
|
||
# Declare any dependencies that are still in development here instead of in | ||
# your gemspec. These might include edge Rails or gems from your path or | ||
# Git. Remember to move these dependencies to your gemspec before releasing | ||
# your gem to rubygems.org. | ||
|
||
# To use debugger | ||
# gem 'ruby-debug' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# WARNING | ||
NOT READY FOR PRODUCTION | ||
|
||
# RuoteTrail | ||
|
||
The goal of this gem is to help you represent [Ruote's workflows](http://ruote.rubyforge.org/) using standard Rails | ||
facilities, e.g. partials, helpers, render, models, etc. | ||
|
||
Ruote::Trail is an [isolated engine](http://guides.rubyonrails.org/engines.html) which provides basic | ||
behaviors and representation of Ruote's Flow Expression, e.g. define, sequence, concurrence, if, wait, participant, inc, | ||
set. You can easily override their default behaviors and representations by defining your own in your application. | ||
|
||
Adding new behaviors to the `participant expression` can be done by creating a new model in: | ||
|
||
/app/models/ruote_trail/participant.rb | ||
|
||
To override a view, simply create a new one in: | ||
|
||
/app/views/ruote_trail/_participant.html.erb. | ||
|
||
## Hierarchy | ||
|
||
- Expression | ||
- Leaf Expression | ||
- Participant | ||
- If | ||
- Wait | ||
- ... | ||
- Branch Expression | ||
- Define | ||
- Sequence | ||
- Concurrence | ||
- ... | ||
|
||
## Installation | ||
|
||
TODO | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
gem 'ruote-trail-on-rails' | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install ruote-trail-on-rails | ||
|
||
Then register the service in the ruote engine: | ||
|
||
```ruby | ||
RuoteKit.engine.add_service('trail', | ||
'ruote/trail/observer', | ||
'RuoteTrail::Observer', | ||
'archive' => 'Ruote::Trail::Archive::ActiveRecord') | ||
``` | ||
|
||
## Usage | ||
|
||
New behaviors ca be added to low-level Expression such as Expression (root), BranchExpression or LeafExpression | ||
to affect all Expressions at once, only Leaves or only Branches. | ||
|
||
Create a file called /config/initializers/ruote-trail-on-rails.rb containing modules with the desired behaviors. Then | ||
use the following config to define which module will be included in the which low-level Expression. | ||
|
||
```ruby | ||
module RuoteTrailBranchBehavior | ||
def xyz | ||
# ... | ||
end | ||
|
||
# ... | ||
end | ||
|
||
RuoteTrail.configure do |config| | ||
config.add_branch_expression_behavior = RuoteTrailBranchBehavior | ||
#config.add_leaf_expression_behavior = RuoteTrailLeafBehavior | ||
#config.add_expression_behavior = RuoteTrailBehavior | ||
end | ||
``` | ||
|
||
### :pass, :present, :future | ||
|
||
The following methods are available on each Expressions to identify its era: | ||
|
||
``` | ||
active? | ||
disabled? | ||
in_past? | ||
in_present? | ||
in_future? | ||
``` | ||
|
||
## TODO | ||
|
||
1. Extract RuoteTrail::Observer in a separate gem. | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request | ||
|
||
## License | ||
|
||
GPLv2 | ||
|
||
## Source | ||
|
||
https://github.com/northox/ruote-trail-on-rails | ||
|
||
## Author | ||
|
||
Danny Fullerton - Mantor Organization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env rake | ||
begin | ||
require 'bundler/setup' | ||
rescue LoadError | ||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks' | ||
end | ||
begin | ||
require 'rdoc/task' | ||
rescue LoadError | ||
require 'rdoc/rdoc' | ||
require 'rake/rdoctask' | ||
RDoc::Task = Rake::RDocTask | ||
end | ||
|
||
RDoc::Task.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'RuoteTrail' | ||
rdoc.options << '--line-numbers' | ||
rdoc.rdoc_files.include('README.rdoc') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
|
||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) | ||
load 'rails/tasks/engine.rake' | ||
|
||
|
||
|
||
Bundler::GemHelper.install_tasks | ||
|
||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.libs << 'test' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = false | ||
end | ||
|
||
|
||
task :default => :test |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// This is a manifest file that'll be compiled into application.js, which will include all the files | ||
// listed below. | ||
// | ||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | ||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. | ||
// | ||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
// the compiled file. | ||
// | ||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD | ||
// GO AFTER THE REQUIRES BELOW. | ||
// | ||
//= require jquery | ||
//= require jquery_ujs | ||
//= require_tree . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* This is a manifest file that'll be compiled into application.css, which will include all the files | ||
* listed below. | ||
* | ||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, | ||
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. | ||
* | ||
* You're free to add application-wide styles to this file and they'll appear at the top of the | ||
* compiled file, but it's generally better to create a new file per style scope. | ||
* | ||
*= require_self | ||
*= require_tree . | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module RuoteTrail | ||
class ApplicationController < ActionController::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module RuoteTrail | ||
module ApplicationHelper | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module RuoteTrail | ||
class BranchExpression < Expression | ||
attr_reader :children | ||
|
||
def initialize (id, name, params = {}, workitem = {}, era = :present) | ||
|
||
super(id, name, params, workitem, era) | ||
|
||
@children = Array.new | ||
|
||
mod = RuoteTrail.configuration.add_branch_expression_behavior | ||
self.class.send(:include, mod) if mod | ||
end | ||
|
||
def << (child) @children << child end | ||
|
||
def each (&block) @children.each(&block) end | ||
|
||
def [] (id) @children[id] end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module RuoteTrail | ||
class Concurrence < BranchExpression | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module RuoteTrail | ||
class Define < BranchExpression | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
module RuoteTrail | ||
class Expression | ||
attr_reader :id, :name, :params, :workitem, :era | ||
|
||
def initialize(id, name, params = {}, workitem = {}, era = :present) | ||
|
||
@id = id | ||
@name = name # TODO validate name ... | ||
@params = params | ||
@workitem = workitem | ||
@era = era | ||
|
||
mod = RuoteTrail.configuration.add_expression_behavior | ||
self.class.send(:include, mod) if mod | ||
end | ||
|
||
def active?() @era == :present end | ||
def inactive?() @era != :present end | ||
# alias inactive? disabled? | ||
|
||
def is_past?() @era == :past end | ||
def is_present?() @era == :present end | ||
def is_future?() @era == :future end | ||
|
||
def layout() false end | ||
|
||
def to_partial_path | ||
|
||
self.class.name.underscore | ||
end | ||
|
||
# Returns proper Expression type based on name. | ||
# | ||
# Anything not a Ruote Expression is considered a Participant Expression, e.g., | ||
# if == If, sequence == Sequence, admin == Participant | ||
# | ||
def self.factory(id, era = :present, exp = nil) | ||
|
||
name, workitem, params = params_workitem(id, era, exp) | ||
|
||
klass = is_expression?(name.camelize) ? RuoteTrail::const_get(name.camelize) : RuoteTrail::Participant | ||
klass.new(id, name, params, workitem, era) | ||
end | ||
|
||
protected | ||
|
||
def self.is_expression?(name) | ||
|
||
RuoteTrail.const_get(name) < RuoteTrail::Expression | ||
true | ||
|
||
rescue NameError # TODO - low priority - could this be cleaner? avoid exception? | ||
false | ||
|
||
end | ||
|
||
def self.params_workitem(id, era, exp = nil) | ||
|
||
case era | ||
when :present | ||
wi = RuoteKit.storage_participant[id] | ||
[ | ||
wi.participant_name, | ||
wi.fields.except(:params), | ||
wi.params | ||
] | ||
when :past | ||
if exp[1]['fields'].nil? | ||
[ | ||
exp[0], | ||
{}, | ||
{} | ||
] | ||
elsif exp[1]['fields']['params'].nil? | ||
[ | ||
exp[0], | ||
exp[1]['fields'], | ||
{} | ||
] | ||
else | ||
[ | ||
exp[0], | ||
exp[1]['fields'].except(:params), | ||
exp[1]['fields']['params'] | ||
] | ||
end | ||
when :future # TODO should be load from non-trail to capture on-the-fly process modifications? Just like Present. | ||
[ | ||
exp[0], | ||
{}, | ||
exp[1] | ||
] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module RuoteTrail | ||
class If < LeafExpression | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module RuoteTrail | ||
class LeafExpression < Expression | ||
|
||
def initialize(id, name, params = {}, workitem = {}, era = :present) | ||
|
||
super(id, name, params, workitem, era) # TODO *args? | ||
|
||
mod = RuoteTrail.configuration.add_leaf_expression_behavior | ||
self.class.send(:include, mod) if mod | ||
end | ||
|
||
def layout | ||
'layouts/ruote_trail/leaf-expression' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module RuoteTrail | ||
class Participant < LeafExpression | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module RuoteTrail | ||
class Sequence < BranchExpression | ||
end | ||
end |
Oops, something went wrong.