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 +4 -4
- data/lib/ruby_avatar_smith/version.rb +1 -1
- data/lib/ruby_avatar_smith.rb +12 -27
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bab2124a265be724f9217ab0fa1c152e59b954e830e6c1c2604497cdb0e7ee2
|
4
|
+
data.tar.gz: 6fd50d3dc1c7749bfaaa7d9ec837e9c088367e92b4f17b7e31bdd5aa435d77c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94cd39af701cd2f5cd73872b41a06710cd27d206ffefd44ef905f7f9cc2b52bacb466be2659b59dc63f4f7d69f5bc81e99749a0078c3635bf3edced653879482
|
7
|
+
data.tar.gz: ba5eaa120376e5b2684d1ddbebbe3b4d8ef497f761b4edfd8e55332bb5004a1d60292e498787ef2b16c758ff7c6bc05713873a7d627fafb3808452c01c1e4c2f
|
data/lib/ruby_avatar_smith.rb
CHANGED
@@ -1,37 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require 'active_storage'
|
6
|
-
|
3
|
+
require 'open3'
|
4
|
+
require 'base64'
|
7
5
|
module RubyAvatarSmith
|
8
6
|
class Error < StandardError; end
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
23
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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.
|
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-
|
11
|
+
date: 2024-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: mini_magick
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
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: '
|
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: '
|
53
|
+
version: '2.5'
|
54
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - ">="
|