Last active
January 11, 2016 14:55
-
-
Save olmstadfm/f35447da6e8079cfbe93 to your computer and use it in GitHub Desktop.
Бесконечная генерация рандомных pdf через fuse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Для тестирования было нужно много pdf, различающихся хеш-суммой. | |
# Скрипт внизу через fuse создает папку с одним виртуальным файлом. | |
# Каждый раз, когда кто-то обращается к файлу, скрипт вычисляет что | |
# он отдаст. В моем случае это тупо врем десять раз, потому что мне | |
# достаточно чтобы просто хеши у файлов разные были. | |
# | |
# Это просто немного исправленный hello world из примеров работы с | |
# гемом, но полезно, да. | |
require 'rfusefs' | |
class HelloDir | |
def contents(path) | |
["hello.pdf"] | |
end | |
def file?(path) | |
path == '/hello.pdf' | |
end | |
def read_file(path) | |
"#{Time.now}\n"*10 | |
end | |
end | |
# Usage: #{$0} mountpoint [mount_options] | |
FuseFS.main() { |options| HelloDir.new } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment