rails_on_rails 0.0.18 → 0.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 +4 -4
- data/README.md +14 -1
- data/lib/autogenerators/generator_templates/controller.txt +0 -7
- data/lib/autogenerators/handlers/controller.rb +3 -16
- data/lib/autogenerators/rails_templates/global_controller.rb +2 -2
- data/lib/constants/cli_constants.rb +2 -2
- data/lib/constants/options.rb +1 -1
- data/lib/utils/rails_methods.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79e060621e3223010ebd62ec76daa8665c3402c7ef72816735eb5f4d6555ce85
|
4
|
+
data.tar.gz: 2d744aaa383e59b2b7f591acb1f74e255b50903e839fb4b7d17646310c50087d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08aa1c5d9426b1dfe99ca25d17361d6544fce8c063ef71422ff37b9c4a854e56566a4d7ccf3e513f951d177eaee535071ed4bd9c11867dd8eb7197f3a1150ad9'
|
7
|
+
data.tar.gz: a46fe0a29071cc99ee39b8039e7fd3ab14369062c05a0e0a60e44dbf7ac0ca18d93226be380eb90666fd8763e91037a44c541c83ae7ef793455eee9f94771407
|
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Rails on Rails
|
2
2
|
|
3
|
+
***
|
4
|
+
If you updated from the minor version from the patch versions, you will need to reinitialize your project
|
5
|
+
The global controller file has changed
|
6
|
+
***
|
7
|
+
|
3
8
|
All commands must be execute in your Rails root project directory
|
4
9
|
|
5
10
|
## Installation
|
@@ -12,6 +17,7 @@ Gemfile Install:
|
|
12
17
|
`gem 'rails_on_rails'`
|
13
18
|
|
14
19
|
## Gem Dependencies
|
20
|
+
- Ruby Version >= 2.5
|
15
21
|
- Rails Version 5: `gem 'rails', '~> 5'`
|
16
22
|
- Rails Rspec Version >= 3.8: `gem 'rspec-rails', '~> 3.8'`
|
17
23
|
- Faker Version >= 1.9: `gem 'faker', '~> 1.9'`
|
@@ -21,6 +27,13 @@ If you run into hangups with spring, run `spring stop` before your `rails_on_rai
|
|
21
27
|
Then `spring server` to resume spring
|
22
28
|
|
23
29
|
```
|
30
|
+
rails new tutorial
|
31
|
+
cd tutorial
|
32
|
+
|
33
|
+
# Check to make sure your initial rails database is setup correctly
|
34
|
+
# Check to make sure your initial rails setup is fully functional
|
35
|
+
# Make sure rails_on_rails is install in your gem file
|
36
|
+
|
24
37
|
rails_on_rails init
|
25
38
|
```
|
26
39
|
|
@@ -62,7 +75,7 @@ But instead generates a controller for your model with unit tests to test the fu
|
|
62
75
|
and update a model assocations.
|
63
76
|
|
64
77
|
```
|
65
|
-
rails_on_rails model <ModelName> <*rails-model-generate-parameters>
|
78
|
+
rails_on_rails model <ModelName> <*native-rails-model-generate-parameters>
|
66
79
|
```
|
67
80
|
|
68
81
|
By default all our basic CRUD operations are complete for: Index, Show, Create, Update, & Destroy
|
@@ -6,29 +6,16 @@ MODEL_PARAMS = ARGV
|
|
6
6
|
2.times { |i| MODEL_PARAMS.shift }
|
7
7
|
|
8
8
|
MODEL_SNAKE_CASE = MODEL_NAME.underscore
|
9
|
+
MODEL_CAMEL_CASE = MODEL_NAME.camelize
|
9
10
|
|
10
|
-
system("bash #{__dir__}/../bash_commands/generate_model.sh #{
|
11
|
+
system("bash #{__dir__}/../bash_commands/generate_model.sh #{MODEL_CAMEL_CASE} #{MODEL_PARAMS.join(' ')}") if !SKIP_MODEL
|
11
12
|
system("bash #{__dir__}/../bash_commands/generate_controller.sh #{MODEL_SNAKE_CASE} --no-assets --no-view-specs --no-helper")
|
12
13
|
|
13
14
|
controller_path = "#{Dir.pwd}/app/controllers/#{MODEL_SNAKE_CASE}_controller.rb"
|
14
15
|
template_path = "#{__dir__}/../generator_templates/controller.txt"
|
15
16
|
|
16
17
|
read_file = File.open(template_path, 'r:UTF-8', &:read)
|
17
|
-
length = MODEL_PARAMS.length
|
18
18
|
|
19
|
-
|
20
|
-
str = ''
|
21
|
-
key, type = item.split(':')
|
22
|
-
polymorphoric = false
|
23
|
-
if /references/.match?(type)
|
24
|
-
polymorphoric = /poly/.match?(type)
|
25
|
-
type = 'references'
|
26
|
-
end
|
27
|
-
str += type == 'references' ? "{ key: :#{key}, model: #{key.split('_').map(&:capitalize!).join('')} }" : ":#{key}"
|
28
|
-
str
|
29
|
-
end.join(', ')
|
30
|
-
|
31
|
-
read_file = read_file.gsub! '{{ MODEL }}', MODEL_NAME
|
32
|
-
read_file = read_file.gsub! '{{ PARAMS }}', PARAMS_STRING
|
19
|
+
read_file = read_file.gsub! '{{ MODEL }}', MODEL_CAMEL_CASE
|
33
20
|
|
34
21
|
File.write(controller_path, read_file)
|
@@ -12,11 +12,11 @@ class GlobalController < ApplicationController
|
|
12
12
|
# Default declarations
|
13
13
|
|
14
14
|
def model
|
15
|
-
|
15
|
+
self.class.to_s.chomp("Controller").singularize.constantize
|
16
16
|
end
|
17
17
|
|
18
18
|
def render_params
|
19
|
-
|
19
|
+
params.permit(*model.columns.map { |e| e.name.to_sym })
|
20
20
|
end
|
21
21
|
|
22
22
|
def default_options
|
@@ -23,7 +23,7 @@ List of commands:
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def INITIALIZE_HELP_STRING
|
26
|
-
opts = skip_initialize_options.
|
26
|
+
opts = skip_initialize_options.keys.map { |e| "\t=> #{e.to_s}" }
|
27
27
|
"This command has no parameters but has optional commands. Optional flag options are:
|
28
28
|
--skip=<options-separated-by-a-comma-for-multiple-options>
|
29
29
|
Skip Options:
|
@@ -32,7 +32,7 @@ List of commands:
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def GENERATE_MODEL_CONTROLLER_HELP_STRING
|
35
|
-
opts = skip_model_controller_options.
|
35
|
+
opts = skip_model_controller_options.keys.map { |e| "\t=> #{e.to_s}" }
|
36
36
|
"This command runs the same as 'rails generate model --help'.
|
37
37
|
|
38
38
|
Use the parameters in 'rails generate model' to generate your CRUD operators.
|
data/lib/constants/options.rb
CHANGED
data/lib/utils/rails_methods.rb
CHANGED