Guest User

Untitled

a guest
Apr 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. require 'fileutils'
  2. require 'Rake'
  3.  
  4. class SmartFileList < Rake::FileList
  5. attr_accessor :base_path
  6.  
  7. def initialize(base_path)
  8. super()
  9. @base_path = base_path.sub(%r{/$}, "")
  10. end
  11.  
  12. def extensions(*extensions)
  13. puts extensions
  14. paths = Array.new
  15. extensions.each do |ext|
  16. paths << "*.#{ext}"
  17. end
  18. include(paths)
  19. end
  20.  
  21. def include(*filenames)
  22.  
  23. filenames.each do |fn|
  24. if fn.respond_to? :to_ary
  25. include(*fn.to_ary)
  26. else
  27. puts "path: #{fn}"
  28. new_path = map_on_base_path(fn)
  29. puts new_path
  30. super new_path
  31. end
  32. end
  33. end
  34.  
  35. private
  36. def map_on_base_path(pattern)
  37. return "#{@base_path}/**/#{pattern}"
  38. end
  39.  
  40.  
  41. end
Add Comment
Please, Sign In to add comment