lib/railroader/scanner.rb in railroader-4.3.5 vs lib/railroader/scanner.rb in railroader-4.3.7
- old
+ new
@@ -10,16 +10,16 @@
$stderr.puts e.message
$stderr.puts "Please install the appropriate dependency."
exit(-1)
end
-#Scans the Rails application.
+# Scans the Rails application.
class Railroader::Scanner
attr_reader :options
RUBY_1_9 = RUBY_VERSION >= "1.9.0"
- #Pass in path to the root of the Rails application
+ # Pass in path to the root of the Rails application
def initialize options, processor = nil
@options = options
@app_tree = Railroader::AppTree.from_options(options)
if (!@app_tree.root || !@app_tree.exists?("app")) && !options[:force_scan]
@@ -27,16 +27,16 @@
end
@processor = processor || Railroader::Processor.new(@app_tree, options)
end
- #Returns the Tracker generated from the scan
+ # Returns the Tracker generated from the scan
def tracker
@processor.tracked_events
end
- #Process everything in the Rails application
+ # Process everything in the Rails application
def process
Railroader.notify "Processing gems..."
process_gems
guess_rails_version
Railroader.notify "Processing configuration..."
@@ -88,13 +88,13 @@
end
@file_list = fp.file_list
end
- #Process config/environment.rb and config/gems.rb
+ # Process config/environment.rb and config/gems.rb
#
- #Stores parsed information in tracker.config
+ # Stores parsed information in tracker.config
def process_config
if options[:rails3] or options[:rails4] or options[:rails5]
process_config_file "application.rb"
process_config_file "environments/production.rb"
else
@@ -126,11 +126,11 @@
tracker.error e.exception(e.message + "\nwhile processing #{path}"), e.backtrace
end
private :process_config_file
- #Process Gemfile
+ # Process Gemfile
def process_gems
gem_files = {}
if @app_tree.exists? "Gemfile"
gem_files[:gemfile] = { :src => parse_ruby(@app_tree.read("Gemfile")), :file => "Gemfile" }
elsif @app_tree.exists? "gems.rb"
@@ -149,11 +149,11 @@
rescue => e
Railroader.notify "[Notice] Error while processing Gemfile."
tracker.error e.exception(e.message + "\nWhile processing Gemfile"), e.backtrace
end
- #Set :rails3/:rails4 option if version was not determined from Gemfile
+ # Set :rails3/:rails4 option if version was not determined from Gemfile
def guess_rails_version
unless tracker.options[:rails3] or tracker.options[:rails4]
if @app_tree.exists?("script/rails")
tracker.options[:rails3] = true
Railroader.notify "[Notice] Detected Rails 3 application"
@@ -168,28 +168,28 @@
Railroader.notify "[Notice] Detected Rails 4 application"
end
end
end
- #Process all the .rb files in config/initializers/
+ # Process all the .rb files in config/initializers/
#
- #Adds parsed information to tracker.initializers
+ # Adds parsed information to tracker.initializers
def process_initializers
track_progress @file_list[:initializers] do |init|
Railroader.debug "Processing #{init[:path]}"
process_initializer init
end
end
- #Process an initializer
+ # Process an initializer
def process_initializer init
@processor.process_initializer(init.path, init.ast)
end
- #Process all .rb in lib/
+ # Process all .rb in lib/
#
- #Adds parsed information to tracker.libs.
+ # Adds parsed information to tracker.libs.
def process_libs
if options[:skip_libs]
Railroader.notify '[Skipping]'
return
end
@@ -198,18 +198,18 @@
Railroader.debug "Processing #{lib.path}"
process_lib lib
end
end
- #Process a library
+ # Process a library
def process_lib lib
@processor.process_lib lib.ast, lib.path
end
- #Process config/routes.rb
+ # Process config/routes.rb
#
- #Adds parsed information to tracker.routes
+ # Adds parsed information to tracker.routes
def process_routes
if @app_tree.exists?("config/routes.rb")
begin
@processor.process_routes parse_ruby(@app_tree.read("config/routes.rb"))
rescue => e
@@ -220,13 +220,13 @@
else
Railroader.notify "[Notice] No route information found"
end
end
- #Process all .rb files in controllers/
+ # Process all .rb files in controllers/
#
- #Adds processed controllers to tracker.controllers
+ # Adds processed controllers to tracker.controllers
def process_controllers
track_progress @file_list[:controllers] do |controller|
Railroader.debug "Processing #{controller.path}"
process_controller controller
end
@@ -240,11 +240,11 @@
controller.src.each do |file, src|
@processor.process_controller_alias name, src, nil, file
end
end
- #No longer need these processed filter methods
+ # No longer need these processed filter methods
tracker.filter_cache.clear
end
def process_controller astfile
begin
@@ -252,13 +252,13 @@
rescue => e
tracker.error e.exception(e.message + "\nWhile processing #{astfile.path}"), e.backtrace
end
end
- #Process all views and partials in views/
+ # Process all views and partials in views/
#
- #Adds processed views to tracker.views
+ # Adds processed views to tracker.views
def process_templates
templates = @file_list[:templates].sort_by { |t| t[:path] }
track_progress templates, "templates" do |template|
Railroader.debug "Processing #{template[:path]}"
@@ -277,12 +277,12 @@
Railroader.debug "Processing #{name}"
@processor.process_template_alias template
end
end
- #Process all the .rb files in models/
+ # Process all the .rb files in models/
#
- #Adds the processed models to tracker.models
+ # Adds the processed models to tracker.models
def process_models
track_progress @file_list[:models] do |model|
Railroader.debug "Processing #{model[:path]}"
process_model model[:path], model[:ast]
end