masked-identifier 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright 2011 YOURNAME
1
+ Copyright 2011 Matt Hodan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -2,6 +2,20 @@
2
2
 
3
3
  Masked Identifier makes it easy to add a non-incrementing identifier to any ActiveRecord object.
4
4
 
5
+ Instead of
6
+
7
+ ```ruby
8
+ http://localhost:3000/users/1
9
+ user = User.find(1)
10
+ ```
11
+
12
+ with Masked Identifier you can
13
+
14
+ ```ruby
15
+ http://localhost:3000/users/2xfYgm1pQ8
16
+ user = User.find_by_masked_identifier('2xfYgm1pQ8')
17
+ ```
18
+
5
19
  ## Installation
6
20
 
7
21
  Add ```gem 'masked-identifier'``` to your Rails project Gemfile.
@@ -11,7 +25,7 @@
11
25
  ## Usage
12
26
 
13
27
  Add a column named 'masked_identifier' to the table of the ActiveRecord object that you want to
14
- be able to refer to using a masked identifier. Also, don't forget to add an index for this new
28
+ be able to find using a masked identifier. Also, don't forget to add an index for this new
15
29
  column
16
30
 
17
31
  ```ruby
@@ -40,7 +54,7 @@ user.masked_identifier
40
54
  Lookup users based on the object's ```masked_identifier``` property
41
55
 
42
56
  ```ruby
43
- user = User.find_by_masked_identifier("2xfYgm1pQ8")
57
+ user = User.find_by_masked_identifier('2xfYgm1pQ8')
44
58
  user.name
45
59
  => "Matt"
46
60
  ```
@@ -59,7 +73,7 @@ end
59
73
  ## Options
60
74
 
61
75
  Masked Identifier lets you edit a number of settings by including an options hash following
62
- ```has_masked_identifier```:
76
+ ```has_masked_identifier```
63
77
 
64
78
  ```ruby
65
79
  class User < ActiveRecord::Base
@@ -77,7 +91,7 @@ error._
77
91
  * ```property``` - override the default ```masked_identifier``` property with a custom named
78
92
  property. _Don't forget you'll need to use this custom name in your database migration too_
79
93
 
80
- * ```charset``` - override the defailt character set used when generating masked identifiers
94
+ * ```charset``` - override the default character set used when generating masked identifiers
81
95
  (default character set includes a-z, A-Z, and 0-9). _Note: As the size of the character set is
82
96
  increased, the number of possible unique masked identifiers also increases_
83
97
 
@@ -87,13 +101,13 @@ error._
87
101
 
88
102
  ## Exceptions
89
103
 
90
- Make sure you handle the following possible exceptions in your applicaiton:
104
+ Make sure you handle the following possible exceptions in your application:
91
105
 
92
106
  * ```[YourActiveRecordObject]::InvalidProperty``` - if object does not have a
93
107
  ```masked_identifier``` property (or the custom property passed to the ```property``` option
94
108
  does not exist)
95
109
 
96
- * ```CodeGenerator::TooManyFailedAttempts``` - if unable to find a unique code to user as a masked
110
+ * ```CodeGenerator::TooManyFailedAttempts``` - if unable to find a unique code to use as a masked
97
111
  identifier
98
112
 
99
113
  * ```CodeGenerator::InvalidAttemptsValue``` - if the value provided to the ```attempts``` option
@@ -18,34 +18,36 @@
18
18
  # CodeGenerator::InvalidCodeLength if value provided is not an Integer or < 1
19
19
  # CodeGenerator::InvalidCharset if value provided is not an Array with size >= 1
20
20
  #
21
- class CodeGenerator
22
- def self.unique_code(klass, property, options = {})
23
- attempts = options[:attempts] || 20
24
- raise InvalidAttemptsValue, 'Attempts value must be an integer >= 1' if !attempts.is_a?(Integer) || attempts <= 0
21
+ module MaskedIdentifier
22
+ class CodeGenerator
23
+ def self.unique_code(klass, property, options = {})
24
+ attempts = options[:attempts] || 20
25
+ raise InvalidAttemptsValue, 'Attempts value must be an integer >= 1' if !attempts.is_a?(Integer) || attempts <= 0
25
26
 
26
- begin
27
- i ||= 0; i += 1
28
- raise TooManyFailedAttempts, 'Failed to find a unique code' if i > attempts
29
- code = self.random_code length: options[:length], charset: options[:charset]
30
- end until self.code_is_unique? klass, property, code
31
- return code
32
- end
27
+ begin
28
+ i ||= 0; i += 1
29
+ raise TooManyFailedAttempts, 'Failed to find a unique code' if i > attempts
30
+ code = self.random_code length: options[:length], charset: options[:charset]
31
+ end until self.code_is_unique? klass, property, code
32
+ return code
33
+ end
33
34
 
34
- private
35
- def self.code_is_unique?(klass, property, code)
36
- true if klass.class.send('find_by_' + property, code).nil?
37
- end
35
+ private
36
+ def self.code_is_unique?(klass, property, code)
37
+ true if !klass.class.exists? property => code
38
+ end
38
39
 
39
- def self.random_code(options = {})
40
- length = options[:length] || 10
41
- raise InvalidCodeLength, 'Code length must be an integer >= 1' if !length.is_a?(Integer) || length <= 0
42
- charset = options[:charset] || %w{ 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H J K L M N O P Q R T U V W X Y Z }
43
- raise InvalidCharset, 'Charset must be an array with 1 or more values' if !charset.is_a?(Array) || charset.length < 1
44
- (0...length).map { charset.to_a[rand(charset.size)] }.join
45
- end
40
+ def self.random_code(options = {})
41
+ length = options[:length] || 10
42
+ raise InvalidCodeLength, 'Code length must be an integer >= 1' if !length.is_a?(Integer) || length <= 0
43
+ charset = options[:charset] || %w{ 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H J K L M N O P Q R T U V W X Y Z }
44
+ raise InvalidCharset, 'Charset must be an array with 1 or more values' if !charset.is_a?(Array) || charset.length < 1
45
+ (0...length).map { charset.to_a[rand(charset.size)] }.join
46
+ end
46
47
 
47
- class TooManyFailedAttempts < StandardError; end
48
- class InvalidAttemptsValue < ArgumentError; end
49
- class InvalidCodeLength < ArgumentError; end
50
- class InvalidCharset < ArgumentError; end
48
+ class TooManyFailedAttempts < StandardError; end
49
+ class InvalidAttemptsValue < ArgumentError; end
50
+ class InvalidCodeLength < ArgumentError; end
51
+ class InvalidCharset < ArgumentError; end
52
+ end
51
53
  end
File without changes
@@ -64,3 +64,80 @@ Migrating to CreateUsers (20110731204706)
64
64
   (3.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
65
65
   (0.1ms) SELECT version FROM "schema_migrations"
66
66
   (2.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20110731204706')
67
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
68
+  (0.2ms) select sqlite_version(*)
69
+  (3.6ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "masked_identifier" varchar(255), "mid" varchar(255), "created_at" datetime, "updated_at" datetime) 
70
+  (0.1ms) PRAGMA index_list("users")
71
+  (2.5ms) CREATE INDEX "index_users_on_masked_identifier" ON "users" ("masked_identifier")
72
+  (2.6ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
73
+  (0.1ms) PRAGMA index_list("schema_migrations")
74
+  (2.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
75
+  (0.1ms) SELECT version FROM "schema_migrations"
76
+  (2.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20110731204706')
77
+  (0.3ms) select sqlite_version(*)
78
+  (42.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "masked_identifier" varchar(255), "mid" varchar(255), "created_at" datetime, "updated_at" datetime)
79
+  (0.1ms) PRAGMA index_list("users")
80
+  (2.2ms) CREATE INDEX "index_users_on_masked_identifier" ON "users" ("masked_identifier")
81
+  (2.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
82
+  (0.1ms) PRAGMA index_list("schema_migrations")
83
+  (2.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
84
+  (0.1ms) SELECT version FROM "schema_migrations"
85
+  (2.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20110731204706')
86
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
87
+  (0.4ms) select sqlite_version(*)
88
+  (300.8ms) DROP TABLE "users"
89
+  (2.7ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "masked_identifier" varchar(255), "mid" varchar(255), "created_at" datetime, "updated_at" datetime) 
90
+  (0.1ms) PRAGMA index_list("users")
91
+  (2.4ms) CREATE INDEX "index_users_on_masked_identifier" ON "users" ("masked_identifier")
92
+  (0.1ms) SELECT version FROM "schema_migrations"
93
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
94
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
95
+  (0.2ms) select sqlite_version(*)
96
+  (47.7ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "masked_identifier" varchar(255), "mid" varchar(255), "created_at" datetime, "updated_at" datetime) 
97
+  (0.1ms) PRAGMA index_list("users")
98
+  (2.1ms) CREATE INDEX "index_users_on_masked_identifier" ON "users" ("masked_identifier")
99
+  (2.7ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
100
+  (0.1ms) PRAGMA index_list("schema_migrations")
101
+  (3.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
102
+  (0.1ms) SELECT version FROM "schema_migrations"
103
+  (2.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20110731204706')
104
+  (0.3ms) select sqlite_version(*)
105
+  (39.8ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "masked_identifier" varchar(255), "mid" varchar(255), "created_at" datetime, "updated_at" datetime)
106
+  (0.1ms) PRAGMA index_list("users")
107
+  (2.2ms) CREATE INDEX "index_users_on_masked_identifier" ON "users" ("masked_identifier")
108
+  (2.7ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
109
+  (0.1ms) PRAGMA index_list("schema_migrations")
110
+  (2.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
111
+  (0.1ms) SELECT version FROM "schema_migrations"
112
+  (2.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20110731204706')
113
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
114
+  (0.3ms) select sqlite_version(*)
115
+  (51.7ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "masked_identifier" varchar(255), "mid" varchar(255), "created_at" datetime, "updated_at" datetime)
116
+  (0.1ms) PRAGMA index_list("users")
117
+  (2.5ms) CREATE INDEX "index_users_on_masked_identifier" ON "users" ("masked_identifier")
118
+  (2.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
119
+  (0.1ms) PRAGMA index_list("schema_migrations")
120
+  (3.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
121
+  (0.1ms) SELECT version FROM "schema_migrations"
122
+  (2.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20110731204706')
123
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
124
+  (0.3ms) select sqlite_version(*)
125
+  (32.6ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "masked_identifier" varchar(255), "mid" varchar(255), "created_at" datetime, "updated_at" datetime)
126
+  (0.1ms) PRAGMA index_list("users")
127
+  (2.1ms) CREATE INDEX "index_users_on_masked_identifier" ON "users" ("masked_identifier")
128
+  (2.5ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
129
+  (0.1ms) PRAGMA index_list("schema_migrations")
130
+  (2.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
131
+  (0.4ms) SELECT version FROM "schema_migrations"
132
+  (2.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20110731204706')
133
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
134
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
135
+  (0.2ms) select sqlite_version(*)
136
+  (319.2ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "masked_identifier" varchar(255), "mid" varchar(255), "created_at" datetime, "updated_at" datetime) 
137
+  (0.1ms) PRAGMA index_list("users")
138
+  (2.6ms) CREATE INDEX "index_users_on_masked_identifier" ON "users" ("masked_identifier")
139
+  (3.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
140
+  (0.1ms) PRAGMA index_list("schema_migrations")
141
+  (3.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
142
+  (0.1ms) SELECT version FROM "schema_migrations"
143
+  (3.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20110731204706')
@@ -227,3 +227,179 @@
227
227
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'caddadbabd' LIMIT 1
228
228
  SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 00:04:56 UTC +00:00], ["masked_identifier", "caddadbabd"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 00:04:56 UTC +00:00]]
229
229
   (0.1ms) RELEASE SAVEPOINT active_record_1
230
+  (0.0ms) SAVEPOINT active_record_1
231
+ User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'adOBAdq7cs' LIMIT 1
232
+ SQL (44.4ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00], ["masked_identifier", "adOBAdq7cs"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00]]
233
+  (0.1ms) RELEASE SAVEPOINT active_record_1
234
+  (0.0ms) SAVEPOINT active_record_1
235
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'QNwK7K' LIMIT 1
236
+ SQL (0.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00], ["masked_identifier", "QNwK7K"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00]]
237
+  (0.1ms) RELEASE SAVEPOINT active_record_1
238
+  (0.0ms) SAVEPOINT active_record_1
239
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
240
+  (0.0ms) SAVEPOINT active_record_1
241
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
242
+ SQL (0.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00], ["masked_identifier", "a"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00]]
243
+  (0.3ms) RELEASE SAVEPOINT active_record_1
244
+  (0.0ms) SAVEPOINT active_record_1
245
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."mid" = '2yg1vh10Hn' LIMIT 1
246
+ SQL (0.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00], ["masked_identifier", nil], ["mid", "2yg1vh10Hn"], ["updated_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00]]
247
+  (0.1ms) RELEASE SAVEPOINT active_record_1
248
+  (0.0ms) SAVEPOINT active_record_1
249
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'bacbcaddba' LIMIT 1
250
+ SQL (0.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00], ["masked_identifier", "bacbcaddba"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:00:49 UTC +00:00]]
251
+  (0.1ms) RELEASE SAVEPOINT active_record_1
252
+  (0.0ms) SAVEPOINT active_record_1
253
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'DBWHFaj1Zr' LIMIT 1
254
+ SQL (13.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00], ["masked_identifier", "DBWHFaj1Zr"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00]]
255
+  (0.1ms) RELEASE SAVEPOINT active_record_1
256
+  (0.0ms) SAVEPOINT active_record_1
257
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'rC6Fdp' LIMIT 1
258
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00], ["masked_identifier", "rC6Fdp"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00]]
259
+  (0.1ms) RELEASE SAVEPOINT active_record_1
260
+  (0.1ms) SAVEPOINT active_record_1
261
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
262
+  (0.1ms) SAVEPOINT active_record_1
263
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
264
+ SQL (0.8ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00], ["masked_identifier", "a"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00]]
265
+  (0.1ms) RELEASE SAVEPOINT active_record_1
266
+  (0.1ms) SAVEPOINT active_record_1
267
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."mid" = 'dbzeZBVdWK' LIMIT 1
268
+ SQL (0.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00], ["masked_identifier", nil], ["mid", "dbzeZBVdWK"], ["updated_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00]]
269
+  (0.1ms) RELEASE SAVEPOINT active_record_1
270
+  (0.0ms) SAVEPOINT active_record_1
271
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'ddbbabcbdd' LIMIT 1
272
+ SQL (0.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00], ["masked_identifier", "ddbbabcbdd"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:01:26 UTC +00:00]]
273
+  (0.1ms) RELEASE SAVEPOINT active_record_1
274
+  (0.0ms) SAVEPOINT active_record_1
275
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'FYzmv6nlvq' LIMIT 1
276
+ SQL (14.2ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00], ["masked_identifier", "FYzmv6nlvq"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00]]
277
+  (0.1ms) RELEASE SAVEPOINT active_record_1
278
+  (0.0ms) SAVEPOINT active_record_1
279
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'zUumxc' LIMIT 1
280
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00], ["masked_identifier", "zUumxc"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00]]
281
+  (0.1ms) RELEASE SAVEPOINT active_record_1
282
+  (0.1ms) SAVEPOINT active_record_1
283
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
284
+  (0.1ms) SAVEPOINT active_record_1
285
+ User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
286
+ SQL (0.8ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00], ["masked_identifier", "a"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00]]
287
+  (0.1ms) RELEASE SAVEPOINT active_record_1
288
+  (0.0ms) SAVEPOINT active_record_1
289
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
290
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
291
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
292
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
293
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
294
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
295
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
296
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
297
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
298
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
299
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
300
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
301
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
302
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
303
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
304
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
305
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
306
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
307
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
308
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
309
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
310
+  (0.0ms) SAVEPOINT active_record_1
311
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."mid" = 'nKABMM0Ntd' LIMIT 1
312
+ SQL (0.8ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00], ["masked_identifier", nil], ["mid", "nKABMM0Ntd"], ["updated_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00]]
313
+  (0.1ms) RELEASE SAVEPOINT active_record_1
314
+  (0.0ms) SAVEPOINT active_record_1
315
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."masked_identifier" = 'ccbaddccdd' LIMIT 1
316
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00], ["masked_identifier", "ccbaddccdd"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 05:02:40 UTC +00:00]]
317
+  (0.1ms) RELEASE SAVEPOINT active_record_1
318
+  (0.0ms) SAVEPOINT active_record_1
319
+  (0.6ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'lgf6z4cJUE' LIMIT 1
320
+ SQL (14.2ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00], ["masked_identifier", "lgf6z4cJUE"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00]]
321
+  (0.1ms) RELEASE SAVEPOINT active_record_1
322
+  (0.0ms) SAVEPOINT active_record_1
323
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'uEieFy' LIMIT 1
324
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00], ["masked_identifier", "uEieFy"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00]]
325
+  (0.1ms) RELEASE SAVEPOINT active_record_1
326
+  (0.0ms) SAVEPOINT active_record_1
327
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
328
+  (0.0ms) SAVEPOINT active_record_1
329
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
330
+ SQL (3.0ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00], ["masked_identifier", "a"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00]]
331
+  (0.1ms) RELEASE SAVEPOINT active_record_1
332
+  (0.0ms) SAVEPOINT active_record_1
333
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
334
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
335
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
336
+  (0.2ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
337
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
338
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
339
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
340
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
341
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
342
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
343
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
344
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
345
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
346
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
347
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
348
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
349
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
350
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
351
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
352
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
353
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
354
+  (0.0ms) SAVEPOINT active_record_1
355
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."mid" = 'emCkYiHolo' LIMIT 1
356
+ SQL (0.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00], ["masked_identifier", nil], ["mid", "emCkYiHolo"], ["updated_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00]]
357
+  (0.1ms) RELEASE SAVEPOINT active_record_1
358
+  (0.0ms) SAVEPOINT active_record_1
359
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'cabcdacbdd' LIMIT 1
360
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00], ["masked_identifier", "cabcdacbdd"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 06:46:21 UTC +00:00]]
361
+  (0.1ms) RELEASE SAVEPOINT active_record_1
362
+  (0.0ms) SAVEPOINT active_record_1
363
+  (0.2ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'GoO6aFQRqf' LIMIT 1
364
+ SQL (13.8ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00], ["masked_identifier", "GoO6aFQRqf"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00]]
365
+  (0.1ms) RELEASE SAVEPOINT active_record_1
366
+  (0.0ms) SAVEPOINT active_record_1
367
+  (0.2ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'Qi2VDW' LIMIT 1
368
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00], ["masked_identifier", "Qi2VDW"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00]]
369
+  (0.1ms) RELEASE SAVEPOINT active_record_1
370
+  (0.0ms) SAVEPOINT active_record_1
371
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
372
+  (0.0ms) SAVEPOINT active_record_1
373
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
374
+ SQL (0.7ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00], ["masked_identifier", "a"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00]]
375
+  (0.1ms) RELEASE SAVEPOINT active_record_1
376
+  (0.0ms) SAVEPOINT active_record_1
377
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
378
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
379
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
380
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
381
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
382
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
383
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
384
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
385
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
386
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
387
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
388
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
389
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
390
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
391
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
392
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
393
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
394
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
395
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
396
+  (0.0ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'a' LIMIT 1
397
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
398
+  (0.0ms) SAVEPOINT active_record_1
399
+  (0.2ms) SELECT 1 FROM "users" WHERE "users"."mid" = 'UhvWgt6iJu' LIMIT 1
400
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00], ["masked_identifier", nil], ["mid", "UhvWgt6iJu"], ["updated_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00]]
401
+  (0.1ms) RELEASE SAVEPOINT active_record_1
402
+  (0.0ms) SAVEPOINT active_record_1
403
+  (0.1ms) SELECT 1 FROM "users" WHERE "users"."masked_identifier" = 'aacdaadacb' LIMIT 1
404
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "masked_identifier", "mid", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00], ["masked_identifier", "aacdaadacb"], ["mid", nil], ["updated_at", Mon, 01 Aug 2011 07:11:12 UTC +00:00]]
405
+  (0.1ms) RELEASE SAVEPOINT active_record_1
@@ -39,7 +39,7 @@ class MaskedIdentifierTest < ActiveSupport::TestCase
39
39
  charset = %w{ a }
40
40
  User.has_masked_identifier charset: charset, length: 1
41
41
  User.create!
42
- assert_raise CodeGenerator::TooManyFailedAttempts do
42
+ assert_raise MaskedIdentifier::CodeGenerator::TooManyFailedAttempts do
43
43
  User.create!
44
44
  end
45
45
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: masked-identifier
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
4
+ prerelease:
5
+ version: 0.0.4
11
6
  platform: ruby
12
7
  authors:
13
8
  - Matt Hodan
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-07-31 00:00:00 -07:00
19
- default_executable:
13
+ date: 2011-08-01 00:00:00 Z
20
14
  dependencies: []
21
15
 
22
16
  description: Automatically adds a masked identifier to an ActiveRecord object on create. View the project GitHub page for more info.
@@ -60,6 +54,7 @@ files:
60
54
  - test/dummy/db/development.sqlite3
61
55
  - test/dummy/db/migrate/20110731204706_create_users.rb
62
56
  - test/dummy/db/schema.rb
57
+ - test/dummy/db/seeds.rb
63
58
  - test/dummy/db/test.sqlite3
64
59
  - test/dummy/log/development.log
65
60
  - test/dummy/log/test.log
@@ -73,7 +68,6 @@ files:
73
68
  - test/dummy/test/unit/user_test.rb
74
69
  - test/masked-identifier_test.rb
75
70
  - test/test_helper.rb
76
- has_rdoc: true
77
71
  homepage: http://github.com/matthodan/masked-identifier
78
72
  licenses: []
79
73
 
@@ -87,23 +81,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
81
  requirements:
88
82
  - - ">="
89
83
  - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
84
  version: "0"
94
85
  required_rubygems_version: !ruby/object:Gem::Requirement
95
86
  none: false
96
87
  requirements:
97
88
  - - ">="
98
89
  - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
90
  version: "0"
103
91
  requirements: []
104
92
 
105
93
  rubyforge_project:
106
- rubygems_version: 1.3.7
94
+ rubygems_version: 1.8.6
107
95
  signing_key:
108
96
  specification_version: 3
109
97
  summary: Use a masked identifier as a non-incrementing reference to an ActiveRecord object
@@ -133,6 +121,7 @@ test_files:
133
121
  - test/dummy/db/development.sqlite3
134
122
  - test/dummy/db/migrate/20110731204706_create_users.rb
135
123
  - test/dummy/db/schema.rb
124
+ - test/dummy/db/seeds.rb
136
125
  - test/dummy/db/test.sqlite3
137
126
  - test/dummy/log/development.log
138
127
  - test/dummy/log/test.log