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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8966d388eadb4d4a8bf06cb11b8f6bf089cccc92978434182a4a9612f5fe3138
4
- data.tar.gz: 8e6ef5dea561facca6109ee861e519cbf35c92dd8161632fd23b07707f6caf5b
3
+ metadata.gz: bbd15745a37c7040fc7f08377dce62bef9678e5b417366dd5615027daed29b27
4
+ data.tar.gz: cfdb84cfbadb15ab1a9704e1938766617f2da4787a50aab8db0c61482159ca62
5
5
  SHA512:
6
- metadata.gz: fc586ceb61302dc59c776021de3afabe6d7851c4a4ff5476237228a6d9e571880cbf3934eccb5a9bfe8c678378698979e3da18de9f2b24adef5af2d6bfe11ee5
7
- data.tar.gz: b80b8c7cc65913e3a2645e133e625a81c8f3cdaabd94e7e809e986e8f097155ee1a33802a3d7a1a169cd3878ebb71e5b1165b81915734506598e8d488a454bbb
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.1"
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.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-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