ui_avatars 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ui_avatars.rb +32 -20
  3. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a25f97f86a820d836820ea84dafc470303ea925a2ce5a4cd1f5392589e35df7e
4
- data.tar.gz: 39ef0259d137b2e2b4e7b2936fb304f66037bd7fa308152681f0962b9daae637
3
+ metadata.gz: e641efaff3eb0b6ea605173c6de0f5aacc75a1607c63d428227fbfbf2753ccc8
4
+ data.tar.gz: 7e9613ae832f47863d4f1a19ed182ff604626cc7abfe64c4437fe732199bcb44
5
5
  SHA512:
6
- metadata.gz: 1c66203c763fa91c5d0797d548c2fedc54c93143a55580753f75a9a1f2d9a401042221657e1a20ea57b473990490b52b9d91e1c8929d70c43c1dbe8991611356
7
- data.tar.gz: 2f99d6fee80d03df0ad1e20dfaa41b43717d3ced16b7528be423b7207f12e52992ec4d105ba5debe1d9ce8d29b031df74facddfa9c2519088fb082141e4b75f3
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
- def self.generateURL(name:, color:nil, background:nil, size:nil, font_size:nil, length:nil, rounded:nil, uppercase:nil, bold:nil, fmt:nil)
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
- url = "https://ui-avatars.com/api/"
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
- query = "?"
9
- query += "name=#{CGI.escape(name)}" # name is the only mandatory parameter
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.1
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-06 00:00:00.000000000 Z
11
+ date: 2021-05-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Generates a URL to an SVG Image based on user-specific parameters provided
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 https://ui-avatars.com
43
+ summary: Generate color-box avatars with users initials from provided names using
44
+ https://ui-avatars.com
43
45
  test_files: []