Parent

Class/Module Index [+]

Quicksearch

Brakeman::AppTree

Constants

VIEW_EXTENSIONS

Attributes

root[R]

Public Class Methods

from_options(options) click to toggle source
# File lib/brakeman/app_tree.rb, line 7
def self.from_options(options)
  root = options[:app_path]

  # Convert files into Regexp for matching
  if options[:skip_files]
    list = "(?:" << options[:skip_files].map { |f| Regexp.escape f }.join("|") << ")$"
    new(root, Regexp.new(list))
  else
    new(root)
  end
end
new(root, skip_files = nil) click to toggle source
# File lib/brakeman/app_tree.rb, line 19
def initialize(root, skip_files = nil)
  @root = root
  @skip_files = skip_files
end

Public Instance Methods

controller_paths() click to toggle source
# File lib/brakeman/app_tree.rb, line 53
def controller_paths
  @controller_paths ||= find_paths("app/controllers")
end
exists?(path) click to toggle source
# File lib/brakeman/app_tree.rb, line 40
def exists?(path)
  File.exists?(File.join(@root, path))
end
expand_path(path) click to toggle source
# File lib/brakeman/app_tree.rb, line 24
def expand_path(path)
  File.expand_path(path, @root)
end
initializer_paths() click to toggle source
# File lib/brakeman/app_tree.rb, line 49
def initializer_paths
  @initializer_paths ||= find_paths("config/initializers")
end
layout_exists?(name) click to toggle source
# File lib/brakeman/app_tree.rb, line 65
def layout_exists?(name)
  pattern = "#{@root}/app/views/layouts/#{name}.html.{erb,haml}"
  !Dir.glob(pattern).empty?
end
lib_paths() click to toggle source
# File lib/brakeman/app_tree.rb, line 70
def lib_paths
  @lib_files ||= find_paths("lib")
end
model_paths() click to toggle source
# File lib/brakeman/app_tree.rb, line 57
def model_paths
  @model_paths ||= find_paths("app/models")
end
path_exists?(path) click to toggle source

This is a pair for read_path. Again, would like to kill these

# File lib/brakeman/app_tree.rb, line 45
def path_exists?(path)
  File.exists?(path)
end
read(path) click to toggle source
# File lib/brakeman/app_tree.rb, line 28
def read(path)
  File.read(File.join(@root, path))
end
read_path(path) click to toggle source

This variation requires full paths instead of paths based off the project root. I'd prefer to get all the code outside of AppTree using project-root based paths (e.g. app/models/user.rb) instead of full paths, but I suspect it's an incompatible change.

# File lib/brakeman/app_tree.rb, line 36
def read_path(path)
  File.read(path)
end
template_paths() click to toggle source
# File lib/brakeman/app_tree.rb, line 61
def template_paths
  @template_paths ||= find_paths("app/views", "*.{#{VIEW_EXTENSIONS}}")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.