README.md in heavy_control-0.1.1 vs README.md in heavy_control-0.1.2
- old
+ new
@@ -1,10 +1,12 @@
# HeavyControl
[![Gem Version](https://badge.fury.io/rb/heavy_control.svg)](http://badge.fury.io/rb/heavy_control)
[![Build Status](https://travis-ci.org/ffloyd/heavy_control.svg?branch=master)](https://travis-ci.org/ffloyd/heavy_control)
[![Code Climate](https://codeclimate.com/github/ffloyd/heavy_control.svg)](https://codeclimate.com/github/ffloyd/heavy_control)
+[![Test Coverage](https://codeclimate.com/github/ffloyd/heavy_control/badges/coverage.svg)](https://codeclimate.com/github/ffloyd/heavy_control/coverage)
+[![Issue Count](https://codeclimate.com/github/ffloyd/heavy_control/badges/issue_count.svg)](https://codeclimate.com/github/ffloyd/heavy_control)
[![git.legal](https://git.legal/projects/1859/badge.svg "Number of libraries approved")](https://git.legal/projects/1859)
HeavyControl adds tools which allows you to modify Rails autoloading logic.
## Installation
@@ -58,10 +60,12 @@
HeavyControl: Search for file with suffix 'organization'
HeavyControl: and found '/vagrant/app/models/organization.rb'
HeavyControl: Require of load '/vagrant/app/models/organization' with const_path 'Organization'
```
+You may also turn off previously enabled debugging using `debug false`.
+
### Ignore subfolders
Rails automatically adds all folders under `/app` into autoloading paths. When you use constant (class, module) first time autoloading will search for file
with implementation. File path calculation is based on naming convention. So, for `YourContext::YourClass` it will be `[RAILS_ROOT]/app/[ANY_FOLDER]/your_context/your_class.rb`.
@@ -72,10 +76,28 @@
HeavyControl.config do
ignore_subfolder 'subfolder'
end
```
+For example lets write substitution to [trailblazer-loader](https://github.com/trailblazer/trailblazer-loader). README of this gem describes three naming and directory layout styles: _Compound-Singular_, _Explicit-Singular_ and _Explicit-Plural_.
+
+#### Compound-Singular
+
+It's very non-rails style. It forces us to keep from one to several class definitions in a single file. If you are using Rails I suggest you to avoid this. Currently, heavy_control doesn't support any code-placement styles where we put several classes inside one file.
+
+#### Explicit-Singular and Explicit-Plural
+
+This directory layout styles will work with classic rails autoloading correctly, except 'operation' and 'operations' folders. Given directories doesn't affect class namespaces. So, we will easy express this rule via `ignore_subfolder` option.
+
+```ruby
+# config/initializers/heavy_control.rb
+HeavyControl.config do
+ ignore_subfolder 'operation' # singular
+ ignore_subfolder 'operations' # plural
+end
+```
+
### 'Toplevel constant referenced' situations
Sometimes we can get errors related to warnings like this:
```
@@ -88,9 +110,11 @@
# config/initializers/heavy_control.rb
HeavyControl.config do
always_load 'YourContext::YourClass'
end
```
+
+In other words, for `always_load` you should use constant name which displays right after 'referenced by' words in a warning text.
You may write several names separated by comma.
`always_load` differs from `require_dependency`. It explicitly resolves constant names on initalization via `constantize` (before other constants are loaded). Also it happens each reload in development.