Class: Syntaxer::Git
- Inherits:
-
Object
- Object
- Syntaxer::Git
- Defined in:
- lib/syntaxer/repository.rb
Instance Method Summary collapse
-
#added_files ⇒ Array
Returns list of files what have been added.
-
#changed_and_added_files ⇒ Array
Aggregates added and changed files in one array.
-
#changed_files ⇒ Array
Returns list of files what have been changed.
-
#initialize(repo_path) ⇒ Git
constructor
A new instance of Git.
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.(repo_path)) rescue ArgumentError => ex raise GitRepositoryError, "The path you specified is not a git repository: '#{File.(repo_path)}'" end |
Instance Method Details
#added_files ⇒ Array
Returns list of files what have been added
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_files ⇒ Array
Aggregates added and changed files in one 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_files ⇒ Array
Returns list of files what have been changed
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 |