Class: GithubToCanvasQuiz::RepositoryInterface
- Inherits:
-
Object
- Object
- GithubToCanvasQuiz::RepositoryInterface
- Defined in:
- lib/github_to_canvas_quiz/repository_interface.rb
Overview
Interface for working with a local git repo
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #commit_files(*filepaths, message) ⇒ Object
-
#initialize(path) ⇒ RepositoryInterface
constructor
A new instance of RepositoryInterface.
Constructor Details
#initialize(path) ⇒ RepositoryInterface
Returns a new instance of RepositoryInterface.
8 9 10 11 12 13 14 |
# File 'lib/github_to_canvas_quiz/repository_interface.rb', line 8 def initialize(path) path = File.(path) raise DirectoryNotFoundError unless Pathname(path).directory? @path = path @git = Git.init(path) end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
6 7 8 |
# File 'lib/github_to_canvas_quiz/repository_interface.rb', line 6 def git @git end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/github_to_canvas_quiz/repository_interface.rb', line 6 def path @path end |
Instance Method Details
#commit_files(*filepaths, message) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/github_to_canvas_quiz/repository_interface.rb', line 16 def commit_files(*filepaths, ) relative_paths = filepaths.map { |filepath| relative_path(filepath) } return unless new_repo? || relative_paths.any? { |filepath| pending_changes?(filepath) } git.add(relative_paths) git.commit("AUTO: #{}") end |