Guest User

Untitled

a guest
Jan 23rd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. # For evergreen nested directory support
  2. # 1. Create a /config/evergreen.rb file and put these contents in it
  3. module Evergreen
  4. class Suite
  5. def specs
  6. Dir.glob(File.join(root, Evergreen.spec_dir, '**', '*_spec.{js,coffee,js.coffee}')).map do |path|
  7. Spec.new(self, path.gsub(File.join(root), ''))
  8. end
  9. end
  10.  
  11. def templates
  12. Dir.glob(File.join(root, Evergreen.template_dir, '**', '*')).map do |path|
  13. Template.new(self, path.gsub(File.join(root), '')) unless File.directory?(path)
  14. end.compact
  15. end
  16. end
  17. end
  18.  
  19. module Evergreen
  20. class Spec
  21. def initialize(suite, name)
  22. @suite = suite
  23. @name = name
  24. @name = "#{Evergreen.spec_dir}/#{name}" if !exist?
  25. end
  26.  
  27. def name
  28. @name.gsub("/#{Evergreen.spec_dir}/", '')
  29. end
  30.  
  31. def read
  32. require 'coffee-script'
  33. if full_path =~ /\.coffee$/
  34. CoffeeScript.compile File.read(full_path), :bare => true
  35. else
  36. File.read(full_path)
  37. end
  38. end
  39. end
  40. end
  41.  
  42. module Evergreen
  43. class Template
  44. def name
  45. @name.gsub("/#{Evergreen.template_dir}/", '')
  46. end
  47.  
  48. def full_path
  49. File.join(root, @name)
  50. end
  51. end
  52. end
Add Comment
Please, Sign In to add comment