dependancy 0.0.3 → 0.0.4

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.
@@ -37,8 +37,15 @@ module Dependancy
37
37
 
38
38
  val
39
39
  end
40
- end
40
+ end # define_method name do
41
41
  end
42
42
  end
43
+
44
+ def private_dependancy(name, &block)
45
+ dependancy name, &block
46
+
47
+ private name
48
+ private "#{name}="
49
+ end
43
50
  end # module ClassMethods
44
51
  end
@@ -1,3 +1,3 @@
1
1
  module Dependancy
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -32,7 +32,11 @@ describe Dependancy do
32
32
  Bar.new
33
33
  end
34
34
 
35
- dependancy :bar5
35
+ private_dependancy :bar5 do
36
+ Bar.new
37
+ end
38
+
39
+ dependancy :bar6
36
40
 
37
41
  def self.counter
38
42
  @count ||= 0
@@ -44,23 +48,22 @@ describe Dependancy do
44
48
  end
45
49
  end
46
50
 
51
+ let(:foo) { Foo.new }
52
+
47
53
  it '._dependancies' do
48
- Foo._dependancies.should have(5).items
54
+ Foo._dependancies.should have(6).items
49
55
  end
50
56
 
51
57
  it 'dependancy have default value' do
52
- foo = Foo.new
53
58
  foo.bar1.should be_a Bar
54
59
  end
55
60
 
56
61
  it 'dependancy could access current object' do
57
- foo = Foo.new
58
62
  bar = foo.bar2
59
63
  bar.name.should == 'foo name'
60
64
  end
61
65
 
62
66
  it 'assign a new dependancy' do
63
- foo = Foo.new
64
67
  old_bar = foo.bar1
65
68
  foo.bar1 = Bar.new
66
69
 
@@ -68,12 +71,10 @@ describe Dependancy do
68
71
  end
69
72
 
70
73
  it 'have nil value if there is error' do
71
- foo = Foo.new
72
74
  foo.bar3.should be_nil
73
75
  end
74
76
 
75
77
  it 'only eval dependancy block once' do
76
- foo = Foo.new
77
78
  foo.bar4
78
79
  foo.bar4.should be_a Bar
79
80
 
@@ -82,4 +83,9 @@ describe Dependancy do
82
83
 
83
84
  Foo.count.should == 1
84
85
  end
86
+
87
+ it '.private_dependancy' do
88
+ expect { foo.bar5 }.to raise_error NoMethodError
89
+ foo.send(:bar5).should be_a Bar
90
+ end
85
91
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependancy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &9991900 !ruby/object:Gem::Requirement
16
+ requirement: &9636550 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *9991900
24
+ version_requirements: *9636550
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard-rspec
27
- requirement: &9991640 !ruby/object:Gem::Requirement
27
+ requirement: &9636330 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *9991640
35
+ version_requirements: *9636330
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-debug19
38
- requirement: &9991370 !ruby/object:Gem::Requirement
38
+ requirement: &9636100 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *9991370
46
+ version_requirements: *9636100
47
47
  description: Getters & setters for dependency injection
48
48
  email:
49
49
  - Aaron2Ti@gmail.com