rucaptcha 3.0.2 → 3.1.2.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c4e59d0ae8ca9c8150ed223a54bf4a477b53204ae493ca3fb7b539e369643c1
4
- data.tar.gz: 68360371ac0d535e650544ce9da1b10cb86c6789694f5f22a988ca81b40a1288
3
+ metadata.gz: 81a43a3920a527d883910bfadba7a44f4ff90be634a175f850c5642b0e4a1326
4
+ data.tar.gz: 8981a95b425dfc626b2591f05bbeb3217e0bfe2d36661244b304ee8c00d7a971
5
5
  SHA512:
6
- metadata.gz: ce175dcfa068ec3f305b4e3342e24157e903a60785a7cbc02b7658b07f96d9425ace21f014179b0e7519bc7a16240d0d1e6b279877ce9158e2273fc20865b1df
7
- data.tar.gz: 8f33fb0d3fff14ca563e11b3e99afd800997cea49cae0550fb8d522465b96026f438a9b6840871c8e4a4935a876213c7fb29ff144526608e2071e10dac27b033
6
+ metadata.gz: c470fa39817b95bdfa39fd77385a2f45b7a2e4a0acb459847d6667385a7b3a311cc7b77d40a78b30af962afd5cd44d893ab877dcd2941f456e69f5860364eb92
7
+ data.tar.gz: 8c7006fa7922601e165e249401505e61076363740188e5dea8af9e106d62249519fde01a776538b20a05ff94356eec08d9d685823a1d3e45934d52308ab92609
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
@@ -7,7 +7,7 @@ module RuCaptcha
7
7
  headers["Pragma"] = "no-cache"
8
8
  data = generate_rucaptcha
9
9
 
10
- opts = { disposition: "inline", type: "image/png" }
10
+ opts = { disposition: "inline", type: "image/jpeg" }
11
11
  send_data data, opts
12
12
  end
13
13
  end
@@ -0,0 +1,3 @@
1
+ 'de-DE':
2
+ rucaptcha:
3
+ invalid: "Falsches Captcha (Wenn es nicht erkannt wird, klicken Sie darauf , um das Captcha zu aktualisieren)"
@@ -9,6 +9,6 @@ crate-type = ["cdylib"]
9
9
  [dependencies]
10
10
  image = "0.24.4"
11
11
  imageproc = "0.23.0"
12
- magnus = "0.3"
12
+ magnus = "0.4"
13
13
  rand = "0.8.5"
14
14
  rusttype = "0.9.2"
@@ -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::{gaussian_noise_mut, salt_and_pepper_noise_mut};
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: 300,
199
- height: 100,
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::Png)
252
+ .write_to(&mut Cursor::new(&mut bytes), image::ImageFormat::Jpeg)
259
253
  .unwrap();
260
254
 
261
255
  Captcha { text, image: bytes }
@@ -1,3 +1,3 @@
1
1
  module RuCaptcha
2
- VERSION = "3.0.2"
2
+ VERSION = "3.1.2.pre2"
3
3
  end
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.2
4
+ version: 3.1.2.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-18 00:00:00.000000000 Z
11
+ date: 2023-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.9.18
41
- description:
41
+ description:
42
42
  email: huacnlee@gmail.com
43
43
  executables: []
44
44
  extensions:
@@ -48,6 +48,7 @@ files:
48
48
  - README.md
49
49
  - Rakefile
50
50
  - app/controllers/ru_captcha/captcha_controller.rb
51
+ - config/locales/rucaptcha.de-DE.yml
51
52
  - config/locales/rucaptcha.en.yml
52
53
  - config/locales/rucaptcha.pt-BR.yml
53
54
  - config/locales/rucaptcha.zh-CN.yml
@@ -72,7 +73,7 @@ homepage: https://github.com/huacnlee/rucaptcha
72
73
  licenses:
73
74
  - MIT
74
75
  metadata: {}
75
- post_install_message:
76
+ post_install_message:
76
77
  rdoc_options: []
77
78
  require_paths:
78
79
  - lib
@@ -83,12 +84,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
84
  version: 2.7.0
84
85
  required_rubygems_version: !ruby/object:Gem::Requirement
85
86
  requirements:
86
- - - ">="
87
+ - - ">"
87
88
  - !ruby/object:Gem::Version
88
- version: '0'
89
+ version: 1.3.1
89
90
  requirements: []
90
- rubygems_version: 3.4.0.dev
91
- signing_key:
91
+ rubygems_version: 3.4.1
92
+ signing_key:
92
93
  specification_version: 4
93
94
  summary: Captcha Gem for Rails, which generates captcha image by Rust.
94
95
  test_files: []