Class: Gemkeeper::GitRepository
- Inherits:
-
Object
- Object
- Gemkeeper::GitRepository
- Defined in:
- lib/gemkeeper/git_repository.rb
Constant Summary collapse
- SAFE_REF_PATTERN =
/\A[a-zA-Z0-9._-]+\z/
Instance Attribute Summary collapse
-
#local_path ⇒ Object
readonly
Returns the value of attribute local_path.
-
#repo_url ⇒ Object
readonly
Returns the value of attribute repo_url.
Instance Method Summary collapse
- #checkout_version(version) ⇒ Object
- #clone_or_pull ⇒ Object
- #current_version ⇒ Object
- #find_gemspec ⇒ Object
-
#initialize(repo_url, local_path) ⇒ GitRepository
constructor
A new instance of GitRepository.
Constructor Details
#initialize(repo_url, local_path) ⇒ GitRepository
Returns a new instance of GitRepository.
10 11 12 13 |
# File 'lib/gemkeeper/git_repository.rb', line 10 def initialize(repo_url, local_path) @repo_url = repo_url @local_path = local_path end |
Instance Attribute Details
#local_path ⇒ Object (readonly)
Returns the value of attribute local_path.
8 9 10 |
# File 'lib/gemkeeper/git_repository.rb', line 8 def local_path @local_path end |
#repo_url ⇒ Object (readonly)
Returns the value of attribute repo_url.
8 9 10 |
# File 'lib/gemkeeper/git_repository.rb', line 8 def repo_url @repo_url end |
Instance Method Details
#checkout_version(version) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/gemkeeper/git_repository.rb', line 25 def checkout_version(version) if version == "latest" checkout_trunk else checkout_tag(version) end end |
#clone_or_pull ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/gemkeeper/git_repository.rb', line 15 def clone_or_pull if File.directory?(File.join(@local_path, ".git")) pull else clone end end |
#current_version ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/gemkeeper/git_repository.rb', line 33 def current_version gemspec_path = find_gemspec return nil unless gemspec_path content = File.read(gemspec_path) extract_version_from_content(content) || version_from_requires(content, File.dirname(gemspec_path)) || version_from_version_files end |
#find_gemspec ⇒ Object
43 44 45 |
# File 'lib/gemkeeper/git_repository.rb', line 43 def find_gemspec Dir.glob(File.join(@local_path, "*.gemspec")).first end |