Class: Git

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGit

Returns a new instance of Git.



5
6
7
8
# File 'lib/aidir/git.rb', line 5

def initialize
  @errors = []
  @changed_files = []
end

Instance Attribute Details

#changed_filesObject

Returns the value of attribute changed_files.



3
4
5
# File 'lib/aidir/git.rb', line 3

def changed_files
  @changed_files
end

#errorsObject

Returns the value of attribute errors.



3
4
5
# File 'lib/aidir/git.rb', line 3

def errors
  @errors
end

Instance Method Details

#clear_cached_filesObject



25
26
27
28
29
# File 'lib/aidir/git.rb', line 25

def clear_cached_files
  @changed_files.each do |file|
    File.delete(temp(file))
  end
end

#is_repository?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'lib/aidir/git.rb', line 10

def is_repository?
  Open3.popen3('git rev-parse') do |_, _, stderr|
    error = stderr.read
    @errors << error unless error.empty?
  end
  @errors.empty?
end

#ruby_filesObject



18
19
20
21
22
23
# File 'lib/aidir/git.rb', line 18

def ruby_files
  all_changed_files
  filter_ruby_files
  cache_files
  @changed_files
end