Cleanio

Cleanio is a simple Ruby gem that removes comments from .rb files. It can handle single-line comments and inline comments, leaving your code clean and readable.


Table of Contents

  1. Installation
  2. Usage
  3. Testing
  4. Contribution
  5. License
  6. TODO

Installation

To install Cleanio, add it to your Gemfile:

gem 'cleanio'

Then execute:

bundle install

Or install it yourself using the following command:

gem install cleanio

Usage

To clean up comments from a .rb file or directory, use the Cleanio::Remover.clean method. This will remove all single-line comments and inline comments from the file or directory.

require 'cleanio'

Cleanio::Remover.clean('path/to/your_file.rb')
Cleanio::Remover.clean('path/to/your_directory')

Audit Mode

To use the audit mode, pass the audit: true flag to the clean method. This will output the file paths and lines containing comments without modifying the files.

Example

Cleanio::Remover.clean('example.rb', audit: true)

Output

File: example.rb
  Line 1: # This is a comment
  Line 3: # Another comment

Command-Line Interface (CLI)

You can use Cleanio directly from the command line to clean or audit .rb files.

Clean Comments

To remove comments from a file, use:

cleanio -p path/to/file.rb
cleanio -p path/to/directory

Audit mode

To run Cleanio in audit mode without modifying files, use the --audit flag:

cleanio -p path/to/file.rb --audit
cleanio -p path/to/directory --audit

Testing

Cleanio uses RSpec for testing. To run the tests, first make sure all dependencies are installed:

bundle install

Then, run the tests with:

bundle exec rspec

All tests are located in the spec directory and cover the main functionality of the gem, ensuring it properly removes comments from Ruby files.

Contribution

Bug reports and pull requests are welcome on GitHub at https://github.com/justi/cleanio.

To contribute:

Fork the repository. Create a new branch (git checkout -b feature-branch). Make your changes. Commit your changes (git commit -m 'Add new feature'). Push to the branch (git push origin feature-branch). Open a pull request.

Please ensure that your code follows the existing style and that all tests pass.

License

The gem is available as open source under the terms of the MIT License.

TODO