class SlimGruntHelpers::Models::Usemin

Constants

BASE_OPTIONS

Public Class Methods

new() click to toggle source
# File lib/slim-grunt-helpers/models/usemin.rb, line 11
def initialize
  @links = []
end

Public Instance Methods

<<(path, options={}) click to toggle source
# File lib/slim-grunt-helpers/models/usemin.rb, line 15
def <<(path, options={})
  @links << { path: path.to_s, options: base_options.merge(options) }
end
Also aliased as: add, include
add(path, options={})
Alias for: <<
base_options() click to toggle source
# File lib/slim-grunt-helpers/models/usemin.rb, line 29
def base_options
  BASE_OPTIONS
end
each(options={}) { |transform_link(link, options)| ... } click to toggle source
# File lib/slim-grunt-helpers/models/usemin.rb, line 25
def each(options={})
  @links.each { |link| yield(transform_link(link, options)) }
end
include(path, options={})
Alias for: <<
require(path, options={}) click to toggle source
# File lib/slim-grunt-helpers/models/usemin.rb, line 21
def require(path, options={})
  self.include(path, options) unless file_already_included? path
end
require_tree(root_path, pattern, options={}) click to toggle source
# File lib/slim-grunt-helpers/models/usemin.rb, line 33
def require_tree(root_path, pattern, options={})
  unless root_path.respond_to? :join
    root_path = Pathname.new(root_path.to_s)
  end
  
  Dir[root_path.join(pattern).to_s].reject do |file|
    File.directory? file
  end.each do |file|
    file_name      = file.to_s
    real_root_path = "#{ root_path }/"
    file_name[real_root_path] = ''
    transform_ext             = options[:transform_ext]
    unless transform_ext.nil?
      transform_ext = ".#{ transform_ext }" unless transform_ext[0] == '.'

      origin_ext = File.extname(file_name)
      file_name[origin_ext] = transform_ext
    end
    
    self.require file_name, options.reject { |key| key == :transform_ext }
  end
end

Protected Instance Methods

Private Instance Methods

file_already_included?(path) click to toggle source
# File lib/slim-grunt-helpers/models/usemin.rb, line 64
def file_already_included?(path)
  path = path.to_s
  @links.find { |link| link[:path] == path }
end