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

Require config environment over rails runner #11399

Merged

Conversation

jrafanie
Copy link
Member

Benefits:

ruby tools/purge_orphaned_tag_values.rb -s 100

Or, the old way:
bin/rails runner tools/purge_orphaned_tag_values.rb -- -s 100

Discovered while reviewing: #11281

Benefits:
* rails runner is for shebang lines or inline ruby, see ManageIQ#4307
* We don't have to check if rails is loaded.
* Can be run outside rails root directory via ruby.
* We don't need -- to avoid rails runner modifying our args.
* Less typing.
* Existing bin/rails runner callers with args just work:

`ruby tools/purge_orphaned_tag_values.rb -s 100`

Or, the old way:
`bin/rails runner tools/purge_orphaned_tag_values.rb -- -s 100`

Discovered while reviewing: ManageIQ#11281
@jrafanie
Copy link
Member Author

cc @durandom @Fryguy

@miq-bot
Copy link
Member

miq-bot commented Sep 20, 2016

Checked commits jrafanie/manageiq@6e29c84~...7e97acf with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
5 files checked, 5 offenses detected

tools/purge_metrics.rb

tools/purge_miq_report_results.rb

tools/purge_orphaned_tag_values.rb

@jrafanie
Copy link
Member Author

Chill ❄️ rubocop❄️ , I'm not touching those style changes in this PR.

Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

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

I like it for consistency :)

@Fryguy
Copy link
Member

Fryguy commented Sep 20, 2016

👍

If you happen to run with rails runner, things will still work, right?

@@ -1,10 +1,10 @@
require File.expand_path('../config/environment', __dir__)
Copy link
Member

@NickLaMuro NickLaMuro Sep 20, 2016

Choose a reason for hiding this comment

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

Pedantic (possibly for another PR): Would adding a #!/usr/bin/env ruby at the top here makes sense and making these executable?

I assume there is a reason they are not already, but it would just cut down on the typing further:

ruby tools/purge_orphaned_tag_values.rb -s 100 v.s. tools/purge_orphaned_tag_values.rb -s 100

Copy link
Member Author

Choose a reason for hiding this comment

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

I assume there is a reason they are not already, but it would just cut down on the typing further:

Probably because of appliance rpm business. I believe shebang lines will work properly in the appliance multiple ruby environment with system ruby from CentOS/RHEL and having packaged 2.2+ ruby from software collections. I don't have an appliance with system ruby rpm and scl ruby rpm at the same time.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a good idea, but I believe it involves more testing than this PR does.

@jrafanie
Copy link
Member Author

If you happen to run with rails runner, things will still work, right?

@Fryguy Yes, I tried each of these with ruby and rails runner.

So, both of these work:

ruby tools/purge_orphaned_tag_values.rb -s 100

Or, the old way:
bin/rails runner tools/purge_orphaned_tag_values.rb -- -s 100

I didn't remove the shifting of the "--" in the event it's coming from rails runner invocation.

@Fryguy Fryguy merged commit 1cb6078 into ManageIQ:master Sep 20, 2016
@Fryguy Fryguy deleted the require_config_environment_over_rails_runner branch September 20, 2016 20:54
@Fryguy Fryguy added this to the Sprint 47 Ending Oct 3, 2016 milestone Sep 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants