micon 0.1.27 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/micon/core.rb +2 -4
- data/spec/callbacks_spec.rb +4 -4
- metadata +3 -3
data/lib/micon/core.rb
CHANGED
@@ -171,13 +171,11 @@ class Micon::Core
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def before component, options = {}, &block
|
174
|
-
options[:bang] = true unless options.include? :bang
|
175
174
|
raise_without_self "component :#{component} already created!" if options[:bang] and include?(component)
|
176
175
|
@metadata.register_before component, &block
|
177
176
|
end
|
178
177
|
|
179
178
|
def after component, options = {}, &block
|
180
|
-
options[:bang] = true unless options.include? :bang
|
181
179
|
if include? component
|
182
180
|
if options[:bang]
|
183
181
|
raise_without_self "component :#{component} already created!"
|
@@ -240,7 +238,7 @@ class Micon::Core
|
|
240
238
|
def runtime_path; @runtime_path ||= File.expand_path('.') end
|
241
239
|
def runtime_path= runtime_path
|
242
240
|
runtime_path, force = runtime_path
|
243
|
-
raise "some components
|
241
|
+
raise "some components have been already initialized before You set :runtime_path!" unless empty? or force
|
244
242
|
@runtime_path = runtime_path
|
245
243
|
end
|
246
244
|
def runtime_path?; !!@runtime_path end
|
@@ -251,7 +249,7 @@ class Micon::Core
|
|
251
249
|
def mode; @mode ||= :development end
|
252
250
|
def mode= mode
|
253
251
|
mode, force = mode
|
254
|
-
raise "some components
|
252
|
+
raise "some components have been already initialized before You set :mode!" unless empty? or force
|
255
253
|
@mode = mode
|
256
254
|
end
|
257
255
|
def mode?; !!@mode end
|
data/spec/callbacks_spec.rb
CHANGED
@@ -72,8 +72,8 @@ describe "Callbacks" do
|
|
72
72
|
micon.register(:the_object){"the_object"}
|
73
73
|
micon[:the_object]
|
74
74
|
|
75
|
-
-> {micon.before(:the_object){}}.should raise_error(/already created/)
|
76
|
-
-> {micon.after(:the_object){}}.should raise_error(/already created/)
|
75
|
+
-> {micon.before(:the_object, bang: true){}}.should raise_error(/already created/)
|
76
|
+
-> {micon.after(:the_object, bang: true){}}.should raise_error(/already created/)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should raise error if callback defined after scope already started" do
|
@@ -83,13 +83,13 @@ describe "Callbacks" do
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
it ":after
|
86
|
+
it ":after should execute callback if component already started and also register it as :after callback" do
|
87
87
|
micon.register(:the_object){"the_object"}
|
88
88
|
micon[:the_object]
|
89
89
|
|
90
90
|
check = mock
|
91
91
|
check.should_receive(:first).twice
|
92
|
-
micon.after(:the_object
|
92
|
+
micon.after(:the_object){check.first}
|
93
93
|
|
94
94
|
micon.delete :the_object
|
95
95
|
micon[:the_object]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.28
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-19 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.8.
|
68
|
+
rubygems_version: 1.8.10
|
69
69
|
signing_key:
|
70
70
|
specification_version: 3
|
71
71
|
summary: Silent killer of dependencies and configs
|