Sha256: 72583a6592d374b1aa52b14246580a8d8c92fe2aa6132e861d45c2e5b06b9048

Contents?: true

Size: 1008 Bytes

Versions: 2

Compression:

Stored size: 1008 Bytes

Contents

require 'fileutils'
module Mp4Renamer
  class FixtureHelper
    attr_reader :fixture_files,
                :fixtures_dir,
                :sample_files

    def initialize
      @fixtures_dir  = File.expand_path("../../../../fixtures", __FILE__)
      @fixture_files = %w(01.mp4 02.m4a).map { |file| [fixtures_dir, file].join(File::SEPARATOR) }
      @sample_files  = fixture_files.map { |file| sample_file(file) }
    end

    def setup
      fixture_files.each do |file|
        FileUtils.cp file, sample_file(file)
      end
    end

    def teardown
      fixture_files.each do |file|
        FileUtils.rm_rf sample_file(file)
      end
    end

    private

    def sample_file(file)
      [fixtures_dir, "sample_#{File.basename(file, '.*')}#{File.extname(file)}"].join(File::SEPARATOR)
    end
  end
end

if __FILE__ == $0
  require 'pry'
  require 'awesome_print'
  include Mp4Renamer

  helper = FixtureHelper.new

  helper.setup
  samples = helper.sample_files
  puts samples
  helper.teardown
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mp4_renamer-0.1.1 test/lib/mp4_renamer/fixture_helper.rb
mp4_renamer-0.1.0 test/lib/mp4_renamer/fixture_helper.rb