Project

cybertron

0.0
No release in over 3 years
Low commit activity in last 3 years
Cybertron is a Ruby CLI to create codemods
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 13.0

Runtime

~> 2.6
~> 3.0
>= 0
 Project Readme

cybertron

Gem Version Build Status Coverage Status

cybertron is a command line tool for generating, testing and publishing converters aka Codemods for Ruby inspired by codemod-cli for Javascript by Robert Jackson

INFO: You can use a tool like codeshift to run your codemods/transforms against your Ruby codebase. For writing transforms you can also make use of the Ruby AST Explorer

Installation

$ gem install cybertron

Usage

Create a new codemod project

$ cybertron new <project-name>

Example:

$ cybertron new my_ruby_codemod

This will create a project structure like this:

my_ruby_codemod
| transforms
| spec
| | spec_helper.rb
.rspec
Rakefile

Generate a new transform

$ cd <project-name>
$ cybertron generate transform <transform-name>

Example:

$ cd my_ruby_codemod
$ cybertron generate transform my_transform

Now the project structure will be like this:

my_ruby_codemod
| transforms
| | my_transform
| | | fixtures
| | | | basic_input.rb
| | | | basic_output.rb
| | | transform.rb
| spec
| | my_transform_spec.rb
| | spec_helper.rb
.rspec
Rakefile

Generate a new fixture for transform

$ cybertron generate fixture <transform-name> <fixture-name>

Example:

$ cybertron generate fixture my_transform advanced_usage

Now the project structure will be like this:

my_ruby_codemod
| transforms
| | my_transform
| | | fixtures
| | | | basic_input.rb
| | | | basic_output.rb
| | | | advanced_usage_input.rb
| | | | advanced_usage_output.rb
| | | transform.rb
| spec
| | my_transform_spec.rb
| | spec_helper.rb
.rspec
Rakefile

Run tests for your codemod transforms

$ cybertron spec

This will run all the specs in the spec folder, by comparing the input and output fixtures against themselves for each and every transform.

Finding help or usage instructions

To display the help message and usage instructions, just invoke cybertron without any arguments

$ cybertron

To display help about any particular command,

$ cybertron help <command-name>

For example, to know more about the generate command:

$ cybertron help generate

Other related tools

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rajasegar/cybertron. 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.

Code of Conduct

Everyone interacting in the Cybertron project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.