redis-email_activation_token 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34d4beb09411f1c70cfaaad8ffbb014e741a235d
4
+ data.tar.gz: ec2548e3def5c2bb6815ec3c56209bfe2d0dbb8d
5
+ SHA512:
6
+ metadata.gz: 28f4db3473db442dfc4808dda237ee380b34b470215988a21c24b33d30ac9695db944a5aab330e0e820f12c60bc00a5ffa06ca384d7ed1f2d6416e0f644c07ea
7
+ data.tar.gz: a407d0f7a701f7387c19e054d6fab30b923ee8450c426db6928e0d48f791d4332c05651d6cb608e1cb3aefea1a69f1172e91bc5d30c065c090ee4a03ac4fa3c7
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /vendor/bundle
16
+ dump.rdb
data/.pryrc ADDED
@@ -0,0 +1 @@
1
+ require_relative 'lib/redis-email_activation_token'
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 2.1.2
5
+ - 2.1.3
6
+ services:
7
+ - redis-server
8
+ script: bundle exec rspec
9
+ notifications:
10
+ on_success: always
11
+ on_failure: always
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'redis'
6
+
7
+ group :test, :development do
8
+ gem 'ffaker'
9
+ gem 'awesome_print'
10
+
11
+ gem 'guard'
12
+ gem 'guard-rspec'
13
+ gem 'growl'
14
+
15
+ gem 'byebug'
16
+ gem 'pry-rails'
17
+ gem 'pry-coolline'
18
+ gem 'pry-doc'
19
+ gem 'pry-byebug'
20
+ gem 'pry-stack_explorer'
21
+ end
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+
6
+ watch(%r{^lib/redis/email_activation_token/redis_ext.rb$}) { |m| "spec/lib/redis/email_activation_token/redis_ext_spec.rb" }
7
+ end
8
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 onigra
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Redis::EmailActivationToken
2
+
3
+ [![Build Status](https://travis-ci.org/onigra/redis-email_activation_token.svg?branch=master)](https://travis-ci.org/onigra/redis-email_activation_token) [![Coverage Status](https://coveralls.io/repos/onigra/redis-email_activation_token/badge.png?branch=master)](https://coveralls.io/r/onigra/redis-email_activation_token?branch=master) [![Code Climate](https://codeclimate.com/github/onigra/redis-email_activation_token/badges/gpa.svg)](https://codeclimate.com/github/onigra/redis-email_activation_token)
4
+
5
+ TODO: Write a gem description
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'redis-email_activation_token'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install redis-email_activation_token
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/redis-email-activation-token/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1 @@
1
+ require 'redis/email_activation_token'
@@ -0,0 +1,5 @@
1
+ require 'redis'
2
+
3
+ dir = File.expand_path("email_activation_token", File.dirname(__FILE__))
4
+ require dir + "/version"
5
+ require dir + "/redis_ext"
@@ -0,0 +1,44 @@
1
+ require 'redis'
2
+
3
+ class Redis
4
+ class EmailActivationToken
5
+ attr_reader :expire
6
+
7
+ def initialize(email, opts = {})
8
+ @email = email
9
+ @expire = opts.delete(:expire) || 259200 # default 3 days
10
+ @redis = opts.delete(:redis) || Redis.new(opts)
11
+
12
+ freeze
13
+ end
14
+
15
+ def create
16
+ if exists?
17
+ false
18
+ else
19
+ set_key
20
+ get
21
+ end
22
+ end
23
+
24
+ def exists?
25
+ @redis.exists @email
26
+ end
27
+
28
+ def get
29
+ @redis.get @email
30
+ end
31
+
32
+ private
33
+
34
+ def set_key
35
+ @redis.set(@email, generate_token)
36
+ @redis.expire(@email, @expire)
37
+ end
38
+
39
+ def generate_token
40
+ SecureRandom.urlsafe_base64
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ class Redis
2
+ class EmailActivationToken
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'redis/email_activation_token/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "redis-email_activation_token"
8
+ spec.version = Redis::EmailActivationToken::VERSION
9
+ spec.authors = ["onigra"]
10
+ spec.email = ["3280467rec@gmail.com"]
11
+ spec.summary = %q{Create email activation token by redis}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "coveralls"
25
+ end
@@ -0,0 +1,79 @@
1
+ require File.expand_path(File.join('../../../', 'spec_helper'), File.dirname(__FILE__))
2
+
3
+ describe "redis" do
4
+ before :all do
5
+ @redis = Redis.new :db => 15
6
+ end
7
+
8
+ before :each do
9
+ @redis.flushdb
10
+ end
11
+
12
+ after :all do
13
+ @redis.quit
14
+ end
15
+
16
+ describe Redis::EmailActivationToken do
17
+ let(:obj) { Redis::EmailActivationToken.new(Faker::Internet.free_email, redis: @redis) }
18
+
19
+ describe "#create" do
20
+ context "nothing" do
21
+ subject { obj.create }
22
+
23
+ it "Return Activation Token" do
24
+ is_expected.to be_kind_of String
25
+ end
26
+ end
27
+
28
+ context "exists" do
29
+ before { obj.create }
30
+ subject { obj.create }
31
+ it { is_expected.to be_falsy }
32
+ end
33
+ end
34
+
35
+ describe "#exists?" do
36
+ context "nothing" do
37
+ subject { obj.exists? }
38
+ it { is_expected.to be_falsy }
39
+ end
40
+
41
+ context "exists" do
42
+ before { obj.create }
43
+ subject { obj.exists? }
44
+ it { is_expected.to be_truthy }
45
+ end
46
+ end
47
+
48
+ describe "#get" do
49
+ context "nothing" do
50
+ subject { obj.get }
51
+ it { is_expected.to be_falsy }
52
+ end
53
+
54
+ context "exists" do
55
+ before { obj.create }
56
+ subject { obj.get }
57
+
58
+ it "Return Activation Token" do
59
+ is_expected.to be_kind_of String
60
+ end
61
+ end
62
+ end
63
+
64
+ describe "Expiry Time Set" do
65
+ let(:obj) { Redis::EmailActivationToken.new(Faker::Internet.free_email, redis: @redis, expire: 5) }
66
+
67
+ it "expite == 5" do
68
+ expect(obj.expire).to eq 5
69
+ end
70
+
71
+ it "Expire Check" do
72
+ obj.create
73
+ sleep 6
74
+ expect(obj.exists?).to be_falsy
75
+ end
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ Bundler.setup
5
+
6
+ require 'redis/email_activation_token'
7
+ require 'ffaker'
8
+ require 'ap'
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redis-email_activation_token
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - onigra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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: coveralls
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: ''
70
+ email:
71
+ - 3280467rec@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".coveralls.yml"
77
+ - ".gitignore"
78
+ - ".pryrc"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - Guardfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - lib/redis-email_activation_token.rb
87
+ - lib/redis/email_activation_token.rb
88
+ - lib/redis/email_activation_token/redis_ext.rb
89
+ - lib/redis/email_activation_token/version.rb
90
+ - redis-email_activation_token.gemspec
91
+ - spec/lib/redis/email_activation_token/redis_ext_spec.rb
92
+ - spec/spec_helper.rb
93
+ homepage: ''
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.2.2
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Create email activation token by redis
117
+ test_files:
118
+ - spec/lib/redis/email_activation_token/redis_ext_spec.rb
119
+ - spec/spec_helper.rb
120
+ has_rdoc: