rails_guardian 0.1.6 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a667ea50382b87912ba9172cfd7021f87ccf082f24a545490bc970880309f63
4
- data.tar.gz: 8006b9bdd5c659bac23c98a570fcd2219c81cd1de1fdc97843b09ce3dd6830e5
3
+ metadata.gz: 847e2b3a8ef43ab4802b5cf5decd4e3225b4ad5576dbff4e0987c51686d0623d
4
+ data.tar.gz: a8d841f545fda207f9e8deb715bfab35f9aeffa1f52959957f584d1377ace481
5
5
  SHA512:
6
- metadata.gz: '019a18c5739a872a0c62d39072a51a748b87188a198c519e45a22838be98ffe2efd77f5f0306d474a753c6c715265362ccb610417cedff15f6debd2726df41be'
7
- data.tar.gz: 21382013680717a101a8995f980c62791a5c41a1029d91763fc0ec2122a5f4439ea3eaa6a99ec272547d5b7b84fcbb9b0802cda4cab2946722dd78c2c32bc58b
6
+ metadata.gz: 775ccf185593dc7c38afad42ed8f8f758d242899dae1e96215ebddc3b9135cc23a37bf1f0747ab65c26354f1a3e61c9ea598ad1fec56f9d7781a2680b9c3bfa8
7
+ data.tar.gz: bceddfcf55f73169499315ccb08fb7431e39c840142d4ad02e14b307dbbe66d6187348a0b4e26b5f4af2afcb9f20e984cc3e2acb0447365c86842f60405ac285
@@ -1,13 +1,23 @@
1
- # lib/generators/rails_guardian/model/model_generator.rb
1
+ # lib/generators/guardian/model/model_generator.rb
2
+ require 'rails/generators/active_record'
3
+
4
+
2
5
  module RailsGuardian
3
- module Generators
4
- class ModelGenerator < Rails::Generators::NamedBase
5
- source_root File.expand_path('templates', __dir__)
6
-
7
- def create_model_file
8
- template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
9
- end
10
- end
11
- end
6
+ module Generators
7
+ class ModelGenerator < Rails::Generators::NamedBase
8
+ include ActiveRecord::Generators::Migration
9
+ source_root File.expand_path('templates', __dir__)
10
+
11
+ def create_model_file
12
+ template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
13
+ end
14
+
15
+ def create_migration_file
16
+ if defined?(ActiveRecord)
17
+ migration_template 'migration.rb', "db/migrate/guardian_create_#{table_name}.rb"
18
+ end
19
+ end
20
+ end
21
+ end
12
22
  end
13
23
 
@@ -0,0 +1,42 @@
1
+ # lib/generators/guardian/model/templates/migration.rb
2
+ class GuardianCreate<%= table_name.camelize %> < ActiveRecord::Migration
3
+ def change
4
+ create_table :<%= table_name %> do |t|
5
+ t.string :email, null: false, default: ""
6
+ t.string :encrypted_password, null: false, default: ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, default: 0, null: false
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ ## Confirmable
23
+ t.string :confirmation_token
24
+ t.datetime :confirmed_at
25
+ t.datetime :confirmation_sent_at
26
+ t.string :unconfirmed_email # Only if using reconfirmable
27
+
28
+ ## Lockable
29
+ t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30
+ t.string :unlock_token # Only if unlock strategy is :email or :both
31
+ t.datetime :locked_at
32
+
33
+ t.timestamps null: false
34
+ end
35
+
36
+ add_index :<%= table_name %>, :email, unique: true
37
+ add_index :<%= table_name %>, :reset_password_token, unique: true
38
+ add_index :<%= table_name %>, :confirmation_token, unique: true
39
+ add_index :<%= table_name %>, :unlock_token, unique: true
40
+ end
41
+ end
42
+
@@ -1,3 +1,3 @@
1
1
  module RailsGuardian
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_guardian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - fabiantorresm
@@ -39,6 +39,7 @@ files:
39
39
  - lib/lib/generators/rails_guardian/install/install_generator.rb
40
40
  - lib/lib/generators/rails_guardian/install/templates/rails_guardian.rb
41
41
  - lib/lib/generators/rails_guardian/model/model_generator.rb
42
+ - lib/lib/generators/rails_guardian/model/templates/migration.rb
42
43
  - lib/lib/generators/rails_guardian/model/templates/model.rb
43
44
  - lib/lib/generators/rails_guardian/views/views_generator.rb
44
45
  - lib/rails_guardian.rb