Class: SlimGruntHelpers::Models::Usemin
- Inherits:
-
Object
- Object
- SlimGruntHelpers::Models::Usemin
- Defined in:
- lib/slim-grunt-helpers/models/usemin.rb
Constant Summary collapse
- BASE_OPTIONS =
{}.freeze
Instance Method Summary collapse
- #<<(path, options = {}) ⇒ Object (also: #add, #include)
- #base_options ⇒ Object
- #each(options = {}) ⇒ Object
-
#initialize ⇒ Usemin
constructor
A new instance of Usemin.
- #require(path, options = {}) ⇒ Object
- #require_tree(root_path, pattern, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Usemin
Returns a new instance of Usemin.
11 12 13 |
# File 'lib/slim-grunt-helpers/models/usemin.rb', line 11 def initialize @links = [] end |
Instance Method Details
#<<(path, options = {}) ⇒ Object Also known as: add, include
15 16 17 |
# File 'lib/slim-grunt-helpers/models/usemin.rb', line 15 def <<(path, ={}) @links << { path: path.to_s, options: .merge() } end |
#base_options ⇒ Object
29 30 31 |
# File 'lib/slim-grunt-helpers/models/usemin.rb', line 29 def BASE_OPTIONS end |
#each(options = {}) ⇒ Object
25 26 27 |
# File 'lib/slim-grunt-helpers/models/usemin.rb', line 25 def each(={}) @links.each { |link| yield(transform_link(link, )) } end |
#require(path, options = {}) ⇒ Object
21 22 23 |
# File 'lib/slim-grunt-helpers/models/usemin.rb', line 21 def require(path, ={}) self.include(path, ) unless file_already_included? path end |
#require_tree(root_path, pattern, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/slim-grunt-helpers/models/usemin.rb', line 33 def require_tree(root_path, pattern, ={}) 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] = '' self.require file_name, end end |