Sha256: 1a20bb01c4bb1fc6ebd2c6d5f85a9b2e483080bfc8003985ea418a6322452ebd

Contents?: true

Size: 1.82 KB

Versions: 19

Compression:

Stored size: 1.82 KB

Contents

require 'sprockets'

module Ultimate
  module Extensions
    module DirectiveProcessor
      extend ActiveSupport::Concern


      def process_require_all_directive(path)
        raise ArgumentError, "require_all argument must be a relative path"  unless relative?(path)

        context.environment.paths.each do |root_path|
          root = Pathname.new(root_path).join(path).expand_path

          if root.exist? && root.directory?
            context.depend_on(root)

            #Dir["#{root}/*"].sort.each do |filename|
            entries(root).each do |pathname|
              filename = root.join(pathname)
              if filename == self.file
                next
              elsif context.asset_requirable?(filename)
                context.require_asset(filename)
              end
            end
          end
        end
      end

      # `require_first` requires all the files
      # inside a first counter single directory.
      #
      #     //= require_first "./ultimate/underscore"
      #
      def process_require_first_directive(path)
        raise ArgumentError, "require_first argument must be a relative path"  unless relative?(path)

        context.environment.paths.each do |root_path|
          root = Pathname.new(root_path).join(path).expand_path

          if root.exist? && root.directory?
            context.depend_on(root)
            Rails.logger.info('----------')
            Rails.logger.info(root)
            Dir["#{root}/*"].sort.each do |filename|
              if filename == self.file
                next
              elsif context.asset_requirable?(filename)
                context.require_asset(filename)
              end
            end

            break

          end
        end
      end

    end
  end
end

Sprockets::DirectiveProcessor.send :include, Ultimate::Extensions::DirectiveProcessor

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ultimate-base-0.5.0.0 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.4.1.0 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.4.0.1 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.4.0.0 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.5.0 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.4.0 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.3.0 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.2.1 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.2 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.1.1 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.1 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.0 lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.3.0.alpha lib/ultimate/extensions/directive_processor.rb
ultimate-base-0.2.4 lib/ultimate-base/extensions/directive_processor.rb
ultimate-base-0.2.3.2 lib/ultimate-base/extensions/directive_processor.rb
ultimate-base-0.2.3 lib/ultimate-base/extensions/directive_processor.rb
ultimate-base-0.2.2 lib/ultimate-base/extensions/directive_processor.rb
ultimate-base-0.2.1 lib/ultimate-base/extensions/directive_processor.rb
ultimate-base-0.2.0 lib/ultimate-base/extensions/directive_processor.rb