kapchonka 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 0f8900bee1ff49fe2f0a4aa08c247425b3c474a3
4
- data.tar.gz: bea04f5fedbf11ba453a73265e0e6396a86d03b3
3
+ metadata.gz: e812c6963ce8c42a1dc0a6f2afc2d21e2e796a8f
4
+ data.tar.gz: 3acfaba1dc91f8e842aeebc5de82c256123dec9b
5
5
  SHA512:
6
- metadata.gz: 4ee823ede479da76daf144cd5d6159886656198091aff81d8a9dd016df2b00cbb43655688d2fd2ef82d66ebe5e7ccd47b1fbdc09c6691a73be4e76b110110b84
7
- data.tar.gz: 6130c8285f78de21c6826aead53d0c3510131731304b48c1e08d35d55c540625b27ced68fe1d77826130834b50725910e6b167e5a484867d58aaed5aa390286e
6
+ metadata.gz: 0923d2bcd893f898c456032126cc51b00e681ec2a1305390812e63898e3e594cc46e1c28e6bf575dda9b6327b74bea90aa4162c3ad60d5e7f65999209ad018c3
7
+ data.tar.gz: 20578519f76e4a6e4ff42caa3949b88de50ec309c8ee1e98179b80e3b9a833d7856e00f7ab4586a1f752c97823fb169e00650920264a2ad3f61772f7f5d5e806
@@ -7,6 +7,8 @@ module Kapchonka
7
7
  autoload :ControllerHelper, 'kapchonka/controller_helper'
8
8
 
9
9
  mattr_accessor :store
10
+ mattr_accessor :driver
11
+ mattr_accessor :expire
10
12
  mattr_accessor :image_width
11
13
  mattr_accessor :image_height
12
14
  mattr_accessor :font_family
@@ -18,12 +20,12 @@ module Kapchonka
18
20
  mattr_accessor :operant_max_number
19
21
 
20
22
 
21
- def self.setup
22
- yield self
23
- end
24
-
25
23
  class << self
26
24
 
25
+ def setup
26
+ yield self
27
+ end
28
+
27
29
  def image_width
28
30
  @image_width || 180
29
31
  end
@@ -60,6 +62,10 @@ module Kapchonka
60
62
  @operands || %w(+ - *)
61
63
  end
62
64
 
65
+ def expire
66
+ 3600
67
+ end
68
+
63
69
  def store
64
70
  @store || :session
65
71
  end
@@ -5,19 +5,20 @@ module Kapchonka
5
5
 
6
6
  class Engine < ::Rails::Engine
7
7
 
8
- config.before_initialize do
8
+ config.after_initialize do
9
9
  case Kapchonka.store
10
10
  when :test
11
11
  require 'kapchonka/test_storage.rb'
12
+ when :redis
13
+ require 'kapchonka/redis_storage.rb'
14
+ when :memcache
15
+ require 'kapchonka/memcache_storage.rb'
12
16
  when :session
13
- include ActionDispatch::Session
14
17
  require 'kapchonka/session_storage.rb'
15
18
  else
16
19
  raise StandardError.new("Unknown store: #{Kapchonka.store}")
17
20
  end
18
- end
19
21
 
20
- config.after_initialize do
21
22
  ActionView::Base.send(:include, Kapchonka::ViewHelper)
22
23
  end
23
24
 
@@ -0,0 +1,23 @@
1
+ module Kapchonka
2
+
3
+ class Storage
4
+ class << self
5
+
6
+ def save! key, value
7
+ memcache = Kapchonka.driver
8
+ memcache.set key.to_s, value.to_s, Kapchonka.expire
9
+ end
10
+
11
+ def get key
12
+ Kapchonka.driver.get key.to_s
13
+ end
14
+
15
+ def remove! key
16
+ Kapchonka.driver.delete key.to_s
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,24 @@
1
+ module Kapchonka
2
+
3
+ class Storage
4
+ class << self
5
+
6
+ def save! key, value
7
+ @redis = Kapchonka.driver
8
+ @redis.set key.to_s, value.to_s
9
+ @redis.expire key, Kapchonka.expire
10
+ end
11
+
12
+ def get key
13
+ Kapchonka.driver.get key.to_s
14
+ end
15
+
16
+ def remove! key
17
+ Kapchonka.driver.del key.to_s
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -1,5 +1,5 @@
1
1
  module Kapchonka
2
2
 
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kapchonka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgar Meinart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,6 +80,48 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: redis
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: memcached
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
83
125
  description: Simple captcha
84
126
  email:
85
127
  - edgars@meinarts.name
@@ -88,7 +130,6 @@ extensions: []
88
130
  extra_rdoc_files: []
89
131
  files:
90
132
  - MIT-LICENSE
91
- - README.rdoc
92
133
  - Rakefile
93
134
  - lib/generators/kapchonka_generator.rb
94
135
  - lib/generators/templates/config.rb
@@ -97,6 +138,8 @@ files:
97
138
  - lib/kapchonka.rb
98
139
  - lib/kapchonka/controller_helper.rb
99
140
  - lib/kapchonka/engine.rb
141
+ - lib/kapchonka/memcache_storage.rb
142
+ - lib/kapchonka/redis_storage.rb
100
143
  - lib/kapchonka/session_storage.rb
101
144
  - lib/kapchonka/test_storage.rb
102
145
  - lib/kapchonka/utils.rb
@@ -1,3 +0,0 @@
1
- = Kapchonka
2
-
3
- This project rocks and uses MIT-LICENSE.