ruby_avatar_smith 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ca3e03d954d4c9ea0aeea0a9f8d8b570197f8304e85ffb1f1ac7910ea76bf24
4
- data.tar.gz: 73db8f2a0007de828493c16c178fbda12881047105aadf3ca0a637f66fe96f26
3
+ metadata.gz: bbd15745a37c7040fc7f08377dce62bef9678e5b417366dd5615027daed29b27
4
+ data.tar.gz: cfdb84cfbadb15ab1a9704e1938766617f2da4787a50aab8db0c61482159ca62
5
5
  SHA512:
6
- metadata.gz: 9540509b38c133b516606810bc50f2b4f9863396ad62b2f886fd70af9170157a355ecfc8dec6a6434866222f01d2924e8c3d8c4f87c6cec1154747776c98c421
7
- data.tar.gz: 1f80f3fc6379cdd12711ce3436e13306e95c5c0e069446a4a2f7c7fa47972dce8b066f23523cb112eeaeea03ad0c3ba895a80c681823fbd7dae46f06490d2a6a
6
+ metadata.gz: 35db88fa9be3e88171a243fef45dc4d0f302f8171aa26ac01b3d05405026c8ff1088372c20715a4745926bd1d24a57daccbea271856200cdd59434c21dae9cc0
7
+ data.tar.gz: 1fa50a35e57858bc092fb2267002910dd1f8fb46b5fc9b763a969f8ed18683f298b96329446316528c863927a0a2049a93496d50f43773b208a5754fb3d4196a
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyAvatarSmith
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rmagick'
4
- require_relative 'ruby_avatar_smith/version'
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 [Magick::Image] The generated image with the text annotation.
15
- def self.create_random_image(width, height, text)
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.0
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-23 00:00:00.000000000 Z
11
+ date: 2024-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick