rails-new-app 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +28 -0
  3. data/.gitignore +2 -0
  4. data/Gemfile +14 -0
  5. data/Gemfile.lock +60 -0
  6. data/README.md +60 -20
  7. data/Rakefile +9 -0
  8. data/lib/rails-new-app.rb +1 -1
  9. data/lib/rails-new-app/processors/authentication_processor.rb +16 -0
  10. data/lib/rails-new-app/processors/authorization_processor.rb +18 -0
  11. data/lib/rails-new-app/runner.rb +97 -146
  12. data/lib/rails-new-app/screens.rb +8 -0
  13. data/lib/rails-new-app/screens/app_name_screen.rb +28 -0
  14. data/lib/rails-new-app/screens/auth_screen.rb +26 -0
  15. data/lib/rails-new-app/screens/authentication_screen.rb +27 -0
  16. data/lib/rails-new-app/screens/authorization_screen.rb +27 -0
  17. data/lib/rails-new-app/screens/choice_screen.rb +52 -0
  18. data/lib/rails-new-app/{steps/code_coverage_step.rb → screens/code_coverage_screen.rb} +3 -3
  19. data/lib/rails-new-app/{steps/database_step.rb → screens/database_screen.rb} +7 -5
  20. data/lib/rails-new-app/{steps/form_builder_step.rb → screens/form_builder_screen.rb} +2 -2
  21. data/lib/rails-new-app/{steps/java_script_framework_step.rb → screens/java_script_framework_screen.rb} +2 -2
  22. data/lib/rails-new-app/screens/menu_screen.rb +61 -0
  23. data/lib/rails-new-app/{steps/pagination_step.rb → screens/pagination_screen.rb} +2 -2
  24. data/lib/rails-new-app/screens/review_and_confirm_screen.rb +59 -0
  25. data/lib/rails-new-app/{steps/ruby_linter_step.rb → screens/ruby_linter_screen.rb} +2 -2
  26. data/lib/rails-new-app/screens/screen.rb +66 -0
  27. data/lib/rails-new-app/{steps/template_engine_step.rb → screens/template_engine_screen.rb} +2 -2
  28. data/lib/rails-new-app/{steps/test_factory_step.rb → screens/test_factory_screen.rb} +3 -3
  29. data/lib/rails-new-app/{steps/test_fake_data.rb → screens/test_fake_data_screen.rb} +3 -3
  30. data/lib/rails-new-app/{steps/test_runner_step.rb → screens/test_runner_screen.rb} +3 -3
  31. data/lib/rails-new-app/{steps/yes_no_choice_step.rb → screens/yes_no_choice_screen.rb} +1 -1
  32. data/lib/rails-new-app/templates/cancancan-config.rb +1 -0
  33. data/lib/rails-new-app/templates/cancancan-gemfile.rb +1 -0
  34. data/lib/rails-new-app/templates/devise-config.rb +1 -0
  35. data/lib/rails-new-app/templates/devise-gemfile.rb +1 -0
  36. data/lib/rails-new-app/templates/pagy-config.rb +1 -1
  37. data/lib/rails-new-app/templates/pundit-config.rb +7 -0
  38. data/lib/rails-new-app/templates/pundit-gemfile.rb +1 -0
  39. data/lib/rails-new-app/version.rb +1 -1
  40. metadata +34 -18
  41. data/lib/rails-new-app/steps.rb +0 -7
  42. data/lib/rails-new-app/steps/app_name_step.rb +0 -20
  43. data/lib/rails-new-app/steps/choice_step.rb +0 -45
  44. data/lib/rails-new-app/steps/rails_version_step.rb +0 -34
  45. data/lib/rails-new-app/steps/step.rb +0 -75
@@ -1,5 +1,5 @@
1
1
  module RailsNewApp
2
- class TemplateEngineStep < ChoiceStep
2
+ class TemplateEngineScreen < ChoiceScreen
3
3
  def step_question
4
4
  "Type the option number of the Template Engine gem to use:"
5
5
  end
@@ -18,7 +18,7 @@ module RailsNewApp
18
18
 
19
19
  def self.default
20
20
  {
21
- option_number: 0,
21
+ option_number: 1,
22
22
  name: "None",
23
23
  key: ""
24
24
  }
@@ -1,5 +1,5 @@
1
1
  module RailsNewApp
2
- class TestFactoryStep < ChoiceStep
2
+ class TestFactoryScreen < ChoiceScreen
3
3
  def step_question
4
4
  warning =
5
5
  if config[:test_runner][:key] == ""
@@ -25,8 +25,8 @@ module RailsNewApp
25
25
 
26
26
  def self.default
27
27
  {
28
- option_number: 0,
29
- name: "None (Default)",
28
+ option_number: 1,
29
+ name: "None",
30
30
  key: ""
31
31
  }
32
32
  end
@@ -1,5 +1,5 @@
1
1
  module RailsNewApp
2
- class TestFakeDataStep < ChoiceStep
2
+ class TestFakeDataScreen < ChoiceScreen
3
3
  def step_question
4
4
  warning =
5
5
  if config[:test_runner][:key] == ""
@@ -25,8 +25,8 @@ module RailsNewApp
25
25
 
26
26
  def self.default
27
27
  {
28
- option_number: 0,
29
- name: "None (Default)",
28
+ option_number: 1,
29
+ name: "None",
30
30
  key: ""
31
31
  }
32
32
  end
@@ -1,5 +1,5 @@
1
1
  module RailsNewApp
2
- class TestRunnerStep < ChoiceStep
2
+ class TestRunnerScreen < ChoiceScreen
3
3
  def options
4
4
  ["None", "Minitest", "RSpec"]
5
5
  end
@@ -18,7 +18,7 @@ module RailsNewApp
18
18
 
19
19
  def self.default
20
20
  {
21
- option_number: 1,
21
+ option_number: 2,
22
22
  name: "Minitest",
23
23
  key: "minitest",
24
24
  in_rails_new: true
@@ -26,7 +26,7 @@ module RailsNewApp
26
26
  end
27
27
 
28
28
  def next_step
29
- option == "None" ? nil : :code_coverage
29
+ option == "None" ? :menu : :code_coverage
30
30
  end
31
31
  end
32
32
  end
@@ -1,5 +1,5 @@
1
1
  module RailsNewApp
2
- class YesNoChoiceStep < ChoiceStep
2
+ class YesNoChoiceScreen < ChoiceScreen
3
3
  def options
4
4
  ["Yes", "No"]
5
5
  end
@@ -0,0 +1 @@
1
+ generate("cancan:ability")
@@ -0,0 +1 @@
1
+ gem "cancancan"
@@ -0,0 +1 @@
1
+ generate("devise:install")
@@ -0,0 +1 @@
1
+ gem "devise"
@@ -1,4 +1,4 @@
1
- initializer "pagy.rb", "Check initializer options at: https://github.com/ddnexus/pagy/blob/master/lib/config/pagy.rb"
1
+ initializer "pagy.rb", "# Check initializer options at: https://github.com/ddnexus/pagy/blob/master/lib/config/pagy.rb"
2
2
 
3
3
  inject_into_file "app/helpers/application_helper.rb", after: "module ApplicationHelper\n" do
4
4
  <<~'RUBY'
@@ -0,0 +1,7 @@
1
+ inject_into_file "app/controllers/application_controller.rb", after: "class ApplicationController < ActionController::Base\n" do
2
+ <<~'RUBY'
3
+ include Pundit
4
+ RUBY
5
+ end
6
+
7
+ generate("pundit:install")
@@ -0,0 +1 @@
1
+ gem "pundit"
@@ -1,3 +1,3 @@
1
1
  module RailsNewApp
2
- VERSION = Gem::Version.new("0.0.3")
2
+ VERSION = Gem::Version.new("0.1.0")
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-new-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Juodziukynas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-23 00:00:00.000000000 Z
11
+ date: 2021-06-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -18,12 +18,18 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ".github/workflows/tests.yml"
21
22
  - ".gitignore"
23
+ - Gemfile
24
+ - Gemfile.lock
22
25
  - LICENSE
23
26
  - README.md
27
+ - Rakefile
24
28
  - exe/rails-new-app
25
29
  - lib/rails-new-app.rb
26
30
  - lib/rails-new-app/processors.rb
31
+ - lib/rails-new-app/processors/authentication_processor.rb
32
+ - lib/rails-new-app/processors/authorization_processor.rb
27
33
  - lib/rails-new-app/processors/code_coverage_processor.rb
28
34
  - lib/rails-new-app/processors/form_builder_processor.rb
29
35
  - lib/rails-new-app/processors/pagination_processor.rb
@@ -34,23 +40,31 @@ files:
34
40
  - lib/rails-new-app/processors/test_fake_data_processor.rb
35
41
  - lib/rails-new-app/processors/test_runner_processor.rb
36
42
  - lib/rails-new-app/runner.rb
37
- - lib/rails-new-app/steps.rb
38
- - lib/rails-new-app/steps/app_name_step.rb
39
- - lib/rails-new-app/steps/choice_step.rb
40
- - lib/rails-new-app/steps/code_coverage_step.rb
41
- - lib/rails-new-app/steps/database_step.rb
42
- - lib/rails-new-app/steps/form_builder_step.rb
43
- - lib/rails-new-app/steps/java_script_framework_step.rb
44
- - lib/rails-new-app/steps/pagination_step.rb
45
- - lib/rails-new-app/steps/rails_version_step.rb
46
- - lib/rails-new-app/steps/ruby_linter_step.rb
47
- - lib/rails-new-app/steps/step.rb
48
- - lib/rails-new-app/steps/template_engine_step.rb
49
- - lib/rails-new-app/steps/test_factory_step.rb
50
- - lib/rails-new-app/steps/test_fake_data.rb
51
- - lib/rails-new-app/steps/test_runner_step.rb
52
- - lib/rails-new-app/steps/yes_no_choice_step.rb
43
+ - lib/rails-new-app/screens.rb
44
+ - lib/rails-new-app/screens/app_name_screen.rb
45
+ - lib/rails-new-app/screens/auth_screen.rb
46
+ - lib/rails-new-app/screens/authentication_screen.rb
47
+ - lib/rails-new-app/screens/authorization_screen.rb
48
+ - lib/rails-new-app/screens/choice_screen.rb
49
+ - lib/rails-new-app/screens/code_coverage_screen.rb
50
+ - lib/rails-new-app/screens/database_screen.rb
51
+ - lib/rails-new-app/screens/form_builder_screen.rb
52
+ - lib/rails-new-app/screens/java_script_framework_screen.rb
53
+ - lib/rails-new-app/screens/menu_screen.rb
54
+ - lib/rails-new-app/screens/pagination_screen.rb
55
+ - lib/rails-new-app/screens/review_and_confirm_screen.rb
56
+ - lib/rails-new-app/screens/ruby_linter_screen.rb
57
+ - lib/rails-new-app/screens/screen.rb
58
+ - lib/rails-new-app/screens/template_engine_screen.rb
59
+ - lib/rails-new-app/screens/test_factory_screen.rb
60
+ - lib/rails-new-app/screens/test_fake_data_screen.rb
61
+ - lib/rails-new-app/screens/test_runner_screen.rb
62
+ - lib/rails-new-app/screens/yes_no_choice_screen.rb
53
63
  - lib/rails-new-app/string_underscore.rb
64
+ - lib/rails-new-app/templates/cancancan-config.rb
65
+ - lib/rails-new-app/templates/cancancan-gemfile.rb
66
+ - lib/rails-new-app/templates/devise-config.rb
67
+ - lib/rails-new-app/templates/devise-gemfile.rb
54
68
  - lib/rails-new-app/templates/factory_bot-gemfile.rb
55
69
  - lib/rails-new-app/templates/factory_bot-minitest-config.rb
56
70
  - lib/rails-new-app/templates/factory_bot-rspec-config.rb
@@ -61,6 +75,8 @@ files:
61
75
  - lib/rails-new-app/templates/kaminari-gemfile.rb
62
76
  - lib/rails-new-app/templates/pagy-config.rb
63
77
  - lib/rails-new-app/templates/pagy-gemfile.rb
78
+ - lib/rails-new-app/templates/pundit-config.rb
79
+ - lib/rails-new-app/templates/pundit-gemfile.rb
64
80
  - lib/rails-new-app/templates/rspec-rails-config.rb
65
81
  - lib/rails-new-app/templates/rspec-rails-gemfile.rb
66
82
  - lib/rails-new-app/templates/rubocop-config.rb
@@ -1,7 +0,0 @@
1
- # require generic steps first
2
- path = File.expand_path("../steps", __FILE__)
3
- require "#{path}/step"
4
- require "#{path}/choice_step"
5
- require "#{path}/yes_no_choice_step"
6
- # require the rest
7
- Dir.glob("#{path}/*").sort.each { |f| require f }
@@ -1,20 +0,0 @@
1
- module RailsNewApp
2
- class AppNameStep < Step
3
- def step_question
4
- "Type the name of the app:"
5
- end
6
-
7
- def after_valid
8
- puts "Your app is: #{@selection}\n"
9
- end
10
-
11
- def valid?(input)
12
- if /\A[a-z_]+\z/i.match?(input.strip)
13
- true
14
- else
15
- puts "Invalid app name"
16
- false
17
- end
18
- end
19
- end
20
- end
@@ -1,45 +0,0 @@
1
- module RailsNewApp
2
- class ChoiceStep < Step
3
- def options
4
- []
5
- end
6
-
7
- def option
8
- options[@selection]
9
- end
10
-
11
- def ask
12
- puts step_question
13
- puts ""
14
-
15
- current = config[self.class.key][:option_number]
16
- options.each_with_index do |op, idx|
17
- is_current = idx == current ? " (current)" : ""
18
- puts "#{idx} ) #{op}#{is_current}"
19
- end
20
- end
21
-
22
- def clean_input(input)
23
- input.to_i
24
- end
25
-
26
- def valid?(input)
27
- if options[input]
28
- true
29
- else
30
- puts "Invalid option, choose again:"
31
- false
32
- end
33
- end
34
-
35
- def return_value
36
- lower = lowercase_keys[@selection]
37
-
38
- {
39
- option_number: @selection,
40
- name: option,
41
- key: lower
42
- }
43
- end
44
- end
45
- end
@@ -1,34 +0,0 @@
1
- module RailsNewApp
2
- class RailsVersionStep < Step
3
- def valid?(ver)
4
- if /\A[56].\d\z/.match?(ver)
5
- # uncomment this to validate the input against RubyGems
6
- puts "Validating against Rubygems..."
7
- if `gem list -r -e -a rails | grep '[\( ]#{ver}\.'` != ""
8
- true
9
- else
10
- puts "Invalid Rails version, type the version you want to use:"
11
- end
12
- else
13
- puts "Invalid Rails version, type the version you want to use:"
14
- false
15
- end
16
- end
17
-
18
- def step_question
19
- <<~QUESTION
20
- Type the version of Rails you want to use (MAJOR.MINOR):
21
- ! Notice that Rails will use the latest patch version for a given version !
22
-
23
- QUESTION
24
- end
25
-
26
- def after_valid
27
- puts "Selected version is: #{@selection}\n"
28
- end
29
-
30
- def self.default
31
- ""
32
- end
33
- end
34
- end
@@ -1,75 +0,0 @@
1
- module RailsNewApp
2
- class Step
3
- def self.clean_name
4
- to_s.gsub("Step", "").gsub("RailsNewApp::", "")
5
- end
6
-
7
- def self.key
8
- clean_name.underscore.to_sym
9
- end
10
-
11
- def self.run(config)
12
- new.run(config)
13
- end
14
-
15
- attr_reader :config
16
-
17
- def run(current_config)
18
- @config = current_config
19
-
20
- system("clear") if config[:navigation]
21
-
22
- ask
23
- read_and_validate
24
- after_valid
25
- return_value
26
- end
27
-
28
- def step_title
29
- "Generic step question"
30
- end
31
-
32
- # describe the current step
33
- def ask
34
- puts step_question
35
- end
36
-
37
- # loop until the input is valid, sets @selection
38
- def read_and_validate
39
- loop do
40
- input = clean_input(gets.chomp)
41
- if valid?(input)
42
- @selection = input
43
- return true
44
- end
45
- end
46
- end
47
-
48
- # clean the input if needed before validations
49
- def clean_input(input)
50
- input.strip
51
- end
52
-
53
- # validate the input
54
- def valid?(input)
55
- true
56
- end
57
-
58
- # after valid message
59
- def after_valid
60
- end
61
-
62
- # process @selection to return a different value
63
- def return_value
64
- @selection
65
- end
66
-
67
- def self.default
68
- ""
69
- end
70
-
71
- def next_step
72
- nil
73
- end
74
- end
75
- end