Sha256: a23fba010f72b952c84e86aae3af8a13e4c2043b38e7a4a5164144e4de09a560
Contents?: true
Size: 817 Bytes
Versions: 22
Compression:
Stored size: 817 Bytes
Contents
module Lono::Template::Context::Loader module LoadFiles # Load custom helper methods from project def load_files(root) paths = Dir.glob("#{root}/**/*.rb") paths.sort_by! { |p| p.size } # so namespaces are loaded first paths.each do |path| # lib = gem extensions # app = project extensions filename = path.sub(%r{.*/lib/},'').sub(%r{.*/app/helpers/},'').sub('.rb','') module_name = filename.camelize # Prepend a period so require works LONO_ROOT is set to a relative path without a period. # # Example: LONO_ROOT=tmp/lono_project first_char = path[0..0] path = "./#{path}" unless %w[. /].include?(first_char) require path self.class.send :include, module_name.constantize end end end end
Version data entries
22 entries across 22 versions & 1 rubygems