ruby_avatar_smith 0.1.1 → 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: 8966d388eadb4d4a8bf06cb11b8f6bf089cccc92978434182a4a9612f5fe3138
4
- data.tar.gz: 8e6ef5dea561facca6109ee861e519cbf35c92dd8161632fd23b07707f6caf5b
3
+ metadata.gz: 492326d33c8bd2f7c43538542da92917d974884f65394bb6285cc9e4ec8072e5
4
+ data.tar.gz: f393f2136b89ef2bd32098e9ffa4f50f7ec649ff6bdecf0e02699837eb7c7795
5
5
  SHA512:
6
- metadata.gz: fc586ceb61302dc59c776021de3afabe6d7851c4a4ff5476237228a6d9e571880cbf3934eccb5a9bfe8c678378698979e3da18de9f2b24adef5af2d6bfe11ee5
7
- data.tar.gz: b80b8c7cc65913e3a2645e133e625a81c8f3cdaabd94e7e809e986e8f097155ee1a33802a3d7a1a169cd3878ebb71e5b1165b81915734506598e8d488a454bbb
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.1"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -1,28 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rmagick'
4
- require_relative 'ruby_avatar_smith/version'
5
-
3
+ require 'open3'
4
+ require 'base64'
6
5
  module RubyAvatarSmith
7
6
  class Error < StandardError; end
8
7
 
9
- # Generates a random image with the specified width, height, and text annotation.
10
- #
11
- # @param width [Integer] The width of the image.
12
- # @param height [Integer] The height of the image.
13
- # @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)
16
- rand_colour = "rgb(#{rand(0..256)}, #{rand(0..256)}, #{rand(0..256)})"
17
- 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}\"")
18
11
 
19
- text_over_image = Magick::Draw.new
20
- text_over_image.annotate(randam_bg, 0, 0, 0, 0, text) do |x|
21
- x.fill = 'gray83'
22
- x.gravity = Magick::CenterGravity
23
- x.pointsize = 50
12
+ unless status.success?
13
+ raise "Node.js script failed: #{stderr}"
24
14
  end
25
15
 
26
- randam_bg
16
+ data_url = stdout.strip
17
+ base64_image = data_url.split(',')[1]
18
+ Base64.decode64(base64_image)
19
+ end
27
20
  end
28
21
  end
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.1
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-23 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
  - - ">="