json_voorhees 1.0.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -48
  3. data/lib/generators/json_voorhees/app_environment/USAGE +8 -0
  4. data/lib/generators/json_voorhees/app_environment/app_environment_generator.rb +93 -0
  5. data/lib/generators/json_voorhees/app_make_admin/app_make_admin_generator.rb +19 -34
  6. data/lib/generators/json_voorhees/app_make_tests/app_make_tests_generator.rb +5 -19
  7. data/lib/generators/json_voorhees/app_make_user/app_make_user_generator.rb +13 -73
  8. data/lib/generators/json_voorhees/app_scaffold/app_scaffold_generator.rb +2 -12
  9. data/lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb +1 -6
  10. data/lib/generators/json_voorhees/engine_scaffold/engine_scaffold_generator.rb +3 -12
  11. data/lib/generators/json_voorhees/massive_scaffold/massive_scaffold_generator.rb +12 -28
  12. data/lib/generators/json_voorhees/setup_app/setup_app_generator.rb +32 -97
  13. data/lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb +8 -23
  14. data/lib/generators/json_voorhees/setup_engine/setup_engine_generator.rb +0 -3
  15. data/lib/json_voorhees/version.rb +1 -1
  16. data/test/fresh_copy/test_app/Gemfile +12 -17
  17. data/test/fresh_copy/test_app/Gemfile.lock +56 -61
  18. data/test/fresh_copy/test_app/Rakefile +1 -1
  19. data/test/fresh_copy/test_app/app/assets/stylesheets/application.css +5 -3
  20. data/test/fresh_copy/test_app/app/views/layouts/application.html.erb +2 -2
  21. data/test/fresh_copy/test_app/bin/rails +4 -0
  22. data/test/fresh_copy/test_app/bin/rake +4 -0
  23. data/test/fresh_copy/test_app/bin/spring +18 -0
  24. data/test/fresh_copy/test_app/config/database.yml +8 -8
  25. data/test/fresh_copy/test_app/config/environment.rb +1 -1
  26. data/test/fresh_copy/test_app/config/environments/development.rb +10 -2
  27. data/test/fresh_copy/test_app/config/environments/production.rb +7 -9
  28. data/test/fresh_copy/test_app/config/environments/test.rb +5 -2
  29. data/test/fresh_copy/test_app/config/initializers/assets.rb +8 -0
  30. data/test/fresh_copy/test_app/config/initializers/cookies_serializer.rb +3 -0
  31. data/test/fresh_copy/test_app/config/initializers/mime_types.rb +0 -1
  32. data/test/fresh_copy/test_app/config/initializers/session_store.rb +1 -1
  33. data/test/fresh_copy/test_app/config/routes.rb +1 -1
  34. data/test/fresh_copy/test_app/config/secrets.yml +22 -0
  35. data/test/fresh_copy/test_app/public/404.html +20 -11
  36. data/test/fresh_copy/test_app/public/422.html +20 -11
  37. data/test/fresh_copy/test_app/public/500.html +19 -10
  38. data/test/fresh_copy/test_app/test/test_helper.rb +1 -6
  39. data/test/lib/generators/json_voorhees/app_environment_generator_test.rb +16 -0
  40. metadata +15 -21
  41. data/lib/generators/json_voorhees/app_make_admin/templates/views/admin_home_no_user +0 -1
  42. data/lib/generators/json_voorhees/app_make_tests/templates/no_auth_request.rb.erb +0 -114
  43. data/lib/generators/json_voorhees/app_make_user/templates/active_admin_register.rb.erb +0 -83
  44. data/lib/generators/json_voorhees/app_make_user/templates/user/include_authorization.rb +0 -4
  45. data/lib/generators/json_voorhees/app_make_user/templates/user/specs/factory_girl.rb +0 -14
  46. data/lib/generators/json_voorhees/app_make_user/templates/user/specs/model_specs.rb +0 -61
  47. data/lib/generators/json_voorhees/app_make_user/templates/user/specs/no_arcadex_request_specs.rb +0 -85
  48. data/lib/generators/json_voorhees/app_make_user/templates/user/specs/request_specs.rb +0 -244
  49. data/lib/generators/json_voorhees/app_make_user/templates/user/specs/route_specs.rb +0 -91
  50. data/lib/generators/json_voorhees/app_make_user/templates/user/user_authorizations.rb +0 -92
  51. data/lib/generators/json_voorhees/app_make_user/templates/user/user_controller.rb +0 -169
  52. data/lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb +0 -35
  53. data/lib/generators/json_voorhees/app_make_user/templates/user/user_routes.rb +0 -32
  54. data/lib/generators/json_voorhees/app_make_user/templates/user/user_serializer.rb +0 -43
  55. data/lib/generators/json_voorhees/engine_create_controller/templates/no_auth_controller_template.rb.erb +0 -61
  56. data/lib/generators/json_voorhees/setup_app/templates/api_controller_no_arcadex.rb +0 -33
  57. data/test/fresh_copy/test_app/config/initializers/secret_token.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2c926864334abb5b22eb0fc430e9055a048dffc
4
- data.tar.gz: 3813492073e69ea5b0b3db2c032c58dda4c42a18
3
+ metadata.gz: 91bf14314c7a2f79af77af90bfa0a863e526b974
4
+ data.tar.gz: ebfc93743fa9afe4aed1720ef3ce45bdc50d9849
5
5
  SHA512:
6
- metadata.gz: 579cf7928420d787ecd5a9faaa7eaabb9b51b7e87b41bec0edb153ded265d96eebf4703dc5ba8912db88edcc09383559d0005228d76509b574e1f1b792bfbfc6
7
- data.tar.gz: dcfb1a56bd048626ef630a5bee36013924d7442b753fcfc3acf0aef983d76e93992cfa149ca7669d5b3a81270bf014a158b57e4a85efe407a9b362f77dfa0fdd
6
+ metadata.gz: 5a78ccf46ca1aa2b1e460af590b1ecfbc67043fddaa585f3e9aa67b41f60220a494056cf6ca2b2883db60ced09260de56d63a0a5323e51239bd6aa8e4c5bb622
7
+ data.tar.gz: 93f2da6370b2b17f06ac1a840b152a93de811639113f34531c277d52606c88fcaaa584bad3d3a0ff607a36266500e154f208462c14005ab01ca188b51635a719
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # JsonVoorhees 1.0.0
1
+ # JsonVoorhees 1.3.0
2
2
 
3
3
  ## Introduction
4
4
 
@@ -15,10 +15,6 @@ To install, put this in your main_app and run bundle install.
15
15
  ```bash
16
16
  gem "json_voorhees"
17
17
  ```
18
- To setup your application use the command below. It takes options that allow you
19
- to do things like skip active_admin, skip a generic admin page, skip arcadex, and even
20
- skip a user class. The default runs with active_admin, a user class and arcadex.
21
-
22
18
  ```bash
23
19
  rails g json_voorhees:setup_app
24
20
  ```
@@ -47,31 +43,11 @@ rails g json_voorhees:massive_scaffold chat message 1 user_id:integer message:te
47
43
  2. (in main_app root) rails g json_voorhees:setup_app
48
44
  3. (in main_app root) rails g json_voorhees:create_engine [engine name]
49
45
  4. (in main_app root) rails g json_voorhees:massive_scaffold [engine name] [resource name] [api_version] [field:type field:type]
50
- 5. (in main_app root) Copy migrations to main app and run db migrations in main app like so. "rake railties:install:migrations && rake db:migrate RAILS_ENV=development"
46
+ 5. (in main_app root) Copy migrations to main app and run db migrations in main app like so. "rake railties:install:migrations && rake db:migrate RAILS_ENV=development && rake db:migrate RAILS_ENV=test"
51
47
  6. (in main_app root) Run "rspec" to check for errors
52
48
 
53
49
  I usually set the app up, and then design the database. I make a list of all the models I need, then separate them into engines. Then I run 20 or so massive scaffolds using "&&". The result is a modular functioning backend that only needs the model relationships wired together. The default tests get you pretty far.
54
50
 
55
- ## Individual Generator Use
56
-
57
- If massive scaffold is too bulky for you, you have the option of running the
58
- generators individually. Use rails g to see the generators that come with
59
- the gem and the options. They each have a multitude of arguments and options.
60
-
61
- 1. rails g json_voorhees:app_make_admin
62
- 2. rails g json_voorhees:app_make_authorizations
63
- 3. rails g json_voorhees:app_make_tests
64
- 4. rails g json_voorhees:app_make_user
65
- 5. rails g json_voorhees:app_scaffold
66
- 6. rails g json_voorhees:engine_create_controller
67
- 7. rails g json_voorhees:engine_create_model
68
- 8. rails g json_voorhees:engine_create_serializer
69
- 9. rails g json_voorhees:engine_scaffold
70
- 10. rails g json_voorhees:massive_scaffold
71
- 11. rails g json_voorhees:setup_app
72
- 12. rails g json_voorhees:setup_engine
73
- 13. rails g json_voorhees:create_engine
74
-
75
51
  ## Versioning
76
52
 
77
53
  This generator is strongly tied in with versioning. As so every
@@ -79,30 +55,23 @@ model, controller, serializer, test and factory created with this tool are
79
55
  versioned. The main app hosts the application controllers and test suite. Everything
80
56
  else resides in engines for good modularity.
81
57
 
82
- ## Recent Additions
83
-
84
- Create the create_engine generator and made hooking the engine up to the main_app painless.
85
-
86
- ## Reminder
58
+ ## Gotchas and Reminders
87
59
 
88
- For more granular control over tokens and the admin user,
89
- clone the github repos into the engines folder and point your
90
- gem file to that. Edit what you want.
60
+ 1. Make sure the version of Rails is the same in both engine and app.
61
+ 2. The mailer doesn't need to be set up. For test and development it is set so this doesn't have to be the case but change the environment config file to make it work.
62
+ 3. To user the mailer, make sure to export GMAIL_USERNAME and GMAIL_PASSWORD to your environment. Or you can just overwrite the values in the environment config file.
63
+ 4. To use gmail, your account needs to have an app_password. That is the password that should go on file.
64
+ 5. Account mailer in the people engine needs to be updated with the correct domain as well the host in application.rb config file for production.
65
+ 6. The account controller isn't under the api, forgotten_passwords etc should be implemented on the server.
91
66
 
92
- To setup admin restrictions, use the attributes for the admin
93
- class and put before_filters before all of the CRUD actions.
94
- Make sure the current_user has the correct permissions.
67
+ Does not work with Rails 4.2 yet. Byebug is added by default and this generator tries to add it twice.
95
68
 
96
- If active admin is used (it is by default) the admin section username is admin and password is password. Otherwise the password is password123.
69
+ ##Future
97
70
 
98
- ## To Do
71
+ 1. Sidekiq
72
+ 2. Paperclip
73
+ 3. Websockets
74
+ 4. Facebook support
99
75
 
100
- 1. Maybe give an option to include pagination?
101
- 2. Option for websockets and paperclip?
102
- 3. Make the non defaults easier to user
103
- 4. Use Devise as the default user and admin user? This will make it easier for users to reset their password as this is already setup.
104
- 5. Git clone arcadex, type_validator and defcon to make it easier for users to customize?
105
- 6. Move the people engine into it's own gem?
106
- 7. Create a whenever task to destroy expired tokens.
107
- 8. Fix the breadcrumbs link in ActiveAdmin.
108
- 9. Add a mailgun and support for forgotten passwords
76
+ Emails are sent synchronously for now. I'm waiting for ActiveJob in Rails 4.2 so I can
77
+ implement that interface and user the sidekiq adapter.
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate app_environment Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,93 @@
1
+ module JsonVoorhees
2
+ class AppEnvironmentGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def sprint
6
+ createDev
7
+ createTest
8
+ createPro
9
+ addToApplication
10
+ end
11
+
12
+ private
13
+
14
+ def addToApplication
15
+ inject_into_file 'config/application.rb', after: "class Application < Rails::Application\n" do <<-'RUBY'
16
+
17
+ #So url_for works in the mailer
18
+ config.action_mailer.default_url_options = { host: 'localhost:3000' }
19
+ config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors" do
20
+ allow do
21
+ origins '*'
22
+ resource '*', :headers => :any, :methods => [:get, :post, :put, :delete, :options]
23
+ end
24
+ end
25
+
26
+ RUBY
27
+ end
28
+ end
29
+
30
+ def createDev
31
+ gsub_file "config/environments/development.rb", "config.action_mailer.raise_delivery_errors = false\n", "#config.action_mailer.raise_delivery_errors = false\n"
32
+ inject_into_file 'config/environments/development.rb', after: "configure do\n" do <<-'RUBY'
33
+
34
+ config.action_mailer.perform_deliveries = true
35
+ config.action_mailer.raise_delivery_errors = false
36
+ config.action_mailer.default_options = {from: ENV['GMAIL_USERNAME']}
37
+ config.action_mailer.delivery_method = :smtp
38
+ config.action_mailer.smtp_settings = {
39
+ address: 'smtp.gmail.com',
40
+ port: 587,
41
+ domain: 'localhost:3000',
42
+ user_name: ENV['GMAIL_USERNAME'],
43
+ password: ENV['GMAIL_PASSWORD'],
44
+ authentication: 'plain',
45
+ enable_starttls_auto: true }
46
+
47
+ RUBY
48
+ end
49
+ end
50
+
51
+ def createTest
52
+ gsub_file "config/environments/test.rb", "config.action_mailer.delivery_method = :test\n", "#config.action_mailer.delivery_method = :test\n"
53
+ inject_into_file 'config/environments/test.rb', after: "configure do\n" do <<-'RUBY'
54
+
55
+ #config.action_mailer.perform_deliveries = false
56
+ config.action_mailer.raise_delivery_errors = true
57
+ config.action_mailer.default_options = {from: 'testing123@example.com'}
58
+ # Emails get sent here ::ActionMailer::Base.deliveries array.
59
+ config.action_mailer.delivery_method = :test
60
+ config.action_mailer.smtp_settings = {
61
+ address: 'smtp.gmail.com',
62
+ port: 587,
63
+ domain: 'localhost:3000',
64
+ user_name: 'testing123',
65
+ password: 'testing123',
66
+ authentication: 'plain',
67
+ enable_starttls_auto: true }
68
+
69
+ RUBY
70
+ end
71
+ end
72
+
73
+ def createPro
74
+ inject_into_file 'config/environments/production.rb', after: "configure do\n" do <<-'RUBY'
75
+
76
+ config.action_mailer.perform_deliveries = true
77
+ config.action_mailer.raise_delivery_errors = true
78
+ config.action_mailer.default_options = {from: ENV['GMAIL_USERNAME']}
79
+ config.action_mailer.delivery_method = :smtp
80
+ config.action_mailer.smtp_settings = {
81
+ address: 'smtp.gmail.com',
82
+ port: 587,
83
+ domain: 'example.com',
84
+ user_name: ENV['GMAIL_USERNAME'],
85
+ password: ENV['GMAIL_PASSWORD'],
86
+ authentication: 'plain',
87
+ enable_starttls_auto: true }
88
+
89
+ RUBY
90
+ end
91
+ end
92
+ end
93
+ end
@@ -1,21 +1,31 @@
1
1
  module JsonVoorhees
2
2
  class AppMakeAdminGenerator < Rails::Generators::Base
3
3
  source_root File.expand_path('../templates', __FILE__)
4
- class_option :arcadex, :type => :boolean, :default => true, :description => "Include arcadex gem and authentication in api_controller"
5
- class_option :user, :type => :boolean, :default => true, :description => "Create an admin page with user class"
6
- class_option :active_admin, :type => :boolean, :default => true, :description => "Setup the active_admin gem, the gem needs to be already added"
7
4
 
8
5
  def sprint
9
- if options.active_admin?
10
- make_active_admin
11
- make_dashboard
12
- else
13
- make_admin
14
- end
6
+ clone_engine
7
+ insert_defcon_engine
8
+ make_active_admin
9
+ make_dashboard
15
10
  end
16
11
 
17
12
  private
18
13
 
14
+ def clone_engine
15
+ run "git clone https://github.com/cleor41/defcon.git"
16
+ run "mv defcon engines/defcon"
17
+ run "rm -rf engines/defcon/.git"
18
+ end
19
+
20
+ def insert_defcon_engine
21
+ inject_into_file 'Gemfile', after: "source \'https://rubygems.org\'\n" do <<-'RUBY'
22
+
23
+ gem 'defcon', :path => "engines/defcon"
24
+
25
+ RUBY
26
+ end
27
+ end
28
+
19
29
  def make_dashboard
20
30
  run "rm -f app/admin/dashboard.rb"
21
31
  copy_file "dashboard.rb.erb", "app/admin/dashboard.rb"
@@ -70,30 +80,5 @@ module JsonVoorhees
70
80
  end
71
81
  end
72
82
 
73
- def make_admin
74
- if options.user? && options.arcadex?
75
- #copy admin page with user engine
76
- copy_file "views/admin_home_with_user", "app/views/main/admin.html.erb"
77
- else
78
- #copy admin page without user engine
79
- copy_file "views/admin_home_no_user", "app/views/main/admin.html.erb"
80
- end
81
- run "rm -f app/views/layouts/application.html.erb"
82
- copy_file "views/application", "app/views/layouts/application.html.erb"
83
- template "views/_header.html.erb", "app/views/layouts/_header.html.erb"
84
- copy_file "views/_footer.html.erb", "app/views/layouts/_footer.html.erb"
85
- inject_into_file 'app/controllers/application_controller.rb', after: "protect_from_forgery with: :exception\n" do <<-'RUBY'
86
-
87
- #This needs to be put inside a config file. but this is good for now
88
- #This only requires the password for the admin section of the website
89
- http_basic_authenticate_with name: "admin", password: "password"
90
-
91
- RUBY
92
- end
93
- run "rm -f app/assets/stylesheets/application.css"
94
- copy_file "views/application.css.scss", "app/assets/stylesheets/application.css.scss"
95
- append_file "app/assets/javascripts/application.js", "//= require bootstrap-sprockets"
96
- end
97
-
98
83
  end
99
84
  end
@@ -5,27 +5,13 @@ module JsonVoorhees
5
5
  argument :resource_name, :type => :string
6
6
  argument :api_version, :type => :string, :default => "1"
7
7
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
8
- class_option :model, :type => :boolean, :default => true, :description => "Create model stub tests"
9
- class_option :request, :type => :boolean, :default => true, :description => "Create request stub tests"
10
- class_option :routing, :type => :boolean, :default => true, :description => "Create routing stub tests"
11
- class_option :arcadex, :type => :boolean, :default => true, :description => "Send requests with an arcadex header"
12
8
 
13
9
  def sprint
14
- if options.model?
15
- template "model.rb.erb", "spec/engines/#{module_snake}/api/v#{api_version}/models/#{resource_singular}_spec.rb"
16
- end
17
- if options.request?
18
- if options.arcadex?
19
- template "request.rb.erb", "spec/engines/#{module_snake}/api/v#{api_version}/requests/#{resource_singular}_spec.rb"
20
- else
21
- template "no_auth_request.rb.erb", "spec/engines/#{module_snake}/api/v#{api_version}/requests/#{resource_singular}_spec.rb"
22
- end
23
- end
24
- if options.routing?
25
- template "routing.rb.erb", "spec/engines/#{module_snake}/api/v#{api_version}/routing/#{resource_singular}_spec.rb"
26
- end
27
- template "factory.rb.erb", "spec/factories/#{module_snake}_#{resource_singular}_#{api_version}_factory.rb"
28
- end
10
+ template "model.rb.erb", "spec/engines/#{module_snake}/api/v#{api_version}/models/#{resource_singular}_spec.rb"
11
+ template "request.rb.erb", "spec/engines/#{module_snake}/api/v#{api_version}/requests/#{resource_singular}_spec.rb"
12
+ template "routing.rb.erb", "spec/engines/#{module_snake}/api/v#{api_version}/routing/#{resource_singular}_spec.rb"
13
+ template "factory.rb.erb", "spec/factories/#{module_snake}_#{resource_singular}_#{api_version}_factory.rb"
14
+ end
29
15
 
30
16
  private
31
17
 
@@ -1,92 +1,32 @@
1
1
  module JsonVoorhees
2
2
  class AppMakeUserGenerator < Rails::Generators::Base
3
3
  source_root File.expand_path('../templates', __FILE__)
4
- class_option :arcadex, :type => :boolean, :default => true, :description => "Include arcadex tokens"
5
- class_option :active_admin, :type => :boolean, :default => true, :description => "Include admin scoping in routes file"
6
4
 
7
5
  def sprint
8
6
  people
9
- if options.active_admin?
10
- #run "rails g active_admin:resource people::user"
11
- custom_active_admin
12
- end
13
7
  end
14
8
 
15
9
  private
16
10
 
17
- def custom_active_admin
18
- template "active_admin_register.rb.erb", "app/admin/people_user.rb"
19
- end
20
-
21
- def people
22
- run "rails plugin new engines/people --mountable"
23
- inside('engines/people') do
24
- #This needs to run the generator for setting up engines
25
- run "rails g json_voorhees:setup_engine people"
26
- add_generator
27
- #Now it needs to create the user class
28
- run "rails g scaffold user username:string:uniq email:string:uniq password_digest:string"
29
- #Add this to the routes and gemfile
30
- add_ordering
31
- end
32
- #Need to add the engine to the main_apps gemfile
33
- route "mount People::Engine, at: \'/\'"
34
- copy_user_files_over
35
- if options.arcadex?
11
+ def people
12
+ run "git clone https://github.com/cleor41/people.git"
13
+ run "mv people engines/people"
14
+ run "rm -rf engines/people/.git"
15
+ #Need to add the engine to the main_apps gemfile
16
+ route "mount People::Engine, at: \'/\'"
36
17
  route "mount Arcadex::Engine, at: \'/\'"
18
+ insert_people_engine
19
+ run "rails g people:all"
37
20
  end
38
- insert_people_engine
39
- end
40
-
41
- def add_ordering
42
- #app/models/people/user.rb
43
- inject_into_file "app/models/people/user.rb", after: "class User < ActiveRecord::Base\n" do <<-'RUBY'
44
21
 
45
- def self.recent(num)
46
- ::People::User.order("created_at DESC").limit(num)
47
- end
48
-
49
- RUBY
50
- end
51
- end
22
+ def insert_people_engine
23
+ inject_into_file 'Gemfile', after: "source \'https://rubygems.org\'\n" do <<-'RUBY'
52
24
 
53
- def add_generator
54
- inject_into_file "people.gemspec", after: "s.test_files = Dir[\"test/**/*\"]\n" do <<-'RUBY'
55
-
56
- s.add_development_dependency "json_voorhees"
25
+ gem 'people', :path => "engines/people"
57
26
 
58
- RUBY
27
+ RUBY
28
+ end
59
29
  end
60
- end
61
-
62
- def insert_people_engine
63
- inject_into_file 'Gemfile', after: "source \'https://rubygems.org\'\n" do <<-'RUBY'
64
-
65
- gem 'people', :path => "engines/people"
66
-
67
- RUBY
68
- end
69
- end
70
-
71
- def copy_user_files_over
72
- template "user/user_authorizations.rb", "gems/authorization/lib/authorization/people/v1/user.rb"
73
- run "rm -f gems/authorization/lib/authorization.rb"
74
- template "user/include_authorization.rb", "gems/authorization/lib/authorization.rb"
75
- template "user/user_controller.rb", "engines/people/app/controllers/people/api/v1/users_controller.rb"
76
- #run "rm -f engines/people/app/models/people/user.rb"
77
- template "user/user_model.rb", "engines/people/app/models/people/v1/user.rb"
78
- run "rm -f engines/people/config/routes.rb"
79
- template "user/user_routes.rb", "engines/people/config/routes.rb"
80
- template "user/user_serializer.rb", "engines/people/app/serializers/people/v1/user_serializer.rb"
81
- template "user/specs/factory_girl.rb", "spec/factories/people_user_1_factory.rb"
82
- template "user/specs/model_specs.rb", "spec/engines/people/api/v1/models/user_spec.rb"
83
- if options.arcadex?
84
- template "user/specs/request_specs.rb", "spec/engines/people/api/v1/requests/user_spec.rb"
85
- else
86
- template "user/specs/no_arcadex_request_specs.rb", "spec/engines/people/api/v1/requests/user_spec.rb"
87
- end
88
- template "user/specs/route_specs.rb", "spec/engines/people/api/v1/routing/user_spec.rb"
89
- end
90
30
 
91
31
  end
92
32
  end
@@ -5,20 +5,10 @@ module JsonVoorhees
5
5
  argument :resource_name, :type => :string
6
6
  argument :api_version, :type => :string, :default => "1"
7
7
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
8
- class_option :model, :type => :boolean, :default => true, :description => "Create model stub tests"
9
- class_option :request, :type => :boolean, :default => true, :description => "Create request stub tests"
10
- class_option :routing, :type => :boolean, :default => true, :description => "Create routing stub tests"
11
- class_option :arcadex, :type => :boolean, :default => true, :description => "Send requests with an arcadex header"
12
-
13
8
 
14
9
  def sprint
15
- if options.arcadex?
16
- run "rails g json_voorhees:app_make_authorizations #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
17
- run "rails g json_voorhees:app_make_tests #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
18
- else
19
- run "rails g json_voorhees:app_make_authorizations #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")} --skip-arcadex"
20
- run "rails g json_voorhees:app_make_tests #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")} --skip-arcadex"
21
- end
10
+ run "rails g json_voorhees:app_make_authorizations #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
11
+ run "rails g json_voorhees:app_make_tests #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
22
12
  end
23
13
 
24
14
  private
@@ -5,14 +5,9 @@ module JsonVoorhees
5
5
  argument :resource_name, :type => :string
6
6
  argument :api_version, :type => :string, :default => "1"
7
7
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
8
- class_option :arcadex, :type => :boolean, :default => true, :description => "Include authorization in controller"
9
8
 
10
9
  def sprint
11
- if options.arcadex?
12
- template "controller_template.rb.erb", "app/controllers/#{module_name.underscore}/api/v#{api_version}/#{resource_plural}_controller.rb"
13
- else
14
- template "no_auth_controller_template.rb.erb", "app/controllers/#{module_name.underscore}/api/v#{api_version}/#{resource_plural}_controller.rb"
15
- end
10
+ template "controller_template.rb.erb", "app/controllers/#{module_name.underscore}/api/v#{api_version}/#{resource_plural}_controller.rb"
16
11
  end
17
12
 
18
13
  private
@@ -5,20 +5,11 @@ module JsonVoorhees
5
5
  argument :resource_name, :type => :string
6
6
  argument :api_version, :type => :string, :default => "1"
7
7
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
8
- class_option :arcadex, :type => :boolean, :default => true, :description => "Include authorization in controller"
9
- class_option :model, :type => :boolean, :default => true, :description => "Create namespaced model"
10
8
 
11
9
  def sprint
12
- if options.arcadex?
13
- run "rails g json_voorhees:engine_create_controller #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
14
- run "rails g json_voorhees:engine_create_serializer #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
15
- else
16
- run "rails g json_voorhees:engine_create_controller #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")} --skip-arcadex"
17
- run "rails g json_voorhees:engine_create_serializer #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")} --skip-arcadex"
18
- end
19
- if options.model?
20
- run "rails g json_voorhees:engine_create_model #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
21
- end
10
+ run "rails g json_voorhees:engine_create_controller #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
11
+ run "rails g json_voorhees:engine_create_serializer #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
12
+ run "rails g json_voorhees:engine_create_model #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
22
13
  end
23
14
 
24
15
  private
@@ -5,47 +5,31 @@ module JsonVoorhees
5
5
  argument :resource_name, :type => :string
6
6
  argument :api_version, :type => :string, :default => "1"
7
7
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
8
- class_option :both, :type => :boolean, :default => true, :description => "Run the rails scaffold in addition to this one"
9
- class_option :model, :type => :boolean, :default => true, :description => "Create model stub tests"
10
- class_option :request, :type => :boolean, :default => true, :description => "Create request stub tests"
11
- class_option :routing, :type => :boolean, :default => true, :description => "Create routing stub tests"
12
- class_option :arcadex, :type => :boolean, :default => true, :description => "Send requests with an arcadex header"
13
- class_option :active_admin, :type => :boolean, :default => true, :description => "Generate the admin resource"
14
8
 
15
9
  def sprint
16
10
  inside "engines/#{module_name.underscore}" do
17
- if options.both?
18
- # We should skip making the migration if this is not version 1
19
- if api_version != "1"
20
- run "rails g scaffold #{resource_name} #{attributes.join(" ")} --no-migration "
21
- else
22
- run "rails g scaffold #{resource_name} #{attributes.join(" ")}"
23
- end
24
- end
25
- if options.arcadex?
26
- run "rails g json_voorhees:engine_scaffold #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
11
+ # We should skip making the migration if this is not version 1
12
+ # Chaned scaffold to model here, dont need the other routes
13
+ if api_version != "1"
14
+ run "rails g model #{resource_name} #{attributes.join(" ")} --no-migration "
27
15
  else
28
- run "rails g json_voorhees:engine_scaffold #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")} --skip-arcadex"
16
+ run "rails g model #{resource_name} #{attributes.join(" ")}"
29
17
  end
18
+ run "rails g json_voorhees:engine_scaffold #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
30
19
  correct_routes
31
20
  end
32
- if options.arcadex?
33
- run "rails g json_voorhees:app_scaffold #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
34
- else
35
- run "rails g json_voorhees:app_scaffold #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")} --skip-arcadex"
36
- end
37
- if options.active_admin?
38
- #run "rails generate active_admin:resource #{module_name.underscore.downcase}::#{resource_name.singularize.underscore.downcase}"
39
- make_custom_active_admin
40
- end
21
+ run "rails g json_voorhees:app_scaffold #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
22
+ #run "rails generate active_admin:resource #{module_name.underscore.downcase}::#{resource_name.singularize.underscore.downcase}"
23
+ make_custom_active_admin
41
24
 
42
25
  end
43
26
 
44
27
  private
45
28
 
46
29
  def correct_routes
47
- gsub_file 'config/routes.rb', "resources :#{resource_plural}", "#resources :#{resource_plural}"
48
- gsub_file 'config/routes.rb', "scope '1' do\n", "scope '1' do\nresources :#{resource_plural}, controller: \'api/v1/#{resource_plural}\'\n"
30
+ #Don't have to comment out the old routes, they aren't created anymore. Also stopped new and edit from being created
31
+ #gsub_file 'config/routes.rb', "resources :#{resource_plural}", "#resources :#{resource_plural}"
32
+ gsub_file 'config/routes.rb', "scope '1' do\n", "scope '1' do\n\t\t\tresources :#{resource_plural}, except: [:new, :edit], controller: \'api/v1/#{resource_plural}\'\n"
49
33
  end
50
34
 
51
35
  def make_custom_active_admin