simple_captcha_guard 0.1.2 → 0.1.4

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
  SHA256:
3
- metadata.gz: 851f28c627a713cad8109d104ae07e848c10f41c78c83dad22868d7ffe373613
4
- data.tar.gz: 760eece5b558de34cf3dadd9c45d62a46a69dfb85b25074bf171160d322d91b0
3
+ metadata.gz: 5384f71624d510527ba7207c1764ecc2e43a668e6de9df865833d2caa8a545f1
4
+ data.tar.gz: b2d02535c1dfa151071b48ce4d4339cf7579c3c05907fe02b015c01e5cbaba85
5
5
  SHA512:
6
- metadata.gz: 5874720c9564e7aec2983c08912629dc61d73a8702625f9c0eabef9f127f085fcbab3d681df0daa32e696cafec9c5b097db6ad07f81c9b09ea97d85ffb4e5187
7
- data.tar.gz: 300fcc972e3399319206f8c5a83b23fbab1c9871802efea4a89ac91f3447f7d2f4b9a92ac30955bd0228dda997b4bdc5c0a5672b022340814736698b982e35c8
6
+ metadata.gz: 32a6525b8b681d8b840926e1a4e2d2fa3519ec62320b1894e4e8584cabd7933a2a10ffbec1678a6a42b9f691a976e76f58f057f01423340d95138e4d41d05d4b
7
+ data.tar.gz: b4e97de1cf3f83c110023355e1f621bca0112502e402fe29ae69d49d863d5b1111532739d6395161d7cc61ef7c5e0d8b0451441ebfe74109388202b000e655ba
@@ -12,7 +12,7 @@ module SimpleCaptchaGuard
12
12
  end
13
13
 
14
14
  def generate_image
15
- MiniMagick::Tool::Convert.new do |convert|
15
+ image = MiniMagick::Tool::Convert.new do |convert|
16
16
  convert.size "121x41"
17
17
  convert.gravity "center"
18
18
  convert.xc "white"
@@ -21,20 +21,27 @@ module SimpleCaptchaGuard
21
21
  convert.pointsize "29"
22
22
  convert.draw "text 0,0 '#{@code}'"
23
23
  color_map = { 1 => "green", 2 => "red", 3 => "blue", 4 => "orange"}
24
- # Add random lines (5 lines)
25
- stroke_count = rand(5..7)
24
+ stroke_count = rand(6..7)
26
25
  stroke_count.times do
27
- convert.stroke "#{color_map[rand(1..4)]}" # line color
28
- convert.strokewidth "#{rand(2)}" # line thickness
29
- x1, y1 = rand(40), rand(40)
30
- x2, y2 = rand(65..120), rand(40)
26
+ convert.stroke "#{color_map[rand(1..4)]}"
27
+ convert.strokewidth "#{rand(2)}"
28
+ x1, y1 = rand(40), rand(38)
29
+ x2, y2 = rand(65..120), rand(38)
31
30
  convert.draw "line #{x1},#{y1} #{x2},#{y2}"
32
31
  end
33
- convert.wave "3x50"
34
- convert << "png:-" # Output to stdout (returns binary blob)
35
-
36
- end.to_blob
32
+ convert.wave "3x55"
33
+ convert << "png:-"
34
+ end
35
+
36
+ # `image` is a String: either image data or a filename
37
+ # If it's a filename, read and return the binary data
38
+ if image.is_a?(String) && File.exist?(image)
39
+ File.binread(image)
40
+ else
41
+ image
42
+ end
37
43
  end
38
44
 
45
+
39
46
  end
40
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_captcha_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmed Mahir Tazwar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-28 00:00:00.000000000 Z
11
+ date: 2025-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -34,7 +34,7 @@ files:
34
34
  - lib/simple_captcha_guard/captcha.rb
35
35
  - lib/simple_captcha_guard/captcha_helper.rb
36
36
  - lib/simple_captcha_guard/railtie.rb
37
- homepage: https://github.com/Utshas/simple-captcha-guard
37
+ homepage: https://medium.com/@tazwarutshas/simplecaptchaguard-add-captcha-protection-to-your-rails-forms-in-seconds-785413d3b807
38
38
  licenses:
39
39
  - MIT
40
40
  metadata: {}