File: binary_fixtures.rb

package info (click to toggle)
ruby-riddle 2.3.1-2~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,752 kB
  • sloc: sql: 25,022; php: 5,992; ruby: 4,757; sh: 59; makefile: 5
file content (20 lines) | stat: -rw-r--r-- 575 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module BinaryFixtures
  def self.build_fixtures(version = nil)
    return if ENV['TRAVIS']

    version ||= %w(0.9.9 1.10 2.0.1 2.1.0)
    Array(version).each do |version|
      FileUtils.mkdir_p "spec/fixtures/data/#{version}"
      `php -f spec/fixtures/data_generator.#{version}.php`
    end
  end

  def query_contents(key)
    path     = "spec/fixtures/data/#{Riddle.loaded_version}/#{key}.bin"
    contents = open(path) { |f| f.read }
    contents.respond_to?(:encoding) ?
      contents.force_encoding('ASCII-8BIT') : contents
  end
end