Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/the-rubies-way/fake_picture
Simple way to generate fake pictures by included in gem pictures for your blog, user and other type of seeds for dev env or even RSpec tests
https://github.com/the-rubies-way/fake_picture
awesome easy easy-to-use fake fake-images fake-pictures faker faker-generator faker-image gem image picture rails random rspec ruby ruby-on-rails rubyonrails
Last synced: 6 days ago
JSON representation
Simple way to generate fake pictures by included in gem pictures for your blog, user and other type of seeds for dev env or even RSpec tests
- Host: GitHub
- URL: https://github.com/the-rubies-way/fake_picture
- Owner: the-rubies-way
- License: mit
- Created: 2022-03-27T13:26:06.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-08-01T08:07:54.000Z (over 1 year ago)
- Last Synced: 2025-01-19T14:12:00.783Z (7 days ago)
- Topics: awesome, easy, easy-to-use, fake, fake-images, fake-pictures, faker, faker-generator, faker-image, gem, image, picture, rails, random, rspec, ruby, ruby-on-rails, rubyonrails
- Language: Ruby
- Homepage:
- Size: 44.7 MB
- Stars: 32
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Actions Status](https://github.com/loqimean/fake_picture/actions/workflows/CI.yml/badge.svg)](https://github.com/loqimean/fake_picture/actions)
[![Listed on OpenSource-Heroes.com](https://opensource-heroes.com/badge-v1.svg)](https://opensource-heroes.com/r/loqimean/fake_picture)# FakePicture
Welcome to my new gem! This is a gem for simple seeding, testing and etc by uploading fake pictures. Now you don't need to create too many folders with pictures, because you can use this gem which can give you the path to a random picture of a selected category or file if you need it.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'fake_picture'
```And then execute:
$ bundle install
Or install it yourself as:
$ gem install fake_picture
## Usage
###### FakePicture::Avatar:
```ruby
FakePicture::Avatar.man #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/avatar/pack/man-4.jpgFakePicture::Avatar.woman #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/avatar/pack/woman-4.jpg
```You can also call the method `person` if you want to get a random `avatar`:
```ruby
FakePicture::Avatar.person #=> "/Users/username/Workplace/fake_picture/lib/fake_picture/avatar/pack/woman-5.svg"
```###### FakePicture::Blog:
```ruby
FakePicture::Blog.preview #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/blog/pack/preview-4.jpg
```###### FakePicture::People:
```ruby
FakePicture::People.man #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/people/pack/man-4.jpgFakePicture::People.woman #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/people/pack/woman-4.jpg
```###### FakePicture::company:
```ruby
FakePicture::Company.logo #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/company/pack/logo-11.svg
```#### As file:
You can also call a method `file` with the method name of this class if you wanna get a picture as a file for some actions, like this:
```ruby
FakePicture::People.file(:man) #=> #
```#### As Base64:
You can also call a method `base64` with a method name of this class if you want to get the picture as a base64 encoded file for might be sending it somewhere, like this:
```ruby
FakePicture::People.base64(:man) #=> ""/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAwICQoJBwwKCgoNDQwOEh4TEhAQ\nEiQaGxUeKyYtLComKSkvNUQ6L.."
```#### In factories:
```ruby
FactoryBot.define do
factory :gallery do
file { FakePicture::Blog.file(:preview) }
end
end
```#### In specs:
```ruby
it 'some create user test' do
post :create, params: {
user: {
name: 'John',
avatar: FakePicture::Avatar.file(:man)
}
}
end
```#### In seeds:
```ruby
User.create(name: 'John', avatar: FakePicture::Avatar.file(:man))
```## Development
Run `rake spec` to run the tests. You can also run `rake console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/loqimean/fake_picture.
### To-Do
- [ ] add commerce pictures, like "products", and certain product types, e.g. "car", "phone" and like this, might be "cakes" 🙂## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Thanks for your support!
[](https://github.com/railsjazz)