rails-interactive 2.1.1 → 2.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36127c97610fe0006be084e612ef004be19a5c028895125714b54972c005a109
4
- data.tar.gz: 3aeee57f6fa0eef511e6bb54c3f5a28c876c69135664a2cfde532e89e19a0c53
3
+ metadata.gz: d5f8f264844d295476f2a3a1b5321d4a24efd197385a3e46476b9e6912fdd35d
4
+ data.tar.gz: 0a305f3ddd4307d3380034b784d5a2e8f2e708c65be9039b5603e479a0e29fbd
5
5
  SHA512:
6
- metadata.gz: ad5734bb977bf9f6ad5adad7be9bab11d3a251cee2d7a86a2b4b7b65f7bf5079279ef696c55979746b746836a67d7a8e7d25b38a1e82b5830f67ccf59a4abf10
7
- data.tar.gz: 8f881c5a4c8043675575349c1a84eb0531958233c86ba5c6db2f31ea7e20659ec6791400a0a0f2a36a90978fe5b0f488b754bad20604de2f2f60f1a5e4da1181
6
+ metadata.gz: 11ba30482ac8c3892b7c103fd2e11e4e92fe6cf9fad851f264e526d2af50c2e2203240aabe18b4fcdccf0846a6f5d9fbe5773990d11fef9100d2d40875346f64
7
+ data.tar.gz: e3b1de0b4b081528d4a0260531e0ec30814d55da0b5e543e0b4dcece30954a3376593be483f14ddb191c52cb4f0a7ea8da940acb008c3a21ccbee68b8e5454f6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-interactive (2.1.1)
4
+ rails-interactive (2.1.2)
5
5
  tty-prompt
6
6
 
7
7
  GEM
@@ -15,37 +15,42 @@
15
15
  type: "select"
16
16
  required: false
17
17
  -
18
- name: template_engine
18
+ name: end_to_end_testing
19
19
  weight: 4
20
20
  type: "select"
21
21
  required: false
22
22
  -
23
- name: code_quality
23
+ name: template_engine
24
24
  weight: 5
25
25
  type: "select"
26
26
  required: false
27
27
  -
28
- name: background_job
28
+ name: code_quality
29
29
  weight: 6
30
30
  type: "select"
31
31
  required: false
32
32
  -
33
- name: security
33
+ name: background_job
34
34
  weight: 7
35
35
  type: "select"
36
36
  required: false
37
37
  -
38
- name: admin_panel
38
+ name: security
39
39
  weight: 8
40
40
  type: "select"
41
41
  required: false
42
42
  -
43
- name: features
43
+ name: admin_panel
44
44
  weight: 9
45
+ type: "select"
46
+ required: false
47
+ -
48
+ name: features
49
+ weight: 10
45
50
  type: "multi_select"
46
51
  required: false
47
52
  -
48
53
  name: development
49
- weight: 10
54
+ weight: 11
50
55
  type: "multi_select"
51
56
  required: false
@@ -139,4 +139,16 @@
139
139
  description: "The administration framework for Ruby on Rails applications. For details: https://github.com/activeadmin/activeadmin"
140
140
  dependencies:
141
141
  - sassc_rails
142
- - devise
142
+ - devise
143
+ -
144
+ identifier: minitest
145
+ name: MiniTest ( Default )
146
+ category: testing
147
+ description: "minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. For details: https://github.com/minitest/minitest"
148
+ dependencies: null
149
+ -
150
+ identifier: capybara
151
+ name: Capybara
152
+ category: end_to_end_testing
153
+ description: "Acceptance test framework for web applications. For details: https://github.com/teamcapybara/capybara"
154
+ dependencies: null
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem_group :development, :test do
4
+ gem "capybara"
5
+ end
6
+
7
+ Bundler.with_unbundled_env { run "bundle install" }
8
+
9
+ if defined? RSpec
10
+ inject_into_file "spec/spec_helper.rb", before: "RSpec.configure do |config|" do
11
+ <<~RB
12
+ require 'capybara/rspec'
13
+ RB
14
+ end
15
+ elsif defined? MiniTest && !defined? RSpec
16
+ inject_into_file "test/test_helper.rb", before: "class ActiveSupport::TestCase" do
17
+ <<~RB
18
+ require 'capybara/rails'
19
+ require 'capybara/minitest'
20
+ RB
21
+ end
22
+ else
23
+ puts "No test framework detected or related test framework does not exist in RailsInteractive"
24
+ end
@@ -5,6 +5,11 @@ Bundler.with_unbundled_env { run "bundle install" }
5
5
 
6
6
  rails_command "generate devise:install"
7
7
 
8
- run "rails generate devise User"
8
+ model_name = ask("What do you want to call your Devise model?")
9
+ model_name = model_name.empty? ? "user" : model_name
10
+
11
+ File.open("devise-model.txt", "w") { |f| f.write(model_name) }
12
+
13
+ run "rails generate devise #{model_name.capitalize}"
9
14
  run "rails db:prepare"
10
15
  run "rails db:migrate"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ run "bundle add minitest"
4
+
5
+ Bundler.with_unbundled_env { run "bundle install" }
@@ -1,30 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "fileutils"
4
+
3
5
  run "bundle add omniauth"
4
6
 
5
7
  run "bundle install"
6
8
 
9
+ devise_model_name = File.read("devise-model.txt")
10
+ FileUtils.rm("devise-model.txt")
11
+
7
12
  # 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"
13
+ rails_command "generate model identity #{devise_model_name}:references provider:string:index uid:string:index token:string:index refresh_token:string:index"
9
14
  # rubocop:enable Layout/LineLength
10
15
 
11
- rails_command "generate migration AddIdentityToUsers identities_count:integer"
16
+ rails_command "generate migration AddIdentityTo#{devise_model_name.capitalize}s identities_count:integer"
12
17
 
13
18
  rails_command "db:migrate"
14
19
 
15
- inject_into_file "config/routes.rb", after: "devise_for :users\n" do
16
- " # devise_for :users, controllers: { omniauth_callbacks: 'omniauth' }"
20
+ inject_into_file "config/routes.rb", after: "devise_for :#{devise_model_name}s\n" do
21
+ " # devise_for :#{devise_model_name}s, controllers: { omniauth_callbacks: 'omniauth' }"
17
22
  end
18
23
 
19
- inject_into_file "app/models/user.rb", after: ":database_authenticatable, " do
24
+ inject_into_file "app/models/#{devise_model_name}.rb", after: ":database_authenticatable, " do
20
25
  ":omniauthable, "
21
26
  end
22
27
 
23
- inject_into_file "app/models/identity.rb", after: "belongs_to :user" do
28
+ inject_into_file "app/models/identity.rb", after: "belongs_to :#{devise_model_name}" do
24
29
  ", counter_cache: true"
25
30
  end
26
31
 
27
- inject_into_file "app/models/user.rb", after: "class User < ApplicationRecord\n" do
32
+ inject_into_file "app/models/#{devise_model_name}.rb",
33
+ after: "class #{devise_model_name.capitalize} < ApplicationRecord\n" do
28
34
  # rubocop:disable Naming/HeredocDelimiterNaming
29
35
  <<-EOF
30
36
  has_many :identities, dependent: :destroy
@@ -36,15 +42,15 @@ inject_into_file "app/models/user.rb", after: "class User < ApplicationRecord\n"
36
42
  identity.token = auth.credentials.token
37
43
  identity.refresh_token = auth.credentials.refresh_token
38
44
  end
39
- if identity.user.nil? && auth.info.email.present?
40
- user = User.where(email: auth.info.email).first_or_initialize
45
+ if identity.#{devise_model_name}.nil? && auth.info.email.present?
46
+ user = #{devise_model_name}.where(email: auth.info.email).first_or_initialize
41
47
  user.name = auth.info.name
42
48
  user.password = Devise.friendly_token if user.new_record?
43
49
  user.save!
44
- identity.user = user
50
+ identity.#{devise_model_name} = user
45
51
  end
46
52
  identity.save!
47
- identity.user
53
+ identity.#{devise_model_name}
48
54
  end
49
55
  end
50
56
 
@@ -57,5 +63,6 @@ file "app/controllers/omniauth_controller.rb", <<~CODE
57
63
 
58
64
  end
59
65
  CODE
60
-
61
- puts "IMPORTANT: Add devise_for :users, controllers: { omniauth_callbacks: 'omniauth' } to your routes.rb"
66
+ # rubocop:disable Layout/LineLength
67
+ puts "IMPORTANT: Add devise_for :#{devise_model_name}s, controllers: { omniauth_callbacks: 'omniauth' } to your routes.rb"
68
+ # rubocop:enable Layout/LineLength
data/lib/cli/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RailsInteractive
4
4
  class CLI
5
- VERSION = "2.1.1"
5
+ VERSION = "2.1.2"
6
6
  end
7
7
  end
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: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oguzhan Ince
@@ -177,6 +177,7 @@ files:
177
177
  - lib/cli/templates/setup_brakeman.rb
178
178
  - lib/cli/templates/setup_bullet.rb
179
179
  - lib/cli/templates/setup_cancancan.rb
180
+ - lib/cli/templates/setup_capybara.rb
180
181
  - lib/cli/templates/setup_devise.rb
181
182
  - lib/cli/templates/setup_faker.rb
182
183
  - lib/cli/templates/setup_friendly_id.rb
@@ -184,6 +185,7 @@ files:
184
185
  - lib/cli/templates/setup_haml.rb
185
186
  - lib/cli/templates/setup_kaminari.rb
186
187
  - lib/cli/templates/setup_letter_opener.rb
188
+ - lib/cli/templates/setup_minitest.rb
187
189
  - lib/cli/templates/setup_omniauth.rb
188
190
  - lib/cli/templates/setup_pundit.rb
189
191
  - lib/cli/templates/setup_rails_admin.rb