mire [ˈmɪʀɛ]
mire analyzes a Ruby project and helps you to find dependencies, call stacks and unused methods. It parses Ruby and Haml files and collects all method definitions and invocations.
- Installation
- Usage
- Configuration
- Dependencies
- TODO
Installation
Add this line to your application's Gemfile:
gem 'mire'And then execute:
$ bundleOr install it yourself as:
$ gem install mireUsage
First you need to analyze the code and create a .mire_analysis.yml
file.
bundle exec mire -aA Ruby code like
class Foo
def bar
buz
end
endwill lead to this .mire_analysis.yml file.
:bar:
:definitions:
- :class: Foo
:method: :bar
:file: foo.rb
:line: 2
:invocations: []
:buz:
:definition: []
:invocations:
- :class: Foo
:method: :bar
:file: foo.rb
:line: 3After this the .mire_analysis.yml file can be used to find unused
methods for example.
bundle exec mire -u
Checking for unused methods
foo.rb:2 Foo.barThis result can only be taken as a hint for unused methods. For example ERB files are not being analysed yet. Also dynamic method definitions or invocations are not considered. So mire can't find every usage of a method.
Configuration
mire can be configured with a .mire.yml file in your project folder.
With mire -i a initial configuration file is created.
You can configure which files or folders should be excluded while analyzing the code or when displaying the unused methods.
excluded_files:
- vendor/**/*
output:
unused:
excluded_files:
- db/migrate/**/*
- spec/**/*
- script/**/*
- lib/**/*Dependencies
Why is HAML-Lint needed?
HAML-Lint did a great job to write a Ruby code extractor for Haml files. mire is using this extractor.
TODO
The current implementation of mire is really basic. It needs to become
more robust and the parsed file types (e.g. .erb) needs to be
extended.
Contributing
- Fork it ( https://github.com/xing/mire/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Authors
Nils Gemeinhardt and Marcus Lankenau
Copyright (c) 2015 XING EVENTS GmbH
Released under the MIT license. For full details see LICENSE included in this distribution.