prependers 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop-https---relaxed-ruby-style-rubocop-yml +5 -1
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +1 -1
- data/README.md +22 -0
- data/lib/prependers/prepender.rb +6 -0
- data/lib/prependers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65760c94b14be5acf986ae0a58fa3306ac97b90a3c06cc8e191e62bbf91cc400
|
4
|
+
data.tar.gz: 3c32036d252c8638148aea455b9159301c4d28b4b35831f36a00de1b519d75ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a0e324243c77caefb069f2774107d8572b8780fb62de9d1d263be26919d6f5c3a3135588c1108b318a9a44d3ca814d93861c588f1eb6d1eff6007cc797f6f1a
|
7
|
+
data.tar.gz: c2a74e634f32940401aa3fe3ebe6f9dff39c5a0be7bacb4b2da610995caff135e29cf27dc99c3046c11cd9f4d3703cdf18ffbea3e6c1f94aad505ba18e137630
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Relaxed.Ruby.Style
|
2
|
-
## Version 2.
|
2
|
+
## Version 2.4
|
3
3
|
|
4
4
|
Style/Alias:
|
5
5
|
Enabled: false
|
@@ -65,6 +65,10 @@ Style/NegatedWhile:
|
|
65
65
|
Enabled: false
|
66
66
|
StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
|
67
67
|
|
68
|
+
Style/NumericPredicate:
|
69
|
+
Enabled: false
|
70
|
+
StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
|
71
|
+
|
68
72
|
Style/ParallelAssignment:
|
69
73
|
Enabled: false
|
70
74
|
StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.2.0] - 2019-07-09
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- `ClassMethods` is now automagically prepended to the singleton class ([#5](https://github.com/nebulab/prependers/pull/5))
|
15
|
+
|
10
16
|
## [0.1.1] - 2019-06-21
|
11
17
|
|
12
18
|
### Fixed
|
@@ -17,6 +23,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
17
23
|
|
18
24
|
Initial release.
|
19
25
|
|
20
|
-
[Unreleased]: https://github.com/nebulab/prependers/compare/v0.
|
26
|
+
[Unreleased]: https://github.com/nebulab/prependers/compare/v0.2.0...HEAD
|
27
|
+
[0.2.0]: https://github.com/nebulab/prependers/compare/v0.1.1...v0.2.0
|
21
28
|
[0.1.1]: https://github.com/nebulab/prependers/compare/v0.1.0...v0.1.1
|
22
29
|
[0.1.0]: https://github.com/nebulab/prependers/releases/tag/v0.1.0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,28 @@ end
|
|
43
43
|
Animals::Dog.new.bark # => 'Woof!'
|
44
44
|
```
|
45
45
|
|
46
|
+
### Extending class methods
|
47
|
+
|
48
|
+
If you want to extend a module's class methods, you can define a `ClassMethods` module in your
|
49
|
+
prepender:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
module Animals::Dog::AddBarking
|
53
|
+
include Prependers::Prepender.new
|
54
|
+
|
55
|
+
module ClassMethods
|
56
|
+
def family
|
57
|
+
puts 'Canids'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Animals::Dog.family # => 'Canids'
|
63
|
+
```
|
64
|
+
|
65
|
+
As you can see, the `ClassMethods` module has automagically been `prepend`ed to the `Animals::Dog`'s
|
66
|
+
singleton class.
|
67
|
+
|
46
68
|
### Autoloading prependers
|
47
69
|
|
48
70
|
If you don't want to include `Prependers::Prepender`, you can also autoload prependers from a path,
|
data/lib/prependers/prepender.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Prependers
|
4
4
|
class Prepender < Module
|
5
|
+
CLASS_METHODS_MODULE_NAME = 'ClassMethods'
|
6
|
+
|
5
7
|
attr_reader :namespace
|
6
8
|
|
7
9
|
def initialize(namespace = nil)
|
@@ -17,6 +19,10 @@ module Prependers
|
|
17
19
|
|
18
20
|
prepended_module = Object.const_get(prepended_module_name)
|
19
21
|
prepended_module.prepend base
|
22
|
+
|
23
|
+
if base.const_defined?(CLASS_METHODS_MODULE_NAME)
|
24
|
+
prepended_module.singleton_class.prepend base.const_get(CLASS_METHODS_MODULE_NAME)
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
data/lib/prependers/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prependers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Desantis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|