rucaptcha 2.0.0.beta4 → 2.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -2
- data/README.md +3 -1
- data/ext/rucaptcha/colors.h +15 -15
- data/ext/rucaptcha/extconf.rb +0 -2
- data/ext/rucaptcha/rucaptcha.c +11 -7
- data/lib/rucaptcha.rb +6 -0
- data/lib/rucaptcha/configuration.rb +2 -0
- data/lib/rucaptcha/controller_helpers.rb +1 -1
- data/lib/rucaptcha/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d77f76c426739b1dff568c242d92e8aab993894
|
4
|
+
data.tar.gz: ce46de282f893b397a26c82bd7071090a2e9a405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0f3f2fb8b5055f82019568aad37d8d927fb5dfc8c68325ec437f9c5d2746b826cb0e42b0868e5088f4e93bcab2e48c6a58ff6ce7aeae5364417436a42019690
|
7
|
+
data.tar.gz: fcef86bd39c1facaa06fc399947298477ba8924ede6091e6351379293b8d22db6be792706a4c79e07f4358febcea078bd8eacacb28928fa87127926be1f685ff
|
data/CHANGELOG.md
CHANGED
@@ -6,8 +6,9 @@
|
|
6
6
|
WARNING!: This version have so many break changes!
|
7
7
|
|
8
8
|
- Use C ext instead of ImageMagick, now it's no dependencies!
|
9
|
-
- New captcha style
|
10
|
-
- Remove `len`, `
|
9
|
+
- New captcha style.
|
10
|
+
- Remove `len`, `font_size`, `cache_limit` config key, no support now.
|
11
|
+
- Output `GIF` format.
|
11
12
|
|
12
13
|
1.2.0
|
13
14
|
-----
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[](https://travis-ci.org/huacnlee/rucaptcha)
|
5
5
|
[](https://codeclimate.com/github/huacnlee/rucaptcha)
|
6
6
|
|
7
|
-
This is a Captcha gem for Rails Applications. It drawing captcha image with C
|
7
|
+
This is a Captcha gem for Rails Applications. It drawing captcha image with C code.
|
8
8
|
|
9
9
|
## Example
|
10
10
|
|
@@ -31,6 +31,8 @@ Create `config/initializers/rucaptcha.rb`
|
|
31
31
|
|
32
32
|
```rb
|
33
33
|
RuCaptcha.configure do
|
34
|
+
# Color style, default: :colorful, allows: [:colorful, :black_white]
|
35
|
+
# self.style = :colorful
|
34
36
|
# Custom captcha code expire time if you need, default: 2 minutes
|
35
37
|
# self.expires_in = 120
|
36
38
|
# [Requirement]
|
data/ext/rucaptcha/colors.h
CHANGED
@@ -3,21 +3,21 @@
|
|
3
3
|
static char *colors[] = {
|
4
4
|
// Black 500 #000000
|
5
5
|
"GIF89a" "\xc8\0\x46\0" "\x83" "\0\0"
|
6
|
-
"\
|
7
|
-
"\
|
8
|
-
"\
|
9
|
-
"\
|
10
|
-
"\
|
11
|
-
"\
|
12
|
-
"\
|
13
|
-
"\
|
14
|
-
"\
|
15
|
-
"\
|
16
|
-
"\
|
17
|
-
"\
|
18
|
-
"\
|
19
|
-
"\
|
20
|
-
"\
|
6
|
+
"\x11\x11\x11"
|
7
|
+
"\x11\x11\x11"
|
8
|
+
"\x11\x11\x11"
|
9
|
+
"\x11\x11\x11"
|
10
|
+
"\x11\x11\x11"
|
11
|
+
"\x11\x11\x11"
|
12
|
+
"\x11\x11\x11"
|
13
|
+
"\x11\x11\x11"
|
14
|
+
"\x11\x11\x11"
|
15
|
+
"\x11\x11\x11"
|
16
|
+
"\x11\x11\x11"
|
17
|
+
"\x11\x11\x11"
|
18
|
+
"\x11\x11\x11"
|
19
|
+
"\x11\x11\x11"
|
20
|
+
"\x11\x11\x11"
|
21
21
|
"\xff\xff\xff" "," "\0\0\0\0" "\xc8\0\x46\0" "\0" "\x04",
|
22
22
|
|
23
23
|
// Red 500 #F44336
|
data/ext/rucaptcha/extconf.rb
CHANGED
data/ext/rucaptcha/rucaptcha.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
// http://github.com/ITikhonov/captcha
|
2
2
|
const int gifsize;
|
3
3
|
void captcha(unsigned char im[70*200], unsigned char l[6]);
|
4
|
-
void makegif(unsigned char im[70*200], unsigned char gif[gifsize]);
|
4
|
+
void makegif(unsigned char im[70*200], unsigned char gif[gifsize], int style);
|
5
5
|
|
6
6
|
#include <unistd.h>
|
7
7
|
#include <stdint.h>
|
@@ -16,13 +16,16 @@ void makegif(unsigned char im[70*200], unsigned char gif[gifsize]);
|
|
16
16
|
static int8_t *lt[];
|
17
17
|
const int gifsize=17646;
|
18
18
|
|
19
|
-
void makegif(unsigned char im[70*200], unsigned char gif[gifsize]) {
|
19
|
+
void makegif(unsigned char im[70*200], unsigned char gif[gifsize], int style) {
|
20
20
|
// tag ; widthxheight ; GCT:0:0:7 ; bgcolor + aspect // GCT
|
21
21
|
// Image Separator // left x top // widthxheight // Flags
|
22
22
|
// LZW code size
|
23
23
|
srand(time(NULL));
|
24
24
|
int color_len = (int) sizeof(colors) / sizeof(colors[0]);
|
25
25
|
int color_idx = rand() % color_len;
|
26
|
+
if (style == 0) {
|
27
|
+
color_idx = 0;
|
28
|
+
}
|
26
29
|
memcpy(gif,colors[color_idx],13+48+10+1);
|
27
30
|
|
28
31
|
int x,y;
|
@@ -185,20 +188,21 @@ VALUE RuCaptcha = Qnil;
|
|
185
188
|
|
186
189
|
void Init_rucaptcha();
|
187
190
|
|
188
|
-
VALUE create(VALUE self);
|
191
|
+
VALUE create(VALUE self, VALUE style);
|
189
192
|
|
190
193
|
void Init_rucaptcha() {
|
191
194
|
RuCaptcha = rb_define_module("RuCaptcha");
|
192
|
-
rb_define_singleton_method(RuCaptcha, "create", create,
|
195
|
+
rb_define_singleton_method(RuCaptcha, "create", create, 1);
|
193
196
|
}
|
194
197
|
|
195
|
-
VALUE create(VALUE self) {
|
198
|
+
VALUE create(VALUE self, VALUE style) {
|
196
199
|
char l[6];
|
197
200
|
unsigned char im[80*200];
|
198
201
|
unsigned char gif[gifsize];
|
202
|
+
int i_style = FIX2INT(style);
|
199
203
|
|
200
|
-
captcha(im,l);
|
201
|
-
makegif(im,gif);
|
204
|
+
captcha(im, l);
|
205
|
+
makegif(im, gif, i_style);
|
202
206
|
|
203
207
|
VALUE result = rb_ary_new2(2);
|
204
208
|
rb_ary_push(result, rb_str_new2(l));
|
data/lib/rucaptcha.rb
CHANGED
@@ -14,6 +14,7 @@ module RuCaptcha
|
|
14
14
|
def config
|
15
15
|
return @config if defined?(@config)
|
16
16
|
@config = Configuration.new
|
17
|
+
@config.style = :colorful
|
17
18
|
@config.expires_in = 2.minutes
|
18
19
|
if Rails.application
|
19
20
|
@config.cache_store = Rails.application.config.cache_store
|
@@ -26,6 +27,11 @@ module RuCaptcha
|
|
26
27
|
def configure(&block)
|
27
28
|
config.instance_exec(&block)
|
28
29
|
end
|
30
|
+
|
31
|
+
def generate()
|
32
|
+
style = config.style == :colorful ? 1 : 0
|
33
|
+
self.create(style)
|
34
|
+
end
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
data/lib/rucaptcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rucaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -79,9 +79,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: 2.0.0
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - "
|
82
|
+
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
84
|
+
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
87
|
rubygems_version: 2.5.2
|