tokens 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2a28e199dfcdd847face8b1157f00ea709a8239
4
+ data.tar.gz: 61ea50e28ce8f06f3b6952a188ae396d30401736
5
+ SHA512:
6
+ metadata.gz: ea8313701c2fc63cf95fb23d18f6d585568debba0e54cd9f9a27ed75507e9c6aa725b8586cf88dff16fdce4f9399d92269d8dba4fe771c07d4dbfb6049939cb7
7
+ data.tar.gz: 12e08c3f5804d7ff40668bf6e12efe94253798b27cd3c2649b82e4b2220593f0d4cf0463772548e925d369da60e3288ec21d0381406e731aca10ce906c2054d9
data/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
1
  pkg
2
- Gemfile.lock
3
2
  .bundle
4
- *.log
3
+ *.log
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ script: "bundle exec rake spec"
3
+
4
+ rvm:
5
+ - 2.0.0
6
+ - 1.9.3
7
+
8
+ gemfile:
9
+ - gemfiles/rails3.gemfile
10
+ - gemfiles/rails4.gemfile
11
+
12
+ notifications:
13
+ email:
14
+ - fnando.vieira@gmail.com
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source "http://rubygems.org"
2
2
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tokens (2.0.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.13)
10
+ actionpack (= 3.2.13)
11
+ mail (~> 2.5.3)
12
+ actionpack (3.2.13)
13
+ activemodel (= 3.2.13)
14
+ activesupport (= 3.2.13)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.4)
18
+ rack (~> 1.4.5)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.2.1)
22
+ activemodel (3.2.13)
23
+ activesupport (= 3.2.13)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.13)
26
+ activemodel (= 3.2.13)
27
+ activesupport (= 3.2.13)
28
+ arel (~> 3.0.2)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.13)
31
+ activemodel (= 3.2.13)
32
+ activesupport (= 3.2.13)
33
+ activesupport (3.2.13)
34
+ i18n (= 0.6.1)
35
+ multi_json (~> 1.0)
36
+ arel (3.0.2)
37
+ awesome_print (1.1.0)
38
+ builder (3.0.4)
39
+ coderay (1.0.9)
40
+ diff-lcs (1.2.4)
41
+ erubis (2.7.0)
42
+ hike (1.2.3)
43
+ i18n (0.6.1)
44
+ journey (1.0.4)
45
+ json (1.8.0)
46
+ mail (2.5.4)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ method_source (0.8.1)
50
+ mime-types (1.23)
51
+ multi_json (1.7.7)
52
+ polyglot (0.3.3)
53
+ pry (0.9.12.2)
54
+ coderay (~> 1.0.5)
55
+ method_source (~> 0.8)
56
+ slop (~> 3.4)
57
+ pry-meta (0.0.5)
58
+ awesome_print
59
+ pry
60
+ pry-nav
61
+ pry-remote
62
+ pry-nav (0.2.3)
63
+ pry (~> 0.9.10)
64
+ pry-remote (0.1.7)
65
+ pry (~> 0.9)
66
+ slop (~> 3.0)
67
+ rack (1.4.5)
68
+ rack-cache (1.2)
69
+ rack (>= 0.4)
70
+ rack-ssl (1.3.3)
71
+ rack
72
+ rack-test (0.6.2)
73
+ rack (>= 1.0)
74
+ rails (3.2.13)
75
+ actionmailer (= 3.2.13)
76
+ actionpack (= 3.2.13)
77
+ activerecord (= 3.2.13)
78
+ activeresource (= 3.2.13)
79
+ activesupport (= 3.2.13)
80
+ bundler (~> 1.0)
81
+ railties (= 3.2.13)
82
+ railties (3.2.13)
83
+ actionpack (= 3.2.13)
84
+ activesupport (= 3.2.13)
85
+ rack-ssl (~> 1.3.2)
86
+ rake (>= 0.8.7)
87
+ rdoc (~> 3.4)
88
+ thor (>= 0.14.6, < 2.0)
89
+ rake (10.0.4)
90
+ rdoc (3.12.2)
91
+ json (~> 1.4)
92
+ rspec-core (2.14.0.rc1)
93
+ rspec-expectations (2.14.0.rc1)
94
+ diff-lcs (>= 1.1.3, < 2.0)
95
+ rspec-mocks (2.14.0.rc1)
96
+ rspec-rails (2.14.0.rc1)
97
+ actionpack (>= 3.0)
98
+ activesupport (>= 3.0)
99
+ railties (>= 3.0)
100
+ rspec-core (= 2.14.0.rc1)
101
+ rspec-expectations (= 2.14.0.rc1)
102
+ rspec-mocks (= 2.14.0.rc1)
103
+ slop (3.4.5)
104
+ sprockets (2.2.2)
105
+ hike (~> 1.2)
106
+ multi_json (~> 1.0)
107
+ rack (~> 1.0)
108
+ tilt (~> 1.1, != 1.3.0)
109
+ sqlite3 (1.3.7)
110
+ thor (0.18.1)
111
+ tilt (1.4.1)
112
+ treetop (1.4.14)
113
+ polyglot
114
+ polyglot (>= 0.3.1)
115
+ tzinfo (0.3.37)
116
+
117
+ PLATFORMS
118
+ ruby
119
+
120
+ DEPENDENCIES
121
+ pry-meta
122
+ rails
123
+ rake
124
+ rspec-rails (~> 2.14.0.rc1)
125
+ sqlite3
126
+ tokens!
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Tokens
2
+
3
+ [![Build Status](https://travis-ci.org/pagseguro/rails.png)](https://travis-ci.org/pagseguro/ruby)
4
+
5
+ ## Usage
6
+
7
+ ### Installation
8
+
9
+ ```bash
10
+ gem install tokens
11
+ ```
12
+
13
+ ### Setting up
14
+
15
+ Add Tokens to your Gemfile and run `rails generate tokens:install`.
16
+ This will create a new migration file. Execute it by running `rake db:migrate`.
17
+
18
+ Finally, add the macro `tokenizable` to your model and be happy!
19
+
20
+ ```ruby
21
+ class User < ActiveRecord::Base
22
+ tokenizable
23
+ end
24
+
25
+ # create a new user; remember that the object need to be saved before creating
26
+ # the token because it depends on the id
27
+ user = User.create(username: "fnando")
28
+
29
+ # create token that never expires
30
+ user.add_token(:activate)
31
+
32
+ # uses custom expires_at
33
+ user.add_token(:activate, expires_at: 10.days.from_now)
34
+
35
+ # uses the default size (12 characters)
36
+ user.add_token(:activate)
37
+
38
+ # uses custom size (up to 122)
39
+ user.add_token(:activate, size: 20)
40
+
41
+ # create token with arbitrary data.
42
+ user.add_token(:activate, data: {action: "do something"})
43
+
44
+ # find token by name
45
+ user.find_token_by_name(:reset_account)
46
+
47
+ # find token by hash
48
+ user.find_token("ea2f14aeac40")
49
+
50
+ # check if a token has expired
51
+ user.tokens.first.expired?
52
+
53
+ # find user by token
54
+ User.find_by_token(:activate, "ea2f14aeac40")
55
+
56
+ # remove all expired tokens except those with NULL values
57
+ Token.clean
58
+
59
+ # generate a token as string, without saving it
60
+ User.generate_token
61
+
62
+ # remove a token by its name
63
+ user.remove_token(:activate)
64
+
65
+ # find user by valid token (same name, same hash, not expired)
66
+ User.find_by_valid_token(:activate, "ea2f14aeac40")
67
+
68
+ # find a token using class scope
69
+ User.find_token(:activate, "ea2f14aeac40")
70
+
71
+ # Token hash
72
+ token.to_s #=> ea2f14aeac40
73
+ ```
74
+
75
+ ## License
76
+
77
+ Copyright (c) 2008-2013 Nando Vieira, released under the MIT license
78
+
79
+ Permission is hereby granted, free of charge, to any person obtaining
80
+ a copy of this software and associated documentation files (the
81
+ "Software"), to deal in the Software without restriction, including
82
+ without limitation the rights to use, copy, modify, merge, publish,
83
+ distribute, sublicense, and/or sell copies of the Software, and to
84
+ permit persons to whom the Software is furnished to do so, subject to
85
+ the following conditions:
86
+
87
+ The above copyright notice and this permission notice shall be
88
+ included in all copies or substantial portions of the Software.
89
+
90
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
91
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
92
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
93
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
94
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
95
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
96
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 3.2"
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: /mnt/hgfs/!%Projects/github/tokens
3
+ specs:
4
+ tokens (1.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.13)
10
+ actionpack (= 3.2.13)
11
+ mail (~> 2.5.3)
12
+ actionpack (3.2.13)
13
+ activemodel (= 3.2.13)
14
+ activesupport (= 3.2.13)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.4)
18
+ rack (~> 1.4.5)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.2.1)
22
+ activemodel (3.2.13)
23
+ activesupport (= 3.2.13)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.13)
26
+ activemodel (= 3.2.13)
27
+ activesupport (= 3.2.13)
28
+ arel (~> 3.0.2)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.13)
31
+ activemodel (= 3.2.13)
32
+ activesupport (= 3.2.13)
33
+ activesupport (3.2.13)
34
+ i18n (= 0.6.1)
35
+ multi_json (~> 1.0)
36
+ arel (3.0.2)
37
+ awesome_print (1.1.0)
38
+ builder (3.0.4)
39
+ coderay (1.0.9)
40
+ diff-lcs (1.2.4)
41
+ erubis (2.7.0)
42
+ hike (1.2.3)
43
+ i18n (0.6.1)
44
+ journey (1.0.4)
45
+ json (1.8.0)
46
+ mail (2.5.4)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ method_source (0.8.1)
50
+ mime-types (1.23)
51
+ multi_json (1.7.7)
52
+ polyglot (0.3.3)
53
+ pry (0.9.12.2)
54
+ coderay (~> 1.0.5)
55
+ method_source (~> 0.8)
56
+ slop (~> 3.4)
57
+ pry-meta (0.0.5)
58
+ awesome_print
59
+ pry
60
+ pry-nav
61
+ pry-remote
62
+ pry-nav (0.2.3)
63
+ pry (~> 0.9.10)
64
+ pry-remote (0.1.7)
65
+ pry (~> 0.9)
66
+ slop (~> 3.0)
67
+ rack (1.4.5)
68
+ rack-cache (1.2)
69
+ rack (>= 0.4)
70
+ rack-ssl (1.3.3)
71
+ rack
72
+ rack-test (0.6.2)
73
+ rack (>= 1.0)
74
+ rails (3.2.13)
75
+ actionmailer (= 3.2.13)
76
+ actionpack (= 3.2.13)
77
+ activerecord (= 3.2.13)
78
+ activeresource (= 3.2.13)
79
+ activesupport (= 3.2.13)
80
+ bundler (~> 1.0)
81
+ railties (= 3.2.13)
82
+ railties (3.2.13)
83
+ actionpack (= 3.2.13)
84
+ activesupport (= 3.2.13)
85
+ rack-ssl (~> 1.3.2)
86
+ rake (>= 0.8.7)
87
+ rdoc (~> 3.4)
88
+ thor (>= 0.14.6, < 2.0)
89
+ rake (10.0.4)
90
+ rdoc (3.12.2)
91
+ json (~> 1.4)
92
+ rspec-core (2.14.0.rc1)
93
+ rspec-expectations (2.14.0.rc1)
94
+ diff-lcs (>= 1.1.3, < 2.0)
95
+ rspec-mocks (2.14.0.rc1)
96
+ rspec-rails (2.14.0.rc1)
97
+ actionpack (>= 3.0)
98
+ activesupport (>= 3.0)
99
+ railties (>= 3.0)
100
+ rspec-core (= 2.14.0.rc1)
101
+ rspec-expectations (= 2.14.0.rc1)
102
+ rspec-mocks (= 2.14.0.rc1)
103
+ slop (3.4.5)
104
+ sprockets (2.2.2)
105
+ hike (~> 1.2)
106
+ multi_json (~> 1.0)
107
+ rack (~> 1.0)
108
+ tilt (~> 1.1, != 1.3.0)
109
+ sqlite3 (1.3.7)
110
+ thor (0.18.1)
111
+ tilt (1.4.1)
112
+ treetop (1.4.14)
113
+ polyglot
114
+ polyglot (>= 0.3.1)
115
+ tzinfo (0.3.37)
116
+
117
+ PLATFORMS
118
+ ruby
119
+
120
+ DEPENDENCIES
121
+ pry-meta
122
+ rails (~> 3.2)
123
+ rake
124
+ rspec-rails (~> 2.14.0.rc1)
125
+ sqlite3
126
+ tokens!
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 4.0.0.rc1"
@@ -0,0 +1,121 @@
1
+ PATH
2
+ remote: /mnt/hgfs/!%Projects/github/tokens
3
+ specs:
4
+ tokens (1.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (4.0.0.rc2)
10
+ actionpack (= 4.0.0.rc2)
11
+ mail (~> 2.5.3)
12
+ actionpack (4.0.0.rc2)
13
+ activesupport (= 4.0.0.rc2)
14
+ builder (~> 3.1.0)
15
+ erubis (~> 2.7.0)
16
+ rack (~> 1.5.2)
17
+ rack-test (~> 0.6.2)
18
+ activemodel (4.0.0.rc2)
19
+ activesupport (= 4.0.0.rc2)
20
+ builder (~> 3.1.0)
21
+ activerecord (4.0.0.rc2)
22
+ activemodel (= 4.0.0.rc2)
23
+ activerecord-deprecated_finders (~> 1.0.2)
24
+ activesupport (= 4.0.0.rc2)
25
+ arel (~> 4.0.0)
26
+ activerecord-deprecated_finders (1.0.3)
27
+ activesupport (4.0.0.rc2)
28
+ i18n (~> 0.6, >= 0.6.4)
29
+ minitest (~> 4.2)
30
+ multi_json (~> 1.3)
31
+ thread_safe (~> 0.1)
32
+ tzinfo (~> 0.3.37)
33
+ arel (4.0.0)
34
+ atomic (1.1.9)
35
+ awesome_print (1.1.0)
36
+ builder (3.1.4)
37
+ coderay (1.0.9)
38
+ diff-lcs (1.2.4)
39
+ erubis (2.7.0)
40
+ hike (1.2.3)
41
+ i18n (0.6.4)
42
+ mail (2.5.4)
43
+ mime-types (~> 1.16)
44
+ treetop (~> 1.4.8)
45
+ method_source (0.8.1)
46
+ mime-types (1.23)
47
+ minitest (4.7.4)
48
+ multi_json (1.7.7)
49
+ polyglot (0.3.3)
50
+ pry (0.9.12.2)
51
+ coderay (~> 1.0.5)
52
+ method_source (~> 0.8)
53
+ slop (~> 3.4)
54
+ pry-meta (0.0.5)
55
+ awesome_print
56
+ pry
57
+ pry-nav
58
+ pry-remote
59
+ pry-nav (0.2.3)
60
+ pry (~> 0.9.10)
61
+ pry-remote (0.1.7)
62
+ pry (~> 0.9)
63
+ slop (~> 3.0)
64
+ rack (1.5.2)
65
+ rack-test (0.6.2)
66
+ rack (>= 1.0)
67
+ rails (4.0.0.rc2)
68
+ actionmailer (= 4.0.0.rc2)
69
+ actionpack (= 4.0.0.rc2)
70
+ activerecord (= 4.0.0.rc2)
71
+ activesupport (= 4.0.0.rc2)
72
+ bundler (>= 1.3.0, < 2.0)
73
+ railties (= 4.0.0.rc2)
74
+ sprockets-rails (~> 2.0.0)
75
+ railties (4.0.0.rc2)
76
+ actionpack (= 4.0.0.rc2)
77
+ activesupport (= 4.0.0.rc2)
78
+ rake (>= 0.8.7)
79
+ thor (>= 0.18.1, < 2.0)
80
+ rake (10.0.4)
81
+ rspec-core (2.14.0.rc1)
82
+ rspec-expectations (2.14.0.rc1)
83
+ diff-lcs (>= 1.1.3, < 2.0)
84
+ rspec-mocks (2.14.0.rc1)
85
+ rspec-rails (2.14.0.rc1)
86
+ actionpack (>= 3.0)
87
+ activesupport (>= 3.0)
88
+ railties (>= 3.0)
89
+ rspec-core (= 2.14.0.rc1)
90
+ rspec-expectations (= 2.14.0.rc1)
91
+ rspec-mocks (= 2.14.0.rc1)
92
+ slop (3.4.5)
93
+ sprockets (2.10.0)
94
+ hike (~> 1.2)
95
+ multi_json (~> 1.0)
96
+ rack (~> 1.0)
97
+ tilt (~> 1.1, != 1.3.0)
98
+ sprockets-rails (2.0.0)
99
+ actionpack (>= 3.0)
100
+ activesupport (>= 3.0)
101
+ sprockets (~> 2.8)
102
+ sqlite3 (1.3.7)
103
+ thor (0.18.1)
104
+ thread_safe (0.1.0)
105
+ atomic
106
+ tilt (1.4.1)
107
+ treetop (1.4.14)
108
+ polyglot
109
+ polyglot (>= 0.3.1)
110
+ tzinfo (0.3.37)
111
+
112
+ PLATFORMS
113
+ ruby
114
+
115
+ DEPENDENCIES
116
+ pry-meta
117
+ rails (~> 4.0.0.rc1)
118
+ rake
119
+ rspec-rails (~> 2.14.0.rc1)
120
+ sqlite3
121
+ tokens!
@@ -4,6 +4,24 @@ module Tokens
4
4
  base.class_eval { extend ClassMethods }
5
5
  end
6
6
 
7
+ module Serializer
8
+ class << self
9
+ # Set the serializer adapter. Defaults to JSON.
10
+ attr_accessor :adapter
11
+ end
12
+
13
+ require "json"
14
+ self.adapter = ::JSON
15
+
16
+ def self.load(data)
17
+ data ? JSON.load(data) : {}
18
+ end
19
+
20
+ def self.dump(data)
21
+ data ? JSON.dump(data) : nil
22
+ end
23
+ end
24
+
7
25
  module ClassMethods
8
26
  # Set up model for using tokens.
9
27
  #
@@ -12,7 +30,7 @@ module Tokens
12
30
  # end
13
31
  #
14
32
  def tokenizable
15
- has_many :tokens, :as => :tokenizable, :dependent => :destroy
33
+ has_many :tokens, as: "tokenizable", dependent: :destroy
16
34
  include InstanceMethods
17
35
  end
18
36
 
@@ -24,8 +42,8 @@ module Tokens
24
42
  validity = Proc.new {|token| Token.where(:token => token).first.nil?}
25
43
 
26
44
  begin
27
- token = SecureRandom.hex(40)[0, size]
28
- token = token.encode("UTF-8") if token.respond_to?(:encoding)
45
+ token = SecureRandom.hex(size)[0, size]
46
+ token = token.encode("UTF-8")
29
47
  end while validity[token] == false
30
48
 
31
49
  token
@@ -34,20 +52,20 @@ module Tokens
34
52
  # Find a token
35
53
  #
36
54
  # User.find_token(:activation, "abcdefg")
37
- # User.find_token(:name => activation, :token => "abcdefg")
38
- # User.find_token(:name => activation, :token => "abcdefg", :tokenizable_id => 1)
55
+ # User.find_token(name: activation, token: "abcdefg")
56
+ # User.find_token(name: activation, token: "abcdefg", tokenizable_id: 1)
39
57
  #
40
58
  def find_token(*args)
41
59
  if args.first.kind_of?(Hash)
42
60
  options = args.first
43
61
  else
44
62
  options = {
45
- :name => args.first,
46
- :token => args.last
63
+ name: args.first,
64
+ token: args.last
47
65
  }
48
66
  end
49
67
 
50
- options.merge!(:name => options[:name].to_s, :tokenizable_type => self.name)
68
+ options.merge!(name: options[:name].to_s, tokenizable_type: self.name)
51
69
  Token.where(options).includes(:tokenizable).first
52
70
  end
53
71
 
@@ -56,8 +74,8 @@ module Tokens
56
74
  # User.find_by_token(:activation, "abcdefg")
57
75
  #
58
76
  def find_by_token(name, hash)
59
- token = find_token(:name => name.to_s, :token => hash)
60
- return nil unless token
77
+ token = find_token(name: name.to_s, token: hash)
78
+ return unless token
61
79
  token.tokenizable
62
80
  end
63
81
 
@@ -66,8 +84,8 @@ module Tokens
66
84
  # User.find_by_valid_token(:activation, "abcdefg")
67
85
  #
68
86
  def find_by_valid_token(name, hash)
69
- token = find_token(:name => name.to_s, :token => hash)
70
- return nil if !token || token.expired?
87
+ token = find_token(name: name.to_s, token: hash)
88
+ return if !token || token.expired?
71
89
  token.tokenizable
72
90
  end
73
91
  end
@@ -78,7 +96,7 @@ module Tokens
78
96
  # @user.valid_token?(:active, "abcdefg")
79
97
  #
80
98
  def valid_token?(name, hash)
81
- self.tokens.where(:name => name.to_s, :token => hash.to_s).first != nil
99
+ self.tokens.where(name: name.to_s, token: hash.to_s).first != nil
82
100
  end
83
101
 
84
102
  # Find a token.
@@ -87,15 +105,15 @@ module Tokens
87
105
  #
88
106
  def find_token(name, token)
89
107
  self.class.find_token(
90
- :tokenizable_id => self.id,
91
- :name => name.to_s,
92
- :token => token
108
+ tokenizable_id: self.id,
109
+ name: name.to_s,
110
+ token: token
93
111
  )
94
112
  end
95
113
 
96
114
  # Find token by its name.
97
115
  def find_token_by_name(name)
98
- self.tokens.find_by_name(name.to_s)
116
+ self.tokens.where(name: name.to_s).first
99
117
  end
100
118
 
101
119
  # Remove token.
@@ -110,23 +128,23 @@ module Tokens
110
128
 
111
129
  # Add a new token.
112
130
  #
113
- # @user.add_token(:api_key, :expires_at => nil)
114
- # @user.add_token(:api_key, :size => 20)
115
- # @user.add_token(:api_key, :data => data.to_yaml)
131
+ # @user.add_token(:api_key, expires_at: nil)
132
+ # @user.add_token(:api_key, size: 20)
133
+ # @user.add_token(:api_key, data: {when: Time.now})
116
134
  #
117
135
  def add_token(name, options={})
118
136
  options.reverse_merge!({
119
- :expires_at => 2.days.from_now,
120
- :size => 12,
121
- :data => nil
137
+ expires_at: 2.days.from_now,
138
+ size: 12,
139
+ data: nil
122
140
  })
123
141
 
124
142
  remove_token(name)
125
143
  attrs = {
126
- :name => name.to_s,
127
- :token => self.class.generate_token(options[:size]),
128
- :expires_at => options[:expires_at],
129
- :data => options[:data]
144
+ name: name.to_s,
145
+ token: self.class.generate_token(options[:size]),
146
+ expires_at: options[:expires_at],
147
+ data: options.fetch(:data) || {}
130
148
  }
131
149
 
132
150
  self.tokens.create!(attrs)
data/lib/tokens/token.rb CHANGED
@@ -1,10 +1,17 @@
1
1
  class Token < ActiveRecord::Base
2
- belongs_to :tokenizable, :polymorphic => true
3
- serialize :data
2
+ belongs_to :tokenizable, polymorphic: true
3
+ serialize :data, Tokens::ActiveRecord::Serializer
4
4
 
5
- attr_accessible :name, :token, :data, :expires_at
6
5
  attr_readonly :tokenizable_id, :tokenizable_type
7
6
 
7
+ def self.clean
8
+ where("expires_at < ? AND expires_at IS NOT NULL", Time.now).delete_all
9
+ end
10
+
11
+ def data
12
+ read_attribute(:data) || {}
13
+ end
14
+
8
15
  def to_s
9
16
  token
10
17
  end
@@ -12,8 +19,4 @@ class Token < ActiveRecord::Base
12
19
  def expired?
13
20
  expires_at && expires_at < Time.now
14
21
  end
15
-
16
- def self.clean
17
- delete_all ["expires_at < ? AND expires_at IS NOT NULL", Time.now]
18
- end
19
22
  end
@@ -1,7 +1,7 @@
1
1
  module Tokens
2
2
  module Version
3
- MAJOR = 1
4
- MINOR = 1
3
+ MAJOR = 2
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
data/spec/schema.rb CHANGED
@@ -8,13 +8,18 @@ ActiveRecord::Schema.define(:version => 0) do
8
8
  end
9
9
 
10
10
  create_table :tokens do |t|
11
- t.integer :tokenizable_id, :null => false
12
- t.string :tokenizable_type, :name, :null => false
13
- t.string :token, :null => false, :limit => 40
14
- t.text :data, :null => true
15
- t.datetime :expires_at, :null => true
16
- t.datetime :created_at
11
+ t.string :name, null: false
12
+ t.belongs_to :tokenizable, null: false, polymorphic: true
13
+ t.string :token, null: false
14
+ t.text :data, null: true
15
+ t.datetime :expires_at, null: true
16
+ t.datetime :created_at, null: false
17
17
  end
18
18
 
19
- add_index :tokens, :token, :unique => true
19
+ add_index :tokens, :tokenizable_type
20
+ add_index :tokens, :tokenizable_id
21
+ add_index :tokens, [:tokenizable_type, :tokenizable_id]
22
+ add_index :tokens, :token
23
+ add_index :tokens, :expires_at
24
+ add_index :tokens, [:tokenizable_id, :tokenizable_type, :name], unique: true
20
25
  end
@@ -1,6 +1,8 @@
1
- ENV["BUNDLE_GEMFILE"] = File.dirname(__FILE__) + "/../../../Gemfile"
2
- require "bundler"
3
- Bundler.setup
1
+ ENV["BUNDLE_GEMFILE"] = ENV.fetch("BUNDLE_GEMFILE") {
2
+ File.dirname(__FILE__) + "/../../../Gemfile"
3
+ }
4
+
5
+ require "bundler/setup"
4
6
  require "rails/all"
5
7
  Bundler.require(:default)
6
8
 
@@ -8,6 +10,7 @@ module Tokens
8
10
  class Application < Rails::Application
9
11
  config.root = File.dirname(__FILE__) + "/.."
10
12
  config.active_support.deprecation = :log
13
+ config.eager_load = true
11
14
  end
12
15
  end
13
16
 
data/spec/tokens_spec.rb CHANGED
@@ -5,158 +5,159 @@ describe Tokens do
5
5
  User.delete_all
6
6
  Post.delete_all
7
7
 
8
- @user = User.create(:name => "Homer")
9
- @another_user = User.create(:name => "Bart")
10
- @post = Post.create(:title => "How to make donuts")
8
+ @user = User.create(name: "Homer")
9
+ @another_user = User.create(name: "Bart")
10
+ @post = Post.create(title: "How to make donuts")
11
11
  @expire = 3.days.from_now
12
12
  end
13
13
 
14
- it "should have tokens association" do
14
+ it "has tokens association" do
15
15
  expect { @user.tokens }.to_not raise_error
16
16
  end
17
17
 
18
- it "should remove all expired tokens" do
18
+ it "removes all expired tokens" do
19
19
  expect {
20
20
  %w(uid activation_code reset_password_code).each do |name|
21
21
  @user.add_token(name, :expires_at => 3.days.ago)
22
22
  end
23
23
  }.to change(Token, :count).by(3)
24
24
 
25
- Token.clean.should == 3
25
+ expect(Token.clean).to eql(3)
26
26
  end
27
27
 
28
- it "should generate token without saving it" do
28
+ it "generates token without saving it" do
29
29
  expect {
30
30
  User.generate_token(32)
31
31
  }.to_not change(Token, :count)
32
32
  end
33
33
 
34
- it "should generate token with custom size" do
35
- User.generate_token(8).size.should == 8
34
+ it "generates token with custom size" do
35
+ expect(User.generate_token(8).size).to eql(8)
36
36
  end
37
37
 
38
- it "should alias token method" do
38
+ it "sets alias for token method" do
39
39
  token = @user.add_token(:uid)
40
- token.to_s.should == token.token
40
+ expect(token.to_s).to eql(token.token)
41
41
  end
42
42
 
43
- it "should find user by token" do
43
+ it "finds user by token" do
44
44
  token = @user.add_token(:uid)
45
- User.find_by_token(:uid, token.to_s).should == @user
45
+ expect(User.find_by_token(:uid, token.to_s)).to eql(@user)
46
46
  end
47
47
 
48
- it "should return user by its valid token without expiration time" do
48
+ it "returns user by its valid token without expiration time" do
49
49
  token = @user.add_token(:uid)
50
- User.find_by_valid_token(:uid, token.to_s).should == @user
50
+ expect(User.find_by_valid_token(:uid, token.to_s)).to eql(@user)
51
51
  end
52
52
 
53
- it "should return user by its valid token with expiration time" do
53
+ it "returns user by its valid token with expiration time" do
54
54
  token = @user.add_token(:uid, :expires_at => @expire)
55
- User.find_by_valid_token(:uid, token.to_s).should == @user
55
+ expect(User.find_by_valid_token(:uid, token.to_s)).to eql(@user)
56
56
  end
57
57
 
58
- it "should find token using class method with one argument (hash only)" do
58
+ it "finds token using class method with one argument (hash only)" do
59
59
  token = @user.add_token(:uid)
60
- User.find_token(:name => :uid, :token => token.to_s).should == token
60
+ expect(User.find_token(:name => :uid, :token => token.to_s)).to eql(token)
61
61
  end
62
62
 
63
- it "should not conflict with other models" do
63
+ it "doesn't conflict with other models" do
64
64
  user_token = @user.add_token(:uid)
65
65
  post_token = @post.add_token(:uid)
66
66
 
67
- User.find_token(post_token.to_s).should == nil
68
- User.find_token(:name => :uid)
67
+ expect(User.find_token(post_token.to_s)).to be_nil
68
+ User.find_token(name: :uid)
69
69
  end
70
70
 
71
71
  it "to_s should return hash" do
72
72
  token = @user.add_token(:uid)
73
- token.to_s.should == token.to_s
73
+ expect(token.to_s).to eql(token.to_s)
74
74
  end
75
75
 
76
76
  describe Token do
77
- it "should be created" do
77
+ it "is created" do
78
78
  expect { @user.add_token(:uid) }.to change(Token, :count)
79
79
  end
80
80
 
81
- it "should be created for different users" do
82
- @user.add_token(:uid).should be_valid
83
- @another_user.add_token(:uid).should be_valid
81
+ it "is created for different users" do
82
+ expect(@user.add_token(:uid)).to be_valid
83
+ expect(@another_user.add_token(:uid)).to be_valid
84
84
  end
85
85
 
86
- it "should be created with expiration date" do
87
- @user.add_token(:uid, :expires_at => @expire).expires_at.should == @expire
86
+ it "is created with expiration date" do
87
+ expect(@user.add_token(:uid, expires_at: @expire).expires_at).to eql(@expire)
88
88
  end
89
89
 
90
- it "should be created with additional data" do
91
- @user.add_token(:uid, :data => "some value").data.should == "some value"
90
+ it "serializes data" do
91
+ token = @user.add_token(:uid, data: {name: "John Doe"})
92
+ token.reload
93
+
94
+ expect(token.data).to include("name" => "John Doe")
92
95
  end
93
96
 
94
- it "should serialize data" do
95
- token = @user.add_token(:uid, :data => {:name => "John Doe"})
96
- token.reload
97
- token.data.should == {:name => "John Doe"}
97
+ it "returns empty hash as serialized data" do
98
+ expect(Token.new.data).to eql({})
98
99
  end
99
100
 
100
- it "should be created with custom size" do
101
- @user.add_token(:uid, :size => 6).to_s.size.should == 6
101
+ it "is created with custom size" do
102
+ expect(@user.add_token(:uid, :size => 6).to_s.size).to eql(6)
102
103
  end
103
104
 
104
- it "should find token by its name" do
105
+ it "finds token by its name" do
105
106
  token = @user.add_token(:uid)
106
- @user.find_token_by_name(:uid).should == token
107
+ expect(@user.find_token_by_name(:uid)).to eql(token)
107
108
  end
108
109
 
109
- it "should be nil when no token is found" do
110
- @user.find_token(:uid, "abcdef").should be_nil
111
- @user.find_token_by_name(:uid).should be_nil
110
+ it "returns nil nil when no token is found" do
111
+ expect(@user.find_token(:uid, "abcdef")).to be_nil
112
+ expect(@user.find_token_by_name(:uid)).to be_nil
112
113
  end
113
114
 
114
- it "should be a valid token" do
115
+ it "is a valid token" do
115
116
  token = @user.add_token(:uid)
116
- @user.valid_token?(:uid, token.to_s).should be_true
117
+ expect(@user.valid_token?(:uid, token.to_s)).to be_true
117
118
  end
118
119
 
119
- it "should not be a valid token" do
120
- @user.valid_token?(:uid, "invalid").should be_false
120
+ it "isn't a valid token" do
121
+ expect(@user.valid_token?(:uid, "invalid")).to be_false
121
122
  end
122
123
 
123
- it "should find token by its name and hash" do
124
+ it "finds token by its name and hash" do
124
125
  token = @user.add_token(:uid)
125
- @user.find_token(:uid, token.to_s).should == token
126
+ expect(@user.find_token(:uid, token.to_s)).to eql(token)
126
127
  end
127
128
 
128
- it "should not be expired when have no expiration date" do
129
- @user.add_token(:uid).should_not be_expired
129
+ it "isn't expired when have no expiration date" do
130
+ expect(@user.add_token(:uid)).not_to be_expired
130
131
  end
131
132
 
132
- it "should not be expired when have a future expiration date" do
133
- @user.add_token(:uid, :expires_at => 3.days.from_now).should_not be_expired
133
+ it "isn't expired when have a future expiration date" do
134
+ expect(@user.add_token(:uid, expires_at: 3.days.from_now)).not_to be_expired
134
135
  end
135
136
 
136
- it "should be expired" do
137
- @user.add_token(:uid, :expires_at => 3.days.ago).should be_expired
137
+ it "is expired" do
138
+ expect(@user.add_token(:uid, :expires_at => 3.days.ago)).to be_expired
138
139
  end
139
140
 
140
- it "should remove token" do
141
+ it "removes token" do
141
142
  @user.add_token(:uid)
142
- @user.remove_token(:uid).should be_true
143
+ expect(@user.remove_token(:uid)).to be_true
143
144
  end
144
145
 
145
- it "should not remove other users tokens" do
146
+ it "doesn't remove other users tokens" do
146
147
  @user.add_token(:uid)
147
148
  @another_user.add_token(:uid)
148
149
 
149
150
  @user.remove_token(:uid)
150
151
 
151
- @user.find_token_by_name(:uid).should be_nil
152
- @another_user.find_token_by_name(:uid).should be_an_instance_of(Token)
152
+ expect(@user.find_token_by_name(:uid)).to be_nil
153
+ expect(@another_user.find_token_by_name(:uid)).to be_an_instance_of(Token)
153
154
  end
154
155
 
155
- it "should not be duplicated" do
156
+ it "isn't duplicated" do
156
157
  @user.add_token(:uid)
157
158
  @user.add_token(:uid)
158
159
 
159
- @user.tokens.find_all_by_name("uid").size.should == 1
160
+ expect(@user.tokens.where(name: "uid").count).to eql(1)
160
161
  end
161
162
  end
162
163
  end
data/templates/tokens.rb CHANGED
@@ -1,22 +1,17 @@
1
1
  class CreateTokens < ActiveRecord::Migration
2
- def self.up
2
+ def change
3
3
  create_table :tokens do |t|
4
- t.integer :tokenizable_id, :null => false
5
- t.string :tokenizable_type, :name, :null => false
6
- t.string :token, :limit => 40, :null => false
7
- t.text :data, :null => true
8
- t.datetime :expires_at, :null => true
9
- t.datetime :created_at
4
+ t.string :name, null: false
5
+ t.belongs_to :tokenizable, null: false, polymorphic: true
6
+ t.string :token, null: false
7
+ t.text :data, null: true
8
+ t.datetime :expires_at, null: true
9
+ t.datetime :created_at, null: false
10
10
  end
11
11
 
12
- add_index :tokens, :tokenizable_type
13
- add_index :tokens, :tokenizable_id
14
12
  add_index :tokens, [:tokenizable_type, :tokenizable_id]
15
13
  add_index :tokens, :token
16
14
  add_index :tokens, :expires_at
17
- end
18
-
19
- def self.down
20
- drop_table :tokens
15
+ add_index :tokens, [:tokenizable_id, :tokenizable_type, :name], unique: true
21
16
  end
22
17
  end
data/tokens.gemspec CHANGED
@@ -17,9 +17,9 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_development_dependency "rails" , "~> 3.1"
21
- s.add_development_dependency "rake" , "~> 0.9"
22
- s.add_development_dependency "rspec-rails" , "~> 2.6"
23
- s.add_development_dependency "sqlite3" , "~> 1.3.4"
24
- s.add_development_dependency "pry"
20
+ s.add_development_dependency "rails"
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "rspec-rails", "~> 2.14.0.rc1"
23
+ s.add_development_dependency "sqlite3"
24
+ s.add_development_dependency "pry-meta"
25
25
  end
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokens
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nando Vieira
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-03-11 00:00:00.000000000 Z
11
+ date: 2013-06-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
- requirement: &70129127795300 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '3.1'
19
+ version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *70129127795300
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rake
27
- requirement: &70129127794500 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - '>='
31
32
  - !ruby/object:Gem::Version
32
- version: '0.9'
33
+ version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *70129127794500
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rspec-rails
38
- requirement: &70129127793560 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
- version: '2.6'
47
+ version: 2.14.0.rc1
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *70129127793560
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.0.rc1
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: sqlite3
49
- requirement: &70129127789940 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ~>
59
+ - - '>='
53
60
  - !ruby/object:Gem::Version
54
- version: 1.3.4
61
+ version: '0'
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *70129127789940
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  - !ruby/object:Gem::Dependency
59
- name: pry
60
- requirement: &70129127806420 !ruby/object:Gem::Requirement
61
- none: false
70
+ name: pry-meta
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
- - - ! '>='
73
+ - - '>='
64
74
  - !ruby/object:Gem::Version
65
75
  version: '0'
66
76
  type: :development
67
77
  prerelease: false
68
- version_requirements: *70129127806420
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Generate named tokens on your ActiveRecord models.
70
84
  email:
71
85
  - fnando.vieira@gmail.com
@@ -75,9 +89,15 @@ extra_rdoc_files: []
75
89
  files:
76
90
  - .gitignore
77
91
  - .rspec
92
+ - .travis.yml
78
93
  - Gemfile
79
- - README.rdoc
94
+ - Gemfile.lock
95
+ - README.md
80
96
  - Rakefile
97
+ - gemfiles/rails3.gemfile
98
+ - gemfiles/rails3.gemfile.lock
99
+ - gemfiles/rails4.gemfile
100
+ - gemfiles/rails4.gemfile.lock
81
101
  - lib/tokens.rb
82
102
  - lib/tokens/active_record.rb
83
103
  - lib/tokens/generator.rb
@@ -94,38 +114,25 @@ files:
94
114
  - tokens.gemspec
95
115
  homepage: http://rubygems.org/gems/tokens
96
116
  licenses: []
117
+ metadata: {}
97
118
  post_install_message:
98
119
  rdoc_options: []
99
120
  require_paths:
100
121
  - lib
101
122
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
123
  requirements:
104
- - - ! '>='
124
+ - - '>='
105
125
  - !ruby/object:Gem::Version
106
126
  version: '0'
107
- segments:
108
- - 0
109
- hash: -3946632129336897439
110
127
  required_rubygems_version: !ruby/object:Gem::Requirement
111
- none: false
112
128
  requirements:
113
- - - ! '>='
129
+ - - '>='
114
130
  - !ruby/object:Gem::Version
115
131
  version: '0'
116
- segments:
117
- - 0
118
- hash: -3946632129336897439
119
132
  requirements: []
120
133
  rubyforge_project:
121
- rubygems_version: 1.8.11
134
+ rubygems_version: 2.0.3
122
135
  signing_key:
123
- specification_version: 3
136
+ specification_version: 4
124
137
  summary: Generate named tokens on your ActiveRecord models.
125
- test_files:
126
- - spec/schema.rb
127
- - spec/spec_helper.rb
128
- - spec/support/config/boot.rb
129
- - spec/support/config/database.yml
130
- - spec/support/models.rb
131
- - spec/tokens_spec.rb
138
+ test_files: []
data/README.rdoc DELETED
@@ -1,90 +0,0 @@
1
- = Tokens
2
-
3
- == Usage
4
-
5
- === Installation
6
-
7
- gem install tokens
8
-
9
- === Setting up
10
-
11
- Add Tokens to your Gemfile and run <tt>rails generate tokens:install</tt>.
12
- This will create a new migration file. Execute it by running <tt>rake db:migrate</tt>.
13
-
14
- Finally, add the macro <tt>tokenizable</tt> to your model and be happy!
15
-
16
- class User < ActiveRecord::Base
17
- tokenizable
18
- end
19
-
20
- # create a new user; remember that the object need to be saved before creating
21
- # the token because it depends on the id
22
- user = User.create(:login => "fnando")
23
-
24
- # create token that never expires
25
- user.add_token(:activate)
26
-
27
- # uses custom expires_at
28
- user.add_token(:activate, :expires_at => 10.days.from_now)
29
-
30
- # uses the default size (12 characters)
31
- user.add_token(:activate)
32
-
33
- # uses custom size (up to 32)
34
- user.add_token(:activate, :size => 20)
35
-
36
- # create token with arbitrary data.
37
- user.add_token(:activate, :data => {:action => 'do something'})
38
-
39
- # find token by name
40
- user.find_token_by_name(:reset_account)
41
-
42
- # find token by hash
43
- user.find_token("ea2f14aeac40")
44
-
45
- # check if a token has expired
46
- user.tokens.first.expired?
47
-
48
- # find user by token
49
- User.find_by_token(:activate, "ea2f14aeac40")
50
-
51
- # remove all expired tokens except those with NULL values
52
- Token.clean
53
-
54
- # generate a token as string, without saving it
55
- User.generate_token
56
-
57
- # remove a token by its name
58
- user.remove_token(:activate)
59
-
60
- # find user by valid token (same name, same hash, not expired)
61
- User.find_by_valid_token(:activate, 'ea2f14aeac40')
62
-
63
- # find a token using class scope
64
- User.find_token(:activate, 'ea2f14aeac40')
65
-
66
- # Token hash
67
- token.to_s #=> ea2f14aeac40
68
-
69
- == License
70
-
71
- Copyright (c) 2008 Nando Vieira, released under the MIT license
72
-
73
- Permission is hereby granted, free of charge, to any person obtaining
74
- a copy of this software and associated documentation files (the
75
- "Software"), to deal in the Software without restriction, including
76
- without limitation the rights to use, copy, modify, merge, publish,
77
- distribute, sublicense, and/or sell copies of the Software, and to
78
- permit persons to whom the Software is furnished to do so, subject to
79
- the following conditions:
80
-
81
- The above copyright notice and this permission notice shall be
82
- included in all copies or substantial portions of the Software.
83
-
84
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
86
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
87
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
88
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
89
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
90
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.