Class: RailsAppSourceMetrics

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_app_source_metrics.rb

Constant Summary collapse

CODE_SECTIONS =
[
	{ :name => "Controllers", :directory => "app/controllers/" },
	{ :name => "Helpers", :directory => "app/helpers/" },
	{ :name => "Models", :directory => "app/models/" },
	{ :name => "Libraries", :directory => "lib/" },
	{ :name => "Integration Tests", :directory => "test/integration/" },
	{ :name => "Functional Tests", :directory => "test/functional/" },
	{ :name => "Unit Tests", :directory => "test/unit/" }
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRailsAppSourceMetrics

Returns a new instance of RailsAppSourceMetrics.



16
17
18
19
20
21
22
23
# File 'lib/rails_app_source_metrics.rb', line 16

def initialize
	@code_sections = CODE_SECTIONS
	@code_sections.each do |section|
		source_stats = DirectorySourceStats.new(File.join(Rails.root, section[:directory]))
		section[:stats] = add_metrics_to_stats(source_stats.get_stats)
	end
	calculate_totals
end

Instance Attribute Details

#code_sectionsObject (readonly)

Returns the value of attribute code_sections.



14
15
16
# File 'lib/rails_app_source_metrics.rb', line 14

def code_sections
  @code_sections
end

#code_to_test_ratioObject (readonly)

Returns the value of attribute code_to_test_ratio.



14
15
16
# File 'lib/rails_app_source_metrics.rb', line 14

def code_to_test_ratio
  @code_to_test_ratio
end

#lines_of_codeObject (readonly)

Returns the value of attribute lines_of_code.



14
15
16
# File 'lib/rails_app_source_metrics.rb', line 14

def lines_of_code
  @lines_of_code
end

#lines_of_test_codeObject (readonly)

Returns the value of attribute lines_of_test_code.



14
15
16
# File 'lib/rails_app_source_metrics.rb', line 14

def lines_of_test_code
  @lines_of_test_code
end

#totalsObject (readonly)

Returns the value of attribute totals.



14
15
16
# File 'lib/rails_app_source_metrics.rb', line 14

def totals
  @totals
end