rename Standard scaffold to Requirement scaffold
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I'd like to rename everything named Standard (including comments) to Requirement. I feel Requirement is a much better name for a model.

"A user adds a proof to meet requirement 1.1.1" sounds better than "User adds proof to meet standard 1.1.1"

https://github.com/akshatpradhan/compliance_chimp

I feel requirement sounds better but let me know if you disagree. Someone recommended using facebook codemod that apparently helps with this sort of thing.

https://github.com/facebook/codemod

If you would be able to open pull request with all tests passing, comments changed, and 1 clean commit, then I'll just merge it into master.

Thank you!

PS. I asked this question before on a bountify question. I thought you might find it interesting what we used last time.

https://bountify.co/what-s-the-easiest-way-to-migrate-move-rename-the-garden-model-to-a-new-parcel-model

Crowdsource coding tasks.

2 Solutions

Winning solution

I've submitted a pull request. Take a look. Let me know if you need anything.

What did you use to do this? I found 2 missed names and I added a comment to the PR. I was wondering if you would be able to git push force after the fix and I'll just merge it in.
akshatpradhan over 5 years ago
Btw, I asked this question before on a bountify question. I thought you might find it interesting what we used last time. https://bountify.co/what-s-the-easiest-way-to-migrate-move-rename-the-garden-model-to-a-new-parcel-model
akshatpradhan over 5 years ago

Even if @super-engineer solution already won, I will post some info about how to do it automatically.
You need two things:

A bash script/command (using find and sed commands) for file/directory names (or a Ruby script, why not?). An example with a bash script:

for file in $(find . -name "standard*.*")
do 
  mv $file `echo $file | sed s/standard/requirement/`
done

For the file contents I would use a text editor with built in or plugin global search&replace. With Vim there's a handful plugins allowing project wise search and replace.

Greplace (https://github.com/skwp/greplace.vim) is old but still valid for an entirely automated process.

If you want to do things with a bit of control you can use Ack (https://github.com/mileszs/ack.vim) to search for files (:Ack standard .) and then opening files one by one by using the quickfix buffer on the bottom.

To apply the search & replace to files found by Ack I would use Abolish by tpope (https://github.com/tpope/vim-abolish): :%Subvert/standard/requirement/gc which replaces any occurrence of 'standard' (ignoring case and plural form of the noun) with 'requirement'.

I tried doing the entire process above and it takes just a couple of minutes. It could be longer for larger projects, though.

really interesting!
akshatpradhan over 5 years ago
View Timeline