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
- #y(obj) ⇒ Object
Instance Method Details
#collapse_line?(line) ⇒ Boolean
71 72 73 |
# File 'lib/never_forget/exception_handler.rb', line 71 def collapse_line?(line) external_path.any? {|p| line.start_with? p } end |
#external_path ⇒ Object
66 67 68 |
# File 'lib/never_forget/exception_handler.rb', line 66 def external_path ['/usr/ruby1.9.2', '/home/heroku_rack', gem_path, system_path].flatten.uniq end |
#gem_path ⇒ Object
53 54 55 56 57 58 |
# File 'lib/never_forget/exception_handler.rb', line 53 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
75 76 77 |
# File 'lib/never_forget/exception_handler.rb', line 75 def ignore_line?(line) line.include? '/Library/Application Support/Pow/' end |
#root_path ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/never_forget/exception_handler.rb', line 91 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
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/never_forget/exception_handler.rb', line 79 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
62 63 64 |
# File 'lib/never_forget/exception_handler.rb', line 62 def system_path SYSDIRS.map { |name| CONFIG["#{name}dir"] }.compact end |
#y(obj) ⇒ Object
49 50 51 |
# File 'lib/never_forget/exception_handler.rb', line 49 def y(obj) YAML.dump(obj).sub(/^---.*\n/, '').gsub(/ !(omap|map:BSON::OrderedHash) *$/, '') end |