simple_workflow 0.0.2 → 0.0.3

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/History.txt CHANGED
@@ -1,8 +1,17 @@
1
+ == 0.0.3 2012-01-05
2
+
3
+ === Fixes
4
+
5
+ * Allow input to with_detour to be a URL string
6
+
7
+
1
8
  == 0.0.2 2009-05-15
2
9
 
3
10
  === Fixes
11
+
4
12
  * Added missing simple_workflow_helper.rb file to manifest
5
13
 
14
+
6
15
  == 0.0.1 2009-05-15
7
16
 
8
17
  * 1 major enhancement:
data/Rakefile CHANGED
@@ -1,29 +1,18 @@
1
- require 'rubygems' unless ENV['NO_RUBYGEMS']
2
- %w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
3
- require File.dirname(__FILE__) + '/lib/simple_workflow'
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require File.dirname(__FILE__) + '/lib/simple_workflow/version'
4
4
 
5
- # Generate all the Rake tasks
6
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
7
- $hoe = Hoe.new('simple_workflow', SimpleWorkflow::VERSION) do |p|
8
- p.developer('Uwe Kubosch', 'uwe@kubosch.no')
9
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
10
- p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
11
- p.rubyforge_name = 'ruby-shoppe'
12
- p.extra_deps = [
13
- ['rails','>= 2.3.2'],
14
- ]
15
- p.extra_dev_deps = [
16
- ['newgem', ">= #{::Newgem::VERSION}"]
17
- ]
18
-
19
- p.clean_globs |= %w[**/.DS_Store tmp *.log]
20
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
21
- p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
22
- p.rsync_args = '-av --delete --ignore-errors'
23
- end
5
+ GEM_FILE = "simple_workflow-#{SimpleWorkflow::VERSION}.gem"
6
+ GEM_SPEC_FILE = 'simple_workflow.gemspec'
7
+
8
+ CLEAN.include('simple_workflow-*.gem', 'tmp')
24
9
 
25
- require 'newgem/tasks' # load /tasks/*.rake
26
- Dir['tasks/**/*.rake'].each { |t| load t }
10
+ task :default => :gem
27
11
 
28
- # TODO - want other tests/tasks run by default? Add them to the list
29
- # task :default => [:spec, :features]
12
+ desc "Generate a gem"
13
+ task :gem => GEM_FILE
14
+
15
+ file GEM_FILE => GEM_SPEC_FILE do
16
+ puts "Generating #{GEM_FILE}"
17
+ `gem build #{GEM_SPEC_FILE}`
18
+ end
@@ -1,8 +1,15 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
- module SimpleWorkflow
5
- VERSION = '0.0.2'
4
+ require 'simple_workflow/version'
5
+ require 'simple_workflow/helper'
6
+ require 'simple_workflow/controller'
7
+
8
+ module ApplicationHelper
9
+ include SimpleWorkflow::Helper
6
10
  end
7
11
 
8
- require 'simple_workflow/simple_workflow_helper'
12
+ class ApplicationController
13
+ include SimpleWorkflow::Helper
14
+ include SimpleWorkflow::Controller
15
+ end
@@ -0,0 +1,76 @@
1
+ module SimpleWorkflow::Controller
2
+ def detour_to(options)
3
+ store_detour(params)
4
+ redirect_to(options)
5
+ end
6
+
7
+ def rjs_detour_to(options)
8
+ store_detour(params, request.post?)
9
+ rjs_redirect_to(options)
10
+ end
11
+
12
+ def rjs_redirect_to(options)
13
+ @options = options
14
+ render :template => 'redirect', :layout => false
15
+ end
16
+
17
+ def store_detour(options, post = false)
18
+ options[:request_method] = :post if post
19
+ if session[:detours] && session[:detours].last == options
20
+ logger.debug "duplicate detour: #{options}"
21
+ return
22
+ end
23
+ logger.debug "adding detour: #{options}"
24
+ session[:detours] ||= []
25
+ session[:detours] << options
26
+ end
27
+
28
+ def store_detour_from_params
29
+ if params[:detour]
30
+ store_detour(params[:detour])
31
+ end
32
+ if params[:return_from_detour] && session[:detours]
33
+ pop_detour
34
+ end
35
+ end
36
+
37
+ def back
38
+ return false if session[:detours].nil?
39
+ detour = pop_detour
40
+ post = detour.delete(:request_method) == :post
41
+ if post
42
+ redirect_to_post(detour)
43
+ else
44
+ redirect_to detour
45
+ end
46
+ return true
47
+ end
48
+
49
+ def back_or_redirect_to(options)
50
+ back or redirect_to options
51
+ end
52
+
53
+ def pop_detour
54
+ detours = session[:detours]
55
+ return nil unless detours
56
+ detour = detours.pop
57
+ logger.debug "popped detour: #{detour.inspect} #{session[:detours].size} more"
58
+ if detours.empty?
59
+ session[:detours] = nil
60
+ end
61
+ detour
62
+ end
63
+
64
+ def redirect_to_post(options)
65
+ url = url_for options
66
+ render :text => <<EOF, :layout => false
67
+ <html>
68
+ <body onload="document.getElementById('form').submit()">
69
+ <form id="form" action="#{url}" method="POST">
70
+ </form>
71
+ </body>
72
+ </html>
73
+ EOF
74
+ end
75
+
76
+ end
@@ -0,0 +1,55 @@
1
+ module SimpleWorkflow::Helper
2
+ def image_button_to(image_source, title, options, html_options = {})
3
+ image_submit_tag image_source, {:class => 'image-submit', :alt => title, :title => title,
4
+ :id => "#{title}_#{options[:id]}", :name => title,
5
+ :onclick => "form.action='#{url_for(options)}'"}.update(html_options)
6
+ end
7
+
8
+ def detour_to(title, options, html_options = nil)
9
+ link_to title, with_detour(options), html_options
10
+ end
11
+
12
+ def with_detour(options)
13
+ detour_options = {:detour => params.reject { |k, v| [:detour, :return_from_detour].include? k.to_sym }}.update(options)
14
+ if options[:layout]== false
15
+ if params[:action] !~ /_no_layout$/
16
+ detour_options[:detour].update({:action => params[:action] + '_no_layout'})
17
+ end
18
+ elsif params[:action] =~ /_no_layout$/
19
+ detour_options[:detour].update({:action => params[:action][0..-11]})
20
+ end
21
+ detour_options
22
+ end
23
+
24
+ def image_detour_to(image_source, title, url_options, image_options = nil, post = false)
25
+ image_options ||= {:class => 'image-submit'}
26
+ image_options.update :alt => title, :title => title
27
+ detour_to image_tag(image_source, image_options), url_options, post ? {:method => :post} : nil
28
+ end
29
+
30
+ def image_link_to(image_source, title, url_options, image_options = nil, post = false)
31
+ image_options ||= {:class => 'image-submit'}
32
+ image_options.update :alt => title, :title => title
33
+ link_to image_tag(image_source, image_options), url_options, post ? {:method => :post} : nil
34
+ end
35
+
36
+ def image_link_to_remote(image_source, title, link_options, image_options = nil, post = false)
37
+ image_options ||= {:class => 'image-submit'}
38
+ image_options.update :alt => title, :title => title
39
+ with_params = link_options.delete(:with)
40
+ link_to_remote image_tag(image_source, image_options), :url => link_options, :with => with_params, :html => post ? {:method => :post} : {}
41
+ end
42
+
43
+ def detour?
44
+ not session[:detours].nil?
45
+ end
46
+
47
+ def back_or_link_to(title, options = nil)
48
+ if session[:detours]
49
+ options = {:return_from_detour => true}.update(session[:detours].last)
50
+ logger.debug "linked return from detour: #{options}"
51
+ end
52
+ link_to(title, options) if options
53
+ end
54
+
55
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleWorkflow
2
+ VERSION = '0.0.3'
3
+ end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
5
11
  platform: ruby
6
12
  authors:
7
13
  - Uwe Kubosch
@@ -9,93 +15,76 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-05-15 00:00:00 +02:00
13
- default_executable:
18
+ date: 2012-01-05 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rails
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 2
31
+ - 3
32
+ - 2
23
33
  version: 2.3.2
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: newgem
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.4.1
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: hoe
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.8.0
44
- version:
45
- description: FIX (describe your package)
46
- email:
47
- - uwe@kubosch.no
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Expands Ruby On Rails to allow simple detour workflows.
37
+ email: uwe@kubosch.no
48
38
  executables: []
49
39
 
50
40
  extensions: []
51
41
 
52
- extra_rdoc_files:
53
- - History.txt
54
- - Manifest.txt
55
- - PostInstall.txt
56
- - README.rdoc
42
+ extra_rdoc_files: []
43
+
57
44
  files:
58
45
  - History.txt
59
46
  - Manifest.txt
60
47
  - PostInstall.txt
61
- - README.rdoc
62
48
  - Rakefile
49
+ - README.rdoc
50
+ - lib/simple_workflow/controller.rb
51
+ - lib/simple_workflow/helper.rb
52
+ - lib/simple_workflow/version.rb
63
53
  - lib/simple_workflow.rb
64
- - lib/simple_workflow/simple_workflow_helper.rb
65
- - script/console
66
- - script/destroy
67
- - script/generate
68
54
  - test/test_helper.rb
69
55
  - test/test_simple_workflow.rb
70
- has_rdoc: true
71
- homepage: http://github.com/#{github_username}/#{project_name}
56
+ homepage: https://github.com/donv/simple_workflow
72
57
  licenses: []
73
58
 
74
- post_install_message: PostInstall.txt
75
- rdoc_options:
76
- - --main
77
- - README.rdoc
59
+ post_install_message:
60
+ rdoc_options: []
61
+
78
62
  require_paths:
79
63
  - lib
80
64
  required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
81
66
  requirements:
82
67
  - - ">="
83
68
  - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
84
72
  version: "0"
85
- version:
86
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
87
75
  requirements:
88
76
  - - ">="
89
77
  - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
90
81
  version: "0"
91
- version:
92
82
  requirements: []
93
83
 
94
84
  rubyforge_project: ruby-shoppe
95
- rubygems_version: 1.3.2
85
+ rubygems_version: 1.8.8
96
86
  signing_key:
97
87
  specification_version: 3
98
- summary: FIX (describe your package)
99
- test_files:
100
- - test/test_helper.rb
101
- - test/test_simple_workflow.rb
88
+ summary: Add simple "detour" workflow to Ruby On Rails.
89
+ test_files: []
90
+
@@ -1,131 +0,0 @@
1
- module SimpleWorkflowHelper
2
- def image_button_to(image_source, title, options, html_options = {})
3
- image_submit_tag image_source, {:class => 'image-submit', :alt => title, :title => title,
4
- :id => "#{title}_#{options[:id]}", :name => title,
5
- :onclick => "form.action='#{url_for(options)}'"}.update(html_options)
6
- end
7
-
8
- def detour_to(title, options, html_options = nil)
9
- link_to title, with_detour(options), html_options
10
- end
11
-
12
- def with_detour(options)
13
- detour_options = {:detour => params.reject {|k, v| [:detour, :return_from_detour].include? k.to_sym}}.update(options)
14
- if options[:layout]== false
15
- if params[:action] !~ /_no_layout$/
16
- detour_options[:detour].update({:action => params[:action] + '_no_layout'})
17
- end
18
- elsif params[:action] =~ /_no_layout$/
19
- detour_options[:detour].update({:action => params[:action][0..-11]})
20
- end
21
- detour_options
22
- end
23
-
24
- def image_detour_to(image_source, title, url_options, image_options = nil, post = false)
25
- image_options ||= {:class => 'image-submit'}
26
- image_options.update :alt => title, :title => title
27
- detour_to image_tag(image_source, image_options), url_options, post ? {:method => :post} : nil
28
- end
29
-
30
- def image_link_to(image_source, title, url_options, image_options = nil, post = false)
31
- image_options ||= {:class => 'image-submit'}
32
- image_options.update :alt => title, :title => title
33
- link_to image_tag(image_source, image_options), url_options, post ? {:method => :post} : nil
34
- end
35
-
36
- def image_link_to_remote(image_source, title, url_options, image_options = nil, post = false)
37
- image_options ||= {:class => 'image-submit'}
38
- image_options.update :alt => title, :title => title
39
- link_to_remote image_tag(image_source, image_options), {:url => url_options}, post ? {:method => :post} : nil
40
- end
41
-
42
- def detour?
43
- not session[:detours].nil?
44
- end
45
-
46
- def back_or_link_to(title, options = nil, html_options = nil)
47
- if session[:detours]
48
- options = {:return_from_detour => true}.update(session[:detours].last)
49
- logger.debug "linked return from detour: #{options}"
50
- end
51
- link_to(title, options, html_options) if options
52
- end
53
-
54
- end
55
-
56
- module SimpleWorkflowController
57
- def detour_to(options)
58
- store_detour(params)
59
- redirect_to(options)
60
- end
61
-
62
- def rjs_detour_to(options)
63
- store_detour(params, request.post?)
64
- rjs_redirect_to(options)
65
- end
66
-
67
- def rjs_redirect_to(options)
68
- @options = options
69
- render :template => 'redirect', :layout => false
70
- end
71
-
72
- def store_detour(options, post = false)
73
- options[:request_method] = :post if post
74
- if session[:detours] && session[:detours].last == options
75
- logger.debug "duplicate detour: #{options}"
76
- return
77
- end
78
- logger.debug "adding detour: #{options}"
79
- session[:detours] ||= []
80
- session[:detours] << options
81
- end
82
-
83
- def store_detour_from_params
84
- if params[:detour]
85
- store_detour(params[:detour])
86
- end
87
- if params[:return_from_detour] && session[:detours]
88
- pop_detour
89
- end
90
- end
91
-
92
- def back
93
- return false if session[:detours].nil?
94
- detour = pop_detour
95
- post = detour.delete(:request_method) == :post
96
- if post
97
- redirect_to_post(detour)
98
- else
99
- redirect_to detour
100
- end
101
- return true
102
- end
103
-
104
- def back_or_redirect_to(options)
105
- back or redirect_to options
106
- end
107
-
108
- def pop_detour
109
- detours = session[:detours]
110
- return nil unless detours
111
- detour = detours.pop
112
- logger.debug "popped detour: #{detour.inspect} #{session[:detours].size} more"
113
- if detours.empty?
114
- session[:detours] = nil
115
- end
116
- detour
117
- end
118
-
119
- def redirect_to_post(options)
120
- url = url_for options
121
- render :text => <<EOF, :layout => false
122
- <html>
123
- <body onload="document.getElementById('form').submit()">
124
- <form id="form" action="#{url}" method="POST">
125
- </form>
126
- </body>
127
- </html>
128
- EOF
129
- end
130
-
131
- end
data/script/console DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/simple_workflow.rb'}"
9
- puts "Loading simple_workflow gem"
10
- exec "#{irb} #{libs} --simple-prompt"
data/script/destroy DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)