Module: Kazoo::Support
- Defined in:
- lib/kazoo/support.rb
Constant Summary collapse
- HTTP_CODES =
{ 400 => :bad_request, 401 => :unauthorized, 402 => :payment_required, 403 => :forbidden, 404 => :not_found, 405 => :method_not_allowed, 406 => :not_acceptable, 500 => :internal_server_error, 501 => :not_implemented, 502 => :bad_gateway, 503 => :service_unavailable, 504 => :gateway_timeout, 505 => :http_version_not_supported }
Instance Method Summary collapse
Instance Method Details
#decamelize(class_name) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/kazoo/support.rb', line 20 def decamelize(class_name) parts = class_name.split('::') parts.map { |part| part.gsub(/([A-Z])/, '_\1').gsub(/(^\_)|(\_$)/, '').downcase }.join('/') end |
#load_files(files) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/kazoo/support.rb', line 27 def load_files(files) excepted_inits = [] files.sort.each do |init| begin require init rescue => e excepted_inits.push([init, {e => 0}]) end end # Go through the ones that might have dependencies on other inits. max_error_size = excepted_inits.size * 4 while excepted_inits.size > 0 begin excepted_init = excepted_inits.pop require excepted_init[0] rescue => e c = e.class excepted_init[1][c] ||= 0 if excepted_init[1][c] > max_error_size raise else excepted_init[1][c] += 1 excepted_inits.unshift(excepted_init) end#if end#begin end#while end |