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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39bb185024ffbd5e1990762b1ce35647de0ce67b4ca5439d56effc648a8b2a01
4
- data.tar.gz: 40c40def58d727176833e52d70bd5e6493c2419893c0caad5fa5a3c1d9fa9059
3
+ metadata.gz: 65760c94b14be5acf986ae0a58fa3306ac97b90a3c06cc8e191e62bbf91cc400
4
+ data.tar.gz: 3c32036d252c8638148aea455b9159301c4d28b4b35831f36a00de1b519d75ec
5
5
  SHA512:
6
- metadata.gz: 34fbaadfbd900fb89f73cba677cb66c0849941b18388de06e30b2a00e1e34c33090ed66be3b9456ce3d9b9d6a0ab672f07740975352dc74dab2bdbbd512cbd38
7
- data.tar.gz: a0aa3bbef7ce89d651ade152f433c0036d1f60b8aaeb4e865b8644833f1405f1813eeb40f32826916e1e0c3545ab8c15f22a37cf992df29eb203edfabd4f1e3d
6
+ metadata.gz: 3a0e324243c77caefb069f2774107d8572b8780fb62de9d1d263be26919d6f5c3a3135588c1108b318a9a44d3ca814d93861c588f1eb6d1eff6007cc797f6f1a
7
+ data.tar.gz: c2a74e634f32940401aa3fe3ebe6f9dff39c5a0be7bacb4b2da610995caff135e29cf27dc99c3046c11cd9f4d3703cdf18ffbea3e6c1f94aad505ba18e137630
@@ -1,5 +1,5 @@
1
1
  # Relaxed.Ruby.Style
2
- ## Version 2.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
@@ -11,3 +11,6 @@ AllCops:
11
11
 
12
12
  Metrics/BlockLength:
13
13
  Enabled: false
14
+
15
+ Style/GuardClause:
16
+ Enabled: false
@@ -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.1.1...HEAD
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prependers (0.1.1)
4
+ prependers (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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,
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prependers
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
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.1.1
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-02 00:00:00.000000000 Z
11
+ date: 2019-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler