Skip to content

add Rails generators#176

Merged
philipqnguyen merged 5 commits intoprocore-oss:masterfrom
wlkrw:add-generator
Dec 19, 2019
Merged

add Rails generators#176
philipqnguyen merged 5 commits intoprocore-oss:masterfrom
wlkrw:add-generator

Conversation

@wlkrw
Copy link
Copy Markdown
Contributor

@wlkrw wlkrw commented Aug 19, 2019

Hello and thanks for making Blueprinter.

I made this for #121

Would YARD doc additions be needed or is in this case the rails g blueprinter:blueprint --help output sufficient?

@wlkrw
Copy link
Copy Markdown
Contributor Author

wlkrw commented Aug 19, 2019

ok, I'll fix for old rubies

@ingeniousgenius
Copy link
Copy Markdown

Hey, what's the story with this?

@wlkrw
Copy link
Copy Markdown
Contributor Author

wlkrw commented Sep 25, 2019

@jesster2k10 I've been offline for a couple weeks, and I don't know that there is much of a story to tell but if you are still interested you can always bundle with my fork and play with the generator this would add. It can introspect on the ActiveRecord model you pass it or just take command flags to write a blueprinter for the model.

Copy link
Copy Markdown
Contributor

@philipqnguyen philipqnguyen left a comment

Choose a reason for hiding this comment

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

@wlkrw Thank you very much for this PR (and sorry for the slow response), I'm really excited for this feature. I have a number of comments below.




class_option :identifier, default: nil, desc: "Add an identifer to the generated blueprint, either uses :id or your specified value", aliases: "-i", banner: "id"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This --identifier option if specified with an argument does not seem to be working. It generates the blueprint, but without the specified identifier. It does set the default :id if no argument is given.

Comment thread lib/generators/blueprinter/blueprint_generator.rb Outdated
Comment thread spec/generators/blueprint_generator_spec.rb
Comment thread spec/generators/blueprint_generator_spec.rb Outdated
Comment thread spec/generators/blueprint_generator_spec.rb Outdated
Comment thread lib/generators/blueprinter/blueprint_generator.rb
Comment thread lib/generators/blueprinter/blueprint_generator.rb

end
end
end
Copy link
Copy Markdown
Contributor

@philipqnguyen philipqnguyen Oct 2, 2019

Choose a reason for hiding this comment

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

Would you make a separate PR for the initializers generator? Reasoning is that I would like to have a more thorough discussion regarding generating initializers and the default configurations, and I don't want to have that block the rest of this PR. Currently, I think it's not very useful to generate an empty initializer by default.

Blueprinter.configure do |config|
end

Rather I'd like to have the initializer generator to generate all the defaults configs of blueprinter, with code comments showing potential options.
Something like

Blueprinter.configure do |config|
  # The default generator is JSON. You may replace it with OJ or Yajil as well.
  config.generator = JSON

  # more defaults and code comments below
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sounds good. I took that part out. I'll wait for the next pr until this is ready to merge in case I drop off the internet again ;)

@wlkrw
Copy link
Copy Markdown
Contributor Author

wlkrw commented Dec 3, 2019

@philipqnguyen I believe I've addressed all your change requests. Thanks for your patience.

Copy link
Copy Markdown
Contributor

@philipqnguyen philipqnguyen left a comment

Choose a reason for hiding this comment

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

@wlkrw thanks for working on this.

Comment thread lib/generators/blueprinter/blueprint_generator.rb
end

def indent
user_intended = {two: " ", four: " ", tab:"\t"}[options["indentation"].intern]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: should this be user_indented?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can be followed up after

@philipqnguyen philipqnguyen merged commit 5228ca1 into procore-oss:master Dec 19, 2019
@wlkrw wlkrw mentioned this pull request Jan 21, 2020
@hugopeixoto hugopeixoto mentioned this pull request May 12, 2020
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.

5 participants