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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0116fa0760d83021b28806d0396bcf1a21d14092
4
- data.tar.gz: bba762c915327a2e835e3ae3c4846dbf5810d9a7
3
+ metadata.gz: f90e37995f8bb3c9bccff8b9271a9f403ac676c1
4
+ data.tar.gz: c518b0c1f572f3cddc4e3bc3379042b69838783d
5
5
  SHA512:
6
- metadata.gz: de284e1d3468560cecf4183309b8db9b70c524c5d576c6822a36439f0390d6c6547cbf2b21627c145e44ea9980109b5fde653113a2a4e637de12e11e16dafcff
7
- data.tar.gz: 76b249f04b4627d6746d98934fa5f772a793b06730ce94989ed9a42b86f03603216e5372db703ff6896833bbb53fa702bf8898a0abfc899dcdd319dcf76d271e
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 following directly below the `plugin :imagemagick` line
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
- plugin :avatarmagick
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 )
@@ -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"
@@ -2,7 +2,9 @@ require "dragonfly"
2
2
  require "avatar_magick/version"
3
3
  require "avatar_magick/plugin"
4
4
 
5
- # registers AvatarMagick as a plugin using both notations to remain consistent
6
- # with the ImageMagick plugin
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] || :png
16
- background = opts[:background_color] ? "##{opts[:background_color]}" : '#000000'
17
- color = opts[:color] ? "##{opts[:color]}" : '#FFFFFF'
18
- size = opts[:size] || '120x120'
19
- font = opts[:font] || 'Arial-Regular'
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' => "text.#{format}")
48
+ content.add_meta('format' => format, 'name' => "avatar.#{format}")
49
49
  end
50
50
  end
51
51
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module AvatarMagick
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  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.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-07 00:00:00.000000000 Z
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: []