Module: NeverForget::TemplateHelpers
- Extended by:
- ActiveSupport::Memoizable
- Includes:
- RbConfig
- Defined in:
- lib/never_forget/exception_handler.rb
Constant Summary collapse
- SYSDIRS =
%w[ vendor site rubylib arch sitelib sitearch vendorlib vendorarch top ]
Instance Method Summary collapse
- #collapse_line?(line) ⇒ Boolean
- #external_path ⇒ Object
- #gem_path ⇒ Object
- #ignore_line?(line) ⇒ Boolean
- #root_path ⇒ Object
- #strip_root(line) ⇒ Object
- #system_path ⇒ Object
Instance Method Details
#collapse_line?(line) ⇒ Boolean
66 67 68 |
# File 'lib/never_forget/exception_handler.rb', line 66 def collapse_line?(line) external_path.any? {|p| line.start_with? p } end |
#external_path ⇒ Object
61 62 63 |
# File 'lib/never_forget/exception_handler.rb', line 61 def external_path ['/usr/ruby1.9.2', '/home/heroku_rack', gem_path, system_path].flatten.uniq end |
#gem_path ⇒ Object
48 49 50 51 52 53 |
# File 'lib/never_forget/exception_handler.rb', line 48 def gem_path paths = [] paths << Bundler.bundle_path << Bundler.user_bundle_path if defined? Bundler paths << Gem.path if defined? Gem paths.flatten.uniq end |
#ignore_line?(line) ⇒ Boolean
70 71 72 |
# File 'lib/never_forget/exception_handler.rb', line 70 def ignore_line?(line) line.include? '/Library/Application Support/Pow/' end |
#root_path ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/never_forget/exception_handler.rb', line 86 def root_path if defined? Bundler then Bundler.root elsif defined? Rails then Rails.root elsif defined? Sinatra::Application then Sinatra::Application.root else Dir.pwd end end |
#strip_root(line) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/never_forget/exception_handler.rb', line 74 def strip_root(line) if line =~ %r{/gems/([^/]+)-(\d[\w.]*)/} gem_name, gem_version = $1, $2 path = line.split($&, 2).last "#{gem_name} (#{gem_version}) #{path}" elsif path = "#{root_path}/" and line.start_with? path line.sub(path, '') else line end end |
#system_path ⇒ Object
57 58 59 |
# File 'lib/never_forget/exception_handler.rb', line 57 def system_path SYSDIRS.map { |name| CONFIG["#{name}dir"] }.compact end |