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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b3e894eb2935644884d0bb884aed9cf07be4580
4
- data.tar.gz: 6fce9e3db60337ff2b9bf1ec7ba3947dc033f079
3
+ metadata.gz: d6c600ae9fbb741b9bdeabbe4f7d9768b3bdb1df
4
+ data.tar.gz: f0da07e2727308444186ba9c7c6f8d918f1a3c23
5
5
  SHA512:
6
- metadata.gz: cbe7868ac9267dae719add1673266aa8a4b09a0ca3428690bb63214bc3563f723c9e9d505b19b081ac74b2c87252bac31ba1713f8dfe6cc2c29592a06b022f95
7
- data.tar.gz: c45893a953e35cf75045cb84e01f5faeec363c3b9cf5088b3ef77b81707d97b07a3b5f111b8c83831d88057c72d18a380dccb9f9cb43c1bb1315d9208ad3a041
6
+ metadata.gz: fe6e677bbecd3ced0f224d6e73ed3efb02775e97abb31aaa106dafae57ccaf9d5febf0f6f9e4d421cbbe5f6ce8efb3c71191ddb63bdb558ca718123b943460bb
7
+ data.tar.gz: d8bd97a85865bb1d61bc2c91a8ecb079f64b8274720b2b9ed6d9e17026c8a499a2f63da729d7f98b657602f811221b3cd80f4b2af4cf02e989e5b64b826911eb
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ 0.1.5
2
+ -----
3
+
4
+ - Use [posix-spawn](https://github.com/rtomayko/posix-spawn) to instead of Kernel#exec to get better performance.
5
+ > fork(2) calls slow down as the parent process uses more memory due to the need to copy page tables.
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
- ![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)
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 specyfied username.
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
@@ -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
@@ -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
- instructions = %W{
72
+ commands = %W(
73
+ convert
70
74
  -size 240x240
71
75
  xc:#{to_rgb(color)}
72
76
  -pointsize 140
73
- -font Roboto-Medium
74
- -weight 500
77
+ -font #{FONT_FILENAME}
78
+ -weight 300
75
79
  -fill '#{FILL_COLOR}'
76
80
  -gravity Center
77
- -annotate -0+10 '#{letter}'
81
+ -annotate -0+5 '#{letter}'
78
82
  '#{filename}'
79
- }
83
+ )
80
84
 
81
- `convert #{instructions.join(" ")}`
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
@@ -1,3 +1,3 @@
1
1
  module LetterAvatar
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
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.1.4
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: 2015-11-30 00:00:00.000000000 Z
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