Method: Cup::Cupfile#javascripts

Defined in:
lib/cup/cupfile.rb

#javascriptsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cup/cupfile.rb', line 25

def javascripts

  javascripts = {}
  current_directory = File.dirname(File.expand_path(self.path))
  
  @javascript_patterns.each do |subdir, patterns|
    javascripts[subdir] = patterns.map do |pattern|

      default_catch_all = pattern == :*

      pattern = '**/*.js' if default_catch_all

      if pattern
        expanded_pattern = current_directory + "/#{subdir}/#{pattern}"
        FileList[expanded_pattern].select do |f|
          if subdir == :spec and f.start_with?(current_directory + "/spec/visual")
            false
          else
            File.extname(f).downcase == '.js'
          end
        end
      end
    end.flatten.compact.uniq
  end

  javascripts
end