rucaptcha 3.0.2-arm64-darwin → 3.1.0-arm64-darwin
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 +11 -0
- data/Rakefile +31 -0
- data/app/controllers/ru_captcha/captcha_controller.rb +1 -1
- data/ext/rucaptcha/src/captcha.rs +4 -10
- data/lib/rucaptcha/2.7/rucaptcha.bundle +0 -0
- data/lib/rucaptcha/3.0/rucaptcha.bundle +0 -0
- data/lib/rucaptcha/3.1/rucaptcha.bundle +0 -0
- data/lib/rucaptcha/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bea39cfc2b5f85511c0503a5ad4ed3f2a8a41385d10cb3ecd0cb9afe3a6e5225
|
4
|
+
data.tar.gz: d61ec3c0fca84b63dcb2d70f4eb22aa090742b4f95e5ef9e905b3348e3224f7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07e2090a60b6ac4a390c2cebf689c8012e6723a9c71218bd30703fff93cce574c184b007c597e278072369be0af800c4cc063433e7ab2258b82ab4bc2104b096
|
7
|
+
data.tar.gz: 7bd76be6212cdd3575df82077da48310c8ab63745f954a988f675afb50311769a446e906fef253299225d02f519c797167e070944272bb748de26d2e7c40253e
|
data/README.md
CHANGED
@@ -162,3 +162,14 @@ else
|
|
162
162
|
render :new
|
163
163
|
end
|
164
164
|
```
|
165
|
+
|
166
|
+
## Performance
|
167
|
+
|
168
|
+
`rake benchmark` to run benchmark test.
|
169
|
+
|
170
|
+
```
|
171
|
+
Warming up --------------------------------------
|
172
|
+
Generate image 51.000 i/100ms
|
173
|
+
Calculating -------------------------------------
|
174
|
+
Generate image 526.350 (± 2.5%) i/s - 2.652k in 5.041681s
|
175
|
+
```
|
data/Rakefile
CHANGED
@@ -32,3 +32,34 @@ task :preview do
|
|
32
32
|
warn "-------------------------\n#{res[0]}"
|
33
33
|
puts res[1].pack("c*")
|
34
34
|
end
|
35
|
+
|
36
|
+
task :memory do
|
37
|
+
require "rucaptcha"
|
38
|
+
require "memory_profiler"
|
39
|
+
|
40
|
+
RuCaptchaCore.create(5, 5)
|
41
|
+
|
42
|
+
report = MemoryProfiler.report do
|
43
|
+
1000.times do
|
44
|
+
RuCaptchaCore.create(5, 5)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
GC.start
|
49
|
+
report.pretty_print
|
50
|
+
|
51
|
+
puts "------------------------- Result Guide -------------------------"
|
52
|
+
puts "If [Total retained] have any bytes, there will have memory leak."
|
53
|
+
end
|
54
|
+
|
55
|
+
task :benchmark do
|
56
|
+
require "rucaptcha"
|
57
|
+
require "benchmark/ips"
|
58
|
+
|
59
|
+
RuCaptchaCore.create(5, 5)
|
60
|
+
|
61
|
+
Benchmark.ips do |x|
|
62
|
+
x.report("Generate image") { RuCaptchaCore.create(5, 5) }
|
63
|
+
x.compare!
|
64
|
+
end
|
65
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
use image::{ImageBuffer, Rgb};
|
2
2
|
use imageproc::drawing::{draw_cubic_bezier_curve_mut, draw_text_mut};
|
3
|
-
use imageproc::noise::
|
3
|
+
use imageproc::noise::gaussian_noise_mut;
|
4
4
|
use rand::{thread_rng, Rng};
|
5
5
|
use rusttype::{Font, Scale};
|
6
6
|
use std::io::Cursor;
|
@@ -195,8 +195,8 @@ impl CaptchaBuilder {
|
|
195
195
|
pub fn new() -> Self {
|
196
196
|
CaptchaBuilder {
|
197
197
|
length: 4,
|
198
|
-
width:
|
199
|
-
height:
|
198
|
+
width: 220,
|
199
|
+
height: 70,
|
200
200
|
complexity: 5,
|
201
201
|
}
|
202
202
|
}
|
@@ -247,15 +247,9 @@ impl CaptchaBuilder {
|
|
247
247
|
((5 * self.complexity) - 5) as u64,
|
248
248
|
);
|
249
249
|
|
250
|
-
salt_and_pepper_noise_mut(
|
251
|
-
&mut image,
|
252
|
-
((0.001 * self.complexity as f64) - 0.001) as f64,
|
253
|
-
(0.8 * self.complexity as f64) as u64,
|
254
|
-
);
|
255
|
-
|
256
250
|
let mut bytes: Vec<u8> = Vec::new();
|
257
251
|
image
|
258
|
-
.write_to(&mut Cursor::new(&mut bytes), image::ImageFormat::
|
252
|
+
.write_to(&mut Cursor::new(&mut bytes), image::ImageFormat::Jpeg)
|
259
253
|
.unwrap();
|
260
254
|
|
261
255
|
Captcha { text, image: bytes }
|
Binary file
|
Binary file
|
Binary file
|
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: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|