Guest User

Untitled

a guest
Apr 26th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. # find rails root, stolen from prh's symlink script
  2. l=`pwd`.chomp
  3. ['', '/..', '/../..', '/../../..', '/../../../..'].each do |p|
  4. root="#{l}#{p}"
  5. root.gsub!(/\/\//,'/')
  6. root.sub!(/\/+[^\/]+\/\.\./,'')
  7. root.sub!(/\/+[^\/]+\/\.\./,'')
  8. root.sub!(/\/+[^\/]+\/\.\./,'')
  9. root.sub!(/\/+[^\/]+\/\.\./,'')
  10. if File.exists?("#{root}/config/boot.rb") and File.read("#{root}/config/boot.rb").match(/RAILS_ROOT/)
  11. RAILS_ROOT = root
  12. end
  13. end
  14.  
  15. PATTERN = '**/taglibs/**/*.dryml'
  16.  
  17. def system_gem_taglibs
  18. require 'rubygems'
  19. gem 'hobo'
  20. hobo_root = $:.find { |path| path =~ %r{/hobo-\d+\.\d+\.\d+/lib} }.sub(/lib\/*$/,'')
  21. Dir["#{hobo_root}#{PATTERN}"]
  22. end
  23.  
  24. files=[]
  25. if Object.const_defined?('RAILS_ROOT') # rails proj
  26. files = Dir["#{RAILS_ROOT}/app/views/#{PATTERN}"] # user taglibs
  27. if Dir['vendor/{plugins,gems}/{hobo,hobo-*}/'].empty? # proj without gem/plugin
  28. files.concat system_gem_taglibs
  29. else # proj with gem/plugin
  30. files.concat Dir["#{RAILS_ROOT}/vendor/{plugins,gems}/{hobo,hobo-*}/#{PATTERN}"]
  31. end
  32. else # no rails proj
  33. files.concat system_gem_taglibs
  34. end
  35.  
  36. puts files.uniq.join("\n")
Add Comment
Please, Sign In to add comment