cleanse 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b90083299b31f490bb5e4b6aa9ad215f13de7bec7389024162cb4c8cf14935b1
4
+ data.tar.gz: 3d3d1b2b3053f6531b00d79a2855704bda544cef9576141ccf92299600e040b3
5
+ SHA512:
6
+ metadata.gz: 3591c649946baedd6ac927bd9e3f51d75f94214c3b2cc426b2fa86fbc6b0284425e85e15f7cda46b3fb6bfa7122e3340942246e4c2d1c6f2a6188ecc0bbc622a
7
+ data.tar.gz: 93e53d2719c236e5fd23f7924a226852977d53e85ae2a575a932bd36ea1b898423c950240c2708eee0efa25d21de9b8534e5eb5b938be12c75948d88f271fc70
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1.0
3
+ Include:
4
+ - 'lib/**/*.rb'
5
+ - 'spec/**/*.rb'
6
+
7
+ Layout/LineLength:
8
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-05-04
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Douglas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/cleanse.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/cleanse/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "cleanse"
7
+ spec.version = Cleanse::VERSION
8
+ spec.authors = ["Douglas Vitor"]
9
+ spec.email = ["douglasvitor.dev@gmail.com"]
10
+
11
+ spec.summary = "Clean your fat ruby classes."
12
+ spec.description = "Cleanse influences you to create modules and include them dynamically in your classes in order to keep them clean."
13
+ spec.homepage = "https://github.com/Doug-Vitor/cleanse"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.1.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
27
+ end
28
+ end
29
+
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cleanse
4
+ module Cleaner
5
+ def self.included(cleanable_class)
6
+ clean!(cleanable_class)
7
+ end
8
+
9
+ def self.clean!(cleanable_class)
10
+ cleanable_class.constants.each do |constant|
11
+ cleanable_class.include(constant) if !cleanable_class.abstract_class? && constant.is_a?(Module)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cleanse
4
+ VERSION = '0.1.0'
5
+ end
data/lib/cleanse.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'cleanse/version'
4
+ require_relative 'cleanse/cleaner'
5
+
6
+ module Cleanse
7
+ if defined?(ActiveRecord::Base)
8
+ parent_classes = children_of(ActiveRecord::Base).flat_map do |parent_class|
9
+ children_of(parent_class)
10
+ end
11
+
12
+ parent_classes.each do |parent_class|
13
+ parent_class.include(Cleanse::Cleaner)
14
+ end
15
+ end
16
+
17
+ def children_of(parent_class)
18
+ parent_class.abstract_class? ? [] : parent.subclasses
19
+ end
20
+ end
data/sig/cleanse.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Cleanse
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cleanse
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Douglas Vitor
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-05-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Cleanse influences you to create modules and include them dynamically
14
+ in your classes in order to keep them clean.
15
+ email:
16
+ - douglasvitor.dev@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - CHANGELOG.md
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - cleanse.gemspec
28
+ - lib/cleanse.rb
29
+ - lib/cleanse/cleaner.rb
30
+ - lib/cleanse/version.rb
31
+ - sig/cleanse.rbs
32
+ homepage: https://github.com/Doug-Vitor/cleanse
33
+ licenses:
34
+ - MIT
35
+ metadata:
36
+ homepage_uri: https://github.com/Doug-Vitor/cleanse
37
+ source_code_uri: https://github.com/Doug-Vitor/cleanse
38
+ changelog_uri: https://github.com/Doug-Vitor/cleanse/blob/main/CHANGELOG.md
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.3.7
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Clean your fat ruby classes.
58
+ test_files: []