Skip to content

Instantly share code, notes, and snippets.

@kzkn
Created March 12, 2025 07:39
Show Gist options
  • Save kzkn/a223b0ab245776d8c960849c96401ef7 to your computer and use it in GitHub Desktop.
Save kzkn/a223b0ab245776d8c960849c96401ef7 to your computer and use it in GitHub Desktop.
# how to use: ruby carrierwave_present.rb | sort
# requires: git, sed, ruby
def do_grep(attribute)
_puts = ->(s) { puts s unless s.empty? }
_puts.call `git grep '#{attribute}\.present?'`
_puts.call `git grep '#{attribute}\.blank?'`
_puts.call `git grep '#{attribute}?'`
end
carrierwave_attributes = `git grep mount_uploader | sed -e 's/^.* mount_uploader ://' -e 's/, .*$//'`.lines.map(&:strip)
carrierwave_attributes.uniq.each do |attribute|
do_grep(attribute)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment