class Fixman::Repository
Constants
- FIELD_LABEL_WIDTH
- GIT_URL_REGEXP
Attributes
groups[RW]
name[RW]
other_fields[RW]
owner[RW]
path[R]
sha[RW]
url[RW]
Public Class Methods
extract_owner_and_name(url)
click to toggle source
# File lib/fixman/repository.rb, line 88 def extract_owner_and_name(url) match_data = GIT_URL_REGEXP.match url [match_data[:owner], match_data[:name]] if match_data end
new(repo_params, fixtures_base, extra_repo_info)
click to toggle source
# File lib/fixman/repository.rb, line 22 def initialize(repo_params, fixtures_base, extra_repo_info) @url = repo_params[:url] @name = repo_params[:name] @owner = repo_params[:owner] @sha = repo_params[:sha] @groups = repo_params[:groups] [:url, :name, :owner, :sha, :groups].each { |key| repo_params.delete key } @other_fields = repo_params @extra_repo_info = extra_repo_info @path = fixtures_base + canonical_name end
retrieve_head_sha(url)
click to toggle source
# File lib/fixman/repository.rb, line 93 def retrieve_head_sha url ref = Git.ls_remote url ref['head'][:sha] end
Public Instance Methods
canonical_name()
click to toggle source
# File lib/fixman/repository.rb, line 55 def canonical_name "#{@owner}/#{@name}" end
destroy()
click to toggle source
# File lib/fixman/repository.rb, line 51 def destroy FileUtils.rm_rf @path if File.exist? @path end
fetch()
click to toggle source
# File lib/fixman/repository.rb, line 40 def fetch git = Git.clone @url, @path git.reset_hard @sha end
fetched?()
click to toggle source
# File lib/fixman/repository.rb, line 36 def fetched? File.exist? @path end
summary()
click to toggle source
# File lib/fixman/repository.rb, line 59 def summary "#{canonical_name}\t#{@sha}" end
to_s()
click to toggle source
# File lib/fixman/repository.rb, line 63 def to_s str = StringIO.new str.puts 'Repository'.ljust(FIELD_LABEL_WIDTH) + canonical_name str.puts 'URL'.ljust(FIELD_LABEL_WIDTH) + @url str.puts 'Commit SHA'.ljust(FIELD_LABEL_WIDTH) + @sha str.puts 'Groups'.ljust(FIELD_LABEL_WIDTH) + @groups.join(', ') @extra_repo_info.each do |info| str.puts info[:label].ljust(FIELD_LABEL_WIDTH) + @other_fields[info[:symbol]] end str.string end
to_yaml()
click to toggle source
# File lib/fixman/repository.rb, line 76 def to_yaml { name: @name, owner: @owner, sha: @sha, url: @url, access_right: @access_right, notes: @notes }.merge(@other_fields).to_yaml end
upgrade()
click to toggle source
# File lib/fixman/repository.rb, line 45 def upgrade git = Git.open @path git.pull git.reset_hard @sha end