Module: Bumbleworks

Extended by:
Forwardable
Defined in:
lib/bumbleworks.rb,
lib/bumbleworks/task.rb,
lib/bumbleworks/user.rb,
lib/bumbleworks/ruote.rb,
lib/bumbleworks/entity.rb,
lib/bumbleworks/process.rb,
lib/bumbleworks/support.rb,
lib/bumbleworks/tracker.rb,
lib/bumbleworks/version.rb,
lib/bumbleworks/schedule.rb,
lib/bumbleworks/workitem.rb,
lib/bumbleworks/task/base.rb,
lib/bumbleworks/expression.rb,
lib/bumbleworks/task/finder.rb,
lib/bumbleworks/error_logger.rb,
lib/bumbleworks/hash_storage.rb,
lib/bumbleworks/tree_builder.rb,
lib/bumbleworks/configuration.rb,
lib/bumbleworks/error_handler.rb,
lib/bumbleworks/simple_logger.rb,
lib/bumbleworks/storage_adapter.rb,
lib/bumbleworks/process_definition.rb,
lib/bumbleworks/process/error_record.rb,
lib/bumbleworks/support/flow_expression.rb,
lib/bumbleworks/workitem_entity_storage.rb,
lib/bumbleworks/participant_registration.rb,
lib/bumbleworks/participants/participant.rb,
lib/bumbleworks/support/wrapper_comparison.rb,
lib/bumbleworks/participants/error_dispatcher.rb,
lib/bumbleworks/participants/entity_interactor.rb,
lib/bumbleworks/participants/local_participant.rb,
lib/bumbleworks/participants/storage_participant.rb

Defined Under Namespace

Modules: Entity, LocalParticipant, Support, User, WorkitemEntityStorage Classes: Configuration, EntityInteractor, EntityNotFound, ErrorDispatcher, ErrorHandler, ErrorLogger, Expression, HashStorage, InvalidEntity, InvalidSetting, Participant, ParticipantRegistration, Process, ProcessDefinition, Ruote, Schedule, SimpleLogger, StorageAdapter, StorageParticipant, Task, Tracker, TreeBuilder, UndefinedSetting, UnsupportedMode, Worker, Workitem

Constant Summary collapse

VERSION =
"0.0.91"

Class Method Summary collapse

Class Method Details

.autoload_participantsObject

Autoloads all files in the configured participants_directory.



125
126
127
# File 'lib/bumbleworks.rb', line 125

def autoload_participants
  Bumbleworks::ParticipantRegistration.autoload_all
end

.autoload_tasksObject

Autoloads all files in the configured tasks_directory.



132
133
134
# File 'lib/bumbleworks.rb', line 132

def autoload_tasks
  Bumbleworks::Task.autoload_all
end

.bootstrap!(options = {}) ⇒ Object

Loads process definitions, and loads participant registration file at configured participant_registration_file path.



172
173
174
175
# File 'lib/bumbleworks.rb', line 172

def bootstrap!(options = {})
  load_definitions!(options)
  Bumbleworks::ParticipantRegistration.register!
end

.clear_configuration!Object

Clears configuration completely, resetting to defaults.



156
157
158
# File 'lib/bumbleworks.rb', line 156

def clear_configuration!
  @configuration = nil
end

.configurationObject

Returns the global configuration, or initializes a new configuration object if it doesn’t exist yet. If initializing new config, also adds default storage adapters.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bumbleworks.rb', line 50

def configuration
  @configuration ||= begin
    configuration = Bumbleworks::Configuration.new
    configuration.add_storage_adapter(Bumbleworks::HashStorage)
    if defined?(Bumbleworks::Redis::Adapter) && Bumbleworks::Redis::Adapter.auto_register?
      configuration.add_storage_adapter(Bumbleworks::Redis::Adapter)
    end
    if defined?(Bumbleworks::Sequel::Adapter) && Bumbleworks::Sequel::Adapter.auto_register?
      configuration.add_storage_adapter(Bumbleworks::Sequel::Adapter)
    end
    configuration
  end
end

.configure {|configuration| ... } ⇒ Object

Yields the global configuration to a block.

Examples:

Bumbleworks.configure do |c|
  c.root = 'path/to/ruote/assets'
end

Yields:

See Also:



80
81
82
83
84
85
# File 'lib/bumbleworks.rb', line 80

def configure(&block)
  unless block
    raise ArgumentError.new("You tried to .configure without a block!")
  end
  yield configuration
end

.configure! {|configuration| ... } ⇒ Object

Same as .configure, but clears all existing configuration settings first.

Yields:

See Also:



92
93
94
95
# File 'lib/bumbleworks.rb', line 92

def configure!(&block)
  clear_configuration!
  configure(&block)
end

.errorsObject

Instantiates a new Bumbleworks::Process::ErrorRecord for each error in the Ruote storage.



194
195
196
197
198
199
200
# File 'lib/bumbleworks.rb', line 194

def errors
  Bumbleworks.dashboard.context.storage.get_many('errors').map { |err|
    Bumbleworks::Process::ErrorRecord.new(
      ::Ruote::ProcessError.new(err)
    )
  }
end

.initialize!Object

Autoloads all necessary files for the Bumbleworks environment



163
164
165
166
# File 'lib/bumbleworks.rb', line 163

def initialize!
  autoload_tasks
  autoload_participants
end

.launch!(process_definition_name, *args) ⇒ Object

Launches the process definition with the given process name, as long as that definition name is already registered with Bumbleworks. If options has an :entity key, attempts to extract the id and class name before sending it, so it can be properly stored in workitem fields (and re-instantiated later).



184
185
186
187
188
# File 'lib/bumbleworks.rb', line 184

def launch!(process_definition_name, *args)
  extract_entity_from_fields!(args.first || {})
  pid = Bumbleworks::Ruote.launch(process_definition_name, *args)
  Bumbleworks::Process.new(pid)
end

.load_definitions!(options = {}) ⇒ Object

Registers all process_definitions in the configured definitions_directory with the Ruote engine.



140
141
142
143
144
# File 'lib/bumbleworks.rb', line 140

def load_definitions!(options = {})
  if directory = definitions_directory
    Bumbleworks::ProcessDefinition.create_all_from_directory!(directory, options)
  end
end

.register_default_participantsObject

Syntactic sugar to register participants without supplying a block - ends up registering only default participants (such as the error handler and storage).



118
119
120
# File 'lib/bumbleworks.rb', line 118

def register_default_participants
  register_participants
end

.register_participants(&block) ⇒ Object

Accepts a block for registering participants. Note that a ‘catchall Ruote::StorageParticipant’ is always added to the end of the list (unless it is defined in the block).

Examples:

Bumbleworks.register_participants do
  painter PainterClass
  builder BuilderClass
  plumber PlumberClass
end


108
109
110
111
# File 'lib/bumbleworks.rb', line 108

def register_participants(&block)
  autoload_participants
  Bumbleworks::Ruote.register_participants(&block)
end

.reset!Object

Resets Bumbleworks - resets dashboard, purges storage, and clears configuration and setup variables.



149
150
151
152
# File 'lib/bumbleworks.rb', line 149

def reset!
  Bumbleworks::Ruote.reset!
  clear_configuration!
end

.store_history?Boolean

Return true only if store_history (from configuration) is true.

Returns:

  • (Boolean)


67
68
69
# File 'lib/bumbleworks.rb', line 67

def store_history?
  configuration.store_history == true
end