ui_avatars 0.0.1 → 0.0.3
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/lib/ui_avatars.rb +32 -20
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e641efaff3eb0b6ea605173c6de0f5aacc75a1607c63d428227fbfbf2753ccc8
|
4
|
+
data.tar.gz: 7e9613ae832f47863d4f1a19ed182ff604626cc7abfe64c4437fe732199bcb44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f547dbf80bbc4ba365d1d30d632ca3e8ee0f7aed67754b1a2c63ee2ca3b30f2d6be5e32b5f8bf7c101e3afebc1c852f044bffc06dd2eaa928e665b4c7b5e5c2e
|
7
|
+
data.tar.gz: 148aea74f4208f6d22b66e7adb9aba50f2ddbffc90a9e0fb8c6d3637550522db6cd1640bd210e4d7e5977378c14fc2bd58ff5d66342cf10ada4df099a0c3d90c
|
data/lib/ui_avatars.rb
CHANGED
@@ -1,26 +1,38 @@
|
|
1
1
|
require "cgi"
|
2
2
|
|
3
3
|
class UIAvatars
|
4
|
-
|
4
|
+
# Uses https://ui-avatars.com/ to generate colorful avatars for the initials of your name
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
# >> UIAvatars.generateURL(name: "Joe Bloggs", color: "blue")
|
8
|
+
# => "https://ui-avatars.com/api/?name=Joe+Bloggs&color=blue"
|
9
|
+
#
|
10
|
+
# Arguments:
|
11
|
+
# name: (String)
|
12
|
+
# color: (String)
|
13
|
+
# background: (String)
|
14
|
+
# size: (String)
|
15
|
+
# font-size: (String)
|
16
|
+
# length: (String)
|
17
|
+
# rounded: (String)
|
18
|
+
# uppercase: (String)
|
19
|
+
# bold: (String)
|
20
|
+
# fmt: (String)
|
21
|
+
def self.generateURL(name:, color: nil, background: nil, size: nil, font_size: nil, length: nil, rounded: nil, uppercase: nil, bold: nil, fmt: nil)
|
22
|
+
url = "https://ui-avatars.com/api/"
|
5
23
|
|
6
|
-
|
24
|
+
query = "?"
|
25
|
+
query += "name=#{CGI.escape(name)}" # name is the only mandatory parameter
|
26
|
+
query += "&color=#{color}" if color
|
27
|
+
query += "&background=#{background}" if background
|
28
|
+
query += "&size=#{size}" if size
|
29
|
+
query += "&font-size=#{font_size}" if font_size
|
30
|
+
query += "&length=#{length}" if length
|
31
|
+
query += "&rounded=#{rounded}" if rounded
|
32
|
+
query += "&uppercase=#{uppercase}" if uppercase
|
33
|
+
query += "&bold=#{bold}" if bold
|
34
|
+
query += "&format=#{fmt}" if fmt
|
7
35
|
|
8
|
-
|
9
|
-
|
10
|
-
query += "&color=#{CGI.escape(color)}" if color
|
11
|
-
query += "&background=#{CGI.escape(background)}" if background
|
12
|
-
query += "&size=#{CGI.escape(size)}" if size
|
13
|
-
query += "&font-size=#{CGI.escape(font_size)}" if font_size
|
14
|
-
query += "&length=#{CGI.escape(length)}" if length
|
15
|
-
query += "&rounded=#{CGI.escape(rounded)}" if rounded
|
16
|
-
query += "&uppercase=#{CGI.escape(uppercase)}" if uppercase
|
17
|
-
query += "&bold=#{CGI.escape(bold)}" if bold
|
18
|
-
query += "&format=#{CGI.escape(fmt)}" if fmt
|
19
|
-
|
20
|
-
return url + query
|
21
|
-
|
22
|
-
end
|
36
|
+
url + query
|
37
|
+
end
|
23
38
|
end
|
24
|
-
|
25
|
-
# configure using an initializer
|
26
|
-
# https://stackoverflow.com/questions/50458163/how-to-make-a-ruby-gem-read-an-initializer
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ui_avatars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Cowlishaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Generates
|
13
|
+
description: Generates the URL (via https://ui-avatars.com) to an SVG or PNG Image
|
14
|
+
of User's Initials with provided options
|
14
15
|
email: mark.cowlishaw@gmail.com
|
15
16
|
executables: []
|
16
17
|
extensions: []
|
@@ -39,5 +40,6 @@ requirements: []
|
|
39
40
|
rubygems_version: 3.0.9
|
40
41
|
signing_key:
|
41
42
|
specification_version: 4
|
42
|
-
summary: Generate avatars with initials from names using
|
43
|
+
summary: Generate color-box avatars with users initials from provided names using
|
44
|
+
https://ui-avatars.com
|
43
45
|
test_files: []
|