ruby_avatar_smith 0.1.3 → 0.1.4

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: bbd15745a37c7040fc7f08377dce62bef9678e5b417366dd5615027daed29b27
4
- data.tar.gz: cfdb84cfbadb15ab1a9704e1938766617f2da4787a50aab8db0c61482159ca62
3
+ metadata.gz: 492326d33c8bd2f7c43538542da92917d974884f65394bb6285cc9e4ec8072e5
4
+ data.tar.gz: f393f2136b89ef2bd32098e9ffa4f50f7ec649ff6bdecf0e02699837eb7c7795
5
5
  SHA512:
6
- metadata.gz: 35db88fa9be3e88171a243fef45dc4d0f302f8171aa26ac01b3d05405026c8ff1088372c20715a4745926bd1d24a57daccbea271856200cdd59434c21dae9cc0
7
- data.tar.gz: 1fa50a35e57858bc092fb2267002910dd1f8fb46b5fc9b763a969f8ed18683f298b96329446316528c863927a0a2049a93496d50f43773b208a5754fb3d4196a
6
+ metadata.gz: 4ded6b557e228f26d0ca7177b6654078682888d6f81e9c729cdb96a0e850934514cbfed14c57cf80d3f80062493dae817a784a059f7d7c53964607c9a79b37e5
7
+ data.tar.gz: 12cfb6e32a5515b9acf5f84f6469c33c2eef078f3d2b34ba5afd69e947b8528e00675f90c354737811e81ec9508e6dd67fa94e28f4b3ff60d05364bd1cc754d3
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyAvatarSmith
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -1,37 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rmagick'
4
- require 'active_support'
5
- require 'active_storage'
6
-
3
+ require 'open3'
4
+ require 'base64'
7
5
  module RubyAvatarSmith
8
6
  class Error < StandardError; end
9
7
 
10
- # Generates a random image with the specified width, height, and text annotation.
11
- #
12
- # @param width [Integer] The width of the image.
13
- # @param height [Integer] The height of the image.
14
- # @param text [String] The text to be annotated on the image.
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
19
- rand_colour = "rgb(#{rand(0..256)}, #{rand(0..256)}, #{rand(0..256)})"
20
- randam_bg = Magick::Image.new(width, height) { |col| col.background_color = rand_colour }
8
+ def self.generate_image(text = "Hello, World!")
9
+ script_path = File.expand_path('../scripts/generate_image.js', __FILE__)
10
+ stdout, stderr, status = Open3.capture3("node #{script_path} \"#{text}\"")
21
11
 
22
- text_over_image = Magick::Draw.new
23
- text_over_image.annotate(randam_bg, 0, 0, 0, 0, text) do |x|
24
- x.fill = 'gray83'
25
- x.gravity = Magick::CenterGravity
26
- x.pointsize = 50
12
+ unless status.success?
13
+ raise "Node.js script failed: #{stderr}"
27
14
  end
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
- )
15
+
16
+ data_url = stdout.strip
17
+ base64_image = data_url.split(',')[1]
18
+ Base64.decode64(base64_image)
19
+ end
35
20
  end
36
21
  end
37
22
 
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.3
4
+ version: 0.1.4
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-26 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
@@ -50,7 +50,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '3.0'
53
+ version: '2.5'
54
54
  required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  requirements:
56
56
  - - ">="