class Abak::Flow::Repository

Constants

REMOTES

Public Class Methods

new() click to toggle source
# File lib/abak-flow/repository.rb, line 9
def initialize
  @_errors = Hash.new

  create_public_instance_methods
end

Public Instance Methods

errors() click to toggle source
# File lib/abak-flow/repository.rb, line 23
def errors
  ErrorsPresenter.new(self, @_errors)
end
valid?() click to toggle source
# File lib/abak-flow/repository.rb, line 15
def valid?
  @_errors = Hash.new
  @_errors["origin"] = ['not_set'] if origin.nil?
  @_errors["upstream"] = ['not_set'] if upstream.nil?

  @_errors.empty?
end

Private Instance Methods

create_public_instance_methods() click to toggle source
# File lib/abak-flow/repository.rb, line 29
def create_public_instance_methods
  remotes = Hash[fetch_remotes_from_git]

  REMOTES.each do |name|
    define_singleton_method(name) { remotes[name] }
  end
end
create_remote(remote) click to toggle source
# File lib/abak-flow/repository.rb, line 42
def create_remote(remote)
  matches = /.+.github\.com[\:|\/](?<owner>.+)\/(?<project>.+).git/.match(remote.url)

  if !matches.nil? && matches.captures.length == 2
    [remote.name, Remote.new(matches[:owner], matches[:project], remote)]
  end
end
fetch_remotes_from_git() click to toggle source
# File lib/abak-flow/repository.rb, line 37
def fetch_remotes_from_git
  Manager.git.remotes.select { |remote| REMOTES.include?(remote.name) }
    .map { |remote| create_remote(remote) }.compact
end