dumpling 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f35ab64a03b696579240966d5b7bc3319c004e3
4
- data.tar.gz: b6ed032e93f0ad3c83b404034ff4d4e0e4dd7ce3
3
+ metadata.gz: b5d404a4a72ad2d88b92a4008aa5c875e52d6413
4
+ data.tar.gz: 492a47199347c218b0cb6b5cb3dad15a95695af6
5
5
  SHA512:
6
- metadata.gz: 16d1109b05bd418eb468d03e9f143f9ac3be88ee93c8bc522dff96308b26f48a335326a67249e12d0aea471b8f5457546a183d1554eb71e70bc1fc9ea42d1f0d
7
- data.tar.gz: c255e615a20097481c66d7baf3b0627e338f878c6c2a9c3c16ed89d534e7e4ef31d3160c77f95c5edfcee971cf67c4b43b9f56efd77090131a3bbbaedc39bdcd
6
+ metadata.gz: 968bb215aa7e4f57291e65c32623107c1754add1860cc5fac55c14ffa9ce90e01969383d0ab21c2b0b2214214e15d00c90968c3b39e21425e5dbe4bf03e66a5c
7
+ data.tar.gz: 17530a9342d58289fec18806a023c4c6057bf8dc4eb15cad8f4c8c2aaa8facf25e9c98fa9bfcb62dfd39cc09bcff0cdd922decab655ed603e67ab7ea48aaaac7
data/.travis.yml CHANGED
@@ -1,4 +1,16 @@
1
1
  language: ruby
2
- rvm:
3
- - 2.2.4
4
2
  before_install: gem install bundler -v 1.11.2
3
+ script:
4
+ - bundle exec rake spec
5
+ rvm:
6
+ - 2.2
7
+ - jruby-9.0.5.0
8
+ - ruby-head
9
+ - rbx
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
13
+ - rvm: rbx
14
+ notifications:
15
+ email:
16
+ - antonkuzmenko.dev@gmail.com
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in dumpling.gemspec
4
4
  gemspec
5
+
6
+ gem 'codeclimate-test-reporter', group: :test, require: nil
data/README.md CHANGED
@@ -1,5 +1,17 @@
1
+ [gem]: https://rubygems.org/gems/dumpling
2
+ [travis]: https://travis-ci.org/antonkuzmenko/dumpling
3
+ [codeclimate]: https://codeclimate.com/github/antonkuzmenko/dumpling
4
+ [coverage]: https://codeclimate.com/github/antonkuzmenko/dumpling/coverage
5
+ [gemnasium]: https://gemnasium.com/antonkuzmenko/dumpling
6
+
1
7
  # Dumpling
2
8
 
9
+ [![Gem Version](https://badge.fury.io/rb/dumpling.svg)][gem]
10
+ [![Build Status](https://travis-ci.org/antonkuzmenko/dumpling.svg?branch=master)][travis]
11
+ [![Code Climate](https://codeclimate.com/github/antonkuzmenko/dumpling/badges/gpa.svg)][codeclimate]
12
+ [![Test Coverage](https://codeclimate.com/github/antonkuzmenko/dumpling/badges/coverage.svg)][coverage]
13
+ [![Dependency Status](https://gemnasium.com/antonkuzmenko/dumpling.svg)][gemnasium]
14
+
3
15
  Dumpling provides you an unobtrusive way to manage dependencies.
4
16
  What is unobtrusive? Unobtrusive means that you don't need to include a module or inherit a class anywhere in your project.
5
17
  Dumpling does not tie your hands. All you have to do is just wire up dependencies.
@@ -120,6 +132,30 @@ container.configure do
120
132
  end
121
133
  ```
122
134
 
135
+ ### Defining abstract services
136
+
137
+ ```ruby
138
+ container = Dumpling::Container.new
139
+ container.configure do
140
+ abstract :repository do |s|
141
+ s.dependency :logger
142
+ s.dependency :persistence_adapter
143
+ end
144
+
145
+ set :users_repository do |s|
146
+ s.class UsersRepository
147
+ s.include :repository
148
+ end
149
+
150
+ set :posts_repository do |s|
151
+ s.class PostsRepository
152
+ s.include :repository
153
+ # overriding dependencies
154
+ s.dependency :postgres_adapter, attribute: :persistence_adapter
155
+ end
156
+ end
157
+ ```
158
+
123
159
  ## Development
124
160
 
125
161
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/dumpling.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.required_ruby_version = '>= 2.2.2'
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.11'
22
- spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'rake', '~> 11.1'
23
23
  spec.add_development_dependency 'rspec', '~> 3.0'
24
- spec.add_development_dependency 'rubocop', '~> 0.36.0'
24
+ spec.add_development_dependency 'rubocop', '~> 0.39.0'
25
25
  spec.add_development_dependency 'simplecov', '~> 0.11'
26
26
  end
@@ -2,12 +2,12 @@ module Dumpling
2
2
  class ClassValidator
3
3
  def validate(specification)
4
4
  unless specification.class.nil? || specification.instance.nil?
5
- fail Errors::Service::Invalid,
6
- 'Do not define both #class and #instance at the same time'
5
+ raise Errors::Service::Invalid,
6
+ 'Do not define both #class and #instance at the same time'
7
7
  end
8
8
 
9
9
  if specification.class.nil? && specification.instance.nil?
10
- fail Errors::Service::Invalid, 'Define #class or #instance'
10
+ raise Errors::Service::Invalid, 'Define #class or #instance'
11
11
  end
12
12
  end
13
13
  end
@@ -11,7 +11,7 @@ module Dumpling
11
11
  end
12
12
 
13
13
  def set(id, &block)
14
- fail(Errors::Container::Duplicate, id) if @services.has?(id)
14
+ raise(Errors::Container::Duplicate, id) if @services.has?(id)
15
15
 
16
16
  specification = create_specification(&block)
17
17
  @services.set(id, specification)
@@ -19,7 +19,7 @@ module Dumpling
19
19
  end
20
20
 
21
21
  def abstract(id, &block)
22
- fail(Errors::Container::Duplicate, id) if @abstract_services.has?(id)
22
+ raise(Errors::Container::Duplicate, id) if @abstract_services.has?(id)
23
23
 
24
24
  specification = create_abstract_specification(&block)
25
25
  @abstract_services.set(id, specification)
@@ -27,7 +27,7 @@ module Dumpling
27
27
  end
28
28
 
29
29
  def get(id)
30
- fail(Errors::Container::Missing, id) unless @services.has?(id)
30
+ raise(Errors::Container::Missing, id) unless @services.has?(id)
31
31
 
32
32
  specification = @services.get(id)
33
33
  build_service(specification)
@@ -13,7 +13,7 @@ module Dumpling
13
13
  missing_services.concat(missing_abstract_services)
14
14
 
15
15
  unless missing_services.empty?
16
- fail Errors::Service::MissingDependencies, missing_services.join(', ')
16
+ raise Errors::Service::MissingDependencies, missing_services.join(', ')
17
17
  end
18
18
  end
19
19
 
@@ -4,7 +4,7 @@ module Dumpling
4
4
  @services = services
5
5
  @abstract_services = abstract_services
6
6
  end
7
-
7
+
8
8
  def build(specification)
9
9
  instance = service_instance(specification)
10
10
  dependencies = service_dependencies(specification)
@@ -14,7 +14,7 @@ module Dumpling
14
14
  end
15
15
  instance
16
16
  end
17
-
17
+
18
18
  private
19
19
 
20
20
  def service_instance(specification)
@@ -2,7 +2,7 @@ module Dumpling
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 0
5
+ TINY = 1
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.').freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumpling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Kuzmenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-13 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '11.1'
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: '10.0'
40
+ version: '11.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.36.0
61
+ version: 0.39.0
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.36.0
68
+ version: 0.39.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement