avatar_magick 1.0.0 → 1.0.1
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 +4 -4
- data/README.md +44 -2
- data/avatar_magick.gemspec +1 -0
- data/lib/avatar_magick.rb +4 -2
- data/lib/avatar_magick/generators/initial_avatar.rb +6 -6
- data/lib/avatar_magick/plugin.rb +8 -0
- data/lib/avatar_magick/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f90e37995f8bb3c9bccff8b9271a9f403ac676c1
|
4
|
+
data.tar.gz: c518b0c1f572f3cddc4e3bc3379042b69838783d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad6fdc37b0d0cc4934bfc0cedf9d5d22a4de2a3584b201f49d0fab25d01b1e766ce962f54cfdc96fa001be2be470bfc73b35ce9bdb2cd957774153d9b1a88894
|
7
|
+
data.tar.gz: 99e0f96b06f80425cefabf3fdce8c934fbdb2babb8ebb4de640cc1e9ae83520b38c6d080e5fbb1ec25f7aba8af92fa8cc2bbd2e91fbbdee02a4d436080e38de7
|
data/README.md
CHANGED
@@ -28,10 +28,15 @@ Once installed, you'll need to register the AvatarMagick plugin along with the [
|
|
28
28
|
|
29
29
|
#### Rails
|
30
30
|
|
31
|
-
If you're using Dragonfly within your Rails application, you'll already have a `config/initializers/dragonfly.rb` file where your Dragonfly configuration settings are stored. Edit the file and add the
|
31
|
+
If you're using Dragonfly within your Rails application, you'll already have a `config/initializers/dragonfly.rb` file where your Dragonfly configuration settings are stored. Edit the file and add the plugin within the `configure` block
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
|
34
|
+
Dragonfly.app.configure do
|
35
|
+
plugin :imagemagick
|
36
|
+
plugin :avatarmagick
|
37
|
+
|
38
|
+
# rest of settings...
|
39
|
+
end
|
35
40
|
```
|
36
41
|
|
37
42
|
#### Sinatra/Rack/Other
|
@@ -47,6 +52,39 @@ Dragonfly.app.configure do
|
|
47
52
|
end
|
48
53
|
```
|
49
54
|
|
55
|
+
## Configuration
|
56
|
+
|
57
|
+
You can configure defaults for text color, background color, size, and font. If not specified, AvatarMagick will use the following defaults
|
58
|
+
|
59
|
+
```
|
60
|
+
color: FFFFFF
|
61
|
+
background_color: 000000
|
62
|
+
size: '120x120'
|
63
|
+
font: 'Arial-Regular'
|
64
|
+
```
|
65
|
+
|
66
|
+
To overwrite, simply provide new values for any of the above within Dragonfly's `configure` block. For example, if you wanted the default background to be red (FF0000) instead of black (000000) and the default size to be 200px by 200px
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
Dragonfly.app.configure do
|
70
|
+
plugin :imagemagick
|
71
|
+
plugin :avatarmagick, background_color: 'FF0000', size: '200x200'
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
Or, if you wanted to change the default font
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
Dragonfly.app.configure do
|
79
|
+
plugin :imagemagick
|
80
|
+
plugin :avatarmagick, font: 'OpenSans'
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
##### Choosing Fonts
|
85
|
+
|
86
|
+
To see what fonts are available, open up the terminal and type `convert -list font`. You can select any font listed when configuring or when calling `generate`.
|
87
|
+
|
50
88
|
## Usage
|
51
89
|
|
52
90
|
Once the plugin is installed and registered, you can use it like any of the other built-in generators (text, plain, etc.)
|
@@ -110,6 +148,10 @@ After checking out the repo, run `bash bin/setup` to install dependencies. Then,
|
|
110
148
|
|
111
149
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
112
150
|
|
151
|
+
## Roadmap
|
152
|
+
|
153
|
+
1. Add support for older versions (0.9.x) of Dragonfly
|
154
|
+
|
113
155
|
## Contributing
|
114
156
|
|
115
157
|
1. Fork it ( https://github.com/[my-github-username]/avatar_magick/fork )
|
data/avatar_magick.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{A Dragonfly Plugin for generating on-the-fly Gmail style avatars}
|
13
13
|
spec.homepage = "https://github.com/bjedrocha/avatar_magick"
|
14
|
+
spec.license = "MIT"
|
14
15
|
|
15
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
17
|
spec.bindir = "exe"
|
data/lib/avatar_magick.rb
CHANGED
@@ -2,7 +2,9 @@ require "dragonfly"
|
|
2
2
|
require "avatar_magick/version"
|
3
3
|
require "avatar_magick/plugin"
|
4
4
|
|
5
|
-
#
|
6
|
-
#
|
5
|
+
# Register plugins so we can do e.g.
|
6
|
+
# Dragonfly.app.configure do
|
7
|
+
# plugin :avatarmagick
|
8
|
+
# end
|
7
9
|
Dragonfly::App.register_plugin(:avatar_magick) { AvatarMagick::Plugin.new }
|
8
10
|
Dragonfly::App.register_plugin(:avatarmagick) { AvatarMagick::Plugin.new }
|
@@ -12,11 +12,11 @@ module AvatarMagick
|
|
12
12
|
args = []
|
13
13
|
|
14
14
|
# defaults
|
15
|
-
format = opts[:format] ||
|
16
|
-
background = opts[:background_color] ? "##{opts[:background_color]}" :
|
17
|
-
color = opts[:color] ? "##{opts[:color]}" :
|
18
|
-
size = opts[:size] ||
|
19
|
-
font = opts[:font] ||
|
15
|
+
format = opts[:format] || 'png'
|
16
|
+
background = opts[:background_color] ? "##{opts[:background_color]}" : content.env[:avatar_magick][:background_color]
|
17
|
+
color = opts[:color] ? "##{opts[:color]}" : content.env[:avatar_magick][:color]
|
18
|
+
size = opts[:size] || content.env[:avatar_magick][:size]
|
19
|
+
font = opts[:font] || content.env[:avatar_magick][:font]
|
20
20
|
|
21
21
|
# extract the first letter of the first 3 words and capitalize
|
22
22
|
text = (string.split(/\s/)- ["", nil]).map { |t| t[0].upcase }.slice(0, 3).join('')
|
@@ -45,7 +45,7 @@ module AvatarMagick
|
|
45
45
|
|
46
46
|
content.generate!(:convert, args.join(' '), format)
|
47
47
|
|
48
|
-
content.add_meta('format' => format, 'name' => "
|
48
|
+
content.add_meta('format' => format, 'name' => "avatar.#{format}")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/avatar_magick/plugin.rb
CHANGED
@@ -5,6 +5,14 @@ module AvatarMagick
|
|
5
5
|
# Registers the initial_avatar generator
|
6
6
|
class Plugin
|
7
7
|
def call(app, opts={})
|
8
|
+
|
9
|
+
# set global configuration options
|
10
|
+
app.env[:avatar_magick] = {}
|
11
|
+
app.env[:avatar_magick][:color] = opts[:color] ? "##{opts[:color]}" : "#FFFFFF"
|
12
|
+
app.env[:avatar_magick][:background_color] = opts[:background_color] ? "##{opts[:background_color]}" : "#000000"
|
13
|
+
app.env[:avatar_magick][:size] = opts[:size] || "120x120"
|
14
|
+
app.env[:avatar_magick][:font] = opts[:font] || "Arial-Regular"
|
15
|
+
|
8
16
|
app.add_generator :initial_avatar, AvatarMagick::Generators::InitialAvatar.new
|
9
17
|
end
|
10
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avatar_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bart Jedrocha
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,7 +87,8 @@ files:
|
|
87
87
|
- lib/avatar_magick/plugin.rb
|
88
88
|
- lib/avatar_magick/version.rb
|
89
89
|
homepage: https://github.com/bjedrocha/avatar_magick
|
90
|
-
licenses:
|
90
|
+
licenses:
|
91
|
+
- MIT
|
91
92
|
metadata: {}
|
92
93
|
post_install_message:
|
93
94
|
rdoc_options: []
|