bumbleworks 0.0.4 → 0.0.6
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/Gemfile.lock +1 -1
- data/bumbleworks.gemspec +1 -1
- data/lib/bumbleworks.rb +17 -12
- data/lib/bumbleworks/configuration.rb +20 -24
- data/lib/bumbleworks/hash_storage.rb +7 -5
- data/lib/bumbleworks/storage_adapter.rb +6 -2
- data/lib/bumbleworks/version.rb +1 -1
- data/spec/lib/bumbleworks/configuration_spec.rb +1 -1
- data/spec/lib/bumbleworks/storage_adapter_spec.rb +10 -3
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/bumbleworks.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Bumbleworks::VERSION
|
9
9
|
spec.authors = ["Maher Hawash", "Ravi Gadad", "Laurie Kemmerer", "David Miller"]
|
10
10
|
spec.email = ["mhawash@renewfund.com", "ravi@renewfund.com", "laurie@renewfund.com", "dave.miller@renewfund.com"]
|
11
|
-
spec.description = %q{Bumbleworks adds a workflow engine (via ruote[http://github.com/jmettraux/ruote] to your application.}
|
11
|
+
spec.description = %q{Bumbleworks adds a workflow engine (via ruote[http://github.com/jmettraux/ruote]) to your application.}
|
12
12
|
spec.summary = %q{Framework around ruote[http://github.com/jmettraux/ruote] workflow engine}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
data/lib/bumbleworks.rb
CHANGED
@@ -25,8 +25,10 @@ module Bumbleworks
|
|
25
25
|
def_delegator Bumbleworks::ProcessDefinition, :define, :define_process
|
26
26
|
|
27
27
|
# @public
|
28
|
-
# Returns the global configuration, or initializes a new
|
29
|
-
#
|
28
|
+
# Returns the global configuration, or initializes a new configuration
|
29
|
+
# object if it doesn't exist yet. If initializing new config, also adds
|
30
|
+
# default storage adapters.
|
31
|
+
#
|
30
32
|
def configuration
|
31
33
|
@configuration ||= begin
|
32
34
|
configuration = Bumbleworks::Configuration.new
|
@@ -42,7 +44,7 @@ module Bumbleworks
|
|
42
44
|
end
|
43
45
|
|
44
46
|
# @public
|
45
|
-
# Yields the global
|
47
|
+
# Yields the global configuration to a block.
|
46
48
|
# @yield [configuration] global configuration
|
47
49
|
#
|
48
50
|
# @example
|
@@ -69,8 +71,8 @@ module Bumbleworks
|
|
69
71
|
|
70
72
|
# @public
|
71
73
|
# Accepts a block for registering participants which
|
72
|
-
# is envoked when start! is called.
|
73
|
-
# 'catchall'
|
74
|
+
# is envoked when start! is called. Note that a
|
75
|
+
# 'catchall Ruote::StorageParticipant' is always added to
|
74
76
|
# the end of the list (unless it is defined in the block).
|
75
77
|
#
|
76
78
|
# @example
|
@@ -84,8 +86,11 @@ module Bumbleworks
|
|
84
86
|
end
|
85
87
|
|
86
88
|
# @public
|
87
|
-
#
|
88
|
-
#
|
89
|
+
# Registers participants and process_definitions with the Ruote engine.
|
90
|
+
# Also calls Bumbleworks::Ruote.dashboard for the first time, which
|
91
|
+
# implicitly instantiates the storage, and might start a worker (if
|
92
|
+
# configuration.autostart_worker is true)
|
93
|
+
#
|
89
94
|
def start!
|
90
95
|
autoload_and_register_participants
|
91
96
|
load_process_definitions
|
@@ -93,18 +98,18 @@ module Bumbleworks
|
|
93
98
|
|
94
99
|
# @public
|
95
100
|
# Resets Bumbleworks - clears configuration and setup variables, and
|
96
|
-
#
|
101
|
+
# also resets the dashboard.
|
102
|
+
#
|
97
103
|
def reset!
|
98
104
|
@configuration = nil
|
99
105
|
@participant_block = nil
|
100
|
-
@registered_process_definitions = nil
|
101
106
|
Bumbleworks::Ruote.reset!
|
102
107
|
end
|
103
108
|
|
104
109
|
# @public
|
105
|
-
# Launches the
|
106
|
-
#
|
107
|
-
#
|
110
|
+
# Launches the process definition with the given process name, as long as
|
111
|
+
# that definition name is already registered with Bumbleworks.
|
112
|
+
#
|
108
113
|
def launch!(process_definition_name, options = {})
|
109
114
|
Bumbleworks::Ruote.launch(process_definition_name, options)
|
110
115
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Bumbleworks
|
2
|
-
# Stores
|
2
|
+
# Stores configuration information
|
3
3
|
#
|
4
|
-
#
|
4
|
+
# Configuration information is loaded from a configuration block defined within
|
5
5
|
# the client application.
|
6
6
|
#
|
7
7
|
# @example Standard settings
|
@@ -33,31 +33,29 @@ module Bumbleworks
|
|
33
33
|
# /participants
|
34
34
|
# /app/participants
|
35
35
|
#
|
36
|
-
# default:
|
36
|
+
# default: none, must be specified
|
37
37
|
# Exceptions: raises Bumbleworks::UndefinedSetting if not defined by the client
|
38
38
|
#
|
39
39
|
define_setting :root
|
40
40
|
|
41
41
|
# Path to the folder which holds the ruote definition files. Bumbleworks
|
42
|
-
# will
|
43
|
-
# tree under this folder. No specific loading order is
|
42
|
+
# will load all definition files by recursively traversing the directory
|
43
|
+
# tree under this folder. No specific loading order is guaranteed
|
44
44
|
#
|
45
45
|
# default: ${Bumbleworks.root}/lib/process_definitions
|
46
46
|
define_setting :definitions_directory
|
47
47
|
|
48
48
|
# Path to the folder which holds the ruote participant files. Bumbleworks
|
49
|
-
# will
|
50
|
-
#
|
51
|
-
#
|
52
|
-
# Bumbleworks will guarantee that these files are autoloaded before registration
|
53
|
-
# of participants.
|
49
|
+
# will recursively traverse the directory tree under this folder and ensure
|
50
|
+
# that all found files are autoloaded before registration of participants.
|
54
51
|
#
|
55
52
|
# default: ${Bumbleworks.root}/participants then ${Bumbleworks.root}/app/participants
|
56
53
|
define_setting :participants_directory
|
57
54
|
|
58
|
-
#
|
59
|
-
# storage solutions are currently supported: Redis and Sequel.
|
60
|
-
#
|
55
|
+
# Bumbleworks requires a dedicated key-value storage for process information. Three
|
56
|
+
# storage solutions are currently supported: Hash, Redis and Sequel. The latter
|
57
|
+
# two require the bumbleworks-redis and bumbleworks-sequel gems, respectively.
|
58
|
+
# You can set the storage as follows:
|
61
59
|
#
|
62
60
|
# @Exammple: Redis
|
63
61
|
# Bumbleworks.storage = Redis.new(:host => '127.0.0.1', :db => 0, :thread_safe => true)
|
@@ -96,10 +94,10 @@ module Bumbleworks
|
|
96
94
|
@participants_folder ||= default_participant_directory
|
97
95
|
end
|
98
96
|
|
99
|
-
# Root folder where
|
100
|
-
# process_definitions,
|
101
|
-
# It can be defined
|
102
|
-
# Bumbleworks.configure {|c| c.root = '/somewhere'}
|
97
|
+
# Root folder where Bumbleworks looks for ruote assets (participants,
|
98
|
+
# process_definitions, etc.) The root path must be absolute.
|
99
|
+
# It can be defined through a configuration block:
|
100
|
+
# Bumbleworks.configure { |c| c.root = '/somewhere' }
|
103
101
|
#
|
104
102
|
# Or directly:
|
105
103
|
# Bumbleworks.root = '/somewhere/else/'
|
@@ -126,15 +124,13 @@ module Bumbleworks
|
|
126
124
|
end
|
127
125
|
|
128
126
|
# Add a storage adapter to the set of possible adapters. Takes an object
|
129
|
-
# that responds to `driver`, `use
|
127
|
+
# that responds to `driver`, `use?`, `storage_class`, and `display_name`.
|
130
128
|
#
|
131
|
-
def add_storage_adapter(
|
132
|
-
raise ArgumentError, "#{
|
133
|
-
|
134
|
-
storage_adapter.respond_to?(:use?) &&
|
135
|
-
storage_adapter.respond_to?(:display_name)
|
129
|
+
def add_storage_adapter(adapter)
|
130
|
+
raise ArgumentError, "#{adapter} is not a Bumbleworks storage adapter" unless
|
131
|
+
[:driver, :use?, :storage_class, :display_name].all? { |m| adapter.respond_to?(m) }
|
136
132
|
|
137
|
-
@storage_adapters <<
|
133
|
+
@storage_adapters << adapter
|
138
134
|
@storage_adapters
|
139
135
|
end
|
140
136
|
|
@@ -2,12 +2,14 @@ require 'bumbleworks/storage_adapter'
|
|
2
2
|
|
3
3
|
module Bumbleworks
|
4
4
|
class HashStorage < Bumbleworks::StorageAdapter
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
class << self
|
6
|
+
def driver
|
7
|
+
::Ruote::HashStorage
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
def storage_class
|
11
|
+
Hash
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -12,12 +12,16 @@ module Bumbleworks
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def use?(storage)
|
15
|
-
storage.
|
15
|
+
storage.is_a? storage_class
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def storage_class
|
19
19
|
raise "Subclass responsibility"
|
20
20
|
end
|
21
|
+
|
22
|
+
def display_name
|
23
|
+
storage_class.name
|
24
|
+
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
data/lib/bumbleworks/version.rb
CHANGED
@@ -110,7 +110,7 @@ describe Bumbleworks::Configuration do
|
|
110
110
|
describe '#add_storage_adapter' do
|
111
111
|
it 'adds storage adapter to registered list' do
|
112
112
|
GoodForNothingStorage = OpenStruct.new(
|
113
|
-
:driver => nil, :display_name => 'Dummy', :use? => true
|
113
|
+
:driver => nil, :storage_class => 'Dummy', :display_name => 'Dummy', :use? => true
|
114
114
|
)
|
115
115
|
configuration.storage_adapters.should be_empty
|
116
116
|
configuration.add_storage_adapter(GoodForNothingStorage)
|
@@ -17,8 +17,15 @@ describe Bumbleworks::StorageAdapter do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '.display_name' do
|
20
|
+
it 'returns storage class name as a string' do
|
21
|
+
described_class.stub(:storage_class).and_return(String)
|
22
|
+
described_class.display_name.should == 'String'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.storage_class' do
|
20
27
|
it 'is a subclass responsibility' do
|
21
|
-
expect { described_class.
|
28
|
+
expect { described_class.storage_class }.to raise_error
|
22
29
|
end
|
23
30
|
end
|
24
31
|
|
@@ -30,10 +37,10 @@ describe Bumbleworks::StorageAdapter do
|
|
30
37
|
|
31
38
|
describe '.use?' do
|
32
39
|
before :each do
|
33
|
-
described_class.stub(:
|
40
|
+
described_class.stub(:storage_class).and_return(String)
|
34
41
|
end
|
35
42
|
|
36
|
-
it 'returns true if argument class
|
43
|
+
it 'returns true if argument class is_a storage class' do
|
37
44
|
described_class.use?('a string').should be_true
|
38
45
|
described_class.use?(:not_a_string).should be_false
|
39
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumbleworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -142,7 +142,7 @@ dependencies:
|
|
142
142
|
- - ! '>='
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
|
-
description: Bumbleworks adds a workflow engine (via ruote[http://github.com/jmettraux/ruote]
|
145
|
+
description: Bumbleworks adds a workflow engine (via ruote[http://github.com/jmettraux/ruote])
|
146
146
|
to your application.
|
147
147
|
email:
|
148
148
|
- mhawash@renewfund.com
|
@@ -217,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
segments:
|
219
219
|
- 0
|
220
|
-
hash:
|
220
|
+
hash: -3888661442558670334
|
221
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
222
|
none: false
|
223
223
|
requirements:
|
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
226
|
version: '0'
|
227
227
|
segments:
|
228
228
|
- 0
|
229
|
-
hash:
|
229
|
+
hash: -3888661442558670334
|
230
230
|
requirements: []
|
231
231
|
rubyforge_project:
|
232
232
|
rubygems_version: 1.8.23
|