rails_steroids 0.3.0 → 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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +9 -6
- data/lib/generators/steroid/controller/USAGE +17 -0
- data/lib/generators/steroid/controller/controller_generator.rb +40 -0
- data/lib/generators/steroid/new_project/USAGE +1 -1
- data/lib/generators/steroid/new_project/new_project_generator.rb +11 -10
- data/lib/generators/steroid/steroid_generator.rb +3 -1
- data/lib/rails_steroids/cli.rb +1 -0
- data/lib/rails_steroids/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff2d152b0dac80d9a18dd7bbb082304395d3a26072b2acbcb9666e3550e6e755
|
4
|
+
data.tar.gz: 0755766a977aceb72eba7bf389f56ea3b13952d68ca8e8c89f0c1727ddcf509d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c4fbaa6605cae87bc92f95b7c5db9728efbacba6631a62e588d8648b9301e048b9aa1a283ef87917320d2865db8e5bc94c17e0e039e67d667c355ed8a1224c2
|
7
|
+
data.tar.gz: d2f1b6282b7918ac5fbc549d15468c37ba3442444b7a2a45399e0bf13ec6733ba5846a7a5f7792277b3790cae002f772250c77007db5424bb4b94944e2818f2f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
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
|
+
|
8
|
+
## [0.3.1] - 2024-02-06
|
9
|
+
|
10
|
+
- Improvement in steroid recipe new_project : Code improvement (variable name for boolean_choices)
|
11
|
+
- Improvement in steroid generator : Add `require 'tty/prompt'` by default
|
12
|
+
|
3
13
|
## [0.3.0] - 2024-02-05
|
4
14
|
|
5
15
|
- Improvement in steroid recipe new_project : Use of TTY-prompt for better interaction
|
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
|
@@ -44,16 +44,17 @@ module Steroid
|
|
44
44
|
js = prompt.select("Choose JavaScript approach:", %w(importmap bun webpack esbuild rollup))
|
45
45
|
cmd << "--javascript #{js}"
|
46
46
|
|
47
|
-
boolean_choices =
|
48
|
-
cmd << "--api" if prompt.select("API only application?",
|
49
|
-
cmd << "--skip-jbuilder" if prompt.select("Skip jbuilder?",
|
50
|
-
cmd << "--skip-git" if prompt.select("Skip git init, .gitignore and .gitattributes?",
|
51
|
-
cmd << "--skip-docker" if prompt.select("Skip Dockerfile, .dockerignore and bin/docker-entrypoint?",
|
52
|
-
cmd << "--skip-action-cable" if prompt.select("Skip Action Cable files?",
|
53
|
-
cmd << "--skip-hotwire" if prompt.select("Skip Hotwire integration?",
|
54
|
-
cmd << "--skip-test" if prompt.select("Skip test files?",
|
55
|
-
cmd << "--skip-system-test" if prompt.select("Skip system test files?",
|
56
|
-
cmd << "--no-rc"
|
47
|
+
boolean_choices = [{name: "yes", value: true}, {name: "no", value: false}]
|
48
|
+
cmd << "--api" if prompt.select("API only application?", boolean_choices)
|
49
|
+
cmd << "--skip-jbuilder" if prompt.select("Skip jbuilder?", boolean_choices)
|
50
|
+
cmd << "--skip-git" if prompt.select("Skip git init, .gitignore and .gitattributes?", boolean_choices)
|
51
|
+
cmd << "--skip-docker" if prompt.select("Skip Dockerfile, .dockerignore and bin/docker-entrypoint?", boolean_choices)
|
52
|
+
cmd << "--skip-action-cable" if prompt.select("Skip Action Cable files?", boolean_choices)
|
53
|
+
cmd << "--skip-hotwire" if prompt.select("Skip Hotwire integration?", boolean_choices)
|
54
|
+
cmd << "--skip-test" if prompt.select("Skip test files?", boolean_choices)
|
55
|
+
cmd << "--skip-system-test" if prompt.select("Skip system test files?", boolean_choices)
|
56
|
+
cmd << "--no-rc" # To skip configurations from .railsrc
|
57
|
+
cmd << "--skip" # To skip overriding existing files
|
57
58
|
run cmd.join(" ")
|
58
59
|
end
|
59
60
|
end
|
@@ -5,6 +5,8 @@ class SteroidGenerator < Rails::Generators::NamedBase
|
|
5
5
|
create_file "lib/generators/steroid/#{name}/#{name}_generator.rb", <<~RUBY
|
6
6
|
# frozen_string_literal: true
|
7
7
|
|
8
|
+
require 'tty/prompt'
|
9
|
+
|
8
10
|
module Steroid
|
9
11
|
class #{name.camelize}Generator < Rails::Generators::Base
|
10
12
|
desc "Adds #{name.titlecase} to the application"
|
@@ -26,7 +28,7 @@ class SteroidGenerator < Rails::Generators::NamedBase
|
|
26
28
|
def create_usage_file
|
27
29
|
create_file "lib/generators/steroid/#{name}/USAGE", <<~RUBY
|
28
30
|
Description:
|
29
|
-
`steroid:#{name}` will inject #{name.titlecase} functionality.
|
31
|
+
`steroid:#{name}` will inject #{name.titlecase} functionality interactively.
|
30
32
|
|
31
33
|
Usage Example:
|
32
34
|
# with installed gem
|
data/lib/rails_steroids/cli.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_steroids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anand Bait
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -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
|