visual_captcha 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +7 -0
- data/assets/audios/12times2.mp3 +0 -0
- data/assets/audios/12times2.ogg +0 -0
- data/assets/audios/2times10.mp3 +0 -0
- data/assets/audios/2times10.ogg +0 -0
- data/assets/audios/4plus1.mp3 +0 -0
- data/assets/audios/4plus1.ogg +0 -0
- data/assets/audios/4plus3.mp3 +0 -0
- data/assets/audios/4plus3.ogg +0 -0
- data/assets/audios/5plus1.mp3 +0 -0
- data/assets/audios/5plus1.ogg +0 -0
- data/assets/audios/5times2.mp3 +0 -0
- data/assets/audios/5times2.ogg +0 -0
- data/assets/audios/6plus6.mp3 +0 -0
- data/assets/audios/6plus6.ogg +0 -0
- data/assets/audios/99plus1.mp3 +0 -0
- data/assets/audios/99plus1.ogg +0 -0
- data/assets/audios/add3to1.mp3 +0 -0
- data/assets/audios/add3to1.ogg +0 -0
- data/assets/audios/addblueandyellow.mp3 +0 -0
- data/assets/audios/addblueandyellow.ogg +0 -0
- data/assets/audios/after2.mp3 +0 -0
- data/assets/audios/after2.ogg +0 -0
- data/assets/audios/capitaloffrance.mp3 +0 -0
- data/assets/audios/capitaloffrance.ogg +0 -0
- data/assets/audios/divide4by2.mp3 +0 -0
- data/assets/audios/divide4by2.ogg +0 -0
- data/assets/audios/firstletteralphabet.mp3 +0 -0
- data/assets/audios/firstletteralphabet.ogg +0 -0
- data/assets/audios/milkcolor.mp3 +0 -0
- data/assets/audios/milkcolor.ogg +0 -0
- data/assets/audios/skycolor.mp3 +0 -0
- data/assets/audios/skycolor.ogg +0 -0
- data/assets/audios/skynight.mp3 +0 -0
- data/assets/audios/skynight.ogg +0 -0
- data/assets/audios/sunastar.mp3 +0 -0
- data/assets/audios/sunastar.ogg +0 -0
- data/assets/audios/thirdmonth.mp3 +0 -0
- data/assets/audios/thirdmonth.ogg +0 -0
- data/assets/audios/yourobot.mp3 +0 -0
- data/assets/audios/yourobot.ogg +0 -0
- data/assets/audios.json +82 -0
- data/assets/images/airplane.png +0 -0
- data/assets/images/airplane@2x.png +0 -0
- data/assets/images/balloons.png +0 -0
- data/assets/images/balloons@2x.png +0 -0
- data/assets/images/camera.png +0 -0
- data/assets/images/camera@2x.png +0 -0
- data/assets/images/car.png +0 -0
- data/assets/images/car@2x.png +0 -0
- data/assets/images/cat.png +0 -0
- data/assets/images/cat@2x.png +0 -0
- data/assets/images/chair.png +0 -0
- data/assets/images/chair@2x.png +0 -0
- data/assets/images/clip.png +0 -0
- data/assets/images/clip@2x.png +0 -0
- data/assets/images/clock.png +0 -0
- data/assets/images/clock@2x.png +0 -0
- data/assets/images/cloud.png +0 -0
- data/assets/images/cloud@2x.png +0 -0
- data/assets/images/computer.png +0 -0
- data/assets/images/computer@2x.png +0 -0
- data/assets/images/envelope.png +0 -0
- data/assets/images/envelope@2x.png +0 -0
- data/assets/images/eye.png +0 -0
- data/assets/images/eye@2x.png +0 -0
- data/assets/images/flag.png +0 -0
- data/assets/images/flag@2x.png +0 -0
- data/assets/images/folder.png +0 -0
- data/assets/images/folder@2x.png +0 -0
- data/assets/images/foot.png +0 -0
- data/assets/images/foot@2x.png +0 -0
- data/assets/images/graph.png +0 -0
- data/assets/images/graph@2x.png +0 -0
- data/assets/images/house.png +0 -0
- data/assets/images/house@2x.png +0 -0
- data/assets/images/key.png +0 -0
- data/assets/images/key@2x.png +0 -0
- data/assets/images/leaf.png +0 -0
- data/assets/images/leaf@2x.png +0 -0
- data/assets/images/light-bulb.png +0 -0
- data/assets/images/light-bulb@2x.png +0 -0
- data/assets/images/lock.png +0 -0
- data/assets/images/lock@2x.png +0 -0
- data/assets/images/magnifying-glass.png +0 -0
- data/assets/images/magnifying-glass@2x.png +0 -0
- data/assets/images/man.png +0 -0
- data/assets/images/man@2x.png +0 -0
- data/assets/images/music-note.png +0 -0
- data/assets/images/music-note@2x.png +0 -0
- data/assets/images/pants.png +0 -0
- data/assets/images/pants@2x.png +0 -0
- data/assets/images/pencil.png +0 -0
- data/assets/images/pencil@2x.png +0 -0
- data/assets/images/printer.png +0 -0
- data/assets/images/printer@2x.png +0 -0
- data/assets/images/robot.png +0 -0
- data/assets/images/robot@2x.png +0 -0
- data/assets/images/scissors.png +0 -0
- data/assets/images/scissors@2x.png +0 -0
- data/assets/images/sunglasses.png +0 -0
- data/assets/images/sunglasses@2x.png +0 -0
- data/assets/images/t-shirt.png +0 -0
- data/assets/images/t-shirt@2x.png +0 -0
- data/assets/images/tag.png +0 -0
- data/assets/images/tag@2x.png +0 -0
- data/assets/images/tree.png +0 -0
- data/assets/images/tree@2x.png +0 -0
- data/assets/images/truck.png +0 -0
- data/assets/images/truck@2x.png +0 -0
- data/assets/images/umbrella.png +0 -0
- data/assets/images/umbrella@2x.png +0 -0
- data/assets/images/woman.png +0 -0
- data/assets/images/woman@2x.png +0 -0
- data/assets/images/world.png +0 -0
- data/assets/images/world@2x.png +0 -0
- data/assets/images.json +150 -0
- data/lib/visual_captcha/captcha.rb +121 -0
- data/lib/visual_captcha/session.rb +24 -0
- data/lib/visual_captcha/version.rb +3 -0
- data/lib/visual_captcha.rb +9 -0
- data/spec/lib/visual_captcha/captcha_spec.rb +12 -0
- data/spec/lib/visual_captcha_spec.rb +4 -0
- data/spec/spec_helper.rb +1 -0
- data/visual_captcha.gemspec +26 -0
- metadata +231 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b8982b9d2f00d6f0b0ba6365d1ec6113b8aa5416
|
4
|
+
data.tar.gz: 1cc363dd419a646bb07f998cb3bd61de35a82ea7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a8df46eb4212c3ac44e56cc15a3c72bc4d53fcc37a98e1fb42859672eca3c76f90e2671b7858a310643cff8d1abc6c73a3c2a9bb81be491fec886a2551f7d50b
|
7
|
+
data.tar.gz: 238135b202959da80c35f2d7d5270fc76b647dad5e0a32af07b4a6718f71091a572d2ce8f9d569621cba7593197dfb60f49fe83b389d892abbd7e6fd60889975
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 emotionLoop
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/assets/audios.json
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"path": "5times2.mp3",
|
4
|
+
"value": "10"
|
5
|
+
},
|
6
|
+
{
|
7
|
+
"path": "2times10.mp3",
|
8
|
+
"value": "20"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"path": "5plus1.mp3",
|
12
|
+
"value": "6"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"path": "4plus1.mp3",
|
16
|
+
"value": "5"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"path": "4plus3.mp3",
|
20
|
+
"value": "7"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"path": "6plus6.mp3",
|
24
|
+
"value": "12"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"path": "12times2.mp3",
|
28
|
+
"value": "24"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"path": "99plus1.mp3",
|
32
|
+
"value": "100"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"path": "add3to1.mp3",
|
36
|
+
"value": "4"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"path": "addblueandyellow.mp3",
|
40
|
+
"value": "green"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"path": "after2.mp3",
|
44
|
+
"value": "3"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"path": "divide4by2.mp3",
|
48
|
+
"value": "2"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"path": "milkcolor.mp3",
|
52
|
+
"value": "white"
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"path": "skycolor.mp3",
|
56
|
+
"value": "blue"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"path": "sunastar.mp3",
|
60
|
+
"value": "yes"
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"path": "yourobot.mp3",
|
64
|
+
"value": "no"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"path": "capitaloffrance.mp3",
|
68
|
+
"value": "paris"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"path": "skynight.mp3",
|
72
|
+
"value": "black"
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"path": "thirdmonth.mp3",
|
76
|
+
"value": "march"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"path": "firstletteralphabet.mp3",
|
80
|
+
"value": "a"
|
81
|
+
}
|
82
|
+
]
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/assets/images.json
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "Airplane",
|
4
|
+
"path": "airplane.png"
|
5
|
+
},
|
6
|
+
{
|
7
|
+
"name": "Balloons",
|
8
|
+
"path": "balloons.png"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"name": "Camera",
|
12
|
+
"path": "camera.png"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "Car",
|
16
|
+
"path": "car.png"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"name": "Cat",
|
20
|
+
"path": "cat.png"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"name": "Chair",
|
24
|
+
"path": "chair.png"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "Clip",
|
28
|
+
"path": "clip.png"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"name": "Clock",
|
32
|
+
"path": "clock.png"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "Cloud",
|
36
|
+
"path": "cloud.png"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "Computer",
|
40
|
+
"path": "computer.png"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"name": "Envelope",
|
44
|
+
"path": "envelope.png"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"name": "Eye",
|
48
|
+
"path": "eye.png"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name": "Flag",
|
52
|
+
"path": "flag.png"
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"name": "Folder",
|
56
|
+
"path": "folder.png"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"name": "Foot",
|
60
|
+
"path": "foot.png"
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"name": "Graph",
|
64
|
+
"path": "graph.png"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"name": "House",
|
68
|
+
"path": "house.png"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"name": "Key",
|
72
|
+
"path": "key.png"
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"name": "Leaf",
|
76
|
+
"path": "leaf.png"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"name": "Light Bulb",
|
80
|
+
"path": "light-bulb.png"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "Lock",
|
84
|
+
"path": "lock.png"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"name": "Magnifying Glass",
|
88
|
+
"path": "magnifying-glass.png"
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"name": "Man",
|
92
|
+
"path": "man.png"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"name": "Music Note",
|
96
|
+
"path": "music-note.png"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"name": "Pants",
|
100
|
+
"path": "pants.png"
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"name": "Pencil",
|
104
|
+
"path": "pencil.png"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"name": "Printer",
|
108
|
+
"path": "printer.png"
|
109
|
+
},
|
110
|
+
{
|
111
|
+
"name": "Robot",
|
112
|
+
"path": "robot.png"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"name": "Scissors",
|
116
|
+
"path": "scissors.png"
|
117
|
+
},
|
118
|
+
{
|
119
|
+
"name": "Sunglasses",
|
120
|
+
"path": "sunglasses.png"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"name": "Tag",
|
124
|
+
"path": "tag.png"
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"name": "Tree",
|
128
|
+
"path": "tree.png"
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"name": "Truck",
|
132
|
+
"path": "truck.png"
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"name": "T-Shirt",
|
136
|
+
"path": "t-shirt.png"
|
137
|
+
},
|
138
|
+
{
|
139
|
+
"name": "Umbrella",
|
140
|
+
"path": "umbrella.png"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"name": "Woman",
|
144
|
+
"path": "woman.png"
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"name": "World",
|
148
|
+
"path": "world.png"
|
149
|
+
}
|
150
|
+
]
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
class VisualCaptcha::Captcha
|
5
|
+
def initialize(session, assets_path = nil, default_images = nil, default_audios = nil)
|
6
|
+
@session = session
|
7
|
+
|
8
|
+
@assets_path = assets_path
|
9
|
+
@assets_path ||= File.join VisualCaptcha.root, 'assets'
|
10
|
+
|
11
|
+
@image_options = default_images
|
12
|
+
@image_options ||= JSON.load File.read("#{@assets_path}/images.json")
|
13
|
+
|
14
|
+
@audio_options = default_audios
|
15
|
+
@audio_options ||= JSON.load File.read("#{@assets_path}/audios.json")
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate(number_of_options = 5)
|
19
|
+
@session.clear
|
20
|
+
|
21
|
+
number_of_options = number_of_options.to_i
|
22
|
+
number_of_options = 2 if number_of_options < 2
|
23
|
+
|
24
|
+
images = all_image_options.sample number_of_options
|
25
|
+
images.each do |image|
|
26
|
+
image['value'] = SecureRandom.hex 10
|
27
|
+
end
|
28
|
+
|
29
|
+
@session.set 'images', images
|
30
|
+
|
31
|
+
@session.set 'validImageOption', selected_images.sample
|
32
|
+
|
33
|
+
@session.set 'validAudioOption', all_audio_options.sample
|
34
|
+
|
35
|
+
@session.set 'frontendData', {
|
36
|
+
'values' => selected_images.map { |i| i['value'] },
|
37
|
+
'imageName' => valid_image_option['name'],
|
38
|
+
'imageFieldName' => SecureRandom.hex(10),
|
39
|
+
'audioFieldName' => SecureRandom.hex(10)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def stream_audio(headers, file_type = 'mp3')
|
44
|
+
audio_option = valid_audio_option
|
45
|
+
return nil if audio_option.nil?
|
46
|
+
|
47
|
+
audio_file_name = "#{audio_option['path']}"
|
48
|
+
audio_file_path = "#{@assets_path}/audios/#{audio_file_name}"
|
49
|
+
|
50
|
+
if file_type == 'ogg'
|
51
|
+
audio_file_path.gsub! /\.mp3/i, '.ogg'
|
52
|
+
|
53
|
+
content_type = 'application/ogg'
|
54
|
+
else
|
55
|
+
content_type = 'audio/mpeg'
|
56
|
+
end
|
57
|
+
|
58
|
+
read_file headers, audio_file_path, content_type
|
59
|
+
end
|
60
|
+
|
61
|
+
def stream_image(headers, index, is_retina)
|
62
|
+
image_option = selected_image_at_index index.to_i
|
63
|
+
return nil if image_option.nil?
|
64
|
+
|
65
|
+
image_file_name = "#{image_option['path']}"
|
66
|
+
image_file_name.gsub! /\.png/i, '@2x.png' if (is_retina.to_i >= 1)
|
67
|
+
image_file_path = "#{@assets_path}/images/#{image_file_name}"
|
68
|
+
|
69
|
+
read_file headers, image_file_path, 'image/png'
|
70
|
+
end
|
71
|
+
|
72
|
+
def selected_images
|
73
|
+
@session.get 'images'
|
74
|
+
end
|
75
|
+
|
76
|
+
def selected_image_at_index(index)
|
77
|
+
images = selected_images
|
78
|
+
images[index] unless images.nil?
|
79
|
+
end
|
80
|
+
|
81
|
+
def frontend_data
|
82
|
+
@session.get 'frontendData'
|
83
|
+
end
|
84
|
+
|
85
|
+
def valid_image_option
|
86
|
+
@session.get 'validImageOption'
|
87
|
+
end
|
88
|
+
|
89
|
+
def valid_audio_option
|
90
|
+
@session.get 'validAudioOption'
|
91
|
+
end
|
92
|
+
|
93
|
+
def validate_image(sent_option)
|
94
|
+
sent_option == valid_image_option['value']
|
95
|
+
end
|
96
|
+
|
97
|
+
def validate_audio(sent_option)
|
98
|
+
sent_option == valid_audio_option['value']
|
99
|
+
end
|
100
|
+
|
101
|
+
def all_image_options
|
102
|
+
@image_options
|
103
|
+
end
|
104
|
+
|
105
|
+
def all_audio_options
|
106
|
+
@audio_options
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def read_file(headers, file_path, content_type)
|
112
|
+
return nil unless File.exists? file_path
|
113
|
+
|
114
|
+
headers['Content-Type'] = content_type
|
115
|
+
headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
|
116
|
+
headers['Pragma'] = 'no-cache'
|
117
|
+
headers['Expires'] = '0'
|
118
|
+
|
119
|
+
File.read file_path
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class VisualCaptcha::Session
|
2
|
+
attr_accessor :session, :namespace
|
3
|
+
|
4
|
+
def initialize(session, namespace = 'visualcaptcha')
|
5
|
+
self.session = session
|
6
|
+
self.namespace = namespace
|
7
|
+
end
|
8
|
+
|
9
|
+
def clear
|
10
|
+
session[namespace] = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(key)
|
14
|
+
clear if session[namespace].nil?
|
15
|
+
|
16
|
+
session[namespace][key]
|
17
|
+
end
|
18
|
+
|
19
|
+
def set(key, value)
|
20
|
+
clear if session[namespace].nil?
|
21
|
+
|
22
|
+
session[namespace][key] = value
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'visual_captcha'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'visual_captcha/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "visual_captcha"
|
8
|
+
spec.version = VisualCaptcha::VERSION
|
9
|
+
spec.authors = ["emotionLoop"]
|
10
|
+
spec.email = "hello@emotionloop.com"
|
11
|
+
spec.description = "RubyGem package for visualCaptcha's backend service"
|
12
|
+
spec.summary = "visualCaptcha RubyGem Package"
|
13
|
+
spec.homepage = "http://emotionloop.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "json"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: visual_captcha
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- emotionLoop
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: RubyGem package for visualCaptcha's backend service
|
70
|
+
email: hello@emotionloop.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- ".gitignore"
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- assets/audios.json
|
81
|
+
- assets/audios/12times2.mp3
|
82
|
+
- assets/audios/12times2.ogg
|
83
|
+
- assets/audios/2times10.mp3
|
84
|
+
- assets/audios/2times10.ogg
|
85
|
+
- assets/audios/4plus1.mp3
|
86
|
+
- assets/audios/4plus1.ogg
|
87
|
+
- assets/audios/4plus3.mp3
|
88
|
+
- assets/audios/4plus3.ogg
|
89
|
+
- assets/audios/5plus1.mp3
|
90
|
+
- assets/audios/5plus1.ogg
|
91
|
+
- assets/audios/5times2.mp3
|
92
|
+
- assets/audios/5times2.ogg
|
93
|
+
- assets/audios/6plus6.mp3
|
94
|
+
- assets/audios/6plus6.ogg
|
95
|
+
- assets/audios/99plus1.mp3
|
96
|
+
- assets/audios/99plus1.ogg
|
97
|
+
- assets/audios/add3to1.mp3
|
98
|
+
- assets/audios/add3to1.ogg
|
99
|
+
- assets/audios/addblueandyellow.mp3
|
100
|
+
- assets/audios/addblueandyellow.ogg
|
101
|
+
- assets/audios/after2.mp3
|
102
|
+
- assets/audios/after2.ogg
|
103
|
+
- assets/audios/capitaloffrance.mp3
|
104
|
+
- assets/audios/capitaloffrance.ogg
|
105
|
+
- assets/audios/divide4by2.mp3
|
106
|
+
- assets/audios/divide4by2.ogg
|
107
|
+
- assets/audios/firstletteralphabet.mp3
|
108
|
+
- assets/audios/firstletteralphabet.ogg
|
109
|
+
- assets/audios/milkcolor.mp3
|
110
|
+
- assets/audios/milkcolor.ogg
|
111
|
+
- assets/audios/skycolor.mp3
|
112
|
+
- assets/audios/skycolor.ogg
|
113
|
+
- assets/audios/skynight.mp3
|
114
|
+
- assets/audios/skynight.ogg
|
115
|
+
- assets/audios/sunastar.mp3
|
116
|
+
- assets/audios/sunastar.ogg
|
117
|
+
- assets/audios/thirdmonth.mp3
|
118
|
+
- assets/audios/thirdmonth.ogg
|
119
|
+
- assets/audios/yourobot.mp3
|
120
|
+
- assets/audios/yourobot.ogg
|
121
|
+
- assets/images.json
|
122
|
+
- assets/images/airplane.png
|
123
|
+
- assets/images/airplane@2x.png
|
124
|
+
- assets/images/balloons.png
|
125
|
+
- assets/images/balloons@2x.png
|
126
|
+
- assets/images/camera.png
|
127
|
+
- assets/images/camera@2x.png
|
128
|
+
- assets/images/car.png
|
129
|
+
- assets/images/car@2x.png
|
130
|
+
- assets/images/cat.png
|
131
|
+
- assets/images/cat@2x.png
|
132
|
+
- assets/images/chair.png
|
133
|
+
- assets/images/chair@2x.png
|
134
|
+
- assets/images/clip.png
|
135
|
+
- assets/images/clip@2x.png
|
136
|
+
- assets/images/clock.png
|
137
|
+
- assets/images/clock@2x.png
|
138
|
+
- assets/images/cloud.png
|
139
|
+
- assets/images/cloud@2x.png
|
140
|
+
- assets/images/computer.png
|
141
|
+
- assets/images/computer@2x.png
|
142
|
+
- assets/images/envelope.png
|
143
|
+
- assets/images/envelope@2x.png
|
144
|
+
- assets/images/eye.png
|
145
|
+
- assets/images/eye@2x.png
|
146
|
+
- assets/images/flag.png
|
147
|
+
- assets/images/flag@2x.png
|
148
|
+
- assets/images/folder.png
|
149
|
+
- assets/images/folder@2x.png
|
150
|
+
- assets/images/foot.png
|
151
|
+
- assets/images/foot@2x.png
|
152
|
+
- assets/images/graph.png
|
153
|
+
- assets/images/graph@2x.png
|
154
|
+
- assets/images/house.png
|
155
|
+
- assets/images/house@2x.png
|
156
|
+
- assets/images/key.png
|
157
|
+
- assets/images/key@2x.png
|
158
|
+
- assets/images/leaf.png
|
159
|
+
- assets/images/leaf@2x.png
|
160
|
+
- assets/images/light-bulb.png
|
161
|
+
- assets/images/light-bulb@2x.png
|
162
|
+
- assets/images/lock.png
|
163
|
+
- assets/images/lock@2x.png
|
164
|
+
- assets/images/magnifying-glass.png
|
165
|
+
- assets/images/magnifying-glass@2x.png
|
166
|
+
- assets/images/man.png
|
167
|
+
- assets/images/man@2x.png
|
168
|
+
- assets/images/music-note.png
|
169
|
+
- assets/images/music-note@2x.png
|
170
|
+
- assets/images/pants.png
|
171
|
+
- assets/images/pants@2x.png
|
172
|
+
- assets/images/pencil.png
|
173
|
+
- assets/images/pencil@2x.png
|
174
|
+
- assets/images/printer.png
|
175
|
+
- assets/images/printer@2x.png
|
176
|
+
- assets/images/robot.png
|
177
|
+
- assets/images/robot@2x.png
|
178
|
+
- assets/images/scissors.png
|
179
|
+
- assets/images/scissors@2x.png
|
180
|
+
- assets/images/sunglasses.png
|
181
|
+
- assets/images/sunglasses@2x.png
|
182
|
+
- assets/images/t-shirt.png
|
183
|
+
- assets/images/t-shirt@2x.png
|
184
|
+
- assets/images/tag.png
|
185
|
+
- assets/images/tag@2x.png
|
186
|
+
- assets/images/tree.png
|
187
|
+
- assets/images/tree@2x.png
|
188
|
+
- assets/images/truck.png
|
189
|
+
- assets/images/truck@2x.png
|
190
|
+
- assets/images/umbrella.png
|
191
|
+
- assets/images/umbrella@2x.png
|
192
|
+
- assets/images/woman.png
|
193
|
+
- assets/images/woman@2x.png
|
194
|
+
- assets/images/world.png
|
195
|
+
- assets/images/world@2x.png
|
196
|
+
- lib/visual_captcha.rb
|
197
|
+
- lib/visual_captcha/captcha.rb
|
198
|
+
- lib/visual_captcha/session.rb
|
199
|
+
- lib/visual_captcha/version.rb
|
200
|
+
- spec/lib/visual_captcha/captcha_spec.rb
|
201
|
+
- spec/lib/visual_captcha_spec.rb
|
202
|
+
- spec/spec_helper.rb
|
203
|
+
- visual_captcha.gemspec
|
204
|
+
homepage: http://emotionloop.com
|
205
|
+
licenses:
|
206
|
+
- MIT
|
207
|
+
metadata: {}
|
208
|
+
post_install_message:
|
209
|
+
rdoc_options: []
|
210
|
+
require_paths:
|
211
|
+
- lib
|
212
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
requirements: []
|
223
|
+
rubyforge_project:
|
224
|
+
rubygems_version: 2.0.14
|
225
|
+
signing_key:
|
226
|
+
specification_version: 4
|
227
|
+
summary: visualCaptcha RubyGem Package
|
228
|
+
test_files:
|
229
|
+
- spec/lib/visual_captcha/captcha_spec.rb
|
230
|
+
- spec/lib/visual_captcha_spec.rb
|
231
|
+
- spec/spec_helper.rb
|