ruby_avatar_smith 0.1.3 → 0.1.5

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: 5bab2124a265be724f9217ab0fa1c152e59b954e830e6c1c2604497cdb0e7ee2
4
+ data.tar.gz: 6fd50d3dc1c7749bfaaa7d9ec837e9c088367e92b4f17b7e31bdd5aa435d77c7
5
5
  SHA512:
6
- metadata.gz: 35db88fa9be3e88171a243fef45dc4d0f302f8171aa26ac01b3d05405026c8ff1088372c20715a4745926bd1d24a57daccbea271856200cdd59434c21dae9cc0
7
- data.tar.gz: 1fa50a35e57858bc092fb2267002910dd1f8fb46b5fc9b763a969f8ed18683f298b96329446316528c863927a0a2049a93496d50f43773b208a5754fb3d4196a
6
+ metadata.gz: 94cd39af701cd2f5cd73872b41a06710cd27d206ffefd44ef905f7f9cc2b52bacb466be2659b59dc63f4f7d69f5bc81e99749a0078c3635bf3edced653879482
7
+ data.tar.gz: ba5eaa120376e5b2684d1ddbebbe3b4d8ef497f761b4edfd8e55332bb5004a1d60292e498787ef2b16c758ff7c6bc05713873a7d627fafb3808452c01c1e4c2f
@@ -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.5"
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,29 +1,29 @@
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.5
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
- name: rmagick
14
+ name: mini_magick
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '0'
27
27
  description: ruby_avatar_smith is a Ruby gem that provides functionality to generate
28
28
  avatars with user initials. It can be used to create profile pictures dynamically.
29
29
  email:
@@ -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
  - - ">="