cleanse 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/lib/cleanse/version.rb +1 -1
- data/lib/cleanse.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 48ff8467e9ded2005f428c6fc11379660366a9756fb7cb3aafd9c36edaabc771
|
|
4
|
+
data.tar.gz: 346188d6031d41a26745814546aa9e88b1b4f2935c7cb1209b6c05ad0e2b5bbc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47d7f5f084fce8354a29af2f280ede64b8116c6f8dad63ccf865eb3c7bc929361aa8610dd279d9433ecd79f69b0a062ccb19da35fe3580426aaace547d74fcef
|
|
7
|
+
data.tar.gz: 8f782d65d080664578721bc5e9b1d83097fec0103d020b91625258c328e5190ca84ed0213627df5859d88ad2da7d94bb69da8f1eba5c2f03412b134c798cd4d0
|
data/README.md
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Cleanse
|
|
2
|
+
|
|
3
|
+
Cleanse influences you to create modules and include them dynamically in your classes in order to keep them clean.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
Create modules with the same name as the class you want to clean up and, finally, include our module with the `include Cleanse::Cleaner` directive in the class.
|
|
7
|
+
|
|
8
|
+
In the case of Rails applications, all the modules defined in `app/models/concerns` will be included automatically in their respective models. For this to work properly, make sure you enable eager load in each environment in the `config/environments` folder:
|
|
9
|
+
|
|
10
|
+
```config.eager_load = true```
|
|
11
|
+
|
|
12
|
+
## Purpose
|
|
13
|
+
|
|
14
|
+
Imagine a fat product model with countless lines of code. In order to reduce it to just the class definition line (`class Product; end`), we encourage you to create descriptive modules with the same name as your class. `Cleanse::Cleaner` will include all these modules and your code will be more concise, objective and maintainable.
|
|
15
|
+
|
|
16
|
+
- `app/models/product.rb` -> The cleaned class;
|
|
17
|
+
- `app/models/concerns/product/associations.rb` -> The code containing the product model associations;
|
|
18
|
+
- `app/models/concerns/product/callbacks.rb` -> The active record callbacks for the product model;
|
|
19
|
+
- `app/models/concerns/product/?.rb` -> Whatever you want, it will be included automatically.
|
|
20
|
+
|
|
21
|
+
## Questions/suggestions/contributions
|
|
22
|
+
Feel free to create issues or pull request in this repository.
|
data/lib/cleanse/version.rb
CHANGED
data/lib/cleanse.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Cleanse
|
|
|
18
18
|
parent_class = 'ApplicationRecord'.safe_constantize || 'ActiveRecord::Base'.safe_constantize || nil
|
|
19
19
|
return unless parent_class
|
|
20
20
|
|
|
21
|
-
cleanable_classes = children_of(parent_class)
|
|
21
|
+
cleanable_classes = Cleanse.children_of(parent_class)
|
|
22
22
|
cleanable_classes.each do |cleanable_class|
|
|
23
23
|
cleanable_class.include(Cleanse::Cleaner)
|
|
24
24
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cleanse
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Douglas Vitor
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-05-
|
|
11
|
+
date: 2025-05-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Cleanse influences you to create modules and include them dynamically
|
|
14
14
|
in your classes in order to keep them clean.
|
|
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
52
|
version: '0'
|
|
53
53
|
requirements: []
|
|
54
|
-
rubygems_version: 3.
|
|
54
|
+
rubygems_version: 3.5.11
|
|
55
55
|
signing_key:
|
|
56
56
|
specification_version: 4
|
|
57
57
|
summary: Clean your fat ruby classes.
|