Class: Git::Elements

Inherits:
Base
  • Object
show all
Defined in:
lib/git/elements.rb

Constant Summary collapse

IGNORE =
'gcignore'
RECURSIVE =
'gcrecursive'

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Elements

Returns a new instance of Elements.


10
11
12
13
14
# File 'lib/git/elements.rb', line 10

def initialize( path )
  @path = path.clone
  super( { :working_directory => @path } )
  @gcfiles, @gitfiles = elements_scan
end

Instance Method Details

#filesObject


32
33
34
35
36
37
# File 'lib/git/elements.rb', line 32

def files
  return @files if @files
  @files = @gitfiles.reject do | f |
    (ignored + folders).find { |i| f =~ /^#{i}/ }
  end.sort
end

#foldersObject


24
25
26
27
28
29
30
# File 'lib/git/elements.rb', line 24

def folders
  return @folders if @folders
  recursives = @gcfiles.select do | f |
    File.basename( f ) =~ /^\.#{RECURSIVE}$/i
  end
  @folders = gcfiles_scan( recursives ).collect { |f| File.join f, '/' }
end

#ignoredObject


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

def ignored
  return @ignored if @ignored
  ignores = @gcfiles.select do | f |
    File.basename( f ) =~ /^\.#{IGNORE}$/i
  end
  @ignored = gcfiles_scan( ignores )
end