class Herdsman::HerdMember
Constants
- Message
Attributes
config[R]
repo[R]
Public Class Methods
new(repo, config)
click to toggle source
# File lib/herdsman/herd_member.rb, line 3 def initialize(repo, config) @repo = repo @config = config end
Public Instance Methods
gathered?()
click to toggle source
# File lib/herdsman/herd_member.rb, line 8 def gathered? [repo_initialized?, repo_has_zero_unpushed_commits?, repo_has_zero_unpulled_commits?, repo_has_zero_untracked_files?, repo_has_zero_modified_files?, repo_on_specified_revision?].all? end
status_report()
click to toggle source
# File lib/herdsman/herd_member.rb, line 17 def status_report clear_messages messages << Message.new(:info, "#{name} is ok") if gathered? messages end
Private Instance Methods
clear_messages()
click to toggle source
# File lib/herdsman/herd_member.rb, line 33 def clear_messages @messages = [] end
fetch_cache()
click to toggle source
# File lib/herdsman/herd_member.rb, line 45 def fetch_cache config.fetch_cache end
fetch_cached?()
click to toggle source
# File lib/herdsman/herd_member.rb, line 49 def fetch_cached? Time.now - repo.last_fetched < fetch_cache end
messages()
click to toggle source
# File lib/herdsman/herd_member.rb, line 29 def messages @messages ||= [] end
name()
click to toggle source
# File lib/herdsman/herd_member.rb, line 37 def name config.name end
repo_fetch!()
click to toggle source
# File lib/herdsman/herd_member.rb, line 53 def repo_fetch! repo.fetch! rescue messages << Message.new(:warn, "#{name} failed to fetch") end
repo_has_zero_modified_files?()
click to toggle source
# File lib/herdsman/herd_member.rb, line 88 def repo_has_zero_modified_files? if repo.has_modified_files? messages << Message.new(:warn, "#{name} has modified files") end !repo.has_modified_files? end
repo_has_zero_unpulled_commits?()
click to toggle source
# File lib/herdsman/herd_member.rb, line 73 def repo_has_zero_unpulled_commits? repo_fetch! unless fetch_cached? if repo.has_unpulled_commits? messages << Message.new(:warn, "#{name} has unpulled commits") end !repo.has_unpulled_commits? end
repo_has_zero_unpushed_commits?()
click to toggle source
# File lib/herdsman/herd_member.rb, line 66 def repo_has_zero_unpushed_commits? if repo.has_unpushed_commits? messages << Message.new(:warn, "#{name} has unpushed commits") end !repo.has_unpushed_commits? end
repo_has_zero_untracked_files?()
click to toggle source
# File lib/herdsman/herd_member.rb, line 81 def repo_has_zero_untracked_files? if repo.has_untracked_files? messages << Message.new(:warn, "#{name} has untracked files") end !repo.has_untracked_files? end
repo_initialized?()
click to toggle source
# File lib/herdsman/herd_member.rb, line 59 def repo_initialized? unless repo.initialized? messages << Message.new(:warn, "#{repo.path} is not a git repo") end repo.initialized? end
repo_on_specified_revision?()
click to toggle source
# File lib/herdsman/herd_member.rb, line 95 def repo_on_specified_revision? if repo.initialized? && !repo.revision?(revision) messages << Message.new(:warn, "#{name} revision is not '#{revision}'") end !repo.initialized? || repo.revision?(revision) end
revision()
click to toggle source
# File lib/herdsman/herd_member.rb, line 41 def revision config.revision end