bzproxies 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/bzproxies/array_proxy.rb +2 -1
- data/lib/bzproxies/core_ext.rb +2 -2
- data/lib/bzproxies/owner.rb +2 -6
- data/lib/bzproxies/version.rb +1 -1
- data/lib/bzproxies.rb +1 -0
- data/spec/accessors_spec.rb +3 -2
- data/spec/array_proxy_spec.rb +2 -2
- data/spec/fixtures/accessors.rb +1 -1
- data/spec/fixtures/recursive.rb +9 -0
- data/spec/recursive_spec.rb +11 -0
- metadata +8 -6
data/README.md
CHANGED
@@ -30,7 +30,7 @@ You can use some objects that mimics objects covered by proxies:
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
<i>TODO: create global function creting stub for concrete proxy (as same one in Delegate class).</i>
|
34
34
|
|
35
35
|
Than you may use proxy_accessor to specify attribute that will cover some given values with proxy:
|
36
36
|
|
@@ -17,7 +17,7 @@ module Proxies
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
[:concat, :fill, :flatten!, :insert, :map!, :push, :replace, :unshift,
|
20
|
+
[:concat, :fill, :flatten!, :insert, :map!, :push, :replace, :unshift, :<<, :[]=].each do |meth|
|
21
21
|
define_method meth do |*args, &block|
|
22
22
|
@target.send meth, *args, &block
|
23
23
|
unless @proxies.empty? || @target.nil?
|
@@ -30,6 +30,7 @@ module Proxies
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
self
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
data/lib/bzproxies/core_ext.rb
CHANGED
data/lib/bzproxies/owner.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
|
2
2
|
module Proxies
|
3
|
-
module Owner
|
4
|
-
|
5
|
-
def self.included(base)
|
6
|
-
base.send :extend, Accessors
|
7
|
-
end
|
3
|
+
module Owner
|
8
4
|
|
9
5
|
module Accessors
|
10
6
|
|
@@ -35,7 +31,7 @@ module Proxies
|
|
35
31
|
else
|
36
32
|
val = proxy.send :new, v, :proxies => proxies
|
37
33
|
end
|
38
|
-
|
34
|
+
instance_eval("@#{name} = val")
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
data/lib/bzproxies/version.rb
CHANGED
data/lib/bzproxies.rb
CHANGED
data/spec/accessors_spec.rb
CHANGED
@@ -28,6 +28,7 @@ describe Proxies::Owner::Accessors do
|
|
28
28
|
owner = Ex2.new
|
29
29
|
owner.test = a
|
30
30
|
owner.test.proxy?.should be_true
|
31
|
+
owner.test.should == a
|
31
32
|
end
|
32
33
|
|
33
34
|
it "doesnt cover proxy objects and stubs" do
|
@@ -78,8 +79,8 @@ describe Proxies::Owner::Accessors do
|
|
78
79
|
|
79
80
|
it "works properly with array proxy" do
|
80
81
|
owner = Ex5.new
|
81
|
-
owner.children = [1,2]
|
82
|
-
owner.children.should each_respond_to :check
|
82
|
+
owner.children = [1,2,owner]
|
83
|
+
owner.children.should each_respond_to :check
|
83
84
|
end
|
84
85
|
|
85
86
|
end
|
data/spec/array_proxy_spec.rb
CHANGED
@@ -35,10 +35,10 @@ describe Proxies::ArrayProxy do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "covers with this proxy each element that inserted into array" do
|
38
|
-
|
38
|
+
|
39
39
|
@proxy.should each_respond_to :test?
|
40
|
-
test1 = ["one", :two, [3]]
|
41
40
|
|
41
|
+
test1 = ["one", :two, [3]]
|
42
42
|
@proxy.concat test1
|
43
43
|
@proxy.should each_respond_to :test?
|
44
44
|
|
data/spec/fixtures/accessors.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "recursive structures with proxies" do
|
4
|
+
it "should set proxied params properly" do
|
5
|
+
string = "atata"
|
6
|
+
a = RecursiveTest1.new string
|
7
|
+
a.test = "test1"
|
8
|
+
a.test.should == "test1"
|
9
|
+
a.test.test_method.should be_true
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bzproxies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-22 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &77099130 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *77099130
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &77098880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.6'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *77098880
|
36
36
|
description: collection of reusable proxies and accessorsetc.
|
37
37
|
email: bombazook@gmail.com
|
38
38
|
executables: []
|
@@ -59,7 +59,9 @@ files:
|
|
59
59
|
- spec/fixtures/accessors.rb
|
60
60
|
- spec/fixtures/array_proxy.rb
|
61
61
|
- spec/fixtures/base.rb
|
62
|
+
- spec/fixtures/recursive.rb
|
62
63
|
- spec/matchers.rb
|
64
|
+
- spec/recursive_spec.rb
|
63
65
|
- spec/spec_helper.rb
|
64
66
|
homepage: http://github.com/bombazook/bzproxies
|
65
67
|
licenses: []
|