Sha256: eded6f7389d0d5bc18493a92f83dc93164da7d7d8eed621a034ee8777882a6df

Contents?: true

Size: 993 Bytes

Versions: 10

Compression:

Stored size: 993 Bytes

Contents

module EY
  class << self
    def define_git_repo(name, &setup)
      git_repo_setup[name] ||= setup
    end

    def refresh_git_repo(name)
      git_repo_dir_cache.delete name
    end

    def git_repo_dir(name)
      return git_repo_dir_cache[name] if git_repo_dir_cache.has_key?(name)
      raise ArgumentError, "No definition for git repo #{name}" unless git_repo_setup[name]

      git_dir = TMPDIR.join("engineyard_test_repo_#{Time.now.tv_sec}_#{Time.now.tv_usec}_#{$$}")
      git_dir.mkpath
      Dir.chdir(git_dir) do
        system("git init -q")
        system('git config user.email ey@spec.test')
        system('git config user.name "EY Specs"')
        system("git remote add testremote user@git.host:path/to/repo.git")
        git_repo_setup[name].call(git_dir)
      end
      git_repo_dir_cache[name] = git_dir
    end

    protected

    def git_repo_setup
      @git_repo_setup ||= {}
    end

    def git_repo_dir_cache
      @git_repo_dir_cache ||= {}
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
engineyard-2.0.9 spec/support/git_repos.rb
engineyard-2.0.8 spec/support/git_repos.rb
engineyard-2.0.7 spec/support/git_repos.rb
engineyard-2.0.6 spec/support/git_repos.rb
engineyard-2.0.5 spec/support/git_repos.rb
engineyard-2.0.4 spec/support/git_repos.rb
engineyard-2.0.2 spec/support/git_repos.rb
engineyard-2.0.1 spec/support/git_repos.rb
engineyard-2.0.0 spec/support/git_repos.rb
engineyard-2.0.0.rc1 spec/support/git_repos.rb