calvatar 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/calvatar-0.1.0.gem +0 -0
- data/lib/calvatar/engine.rb +11 -0
- data/lib/calvatar/version.rb +1 -1
- data/lib/calvatar.rb +15 -11
- data/lib/calvatar_helper.rb +7 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed16b97bc9e716297aa1166f2fc5f890b4b8d26b9924ff098f6feba59314741
|
4
|
+
data.tar.gz: 751f70838be604b7ac67f0c87136f52f7b58f6ad98a98fb908ded652066c8d9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c40556cd10b99a8e901bd982c8e830f7704ade22728e33fe318d52bff9f79728b29fe042f92bad8ca18f026fdf39d6e1de95575c883e45001d66a9c8fc57560d
|
7
|
+
data.tar.gz: 2b34f7417f58f22e86178af90b76a809cf5dd30bca806be01f6a3398c307ad6c3c8f01164ace3488df7a93b91c708f61c1cc9afa6d092f6472a2d0ef35654380
|
data/calvatar-0.1.0.gem
ADDED
Binary file
|
data/lib/calvatar/version.rb
CHANGED
data/lib/calvatar.rb
CHANGED
@@ -1,37 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'calvatar/version'
|
4
|
+
require 'calvatar_helper'
|
4
5
|
|
5
6
|
module Calvatar
|
6
7
|
class Avatar
|
7
|
-
|
8
|
+
DEFAULT_COLORS = [
|
8
9
|
'#FF5733', '#33FF57', '#3357FF', '#F1C40F', '#9B59B6',
|
9
10
|
'#E67E22', '#1ABC9C', '#2ECC71', '#3498DB', '#34495E'
|
10
|
-
]
|
11
|
+
].freeze
|
11
12
|
|
12
|
-
|
13
|
+
DEFAULT_SIZE = 50
|
14
|
+
|
15
|
+
def initialize(name, colors: DEFAULT_COLORS, size: DEFAULT_SIZE)
|
13
16
|
@initials = extract_initials(name)
|
14
|
-
@color =
|
17
|
+
@color = colors.sample
|
18
|
+
@size = size
|
15
19
|
end
|
16
20
|
|
17
21
|
def generate
|
18
22
|
svg = <<~SVG
|
19
|
-
<svg xmlns='http://www.w3.org/2000/svg' width='
|
20
|
-
<rect width='100' height='100' fill='#{@color}'/>
|
21
|
-
<text x='50%' y='50%' font-size='
|
23
|
+
<svg xmlns='http://www.w3.org/2000/svg' width='#{@size}' height='#{@size}'>
|
24
|
+
<rect width='100%' height='100%' fill='#{@color}'/>
|
25
|
+
<text x='50%' y='50%' font-size='#{@size * 0.8}' text-anchor='middle' fill='white' dy='.3em'>#{@initials}</text>
|
22
26
|
</svg>
|
23
27
|
SVG
|
24
|
-
svg.html_safe
|
28
|
+
svg.html_safe
|
25
29
|
end
|
26
30
|
|
27
|
-
def self.generate_avatar(name)
|
28
|
-
new(name).generate
|
31
|
+
def self.generate_avatar(name, colors: DEFAULT_COLORS, size: DEFAULT_SIZE)
|
32
|
+
new(name, colors: colors, size: size).generate
|
29
33
|
end
|
30
34
|
|
31
35
|
private
|
32
36
|
|
33
37
|
def extract_initials(name)
|
34
|
-
name.split.map(&:chr).join.upcase
|
38
|
+
name.split.map(&:chr).join.upcase
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calvatar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitória Calvi Meinerz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -23,8 +23,11 @@ files:
|
|
23
23
|
- LICENSE.txt
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
|
+
- calvatar-0.1.0.gem
|
26
27
|
- lib/calvatar.rb
|
28
|
+
- lib/calvatar/engine.rb
|
27
29
|
- lib/calvatar/version.rb
|
30
|
+
- lib/calvatar_helper.rb
|
28
31
|
- sig/calvatar.rbs
|
29
32
|
homepage: https://github.com/calvitoria/calvatar
|
30
33
|
licenses:
|