Project

isort

0.0
The project is in a healthy, maintained state
Isort automatically sorts and organizes your Ruby imports, including require, require_relative, include, using, and extend statements.Has the ability to group different types of imports together. It can process single files or entire directories directly throughcommand-line interface, and preserve the code comments and inline documentation
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0

Runtime

~> 0.2.0
 Project Readme

Isort

A Ruby gem that automatically sorts and organizes your import statements in Ruby files. You can use it on a file or a complete directory at once. Checkout here: https://rubygems.org/gems/isort

Installation

gem install isort

Usage

Command Line

For file:

isort --file path/to/your/file.rb
or
isort -f path/to/your/file.rb

For directory

isort --directory path/to/your/directory
or
isort -d path/to/your/directory

In Ruby Code

require 'isort'

sorter = Isort::FileSorter.new('path/to/your/file.rb')
sorter.sort_and_format_imports

Features

  • Sorts import statements correctly as per the norms
  • Groups imports by type (require, require_relative, include, extend)
  • Preserves code structure and spacing
  • Maintains conditional requires
  • Respects nested class and module definitions

Contributing

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

License

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