bzproxies 0.1.0 → 0.1.1

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.
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
- #TODO: create global function creting stub for concrete proxy (as same one in Delegate class).
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, :<<].each do |meth|
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
 
@@ -1,7 +1,7 @@
1
1
  require 'bzproxies/owner'
2
2
 
3
- class Object
4
- include Proxies::Owner
3
+ class Module
4
+ include Proxies::Owner::Accessors
5
5
  end
6
6
 
7
7
  class NilClass
@@ -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
- instance_variable_set("@#{name}", val)
34
+ instance_eval("@#{name} = val")
39
35
  end
40
36
  end
41
37
  end
@@ -1,3 +1,3 @@
1
1
  module Bzproxies
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/bzproxies.rb CHANGED
@@ -2,6 +2,7 @@ require "bzproxies/version"
2
2
  require "bzproxies/base"
3
3
  require "bzproxies/owner"
4
4
  require "bzproxies/array_proxy"
5
+ require "bzproxies/core_ext"
5
6
  Proxy = Proxies::Base
6
7
  Owner = Proxies::Owner
7
8
  ArrayProxy = Proxies::ArrayProxy
@@ -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
@@ -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
- # [:replace, :unshift]
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
 
@@ -1,7 +1,7 @@
1
1
  require 'bzproxies'
2
2
 
3
3
  class Ex1
4
- proxy_reader :test, :proxy => Proxies::Base
4
+ proxy_reader :test, :proxy => Proxy
5
5
  def test= any
6
6
  @test = any
7
7
  end
@@ -0,0 +1,9 @@
1
+ require 'bzproxies'
2
+
3
+ class RecursiveTest1 < Proxy
4
+ proxy_accessor :test, :proxy => ::RecursiveTest1
5
+
6
+ def test_method
7
+ true
8
+ end
9
+ end
@@ -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.0
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-21 00:00:00.000000000Z
12
+ date: 2011-10-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &75069720 !ruby/object:Gem::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: *75069720
24
+ version_requirements: *77099130
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &75069470 !ruby/object:Gem::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: *75069470
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: []