Class: Gitignores::GitignoreFetcher
- Inherits:
-
Object
- Object
- Gitignores::GitignoreFetcher
- Defined in:
- lib/gitignores/fetcher.rb
Instance Attribute Summary collapse
-
#git ⇒ Object
writeonly
Sets the attribute git.
-
#local_repository ⇒ Object
writeonly
Sets the attribute local_repository.
-
#remote_repository ⇒ Object
writeonly
Sets the attribute remote_repository.
-
#update_ignores ⇒ Object
writeonly
Sets the attribute update_ignores.
Instance Method Summary collapse
-
#fetch_gitignores ⇒ Object
If needed, retrieves gitignores from Github and places them in @local_repository If @update_ignores? is set, will try to update the latest gitignores Will store all gitignores in the @local_repository.
-
#initialize(local_repository, remote_repository) ⇒ GitignoreFetcher
constructor
A new instance of GitignoreFetcher.
- #list_gitignores ⇒ Object
Constructor Details
#initialize(local_repository, remote_repository) ⇒ GitignoreFetcher
Returns a new instance of GitignoreFetcher.
9 10 11 12 13 14 |
# File 'lib/gitignores/fetcher.rb', line 9 def initialize(local_repository, remote_repository) @local_repository = local_repository @remote_repository = remote_repository @update_ignores = false @git = Git.new end |
Instance Attribute Details
#git=(value) ⇒ Object (writeonly)
Sets the attribute git
7 8 9 |
# File 'lib/gitignores/fetcher.rb', line 7 def git=(value) @git = value end |
#local_repository=(value) ⇒ Object (writeonly)
Sets the attribute local_repository
7 8 9 |
# File 'lib/gitignores/fetcher.rb', line 7 def local_repository=(value) @local_repository = value end |
#remote_repository=(value) ⇒ Object (writeonly)
Sets the attribute remote_repository
7 8 9 |
# File 'lib/gitignores/fetcher.rb', line 7 def remote_repository=(value) @remote_repository = value end |
#update_ignores=(value) ⇒ Object (writeonly)
Sets the attribute update_ignores
7 8 9 |
# File 'lib/gitignores/fetcher.rb', line 7 def update_ignores=(value) @update_ignores = value end |
Instance Method Details
#fetch_gitignores ⇒ Object
If needed, retrieves gitignores from Github and places them in @local_repository If @update_ignores? is set, will try to update the latest gitignores Will store all gitignores in the @local_repository
19 20 21 22 23 24 25 26 |
# File 'lib/gitignores/fetcher.rb', line 19 def fetch_gitignores() unless (Dir.exist?(@local_repository)) @git.clone @remote_repository, @local_repository end if @update_ignores @git.pull @local_repository end end |
#list_gitignores ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/gitignores/fetcher.rb', line 28 def list_gitignores() fetch_gitignores Dir.glob(@local_repository + "/**/*.gitignore").collect { |x| File.basename x, ".gitignore" } end |