calvatar 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e19664a6fdb99eb02aadbe900dc0b0cd58e5386d2e149199a79df19866068af5
4
- data.tar.gz: f6573349fce95430ff476a6c60253386c9f4e05b11aac90661203c3decb357bf
3
+ metadata.gz: 1ed16b97bc9e716297aa1166f2fc5f890b4b8d26b9924ff098f6feba59314741
4
+ data.tar.gz: 751f70838be604b7ac67f0c87136f52f7b58f6ad98a98fb908ded652066c8d9b
5
5
  SHA512:
6
- metadata.gz: 348806daae68aa1d82d19083574e15038f3c0aca5b482833a011abe934d2521a4d27427290cc29b2d4121010b7e6e5a517e1dead24671c3589883bc8c64c2b23
7
- data.tar.gz: df8382832f550c500ffd78437b17809f9b6e41ed358a456b71b1abd32c466c3b2e0ec2d16d67ebb7807ecacf7a146e54d79155889fb9b30dca3f89d3e4596f2c
6
+ metadata.gz: c40556cd10b99a8e901bd982c8e830f7704ade22728e33fe318d52bff9f79728b29fe042f92bad8ca18f026fdf39d6e1de95575c883e45001d66a9c8fc57560d
7
+ data.tar.gz: 2b34f7417f58f22e86178af90b76a809cf5dd30bca806be01f6a3398c307ad6c3c8f01164ace3488df7a93b91c708f61c1cc9afa6d092f6472a2d0ef35654380
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Calvatar
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/calvatar.rb CHANGED
@@ -5,34 +5,37 @@ require 'calvatar_helper'
5
5
 
6
6
  module Calvatar
7
7
  class Avatar
8
- COLORS = [
8
+ DEFAULT_COLORS = [
9
9
  '#FF5733', '#33FF57', '#3357FF', '#F1C40F', '#9B59B6',
10
10
  '#E67E22', '#1ABC9C', '#2ECC71', '#3498DB', '#34495E'
11
- ]
11
+ ].freeze
12
12
 
13
- def initialize(name)
13
+ DEFAULT_SIZE = 50
14
+
15
+ def initialize(name, colors: DEFAULT_COLORS, size: DEFAULT_SIZE)
14
16
  @initials = extract_initials(name)
15
- @color = COLORS.sample
17
+ @color = colors.sample
18
+ @size = size
16
19
  end
17
20
 
18
21
  def generate
19
22
  svg = <<~SVG
20
- <svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'>
21
- <rect width='100' height='100' fill='#{@color}'/>
22
- <text x='50%' y='50%' font-size='40' text-anchor='middle' fill='white' dy='.3em'>#{@initials}</text>
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>
23
26
  </svg>
24
27
  SVG
25
- svg.html_safe # Ensure the output is HTML safe for Rails
28
+ svg.html_safe
26
29
  end
27
30
 
28
- def self.generate_avatar(name)
29
- new(name).generate
31
+ def self.generate_avatar(name, colors: DEFAULT_COLORS, size: DEFAULT_SIZE)
32
+ new(name, colors: colors, size: size).generate
30
33
  end
31
34
 
32
35
  private
33
36
 
34
37
  def extract_initials(name)
35
- name.split.map(&:chr).join.upcase # Get initials from the name
38
+ name.split.map(&:chr).join.upcase
36
39
  end
37
40
  end
38
41
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CalvatarHelper
4
- def calvatar_for(name)
5
- Calvatar::Avatar.generate_avatar(name)
4
+ def calvatar_for(name, colors: Calvatar::Avatar::DEFAULT_COLORS, size: Calvatar::Avatar::DEFAULT_SIZE)
5
+ Calvatar::Avatar.generate_avatar(name, colors: colors, size: size)
6
6
  end
7
7
  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.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-19 00:00:00.000000000 Z
11
+ date: 2024-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: