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 +4 -4
- data/lib/ruby_avatar_smith/version.rb +1 -1
- data/lib/ruby_avatar_smith.rb +12 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 492326d33c8bd2f7c43538542da92917d974884f65394bb6285cc9e4ec8072e5
|
4
|
+
data.tar.gz: f393f2136b89ef2bd32098e9ffa4f50f7ec649ff6bdecf0e02699837eb7c7795
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ded6b557e228f26d0ca7177b6654078682888d6f81e9c729cdb96a0e850934514cbfed14c57cf80d3f80062493dae817a784a059f7d7c53964607c9a79b37e5
|
7
|
+
data.tar.gz: 12cfb6e32a5515b9acf5f84f6469c33c2eef078f3d2b34ba5afd69e947b8528e00675f90c354737811e81ec9508e6dd67fa94e28f4b3ff60d05364bd1cc754d3
|
data/lib/ruby_avatar_smith.rb
CHANGED
@@ -1,28 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
3
|
+
require 'open3'
|
4
|
+
require 'base64'
|
6
5
|
module RubyAvatarSmith
|
7
6
|
class Error < StandardError; end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
20
|
-
|
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
|
-
|
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.
|
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-
|
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: '
|
53
|
+
version: '2.5'
|
54
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - ">="
|