letter_avatar 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +6 -4
- data/letter_avatar.gemspec +2 -0
- data/lib/letter_avatar/avatar.rb +17 -6
- data/lib/letter_avatar/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6c600ae9fbb741b9bdeabbe4f7d9768b3bdb1df
|
4
|
+
data.tar.gz: f0da07e2727308444186ba9c7c6f8d918f1a3c23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe6e677bbecd3ced0f224d6e73ed3efb02775e97abb31aaa106dafae57ccaf9d5febf0f6f9e4d421cbbe5f6ce8efb3c71191ddb63bdb558ca718123b943460bb
|
7
|
+
data.tar.gz: d8bd97a85865bb1d61bc2c91a8ecb079f64b8274720b2b9ed6d9e17026c8a499a2f63da729d7f98b657602f811221b3cd80f4b2af4cf02e989e5b64b826911eb
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Code extracted from discourse source (thanks guys!) - I needed this functionalit
|
|
10
10
|
|
11
11
|
#### Google's Inbox Palette
|
12
12
|
|
13
|
-
|
13
|
+
<img src="https://cloud.githubusercontent.com/assets/5518/13031513/43eefa76-d30b-11e5-8f06-85f8eb2a4fb6.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031514/43ef6d8a-d30b-11e5-9fbc-38ae526b56b3.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031517/43f0da12-d30b-11e5-8fef-6c7daf235a54.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031515/43f0568c-d30b-11e5-95c5-1653361d4443.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031512/43eebcc8-d30b-11e5-9f95-0093bfadd182.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031516/43f0d0bc-d30b-11e5-8822-f01a6a138ff8.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031519/44382430-d30b-11e5-96e4-bcd7ce5eb155.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031518/44378d04-d30b-11e5-9400-55ff46b94cbe.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031521/443a03cc-d30b-11e5-8467-9592e9dbb2ae.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031523/443badc6-d30b-11e5-9d72-45613018cab4.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031520/44394e14-d30b-11e5-966c-2eada89295c9.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031522/443a71fe-d30b-11e5-88f4-37d1fd220abb.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031525/44752b1e-d30b-11e5-8290-ed8888055e64.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031524/4471cef6-d30b-11e5-9f4c-004f993dd27b.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031526/4475a990-d30b-11e5-8be3-c8f4482dee03.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031527/44772482-d30b-11e5-92f0-b9190c312d70.png" width="60" /> <img src="https://cloud.githubusercontent.com/assets/5518/13031528/447804ce-d30b-11e5-8002-9424d5474ddb.png" width="60" />
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
@@ -57,7 +57,7 @@ end
|
|
57
57
|
|
58
58
|
We have two color palettes implemented: `iwanthue` and `google`.
|
59
59
|
|
60
|
-
Each of them have different colors, but the `iwanthue` also differently calculates the color for
|
60
|
+
Each of them have different colors, but the `iwanthue` also differently calculates the color for specified username.
|
61
61
|
|
62
62
|
The `google` selected will generate the same avatar for both, "Krzysiek" and "ksz2k" usernames given (both of them starts with letter "k"), but `iwanthue` will calculate it's md5 and then selects color, so there's huge chance that these usernames get different colors.
|
63
63
|
|
@@ -80,8 +80,8 @@ There's also helper for this. To use it, you need:
|
|
80
80
|
|
81
81
|
```ruby
|
82
82
|
letter_avatar_for('ksz2k', 200)
|
83
|
-
# or even
|
84
|
-
letter_avatar_tag('ksz2k', 200, class: 'av')
|
83
|
+
# or even
|
84
|
+
letter_avatar_tag('ksz2k', 200, class: 'av')
|
85
85
|
```
|
86
86
|
|
87
87
|
### Way to support non [a-z0-9] charsets
|
@@ -100,6 +100,8 @@ Then you can get right avatar now:
|
|
100
100
|
|
101
101
|
```rb
|
102
102
|
letter_avatar_for(user.username_for_avatar, 200)
|
103
|
+
# or
|
104
|
+
letter_avatar_tag(user.username_for_avatar, 200, class: 'av')
|
103
105
|
```
|
104
106
|
|
105
107
|
## Contributing
|
data/letter_avatar.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
+
spec.add_dependency 'posix-spawn', '>= 0.3.0'
|
24
|
+
|
23
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
26
|
spec.add_development_dependency "rake"
|
25
27
|
end
|
data/lib/letter_avatar/avatar.rb
CHANGED
@@ -12,6 +12,8 @@ module LetterAvatar
|
|
12
12
|
|
13
13
|
FILL_COLOR = 'rgba(255, 255, 255, 0.65)'.freeze
|
14
14
|
|
15
|
+
FONT_FILENAME = File.join(File.expand_path("../../", File.dirname(__FILE__)), "Roboto-Medium")
|
16
|
+
|
15
17
|
class << self
|
16
18
|
|
17
19
|
class Identity
|
@@ -64,21 +66,30 @@ module LetterAvatar
|
|
64
66
|
color = identity.color
|
65
67
|
letter = identity.letter
|
66
68
|
|
69
|
+
|
67
70
|
filename = fullsize_path(identity)
|
68
71
|
|
69
|
-
|
72
|
+
commands = %W(
|
73
|
+
convert
|
70
74
|
-size 240x240
|
71
75
|
xc:#{to_rgb(color)}
|
72
76
|
-pointsize 140
|
73
|
-
-font
|
74
|
-
-weight
|
77
|
+
-font #{FONT_FILENAME}
|
78
|
+
-weight 300
|
75
79
|
-fill '#{FILL_COLOR}'
|
76
80
|
-gravity Center
|
77
|
-
-annotate -0+
|
81
|
+
-annotate -0+5 '#{letter}'
|
78
82
|
'#{filename}'
|
79
|
-
|
83
|
+
)
|
80
84
|
|
81
|
-
|
85
|
+
command = commands.join(' ')
|
86
|
+
|
87
|
+
pid, stdin, stdout, stderr = POSIX::Spawn.popen4(command)
|
88
|
+
Process.waitpid(pid)
|
89
|
+
err = stderr.read
|
90
|
+
if err != nil && err.length > 0
|
91
|
+
raise "letter_avatar error: #{err.strip}"
|
92
|
+
end
|
82
93
|
|
83
94
|
filename
|
84
95
|
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- discourse developers
|
@@ -11,8 +11,22 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: posix-spawn
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.3.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.3.0
|
16
30
|
- !ruby/object:Gem::Dependency
|
17
31
|
name: bundler
|
18
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,6 +63,7 @@ extensions: []
|
|
49
63
|
extra_rdoc_files: []
|
50
64
|
files:
|
51
65
|
- ".gitignore"
|
66
|
+
- CHANGELOG.md
|
52
67
|
- Gemfile
|
53
68
|
- LICENSE.txt
|
54
69
|
- README.md
|