faker
faker copied to clipboard
Add image_file method to Placeholdit module
Hey,
Are you interested about a method to directly retrieve a file instead a url with Placeholdit module. The idea is to easily create attachment on an app without downloading the image file from URL.
Right now a created a method to do the job but may be it's something that could be done directly by Faker.
def image_file(size = '300x300', format = 'png', background_color = nil, text_color = nil, text = nil)
download_file image(size, format, background_color, text_color, text)
end
private
def download_file(url)
file = Tempfile.new("faker_placeholdit")
file.binmode
file << Net::HTTP.get(URI(url))
file.close
File.new(file.path)
end
What do you thing about ? If you think It's interesting, let me know and I could work on a pull request.
@vbrazo if you added the "feature request" tag, does that mean you'll accept a PR on this? 🤔
@aamarill no, I'm just categorizing the PRs and issues, so we can focus on the categories that we prefer.