Rails previously used a symbol and a hashrocket to declare/modify hashes, like so:
:name => "Mr. Foo B. Baz"
Now it uses this JSON-inpired style:
name: "Mr. Foo B. Baz"
In order to move to the pretty, concise new style (heh, I like it!) go a regex-replace in your text editor and replace this:
This is what happens:
When you use something like Rails Composer(which is an awesome tool, BTW) you get a messy Gemfile like this:
You can fix some of that with the first tip, but for neat grouping, do this:
- In your editor’s find/replace box, enter this regex:
gem .* (\w+): :development(?:.*)
- Select and cut all the lines.
- Create a new “group :development” block and paste the cut lines in.
- Repeat this with “group :test”, “group :production”, “group :staging”(if you have one) and “group :development, :test”. (For the last one, your regex should have “[:development, :test]”)
Note to self: write an awesome gem to cleanup Gemfiles :idea:
Select all text matching this regex:
, [\"\'][">=", "~>"]*.*[\"\'][,]*
Delete it and sleep peacefully.
[I can’t write any further as someone has turned on a 3KHz sound. Stupid neighbours.]