strudel 0.1.0 → 1.0.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 +5 -13
- data/.rspec +1 -1
- data/.rubocop.yml +24 -2
- data/.travis.yml +38 -14
- data/.yardopts +4 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +2 -0
- data/README.md +10 -13
- data/bin/check-version +10 -0
- data/bin/rspec +10 -6
- data/bin/rubocop +20 -0
- data/bin/yard +10 -6
- data/bin/yardoc +10 -6
- data/bin/yri +10 -6
- data/lib/strudel.rb +32 -27
- data/lib/strudel/version.rb +10 -0
- data/strudel.gemspec +11 -9
- metadata +37 -49
- data/Rakefile +0 -11
- data/bin/rake +0 -16
checksums.yaml
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
5
|
-
data.tar.gz: !binary |-
|
|
6
|
-
MjViNzIwNjY2ZmEzMWI3ZGIxMTEyZDFkZDJlYTdmYTVhYjI3YzZlYQ==
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9db4e6d114547cb7cea2a9fa90518d63d6bd57a740cc0e98d7e91653570c65c6
|
|
4
|
+
data.tar.gz: 0ef732a0b969100b1e5e1d43e86437231bbdda1a77d78ad923c6bd1a96e63921
|
|
7
5
|
SHA512:
|
|
8
|
-
metadata.gz:
|
|
9
|
-
|
|
10
|
-
YzljMzVhMjA5NmI1NDA2M2M2YzdhZmFkNTAyMjA2MTdmMTI0ZmE0YTFkYzcx
|
|
11
|
-
YzY0ZGY4OTU2NTY1YTFkZWQ2OGJiMmViOTE4Y2JhNTAxYjdiNDM=
|
|
12
|
-
data.tar.gz: !binary |-
|
|
13
|
-
MTZiNjhlYTY0ZmMyZGFhNGU1NjQ4Mjc5YzgyYzM4YWJlNTI2OTVkM2M2ZmUz
|
|
14
|
-
N2MwY2Y5NWEyOTEyNmRmMjIwNWUwNDFjMjFiZjFmNWNhZTU3YTdlYmQzYjMy
|
|
15
|
-
MjlmYWI2MTZmZTE5M2QzZDQxMzgyNDU2YTc5MDFlYTEzYjQ5Y2I=
|
|
6
|
+
metadata.gz: 74888d188dd6910dc36cd8c59bd20e7600eaefad47a5084480ebfbe481112d2f773671bee37d82591df61a90835f8629c24fc5d87b17a78c16356c803ab7ee9e
|
|
7
|
+
data.tar.gz: 34d51387b1f6784a349be15ac1aa5a30a4131c1d68d46f0aa2830997faa6e0786365fb2402ccd932252fbbeb75b4cbfbb45ee25e86b3a742d2de2730fb5ab120
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
|
+
---
|
|
1
2
|
AllCops:
|
|
3
|
+
TargetRubyVersion: 2.3
|
|
4
|
+
|
|
5
|
+
Layout/EndAlignment:
|
|
6
|
+
EnforcedStyleAlignWith: variable
|
|
7
|
+
|
|
8
|
+
Layout/ParameterAlignment:
|
|
9
|
+
EnforcedStyle: with_fixed_indentation
|
|
10
|
+
|
|
11
|
+
Layout/FirstArrayElementIndentation:
|
|
12
|
+
EnforcedStyle: consistent
|
|
13
|
+
|
|
14
|
+
Layout/FirstHashElementIndentation:
|
|
15
|
+
EnforcedStyle: consistent
|
|
16
|
+
|
|
17
|
+
Layout/MultilineMethodCallIndentation:
|
|
18
|
+
EnforcedStyle: indented
|
|
19
|
+
|
|
20
|
+
Lint/MissingCopEnableDirective:
|
|
21
|
+
Enabled: false
|
|
22
|
+
|
|
23
|
+
Metrics/BlockLength:
|
|
2
24
|
Exclude:
|
|
3
|
-
-
|
|
4
|
-
|
|
25
|
+
- spec/*
|
|
26
|
+
|
|
5
27
|
Style/Documentation:
|
|
6
28
|
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -1,16 +1,40 @@
|
|
|
1
|
+
---
|
|
1
2
|
language: ruby
|
|
2
3
|
rvm:
|
|
3
|
-
- 2.
|
|
4
|
-
- 2.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
- 2.3
|
|
5
|
+
- 2.4
|
|
6
|
+
- 2.5
|
|
7
|
+
- 2.6
|
|
8
|
+
- 2.7
|
|
9
|
+
env:
|
|
10
|
+
global:
|
|
11
|
+
- COVERAGE=1
|
|
12
|
+
- secure: 'O3/v5fgksUZyzVDj/I0nLOwFba9UWXjIiqXguE0gMb1t2qofeI/cEJ/2RWnUpvxuF8mbuPwJG2rU3OLK+2q2pwWpMnVbScc0G8l1mVfG6IlLdkuDWWxjtieKvAbRvcfPLaai0u4V/equs1L5izOreNhc2bp0a7+0ZMHx5SgKxg5OjglcoMIIZgSixpkqITZbPmWDFYSj812lLed1MkP6zkpUsNlxOHrAhw6e3uEPTYwCPgqr2Q08ghgxZgvJP2qbD37Ei1s/fXKmsT6nsXo6y1/mb6jnIjoPkPtykRb3sp1xfFRQMER7jJy4e6ZFCz6nIbNX+7LBzE/5xPywViZ34NrzAnNaLka15w4OxVVQM9kp6mYjZ7FwtZVY6vri40DhbrtCmWOjftRsDP42gkQB51VCMYXTYOkPaeTIJeU4kkrihc5LRDCL8ZqssdW26bLw7NJmlCgedzJV1Bzfz7VfbNi2NRp4wRB9C7vtRK4+YvqFmCu+zu8hyEcE3aqwaYBZQaERZkb6TPgifZor0Kb/uS9y31FxbYlquaLukyN298kWktktP5F+y670066OPNgAoI65Clu7PI3tE9ekUBcK1lO4b25PrVWnOz2WKGVpEhTewZ+nU3Or1oKoFTPObAdbynP080CPx1WNP+CDRphyq3yJfSb7lhw98aGKVeRVVho='
|
|
13
|
+
|
|
14
|
+
before_script:
|
|
15
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
|
16
|
+
- chmod +x ./cc-test-reporter
|
|
17
|
+
- ./cc-test-reporter before-build
|
|
18
|
+
|
|
19
|
+
script:
|
|
20
|
+
- bin/rubocop
|
|
21
|
+
- bin/rspec --format doc
|
|
22
|
+
- bin/check-version
|
|
23
|
+
|
|
24
|
+
after_script:
|
|
25
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
include:
|
|
29
|
+
- stage: release
|
|
30
|
+
rvm: 2.3
|
|
31
|
+
script: skip
|
|
32
|
+
deploy:
|
|
33
|
+
provider: rubygems
|
|
34
|
+
api_key:
|
|
35
|
+
secure: 'tcEf3gBUUPOVkDFjvKhBX44cYghbFLXA5BEtmBPwqDXbWaoMVSDcsBRCddLLJts2k1tmYyGVSLP7FR8zE7tfJy40iqSqQRTtdB58SxAoMdU02+x0D8uCgMwdX7qLJePoxW4WVryMo8bql7N4ydtXwlV9POJiDKK47R21G7KvIplMGvav0/SYFFfI21BzCc6Pt8X6a0EuJXJNvqFhJAEvyp+7T8M83owIXwEIsarVc3VTTmefjAJ6zAvpLlRKYU63qN1hOqdzDfGhynNAYhIgstpDwmbwSqxkn4vxmn2OQSXwCeajLiB+nDMpevPGgE9KoeKKGWmv/N0qsgLohR9HziCBl1rolhjfYKshgN18iBBOW1iKBr0sb3EeWU2EDcnDGRvCx6vqD6LTj2TkFI0/nQYuIdPK8eWogpH3hpDwQWcC970bFDWrPFnuQ/jy2wS43y+Q8eAY3cbi07qzc5dMtA/YHkl/PpXM/VjPSWz95clcKc9tSgZN6Vy9dEfYhsTbtbY32SSBw+54N9g1dBaLgeA0T5J/HfNRRldLsZmoolNpeQ11ZLD/afL0Va4rR+qgKG3Hx8Yglp34NzZhSZ0wkrw/RPE2cSCBvknwL/thw+9PKqbSiao9GGFadVJt5KajIP501Bn8oBzoHqU9OuGG8i95MNLZSktnemMbYIgBsDc='
|
|
36
|
+
gem: strudel
|
|
37
|
+
on:
|
|
38
|
+
tags: true
|
|
39
|
+
condition: bin/check-version
|
|
40
|
+
repo: justinhoward/strudel
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## Release v1.0.2
|
|
2
|
+
|
|
3
|
+
* Remove rake development dependency
|
|
4
|
+
* Add Strudel.version method
|
|
5
|
+
* Add support for Ruby 2.7
|
|
6
|
+
|
|
7
|
+
## Release v1.0.0
|
|
8
|
+
|
|
9
|
+
Update dependencies and first stable release
|
|
10
|
+
|
|
11
|
+
## Release v0.1.3
|
|
12
|
+
|
|
13
|
+
Add support for Ruby 2.3
|
|
14
|
+
|
|
15
|
+
## Release v0.1.2
|
|
16
|
+
|
|
17
|
+
Add versions to all dev dependencies
|
|
18
|
+
|
|
19
|
+
## Release v0.1.1
|
|
20
|
+
|
|
21
|
+
Clean up development dependencies
|
|
22
|
+
|
|
23
|
+
## Release v0.1.0
|
|
24
|
+
|
|
25
|
+
Initial release
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# Strudel
|
|
2
2
|
|
|
3
|
-
[]
|
|
6
|
-
(https://codeclimate.com/github/justinhoward/strudel)
|
|
7
|
-
[]
|
|
10
|
-
(http://inch-ci.org/github/justinhoward/strudel)
|
|
3
|
+
[](https://badge.fury.io/rb/strudel)
|
|
4
|
+
[](https://travis-ci.org/justinhoward/strudel)
|
|
5
|
+
[](https://codeclimate.com/github/justinhoward/strudel)
|
|
6
|
+
[](https://codeclimate.com/github/justinhoward/strudel)
|
|
7
|
+
[](http://inch-ci.org/github/justinhoward/strudel)
|
|
11
8
|
|
|
12
9
|
Strudel is a dependency injection container for Ruby. It's a way to organize
|
|
13
10
|
your Ruby application to take advantage of the [dependency inversion
|
|
@@ -29,7 +26,7 @@ dependencies in one place.
|
|
|
29
26
|
|
|
30
27
|
You may have read [this post][dhh] by David Heineimer Hansson. However he
|
|
31
28
|
didn't address the primary benefit of DI, explicitly defining dependencies.
|
|
32
|
-
I also happen to think that patching code at runtime for testing is
|
|
29
|
+
I also happen to think that patching code at runtime for testing is an egregious
|
|
33
30
|
anti-pattern. In case you need more convincing, check out this
|
|
34
31
|
[great post][piotr] by Piotr Solnica.
|
|
35
32
|
|
|
@@ -94,11 +91,11 @@ available methods:
|
|
|
94
91
|
|
|
95
92
|
## API Documentation
|
|
96
93
|
|
|
97
|
-
API documentation can be found [
|
|
98
|
-
with yard.
|
|
94
|
+
API documentation can be found at [rubydoc.info][docs], or you can generate HTML
|
|
95
|
+
documentation with yard.
|
|
99
96
|
|
|
100
97
|
```sh
|
|
101
|
-
bin/
|
|
98
|
+
bin/yard
|
|
102
99
|
```
|
|
103
100
|
|
|
104
101
|
## Credits
|
|
@@ -121,4 +118,4 @@ License][mit].
|
|
|
121
118
|
[pimple]: http://pimple.sensiolabs.org
|
|
122
119
|
[fabien]: https://github.com/fabpot
|
|
123
120
|
[mit]: http://opensource.org/licenses/MIT
|
|
124
|
-
[
|
|
121
|
+
[docs]: http://www.rubydoc.info/github/justinhoward/strudel
|
data/bin/check-version
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
tag="$(git describe --abbrev=0 2>/dev/null || echo)"
|
|
6
|
+
tag="${tag#v}"
|
|
7
|
+
[ "$tag" = '' ] && exit 0
|
|
8
|
+
|
|
9
|
+
tag_gt_version=$(ruby -r ./lib/strudel/version -e "puts Strudel.version >= Gem::Version.new('${tag}')")
|
|
10
|
+
test "$tag_gt_version" = true
|
data/bin/rspec
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
#
|
|
3
5
|
# This file was generated by Bundler.
|
|
4
6
|
#
|
|
@@ -6,11 +8,13 @@
|
|
|
6
8
|
# this file is here to facilitate running it.
|
|
7
9
|
#
|
|
8
10
|
|
|
9
|
-
require
|
|
10
|
-
ENV[
|
|
11
|
-
|
|
11
|
+
require 'pathname'
|
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
|
|
13
|
+
'../../Gemfile',
|
|
14
|
+
Pathname.new(__FILE__).realpath
|
|
15
|
+
)
|
|
12
16
|
|
|
13
|
-
require
|
|
14
|
-
require
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'bundler/setup'
|
|
15
19
|
|
|
16
|
-
load Gem.bin_path(
|
|
20
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/rubocop
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require 'pathname'
|
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
|
|
13
|
+
'../../Gemfile',
|
|
14
|
+
Pathname.new(__FILE__).realpath
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'bundler/setup'
|
|
19
|
+
|
|
20
|
+
load Gem.bin_path('rubocop', 'rubocop')
|
data/bin/yard
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
#
|
|
3
5
|
# This file was generated by Bundler.
|
|
4
6
|
#
|
|
@@ -6,11 +8,13 @@
|
|
|
6
8
|
# this file is here to facilitate running it.
|
|
7
9
|
#
|
|
8
10
|
|
|
9
|
-
require
|
|
10
|
-
ENV[
|
|
11
|
-
|
|
11
|
+
require 'pathname'
|
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
|
|
13
|
+
'../../Gemfile',
|
|
14
|
+
Pathname.new(__FILE__).realpath
|
|
15
|
+
)
|
|
12
16
|
|
|
13
|
-
require
|
|
14
|
-
require
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'bundler/setup'
|
|
15
19
|
|
|
16
|
-
load Gem.bin_path(
|
|
20
|
+
load Gem.bin_path('yard', 'yard')
|
data/bin/yardoc
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
#
|
|
3
5
|
# This file was generated by Bundler.
|
|
4
6
|
#
|
|
@@ -6,11 +8,13 @@
|
|
|
6
8
|
# this file is here to facilitate running it.
|
|
7
9
|
#
|
|
8
10
|
|
|
9
|
-
require
|
|
10
|
-
ENV[
|
|
11
|
-
|
|
11
|
+
require 'pathname'
|
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
|
|
13
|
+
'../../Gemfile',
|
|
14
|
+
Pathname.new(__FILE__).realpath
|
|
15
|
+
)
|
|
12
16
|
|
|
13
|
-
require
|
|
14
|
-
require
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'bundler/setup'
|
|
15
19
|
|
|
16
|
-
load Gem.bin_path(
|
|
20
|
+
load Gem.bin_path('yard', 'yardoc')
|
data/bin/yri
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
#
|
|
3
5
|
# This file was generated by Bundler.
|
|
4
6
|
#
|
|
@@ -6,11 +8,13 @@
|
|
|
6
8
|
# this file is here to facilitate running it.
|
|
7
9
|
#
|
|
8
10
|
|
|
9
|
-
require
|
|
10
|
-
ENV[
|
|
11
|
-
|
|
11
|
+
require 'pathname'
|
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
|
|
13
|
+
'../../Gemfile',
|
|
14
|
+
Pathname.new(__FILE__).realpath
|
|
15
|
+
)
|
|
12
16
|
|
|
13
|
-
require
|
|
14
|
-
require
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'bundler/setup'
|
|
15
19
|
|
|
16
|
-
load Gem.bin_path(
|
|
20
|
+
load Gem.bin_path('yard', 'yri')
|
data/lib/strudel.rb
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'strudel/version'
|
|
4
|
+
|
|
1
5
|
# Strudel
|
|
2
6
|
#
|
|
3
7
|
# A tiny dependency injection container
|
|
@@ -14,7 +18,7 @@ class Strudel
|
|
|
14
18
|
|
|
15
19
|
# Get a service by key
|
|
16
20
|
#
|
|
17
|
-
# If the service is not set, returns
|
|
21
|
+
# If the service is not set, returns `nil`.
|
|
18
22
|
#
|
|
19
23
|
# @param [key] key The service key
|
|
20
24
|
# @return [value, nil] The service or nil if not set
|
|
@@ -31,13 +35,13 @@ class Strudel
|
|
|
31
35
|
|
|
32
36
|
# Set a service by key and value
|
|
33
37
|
#
|
|
34
|
-
# If
|
|
38
|
+
# If `service` is a Proc, its return value will be treated as a
|
|
35
39
|
# singleton service meaning it will be initialized the first time it is
|
|
36
40
|
# requested and its valud will be cached for subsequent requests.
|
|
37
41
|
#
|
|
38
|
-
# Use the
|
|
42
|
+
# Use the `set` method to allow using a block instead of a Proc argument.
|
|
39
43
|
#
|
|
40
|
-
# If
|
|
44
|
+
# If `service` is not a function, its value will be stored directly.
|
|
41
45
|
#
|
|
42
46
|
# @param [key] key The service key
|
|
43
47
|
# @param [Proc, value] service The service singleton Proc or static service
|
|
@@ -48,74 +52,74 @@ class Strudel
|
|
|
48
52
|
|
|
49
53
|
# Set a service by key and value
|
|
50
54
|
#
|
|
51
|
-
# Same as
|
|
55
|
+
# Same as `[]=` except allows passing a block instead of a Proc argument.
|
|
52
56
|
#
|
|
53
57
|
# @param [key] key The service key
|
|
54
58
|
# @param [Proc, value, nil] service The service singleton Proc or static
|
|
55
59
|
# service
|
|
56
60
|
# @yield [self]
|
|
57
61
|
# @return [self]
|
|
58
|
-
def set(key, service = nil)
|
|
59
|
-
create(key, service ||
|
|
62
|
+
def set(key, service = nil, &block)
|
|
63
|
+
create(key, service || block, @procs)
|
|
60
64
|
end
|
|
61
65
|
|
|
62
66
|
# Set a factory service by key and value
|
|
63
67
|
#
|
|
64
|
-
# If
|
|
68
|
+
# If `factory` is a function, it will be called every time the service is
|
|
65
69
|
# requested. So if it returns an object, it will create a new object for
|
|
66
70
|
# every request.
|
|
67
71
|
#
|
|
68
|
-
# If
|
|
72
|
+
# If `factory` is not a function, this method acts like `set`.
|
|
69
73
|
#
|
|
70
74
|
# @param [key] key The service key
|
|
71
75
|
# @param [Proc, block] factory The service factory Proc or static service
|
|
72
76
|
# @yield [self]
|
|
73
77
|
# @return [self]
|
|
74
|
-
def factory(key, factory = nil)
|
|
75
|
-
create(key, factory ||
|
|
78
|
+
def factory(key, factory = nil, &block)
|
|
79
|
+
create(key, factory || block, @factories)
|
|
76
80
|
end
|
|
77
81
|
|
|
78
82
|
# Set a protected service by name and value
|
|
79
83
|
#
|
|
80
|
-
# If
|
|
81
|
-
# service. So when it is requested with
|
|
84
|
+
# If `service` is a function, the function itself will be registered as a
|
|
85
|
+
# service. So when it is requested with `get`, the function will be returned
|
|
82
86
|
# instead of the function's return value.
|
|
83
87
|
#
|
|
84
|
-
# If
|
|
88
|
+
# If `service` is not a function, this method acts like `set`.
|
|
85
89
|
#
|
|
86
90
|
# @param [key] key The service key
|
|
87
91
|
# @param [Proc, value, nil] service The service function.
|
|
88
92
|
# @yield [self]
|
|
89
93
|
# @return [self]
|
|
90
|
-
def protect(key, service = nil)
|
|
91
|
-
create(key, service ||
|
|
94
|
+
def protect(key, service = nil, &block)
|
|
95
|
+
create(key, service || block)
|
|
92
96
|
end
|
|
93
97
|
|
|
94
98
|
# Extends an existing service and overrides it.
|
|
95
99
|
#
|
|
96
|
-
# The
|
|
97
|
-
#
|
|
100
|
+
# The `extender` block will be called with 2 arguments: `old_value` and
|
|
101
|
+
# `self`. If there is no existing `key` service, `old_value` will be nil. It
|
|
98
102
|
# should return the new value for the service that will override the existing
|
|
99
103
|
# one.
|
|
100
104
|
#
|
|
101
|
-
# If
|
|
105
|
+
# If `extend` is called for a service that was created with `set`, the
|
|
102
106
|
# resulting service will be a singleton.
|
|
103
107
|
#
|
|
104
|
-
# If
|
|
108
|
+
# If `extend` is called for a service that was created with `factory`, the
|
|
105
109
|
# resulting service will be a factory.
|
|
106
110
|
#
|
|
107
|
-
# If
|
|
111
|
+
# If `extend` is called for a service that was created with `protect`, the
|
|
108
112
|
# resulting service will also be protected.
|
|
109
113
|
#
|
|
110
|
-
# If
|
|
111
|
-
# service like
|
|
114
|
+
# If `extender` is not a function, this method will override any existing
|
|
115
|
+
# service like `set`.
|
|
112
116
|
#
|
|
113
117
|
# @param [key] key The service key
|
|
114
118
|
# @param [Proc, value, nil] extender
|
|
115
119
|
# @yield [old_value, self]
|
|
116
120
|
# @return [self]
|
|
117
|
-
def extend(key, extender = nil)
|
|
118
|
-
extender ||=
|
|
121
|
+
def extend(key, extender = nil, &block)
|
|
122
|
+
extender ||= block
|
|
119
123
|
return set(key, extender) unless extender.is_a?(Proc) && @services.key?(key)
|
|
120
124
|
|
|
121
125
|
extended = @services[key]
|
|
@@ -128,7 +132,7 @@ class Strudel
|
|
|
128
132
|
# Iterates over the service keys
|
|
129
133
|
#
|
|
130
134
|
# If a block is given, the block is called with each of the service keys
|
|
131
|
-
# If a block is not given, returns an
|
|
135
|
+
# If a block is not given, returns an `Enumerable` of the keys.
|
|
132
136
|
#
|
|
133
137
|
# The key order is undefined.
|
|
134
138
|
#
|
|
@@ -136,10 +140,11 @@ class Strudel
|
|
|
136
140
|
# @return [Enumerable, nil]
|
|
137
141
|
def each
|
|
138
142
|
return @services.each_key unless block_given?
|
|
143
|
+
|
|
139
144
|
@services.each_key { |key| yield key }
|
|
140
145
|
end
|
|
141
146
|
|
|
142
|
-
# Checks if a service for
|
|
147
|
+
# Checks if a service for `key` exists.
|
|
143
148
|
#
|
|
144
149
|
# @return [bool] True if the service exists.
|
|
145
150
|
def include?(key)
|
data/strudel.gemspec
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require 'strudel/version'
|
|
4
6
|
|
|
5
7
|
Gem::Specification.new do |spec|
|
|
6
8
|
spec.name = 'strudel'
|
|
7
|
-
spec.version =
|
|
9
|
+
spec.version = Strudel.version
|
|
8
10
|
spec.authors = ['Justin Howard']
|
|
9
11
|
spec.email = ['jmhoward0@gmail.com']
|
|
10
12
|
|
|
@@ -17,10 +19,10 @@ Gem::Specification.new do |spec|
|
|
|
17
19
|
end
|
|
18
20
|
spec.require_paths = ['lib']
|
|
19
21
|
|
|
20
|
-
spec.add_development_dependency '
|
|
21
|
-
spec.add_development_dependency 'rspec'
|
|
22
|
-
|
|
23
|
-
spec.add_development_dependency '
|
|
24
|
-
spec.add_development_dependency '
|
|
25
|
-
spec.add_development_dependency '
|
|
22
|
+
spec.add_development_dependency 'redcarpet', '~> 3.4'
|
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
|
24
|
+
# 0.81 is the last rubocop version with Ruby 2.3 support
|
|
25
|
+
spec.add_development_dependency 'rubocop', '0.81.0'
|
|
26
|
+
spec.add_development_dependency 'simplecov', '~> 0.11'
|
|
27
|
+
spec.add_development_dependency 'yard', '>= 0.9.11'
|
|
26
28
|
end
|
metadata
CHANGED
|
@@ -1,99 +1,85 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strudel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Howard
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-08-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: redcarpet
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '3.4'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '3.4'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rspec
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '3.4'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '3.4'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rubocop
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - '='
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 0.81.0
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - '='
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 0.81.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: simplecov
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
61
|
+
version: '0.11'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
68
|
+
version: '0.11'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - ! '>='
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - ! '>='
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: codeclimate-test-reporter
|
|
70
|
+
name: yard
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
86
72
|
requirements:
|
|
87
|
-
- -
|
|
73
|
+
- - ">="
|
|
88
74
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
75
|
+
version: 0.9.11
|
|
90
76
|
type: :development
|
|
91
77
|
prerelease: false
|
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
79
|
requirements:
|
|
94
|
-
- -
|
|
80
|
+
- - ">="
|
|
95
81
|
- !ruby/object:Gem::Version
|
|
96
|
-
version:
|
|
82
|
+
version: 0.9.11
|
|
97
83
|
description:
|
|
98
84
|
email:
|
|
99
85
|
- jmhoward0@gmail.com
|
|
@@ -101,20 +87,23 @@ executables: []
|
|
|
101
87
|
extensions: []
|
|
102
88
|
extra_rdoc_files: []
|
|
103
89
|
files:
|
|
104
|
-
- .gitignore
|
|
105
|
-
- .rspec
|
|
106
|
-
- .rubocop.yml
|
|
107
|
-
- .travis.yml
|
|
90
|
+
- ".gitignore"
|
|
91
|
+
- ".rspec"
|
|
92
|
+
- ".rubocop.yml"
|
|
93
|
+
- ".travis.yml"
|
|
94
|
+
- ".yardopts"
|
|
95
|
+
- CHANGELOG.md
|
|
108
96
|
- Gemfile
|
|
109
97
|
- LICENSE.txt
|
|
110
98
|
- README.md
|
|
111
|
-
-
|
|
112
|
-
- bin/rake
|
|
99
|
+
- bin/check-version
|
|
113
100
|
- bin/rspec
|
|
101
|
+
- bin/rubocop
|
|
114
102
|
- bin/yard
|
|
115
103
|
- bin/yardoc
|
|
116
104
|
- bin/yri
|
|
117
105
|
- lib/strudel.rb
|
|
106
|
+
- lib/strudel/version.rb
|
|
118
107
|
- strudel.gemspec
|
|
119
108
|
homepage: https://github.com/justinhoward/strudel
|
|
120
109
|
licenses:
|
|
@@ -126,17 +115,16 @@ require_paths:
|
|
|
126
115
|
- lib
|
|
127
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
117
|
requirements:
|
|
129
|
-
- -
|
|
118
|
+
- - ">="
|
|
130
119
|
- !ruby/object:Gem::Version
|
|
131
120
|
version: '0'
|
|
132
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
122
|
requirements:
|
|
134
|
-
- -
|
|
123
|
+
- - ">="
|
|
135
124
|
- !ruby/object:Gem::Version
|
|
136
125
|
version: '0'
|
|
137
126
|
requirements: []
|
|
138
|
-
|
|
139
|
-
rubygems_version: 2.4.5
|
|
127
|
+
rubygems_version: 3.0.8
|
|
140
128
|
signing_key:
|
|
141
129
|
specification_version: 4
|
|
142
130
|
summary: A tiny dependency injection container
|
data/Rakefile
DELETED
data/bin/rake
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
#
|
|
3
|
-
# This file was generated by Bundler.
|
|
4
|
-
#
|
|
5
|
-
# The application 'rake' is installed as part of a gem, and
|
|
6
|
-
# this file is here to facilitate running it.
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
require "pathname"
|
|
10
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
11
|
-
Pathname.new(__FILE__).realpath)
|
|
12
|
-
|
|
13
|
-
require "rubygems"
|
|
14
|
-
require "bundler/setup"
|
|
15
|
-
|
|
16
|
-
load Gem.bin_path("rake", "rake")
|