rails-interactive 0.1.4 → 0.1.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rails_interactive/templates/setup_cancancan.rb +7 -0
- data/lib/rails_interactive/templates/setup_omniauth.rb +61 -0
- data/lib/rails_interactive/templates/setup_pundit.rb +15 -0
- data/lib/rails_interactive/version.rb +1 -1
- data/lib/rails_interactive.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1d6d7de1b01f37818e7d8f40a4ea4f70e4f7419e0a9289a09a345f8761728bf
|
4
|
+
data.tar.gz: 6eb6ad5b7193fd37f1d8abadc238806e4a37892bc0f422821f2ef2ec62c69726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa7219d9f1233d37defe9944d032e5367bdcc0aeda2b4e3e78d8e49b21470f1d4b0f0d39fda2ac87a77782c3801d8e33c450fd3abce5ddcb2c86170735b3ddff
|
7
|
+
data.tar.gz: 54af5dfed258953ce0439154e4f2cfbc7d239aecd7f3d4c7a15ae12fbfbffdaa51753f647fab8d275a6b3d8b02bced5c94df83252cafefe3e8a8d142db80cc40
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
run "bundle add omniauth"
|
4
|
+
|
5
|
+
run "bundle install"
|
6
|
+
|
7
|
+
# rubocop:disable Layout/LineLength
|
8
|
+
rails_command "generate model identity user:references provider:string:index uid:string:index token:string:index refresh_token:string:index"
|
9
|
+
# rubocop:enable Layout/LineLength
|
10
|
+
|
11
|
+
rails_command "generate migration AddIdentityToUsers identities_count:integer"
|
12
|
+
|
13
|
+
rails_command "db:migrate"
|
14
|
+
|
15
|
+
inject_into_file "config/routes.rb", after: "devise_for :users\n" do
|
16
|
+
" # devise_for :users, controllers: { omniauth_callbacks: 'omniauth' }"
|
17
|
+
end
|
18
|
+
|
19
|
+
inject_into_file "app/models/user.rb", after: ":database_authenticatable, " do
|
20
|
+
":omniauthable, "
|
21
|
+
end
|
22
|
+
|
23
|
+
inject_into_file "app/models/identity.rb", after: "belongs_to :user" do
|
24
|
+
", counter_cache: true"
|
25
|
+
end
|
26
|
+
|
27
|
+
inject_into_file "app/models/user.rb", after: "class User < ApplicationRecord\n" do
|
28
|
+
# rubocop:disable Naming/HeredocDelimiterNaming
|
29
|
+
<<-EOF
|
30
|
+
has_many :identities, dependent: :destroy
|
31
|
+
|
32
|
+
def self.from_omniauth(auth)
|
33
|
+
if auth.present? && auth.provider.present? && auth.uid.present?
|
34
|
+
identity = Identity.where(provider: auth.provider, uid: auth.uid).first_or_initialize
|
35
|
+
if auth.credentials.present?
|
36
|
+
identity.token = auth.credentials.token
|
37
|
+
identity.refresh_token = auth.credentials.refresh_token
|
38
|
+
end
|
39
|
+
if identity.user.nil? && auth.info.email.present?
|
40
|
+
user = User.where(email: auth.info.email).first_or_initialize
|
41
|
+
user.name = auth.info.name
|
42
|
+
user.password = Devise.friendly_token if user.new_record?
|
43
|
+
user.save!
|
44
|
+
identity.user = user
|
45
|
+
end
|
46
|
+
identity.save!
|
47
|
+
identity.user
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
EOF
|
52
|
+
# rubocop:enable Naming/HeredocDelimiterNaming
|
53
|
+
end
|
54
|
+
|
55
|
+
file "app/controllers/omniauth_controller.rb", <<~CODE
|
56
|
+
class OmniauthController < Devise::OmniauthCallbacksController
|
57
|
+
|
58
|
+
end
|
59
|
+
CODE
|
60
|
+
|
61
|
+
puts "IMPORTANT: Add devise_for :users, controllers: { omniauth_callbacks: 'omniauth' } to your routes.rb"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
run "bundle add pundit"
|
4
|
+
|
5
|
+
puts "Add - Pundit module to Application Controller"
|
6
|
+
puts ""
|
7
|
+
|
8
|
+
inject_into_file "app/controllers/application_controller.rb",
|
9
|
+
after: "class ApplicationController < ActionController::Base\n" do
|
10
|
+
" include Pundit\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
puts "Run - Pundit Generator"
|
14
|
+
|
15
|
+
rails_command("generate pundit:install")
|
data/lib/rails_interactive.rb
CHANGED
@@ -32,7 +32,7 @@ module RailsInteractive
|
|
32
32
|
database_types = { "PostgreSQL" => "-d postgresql", "MySQL" => "-d mysql", "SQLite" => "" }
|
33
33
|
@inputs[:database] = Prompt.new("Choose project's database: ", "select", database_types, required: true).perform
|
34
34
|
|
35
|
-
features = %w[devise]
|
35
|
+
features = %w[devise cancancan omniauth pundit]
|
36
36
|
@inputs[:features] = Prompt.new("Choose project features: ", "multi_select", features).perform
|
37
37
|
|
38
38
|
create
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-interactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oguzhan Ince
|
@@ -136,7 +136,10 @@ files:
|
|
136
136
|
- lib/rails_interactive.rb
|
137
137
|
- lib/rails_interactive/message.rb
|
138
138
|
- lib/rails_interactive/prompt.rb
|
139
|
+
- lib/rails_interactive/templates/setup_cancancan.rb
|
139
140
|
- lib/rails_interactive/templates/setup_devise.rb
|
141
|
+
- lib/rails_interactive/templates/setup_omniauth.rb
|
142
|
+
- lib/rails_interactive/templates/setup_pundit.rb
|
140
143
|
- lib/rails_interactive/version.rb
|
141
144
|
- rails-interactive.gemspec
|
142
145
|
homepage: https://github.com/oguzsh/rails-interactive
|