ioc_rb 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cdaa166b74b872446a6ae30c0b18ddc7a74e94c
4
- data.tar.gz: 41f3d362e8e3f257a0efdcc77c357faf12682c24
3
+ metadata.gz: 9180db4952fb3ef76a877f9b02154eb1e3b45668
4
+ data.tar.gz: 49683687fc9e53c94e0b20a4c524f53823d0b25e
5
5
  SHA512:
6
- metadata.gz: 794093273697db155d7b6e975b2b8f5ce47d40c01c983d0f80b8d337979fb21048cefd9b0a8a7c1d6337bcccd6485a09f58904d60e42b152f97d80ff686edecd
7
- data.tar.gz: 72527ab78b9f818f428fa0c7dd2781654af3a7d4fe3be38f6b0a2df82cebfaeb12ad5796158555c7c45fd3f4017094453f3e280623b286f5dc1f0f1dc371fdc2
6
+ metadata.gz: b1b259e9c84ef988c3040ce5d4ddd0cbb677ff35309c2351e90f9154b9e5b924c43acb6d6ae7b296c164ecb773d7c732c3009ab6acc8ad399d712c7a00d01804
7
+ data.tar.gz: 631f9b15dca44d60ec8e7a066c9c841b2f7a4670ce8f8cc72d8e4ef7002023938e2dd89d917a320cef401999efb79bd1904c96bf52a47ef5e301fa08740aaee4
@@ -1,23 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ioc_rb (0.4.0)
5
- activesupport
4
+ ioc_rb (0.5.0)
6
5
  request_store
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- activesupport (4.2.0)
12
- i18n (~> 0.7)
13
- json (~> 1.7, >= 1.7.7)
14
- minitest (~> 5.1)
15
- thread_safe (~> 0.3, >= 0.3.4)
16
- tzinfo (~> 1.1)
17
10
  diff-lcs (1.2.5)
18
- i18n (0.7.0)
19
- json (1.8.3)
20
- minitest (5.8.3)
21
11
  rake (10.1.1)
22
12
  request_store (1.0.5)
23
13
  rspec (2.14.1)
@@ -28,9 +18,6 @@ GEM
28
18
  rspec-expectations (2.14.4)
29
19
  diff-lcs (>= 1.1.3, < 2.0)
30
20
  rspec-mocks (2.14.4)
31
- thread_safe (0.3.5)
32
- tzinfo (1.2.2)
33
- thread_safe (~> 0.1)
34
21
 
35
22
  PLATFORMS
36
23
  ruby
@@ -42,4 +29,4 @@ DEPENDENCIES
42
29
  rspec
43
30
 
44
31
  BUNDLED WITH
45
- 1.11.2
32
+ 1.13.6
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "request_store"
22
- spec.add_dependency "activesupport"
23
22
  spec.add_development_dependency "bundler", "~> 1.3"
24
23
  spec.add_development_dependency "rake"
25
24
  end
@@ -0,0 +1,181 @@
1
+ ##### vendored code from active_support (5.0.0) for Class.class_attribute ####
2
+ # require 'active_support/core_ext/class/attribute'
3
+ # require 'active_support/core_ext/kernel/singleton_class'
4
+ # require 'active_support/core_ext/module/remove_method'
5
+ # require 'active_support/core_ext/array/extract_options'
6
+
7
+ unless defined?(ActiveSupport)
8
+ class Module
9
+ def remove_possible_method(method)
10
+ if method_defined?(method) || private_method_defined?(method)
11
+ undef_method(method)
12
+ end
13
+ end
14
+
15
+ def redefine_method(method, &block)
16
+ remove_possible_method(method)
17
+ define_method(method, &block)
18
+ end
19
+ end
20
+
21
+ module Kernel
22
+ # class_eval on an object acts like singleton_class.class_eval.
23
+ def class_eval(*args, &block)
24
+ singleton_class.class_eval(*args, &block)
25
+ end
26
+ end
27
+
28
+ class Hash
29
+ # By default, only instances of Hash itself are extractable.
30
+ # Subclasses of Hash may implement this method and return
31
+ # true to declare themselves as extractable. If a Hash
32
+ # is extractable, Array#extract_options! pops it from
33
+ # the Array when it is the last element of the Array.
34
+ def extractable_options?
35
+ instance_of?(Hash)
36
+ end
37
+ end
38
+
39
+ class Array
40
+ # Extracts options from a set of arguments. Removes and returns the last
41
+ # element in the array if it's a hash, otherwise returns a blank hash.
42
+ #
43
+ # def options(*args)
44
+ # args.extract_options!
45
+ # end
46
+ #
47
+ # options(1, 2) # => {}
48
+ # options(1, 2, a: :b) # => {:a=>:b}
49
+ def extract_options!
50
+ if last.is_a?(Hash) && last.extractable_options?
51
+ pop
52
+ else
53
+ {}
54
+ end
55
+ end
56
+ end
57
+
58
+ class Class
59
+ # Declare a class-level attribute whose value is inheritable by subclasses.
60
+ # Subclasses can change their own value and it will not impact parent class.
61
+ #
62
+ # class Base
63
+ # class_attribute :setting
64
+ # end
65
+ #
66
+ # class Subclass < Base
67
+ # end
68
+ #
69
+ # Base.setting = true
70
+ # Subclass.setting # => true
71
+ # Subclass.setting = false
72
+ # Subclass.setting # => false
73
+ # Base.setting # => true
74
+ #
75
+ # In the above case as long as Subclass does not assign a value to setting
76
+ # by performing <tt>Subclass.setting = _something_ </tt>, <tt>Subclass.setting</tt>
77
+ # would read value assigned to parent class. Once Subclass assigns a value then
78
+ # the value assigned by Subclass would be returned.
79
+ #
80
+ # This matches normal Ruby method inheritance: think of writing an attribute
81
+ # on a subclass as overriding the reader method. However, you need to be aware
82
+ # when using +class_attribute+ with mutable structures as +Array+ or +Hash+.
83
+ # In such cases, you don't want to do changes in places but use setters:
84
+ #
85
+ # Base.setting = []
86
+ # Base.setting # => []
87
+ # Subclass.setting # => []
88
+ #
89
+ # # Appending in child changes both parent and child because it is the same object:
90
+ # Subclass.setting << :foo
91
+ # Base.setting # => [:foo]
92
+ # Subclass.setting # => [:foo]
93
+ #
94
+ # # Use setters to not propagate changes:
95
+ # Base.setting = []
96
+ # Subclass.setting += [:foo]
97
+ # Base.setting # => []
98
+ # Subclass.setting # => [:foo]
99
+ #
100
+ # For convenience, an instance predicate method is defined as well.
101
+ # To skip it, pass <tt>instance_predicate: false</tt>.
102
+ #
103
+ # Subclass.setting? # => false
104
+ #
105
+ # Instances may overwrite the class value in the same way:
106
+ #
107
+ # Base.setting = true
108
+ # object = Base.new
109
+ # object.setting # => true
110
+ # object.setting = false
111
+ # object.setting # => false
112
+ # Base.setting # => true
113
+ #
114
+ # To opt out of the instance reader method, pass <tt>instance_reader: false</tt>.
115
+ #
116
+ # object.setting # => NoMethodError
117
+ # object.setting? # => NoMethodError
118
+ #
119
+ # To opt out of the instance writer method, pass <tt>instance_writer: false</tt>.
120
+ #
121
+ # object.setting = false # => NoMethodError
122
+ #
123
+ # To opt out of both instance methods, pass <tt>instance_accessor: false</tt>.
124
+ def class_attribute(*attrs)
125
+ options = attrs.extract_options!
126
+ instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true)
127
+ instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true)
128
+ instance_predicate = options.fetch(:instance_predicate, true)
129
+
130
+ attrs.each do |name|
131
+ define_singleton_method(name) { nil }
132
+ define_singleton_method("#{name}?") { !!public_send(name) } if instance_predicate
133
+
134
+ ivar = "@#{name}"
135
+
136
+ define_singleton_method("#{name}=") do |val|
137
+ singleton_class.class_eval do
138
+ remove_possible_method(name)
139
+ define_method(name) { val }
140
+ end
141
+
142
+ if singleton_class?
143
+ class_eval do
144
+ remove_possible_method(name)
145
+ define_method(name) do
146
+ if instance_variable_defined? ivar
147
+ instance_variable_get ivar
148
+ else
149
+ singleton_class.send name
150
+ end
151
+ end
152
+ end
153
+ end
154
+ val
155
+ end
156
+
157
+ if instance_reader
158
+ remove_possible_method name
159
+ define_method(name) do
160
+ if instance_variable_defined?(ivar)
161
+ instance_variable_get ivar
162
+ else
163
+ self.class.public_send name
164
+ end
165
+ end
166
+ define_method("#{name}?") { !!public_send(name) } if instance_predicate
167
+ end
168
+
169
+ attr_writer name if instance_writer
170
+ end
171
+ end
172
+
173
+ private
174
+
175
+ unless respond_to?(:singleton_class?)
176
+ def singleton_class?
177
+ ancestors.first != self
178
+ end
179
+ end
180
+ end
181
+ end
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/class/attribute'
1
+ require 'ext/vendored_activesupport'
2
2
  require 'ioc_rb/version'
3
3
  require 'ioc_rb/inject'
4
4
  require 'ioc_rb/container'
@@ -1,3 +1,3 @@
1
1
  module IocRb
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ioc_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Gazizov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-06 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: request_store
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -82,6 +68,7 @@ files:
82
68
  - README.md
83
69
  - Rakefile
84
70
  - ioc_rb.gemspec
71
+ - lib/ext/vendored_activesupport.rb
85
72
  - lib/ioc_rb.rb
86
73
  - lib/ioc_rb/args_validator.rb
87
74
  - lib/ioc_rb/bean_factory.rb
@@ -120,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
107
  version: '0'
121
108
  requirements: []
122
109
  rubyforge_project:
123
- rubygems_version: 2.2.5
110
+ rubygems_version: 2.4.5.1
124
111
  signing_key:
125
112
  specification_version: 4
126
113
  summary: Inversion of Controll Container