lib/cloud-crowd.rb in documentcloud-cloud-crowd-0.0.5 vs lib/cloud-crowd.rb in documentcloud-cloud-crowd-0.0.6

- old
+ new

@@ -17,32 +17,37 @@ autoload :Daemons, 'daemons' autoload :Digest, 'digest' autoload :ERB, 'erb' autoload :FileUtils, 'fileutils' autoload :JSON, 'json' -autoload :RestClient, 'rest_client' +autoload :RestClient, 'restclient' autoload :RightAws, 'right_aws' autoload :Sinatra, 'sinatra' autoload :Socket, 'socket' autoload :YAML, 'yaml' +# Common code which should really be required in every circumstance. +require 'cloud_crowd/exceptions' + module CloudCrowd # Autoload all the CloudCrowd classes which may not be required. - autoload :App, 'cloud_crowd/app' - autoload :Action, 'cloud_crowd/action' - autoload :AssetStore, 'cloud_crowd/asset_store' - autoload :Helpers, 'cloud_crowd/helpers' - autoload :Inflector, 'cloud_crowd/inflector' - autoload :Job, 'cloud_crowd/models' - autoload :WorkUnit, 'cloud_crowd/models' + autoload :App, 'cloud_crowd/app' + autoload :Action, 'cloud_crowd/action' + autoload :AssetStore, 'cloud_crowd/asset_store' + autoload :Helpers, 'cloud_crowd/helpers' + autoload :Inflector, 'cloud_crowd/inflector' + autoload :Job, 'cloud_crowd/models' + autoload :Worker, 'cloud_crowd/worker' + autoload :WorkUnit, 'cloud_crowd/models' + autoload :WorkerRecord, 'cloud_crowd/models' # Root directory of the CloudCrowd gem. ROOT = File.expand_path(File.dirname(__FILE__) + '/..') # Keep the version in sync with the gemspec. - VERSION = '0.0.5' + VERSION = '0.0.6' # A Job is processing if its WorkUnits in the queue to be handled by workers. PROCESSING = 1 # A Job has succeeded if all of its WorkUnits have finished successfully. @@ -66,13 +71,11 @@ # A work unit is considered incomplete if it's being processed, split up or # merged together. INCOMPLETE = [PROCESSING, SPLITTING, MERGING] # Mapping of statuses to their display strings. - DISPLAY_STATUS_MAP = { - 1 => 'processing', 2 => 'succeeded', 3 => 'failed', 4 => 'splitting', 5 => 'merging' - } + DISPLAY_STATUS_MAP = ['unknown', 'processing', 'succeeded', 'failed', 'splitting', 'merging'] class << self attr_reader :config # Configure CloudCrowd by passing in the path to <tt>config.yml</tt>. @@ -99,24 +102,24 @@ end # Return the displayable status name of an internal CloudCrowd status number. # (See the above constants). def display_status(status) - DISPLAY_STATUS_MAP[status] + DISPLAY_STATUS_MAP[status] || 'unknown' end # CloudCrowd::Actions are requested dynamically by name. Access them through # this actions property, which behaves like a hash. At load time, we # load all installed Actions and CloudCrowd's default Actions into it. # If you wish to have certain workers be specialized to only handle certain # Actions, then install only those into the actions directory. def actions return @actions if @actions @actions = {} - default_actions = Dir["#{ROOT}/actions/*.rb"] - custom_actions = Dir["#{CloudCrowd.config[:actions_path]}/*.rb"] || - Dir["#{@config_path}/actions/*.rb"] - (default_actions + custom_actions).each do |path| + default_actions = Dir["#{ROOT}/actions/*.rb"] + installed_actions = Dir["#{@config_path}/actions/*.rb"] + custom_actions = Dir["#{CloudCrowd.config[:actions_path]}/*.rb"] + (default_actions + installed_actions + custom_actions).each do |path| name = File.basename(path, File.extname(path)) require path @actions[name] = Module.const_get(Inflector.camelize(name)) end @actions \ No newline at end of file