class Salt::Formula::Git

Attributes

repo[R]

@!attribute [r] repo

@api private
@return [Salt::Matrix::Gitrepo]

Public Class Methods

implement?(name, args) click to toggle source
# File lib/salt/formula/git.rb, line 9
def self.implement?(name, args)
  args.is_a? Hash and (args.has_key?(:git) or args.has_key?(:github))
rescue
  false
end
new(name, dirname, args) click to toggle source
Calls superclass method Salt::Formula::Base::new
# File lib/salt/formula/git.rb, line 20
def initialize(name, dirname, args)
  super
  parse_options(@args)
  @name = name
  @repo = Salt::Matrix::Gitrepo.new(@remote, @name, @ref, dirname)
end

Public Instance Methods

properties() click to toggle source
# File lib/salt/formula/git.rb, line 31
def properties
  {
    :expected => @ref,
    :actual   => (@repo.head || "(unresolvable)"),
    :type     => :git,
  }
end
version() click to toggle source
# File lib/salt/formula/git.rb, line 27
def version
  @ref
end

Private Instance Methods

parse_options(options) click to toggle source
# File lib/salt/formula/git.rb, line 45
def parse_options(options)
  @remote = options.delete(:git) || options.delete(:github)

  if options[:branch]
    @ref = "origin/#{options.delete(:branch)}"
  end

  if options[:tag]
    @ref = options.delete(:tag)
  end

  if options[:commit]
    @ref = options.delete(:commit)
  end

  if options[:ref]
    @ref = options.delete(:ref)
  end

  @ref ||= 'master'

  unless options.empty?
    raise ArgumentError, "Unhandled options #{options.keys.inspect} specified for #{self.class}"
  end
end