magic-support 0.1.0 → 0.2.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 +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +16 -0
- data/README.md +6 -7
- data/lib/magic/core_ext/kernel/optional.rb +1 -1
- data/lib/magic/core_ext/kernel/utils.rb +23 -0
- data/lib/magic/core_ext/kernel.rb +2 -24
- data/lib/magic/core_ext.rb +2 -14
- data/lib/magic/loader.rb +16 -0
- data/lib/magic/support/version.rb +1 -1
- data/lib/rspec/method.rb +20 -16
- data/sig/magic/core_ext.rbs +0 -2
- data/sig/magic/loader.rbs +5 -0
- data/sig/rspec/method.rbs +4 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa812d41502d5c332298c520006236fb6c6535e8403e0beb253354712f7694e8
|
4
|
+
data.tar.gz: 2029e9de5202d7c451264ae71ef471d76723e89451556b3db6c511b51102f05d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 987615bca255fc3fe46178003bcea2e96df7ce8b55ae07f3b73551c8631209ddb0dea1da5931bc48396b1c983538507b96c185ebde57cbbcab40e828366753fc
|
7
|
+
data.tar.gz: 4cce946f3b7dc0211041516e9d9fa5ab083b6610af51fd63e9f2f062bbedd5d383bb4039d4e6c7f02a0009272f938fe826480b782f9229c6a1b22308a82e5499
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## [0.2.0] — 2025-05-13
|
2
|
+
|
3
|
+
### RSpec
|
4
|
+
|
5
|
+
#### Method specs
|
6
|
+
|
7
|
+
##### Added
|
8
|
+
|
9
|
+
- Receiver objects are exposed via `receiver`.
|
10
|
+
- Emit warnings on missing methods.
|
11
|
+
|
12
|
+
##### Fixed
|
13
|
+
|
14
|
+
- Don’t swallow unrelated name errors.
|
15
|
+
|
16
|
+
|
1
17
|
## [0.1.0] — 2024-11-28
|
2
18
|
|
3
19
|
### Added
|
data/README.md
CHANGED
@@ -19,18 +19,16 @@ It’s inspired by [Active Support](
|
|
19
19
|
|
20
20
|
## Installation
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
Install the gem and add to the application's Gemfile by executing:
|
22
|
+
Install the gem and add to the application’s Gemfile by executing:
|
25
23
|
|
26
24
|
```bash
|
27
|
-
bundle add
|
25
|
+
bundle add magic-support
|
28
26
|
```
|
29
27
|
|
30
|
-
If
|
28
|
+
If Bundler is not being used to manage dependencies, install the gem by executing:
|
31
29
|
|
32
30
|
```bash
|
33
|
-
gem install
|
31
|
+
gem install magic-support
|
34
32
|
```
|
35
33
|
|
36
34
|
## Core extensions
|
@@ -107,7 +105,7 @@ It holds authors info to be used primarily in gem specs.
|
|
107
105
|
Pre-install Magic Support if you plan to use `Gem::Author` in your gemspec.
|
108
106
|
|
109
107
|
```bash
|
110
|
-
gem install
|
108
|
+
gem install magic-support
|
111
109
|
```
|
112
110
|
|
113
111
|
#### Usage
|
@@ -186,6 +184,7 @@ In cases when the method couldn’t be found (e.g., due to delegation via `metho
|
|
186
184
|
instead.
|
187
185
|
Anyway, one may treat it as something _callable_.
|
188
186
|
|
187
|
+
A receiver object is exposed via `receiver`.
|
189
188
|
A method name is exposed as a `Symbol` via `method_name`.
|
190
189
|
|
191
190
|
> [!NOTE]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Magic # :nodoc:
|
4
|
+
module CoreExt # :nodoc:
|
5
|
+
module Kernel
|
6
|
+
# Some classes copy Kernel methods on initialization instead of
|
7
|
+
# including Kernel itself. Thus, new methods should be defined
|
8
|
+
# explicitly for them.
|
9
|
+
MODULES = [ # classes/modules including Kernel methods
|
10
|
+
::Kernel,
|
11
|
+
(Delegator if defined? Delegator),
|
12
|
+
].compact.freeze
|
13
|
+
end
|
14
|
+
|
15
|
+
module_function
|
16
|
+
|
17
|
+
def kernel(&)
|
18
|
+
Module.new(&).tap do |kernel|
|
19
|
+
Kernel::MODULES.each { _1.include kernel }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,27 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'magic/
|
3
|
+
require 'magic/loader'
|
4
4
|
|
5
|
-
|
6
|
-
module CoreExt # :nodoc:
|
7
|
-
module Kernel
|
8
|
-
# Some classes copy Kernel methods on initialization instead of
|
9
|
-
# including Kernel itself. Thus, new methods should be defined
|
10
|
-
# explicitly for them.
|
11
|
-
MODULES = [ # classes/modules including Kernel methods
|
12
|
-
::Kernel,
|
13
|
-
(Delegator if defined? Delegator),
|
14
|
-
].compact.freeze
|
15
|
-
end
|
16
|
-
|
17
|
-
module_function
|
18
|
-
|
19
|
-
def kernel(&)
|
20
|
-
Module.new(&).tap do |kernel|
|
21
|
-
Kernel::MODULES.each { _1.include kernel }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
CoreExt.require_all __FILE__
|
27
|
-
end
|
5
|
+
Magic::Loader.require_all
|
data/lib/magic/core_ext.rb
CHANGED
@@ -1,17 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
module CoreExt # :nodoc:
|
5
|
-
module_function
|
3
|
+
require 'magic/loader'
|
6
4
|
|
7
|
-
|
8
|
-
scope
|
9
|
-
.delete_suffix('.rb')
|
10
|
-
.then { Pathname _1 }
|
11
|
-
.glob('*.rb')
|
12
|
-
.each { require _1 }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
CoreExt.require_all
|
17
|
-
end
|
5
|
+
Magic::Loader.require_all
|
data/lib/magic/loader.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module Magic # :nodoc:
|
6
|
+
module Loader # :nodoc:
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def require_all scope = caller_locations[0].path
|
10
|
+
Pathname(scope)
|
11
|
+
.sub_ext('')
|
12
|
+
.glob('*.rb')
|
13
|
+
.each { require _1 }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/rspec/method.rb
CHANGED
@@ -30,22 +30,15 @@ module RSpec # :nodoc:
|
|
30
30
|
subject_method = subject_method.super_method or break
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
receiver.method name
|
45
|
-
rescue NameError
|
46
|
-
# TODO: emit a warning
|
47
|
-
|
48
|
-
-> *args { receiver.send name, *args }
|
33
|
+
let :receiver do
|
34
|
+
case [ scope, subject_method&.bind_call(self) || super() ]
|
35
|
+
in '#', receiver
|
36
|
+
receiver
|
37
|
+
in '.', Module => receiver
|
38
|
+
receiver
|
39
|
+
in '.', receiver
|
40
|
+
receiver.class
|
41
|
+
end
|
49
42
|
end
|
50
43
|
|
51
44
|
let(:method_name) { name.to_sym }
|
@@ -62,6 +55,17 @@ module RSpec # :nodoc:
|
|
62
55
|
|
63
56
|
def its_result(*args, &) = its(args, &)
|
64
57
|
end
|
58
|
+
|
59
|
+
def subject
|
60
|
+
receiver.method method_name
|
61
|
+
rescue NameError => error
|
62
|
+
raise unless
|
63
|
+
(receiver.is_a? error.receiver rescue false)
|
64
|
+
|
65
|
+
warn "Testing #{error}"
|
66
|
+
|
67
|
+
-> *args { receiver.send method_name, *args }
|
68
|
+
end
|
65
69
|
end
|
66
70
|
end
|
67
71
|
|
data/sig/magic/core_ext.rbs
CHANGED
data/sig/rspec/method.rbs
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magic-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Senko
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-05-13 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -40,6 +40,8 @@ files:
|
|
40
40
|
- lib/magic/core_ext.rb
|
41
41
|
- lib/magic/core_ext/kernel.rb
|
42
42
|
- lib/magic/core_ext/kernel/optional.rb
|
43
|
+
- lib/magic/core_ext/kernel/utils.rb
|
44
|
+
- lib/magic/loader.rb
|
43
45
|
- lib/magic/support.rb
|
44
46
|
- lib/magic/support/authors.rb
|
45
47
|
- lib/magic/support/version.rb
|
@@ -48,6 +50,7 @@ files:
|
|
48
50
|
- sig/lib/magic/support/author.rbs
|
49
51
|
- sig/magic/core_ext.rbs
|
50
52
|
- sig/magic/core_ext/kernel.rbs
|
53
|
+
- sig/magic/loader.rbs
|
51
54
|
- sig/magic/support.rbs
|
52
55
|
- sig/rspec/method.rbs
|
53
56
|
- sig/rubygems/author.rbs
|
@@ -56,7 +59,7 @@ licenses:
|
|
56
59
|
- MIT
|
57
60
|
metadata:
|
58
61
|
source_code_uri: https://github.com/Alexander-Senko/magic-support
|
59
|
-
changelog_uri: https://github.com/Alexander-Senko/magic-support/blob/v0.
|
62
|
+
changelog_uri: https://github.com/Alexander-Senko/magic-support/blob/v0.2.0/CHANGELOG.md
|
60
63
|
rdoc_options: []
|
61
64
|
require_paths:
|
62
65
|
- lib
|
@@ -71,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
74
|
- !ruby/object:Gem::Version
|
72
75
|
version: '0'
|
73
76
|
requirements: []
|
74
|
-
rubygems_version: 3.6.
|
77
|
+
rubygems_version: 3.6.5
|
75
78
|
specification_version: 4
|
76
79
|
summary: Active Support extended
|
77
80
|
test_files: []
|