Sha256: 41790bf1fe26c543b9467be91f294d7a5425674774a3f6e58d5332bb318445a9

Contents?: true

Size: 733 Bytes

Versions: 4

Compression:

Stored size: 733 Bytes

Contents

# encoding: UTF-8

require 'tmp-repo'

module RepoFixture
  autoload :Fixture,     'repo-fixture/fixture'
  autoload :ZipStrategy, 'repo-fixture/zip_strategy'

  def self.create
    fixture = Fixture.new(TmpRepo.new)
    yield fixture
    fixture
  end

  def self.load(file, strategy = Fixture::DEFAULT_STRATEGY)
    strategy_class_for(strategy).load(file)
  end

  def self.strategy_class_for(strategy)
    const_str = "#{camelize(strategy.to_s)}Strategy"
    if RepoFixture.const_defined?(const_str)
      RepoFixture.const_get(const_str)
    else
      raise ArgumentError, "'#{strategy}' isn't a valid export strategy."
    end
  end

  private

  def self.camelize(str)
    str.gsub(/(^\w|[-_]\w)/) { $1[-1].upcase }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
repo-fixture-1.1.0 lib/repo-fixture.rb
repo-fixture-1.0.2 lib/repo-fixture.rb
repo-fixture-1.0.1 lib/repo-fixture.rb
repo-fixture-1.0.0 lib/repo-fixture.rb