letter_avatar 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9937b0181e1075bff408e36208441cfb7eff4515
4
- data.tar.gz: df264c6a6abc31765f0d2184ca943eeab5051448
3
+ metadata.gz: 989abb8166d1c71d0da71f8182b8d9b0755ad042
4
+ data.tar.gz: 5109232282967eac2d5c5b854eb12590690cc61b
5
5
  SHA512:
6
- metadata.gz: 6d6fb28151cc89bb946b7d2d263cc3a1ff965ac54c23f387734dc09f89399cb9c66433a5c58c16c3ac87f55cba6e028ebb2828a4bd1c25b76f6044b02fd48329
7
- data.tar.gz: b227e934e71a03ee2e63f8974708d95b01fe61f9d1bfba62792f966afa434e88214bfb44827ef737aa4ffbdb326b96a909ff4178bd105fb5ebb54f53c0f91444
6
+ metadata.gz: dc911d3955696fdb1b4a6f3d0037efa7641aa4ec7f76534e7488e6438d424f039af9f616abf5fa0e7bdbaef73fa3aa1493675e101950b9f9044ce1801111fce0
7
+ data.tar.gz: 5b186666a21e8ab53ab6ead898cbb9acc0f661c48793964cb2bb9775f42a8ef0ae1f7d9e5f328192698308297e921e0e4695a09e82bf35292bc3b49ff796cee1
data/README.md CHANGED
@@ -6,11 +6,23 @@ Code extracted from discourse source (thanks guys!) - I needed this functionalit
6
6
 
7
7
  [![Code Climate](https://codeclimate.com/github/ksz2k/letter_avatar/badges/gpa.svg)](https://codeclimate.com/github/ksz2k/letter_avatar)
8
8
 
9
+ ## Examples
10
+
11
+ ![a](https://cloud.githubusercontent.com/assets/5518/11028712/fb4ceb8a-86fb-11e5-8a94-c75eaf46b089.png) ![b](https://cloud.githubusercontent.com/assets/5518/11028713/fb55fc5c-86fb-11e5-9a67-a4e84ee618be.png) ![c](https://cloud.githubusercontent.com/assets/5518/11028715/fb5a8178-86fb-11e5-9312-9cc990b1a94f.png) ![d](https://cloud.githubusercontent.com/assets/5518/11028714/fb567f88-86fb-11e5-8e99-b14602321f69.png) ![e](https://cloud.githubusercontent.com/assets/5518/11028716/fb61d194-86fb-11e5-8bab-bc69cad905cc.png) ![f](https://cloud.githubusercontent.com/assets/5518/11028717/fb656d54-86fb-11e5-810a-f8a3847c0da8.png) ![g](https://cloud.githubusercontent.com/assets/5518/11028718/fb862e7c-86fb-11e5-8b46-42a64fb15f46.png) ![h](https://cloud.githubusercontent.com/assets/5518/11028719/fb8f1910-86fb-11e5-9794-433a9490b15a.png) ![j](https://cloud.githubusercontent.com/assets/5518/11028720/fb8f200e-86fb-11e5-8b20-476745abfe21.png) ![l](https://cloud.githubusercontent.com/assets/5518/11028721/fb923654-86fb-11e5-961c-92be1aaedef8.png) ![m](https://cloud.githubusercontent.com/assets/5518/11028722/fb9e68b6-86fb-11e5-8ba6-4e8ece3a9d89.png) ![n](https://cloud.githubusercontent.com/assets/5518/11028723/fba26826-86fb-11e5-9611-bde4bc7d84ed.png) ![p](https://cloud.githubusercontent.com/assets/5518/11028724/fbc4d9ec-86fb-11e5-85f3-0e0b46bbc9a1.png) ![s](https://cloud.githubusercontent.com/assets/5518/11028725/fbc5d464-86fb-11e5-937e-de11c747b70d.png)
12
+
9
13
  ## Installation
10
14
 
11
15
  System requirements
12
16
 
13
- sudo apt-get install -y imagemagick
17
+ ```bash
18
+ $ sudo apt-get install -y imagemagick
19
+ ```
20
+
21
+ Mac OS X
22
+
23
+ ```bash
24
+ $ brew install imagemagick ghostscript
25
+ ```
14
26
 
15
27
  Add this line to your application's Gemfile:
16
28
 
@@ -20,17 +32,21 @@ gem 'letter_avatar'
20
32
 
21
33
  And then execute:
22
34
 
23
- $ bundle
35
+ ```bash
36
+ $ bundle
37
+ ```
24
38
 
25
39
  Or install it yourself as:
26
40
 
27
- $ gem install letter_avatar
41
+ ```bash
42
+ $ gem install letter_avatar
43
+ ```
28
44
 
29
45
  ## Configuration
30
46
 
31
47
  ```ruby
32
48
  LetterAvatar.setup do |config|
33
- config.cache_base_path='public/system/lets' # default is 'public/system'
49
+ config.cache_base_path = 'public/system/lets' # default is 'public/system'
34
50
  end
35
51
  ```
36
52
 
data/Roboto-Medium ADDED
Binary file
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.rubyforge_project = "letter_avatar"
17
17
 
18
- spec.files = `git ls-files`.split($/)
18
+ spec.files = `git ls-files`.split($/) + ['Roboto-Medium']
19
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ["lib"]
@@ -10,7 +10,9 @@ module LetterAvatar
10
10
  # we will need to change this
11
11
  FULLSIZE = 240
12
12
 
13
- class<<self
13
+ FILL_COLOR = 'rgba(255, 255, 255, 0.65)'.freeze
14
+
15
+ class << self
14
16
 
15
17
  class Identity
16
18
  attr_accessor :color, :letter
@@ -63,17 +65,16 @@ module LetterAvatar
63
65
  letter = identity.letter
64
66
 
65
67
  filename = fullsize_path(identity)
66
- stroke = darken(color, 0.8)
67
68
 
68
69
  instructions = %W{
69
70
  -size 240x240
70
71
  xc:#{to_rgb(color)}
71
- -pointsize 200
72
- -fill white
72
+ -pointsize 140
73
+ -font Roboto-Medium
74
+ -weight 500
75
+ -fill '#{FILL_COLOR}'
73
76
  -gravity Center
74
- -stroke #{to_rgb(stroke)}
75
- -strokewidth 2
76
- -annotate -5+20 '#{letter}'
77
+ -annotate -0+10 '#{letter}'
77
78
  '#{filename}'
78
79
  }
79
80
 
@@ -1,237 +1,55 @@
1
1
  module LetterAvatar
2
2
  module Colors
3
3
 
4
+ # Colors form Google Inbox
5
+ # https://inbox.google.com
6
+ COLORS = [
7
+ [226, 95, 81], # A
8
+ [242, 96, 145], # B
9
+ [187, 101, 202], # C
10
+ [149, 114, 207], # D
11
+ [120, 132, 205], # E
12
+ [91, 149, 249], # F
13
+ [72, 194, 249], # G
14
+ [69, 208, 226], # H
15
+ [72, 182, 172], # I
16
+ [82, 188, 137], # J
17
+ [155, 206, 95], # K
18
+ [212, 227, 74], # L
19
+ [254, 218, 16], # M
20
+ [247, 192, 0], # N
21
+ [255, 168, 0], # O
22
+ [255, 138, 96], # P
23
+ [194, 194, 194], # Q
24
+ [143, 164, 175], # R
25
+ [162, 136, 126], # S
26
+ [163, 163, 163], # T
27
+ [175, 181, 226], # U
28
+ [179, 155, 221], # V
29
+ [194, 194, 194], # W
30
+ [124, 222, 235], # X
31
+ [188, 170, 164], # Y
32
+ [173, 214, 125] # Z
33
+ ]
34
+
4
35
  def self.for(username)
5
- all[
6
- Digest::MD5.hexdigest(username)[0...15].to_i(16) % all.length
7
- ]
36
+ char = username[0]
37
+ char.upcase!
38
+ if /[A-Z]/.match(char)
39
+ # 65 is 'A' ord
40
+ idx = char.ord - 65
41
+ return all[idx]
42
+ end
43
+
44
+ if /[\d]/.match(char)
45
+ return all[char.to_i]
46
+ end
47
+
48
+ all[Digest::MD5.hexdigest(username)[0...15].to_i(16) % all.length]
8
49
  end
9
50
 
10
- # palette of optimally disctinct colors
11
- # cf. http://tools.medialab.sciences-po.fr/iwanthue/index.php
12
- # parameters used:
13
- # - H: 0 - 360
14
- # - C: 0 - 2
15
- # - L: 0.75 - 1.5
16
51
  def self.all
17
- [
18
- [198,125,40],
19
- [61,155,243],
20
- [74,243,75],
21
- [238,89,166],
22
- [52,240,224],
23
- [177,156,155],
24
- [240,120,145],
25
- [111,154,78],
26
- [237,179,245],
27
- [237,101,95],
28
- [89,239,155],
29
- [43,254,70],
30
- [163,212,245],
31
- [65,152,142],
32
- [165,135,246],
33
- [181,166,38],
34
- [187,229,206],
35
- [77,164,25],
36
- [179,246,101],
37
- [234,93,37],
38
- [225,155,115],
39
- [142,140,188],
40
- [223,120,140],
41
- [249,174,27],
42
- [244,117,225],
43
- [137,141,102],
44
- [75,191,146],
45
- [188,239,142],
46
- [164,199,145],
47
- [173,120,149],
48
- [59,195,89],
49
- [222,198,220],
50
- [68,145,187],
51
- [236,204,179],
52
- [159,195,72],
53
- [188,121,189],
54
- [166,160,85],
55
- [181,233,37],
56
- [236,177,85],
57
- [121,147,160],
58
- [234,218,110],
59
- [241,157,191],
60
- [62,200,234],
61
- [133,243,34],
62
- [88,149,110],
63
- [59,228,248],
64
- [183,119,118],
65
- [251,195,45],
66
- [113,196,122],
67
- [197,115,70],
68
- [80,175,187],
69
- [103,231,238],
70
- [240,72,133],
71
- [228,149,241],
72
- [180,188,159],
73
- [172,132,85],
74
- [180,135,251],
75
- [236,194,58],
76
- [217,176,109],
77
- [88,244,199],
78
- [186,157,239],
79
- [113,230,96],
80
- [206,115,165],
81
- [244,178,163],
82
- [230,139,26],
83
- [241,125,89],
84
- [83,160,66],
85
- [107,190,166],
86
- [197,161,210],
87
- [198,203,245],
88
- [238,117,19],
89
- [228,119,116],
90
- [131,156,41],
91
- [145,178,168],
92
- [139,170,220],
93
- [233,95,125],
94
- [87,178,230],
95
- [157,200,119],
96
- [237,140,76],
97
- [229,185,186],
98
- [144,206,212],
99
- [236,209,158],
100
- [185,189,79],
101
- [34,208,66],
102
- [84,238,129],
103
- [133,140,134],
104
- [67,157,94],
105
- [168,179,25],
106
- [140,145,240],
107
- [151,241,125],
108
- [67,162,107],
109
- [200,156,21],
110
- [169,173,189],
111
- [226,116,189],
112
- [133,231,191],
113
- [194,161,63],
114
- [241,77,99],
115
- [241,217,53],
116
- [123,204,105],
117
- [210,201,119],
118
- [229,108,155],
119
- [240,91,72],
120
- [187,115,210],
121
- [240,163,100],
122
- [178,217,57],
123
- [179,135,116],
124
- [204,211,24],
125
- [186,135,57],
126
- [223,176,135],
127
- [204,148,151],
128
- [116,223,50],
129
- [95,195,46],
130
- [123,160,236],
131
- [181,172,131],
132
- [142,220,202],
133
- [240,140,112],
134
- [172,145,164],
135
- [228,124,45],
136
- [135,151,243],
137
- [42,205,125],
138
- [192,233,116],
139
- [119,170,114],
140
- [158,138,26],
141
- [73,190,183],
142
- [185,229,243],
143
- [227,107,55],
144
- [196,205,202],
145
- [132,143,60],
146
- [233,192,237],
147
- [62,150,220],
148
- [205,201,141],
149
- [106,140,190],
150
- [161,131,205],
151
- [135,134,158],
152
- [198,139,81],
153
- [115,171,32],
154
- [101,181,67],
155
- [149,137,119],
156
- [37,142,183],
157
- [183,130,175],
158
- [168,125,133],
159
- [124,142,87],
160
- [236,156,171],
161
- [232,194,91],
162
- [219,200,69],
163
- [144,219,34],
164
- [219,95,187],
165
- [145,154,217],
166
- [165,185,100],
167
- [127,238,163],
168
- [224,178,198],
169
- [119,153,120],
170
- [124,212,92],
171
- [172,161,105],
172
- [231,155,135],
173
- [157,132,101],
174
- [122,185,146],
175
- [53,166,51],
176
- [70,163,90],
177
- [150,190,213],
178
- [210,107,60],
179
- [166,152,185],
180
- [159,194,159],
181
- [39,141,222],
182
- [202,176,161],
183
- [95,140,229],
184
- [168,142,87],
185
- [93,170,203],
186
- [159,142,54],
187
- [14,168,39],
188
- [94,150,149],
189
- [187,206,136],
190
- [157,224,166],
191
- [235,158,208],
192
- [109,232,216],
193
- [141,201,87],
194
- [208,124,118],
195
- [142,125,214],
196
- [19,237,174],
197
- [72,219,41],
198
- [234,102,111],
199
- [168,142,79],
200
- [188,135,35],
201
- [95,155,143],
202
- [148,173,116],
203
- [223,112,95],
204
- [228,128,236],
205
- [206,114,54],
206
- [195,119,88],
207
- [235,140,94],
208
- [235,202,125],
209
- [233,155,153],
210
- [214,214,238],
211
- [246,200,35],
212
- [151,125,171],
213
- [132,145,172],
214
- [131,142,118],
215
- [199,126,150],
216
- [61,162,123],
217
- [58,176,151],
218
- [215,141,69],
219
- [225,154,220],
220
- [220,77,167],
221
- [233,161,64],
222
- [130,221,137],
223
- [81,191,129],
224
- [169,162,140],
225
- [174,177,222],
226
- [236,174,47],
227
- [233,188,180],
228
- [69,222,172],
229
- [71,232,93],
230
- [118,211,238],
231
- [157,224,83],
232
- [218,105,73],
233
- [126,169,36]
234
- ]
52
+ COLORS
235
53
  end
236
54
 
237
55
  end
@@ -1,3 +1,3 @@
1
1
  module LetterAvatar
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
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.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - discourse developers
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-10-28 00:00:00.000000000 Z
14
+ date: 2015-11-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -53,6 +53,7 @@ files:
53
53
  - LICENSE.txt
54
54
  - README.md
55
55
  - Rakefile
56
+ - Roboto-Medium
56
57
  - letter_avatar.gemspec
57
58
  - lib/letter_avatar.rb
58
59
  - lib/letter_avatar/avatar.rb