Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scaffold generator #1266

Open
wants to merge 1 commit into
base: release-0-9
Choose a base branch
from

Conversation

jamesconant
Copy link

@jamesconant jamesconant commented Jun 28, 2019

Warning! - Work-in-progress

  • scaffolds: models, resources, controllers, routes
  • change resource templates to .erb for better syntax highlighting support

resolves: #1265

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

New Feature Submissions:

  • I've submitted an issue that describes this feature, and received the go ahead from the maintainers.
  • My submission includes new tests.
  • My submission maintains compliance with JSON:API.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

Test Plan:

TODO

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

* scaffolds: models, resources, controllers, routes
* change resource templates to .erb for better syntax highlighting support

resolves: cerebris#1265
@@ -2,7 +2,7 @@ module Jsonapi
class ControllerGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)

def create_resource
def create_controller
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] Is the intention for these generators to refer to "resource" more generally, i.e. any kind of MVC element, or was it referring to a "resource" in the sense of the resource classes created and relied on by this library?

@@ -0,0 +1,120 @@
module Jsonapi
Copy link
Author

@jamesconant jamesconant Jun 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] In an effort to keep this simple, I've not broken the generators out in to sub-generators in called them from one meta-generator method. I'm not opposed to breaking them out if folks feel strongly about that.

if namespace_path.present?
@application_record_class = application_record_class
path = namespaced_file_path(models_path, 'application_record.rb')
template 'application_record.erb', path
Copy link
Author

@jamesconant jamesconant Jun 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] I noticed in the generators that already exist here that file paths for templates are ran through File, and I was wondering if that was a best practice that I was not aware of, or what the utility in doing so is? Would there not be an error with or without its use that points out that the file does not exist?

@jamesconant
Copy link
Author

[question] I also noticed that the templates that already exist include a jsonapi_ prefix and I was curious if that was a convention, or just incidental?

@kevintraver
Copy link
Contributor

It would also be awesome if any field parameters for the model would be automatically added as attributes in the generated JSONAPI::Resource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants