Module: Motion::Require::Ext::ConfigTask

Defined in:
lib/motion-require/ext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
# File 'lib/motion-require/ext.rb', line 8

def self.included(base)
  base.class_eval do
    alias_method :files_dependencies_without_require, :files_dependencies
    alias_method :files_dependencies, :files_dependencies_with_require
  end
end

Instance Method Details

#files_dependencies_with_require(deps_hash) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/motion-require/ext.rb', line 15

def files_dependencies_with_require(deps_hash)
  res_path = lambda do |x|
    path = /^\.?\//.match(x) ? x : File.join('.', x)
    unless @files.flatten.include?(path)
      Motion::Project::App.send(:fail, "Can't resolve dependency `#{x}'")
    end
    path
  end
  deps_hash.each do |path, deps|
    deps = [deps] unless deps.is_a?(Array)
    @dependencies[res_path.call(path)] = deps.map(&res_path)
  end
end