Class: Brakeman::RenderPath
- Inherits:
 - 
      Object
      
        
- Object
 - Brakeman::RenderPath
 
 
- Defined in:
 - lib/brakeman/processors/lib/render_path.rb
 
Instance Attribute Summary collapse
- 
  
    
      #path  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute path.
 
Instance Method Summary collapse
- #add_controller_render(controller_name, method_name, line, file) ⇒ Object
 - #add_template_render(template_name, line, file) ⇒ Object
 - #each(&block) ⇒ Object
 - #include_any_method?(method_names) ⇒ Boolean
 - #include_controller?(klass) ⇒ Boolean
 - #include_template?(name) ⇒ Boolean
 - 
  
    
      #initialize  ⇒ RenderPath 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of RenderPath.
 - #initialize_copy(original) ⇒ Object
 - #join(*args) ⇒ Object
 - #last ⇒ Object
 - #last_template=(template) ⇒ Object
 - #length ⇒ Object
 - #map(&block) ⇒ Object
 - #rendered_from_controller? ⇒ Boolean
 - #to_a ⇒ Object
 - #to_json(*args) ⇒ Object
 - #to_s ⇒ Object
 - #to_sym ⇒ Object
 - #with_relative_paths ⇒ Object
 
Constructor Details
#initialize ⇒ RenderPath
Returns a new instance of RenderPath.
      5 6 7  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 5 def initialize @path = [] end  | 
  
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
      3 4 5  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 3 def path @path end  | 
  
Instance Method Details
#add_controller_render(controller_name, method_name, line, file) ⇒ Object
      9 10 11 12 13 14 15 16 17 18 19 20  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 9 def add_controller_render controller_name, method_name, line, file method_name ||= "" @path << { :type => :controller, :class => controller_name.to_sym, :method => method_name.to_sym, :line => line, :file => file } self end  | 
  
#add_template_render(template_name, line, file) ⇒ Object
      22 23 24 25 26 27 28 29 30  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 22 def add_template_render template_name, line, file @path << { :type => :template, :name => template_name.to_sym, :line => line, :file => file } self end  | 
  
#each(&block) ⇒ Object
      73 74 75  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 73 def each &block @path.each(&block) end  | 
  
#include_any_method?(method_names) ⇒ Boolean
      59 60 61 62 63 64 65  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 59 def include_any_method? method_names names = method_names.map(&:to_sym) @path.any? do |loc| loc[:type] == :controller and names.include? loc[:method] end end  | 
  
#include_controller?(klass) ⇒ Boolean
      51 52 53 54 55 56 57  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 51 def include_controller? klass klass = klass.to_sym @path.any? do |loc| loc[:type] == :controller and loc[:class] == klass end end  | 
  
#include_template?(name) ⇒ Boolean
      43 44 45 46 47 48 49  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 43 def include_template? name name = name.to_sym @path.any? do |loc| loc[:type] == :template and loc[:name] == name end end  | 
  
#initialize_copy(original) ⇒ Object
      134 135 136 137  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 134 def initialize_copy original @path = original.path.dup self end  | 
  
#join(*args) ⇒ Object
      77 78 79  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 77 def join *args self.to_a.join(*args) end  | 
  
#last ⇒ Object
      100 101 102  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 100 def last self.to_a.last end  | 
  
#last_template=(template) ⇒ Object
      32 33 34 35 36 37 38 39 40 41  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 32 def last_template= template if @path.last @path.last[:rendered] = { name: template.name, file: template.file, } else Brakeman.debug "[Notice] No render path to add template information" end end  | 
  
#length ⇒ Object
      81 82 83  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 81 def length @path.length end  | 
  
#map(&block) ⇒ Object
      85 86 87  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 85 def map &block @path.map(&block) end  | 
  
#rendered_from_controller? ⇒ Boolean
      67 68 69 70 71  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 67 def rendered_from_controller? @path.any? do |loc| loc[:type] == :controller end end  | 
  
#to_a ⇒ Object
      89 90 91 92 93 94 95 96 97 98  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 89 def to_a @path.map do |loc| case loc[:type] when :template "Template:#{loc[:name]}" when :controller "#{loc[:class]}##{loc[:method]}" end end end  | 
  
#to_json(*args) ⇒ Object
      112 113 114 115  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 112 def to_json *args require 'json' JSON.generate(@path) end  | 
  
#to_s ⇒ Object
      104 105 106  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 104 def to_s self.to_a.to_s end  | 
  
#to_sym ⇒ Object
      108 109 110  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 108 def to_sym self.to_s.to_sym end  | 
  
#with_relative_paths ⇒ Object
      117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132  | 
    
      # File 'lib/brakeman/processors/lib/render_path.rb', line 117 def with_relative_paths @path.map do |loc| r = loc.dup if r[:file] r[:file] = r[:file].relative end if r[:rendered] and r[:rendered][:file] r[:rendered] = r[:rendered].dup r[:rendered][:file] = r[:rendered][:file].relative end r end end  |