Class: RepoFixture::Fixture

Inherits:
Object
  • Object
show all
Defined in:
lib/repo-fixture/fixture.rb

Constant Summary collapse

DEFAULT_STRATEGY =
:zip

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Fixture

Returns a new instance of Fixture.



12
13
14
# File 'lib/repo-fixture/fixture.rb', line 12

def initialize(repo)
  @repo = repo
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



36
37
38
# File 'lib/repo-fixture/fixture.rb', line 36

def method_missing(method, *args, &block)
  repo.send(method, *args, &block)
end

Instance Attribute Details

#repoObject (readonly)

Returns the value of attribute repo.



10
11
12
# File 'lib/repo-fixture/fixture.rb', line 10

def repo
  @repo
end

Instance Method Details

#copy_files(files) ⇒ Object

Copies files into the repo. Optional block receives each file, return value is the desired path inside the archive.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/repo-fixture/fixture.rb', line 18

def copy_files(files)
  Array(files).each do |file|
    output_file = if block_given?
      yield file
    else
      file
    end

    output_file = File.join(repo.working_dir, output_file)
    FileUtils.mkdir_p(File.dirname(output_file))
    FileUtils.cp(file, output_file)
  end
end

#export(export_file, strategy = DEFAULT_STRATEGY) ⇒ Object



40
41
42
# File 'lib/repo-fixture/fixture.rb', line 40

def export(export_file, strategy = DEFAULT_STRATEGY)
  strategy_class_for(strategy).export(export_file, self)
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/repo-fixture/fixture.rb', line 32

def respond_to?(method)
  repo.respond_to?(method)
end

#sh(command) ⇒ Object



44
45
46
# File 'lib/repo-fixture/fixture.rb', line 44

def sh(command)
  repo.in_repo { `#{command}` }
end