rails_steroids 0.3.1 → 0.4.0

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: 6ce6fbe0a8cf0bdac91965f3a73e05a01b415a68358d81899ed9745bc1777115
4
- data.tar.gz: 9eefd09397f43fa4d36a6cb50989afdeb1b1902638f097765c8e9d9cb0fa7892
3
+ metadata.gz: ff2d152b0dac80d9a18dd7bbb082304395d3a26072b2acbcb9666e3550e6e755
4
+ data.tar.gz: 0755766a977aceb72eba7bf389f56ea3b13952d68ca8e8c89f0c1727ddcf509d
5
5
  SHA512:
6
- metadata.gz: 624785f5c35d1b51368c5629c94b16ab96b62528f4e003c26ca9f0707a1d9b3ac5c1f540ed4e1995eca01c8782b25653298b24fb459517e7254c164935356572
7
- data.tar.gz: 186c3eac0b2e7368ae0b6da42cb67618ead70105f72db44ab0a16adc2c3813277d4a6c08e8cab44310617468b1349b20cf110141c3e1b981eda9b45245d5b815
6
+ metadata.gz: 0c4fbaa6605cae87bc92f95b7c5db9728efbacba6631a62e588d8648b9301e048b9aa1a283ef87917320d2865db8e5bc94c17e0e039e67d667c355ed8a1224c2
7
+ data.tar.gz: d2f1b6282b7918ac5fbc549d15468c37ba3442444b7a2a45399e0bf13ec6733ba5846a7a5f7792277b3790cae002f772250c77007db5424bb4b94944e2818f2f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2024-02-06
4
+
5
+ - New steroid recipe: controller (Create new controller interactively)
6
+ - Documentation improvement
7
+
3
8
  ## [0.3.1] - 2024-02-06
4
9
 
5
10
  - Improvement in steroid recipe new_project : Code improvement (variable name for boolean_choices)
data/README.md CHANGED
@@ -11,9 +11,9 @@
11
11
 
12
12
  Any small idea evolves when it actually starts taking shape. But most of the time, when we think of developing an idea as a POC or hobby project, we end up spending more time in setting up the project and lose the momentum. And you must have realised that many tasks that we do with a new project from scratch are quite repetitive.
13
13
 
14
- Rails templates and other templating gems are a way of quickly generating an application but when it comes to adding some features in an already generated application then we need some way to do that. We have certain inbuilt generators which can be used for basic components but they need more coding over it.
14
+ Rails templates and other templating gems are a way of quickly generating an application but when it comes to adding some features in an already generated application then we need some way to do that. We have certain inbuilt generators which can be used for basic components but they need more coding over it. Also remembering options is a also a task or you will have to go through documentation to select options to be provided to generators.
15
15
 
16
- So here are steroids for your application, which are actually generators with special powers. This gem contains different steroids which will setup commonly used features very quickly and reduce your coding work so that you can focus on your precious idea.
16
+ So here are steroids for your application, which are actually generators with special powers. This gem contains different steroids which will run generators interactively help you choose options and so you will not have to remember them. Going forward the gem will also contain steroids which will setup commonly used features and functionalities from gems very quickly and reduce your coding work so that you can focus on your precious idea. Using these steroids is also very good for those who are learning Rails newly as you get to use generators interactively
17
17
 
18
18
  ## Installation
19
19
 
@@ -33,20 +33,23 @@ gem install rails_steroids
33
33
  ## Usage
34
34
 
35
35
  You can use the gem from command line using gem's CLI.
36
- You can inject the steroid into your application using command like:
37
- ```
38
- rails_steroids inject steroid:STEROID_NAME
39
- ```
40
36
 
41
37
  You can check the list of available steroids using command:
42
38
  ```
43
39
  rails_steroids list
44
40
  ```
45
41
 
42
+ You can inject the steroid into your application using command like:
43
+ ```
44
+ rails_steroids inject steroid:STEROID_NAME
45
+ ```
46
+ and then enjoy easily entering or selecting options interactively to the questions asked on terminal.
47
+
46
48
  ## Available Steroids
47
49
 
48
50
  | Functionality | Command |
49
51
  |---|---|
52
+ |controller|`rails_steroids inject steroid:controller`|
50
53
  |new_project|`rails_steroids inject steroid:new_project`|
51
54
 
52
55
  ## Development
@@ -0,0 +1,17 @@
1
+ Description:
2
+ `steroid:controller` will create Controller interactively.
3
+
4
+ Usage Example:
5
+ # with installed gem
6
+ rails_steroids inject steroid:controller
7
+ # with bundler
8
+ bin/rails g steroid:controller
9
+
10
+ What will this do?:
11
+ Create new Rails controller with configurations selected interactively.
12
+ Current options available to customize are:
13
+ * Controller name
14
+ * Choose from actions: index, show, new, edit, create, update, destroy
15
+ * Specify any custom/additional actions
16
+ * Skip adding routes
17
+ * Skip creating helper
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tty/prompt'
4
+
5
+ module Steroid
6
+ class ControllerGenerator < Rails::Generators::Base
7
+ desc "Adds Controller to the application"
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ def add_controller
11
+ say "Injecting steroid: Controller", :green
12
+ cmd = ["rails generate controller"]
13
+ prompt = TTY::Prompt.new
14
+ controller_name = prompt.ask("What is the great name of your controller?") do |q|
15
+ q.required true
16
+ q.modify :remove
17
+ end
18
+ cmd << controller_name
19
+
20
+ actions = prompt.multi_select("Choose actions:", %w(index show new edit create update destroy))
21
+ cmd += actions
22
+
23
+ boolean_choices = [{name: "yes", value: true}, {name: "no", value: false}]
24
+
25
+ custom_actions = []
26
+ while prompt.select("Would you like to add more actions?", boolean_choices)
27
+ custom_actions << prompt.ask("specify name of action:") do |q|
28
+ q.required true
29
+ q.modify :remove
30
+ end
31
+ end
32
+ cmd += custom_actions
33
+
34
+ cmd << "--skip-routes" if prompt.select("Skip routes?", boolean_choices)
35
+ cmd << "--no-helper" if prompt.select("Skip helper?", boolean_choices)
36
+
37
+ run cmd.join(" ")
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  Description:
2
- `steroid:new_project` will inject New Project functionality.
2
+ `steroid:new_project` will create New Project interactively.
3
3
 
4
4
  Usage Example:
5
5
  # with installed gem
@@ -28,7 +28,7 @@ class SteroidGenerator < Rails::Generators::NamedBase
28
28
  def create_usage_file
29
29
  create_file "lib/generators/steroid/#{name}/USAGE", <<~RUBY
30
30
  Description:
31
- `steroid:#{name}` will inject #{name.titlecase} functionality.
31
+ `steroid:#{name}` will inject #{name.titlecase} functionality interactively.
32
32
 
33
33
  Usage Example:
34
34
  # with installed gem
@@ -25,6 +25,7 @@ module RailsSteroids
25
25
  puts "| Functionality | Command |"
26
26
  puts "|---|---|"
27
27
  steroid_names = [
28
+ 'controller',
28
29
  'new_project',
29
30
  ]
30
31
  steroid_names.each do |steroid|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsSteroids
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_steroids
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anand Bait
@@ -104,6 +104,8 @@ files:
104
104
  - bin/console
105
105
  - bin/rails_steroids
106
106
  - bin/setup
107
+ - lib/generators/steroid/controller/USAGE
108
+ - lib/generators/steroid/controller/controller_generator.rb
107
109
  - lib/generators/steroid/new_project/USAGE
108
110
  - lib/generators/steroid/new_project/new_project_generator.rb
109
111
  - lib/generators/steroid/steroid_generator.rb