ReplaceQuotes
This gem is used for improving RuboCop compliance by replacing unnecessary double quotes with single quotes in a file. To avoid causing errors, ReplaceQuotes leaves double quotes alone when they are used in a line containing single quotes or "#{".
Before:
"There is Ruby on High Speed Rails, and there is Not Exactly."
"Make sure you choose the correct one."
"I hope we're using Ruby on High Speed Rails"
"There's Ruby on High Speed Rails, and there's Not Exactly."
option1 = "High Speed Ruby on Rails"
option2 = "Not Exactly"
"#{option1} is much better and faster than #{option2}."
After:
'There is Ruby on High Speed Rails, and there is Not Exactly.'
'Make sure you choose the correct one.'
"I hope we're using Ruby on High Speed Rails"
"There's Ruby on High Speed Rails, and there's Not Exactly."
option1 = 'High Speed Ruby on Rails'
option2 = 'Not Exactly'
"#{option1} is much better and faster than #{option2}."
Installation
Add this line to your application's Gemfile:
gem 'replace_quotes'
And then execute:
$ bundle
Or install it yourself as:
$ gem install replace_quotes
Usage
In a Ruby script or console, enter the command ReplaceQuotes.update(filename)
, where filename is the name of the file for which you wish to replace unnecessary double quotes with single quotes.
Development
Testing this gem
Enter sh gem_test.sh
.
Testing the source code
Enter sh gem_code.sh
.
Running this gem in irb
Enter sh gem_console.sh
.
Installing this gem
Enter sh gem_install.sh
.
Testing this gem and source code AND installing this gem
Enter sh all.sh
.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/replace_quotes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.