avatarly 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/avatarly.rb +6 -4
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6280b257572ca4c9eae1287abbc892d4296cd53a1b840cdd70890d340049ee84
4
- data.tar.gz: 20c6fe9eb3b506b843b6f29b54b2629106ac6013922ede8a12932015f7bc43c3
3
+ metadata.gz: 3666c36f32ade5c2a49d8609df6d7d529a6c5656d1abb2b5c62fd9a714db9f89
4
+ data.tar.gz: 490763ff605a4afaa7ca15593ab2e1586d31db867fe33fc8412c61293687823c
5
5
  SHA512:
6
- metadata.gz: 624fe874190fd3a3318ab7d5f14b86e4fcaa8c791139dbabbb20672f2bec24064eeea0260dc9dcc0a93a51480e20632895d496ef0c755b8179cee93d0611036d
7
- data.tar.gz: 91eb1b9ed5ab7db9a98fa0c08576623c3dbe8052a05a081a4d527360e08cf2c7996ad795781bd70e8a850a3d01b8b34aad6aec0ee67247df84ec292a85bc01c5
6
+ metadata.gz: ce7015d45196252e381e5421a2188d1897a80f279575333d1931864a8aa7e707dd46bc7d8ce3907230753b089ee5aacd754f37978563bf93a7a401264e9b942f
7
+ data.tar.gz: 6d998d24528ee1872056631cd2d985aea4aaf6e361aed2c1844f597b645f04cff9ef38bd91f8347a891700b9ac037a5f10abc6c70f416a213e4eab5a4cb4cd69
data/README.md CHANGED
@@ -53,6 +53,7 @@ the only required parameter is <tt>text</tt>. Other options that you can pass ar
53
53
  * <tt>vertical_offset</tt> (default: 0)
54
54
  * <tt>format</tt> (default: png)
55
55
  * <tt>lang</tt> (language code if unicode aware upcase required - e.g: :tr, default: nil)
56
+ * <tt>separator</tt> (the custom string or regex used to split <tt>text</tt> into its initials)
56
57
 
57
58
  As a result you will get an image blob - rest is up to you, do whatever you want with it.
58
59
 
@@ -17,9 +17,9 @@ class Avatarly
17
17
  class << self
18
18
  def generate_avatar(text, opts={})
19
19
  if opts[:lang]
20
- text = UnicodeUtils.upcase(initials(text.to_s.gsub(/[^[[:word:]] ]/,'').strip), opts[:lang])
20
+ text = UnicodeUtils.upcase(initials(text.to_s.gsub(/[^[[:word:]] ]/,'').strip, opts), opts[:lang])
21
21
  else
22
- text = initials(text.to_s.gsub(/[^\w ]/,'').strip).upcase
22
+ text = initials(text.to_s.gsub(/[^\w ]/,'').strip, opts).upcase
23
23
  end
24
24
  generate_image(text, parse_options(opts)).to_blob
25
25
  end
@@ -56,8 +56,10 @@ class Avatarly
56
56
  end.annotate(canvas, 0, 0, 0, opts[:vertical_offset], text)
57
57
  end
58
58
 
59
- def initials(text)
60
- if text.is_email?
59
+ def initials(text, opts)
60
+ if opts[:separator]
61
+ initials_for_separator(text, opts[:separator])
62
+ elsif text.is_email?
61
63
  initials_for_separator(text.split("@").first, ".")
62
64
  elsif text.include?(" ")
63
65
  initials_for_separator(text, " ")
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avatarly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukasz Odziewa
8
+ - Artur Trzop
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
12
+ date: 2019-11-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rmagick
@@ -83,8 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
84
  - !ruby/object:Gem::Version
84
85
  version: '0'
85
86
  requirements: []
86
- rubyforge_project:
87
- rubygems_version: 2.7.6
87
+ rubygems_version: 3.0.6
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Simple gem for creating gmail-like user avatars with initials.