fake_picture 0.2.2 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +51 -13
- data/lib/fake_picture/avatar/avatar.rb +1 -1
- data/lib/fake_picture/blog/blog.rb +1 -1
- data/lib/fake_picture/blog/pack/{night_street-1.jpg → preview-1.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-10.jpg → preview-10.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-10.jpg → preview-11.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-1.jpg → preview-12.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-2.jpg → preview-13.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-3.jpg → preview-14.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-4.jpg → preview-15.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-5.jpg → preview-16.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-6.jpg → preview-17.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-7.jpg → preview-18.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-8.jpg → preview-19.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-2.jpg → preview-2.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{day_street-9.jpg → preview-20.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-3.jpg → preview-3.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-4.jpg → preview-4.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-5.jpg → preview-5.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-6.jpg → preview-6.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-7.jpg → preview-7.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-8.jpg → preview-8.jpg} +0 -0
- data/lib/fake_picture/blog/pack/{night_street-9.jpg → preview-9.jpg} +0 -0
- data/lib/fake_picture/people/people.rb +1 -1
- data/lib/fake_picture/version.rb +1 -1
- data/lib/fake_picture.rb +11 -5
- metadata +23 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9aee13ffffb6146fb529b09d317c3137e637855ad8bbb573e6c96cc02f3afbf
|
|
4
|
+
data.tar.gz: a8d75765bffbebab69148306c2a6eb10d3cfa4907b81a0977108e317cbb0a886
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a6ccef4cad6746581936e08384d41207318fdf3236c02cc2f52c2527a86842ed75fe8657975cd4ea329d8126071809b88611c43426f77e72577523484afc509
|
|
7
|
+
data.tar.gz: 692c1b965f8adc957ebb06bc38aceabc309379c6e2f9b647e05e9eb2cac34232cd8a5d1cb072dee828e9292de0eec532a4cba02e8e3eb7aab9314848c28f0e0f
|
data/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
[](https://github.com/loqimean/fake_picture/actions)
|
|
1
2
|
|
|
2
3
|
# FakePicture
|
|
3
4
|
|
|
@@ -24,37 +25,74 @@ Or install it yourself as:
|
|
|
24
25
|
###### FakePicture::Avatar:
|
|
25
26
|
|
|
26
27
|
```ruby
|
|
27
|
-
FakePicture::Avatar.man
|
|
28
|
-
|
|
29
|
-
FakePicture::Avatar.man_file #=> #<File:/Users/username/workdirectory/fake_picture/lib/fake_picture/avatar/pack/man-2.jpg>
|
|
28
|
+
FakePicture::Avatar.man #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/avatar/pack/man-4.jpg
|
|
30
29
|
|
|
31
30
|
FakePicture::Avatar.woman #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/avatar/pack/woman-4.jpg
|
|
31
|
+
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
You can also call method `person` if you want to get random `avatar`:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
FakePicture::Avatar.person #=> "/Users/xi-master/Workplace/fake_picture/lib/fake_picture/avatar/pack/woman-5.svg"
|
|
34
37
|
```
|
|
35
38
|
|
|
36
39
|
###### FakePicture::Blog:
|
|
37
40
|
|
|
38
41
|
```ruby
|
|
39
|
-
FakePicture::Blog.
|
|
42
|
+
FakePicture::Blog.preview #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/blog/pack/preview-4.jpg
|
|
43
|
+
```
|
|
40
44
|
|
|
41
|
-
FakePicture::
|
|
45
|
+
###### FakePicture::People:
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
```ruby
|
|
48
|
+
FakePicture::People.man #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/people/pack/man-4.jpg
|
|
44
49
|
|
|
45
|
-
FakePicture::
|
|
50
|
+
FakePicture::People.woman #=> /Users/username/workdirectory/fake_picture/lib/fake_picture/people/pack/woman-4.jpg
|
|
46
51
|
```
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
#### As file:
|
|
54
|
+
|
|
55
|
+
You can also call a method `file` with method name of this class if you wanna get picture as file for some actions, like this:
|
|
49
56
|
|
|
50
57
|
```ruby
|
|
51
|
-
FakePicture::People.man
|
|
58
|
+
FakePicture::People.file(:man) #=> #<File:/Users/xi-master/Workplace/fake_picture/lib/fake_picture/avatar/pack/man-6.svg>
|
|
59
|
+
```
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
#### As Base64:
|
|
54
62
|
|
|
55
|
-
|
|
63
|
+
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:
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
```ruby
|
|
66
|
+
FakePicture::People.base64(:man) #=> ""/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAwICQoJBwwKCgoNDQwOEh4TEhAQ\nEiQaGxUeKyYtLComKSkvNUQ6L.."
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### In factories:
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
FactoryBot.define do
|
|
73
|
+
factory :gallery do
|
|
74
|
+
file { FakePicture::Blog.file(:preview) }
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### In specs:
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
it 'some create user test' do
|
|
83
|
+
post :create, params: {
|
|
84
|
+
user: {
|
|
85
|
+
name: 'John',
|
|
86
|
+
avatar: FakePicture::Avatar.file(:man)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
end
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### In seeds:
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
User.create(name: 'John', avatar: FakePicture::Avatar.file(:man))
|
|
58
96
|
```
|
|
59
97
|
|
|
60
98
|
## Development
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/fake_picture/version.rb
CHANGED
data/lib/fake_picture.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
require 'base64'
|
|
2
3
|
|
|
3
4
|
module FakePicture
|
|
4
5
|
class Base
|
|
@@ -11,24 +12,29 @@ module FakePicture
|
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
# def download(query)
|
|
14
|
-
#TODO: make downloading pictures to gem
|
|
15
|
+
#TODO: make downloading pictures to gem by a service: https://source.unsplash.com/random/<width>x<height>
|
|
15
16
|
# end
|
|
16
17
|
|
|
17
|
-
def self.
|
|
18
|
+
def self.initialize_methods(*method_names, new_random_method_name: nil) # from line 17 to 24 make code better
|
|
18
19
|
path_to_pack = "#{__dir__}/fake_picture/#{self.name.split('::').last.downcase}/pack"
|
|
19
20
|
|
|
20
21
|
self.superclass.check_pack_directory_readiness(path_to_pack)
|
|
21
22
|
|
|
22
23
|
[*method_names, :random].each do |name|
|
|
23
24
|
selector = name == :random ? '/*' : "/#{name}-*"
|
|
25
|
+
name = new_random_method_name if name == :random && !new_random_method_name.nil?
|
|
24
26
|
|
|
25
27
|
define_singleton_method :"#{name}" do
|
|
26
28
|
self.superclass.random_file("#{path_to_pack + selector}")
|
|
27
29
|
end
|
|
30
|
+
end
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
define_singleton_method :file do |method_name|
|
|
33
|
+
File.new(self.send(method_name))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
define_singleton_method :base64 do |method_name|
|
|
37
|
+
Base64.encode64(File.read(self.send(method_name)))
|
|
32
38
|
end
|
|
33
39
|
end
|
|
34
40
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fake_picture
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- loqimean
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-06-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: debug
|
|
@@ -80,26 +80,26 @@ files:
|
|
|
80
80
|
- lib/fake_picture/avatar/pack/woman-7.svg
|
|
81
81
|
- lib/fake_picture/avatar/pack/woman-8.svg
|
|
82
82
|
- lib/fake_picture/blog/blog.rb
|
|
83
|
-
- lib/fake_picture/blog/pack/
|
|
84
|
-
- lib/fake_picture/blog/pack/
|
|
85
|
-
- lib/fake_picture/blog/pack/
|
|
86
|
-
- lib/fake_picture/blog/pack/
|
|
87
|
-
- lib/fake_picture/blog/pack/
|
|
88
|
-
- lib/fake_picture/blog/pack/
|
|
89
|
-
- lib/fake_picture/blog/pack/
|
|
90
|
-
- lib/fake_picture/blog/pack/
|
|
91
|
-
- lib/fake_picture/blog/pack/
|
|
92
|
-
- lib/fake_picture/blog/pack/
|
|
93
|
-
- lib/fake_picture/blog/pack/
|
|
94
|
-
- lib/fake_picture/blog/pack/
|
|
95
|
-
- lib/fake_picture/blog/pack/
|
|
96
|
-
- lib/fake_picture/blog/pack/
|
|
97
|
-
- lib/fake_picture/blog/pack/
|
|
98
|
-
- lib/fake_picture/blog/pack/
|
|
99
|
-
- lib/fake_picture/blog/pack/
|
|
100
|
-
- lib/fake_picture/blog/pack/
|
|
101
|
-
- lib/fake_picture/blog/pack/
|
|
102
|
-
- lib/fake_picture/blog/pack/
|
|
83
|
+
- lib/fake_picture/blog/pack/preview-1.jpg
|
|
84
|
+
- lib/fake_picture/blog/pack/preview-10.jpg
|
|
85
|
+
- lib/fake_picture/blog/pack/preview-11.jpg
|
|
86
|
+
- lib/fake_picture/blog/pack/preview-12.jpg
|
|
87
|
+
- lib/fake_picture/blog/pack/preview-13.jpg
|
|
88
|
+
- lib/fake_picture/blog/pack/preview-14.jpg
|
|
89
|
+
- lib/fake_picture/blog/pack/preview-15.jpg
|
|
90
|
+
- lib/fake_picture/blog/pack/preview-16.jpg
|
|
91
|
+
- lib/fake_picture/blog/pack/preview-17.jpg
|
|
92
|
+
- lib/fake_picture/blog/pack/preview-18.jpg
|
|
93
|
+
- lib/fake_picture/blog/pack/preview-19.jpg
|
|
94
|
+
- lib/fake_picture/blog/pack/preview-2.jpg
|
|
95
|
+
- lib/fake_picture/blog/pack/preview-20.jpg
|
|
96
|
+
- lib/fake_picture/blog/pack/preview-3.jpg
|
|
97
|
+
- lib/fake_picture/blog/pack/preview-4.jpg
|
|
98
|
+
- lib/fake_picture/blog/pack/preview-5.jpg
|
|
99
|
+
- lib/fake_picture/blog/pack/preview-6.jpg
|
|
100
|
+
- lib/fake_picture/blog/pack/preview-7.jpg
|
|
101
|
+
- lib/fake_picture/blog/pack/preview-8.jpg
|
|
102
|
+
- lib/fake_picture/blog/pack/preview-9.jpg
|
|
103
103
|
- lib/fake_picture/people/pack/man-1.jpg
|
|
104
104
|
- lib/fake_picture/people/pack/man-10.jpg
|
|
105
105
|
- lib/fake_picture/people/pack/man-2.jpg
|
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
145
|
version: '0'
|
|
146
146
|
requirements: []
|
|
147
|
-
rubygems_version: 3.
|
|
147
|
+
rubygems_version: 3.3.7
|
|
148
148
|
signing_key:
|
|
149
149
|
specification_version: 4
|
|
150
150
|
summary: fake pictures
|