- tested with Ruby (1.8.7, 1.9.3, and 2.0.0) and JRuby(1.8 and 1.9 mode) - see .travis.yml
Given this code
# file : big_code class BigCode def long_method # the only method that should be public _part_1 _part_2 end # PROBLEM : Those 2 methods were extracted and should be private def _part_1 # .... end def _part_2 # .... end end BigCode.new.long_method
When you run this command
$ pp_ruby big_code ^^^
Then the methods usage is tracked while the program runs and this findings report is output:
==================================================================================== = PrivatePlease report : = ==================================================================================== BigCode * Good candidates : can be made private : ------------------------------------------ #_part_2 #_part_1 ====================================================================================
$ gem install private_please
Usage : the 2 modes (auto and manual)
You can use private_please (PP) in either auto-mode or in manual mode.
Optionally you can customize the report contents with the env. variable
- in auto-mode (the example above in TL;DR), you simply run your program with
ruby) and all your code is inspected by PP while it runs.
- in manual mode you must manually instrument (==add code to) each file you want PP to track and inspect.
PP will run the program and track all the classes and methods that are defined.
How to :
- step 1 : use
$ bundle exec pp_ruby -Ilib normal.rb ^^^
A report is automatically printed when the program exits
You tell PP which classes and which methods to track.
How to :
- step 1 : Instrument your Ruby code
- step 2 : launch program as usual, with
step 1 : Instrument your code
# load PP require 'private_please' <<<<<<< ADD THIS (only 1x in the whole program) PrivatePlease.pp_automatic_mode_disable <<<<<<< " " " " " " " " " class BigCode private_please << ~~ JUST ADD THIS in every file you want PP to inspect << << Meaning : "track the code below" def long_method # the only method that should be public _part_1 _part_2 end def _part_1 # .... end def _part_2 # .... end end BigCode.new.long_method
step 2 : run you code normally
$ ruby big_code.rb
Please respect and reuse the current code style and formatting
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request