strudel 0.1.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjE1YjU5NGQwMGM2ZDVhN2Y4NzRjNWUxODJlYWM1NDdlNmIxNGM1Yg==
5
- data.tar.gz: !binary |-
6
- MjViNzIwNjY2ZmEzMWI3ZGIxMTEyZDFkZDJlYTdmYTVhYjI3YzZlYQ==
2
+ SHA256:
3
+ metadata.gz: 9db4e6d114547cb7cea2a9fa90518d63d6bd57a740cc0e98d7e91653570c65c6
4
+ data.tar.gz: 0ef732a0b969100b1e5e1d43e86437231bbdda1a77d78ad923c6bd1a96e63921
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ODI4ZjFmMDVhMzQwNTc1NjE0OGM2ZTMwMjE0NGIxNjE5NmVjZmUwNzk2MGUz
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
@@ -1,2 +1,2 @@
1
- --format documentation
2
1
  --color
2
+ --require spec_helper
@@ -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
- - 'bin/*'
4
- - 'vendor/**/*'
25
+ - spec/*
26
+
5
27
  Style/Documentation:
6
28
  Enabled: false
@@ -1,16 +1,40 @@
1
+ ---
1
2
  language: ruby
2
3
  rvm:
3
- - 2.0.0
4
- - 2.2.2
5
- deploy:
6
- provider: rubygems
7
- api_key:
8
- secure: f1rTqFzMHA1DueBSv7YzFOHy6JxUuSwflvSL6TXG5v5bWs0c6KWi1LhY43pYnpoY3ZyDtFAGgKyvQvvFCvrTB0jQx2lFo2fbXD7LoT1ThX3GLYPvGO79ycUzmXlhNFOGPZo1V3iGb5xAo8ZOVSKNesFWivy81b9SEsL4alv1QUfd2iDs4GzGJMwMIQy758PY21vQhGFfKDXld4ei9cK3hCS4999MluWtjt624FTs9oKoMfzZHfBpMa4ml6oogM1CR3tY8OzjXK0T7nLTr7ykcIiQeJGEP5q8t/IPaDs2v5yPWHv6cm8v9gCewFnzgv0Kqp0CNidzO2OlS3JmOk8mwdKad7dwpm5TKeJp3d9od35vN7H5uYZdozjfiMI7jXsQa+cfsFWWMTf5uaD0hnJFu93AWC+8xxid+/cihcbY8GA2QjjslUNGKZ0/XsWAcE3MBVyBQLecjDWidyyNbgq/LB0lS8F+U9TKTkrNLqID/HsrGnDlA15NY2Kmz74wYs5tEpm5cJ6PLjaJ+vQ8RlgI6Vk+slExheF1bXoQZrGzdXh6G3ZdPxCKynQ7KUkpRfbpmK6NdAaIf2+B77BnpKRYmLcIkfARv2bugBx571IaN8duAz0JIJIWlubL96eJv7RzzRPrsr378OTjEpO8A+w3LyOprhHJ0MYkmeItMKQKl+k=
9
- gem: strudel
10
- on:
11
- tags: true
12
- repo: justinhoward/strudel
13
- addons:
14
- code_climate:
15
- repo_token:
16
- secure: "fSiRB01llLIkzTLFuRHKDwTHJYelGo7+T4q1WZq9/qBuulCzIBUS0VdS7YyZIY0WVhrdhDUVIzNmESt3nGguL9By5TasrMi4HkdaL/WQPQnn/nH4vwkyOFex1mYa/lEmUnYW6fdVWvq9aS79P20zUCcK5EBFqmWZ/jTe7ssFV9u88QwR/NOa1gH8uabsBwefFlg8hKWi+G4DKRtNuOF0dGmiE6bG3VAKv/n16WRXIfyzFHDdNdrURJObHTEzEW7+Q7JNDRsuAcaSwGAWQtOC3RZmUKWfvIy33wJE+amIhL0GHhXJ3L2s1W/pSc/eiIMg1zsGJsbeUg2VdE4XFIRY9nRamXYtCl85IYct9P1nSB4mMXC1ezCN4fmYS0CBfsBJqzEw13mRf2G3qk65z5CYPHIdL0qZ2qHvRw2tz+EVShFk9mLd9g57KsbeGcq+7daOcSMVGo4ypEd/fx512kaWdUxzZQlEZ2YqIFFI3na4aC/dZmmSFdlghtSZCtYnxz/6ZzoHvx+9rZrcR3FNNB+A3TDGynRfmIZf1ZBqKBdbrocUZ4dODxaI7/82J+y3pFoS3bmb+8r8NevwPce/QwPTesU7hJ9iBMutGLJ0+A6WB4iBpBAwq0H7awKVkluCw/me8ZAD7Nwf8+SBjWCUXX87KbCG3niF+EtKjljgE3Q3cFk="
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
@@ -0,0 +1,4 @@
1
+ --markup markdown
2
+ lib/**/*.rb
3
+ -
4
+ LICENSE.txt
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in strudel.gemspec
data/README.md CHANGED
@@ -1,13 +1,10 @@
1
1
  # Strudel
2
2
 
3
- [![Build Status](https://travis-ci.org/justinhoward/strudel.svg?branch=master)]
4
- (https://travis-ci.org/justinhoward/strudel)
5
- [![Code Climate](https://codeclimate.com/github/justinhoward/strudel/badges/gpa.svg)]
6
- (https://codeclimate.com/github/justinhoward/strudel)
7
- [![Test Coverage](https://codeclimate.com/github/justinhoward/strudel/badges/coverage.svg)]
8
- (https://codeclimate.com/github/justinhoward/strudel/coverage)
9
- [![Inline docs](http://inch-ci.org/github/justinhoward/strudel.svg?branch=master&style=shields)]
10
- (http://inch-ci.org/github/justinhoward/strudel)
3
+ [![Gem Version](https://badge.fury.io/rb/strudel.svg)](https://badge.fury.io/rb/strudel)
4
+ [![Build Status](https://travis-ci.org/justinhoward/strudel.svg?branch=master)](https://travis-ci.org/justinhoward/strudel)
5
+ [![Code Climate](https://codeclimate.com/github/justinhoward/strudel/badges/gpa.svg)](https://codeclimate.com/github/justinhoward/strudel)
6
+ [![Test Coverage](https://codeclimate.com/github/justinhoward/strudel/badges/coverage.svg)](https://codeclimate.com/github/justinhoward/strudel)
7
+ [![Inline docs](http://inch-ci.org/github/justinhoward/strudel.svg?branch=master)](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 a egregious
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 [inline][inline-docs], or you can generate HTML documentation
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/rake yard
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
- [inline-docs]: lib/strudel.rb
121
+ [docs]: http://www.rubydoc.info/github/justinhoward/strudel
@@ -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 "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
13
+ '../../Gemfile',
14
+ Pathname.new(__FILE__).realpath
15
+ )
12
16
 
13
- require "rubygems"
14
- require "bundler/setup"
17
+ require 'rubygems'
18
+ require 'bundler/setup'
15
19
 
16
- load Gem.bin_path("rspec-core", "rspec")
20
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -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 "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
13
+ '../../Gemfile',
14
+ Pathname.new(__FILE__).realpath
15
+ )
12
16
 
13
- require "rubygems"
14
- require "bundler/setup"
17
+ require 'rubygems'
18
+ require 'bundler/setup'
15
19
 
16
- load Gem.bin_path("yard", "yard")
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 "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
13
+ '../../Gemfile',
14
+ Pathname.new(__FILE__).realpath
15
+ )
12
16
 
13
- require "rubygems"
14
- require "bundler/setup"
17
+ require 'rubygems'
18
+ require 'bundler/setup'
15
19
 
16
- load Gem.bin_path("yard", "yardoc")
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 "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
13
+ '../../Gemfile',
14
+ Pathname.new(__FILE__).realpath
15
+ )
12
16
 
13
- require "rubygems"
14
- require "bundler/setup"
17
+ require 'rubygems'
18
+ require 'bundler/setup'
15
19
 
16
- load Gem.bin_path("yard", "yri")
20
+ load Gem.bin_path('yard', 'yri')
@@ -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 +nil+.
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 +service+ is a Proc, its return value will be treated as a
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 +set+ method to allow using a block instead of a Proc argument.
42
+ # Use the `set` method to allow using a block instead of a Proc argument.
39
43
  #
40
- # If +service+ is not a function, its value will be stored directly.
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 +[]=+ except allows passing a block instead of a Proc argument.
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 || Proc.new, @procs)
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 +factory+ is a function, it will be called every time the service is
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 +factory+ is not a function, this method acts like +set+.
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 || Proc.new, @factories)
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 +service+ is a function, the function itself will be registered as a
81
- # service. So when it is requested with +get+, the function will be returned
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 +service+ is not a function, this method acts like +set+.
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 || Proc.new)
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 +extender+ block will be called with 2 arguments: +old_value+ and
97
- # +self+. If there is no existing +key+ service, +old_value+ will be nil. It
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 +extend+ is called for a service that was created with +set+, the
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 +extend+ is called for a service that was created with +factory+, the
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 +extend+ is called for a service that was created with +protect+, the
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 +extender+ is not a function, this method will override any existing
111
- # service like +set+.
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 ||= Proc.new
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 +Enumerable+ of the keys.
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 +key+ exists.
147
+ # Checks if a service for `key` exists.
143
148
  #
144
149
  # @return [bool] True if the service exists.
145
150
  def include?(key)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Strudel
4
+ # The current Strudel gem version
5
+ VERSION = '1.0.2'
6
+
7
+ def self.version
8
+ Gem::Version.new(VERSION)
9
+ end
10
+ end
@@ -1,10 +1,12 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
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 = '0.1.0'
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 'rake', '~> 10.0'
21
- spec.add_development_dependency 'rspec'
22
- spec.add_development_dependency 'yard'
23
- spec.add_development_dependency 'simplecov'
24
- spec.add_development_dependency 'rubocop'
25
- spec.add_development_dependency 'codeclimate-test-reporter'
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: 0.1.0
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: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: redcarpet
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '10.0'
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: '10.0'
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: '0'
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: '0'
40
+ version: '3.4'
41
41
  - !ruby/object:Gem::Dependency
42
- name: yard
42
+ name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
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: '0'
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: rubocop
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: '0'
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: '0'
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
- - Rakefile
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
- rubyforge_project:
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
@@ -1,11 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'rubocop/rake_task'
4
- require 'yard'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
- RuboCop::RakeTask.new
8
- YARD::Rake::YardocTask.new
9
-
10
- task default: :check
11
- task check: [:rubocop, :spec]
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")