diff --git a/CHANGELOG.md b/CHANGELOG.md
index f7e9195..78a4eb4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,11 +1,20 @@
+0.1.10
+-----
+
+- `LetterAvatar::AvatarHelper` module tweaks
+ - `letter_avatar_url` method, returning avatar proper url
+ - `letter_avatar_tag` doeas not require `ActionView::Helpers::AssetTagHelper`
+
0.1.9
-----
- `LetterAvatar::Configuration` module, `mattr_accessor` (depending on `ActiveSupport`) removed
+
fixes [#7](https://github.com/ksz2k/letter_avatar/issues/7)
0.1.5
-----
- Use [posix-spawn](https://github.com/rtomayko/posix-spawn) to instead of Kernel#exec to get better performance.
+
> fork(2) calls slow down as the parent process uses more memory due to the need to copy page tables.
diff --git a/README.md b/README.md
index 7c7e988..c8d1bea 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# LetterAvatar
-Gem for creating letter avatar from user's name.
+Gem for creating letter avatar from user's name (or any other strong / character).
-Code extracted from discourse source (thanks guys!) - I needed this functionality in three projects, so here's the gem! :-)
+Code extracted from [discourse](https://www.discourse.org/) source (thanks guys!) - I needed this functionality in three projects, so here's the gem! :-)
[](https://codeclimate.com/github/ksz2k/letter_avatar)
@@ -82,8 +82,13 @@ There's also helper for this. To use it, you need:
```ruby
letter_avatar_for('ksz2k', 200)
+ => "public/system/letter_avatars/2/K/87_178_230/200.png"
+ # or
+ letter_avatar_url('ksz2k', 200)
+ => "/system/letter_avatars/2/K/87_178_230/200.png"
# or even
letter_avatar_tag('ksz2k', 200, class: 'av')
+ => "
"
```
### Way to support non [a-z0-9] charsets
diff --git a/lib/letter_avatar/avatar_helper.rb b/lib/letter_avatar/avatar_helper.rb
index 067469b..f90fa4b 100644
--- a/lib/letter_avatar/avatar_helper.rb
+++ b/lib/letter_avatar/avatar_helper.rb
@@ -10,8 +10,17 @@ module LetterAvatar
avatar_path.to_s.sub('public/','/')
end
+ def letter_avatar_url(name, size = 64)
+ letter_avatar_url_for(letter_avatar_for(name, size))
+ end
+
def letter_avatar_tag(name, size = 64, options = {})
- image_tag(letter_avatar_url_for(letter_avatar_for(name, size)), options)
+ if defined?(ActionView::Helpers::AssetTagHelper)
+ include ActionView::Helpers::AssetTagHelper
+ image_tag(letter_avatar_url(name, size), options.merge(alt: name))
+ else
+ "
"
+ end
end
end
diff --git a/lib/letter_avatar/version.rb b/lib/letter_avatar/version.rb
index 6fad3b3..31c7b69 100644
--- a/lib/letter_avatar/version.rb
+++ b/lib/letter_avatar/version.rb
@@ -1,3 +1,3 @@
module LetterAvatar
- VERSION = "0.1.9"
+ VERSION = "0.1.10"
end
--
libgit2 0.21.0