letter_avatar 0.1.11 → 0.2.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: 91cab30f2c39951229dd104c9f0b109a8c4370ff
4
- data.tar.gz: 4d4e7095dfe310a486bbb454a692666406e72eb3
3
+ metadata.gz: c55c3d79ff3c533932714985087ed6492d67d212
4
+ data.tar.gz: e1e0ce051c935209780bee2fb3ac5a751acda9cb
5
5
  SHA512:
6
- metadata.gz: 9175fff72b9223e4afed6f37d1c436c58a3be3117e9ac58cd3df6766742ed2b711167475c556d203dea76baba9b764bff96c4ca92fb6871a0dfa0ee09a01eabc
7
- data.tar.gz: 145ea83f81b4e0294ca021de7d25c58f3c18a7076c733ef004c4ce8eeac1a6681320411f01d942a0dac75d2f7118f5c2ca2e14345f9548fd7158d3c17745dced
6
+ metadata.gz: e68c68315b536f0953c270f939d002217d2c62f8a04adaaa98efaec49cbdaea2a12209038497d1713b05be5e23b1c31cc6449e2c654dddf354c3a1bba450f460
7
+ data.tar.gz: 4e8f142e1485748418328682ea59f1fc1d2518296a49d86504f03fc4f5ec4929f97153e921b6caf0c4c14f3763848376e7963196d7dfa5199f73837a73ab0e59
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
+ 0.2.0
2
+ -----
3
+
4
+ - Removed `posix-spawn` dependency, Open3 speed is ok.
5
+
1
6
  0.1.11
2
7
  ------
3
8
 
4
- - Windows support
9
+ - Windows support.
5
10
 
6
11
  0.1.10
7
12
  ------
data/README.md CHANGED
@@ -96,7 +96,7 @@ There's also helper for this. To use it, you need:
96
96
  ```rb
97
97
  class User
98
98
  def username_for_avatar
99
- # Translate chinese hanzi to pinyin
99
+ # Translate Chinese hanzi to pinyin
100
100
  # https://github.com/flyerhzm/chinese_pinyin
101
101
  Pinyin.t(self.username)
102
102
  end
data/lib/letter_avatar.rb CHANGED
@@ -1,40 +1,39 @@
1
- require 'posix/spawn'
1
+ require 'open3'
2
2
 
3
- require "letter_avatar/version"
4
- require "letter_avatar/configuration"
5
- require "letter_avatar/avatar"
6
- require "letter_avatar/avatar_helper"
3
+ require 'letter_avatar/version'
4
+ require 'letter_avatar/configuration'
5
+ require 'letter_avatar/avatar'
6
+ require 'letter_avatar/avatar_helper'
7
+ require 'letter_avatar/colors'
7
8
 
8
9
  module LetterAvatar
9
10
  extend LetterAvatar::Configuration
10
11
 
11
12
  class ExecutionError < StandardError; end
12
13
 
13
- def self.setup(&block)
14
+ def self.setup(&_block)
14
15
  yield(self)
15
16
  end
16
17
 
17
18
  def self.resize(from, to, width, height)
18
- begin
19
- execute(
20
- # NOTE: ORDER is important!
21
- %W{
22
- convert
23
- #{from}
24
- -background transparent
25
- -gravity center
26
- -thumbnail #{width}x#{height}^
27
- -extent #{width}x#{height}
28
- -interpolate bicubic
29
- -unsharp 2x0.5+0.7+0
30
- -quality 98
31
- #{to}
32
- }.join(" ")
33
- )
34
- true
35
- rescue => e
36
- false
37
- end
19
+ execute(
20
+ # NOTE: ORDER is important!
21
+ %W(
22
+ convert
23
+ #{from}
24
+ -background transparent
25
+ -gravity center
26
+ -thumbnail #{width}x#{height}^
27
+ -extent #{width}x#{height}
28
+ -interpolate bicubic
29
+ -unsharp 2x0.5+0.7+0
30
+ -quality 98
31
+ #{to}
32
+ ).join(' ')
33
+ )
34
+ true
35
+ rescue
36
+ false
38
37
  end
39
38
 
40
39
  def self.generate(username, size)
@@ -44,18 +43,14 @@ module LetterAvatar
44
43
  def self.execute(cmd)
45
44
  cmd = cmd.join(' ') if cmd.is_a?(Array)
46
45
  if Gem.win_platform?
47
- require "open3"
48
- _stdout_str, err = Open3.capture3(cmd.tr("'", '"'))
49
- else
50
- pid, _stdin, _stdout, stderr = POSIX::Spawn.popen4(cmd)
51
- Process.waitpid(pid)
52
- err = stderr.read
46
+ cmd.tr!("'", '"')
53
47
  end
54
- if err != nil && err.length > 0
48
+
49
+ _stdout_str, err = Open3.capture3(cmd)
50
+ if !err.nil? && !err.empty?
55
51
  raise ExecutionError.new("letter_avatar execution error (when calling '#{cmd}'): '#{err.strip}'")
56
- else
57
- true
58
52
  end
59
- end
60
53
 
54
+ true
55
+ end
61
56
  end
@@ -1,8 +1,5 @@
1
- require "letter_avatar/colors"
2
-
3
1
  module LetterAvatar
4
2
  class Avatar
5
-
6
3
  # BUMP UP if avatar algorithm changes
7
4
  VERSION = 2
8
5
 
@@ -12,10 +9,9 @@ module LetterAvatar
12
9
 
13
10
  FILL_COLOR = 'rgba(255, 255, 255, 0.65)'.freeze
14
11
 
15
- FONT_FILENAME = File.join(File.expand_path("../../", File.dirname(__FILE__)), "Roboto-Medium")
12
+ FONT_FILENAME = File.join(File.expand_path('../../', File.dirname(__FILE__)), 'Roboto-Medium')
16
13
 
17
14
  class << self
18
-
19
15
  class Identity
20
16
  attr_accessor :color, :letter
21
17
 
@@ -28,7 +24,6 @@ module LetterAvatar
28
24
  end
29
25
  end
30
26
 
31
-
32
27
  def cache_path
33
28
  "#{LetterAvatar.cache_base_path || 'public/system'}/letter_avatars/#{VERSION}"
34
29
  end
@@ -42,17 +37,17 @@ module LetterAvatar
42
37
  size = FULLSIZE if size > FULLSIZE
43
38
  filename = cached_path(identity, size)
44
39
 
45
- return filename if cache && File.exists?(filename)
40
+ return filename if cache && File.exist?(filename)
46
41
 
47
42
  fullsize = fullsize_path(identity)
48
- generate_fullsize(identity) if !cache || !File.exists?(fullsize)
43
+ generate_fullsize(identity) if !cache || !File.exist?(fullsize)
49
44
 
50
45
  LetterAvatar.resize(fullsize, filename, size, size)
51
46
  filename
52
47
  end
53
48
 
54
49
  def cached_path(identity, size)
55
- dir = "#{cache_path}/#{identity.letter}/#{identity.color.join("_")}"
50
+ dir = "#{cache_path}/#{identity.letter}/#{identity.color.join('_')}"
56
51
  FileUtils.mkdir_p(dir)
57
52
 
58
53
  "#{dir}/#{size}.png"
@@ -83,14 +78,14 @@ module LetterAvatar
83
78
  filename
84
79
  end
85
80
 
86
- def darken(color,pct)
81
+ def darken(color, pct)
87
82
  color.map do |n|
88
83
  (n.to_f * pct).to_i
89
84
  end
90
85
  end
91
86
 
92
87
  def to_rgb(color)
93
- r,g,b = color
88
+ r, g, b = color
94
89
  "'rgb(#{r},#{g},#{b})'"
95
90
  end
96
91
  end
@@ -1,13 +1,11 @@
1
- # encoding: UTF-8
2
1
  module LetterAvatar
3
2
  module AvatarHelper
4
-
5
3
  def letter_avatar_for(name, size = 64)
6
4
  LetterAvatar.generate(name, size)
7
5
  end
8
6
 
9
7
  def letter_avatar_url_for(avatar_path)
10
- avatar_path.to_s.sub('public/','/')
8
+ avatar_path.to_s.sub('public/', '/')
11
9
  end
12
10
 
13
11
  def letter_avatar_url(name, size = 64)
@@ -22,6 +20,5 @@ module LetterAvatar
22
20
  "<img alt=\"#{name}\" class\"#{options.fetch(:class)}\" src=\"#{letter_avatar_url(name, size)}\" />"
23
21
  end
24
22
  end
25
-
26
23
  end
27
24
  end
@@ -1,8 +1,255 @@
1
1
  module LetterAvatar
2
2
  module Colors
3
-
4
3
  PALETTES = [:google, :iwanthue]
5
4
 
5
+ GOOGLE_COLORS = [
6
+ [226, 95, 81], # A
7
+ [242, 96, 145], # B
8
+ [187, 101, 202], # C
9
+ [149, 114, 207], # D
10
+ [120, 132, 205], # E
11
+ [91, 149, 249], # F
12
+ [72, 194, 249], # G
13
+ [69, 208, 226], # H
14
+ [72, 182, 172], # I
15
+ [82, 188, 137], # J
16
+ [155, 206, 95], # K
17
+ [212, 227, 74], # L
18
+ [254, 218, 16], # M
19
+ [247, 192, 0], # N
20
+ [255, 168, 0], # O
21
+ [255, 138, 96], # P
22
+ [194, 194, 194], # Q
23
+ [143, 164, 175], # R
24
+ [162, 136, 126], # S
25
+ [163, 163, 163], # T
26
+ [175, 181, 226], # U
27
+ [179, 155, 221], # V
28
+ [194, 194, 194], # W
29
+ [124, 222, 235], # X
30
+ [188, 170, 164], # Y
31
+ [173, 214, 125] # Z
32
+ ].freeze
33
+
34
+ IWANTHUE_COLORS = [
35
+ [198, 125, 40],
36
+ [61, 155, 243],
37
+ [74, 243, 75],
38
+ [238, 89, 166],
39
+ [52, 240, 224],
40
+ [177, 156, 155],
41
+ [240, 120, 145],
42
+ [111, 154, 78],
43
+ [237, 179, 245],
44
+ [237, 101, 95],
45
+ [89, 239, 155],
46
+ [43, 254, 70],
47
+ [163, 212, 245],
48
+ [65, 152, 142],
49
+ [165, 135, 246],
50
+ [181, 166, 38],
51
+ [187, 229, 206],
52
+ [77, 164, 25],
53
+ [179, 246, 101],
54
+ [234, 93, 37],
55
+ [225, 155, 115],
56
+ [142, 140, 188],
57
+ [223, 120, 140],
58
+ [249, 174, 27],
59
+ [244, 117, 225],
60
+ [137, 141, 102],
61
+ [75, 191, 146],
62
+ [188, 239, 142],
63
+ [164, 199, 145],
64
+ [173, 120, 149],
65
+ [59, 195, 89],
66
+ [222, 198, 220],
67
+ [68, 145, 187],
68
+ [236, 204, 179],
69
+ [159, 195, 72],
70
+ [188, 121, 189],
71
+ [166, 160, 85],
72
+ [181, 233, 37],
73
+ [236, 177, 85],
74
+ [121, 147, 160],
75
+ [234, 218, 110],
76
+ [241, 157, 191],
77
+ [62, 200, 234],
78
+ [133, 243, 34],
79
+ [88, 149, 110],
80
+ [59, 228, 248],
81
+ [183, 119, 118],
82
+ [251, 195, 45],
83
+ [113, 196, 122],
84
+ [197, 115, 70],
85
+ [80, 175, 187],
86
+ [103, 231, 238],
87
+ [240, 72, 133],
88
+ [228, 149, 241],
89
+ [180, 188, 159],
90
+ [172, 132, 85],
91
+ [180, 135, 251],
92
+ [236, 194, 58],
93
+ [217, 176, 109],
94
+ [88, 244, 199],
95
+ [186, 157, 239],
96
+ [113, 230, 96],
97
+ [206, 115, 165],
98
+ [244, 178, 163],
99
+ [230, 139, 26],
100
+ [241, 125, 89],
101
+ [83, 160, 66],
102
+ [107, 190, 166],
103
+ [197, 161, 210],
104
+ [198, 203, 245],
105
+ [238, 117, 19],
106
+ [228, 119, 116],
107
+ [131, 156, 41],
108
+ [145, 178, 168],
109
+ [139, 170, 220],
110
+ [233, 95, 125],
111
+ [87, 178, 230],
112
+ [157, 200, 119],
113
+ [237, 140, 76],
114
+ [229, 185, 186],
115
+ [144, 206, 212],
116
+ [236, 209, 158],
117
+ [185, 189, 79],
118
+ [34, 208, 66],
119
+ [84, 238, 129],
120
+ [133, 140, 134],
121
+ [67, 157, 94],
122
+ [168, 179, 25],
123
+ [140, 145, 240],
124
+ [151, 241, 125],
125
+ [67, 162, 107],
126
+ [200, 156, 21],
127
+ [169, 173, 189],
128
+ [226, 116, 189],
129
+ [133, 231, 191],
130
+ [194, 161, 63],
131
+ [241, 77, 99],
132
+ [241, 217, 53],
133
+ [123, 204, 105],
134
+ [210, 201, 119],
135
+ [229, 108, 155],
136
+ [240, 91, 72],
137
+ [187, 115, 210],
138
+ [240, 163, 100],
139
+ [178, 217, 57],
140
+ [179, 135, 116],
141
+ [204, 211, 24],
142
+ [186, 135, 57],
143
+ [223, 176, 135],
144
+ [204, 148, 151],
145
+ [116, 223, 50],
146
+ [95, 195, 46],
147
+ [123, 160, 236],
148
+ [181, 172, 131],
149
+ [142, 220, 202],
150
+ [240, 140, 112],
151
+ [172, 145, 164],
152
+ [228, 124, 45],
153
+ [135, 151, 243],
154
+ [42, 205, 125],
155
+ [192, 233, 116],
156
+ [119, 170, 114],
157
+ [158, 138, 26],
158
+ [73, 190, 183],
159
+ [185, 229, 243],
160
+ [227, 107, 55],
161
+ [196, 205, 202],
162
+ [132, 143, 60],
163
+ [233, 192, 237],
164
+ [62, 150, 220],
165
+ [205, 201, 141],
166
+ [106, 140, 190],
167
+ [161, 131, 205],
168
+ [135, 134, 158],
169
+ [198, 139, 81],
170
+ [115, 171, 32],
171
+ [101, 181, 67],
172
+ [149, 137, 119],
173
+ [37, 142, 183],
174
+ [183, 130, 175],
175
+ [168, 125, 133],
176
+ [124, 142, 87],
177
+ [236, 156, 171],
178
+ [232, 194, 91],
179
+ [219, 200, 69],
180
+ [144, 219, 34],
181
+ [219, 95, 187],
182
+ [145, 154, 217],
183
+ [165, 185, 100],
184
+ [127, 238, 163],
185
+ [224, 178, 198],
186
+ [119, 153, 120],
187
+ [124, 212, 92],
188
+ [172, 161, 105],
189
+ [231, 155, 135],
190
+ [157, 132, 101],
191
+ [122, 185, 146],
192
+ [53, 166, 51],
193
+ [70, 163, 90],
194
+ [150, 190, 213],
195
+ [210, 107, 60],
196
+ [166, 152, 185],
197
+ [159, 194, 159],
198
+ [39, 141, 222],
199
+ [202, 176, 161],
200
+ [95, 140, 229],
201
+ [168, 142, 87],
202
+ [93, 170, 203],
203
+ [159, 142, 54],
204
+ [14, 168, 39],
205
+ [94, 150, 149],
206
+ [187, 206, 136],
207
+ [157, 224, 166],
208
+ [235, 158, 208],
209
+ [109, 232, 216],
210
+ [141, 201, 87],
211
+ [208, 124, 118],
212
+ [142, 125, 214],
213
+ [19, 237, 174],
214
+ [72, 219, 41],
215
+ [234, 102, 111],
216
+ [168, 142, 79],
217
+ [188, 135, 35],
218
+ [95, 155, 143],
219
+ [148, 173, 116],
220
+ [223, 112, 95],
221
+ [228, 128, 236],
222
+ [206, 114, 54],
223
+ [195, 119, 88],
224
+ [235, 140, 94],
225
+ [235, 202, 125],
226
+ [233, 155, 153],
227
+ [214, 214, 238],
228
+ [246, 200, 35],
229
+ [151, 125, 171],
230
+ [132, 145, 172],
231
+ [131, 142, 118],
232
+ [199, 126, 150],
233
+ [61, 162, 123],
234
+ [58, 176, 151],
235
+ [215, 141, 69],
236
+ [225, 154, 220],
237
+ [220, 77, 167],
238
+ [233, 161, 64],
239
+ [130, 221, 137],
240
+ [81, 191, 129],
241
+ [169, 162, 140],
242
+ [174, 177, 222],
243
+ [236, 174, 47],
244
+ [233, 188, 180],
245
+ [69, 222, 172],
246
+ [71, 232, 93],
247
+ [118, 211, 238],
248
+ [157, 224, 83],
249
+ [218, 105, 73],
250
+ [126, 169, 36]
251
+ ].freeze
252
+
6
253
  def self.for(username)
7
254
  public_send("with_#{LetterAvatar.colors_palette}", username)
8
255
  end
@@ -16,49 +263,21 @@ module LetterAvatar
16
263
  def self.with_google(username)
17
264
  char = username[0].upcase
18
265
 
19
- if /[A-Z]/.match(char)
266
+ if /[A-Z]/ =~ char
20
267
  # 65 is 'A' ord
21
268
  idx = char.ord - 65
22
269
  google[idx]
23
- elsif /[\d]/.match(char)
270
+ elsif /[\d]/ =~ char
24
271
  google[char.to_i]
25
272
  else
26
273
  google[Digest::MD5.hexdigest(username)[0...15].to_i(16) % google.length]
27
274
  end
28
275
  end
29
276
 
30
-
31
277
  # Colors form Google Inbox
32
278
  # https://inbox.google.com
33
279
  def self.google
34
- [
35
- [226, 95, 81], # A
36
- [242, 96, 145], # B
37
- [187, 101, 202], # C
38
- [149, 114, 207], # D
39
- [120, 132, 205], # E
40
- [91, 149, 249], # F
41
- [72, 194, 249], # G
42
- [69, 208, 226], # H
43
- [72, 182, 172], # I
44
- [82, 188, 137], # J
45
- [155, 206, 95], # K
46
- [212, 227, 74], # L
47
- [254, 218, 16], # M
48
- [247, 192, 0], # N
49
- [255, 168, 0], # O
50
- [255, 138, 96], # P
51
- [194, 194, 194], # Q
52
- [143, 164, 175], # R
53
- [162, 136, 126], # S
54
- [163, 163, 163], # T
55
- [175, 181, 226], # U
56
- [179, 155, 221], # V
57
- [194, 194, 194], # W
58
- [124, 222, 235], # X
59
- [188, 170, 164], # Y
60
- [173, 214, 125] # Z
61
- ]
280
+ GOOGLE_COLORS
62
281
  end
63
282
 
64
283
  # palette of optimally disctinct colors
@@ -68,225 +287,7 @@ module LetterAvatar
68
287
  # - C: 0 - 2
69
288
  # - L: 0.75 - 1.5
70
289
  def self.iwanthue
71
- [
72
- [198,125,40],
73
- [61,155,243],
74
- [74,243,75],
75
- [238,89,166],
76
- [52,240,224],
77
- [177,156,155],
78
- [240,120,145],
79
- [111,154,78],
80
- [237,179,245],
81
- [237,101,95],
82
- [89,239,155],
83
- [43,254,70],
84
- [163,212,245],
85
- [65,152,142],
86
- [165,135,246],
87
- [181,166,38],
88
- [187,229,206],
89
- [77,164,25],
90
- [179,246,101],
91
- [234,93,37],
92
- [225,155,115],
93
- [142,140,188],
94
- [223,120,140],
95
- [249,174,27],
96
- [244,117,225],
97
- [137,141,102],
98
- [75,191,146],
99
- [188,239,142],
100
- [164,199,145],
101
- [173,120,149],
102
- [59,195,89],
103
- [222,198,220],
104
- [68,145,187],
105
- [236,204,179],
106
- [159,195,72],
107
- [188,121,189],
108
- [166,160,85],
109
- [181,233,37],
110
- [236,177,85],
111
- [121,147,160],
112
- [234,218,110],
113
- [241,157,191],
114
- [62,200,234],
115
- [133,243,34],
116
- [88,149,110],
117
- [59,228,248],
118
- [183,119,118],
119
- [251,195,45],
120
- [113,196,122],
121
- [197,115,70],
122
- [80,175,187],
123
- [103,231,238],
124
- [240,72,133],
125
- [228,149,241],
126
- [180,188,159],
127
- [172,132,85],
128
- [180,135,251],
129
- [236,194,58],
130
- [217,176,109],
131
- [88,244,199],
132
- [186,157,239],
133
- [113,230,96],
134
- [206,115,165],
135
- [244,178,163],
136
- [230,139,26],
137
- [241,125,89],
138
- [83,160,66],
139
- [107,190,166],
140
- [197,161,210],
141
- [198,203,245],
142
- [238,117,19],
143
- [228,119,116],
144
- [131,156,41],
145
- [145,178,168],
146
- [139,170,220],
147
- [233,95,125],
148
- [87,178,230],
149
- [157,200,119],
150
- [237,140,76],
151
- [229,185,186],
152
- [144,206,212],
153
- [236,209,158],
154
- [185,189,79],
155
- [34,208,66],
156
- [84,238,129],
157
- [133,140,134],
158
- [67,157,94],
159
- [168,179,25],
160
- [140,145,240],
161
- [151,241,125],
162
- [67,162,107],
163
- [200,156,21],
164
- [169,173,189],
165
- [226,116,189],
166
- [133,231,191],
167
- [194,161,63],
168
- [241,77,99],
169
- [241,217,53],
170
- [123,204,105],
171
- [210,201,119],
172
- [229,108,155],
173
- [240,91,72],
174
- [187,115,210],
175
- [240,163,100],
176
- [178,217,57],
177
- [179,135,116],
178
- [204,211,24],
179
- [186,135,57],
180
- [223,176,135],
181
- [204,148,151],
182
- [116,223,50],
183
- [95,195,46],
184
- [123,160,236],
185
- [181,172,131],
186
- [142,220,202],
187
- [240,140,112],
188
- [172,145,164],
189
- [228,124,45],
190
- [135,151,243],
191
- [42,205,125],
192
- [192,233,116],
193
- [119,170,114],
194
- [158,138,26],
195
- [73,190,183],
196
- [185,229,243],
197
- [227,107,55],
198
- [196,205,202],
199
- [132,143,60],
200
- [233,192,237],
201
- [62,150,220],
202
- [205,201,141],
203
- [106,140,190],
204
- [161,131,205],
205
- [135,134,158],
206
- [198,139,81],
207
- [115,171,32],
208
- [101,181,67],
209
- [149,137,119],
210
- [37,142,183],
211
- [183,130,175],
212
- [168,125,133],
213
- [124,142,87],
214
- [236,156,171],
215
- [232,194,91],
216
- [219,200,69],
217
- [144,219,34],
218
- [219,95,187],
219
- [145,154,217],
220
- [165,185,100],
221
- [127,238,163],
222
- [224,178,198],
223
- [119,153,120],
224
- [124,212,92],
225
- [172,161,105],
226
- [231,155,135],
227
- [157,132,101],
228
- [122,185,146],
229
- [53,166,51],
230
- [70,163,90],
231
- [150,190,213],
232
- [210,107,60],
233
- [166,152,185],
234
- [159,194,159],
235
- [39,141,222],
236
- [202,176,161],
237
- [95,140,229],
238
- [168,142,87],
239
- [93,170,203],
240
- [159,142,54],
241
- [14,168,39],
242
- [94,150,149],
243
- [187,206,136],
244
- [157,224,166],
245
- [235,158,208],
246
- [109,232,216],
247
- [141,201,87],
248
- [208,124,118],
249
- [142,125,214],
250
- [19,237,174],
251
- [72,219,41],
252
- [234,102,111],
253
- [168,142,79],
254
- [188,135,35],
255
- [95,155,143],
256
- [148,173,116],
257
- [223,112,95],
258
- [228,128,236],
259
- [206,114,54],
260
- [195,119,88],
261
- [235,140,94],
262
- [235,202,125],
263
- [233,155,153],
264
- [214,214,238],
265
- [246,200,35],
266
- [151,125,171],
267
- [132,145,172],
268
- [131,142,118],
269
- [199,126,150],
270
- [61,162,123],
271
- [58,176,151],
272
- [215,141,69],
273
- [225,154,220],
274
- [220,77,167],
275
- [233,161,64],
276
- [130,221,137],
277
- [81,191,129],
278
- [169,162,140],
279
- [174,177,222],
280
- [236,174,47],
281
- [233,188,180],
282
- [69,222,172],
283
- [71,232,93],
284
- [118,211,238],
285
- [157,224,83],
286
- [218,105,73],
287
- [126,169,36]
288
- ]
290
+ IWANTHUE_COLORS
289
291
  end
290
-
291
292
  end
292
293
  end
@@ -1,8 +1,5 @@
1
- require "letter_avatar/colors"
2
-
3
1
  module LetterAvatar
4
2
  module Configuration
5
-
6
3
  def cache_base_path
7
4
  @cache_base_path
8
5
  end
@@ -34,6 +31,5 @@ module LetterAvatar
34
31
  def annotate_position=(v)
35
32
  @annotate_position = v
36
33
  end
37
-
38
34
  end
39
35
  end
@@ -1,13 +1,13 @@
1
1
  module LetterAvatar
2
2
  module HasAvatar
3
3
  extend ActiveSupport::Concern
4
-
5
- def avatar_path size=200
4
+
5
+ def avatar_path(size = 200)
6
6
  LetterAvatar.generate(name, size)
7
7
  end
8
-
9
- def avatar_url size=200
10
- avatar_path(size).gsub(/public/,'')
8
+
9
+ def avatar_url(size = 200)
10
+ avatar_path(size).gsub(/public/, '')
11
11
  end
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module LetterAvatar
2
- VERSION = "0.1.11"
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,60 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letter_avatar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - discourse developers
7
+ - Discourse Developers
8
8
  - Krzysiek Szczuka
9
9
  - Mateusz Mróz
10
10
  - Jason Lee
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-02-29 00:00:00.000000000 Z
14
+ date: 2016-05-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: posix-spawn
17
+ name: activesupport
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.3.0
22
+ version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.3.0
30
- - !ruby/object:Gem::Dependency
31
- name: bundler
32
- requirement: !ruby/object:Gem::Requirement
33
- requirements:
34
- - - "~>"
35
- - !ruby/object:Gem::Version
36
- version: '1.3'
37
- type: :development
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '1.3'
44
- - !ruby/object:Gem::Dependency
45
- name: rake
46
- requirement: !ruby/object:Gem::Requirement
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: '0'
51
- type: :development
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: '0'
29
+ version: 3.0.0
58
30
  description: Gem for creating letter avatar from user's name
59
31
  email:
60
32
  - kszczuka@gmail.com
@@ -62,14 +34,9 @@ executables: []
62
34
  extensions: []
63
35
  extra_rdoc_files: []
64
36
  files:
65
- - ".gitignore"
66
37
  - CHANGELOG.md
67
- - Gemfile
68
- - LICENSE.txt
69
38
  - README.md
70
- - Rakefile
71
39
  - Roboto-Medium
72
- - letter_avatar.gemspec
73
40
  - lib/letter_avatar.rb
74
41
  - lib/letter_avatar/avatar.rb
75
42
  - lib/letter_avatar/avatar_helper.rb
@@ -96,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
63
  - !ruby/object:Gem::Version
97
64
  version: '0'
98
65
  requirements: []
99
- rubyforge_project: letter_avatar
66
+ rubyforge_project:
100
67
  rubygems_version: 2.4.6
101
68
  signing_key:
102
69
  specification_version: 4
data/.gitignore DELETED
@@ -1,48 +0,0 @@
1
- *.rbc
2
- capybara-*.html
3
- .rspec
4
- /log
5
- /tmp
6
- /db/*.sqlite3
7
- /public/system
8
- /coverage/
9
- /spec/tmp
10
- **.orig
11
- rerun.txt
12
- pickle-email-*.html
13
-
14
- # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
15
- config/initializers/secret_token.rb
16
- config/secrets.yml
17
-
18
- ## Environment normalisation:
19
- /.bundle
20
- /vendor/bundle
21
-
22
- # these should all be checked in to normalise the environment:
23
- # Gemfile.lock, .ruby-version, .ruby-gemset
24
-
25
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
26
- .rvmrc
27
-
28
- # if using bower-rails ignore default bower_components path bower.json files
29
- /vendor/assets/bower_components
30
- *.bowerrc
31
- bower.json
32
- *.gem
33
- *.rbc
34
- .bundle
35
- .config
36
- .yardoc
37
- Gemfile.lock
38
- InstalledFiles
39
- _yardoc
40
- coverage
41
- doc/
42
- lib/bundler/man
43
- pkg
44
- rdoc
45
- spec/reports
46
- test/tmp
47
- test/version_tmp
48
- tmp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in letter_avatar.gemspec
4
- gemspec
data/LICENSE.txt DELETED
@@ -1,339 +0,0 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 2, June 1991
3
-
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
- Everyone is permitted to copy and distribute verbatim copies
7
- of this license document, but changing it is not allowed.
8
-
9
- Preamble
10
-
11
- The licenses for most software are designed to take away your
12
- freedom to share and change it. By contrast, the GNU General Public
13
- License is intended to guarantee your freedom to share and change free
14
- software--to make sure the software is free for all its users. This
15
- General Public License applies to most of the Free Software
16
- Foundation's software and to any other program whose authors commit to
17
- using it. (Some other Free Software Foundation software is covered by
18
- the GNU Lesser General Public License instead.) You can apply it to
19
- your programs, too.
20
-
21
- When we speak of free software, we are referring to freedom, not
22
- price. Our General Public Licenses are designed to make sure that you
23
- have the freedom to distribute copies of free software (and charge for
24
- this service if you wish), that you receive source code or can get it
25
- if you want it, that you can change the software or use pieces of it
26
- in new free programs; and that you know you can do these things.
27
-
28
- To protect your rights, we need to make restrictions that forbid
29
- anyone to deny you these rights or to ask you to surrender the rights.
30
- These restrictions translate to certain responsibilities for you if you
31
- distribute copies of the software, or if you modify it.
32
-
33
- For example, if you distribute copies of such a program, whether
34
- gratis or for a fee, you must give the recipients all the rights that
35
- you have. You must make sure that they, too, receive or can get the
36
- source code. And you must show them these terms so they know their
37
- rights.
38
-
39
- We protect your rights with two steps: (1) copyright the software, and
40
- (2) offer you this license which gives you legal permission to copy,
41
- distribute and/or modify the software.
42
-
43
- Also, for each author's protection and ours, we want to make certain
44
- that everyone understands that there is no warranty for this free
45
- software. If the software is modified by someone else and passed on, we
46
- want its recipients to know that what they have is not the original, so
47
- that any problems introduced by others will not reflect on the original
48
- authors' reputations.
49
-
50
- Finally, any free program is threatened constantly by software
51
- patents. We wish to avoid the danger that redistributors of a free
52
- program will individually obtain patent licenses, in effect making the
53
- program proprietary. To prevent this, we have made it clear that any
54
- patent must be licensed for everyone's free use or not licensed at all.
55
-
56
- The precise terms and conditions for copying, distribution and
57
- modification follow.
58
-
59
- GNU GENERAL PUBLIC LICENSE
60
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
-
62
- 0. This License applies to any program or other work which contains
63
- a notice placed by the copyright holder saying it may be distributed
64
- under the terms of this General Public License. The "Program", below,
65
- refers to any such program or work, and a "work based on the Program"
66
- means either the Program or any derivative work under copyright law:
67
- that is to say, a work containing the Program or a portion of it,
68
- either verbatim or with modifications and/or translated into another
69
- language. (Hereinafter, translation is included without limitation in
70
- the term "modification".) Each licensee is addressed as "you".
71
-
72
- Activities other than copying, distribution and modification are not
73
- covered by this License; they are outside its scope. The act of
74
- running the Program is not restricted, and the output from the Program
75
- is covered only if its contents constitute a work based on the
76
- Program (independent of having been made by running the Program).
77
- Whether that is true depends on what the Program does.
78
-
79
- 1. You may copy and distribute verbatim copies of the Program's
80
- source code as you receive it, in any medium, provided that you
81
- conspicuously and appropriately publish on each copy an appropriate
82
- copyright notice and disclaimer of warranty; keep intact all the
83
- notices that refer to this License and to the absence of any warranty;
84
- and give any other recipients of the Program a copy of this License
85
- along with the Program.
86
-
87
- You may charge a fee for the physical act of transferring a copy, and
88
- you may at your option offer warranty protection in exchange for a fee.
89
-
90
- 2. You may modify your copy or copies of the Program or any portion
91
- of it, thus forming a work based on the Program, and copy and
92
- distribute such modifications or work under the terms of Section 1
93
- above, provided that you also meet all of these conditions:
94
-
95
- a) You must cause the modified files to carry prominent notices
96
- stating that you changed the files and the date of any change.
97
-
98
- b) You must cause any work that you distribute or publish, that in
99
- whole or in part contains or is derived from the Program or any
100
- part thereof, to be licensed as a whole at no charge to all third
101
- parties under the terms of this License.
102
-
103
- c) If the modified program normally reads commands interactively
104
- when run, you must cause it, when started running for such
105
- interactive use in the most ordinary way, to print or display an
106
- announcement including an appropriate copyright notice and a
107
- notice that there is no warranty (or else, saying that you provide
108
- a warranty) and that users may redistribute the program under
109
- these conditions, and telling the user how to view a copy of this
110
- License. (Exception: if the Program itself is interactive but
111
- does not normally print such an announcement, your work based on
112
- the Program is not required to print an announcement.)
113
-
114
- These requirements apply to the modified work as a whole. If
115
- identifiable sections of that work are not derived from the Program,
116
- and can be reasonably considered independent and separate works in
117
- themselves, then this License, and its terms, do not apply to those
118
- sections when you distribute them as separate works. But when you
119
- distribute the same sections as part of a whole which is a work based
120
- on the Program, the distribution of the whole must be on the terms of
121
- this License, whose permissions for other licensees extend to the
122
- entire whole, and thus to each and every part regardless of who wrote it.
123
-
124
- Thus, it is not the intent of this section to claim rights or contest
125
- your rights to work written entirely by you; rather, the intent is to
126
- exercise the right to control the distribution of derivative or
127
- collective works based on the Program.
128
-
129
- In addition, mere aggregation of another work not based on the Program
130
- with the Program (or with a work based on the Program) on a volume of
131
- a storage or distribution medium does not bring the other work under
132
- the scope of this License.
133
-
134
- 3. You may copy and distribute the Program (or a work based on it,
135
- under Section 2) in object code or executable form under the terms of
136
- Sections 1 and 2 above provided that you also do one of the following:
137
-
138
- a) Accompany it with the complete corresponding machine-readable
139
- source code, which must be distributed under the terms of Sections
140
- 1 and 2 above on a medium customarily used for software interchange; or,
141
-
142
- b) Accompany it with a written offer, valid for at least three
143
- years, to give any third party, for a charge no more than your
144
- cost of physically performing source distribution, a complete
145
- machine-readable copy of the corresponding source code, to be
146
- distributed under the terms of Sections 1 and 2 above on a medium
147
- customarily used for software interchange; or,
148
-
149
- c) Accompany it with the information you received as to the offer
150
- to distribute corresponding source code. (This alternative is
151
- allowed only for noncommercial distribution and only if you
152
- received the program in object code or executable form with such
153
- an offer, in accord with Subsection b above.)
154
-
155
- The source code for a work means the preferred form of the work for
156
- making modifications to it. For an executable work, complete source
157
- code means all the source code for all modules it contains, plus any
158
- associated interface definition files, plus the scripts used to
159
- control compilation and installation of the executable. However, as a
160
- special exception, the source code distributed need not include
161
- anything that is normally distributed (in either source or binary
162
- form) with the major components (compiler, kernel, and so on) of the
163
- operating system on which the executable runs, unless that component
164
- itself accompanies the executable.
165
-
166
- If distribution of executable or object code is made by offering
167
- access to copy from a designated place, then offering equivalent
168
- access to copy the source code from the same place counts as
169
- distribution of the source code, even though third parties are not
170
- compelled to copy the source along with the object code.
171
-
172
- 4. You may not copy, modify, sublicense, or distribute the Program
173
- except as expressly provided under this License. Any attempt
174
- otherwise to copy, modify, sublicense or distribute the Program is
175
- void, and will automatically terminate your rights under this License.
176
- However, parties who have received copies, or rights, from you under
177
- this License will not have their licenses terminated so long as such
178
- parties remain in full compliance.
179
-
180
- 5. You are not required to accept this License, since you have not
181
- signed it. However, nothing else grants you permission to modify or
182
- distribute the Program or its derivative works. These actions are
183
- prohibited by law if you do not accept this License. Therefore, by
184
- modifying or distributing the Program (or any work based on the
185
- Program), you indicate your acceptance of this License to do so, and
186
- all its terms and conditions for copying, distributing or modifying
187
- the Program or works based on it.
188
-
189
- 6. Each time you redistribute the Program (or any work based on the
190
- Program), the recipient automatically receives a license from the
191
- original licensor to copy, distribute or modify the Program subject to
192
- these terms and conditions. You may not impose any further
193
- restrictions on the recipients' exercise of the rights granted herein.
194
- You are not responsible for enforcing compliance by third parties to
195
- this License.
196
-
197
- 7. If, as a consequence of a court judgment or allegation of patent
198
- infringement or for any other reason (not limited to patent issues),
199
- conditions are imposed on you (whether by court order, agreement or
200
- otherwise) that contradict the conditions of this License, they do not
201
- excuse you from the conditions of this License. If you cannot
202
- distribute so as to satisfy simultaneously your obligations under this
203
- License and any other pertinent obligations, then as a consequence you
204
- may not distribute the Program at all. For example, if a patent
205
- license would not permit royalty-free redistribution of the Program by
206
- all those who receive copies directly or indirectly through you, then
207
- the only way you could satisfy both it and this License would be to
208
- refrain entirely from distribution of the Program.
209
-
210
- If any portion of this section is held invalid or unenforceable under
211
- any particular circumstance, the balance of the section is intended to
212
- apply and the section as a whole is intended to apply in other
213
- circumstances.
214
-
215
- It is not the purpose of this section to induce you to infringe any
216
- patents or other property right claims or to contest validity of any
217
- such claims; this section has the sole purpose of protecting the
218
- integrity of the free software distribution system, which is
219
- implemented by public license practices. Many people have made
220
- generous contributions to the wide range of software distributed
221
- through that system in reliance on consistent application of that
222
- system; it is up to the author/donor to decide if he or she is willing
223
- to distribute software through any other system and a licensee cannot
224
- impose that choice.
225
-
226
- This section is intended to make thoroughly clear what is believed to
227
- be a consequence of the rest of this License.
228
-
229
- 8. If the distribution and/or use of the Program is restricted in
230
- certain countries either by patents or by copyrighted interfaces, the
231
- original copyright holder who places the Program under this License
232
- may add an explicit geographical distribution limitation excluding
233
- those countries, so that distribution is permitted only in or among
234
- countries not thus excluded. In such case, this License incorporates
235
- the limitation as if written in the body of this License.
236
-
237
- 9. The Free Software Foundation may publish revised and/or new versions
238
- of the General Public License from time to time. Such new versions will
239
- be similar in spirit to the present version, but may differ in detail to
240
- address new problems or concerns.
241
-
242
- Each version is given a distinguishing version number. If the Program
243
- specifies a version number of this License which applies to it and "any
244
- later version", you have the option of following the terms and conditions
245
- either of that version or of any later version published by the Free
246
- Software Foundation. If the Program does not specify a version number of
247
- this License, you may choose any version ever published by the Free Software
248
- Foundation.
249
-
250
- 10. If you wish to incorporate parts of the Program into other free
251
- programs whose distribution conditions are different, write to the author
252
- to ask for permission. For software which is copyrighted by the Free
253
- Software Foundation, write to the Free Software Foundation; we sometimes
254
- make exceptions for this. Our decision will be guided by the two goals
255
- of preserving the free status of all derivatives of our free software and
256
- of promoting the sharing and reuse of software generally.
257
-
258
- NO WARRANTY
259
-
260
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
- FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
- PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
- REPAIR OR CORRECTION.
269
-
270
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
- OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
- TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
- YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
- POSSIBILITY OF SUCH DAMAGES.
279
-
280
- END OF TERMS AND CONDITIONS
281
-
282
- How to Apply These Terms to Your New Programs
283
-
284
- If you develop a new program, and you want it to be of the greatest
285
- possible use to the public, the best way to achieve this is to make it
286
- free software which everyone can redistribute and change under these terms.
287
-
288
- To do so, attach the following notices to the program. It is safest
289
- to attach them to the start of each source file to most effectively
290
- convey the exclusion of warranty; and each file should have at least
291
- the "copyright" line and a pointer to where the full notice is found.
292
-
293
- <one line to give the program's name and a brief idea of what it does.>
294
- Copyright (C) <year> <name of author>
295
-
296
- This program is free software; you can redistribute it and/or modify
297
- it under the terms of the GNU General Public License as published by
298
- the Free Software Foundation; either version 2 of the License, or
299
- (at your option) any later version.
300
-
301
- This program is distributed in the hope that it will be useful,
302
- but WITHOUT ANY WARRANTY; without even the implied warranty of
303
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
- GNU General Public License for more details.
305
-
306
- You should have received a copy of the GNU General Public License along
307
- with this program; if not, write to the Free Software Foundation, Inc.,
308
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
-
310
- Also add information on how to contact you by electronic and paper mail.
311
-
312
- If the program is interactive, make it output a short notice like this
313
- when it starts in an interactive mode:
314
-
315
- Gnomovision version 69, Copyright (C) year name of author
316
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
- This is free software, and you are welcome to redistribute it
318
- under certain conditions; type `show c' for details.
319
-
320
- The hypothetical commands `show w' and `show c' should show the appropriate
321
- parts of the General Public License. Of course, the commands you use may
322
- be called something other than `show w' and `show c'; they could even be
323
- mouse-clicks or menu items--whatever suits your program.
324
-
325
- You should also get your employer (if you work as a programmer) or your
326
- school, if any, to sign a "copyright disclaimer" for the program, if
327
- necessary. Here is a sample; alter the names:
328
-
329
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
-
332
- <signature of Ty Coon>, 1 April 1989
333
- Ty Coon, President of Vice
334
-
335
- This General Public License does not permit incorporating your program into
336
- proprietary programs. If your program is a subroutine library, you may
337
- consider it more useful to permit linking proprietary applications with the
338
- library. If this is what you want to do, use the GNU Lesser General
339
- Public License instead of this License.
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'letter_avatar/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "letter_avatar"
8
- spec.version = LetterAvatar::VERSION
9
- spec.authors = ["discourse developers", "Krzysiek Szczuka", "Mateusz Mróz", "Jason Lee"]
10
- spec.email = ["kszczuka@gmail.com"]
11
- spec.description = %q{Gem for creating letter avatar from user's name}
12
- spec.summary = %q{Create nice initals avatars from your users usernames}
13
- spec.homepage = "https://github.com/ksz2k/letter_avatar"
14
- spec.license = "GPL"
15
-
16
- spec.rubyforge_project = "letter_avatar"
17
-
18
- spec.files = `git ls-files`.split($/) + ['Roboto-Medium']
19
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
- spec.require_paths = ["lib"]
22
-
23
- spec.add_dependency 'posix-spawn', '>= 0.3.0'
24
-
25
- spec.add_development_dependency "bundler", "~> 1.3"
26
- spec.add_development_dependency "rake"
27
- end