smart_ioc 0.3.9 → 0.5.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: 1952e81bd1c8dd7759dad214db0629d9d7deb1f51ead352d85d76c7375207903
4
- data.tar.gz: b6a18802edbb15c81e9de29ac346e69a126bb05ec743a91c3abddecc31219f75
3
+ metadata.gz: 9d8b979ba9bf2ec07fbd542a155af2fad52bb85fdbffece8cc50f1e3132c8d77
4
+ data.tar.gz: 47478f2706b6e5a262af7de3974825ca8d01b48839716c14d9996749421b390a
5
5
  SHA512:
6
- metadata.gz: fed6928dafae5cf284d1cb1cec295737c0b2823e6f053e62444f6c688bf73e02be5b70a46b95c1f35cf87ac0b7e96d3483a6e72fb058d96c6b239af23f01f013
7
- data.tar.gz: 7028318cd0bcaa4752c44a221af6a4f7b96eccdeadd2e1676aa90a5fb1547817035e8f7a8f346e20a527bdf5bd365ca9cda82f73e51bca918fe77c09d72b512a
6
+ metadata.gz: 530e72ce702c8f328ca21ce183d6f511216cb957511f026b52dbcd110b9fc0b21e418e2005f549cfcea75f1b6e6b7b1de3134e476609a19588755434c058aefb
7
+ data.tar.gz: 75ac2416d31d4e067d9a4e3fb1966edfa3a929771fad2760f7506bf50a8e8b60c0a7b1d0fa72120856230ceb62212256a402ebebd981b548e17a4e5134da73ed
@@ -0,0 +1,34 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Rspec
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['3.1', '3.3']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby-version }}
32
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
33
+ - name: Run tests
34
+ run: bundle exec rspec spec/
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.2
1
+ 3.3.4
data/Gemfile CHANGED
@@ -6,5 +6,6 @@ gemspec
6
6
  group :test do
7
7
  gem 'rspec'
8
8
  gem 'simplecov'
9
+ gem 'simplecov-html', '0.12.3'
9
10
  gem 'byebug'
10
11
  end
data/Gemfile.lock CHANGED
@@ -1,50 +1,53 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_ioc (0.3.9)
4
+ smart_ioc (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  byebug (11.1.3)
10
- codecov (0.2.5)
11
- colorize
12
- json
13
- simplecov
14
- colorize (0.8.1)
15
- diff-lcs (1.4.4)
16
- docile (1.3.2)
17
- json (2.3.1)
18
- rake (13.0.1)
19
- rspec (3.9.0)
20
- rspec-core (~> 3.9.0)
21
- rspec-expectations (~> 3.9.0)
22
- rspec-mocks (~> 3.9.0)
23
- rspec-core (3.9.2)
24
- rspec-support (~> 3.9.3)
25
- rspec-expectations (3.9.2)
10
+ coderay (1.1.3)
11
+ diff-lcs (1.5.1)
12
+ docile (1.4.1)
13
+ method_source (1.1.0)
14
+ pry (0.14.2)
15
+ coderay (~> 1.1)
16
+ method_source (~> 1.0)
17
+ rake (13.2.1)
18
+ rspec (3.13.0)
19
+ rspec-core (~> 3.13.0)
20
+ rspec-expectations (~> 3.13.0)
21
+ rspec-mocks (~> 3.13.0)
22
+ rspec-core (3.13.0)
23
+ rspec-support (~> 3.13.0)
24
+ rspec-expectations (3.13.2)
26
25
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.9.0)
28
- rspec-mocks (3.9.1)
26
+ rspec-support (~> 3.13.0)
27
+ rspec-mocks (3.13.1)
29
28
  diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.9.0)
31
- rspec-support (3.9.3)
32
- simplecov (0.18.5)
29
+ rspec-support (~> 3.13.0)
30
+ rspec-support (3.13.1)
31
+ simplecov (0.22.0)
33
32
  docile (~> 1.1)
34
33
  simplecov-html (~> 0.11)
35
- simplecov-html (0.12.2)
34
+ simplecov_json_formatter (~> 0.1)
35
+ simplecov-html (0.12.3)
36
+ simplecov_json_formatter (0.1.4)
36
37
 
37
38
  PLATFORMS
38
39
  ruby
40
+ x86_64-darwin-23
39
41
 
40
42
  DEPENDENCIES
41
43
  bundler
42
44
  byebug
43
- codecov
45
+ pry
44
46
  rake
45
47
  rspec
46
48
  simplecov
49
+ simplecov-html (= 0.12.3)
47
50
  smart_ioc!
48
51
 
49
52
  BUNDLED WITH
50
- 2.3.25
53
+ 2.5.14
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # SmartIoC
2
- [![Build Status](https://travis-ci.org/ddd-ruby/smart_ioc.png)](https://travis-ci.org/ddd-ruby/smart_ioc)
3
- [![Code Climate](https://codeclimate.com/github/ddd-ruby/smart_ioc/badges/gpa.svg)](https://codeclimate.com/github/ddd-ruby/smart_ioc)
4
- [![codecov](https://codecov.io/gh/ddd-ruby/smart_ioc/branch/master/graph/badge.svg)](https://codecov.io/gh/ddd-ruby/smart_ioc)
5
- [![Dependency Status](https://gemnasium.com/ddd-ruby/smart_ioc.png)](https://gemnasium.com/ddd-ruby/smart_ioc)
2
+ [![Rspec](https://github.com/droidlabs/smart_ioc/workflows/Rspec/badge.svg)](https://github.com/droidlabs/smart_ioc/actions?query=workflow%3ARspec)
3
+ [![Code Climate](https://codeclimate.com/github/ddd-ruby/smart_ioc/badges/gpa.svg)](https://codeclimate.com/github/ddd-ruby/smart_ioc)
6
4
 
7
5
 
8
6
  SmartIoC is a smart and really simple IoC container for Ruby applications.
@@ -10,6 +8,15 @@ SmartIoC is a smart and really simple IoC container for Ruby applications.
10
8
  ## Installation
11
9
  `gem install smart_ioc`
12
10
 
11
+ ## Ruby versions
12
+
13
+ Please install specific smart_ioc version, depending on Ruby version.
14
+
15
+ | Ruby Version | SmartIoC Version |
16
+ | ------------ | ------------ |
17
+ | < 3.0 | 0.3.2 |
18
+ | >= 3.0 | 0.4.0 |
19
+
13
20
  ## Setup
14
21
  Set package name and source package folder with beans. SmartIoC will parse source files and detect bean definitions automatically for you.
15
22
 
data/docs/index.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # SmartIoC
2
- [![Build Status](https://travis-ci.org/ddd-ruby/smart_ioc.png)](https://travis-ci.org/ddd-ruby/smart_ioc)
3
- [![Code Climate](https://codeclimate.com/github/ddd-ruby/smart_ioc/badges/gpa.svg)](https://codeclimate.com/github/ddd-ruby/smart_ioc)
4
- [![codecov](https://codecov.io/gh/ddd-ruby/smart_ioc/branch/master/graph/badge.svg)](https://codecov.io/gh/ddd-ruby/smart_ioc)
5
- [![Dependency Status](https://gemnasium.com/ddd-ruby/smart_ioc.png)](https://gemnasium.com/ddd-ruby/smart_ioc)
6
-
2
+ [![Rspec](https://github.com/droidlabs/smart_ioc/workflows/Rspec/badge.svg)](https://github.com/droidlabs/smart_ioc/actions?query=workflow%3ARspec)
3
+ [![Code Climate](https://codeclimate.com/github/ddd-ruby/smart_ioc/badges/gpa.svg)](https://codeclimate.com/github/ddd-ruby/smart_ioc)
7
4
 
8
5
  SmartIoC is a smart and really simple IoC container for Ruby applications.
9
6
 
@@ -33,7 +33,7 @@ def bean(bean_name, &proc)
33
33
  end
34
34
  end
35
35
  end
36
-
36
+
37
37
  #{klass_name} = klass
38
38
  )
39
39
  )
@@ -56,4 +56,4 @@ def bean(bean_name, &proc)
56
56
  end
57
57
 
58
58
  klass
59
- end
59
+ end
@@ -64,4 +64,15 @@ class SmartIoC::BeanDefinition
64
64
  str << "factory_method: #{@factory_method}"
65
65
  str.join("\n")
66
66
  end
67
+
68
+ def preload
69
+ @dependencies.each do |dep|
70
+ SmartIoC::Container.get_instance.get_bean(
71
+ dep.ref || dep.bean_name,
72
+ package: dep.package,
73
+ parent_bean_definition: self,
74
+ parent_bean_name: name,
75
+ ).class._smart_ioc_preload_; nil
76
+ end
77
+ end
67
78
  end
@@ -34,7 +34,7 @@ class SmartIoC::BeanLocations
34
34
 
35
35
  # @return names of all found beans
36
36
  def all_bean_names
37
- @data.keys
37
+ @data.values.flat_map(&:keys)
38
38
  end
39
39
 
40
40
  def get_bean_by_path(path)
@@ -168,5 +168,9 @@ module SmartIoC::Iocify
168
168
 
169
169
  nil
170
170
  end
171
+
172
+ def _smart_ioc_preload_
173
+ @bean_definition&.preload; nil
174
+ end
171
175
  end
172
176
  end
@@ -1,3 +1,3 @@
1
1
  module SmartIoC
2
- VERSION = "0.3.9"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/smart_ioc.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'smart_ioc/version'
2
2
  require 'benchmark'
3
+ require 'forwardable'
3
4
 
4
5
  module SmartIoC
5
6
  autoload :Args, 'smart_ioc/args'
@@ -74,14 +75,20 @@ module SmartIoC
74
75
  Container.get_instance
75
76
  end
76
77
 
77
- [:register_bean, :get_bean_definition,
78
- :set_extra_context_for_package, :get_bean, :clear_scopes,
79
- :force_clear_scopes, :set_load_proc].each do |name|
80
- define_method name do |*args, &block|
81
- container.send(name, *args, &block)
82
- end
83
- end
78
+ extend Forwardable
79
+
80
+ container_methods = [
81
+ :register_bean,
82
+ :get_bean_definition,
83
+ :set_extra_context_for_package,
84
+ :get_bean,
85
+ :clear_scopes,
86
+ :force_clear_scopes,
87
+ :set_load_proc
88
+ ]
89
+
90
+ def_delegators :container, *container_methods
84
91
  end
85
92
  end
86
93
 
87
- require 'smart_ioc/bean'
94
+ require 'smart_ioc/bean'
data/smart_ioc.gemspec CHANGED
@@ -20,5 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rake'
23
- spec.add_development_dependency "codecov"
23
+ spec.add_development_dependency "pry"
24
24
  end
@@ -13,8 +13,8 @@ describe SmartIoC::BeanLocator do
13
13
  locations = SmartIoC::BeanLocations.get_bean_locations(:repository)
14
14
 
15
15
  expect(locations[:test].size).to eq(3)
16
- expect(locations[:test][0]).to match(/example\/admins\/repository\/test\/admins_repository.rb/)
17
- expect(locations[:test][1]).to match(/example\/admins\/repository\/admins_repository.rb/)
16
+ expect(locations[:test][0]).to match(/example\/admins\/repository\/admins_repository.rb/)
17
+ expect(locations[:test][1]).to match(/example\/admins\/repository\/test\/admins_repository.rb/)
18
18
  expect(locations[:test][2]).to match(/example\/users\/repository\/users_repository.rb/)
19
19
  }
20
20
 
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,13 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'simplecov'
4
+ require 'pry'
4
5
 
5
6
  SimpleCov.start do
6
7
  add_filter "/spec/"
7
8
  add_filter "/.direnv/"
8
9
  end
9
10
 
10
- if ENV['CI']=='true'
11
- require 'codecov'
12
-
13
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
14
- end
15
-
16
11
  require 'smart_ioc'
17
12
 
18
13
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_ioc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-20 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: codecov
42
+ name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -59,10 +59,10 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/rspec.yml"
62
63
  - ".gitignore"
63
64
  - ".rspec"
64
65
  - ".ruby-version"
65
- - ".travis.yml"
66
66
  - ".yardops"
67
67
  - Gemfile
68
68
  - Gemfile.lock
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.1.4
138
+ rubygems_version: 3.5.11
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Inversion of Control Container
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- rvm:
2
- - 2.2.0
3
- - 2.3.0
4
- - 2.4.0
5
- script:
6
- - "gem install bundler"
7
- - "bundle exec rspec spec/"