Class: Project

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/header-inserter/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Project

Returns a new instance of Project.



10
11
12
# File 'lib/header-inserter/project.rb', line 10

def initialize path
  @path = File.expand_path(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/header-inserter/project.rb', line 8

def path
  @path
end

Instance Method Details

#<=>(other) ⇒ Object



14
15
16
# File 'lib/header-inserter/project.rb', line 14

def <=> other
  @path <=> other.path
end

#list(file_pattern) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/header-inserter/project.rb', line 18

def list file_pattern
  if file_pattern.is_a? Symbol
    file_pattern = /.*\.#{file_pattern.to_s}$/
  end
  files = []
  Find.find @path do |entry|
    short_entry = entry.sub /^#{@path+File::SEPARATOR}/, ""
    if file_pattern.match short_entry
      version_control = obtain_version_control short_entry
      files << ProjectFile.new(self, short_entry, version_control)
    end
  end
  files
end