class Cb
Public Class Methods
partial_helper(file_name)
click to toggle source
# File lib/view_tree.rb, line 28 def self.partial_helper(file_name) # find partials in the file # print out the partial name and # push all the partials into queue reg_partial_name = /(?<=(partial=>)|(render)|(spotpartial=>))\s*['"][a-zA-Z_\/-]+(?=['"])/ begin File.readlines(file_name).each do |line| if !reg_partial_name.match(line).nil? partial_name = reg_partial_name.match(line) partial_name = partial_name.to_s.gsub!(/[\s'"]*/, "") if !partial_name[/spot_loader/].nil? partial_name = line[/(?<=spotpartial=>)\s*['"][a-zA-Z_\/-]+(?=['"])/].to_s.gsub!(/[\s'"]*/, "") else partial_name = File.basename(partial_name) end self.view_helper("_" + partial_name + ".html.erb" ) end end rescue puts "Please input correct controller and action name." exit end end
rel(controller_action_name)
click to toggle source
# File lib/view_tree.rb, line 55 def self.rel(controller_action_name) # Check that if user has input "bundle install --path vendor" if controller_action_name.size == 0 || controller_action_name[0] == "#" || controller_action_name[controller_action_name.size - 1] == "#" || controller_action_name.include?("*") || !controller_action_name.include?("#") puts "Please input controller and action name." exit end bundle_installed = false Dir.open("./vendor").each do |dirname| bundle_installed = true if dirname == "ruby" end if !bundle_installed puts "Please use bundle install --path vendor instead of bundle install" exit end # Scan the gem list array, find all the views used view_name = controller_action_name.gsub(/#/, "/") self.view_helper(view_name) if $file_queue.size == 0 puts "" puts "Please check the controller and action name, I can't find that page." exit end $file_queue.push(["#{$niche_intl}/app/views/layouts/cb_intl/application.html.erb"]) # Print out all the rendered partial while $file_queue.size != 0 file_name = $file_queue.pop() puts file_name if file_name.class == Array file_name = file_name.first end if file_name !~ /featured_employers/ self.partial_helper(file_name) end end end
view_helper(view_name)
click to toggle source
Define methods partial helper and view helper
# File lib/view_tree.rb, line 16 def self.view_helper(view_name) $gem_list.each do |gem| if Dir["#{gem}/**/#{view_name}*"].size != 0 Dir["#{gem}/**/#{view_name}*"].each do |file| $file_queue.push(file) end break end end end