Sha256: ab55b7374216c61cb4b1d18a3a054d27c551a48ee2927eaf87ca62dcdd2abed4

Contents?: true

Size: 1.05 KB

Versions: 18

Compression:

Stored size: 1.05 KB

Contents

# AUTOLOAD EVERYTHING IN THE IMAGETASTIC DIRECTORY TREE

# The convention is that dirs are modules
# so declare them here and autoload any modules/classes inside them
# All paths here are absolute
def camelize(path)
  # e.g. 'test/this_one' => Test::ThisOne
  "#{path}".
    chomp('/').
    gsub('/','::').
    gsub(/([^a-z])(\w)/){ "#{$1}#{$2.upcase}" }.
    gsub('_','').
    sub(/^(\w)/){ $1.upcase }
end
def autoload_files_in_dir(path, namespace)
  # Define the module
  eval("module #{namespace}; end")
  # Autoload modules/classes in that module
  Dir.glob("#{path}/*.rb").each do |file|
    sub_const_name = camelize( File.basename(file, '.rb') )
    eval("#{namespace}.autoload('#{sub_const_name}', '#{file}')")
  end
  # Recurse on subdirectories
  Dir.glob("#{path}/*/").each do |dir|
    sub_namespace = camelize( File.basename(dir) )
    autoload_files_in_dir(dir, "#{namespace}::#{sub_namespace}")
  end
end

autoload_files_in_dir("#{File.dirname(__FILE__)}/dragonfly", 'Dragonfly')

require 'rubygems'
require File.dirname(__FILE__) + '/dragonfly/core_ext/object'

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dragonfly-0.4.3 lib/dragonfly.rb
dragonfly-0.4.2 lib/dragonfly.rb
dragonfly-0.4.1 lib/dragonfly.rb
dragonfly-0.4.0 lib/dragonfly.rb
dragonfly-0.3.8 lib/dragonfly.rb
dragonfly-0.3.7 lib/dragonfly.rb
dragonfly-0.3.6 lib/dragonfly.rb
dragonfly-0.3.5 lib/dragonfly.rb
dragonfly-0.3.4 lib/dragonfly.rb
dragonfly-0.3.3 lib/dragonfly.rb
dragonfly-0.3.2 lib/dragonfly.rb
dragonfly-0.3.0 lib/dragonfly.rb
dragonfly-0.2.1 lib/dragonfly.rb
dragonfly-0.1.6 lib/dragonfly.rb
dragonfly-0.1.5 lib/dragonfly.rb
dragonfly-0.1.4 lib/dragonfly.rb
dragonfly-0.1.1 lib/dragonfly.rb
dragonfly-0.1.0 lib/dragonfly.rb