Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'fileutils'
- require 'Rake'
- class SmartFileList < Rake::FileList
- attr_accessor :base_path
- def initialize(base_path)
- super()
- @base_path = base_path.sub(%r{/$}, "")
- end
- def extensions(*extensions)
- puts extensions
- paths = Array.new
- extensions.each do |ext|
- paths << "*.#{ext}"
- end
- include(paths)
- end
- def include(*filenames)
- filenames.each do |fn|
- if fn.respond_to? :to_ary
- include(*fn.to_ary)
- else
- puts "path: #{fn}"
- new_path = map_on_base_path(fn)
- puts new_path
- super new_path
- end
- end
- end
- private
- def map_on_base_path(pattern)
- return "#{@base_path}/**/#{pattern}"
- end
- end
Add Comment
Please, Sign In to add comment