module Crystal module Plugin class Web attr_reader :dir def initialize dir @dir = dir end def asset name require 'asset_packager' AssetPackager.add "#{dir}/config/asset_packages.yml", "#{dir}/public" crystal.after :environment do crystal.ensure_public_symlink name, "#{dir}/public" end end def routes crystal.after :environment do routes_file = "#{dir}/config/routes.rb" load routes_file if File.exist? routes_file end end def locales I18n.load_path += Dir["#{dir}/config/locales/**/*.{rb,yml}"] end def require_paths *relative_paths relative_paths = relative_paths.first if relative_paths.first.is_a? Array relative_paths.each do |relative_path| path = "#{dir}/#{relative_path}" $LOAD_PATH << path unless $LOAD_PATH.include? path end end def autoload *list list = list.first if list.first.is_a? Array list.each{|d| autoload_dir "#{dir}/#{d}"} end end end end