easy_captcha 0.4.7 → 0.5.0

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_captcha (0.4.7)
4
+ easy_captcha (0.5.0)
5
5
  bundler (~> 1.0.0)
6
6
  rails (>= 3.0.0)
7
7
  rmagick (>= 2.13.1)
@@ -12,66 +12,66 @@ PATH
12
12
  GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
- actionmailer (3.2.0)
16
- actionpack (= 3.2.0)
15
+ actionmailer (3.2.2)
16
+ actionpack (= 3.2.2)
17
17
  mail (~> 2.4.0)
18
- actionpack (3.2.0)
19
- activemodel (= 3.2.0)
20
- activesupport (= 3.2.0)
18
+ actionpack (3.2.2)
19
+ activemodel (= 3.2.2)
20
+ activesupport (= 3.2.2)
21
21
  builder (~> 3.0.0)
22
22
  erubis (~> 2.7.0)
23
- journey (~> 1.0.0)
23
+ journey (~> 1.0.1)
24
24
  rack (~> 1.4.0)
25
25
  rack-cache (~> 1.1)
26
26
  rack-test (~> 0.6.1)
27
27
  sprockets (~> 2.1.2)
28
- activemodel (3.2.0)
29
- activesupport (= 3.2.0)
28
+ activemodel (3.2.2)
29
+ activesupport (= 3.2.2)
30
30
  builder (~> 3.0.0)
31
- activerecord (3.2.0)
32
- activemodel (= 3.2.0)
33
- activesupport (= 3.2.0)
34
- arel (~> 3.0.0)
31
+ activerecord (3.2.2)
32
+ activemodel (= 3.2.2)
33
+ activesupport (= 3.2.2)
34
+ arel (~> 3.0.2)
35
35
  tzinfo (~> 0.3.29)
36
- activeresource (3.2.0)
37
- activemodel (= 3.2.0)
38
- activesupport (= 3.2.0)
39
- activesupport (3.2.0)
36
+ activeresource (3.2.2)
37
+ activemodel (= 3.2.2)
38
+ activesupport (= 3.2.2)
39
+ activesupport (3.2.2)
40
40
  i18n (~> 0.6)
41
41
  multi_json (~> 1.0)
42
- arel (3.0.0)
42
+ arel (3.0.2)
43
43
  builder (3.0.0)
44
44
  diff-lcs (1.1.3)
45
45
  erubis (2.7.0)
46
46
  hike (1.2.1)
47
47
  i18n (0.6.0)
48
- journey (1.0.0)
48
+ journey (1.0.3)
49
49
  json (1.6.5)
50
- mail (2.4.1)
50
+ mail (2.4.4)
51
51
  i18n (>= 0.4.0)
52
52
  mime-types (~> 1.16)
53
53
  treetop (~> 1.4.8)
54
- mime-types (1.17.2)
55
- multi_json (1.0.4)
54
+ mime-types (1.18)
55
+ multi_json (1.2.0)
56
56
  polyglot (0.3.3)
57
57
  rack (1.4.1)
58
- rack-cache (1.1)
58
+ rack-cache (1.2)
59
59
  rack (>= 0.4)
60
60
  rack-ssl (1.3.2)
61
61
  rack
62
62
  rack-test (0.6.1)
63
63
  rack (>= 1.0)
64
- rails (3.2.0)
65
- actionmailer (= 3.2.0)
66
- actionpack (= 3.2.0)
67
- activerecord (= 3.2.0)
68
- activeresource (= 3.2.0)
69
- activesupport (= 3.2.0)
64
+ rails (3.2.2)
65
+ actionmailer (= 3.2.2)
66
+ actionpack (= 3.2.2)
67
+ activerecord (= 3.2.2)
68
+ activeresource (= 3.2.2)
69
+ activesupport (= 3.2.2)
70
70
  bundler (~> 1.0)
71
- railties (= 3.2.0)
72
- railties (3.2.0)
73
- actionpack (= 3.2.0)
74
- activesupport (= 3.2.0)
71
+ railties (= 3.2.2)
72
+ railties (3.2.2)
73
+ actionpack (= 3.2.2)
74
+ activesupport (= 3.2.2)
75
75
  rack-ssl (~> 1.3.2)
76
76
  rake (>= 0.8.7)
77
77
  rdoc (~> 3.4)
@@ -93,8 +93,8 @@ GEM
93
93
  activesupport (>= 3.0)
94
94
  railties (>= 3.0)
95
95
  rspec (~> 2.8.0)
96
- simplecov (0.5.3)
97
- multi_json (~> 1.0.3)
96
+ simplecov (0.6.1)
97
+ multi_json (~> 1.0)
98
98
  simplecov-html (~> 0.5.3)
99
99
  simplecov-html (0.5.3)
100
100
  sprockets (2.1.2)
@@ -106,8 +106,8 @@ GEM
106
106
  treetop (1.4.10)
107
107
  polyglot
108
108
  polyglot (>= 0.3.1)
109
- tzinfo (0.3.31)
110
- yard (0.7.3)
109
+ tzinfo (0.3.32)
110
+ yard (0.7.5)
111
111
 
112
112
  PLATFORMS
113
113
  java
data/README.rdoc CHANGED
@@ -22,7 +22,7 @@ You can configure easy_captcha in "config/initializers/easy_captcha.rb", if you
22
22
  # Cache
23
23
  # config.cache = true
24
24
  # Cache temp dir from Rails.root
25
- # config.cache_temp_dir = Rails.root + 'tmp' + 'captchas'
25
+ # config.cache_temp_dir = Rails.root.join('tmp/captchas')
26
26
  # Cache size
27
27
  # config.cache_size = 500
28
28
  # Cache expire
@@ -46,9 +46,13 @@ You can configure easy_captcha in "config/initializers/easy_captcha.rb", if you
46
46
  # generator.font_fill_color = '#333333'
47
47
  # generator.font_stroke_color = '#000000'
48
48
  # generator.font_stroke = 0
49
- # generator.font_family = File.expand_path('../../resources/afont.ttf', __FILE__)
49
+ # generator.font = File.expand_path('../../resources/afont.ttf', __FILE__)
50
50
 
51
+
52
+ # Background color
51
53
  # generator.image_background_color = "#FFFFFF"
54
+ # Or background image (e.g. transparent png)
55
+ # generator.background_image = File.expand_path('../../resources/captcha_bg.png', __FILE__)
52
56
 
53
57
  # Wave
54
58
  # generator.wave = true
@@ -94,11 +98,13 @@ You find an example app under: http://github.com/phatworx/easy_captcha_example
94
98
  * 0.2 cache support for high frequented sites
95
99
  * 0.3 use generators, optimizations, update licence to same of all my plugins
96
100
  * 0.4 generator support
101
+ * 0.5 (transparent) background support
97
102
 
98
103
  == Maintainers
99
104
 
100
105
  * Team Phatworx (http://github.com/phatworx)
101
106
  * Marco Scholl (http://github.com/traxanos)
107
+ * Alexander Dreher (http://github.com/alexdreher)
102
108
 
103
109
  == Contributing to EasyCaptcha
104
110
 
data/easy_captcha.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = EasyCaptcha::VERSION
8
8
 
9
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
- s.authors = [%q{Marco Scholl}]
10
+ s.authors = [%q{Marco Scholl}, %q{Alexander Dreher}]
11
11
  s.date = %q{2011-09-15}
12
12
  s.description = %q{Captcha-Plugin for Rails}
13
13
  s.email = %q{team@phatworx.de}
@@ -9,7 +9,7 @@ module EasyCaptcha
9
9
  def defaults
10
10
  @font_size = 24
11
11
  @font_fill_color = '#333333'
12
- @font_family = File.expand_path('../../../../resources/captcha.ttf', __FILE__)
12
+ @font = File.expand_path('../../../../resources/captcha.ttf', __FILE__)
13
13
  @font_stroke = '#000000'
14
14
  @font_stroke_color = 0
15
15
  @image_background_color = '#FFFFFF'
@@ -26,10 +26,10 @@ module EasyCaptcha
26
26
  end
27
27
 
28
28
  # Font
29
- attr_accessor :font_size, :font_fill_color, :font_family, :font_stroke, :font_stroke_color
29
+ attr_accessor :font_size, :font_fill_color, :font, :font_family, :font_stroke, :font_stroke_color
30
30
 
31
31
  # Background
32
- attr_accessor :image_background_color
32
+ attr_accessor :image_background_color, :background_image
33
33
 
34
34
  # Sketch
35
35
  attr_accessor :sketch, :sketch_radius, :sketch_sigma
@@ -60,12 +60,13 @@ module EasyCaptcha
60
60
  config = self
61
61
  canvas = Magick::Image.new(EasyCaptcha.image_width, EasyCaptcha.image_height) do |variable|
62
62
  self.background_color = config.image_background_color unless config.image_background_color.nil?
63
+ self.background_color = 'none' if config.background_image.present?
63
64
  end
64
65
 
65
66
  # Render the text in the image
66
67
  canvas.annotate(Magick::Draw.new, 0, 0, 0, 0, code) {
67
68
  self.gravity = Magick::CenterGravity
68
- self.font_family = config.font_family
69
+ self.font = config.font
69
70
  self.font_weight = Magick::LighterWeight
70
71
  self.fill = config.font_fill_color
71
72
  if config.font_stroke.to_i > 0
@@ -92,7 +93,16 @@ module EasyCaptcha
92
93
  # Crop image because to big after waveing
93
94
  canvas = canvas.crop(Magick::CenterGravity, EasyCaptcha.image_width, EasyCaptcha.image_height)
94
95
 
95
- image = canvas.to_blob { self.format = 'PNG' }
96
+
97
+ # Combine images if background image is present
98
+ if config.background_image.present?
99
+ background = Magick::Image.read(config.background_image).first
100
+ background.composite!(canvas, Magick::CenterGravity, Magick::OverCompositeOp)
101
+
102
+ image = background.to_blob { self.format = 'PNG' }
103
+ else
104
+ image = canvas.to_blob { self.format = 'PNG' }
105
+ end
96
106
 
97
107
  # ruby-1.9
98
108
  image = image.force_encoding 'UTF-8' if image.respond_to? :force_encoding
@@ -103,4 +113,4 @@ module EasyCaptcha
103
113
 
104
114
  end
105
115
  end
106
- end
116
+ end
@@ -1,3 +1,3 @@
1
1
  module EasyCaptcha
2
- VERSION = '0.4.7'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,11 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Marco Scholl
9
+ - Alexander Dreher
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
@@ -13,7 +14,7 @@ date: 2011-09-15 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rails
16
- requirement: &7457160 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ! '>='
@@ -21,10 +22,15 @@ dependencies:
21
22
  version: 3.0.0
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *7457160
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 3.0.0
25
31
  - !ruby/object:Gem::Dependency
26
32
  name: bundler
27
- requirement: &7456540 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
28
34
  none: false
29
35
  requirements:
30
36
  - - ~>
@@ -32,10 +38,15 @@ dependencies:
32
38
  version: 1.0.0
33
39
  type: :runtime
34
40
  prerelease: false
35
- version_requirements: *7456540
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.0
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: simplecov
38
- requirement: &7455880 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,15 @@ dependencies:
43
54
  version: 0.3.8
44
55
  type: :runtime
45
56
  prerelease: false
46
- version_requirements: *7455880
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 0.3.8
47
63
  - !ruby/object:Gem::Dependency
48
64
  name: rspec-rails
49
- requirement: &7455220 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
50
66
  none: false
51
67
  requirements:
52
68
  - - ~>
@@ -54,10 +70,15 @@ dependencies:
54
70
  version: 2.8.1
55
71
  type: :runtime
56
72
  prerelease: false
57
- version_requirements: *7455220
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 2.8.1
58
79
  - !ruby/object:Gem::Dependency
59
80
  name: yard
60
- requirement: &7454260 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
61
82
  none: false
62
83
  requirements:
63
84
  - - ! '>='
@@ -65,10 +86,15 @@ dependencies:
65
86
  version: 0.7.0
66
87
  type: :runtime
67
88
  prerelease: false
68
- version_requirements: *7454260
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: 0.7.0
69
95
  - !ruby/object:Gem::Dependency
70
96
  name: rmagick
71
- requirement: &7468660 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
72
98
  none: false
73
99
  requirements:
74
100
  - - ! '>='
@@ -76,7 +102,12 @@ dependencies:
76
102
  version: 2.13.1
77
103
  type: :runtime
78
104
  prerelease: false
79
- version_requirements: *7468660
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 2.13.1
80
111
  description: Captcha-Plugin for Rails
81
112
  email: team@phatworx.de
82
113
  executables: []
@@ -126,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
157
  version: '0'
127
158
  segments:
128
159
  - 0
129
- hash: 3853637032844908925
160
+ hash: -2678361388398322387
130
161
  required_rubygems_version: !ruby/object:Gem::Requirement
131
162
  none: false
132
163
  requirements:
@@ -135,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
166
  version: '0'
136
167
  requirements: []
137
168
  rubyforge_project:
138
- rubygems_version: 1.8.10
169
+ rubygems_version: 1.8.21
139
170
  signing_key:
140
171
  specification_version: 3
141
172
  summary: Captcha-Plugin for Rails