Class: Syntaxer::Git

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

Instance Method Summary collapse

Constructor Details

#initialize(repo_path) ⇒ Git

Returns a new instance of Git.



21
22
23
24
25
# File 'lib/syntaxer/repository.rb', line 21

def initialize(repo_path)
  @repository = ::Git.open(File.expand_path(repo_path))
rescue ArgumentError => ex
  raise GitRepositoryError, "The path you specified is not a git repository: '#{File.expand_path(repo_path)}'"
end

Instance Method Details

#added_filesArray

Returns list of files what have been added

Returns:

  • (Array)


41
42
43
44
45
# File 'lib/syntaxer/repository.rb', line 41

def added_files
  @repository.chdir do
    @added ||= @repository.status.added.to_a.map(&:first)
  end
end

#changed_and_added_filesArray

Aggregates added and changed files in one array

Returns:

  • (Array)


51
52
53
54
# File 'lib/syntaxer/repository.rb', line 51

def changed_and_added_files
  check_repo
  changed_files + added_files
end

#changed_filesArray

Returns list of files what have been changed

Returns:

  • (Array)


31
32
33
34
35
# File 'lib/syntaxer/repository.rb', line 31

def changed_files
  @repository.chdir do
    @changed ||= @repository.status.changed.to_a.map(&:first)
  end
end