Class: LintFu::Plugins::Rails::ModelApplicationFactory

Inherits:
EidosBuilder
  • Object
show all
Defined in:
lib/lint_fu/plugins/rails/model_application_factory.rb

Instance Attribute Summary

Attributes inherited from EidosBuilder

#current_model_element, #eide, #namespace

Instance Method Summary collapse

Methods inherited from EidosBuilder

#process_class, #process_module

Constructor Details

#initialize(fs_root) ⇒ ModelApplicationFactory

Returns a new instance of ModelApplicationFactory.



4
5
6
7
8
# File 'lib/lint_fu/plugins/rails/model_application_factory.rb', line 4

def initialize(fs_root)
  super
  @application = ModelApplication.new(fs_root)
  self.eide << @application
end

Instance Method Details

#buildObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lint_fu/plugins/rails/model_application_factory.rb', line 10

def build
  models_dir = File.join(@application.fs_root, 'app', 'models')
  builder = LintFu::Plugins::ActiveRecord::ModelEidosBuilder.new
  #TODO ensure the Rails app is using ActiveRecord
  Dir.glob(File.join(models_dir, '**', '*.rb')).each do |f|
    sexp = LintFu::Parser.parse_ruby(f)
    builder.process(sexp)
  end
  builder.eide.each { |elem| @application.add_eidos(elem) }

  controllers_dir = File.join(@application.fs_root, 'app', 'controllers')
  builder = ActionPack::ControllerEidosBuilder.new
  Dir.glob(File.join(controllers_dir, '**', '*.rb')).each do |f|
    sexp = LintFu::Parser.parse_ruby(f)
    sexp.file = f
    builder.process(sexp)
  end
  builder.eide.each { |elem| @application.add_eidos(elem) }
end