Class: LOCCounter::Project

Inherits:
FilesCollection show all
Defined in:
lib/loc_counter/project.rb

Overview

A class representing a project.

Constant Summary collapse

SOURCE_FILES =

Dir.glob patterns for project source code files paths

[
  '*.{rb,gemspec}',
  '{Cap,Gem,Rake}file',
  'bin/*',
  '{app,config,lib}/**/*.{gemspec,rake,rb}'
]

Constants inherited from FilesCollection

FilesCollection::RUBY_FILES

Instance Attribute Summary

Attributes inherited from FilesCollection

#files

Instance Method Summary collapse

Methods inherited from FilesCollection

#counts

Constructor Details

#initialize(dir_name) ⇒ Project

Returns a new instance of Project.

Parameters:

  • dir_name (String)

    Path to the project directory

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/loc_counter/project.rb', line 14

def initialize(dir_name)
  raise ArgumentError, "Directory '#{dir_name}' not found" unless File.exists?(dir_name)
  
  @files = []
  SOURCE_FILES.each do |pattern|
    full_pattern = File.join(dir_name, pattern)
    
    @files += Dir.glob(full_pattern).map do |filename|
      SourceFile.new(filename)
    end
  end
end