class Diffend::Repository

Repository for specs

Constants

REPOSITORIES_PATH

Repositories path

SUPPORTED

List of supported repositories split by command

Attributes

name[R]
path[R]

Public Class Methods

new(command, name) click to toggle source

@param command [String] command executed via bundler @param name [String] repository name

# File lib/diffend/repository.rb, line 43
def initialize(command, name)
  @command = command
  @name = name
  @path = File.join(Dir.tmpdir, SecureRandom.uuid)
end

Public Instance Methods

bundler_version_string() click to toggle source

Build bundler version string

@return [String]

# File lib/diffend/repository.rb, line 105
def bundler_version_string
  @bundler_version_string ||= "bundler_#{Bundler::VERSION.tr('.', '_')}"
end
clean() click to toggle source

Clean isolated instance of a repository

# File lib/diffend/repository.rb, line 67
def clean
  FileUtils.rm_rf(path)
end
file_path(file_name) click to toggle source

Build the path to a specified file within the repository

@param file_name [String]

@return [String]

# File lib/diffend/repository.rb, line 83
def file_path(file_name)
  File.join(
    path,
    file_name
  )
end
global_file_path(file_name) click to toggle source

Build global path

@param file_name [String]

@return [String]

# File lib/diffend/repository.rb, line 95
def global_file_path(file_name)
  File.join(
    REPOSITORIES_PATH,
    file_name
  )
end
isolate() { |path| ... } click to toggle source

Execute tasks in an isolated instance of a repository

# File lib/diffend/repository.rb, line 72
def isolate
  setup
  yield(path)
  clean
end
orig_path() click to toggle source

Build repository path

@return [String]

# File lib/diffend/repository.rb, line 52
def orig_path
  @orig_path ||= global_file_path(
    File.join(
      bundler_version_string,
      "#{@command}_#{name}"
    )
  )
end
setup() click to toggle source

Setup an isolated instance of a repository

# File lib/diffend/repository.rb, line 62
def setup
  FileUtils.cp_r(orig_path, path)
end