letter_avatar 0.3.3 → 0.3.4

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
  SHA1:
3
- metadata.gz: f6e9e336fbedc6f6e4956fca1594b012acfefe07
4
- data.tar.gz: fc40530bf77f1b67018ce3fed289ffc05275a994
3
+ metadata.gz: 7a9c80066e2882fbe010bf95f0abd9d050a5f093
4
+ data.tar.gz: 1aa4b8946c1e553b0ea7cb15e13387ec6cef6b99
5
5
  SHA512:
6
- metadata.gz: bf66b3c8c54a40f300fbd9ddd2eeda2f8b24286235a2c4050af2b3185c5591cc69c1ebcd0ce87bd35cfb9c0bbf85561aa25c97bc0ad6011400e500385140a8e0
7
- data.tar.gz: 2446a67eb62b0db7e78dbcab754c8f42bb40afd9e2dfa17a93a356e200aa52202c9875652f0739db3921024a9be481e96cf832772c8587004c0b36d89a2bcb17
6
+ metadata.gz: 453e68d3381212f3e9ad20144d31ad8e0d1095547b66f703afaa33b9dba4c7cc9bb38add0c2f3737634100992cfd2da25097e5a2f402fb8eb376d95b4572eeb2
7
+ data.tar.gz: 49a2e7af21d60ec7b24960948d71f803023116f0049f8e3072548778d60188b9bca367163398822c9c90861035d87e9c8c33a59474fa2dec0f650ab0d5aba90b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.3.4
2
+ -----
3
+
4
+ - enhanced `LetterAvatar::HasAvatar` helper module
5
+
1
6
  0.3.3
2
7
  -----
3
8
 
data/README.md CHANGED
@@ -71,6 +71,8 @@ LetterAvatar.generate 'ksz2k', 200
71
71
  => "public/system/letter_avatars/2/K/87_178_230/200.png"
72
72
  ```
73
73
 
74
+ ### In your controllers / views
75
+
74
76
  There's also helper for this. To use it, you need:
75
77
 
76
78
  * in your helper (eg. `ApplicationHelper`) or controller:
@@ -92,6 +94,30 @@ There's also helper for this. To use it, you need:
92
94
  => "<img class=\"av\" alt=\"ksz2k\" src=\"/system/letter_avatars/2/K/87_178_230/200.png\" />"
93
95
  ```
94
96
 
97
+ ### In your model
98
+
99
+ Say, you have a model `User` (which must have attribute or method `name`)
100
+
101
+ ```ruby
102
+ class User
103
+ include LetterAvatar::HasAvatar
104
+ ...
105
+ end
106
+ ```
107
+
108
+ Then, in your views you can use:
109
+
110
+ ```ruby
111
+ @user.avatar_path(200)
112
+ => "public/system/letter_avatars/2/K/87_178_230/200.png"
113
+ # or
114
+ @user.avatar_url(200)
115
+ => "/system/letter_avatars/2/K/87_178_230/200.png"
116
+ # or even
117
+ @user.avatar_tag(200, class: 'av')
118
+ => "<img class=\"av\" alt=\"ksz2k\" src=\"/system/letter_avatars/2/K/87_178_230/200.png\" />"
119
+ ```
120
+
95
121
  ### Way to support non [a-z0-9] charsets
96
122
 
97
123
  ```rb
@@ -3,6 +3,9 @@ module LetterAvatar
3
3
  def self.included(base)
4
4
  base.send :include, InstanceMethods
5
5
  base.extend ClassMethods
6
+ base.class_eval do
7
+ include LetterAvatar::AvatarHelper
8
+ end
6
9
  end
7
10
 
8
11
  module ClassMethods
@@ -13,14 +16,18 @@ module LetterAvatar
13
16
  base.extend ClassMethods
14
17
  end
15
18
 
16
- def avatar_path(size = 200)
17
- LetterAvatar.generate(name, size)
19
+ def avatar_path(size = 64)
20
+ letter_avatar_for(name, size)
18
21
  end
19
22
 
20
- def avatar_url(size = 200)
21
- avatar_path(size).gsub(/public/, '')
23
+ def avatar_url(size = 64)
24
+ letter_avatar_url(name, size)
22
25
  end
23
26
 
27
+ def avatar_tag(size = 64, options = {})
28
+ letter_avatar_tag(name, size, options)
29
+ end
30
+
24
31
  end
25
32
  end
26
33
  end
@@ -1,3 +1,3 @@
1
1
  module LetterAvatar
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letter_avatar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Discourse Developers
@@ -32,7 +32,7 @@ files:
32
32
  - lib/letter_avatar/version.rb
33
33
  homepage: https://github.com/ksz2k/letter_avatar
34
34
  licenses:
35
- - GPL
35
+ - GPL-2.0
36
36
  metadata: {}
37
37
  post_install_message:
38
38
  rdoc_options: []
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  version: '0'
51
51
  requirements: []
52
52
  rubyforge_project:
53
- rubygems_version: 2.4.6
53
+ rubygems_version: 2.5.1
54
54
  signing_key:
55
55
  specification_version: 4
56
56
  summary: Create nice initals avatars from your users usernames