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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 869bf4e4aef3dfc4c2e799b108ba182f87e700c1627235e1b2351ed525378298
4
- data.tar.gz: f4d2a4923ef066ebfcc305cffcb4451450fbe55db1e525d8f2f656b9a63f4678
3
+ metadata.gz: 79e060621e3223010ebd62ec76daa8665c3402c7ef72816735eb5f4d6555ce85
4
+ data.tar.gz: 2d744aaa383e59b2b7f591acb1f74e255b50903e839fb4b7d17646310c50087d
5
5
  SHA512:
6
- metadata.gz: 7c6aee61bbd5b4cdfb2af12a2f2702c0e8fcc9dbec077542bf5d9e7e4874b351b6d88e70f231ec067fa2e0fe4a92fb3be21ba7b625efcd96258934915f3e63bf
7
- data.tar.gz: fd1bf6ff431699669605de1bceb8a469e796f8989abc7cae12a0c22177621a4b109183564743f7a6669e8ec7e4438797f19a7b8ba9b817b10a0241dab3e08548
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
@@ -1,10 +1,3 @@
1
1
  class {{ MODEL }}Controller < GlobalController
2
2
 
3
- def model
4
- {{ MODEL }}
5
- end
6
-
7
- def render_params
8
- handle_params({{ PARAMS }})
9
- end
10
3
  end
@@ -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 #{MODEL_NAME} #{MODEL_PARAMS.join(' ')}") if !SKIP_MODEL
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
- PARAMS_STRING = MODEL_PARAMS.map do |item|
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
- raise StandardError, 'Define a model'
15
+ self.class.to_s.chomp("Controller").singularize.constantize
16
16
  end
17
17
 
18
18
  def render_params
19
- raise StandardError, 'Define your render_params'
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.stringify_keys.keys.map { |e| "\t=> #{e}" }
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.stringify_keys.keys.map { |e| "\t=> #{e}" }
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.
@@ -2,7 +2,7 @@ class CLIOptions
2
2
  class <<self
3
3
 
4
4
  def gem_version
5
- "0.0.18"
5
+ "0.1.2"
6
6
  end
7
7
 
8
8
  def ascii_art
@@ -6,6 +6,13 @@ class String
6
6
  tr("-", "_").
7
7
  downcase
8
8
  end
9
+
10
+ def camelize
11
+ self.split(/(?=[A-Z])|(_)/)
12
+ .reject { |e| e == '_' }
13
+ .map(&:capitalize)
14
+ .join('')
15
+ end
9
16
  end
10
17
 
11
18
  def true?(obj)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aidan Miles