ruby_avatar_smith 0.1.1 → 0.1.3
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/lib/ruby_avatar_smith/version.rb +1 -1
- data/lib/ruby_avatar_smith.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd15745a37c7040fc7f08377dce62bef9678e5b417366dd5615027daed29b27
|
4
|
+
data.tar.gz: cfdb84cfbadb15ab1a9704e1938766617f2da4787a50aab8db0c61482159ca62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35db88fa9be3e88171a243fef45dc4d0f302f8171aa26ac01b3d05405026c8ff1088372c20715a4745926bd1d24a57daccbea271856200cdd59434c21dae9cc0
|
7
|
+
data.tar.gz: 1fa50a35e57858bc092fb2267002910dd1f8fb46b5fc9b763a969f8ed18683f298b96329446316528c863927a0a2049a93496d50f43773b208a5754fb3d4196a
|
data/lib/ruby_avatar_smith.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rmagick'
|
4
|
-
|
4
|
+
require 'active_support'
|
5
|
+
require 'active_storage'
|
5
6
|
|
6
7
|
module RubyAvatarSmith
|
7
8
|
class Error < StandardError; end
|
@@ -11,8 +12,10 @@ module RubyAvatarSmith
|
|
11
12
|
# @param width [Integer] The width of the image.
|
12
13
|
# @param height [Integer] The height of the image.
|
13
14
|
# @param text [String] The text to be annotated on the image.
|
14
|
-
# @return [
|
15
|
-
|
15
|
+
# @return [ActiveStorage::Blob] The generated image blob.
|
16
|
+
# record User to which image should attach
|
17
|
+
def self.create_user_image(record, width, height, text)
|
18
|
+
byebug
|
16
19
|
rand_colour = "rgb(#{rand(0..256)}, #{rand(0..256)}, #{rand(0..256)})"
|
17
20
|
randam_bg = Magick::Image.new(width, height) { |col| col.background_color = rand_colour }
|
18
21
|
|
@@ -22,7 +25,13 @@ module RubyAvatarSmith
|
|
22
25
|
x.gravity = Magick::CenterGravity
|
23
26
|
x.pointsize = 50
|
24
27
|
end
|
25
|
-
|
26
|
-
randam_bg
|
28
|
+
randam_bg.format = "PNG"
|
29
|
+
random_image_blob = randam_bg.to_blob
|
30
|
+
record.picture.attach(
|
31
|
+
io: StringIO.new(random_image_blob),
|
32
|
+
filename: 'random_image.png',
|
33
|
+
content_type: 'image/png'
|
34
|
+
)
|
27
35
|
end
|
28
36
|
end
|
37
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_avatar_smith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KapilDevPal
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|