schizo 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => "../"
4
+
5
+ gem "activerecord", "~> 3.2.0"
data/.travis.yml CHANGED
@@ -1,4 +1,12 @@
1
- language: ruby
2
1
  rvm:
3
2
  - 1.9.2
4
3
  - 1.9.3
4
+ gemfiles:
5
+ - .gemfiles/Gemfile.activerecord-3.2
6
+ - Gemfile
7
+ matrix:
8
+ include:
9
+ - rvm: 1.9.2
10
+ gemfile: .gemfiles/Gemfile.activerecord-3.2
11
+ - rvm: 1.9.3
12
+ gemfile: Gemfile
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.1.3
2
+ * Specify multiple roles as argument list to #as (andriytyurnikov)
3
+
1
4
  0.1.2
2
5
  * Allow roles to be namespaced
3
6
 
data/lib/schizo/data.rb CHANGED
@@ -18,13 +18,19 @@ module Schizo
18
18
  # poster = user.as(Poster)
19
19
  # poster.name = "coco"
20
20
  # user.name # => "callie"
21
- def as(role, &block)
22
- facade = Facade::ObjectBuilder.new(self, role).product
23
- if block_given?
24
- block.call(facade)
25
- facade.actualize
21
+ def as(*roles, &block)
22
+ first_role = roles.first
23
+ rest_roles = *roles[1..-1]
24
+ if rest_roles.empty?
25
+ facade = Facade::ObjectBuilder.new(self, first_role).product
26
+ if block_given?
27
+ block.call(facade)
28
+ facade.actualize
29
+ else
30
+ facade
31
+ end
26
32
  else
27
- facade
33
+ as(first_role).as(*rest_roles, &block)
28
34
  end
29
35
  end
30
36
 
@@ -1,3 +1,3 @@
1
1
  module Schizo #:nodoc:
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/spec/nested_spec.rb CHANGED
@@ -46,12 +46,18 @@ describe "a nested facade for ClassA with RoleA, RoleB and RoleC" do
46
46
  facade_b.as(role_c)
47
47
  end
48
48
 
49
+ let(:facade_a_b_c) do
50
+ object.as(role_a, role_b, role_c)
51
+ end
52
+
49
53
  it "#instance_of?(ClassA) is true" do
50
54
  facade_c.should be_instance_of(class_a)
55
+ facade_a_b_c.should be_instance_of(class_a)
51
56
  end
52
57
 
53
58
  it "#kind_of?(ClassA) is true" do
54
59
  facade_c.should be_kind_of(class_a)
60
+ facade_a_b_c.should be_kind_of(class_a)
55
61
  end
56
62
 
57
63
  it "should have methods from RoleA, RoleB and RoleC" do
@@ -66,6 +72,10 @@ describe "a nested facade for ClassA with RoleA, RoleB and RoleC" do
66
72
  facade_c.should respond_to(:set_foo)
67
73
  facade_c.should respond_to(:set_bar)
68
74
  facade_c.should respond_to(:set_baz)
75
+
76
+ facade_a_b_c.should respond_to(:set_foo)
77
+ facade_a_b_c.should respond_to(:set_bar)
78
+ facade_a_b_c.should respond_to(:set_baz)
69
79
  end
70
80
 
71
81
  it "#actualize should walk up the chain" do
metadata CHANGED
@@ -1,82 +1,112 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schizo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
4
  prerelease:
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Christopher J. Bottaro
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-11 00:00:00.000000000 Z
12
+ date: 2013-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ prerelease: false
15
16
  name: rspec
16
- requirement: &70253933607880 !ruby/object:Gem::Requirement
17
+ type: :development
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
17
23
  none: false
24
+ requirement: !ruby/object:Gem::Requirement
18
25
  requirements:
19
26
  - - ! '>='
20
27
  - !ruby/object:Gem::Version
21
28
  version: '0'
22
- type: :development
23
- prerelease: false
24
- version_requirements: *70253933607880
29
+ none: false
25
30
  - !ruby/object:Gem::Dependency
31
+ prerelease: false
26
32
  name: activerecord
27
- requirement: &70253933607240 !ruby/object:Gem::Requirement
33
+ type: :development
34
+ version_requirements: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
28
39
  none: false
40
+ requirement: !ruby/object:Gem::Requirement
29
41
  requirements:
30
42
  - - ! '>='
31
43
  - !ruby/object:Gem::Version
32
44
  version: '0'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70253933607240
45
+ none: false
36
46
  - !ruby/object:Gem::Dependency
47
+ prerelease: false
37
48
  name: sqlite3
38
- requirement: &70253933606580 !ruby/object:Gem::Requirement
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
39
55
  none: false
56
+ requirement: !ruby/object:Gem::Requirement
40
57
  requirements:
41
58
  - - ! '>='
42
59
  - !ruby/object:Gem::Version
43
60
  version: '0'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70253933606580
61
+ none: false
47
62
  - !ruby/object:Gem::Dependency
63
+ prerelease: false
48
64
  name: rdoc
49
- requirement: &70253933605840 !ruby/object:Gem::Requirement
65
+ type: :development
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
50
71
  none: false
72
+ requirement: !ruby/object:Gem::Requirement
51
73
  requirements:
52
74
  - - ! '>='
53
75
  - !ruby/object:Gem::Version
54
76
  version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70253933605840
77
+ none: false
58
78
  - !ruby/object:Gem::Dependency
79
+ prerelease: false
59
80
  name: pry
60
- requirement: &70253933604920 !ruby/object:Gem::Requirement
81
+ type: :development
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
61
87
  none: false
88
+ requirement: !ruby/object:Gem::Requirement
62
89
  requirements:
63
90
  - - ! '>='
64
91
  - !ruby/object:Gem::Version
65
92
  version: '0'
66
- type: :development
67
- prerelease: false
68
- version_requirements: *70253933604920
93
+ none: false
69
94
  - !ruby/object:Gem::Dependency
95
+ prerelease: false
70
96
  name: rake
71
- requirement: &70253933604120 !ruby/object:Gem::Requirement
97
+ type: :development
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
72
103
  none: false
104
+ requirement: !ruby/object:Gem::Requirement
73
105
  requirements:
74
106
  - - ! '>='
75
107
  - !ruby/object:Gem::Version
76
108
  version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *70253933604120
109
+ none: false
80
110
  description: DCI (data, context and interaction) for Ruby / Rails / ActiveRecord
81
111
  email:
82
112
  - cjbottaro@alumni.cs.utexas.edu
@@ -84,6 +114,7 @@ executables: []
84
114
  extensions: []
85
115
  extra_rdoc_files: []
86
116
  files:
117
+ - .gemfiles/Gemfile.activerecord-3.2
87
118
  - .gitignore
88
119
  - .travis.yml
89
120
  - CHANGELOG
@@ -117,26 +148,26 @@ rdoc_options: []
117
148
  require_paths:
118
149
  - lib
119
150
  required_ruby_version: !ruby/object:Gem::Requirement
120
- none: false
121
151
  requirements:
122
152
  - - ! '>='
123
153
  - !ruby/object:Gem::Version
124
- version: '0'
125
154
  segments:
126
155
  - 0
127
- hash: -2531469905963506492
128
- required_rubygems_version: !ruby/object:Gem::Requirement
156
+ hash: -3318887318708841529
157
+ version: '0'
129
158
  none: false
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
160
  requirements:
131
161
  - - ! '>='
132
162
  - !ruby/object:Gem::Version
133
- version: '0'
134
163
  segments:
135
164
  - 0
136
- hash: -2531469905963506492
165
+ hash: -3318887318708841529
166
+ version: '0'
167
+ none: false
137
168
  requirements: []
138
169
  rubyforge_project: schizo
139
- rubygems_version: 1.8.11
170
+ rubygems_version: 1.8.23
140
171
  signing_key:
141
172
  specification_version: 3
142
173
  summary: DCI (data, context and interaction) for Ruby / Rails / ActiveRecord