inversion 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == v0.1.1 [2011-09-23] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Bugfix for the Subscribe tag.
4
+
5
+
1
6
  == v0.1.0 [2011-09-23] Michael Granger <ged@FaerieMUD.org>
2
7
 
3
8
  - Added template reloading via Inversion::Template#changed?
data/README.rdoc CHANGED
@@ -75,39 +75,6 @@ one. The resulting template object will be set as the body of the layout templat
75
75
  when the enclosing template is rendered. Templates can be nested this way as deeply as you like.
76
76
 
77
77
 
78
- === Tags To Implement
79
-
80
- * <?prettyprint «attr/methodchain» ?>
81
-
82
- * <?render «attr/methodchain» AS «identifier» IN «template path» ?>
83
-
84
-
85
- === Tags Implemented
86
-
87
- * <?attr?>
88
- * <?call?>
89
- * <?comment?>…<?end?>
90
- * <?for obj, i in attr.each_with_index ?>
91
- <?end?>
92
- * <?config
93
- escaping: 'html'
94
- ignore_unknown_tags: false
95
- ?>
96
- * <?include other_template.tmpl ?>
97
- * <?escape obj.some_method ?>
98
- * <?urlencode obj.some_method ?>
99
- * <?pp obj ?>
100
- * <?if obj.some_method ?>…<?elsif otherobj.some_method ?>…<?else?>…<?end?>
101
- * <?unless obj.some_method ?>..<?end ?>
102
- * <?import attrname ?>
103
- * <?publish identifier ?>...<?end publish ?>
104
- * <?subscribe identifier ?>
105
- * <?timedelta obj.time_method ?>
106
- * <?yield ?>
107
- * <?default attribute to value ?>
108
- * <?begin ?>…<?rescue ?>…<?end?>
109
-
110
-
111
78
  == References
112
79
 
113
80
  * Inversion of Control: http://en.wikipedia.org/wiki/Inversion_of_control
data/lib/inversion.rb CHANGED
@@ -26,10 +26,10 @@ module Inversion
26
26
  require 'inversion/monkeypatches'
27
27
 
28
28
  # Library version constant
29
- VERSION = '0.1.0'
29
+ VERSION = '0.1.1'
30
30
 
31
31
  # Version-control revision constant
32
- REVISION = %q$Revision: dbc96c7b052a $
32
+ REVISION = %q$Revision: d700486aff8c $
33
33
 
34
34
  #
35
35
  # Logging
@@ -196,9 +196,12 @@ class Inversion::RenderState
196
196
  ### Publish the given +nodes+ to all subscribers to the specified +key+.
197
197
  def publish( key, *nodes )
198
198
  key = key.to_sym
199
+ self.log.debug "[0x%016x] Publishing %p nodes: %p" % [ self.object_id * 2, key, nodes ]
199
200
 
200
201
  self.containerstate.publish( key, *nodes ) if self.containerstate
201
202
  self.subscriptions[ key ].each do |subscriber|
203
+ self.log.debug " sending %d nodes to subscriber: %p (a %p)" %
204
+ [ nodes.length, subscriber, subscriber.class ]
202
205
  subscriber.publish( *nodes )
203
206
  end
204
207
  end
@@ -51,10 +51,17 @@ class Inversion::Template::SubscribeTag < Inversion::Template::Tag
51
51
  # The name of the key the nodes will be published under
52
52
  attr_reader :key
53
53
 
54
+ # The tag's default value if nothing matching its key is published
55
+ attr_reader :default
56
+
57
+ # The content publish to the tag so far during the current render
58
+ attr_reader :content
59
+
54
60
 
55
61
  ### Tell the +renderstate+ that this tag is interested in nodes that are published with
56
62
  ### its key.
57
63
  def before_rendering( renderstate )
64
+ @content.clear
58
65
  renderstate.subscribe( self.key, self )
59
66
  end
60
67
 
@@ -68,6 +75,7 @@ class Inversion::Template::SubscribeTag < Inversion::Template::Tag
68
75
  ### Pub/sub callback. Called from the RenderState when a PublishTag publishes +nodes+
69
76
  ### with the same key as the current tag.
70
77
  def publish( *nodes )
78
+ self.log.debug "Adding published nodes %p to %p" % [ nodes, @content ]
71
79
  @content.push( *nodes )
72
80
  end
73
81
 
@@ -84,5 +92,17 @@ class Inversion::Template::SubscribeTag < Inversion::Template::Tag
84
92
  end
85
93
  end
86
94
 
95
+
96
+ ### Return a representation of the object in a String suitable for debugging.
97
+ def inspect
98
+ return "#<%p:0x%016x key: %s, default: %p, content: %p>" % [
99
+ self.class,
100
+ self.object_id * 2,
101
+ self.key,
102
+ self.default,
103
+ self.content,
104
+ ]
105
+ end
106
+
87
107
  end # class Inversion::Template::SubscribeTag
88
108
 
@@ -55,6 +55,17 @@ describe Inversion::Template::SubscribeTag do
55
55
  template = Inversion::Template.new( "<?subscribe not_here || default value! ?>" )
56
56
  template.render.should == "default value!"
57
57
  end
58
+
59
+ it "doesn't retain published nodes across renders" do
60
+ template = Inversion::Template.new( '--<?subscribe stylesheets ?>--<?attr subtemplate ?>' )
61
+ subtemplate = Inversion::Template.new( '<?publish stylesheets ?>a style<?end?>(subtemplate)' )
62
+
63
+ template.subtemplate = subtemplate
64
+
65
+ template.render.should == '--a style--(subtemplate)'
66
+ template.render.should == '--a style--(subtemplate)'
67
+ end
68
+
58
69
  end
59
70
 
60
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inversion
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:
@@ -49,11 +49,11 @@ cert_chain:
49
49
  -----END CERTIFICATE-----
50
50
 
51
51
  '
52
- date: 2011-09-23 00:00:00.000000000Z
52
+ date: 2011-09-24 00:00:00.000000000Z
53
53
  dependencies:
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: hoe-mercurial
56
- requirement: &2153364080 !ruby/object:Gem::Requirement
56
+ requirement: &2165958340 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
59
  - - ~>
@@ -61,10 +61,10 @@ dependencies:
61
61
  version: 1.3.0
62
62
  type: :development
63
63
  prerelease: false
64
- version_requirements: *2153364080
64
+ version_requirements: *2165958340
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: hoe-manualgen
67
- requirement: &2153363380 !ruby/object:Gem::Requirement
67
+ requirement: &2165957540 !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements:
70
70
  - - ~>
@@ -72,10 +72,10 @@ dependencies:
72
72
  version: 0.1.1
73
73
  type: :development
74
74
  prerelease: false
75
- version_requirements: *2153363380
75
+ version_requirements: *2165957540
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: hoe-highline
78
- requirement: &2153362780 !ruby/object:Gem::Requirement
78
+ requirement: &2165956880 !ruby/object:Gem::Requirement
79
79
  none: false
80
80
  requirements:
81
81
  - - ~>
@@ -83,10 +83,10 @@ dependencies:
83
83
  version: 0.0.1
84
84
  type: :development
85
85
  prerelease: false
86
- version_requirements: *2153362780
86
+ version_requirements: *2165956880
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: rspec
89
- requirement: &2153362080 !ruby/object:Gem::Requirement
89
+ requirement: &2165956120 !ruby/object:Gem::Requirement
90
90
  none: false
91
91
  requirements:
92
92
  - - ~>
@@ -94,10 +94,10 @@ dependencies:
94
94
  version: 2.6.0
95
95
  type: :development
96
96
  prerelease: false
97
- version_requirements: *2153362080
97
+ version_requirements: *2165956120
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: tilt
100
- requirement: &2153350520 !ruby/object:Gem::Requirement
100
+ requirement: &2165955380 !ruby/object:Gem::Requirement
101
101
  none: false
102
102
  requirements:
103
103
  - - ~>
@@ -105,10 +105,10 @@ dependencies:
105
105
  version: 1.3.2
106
106
  type: :development
107
107
  prerelease: false
108
- version_requirements: *2153350520
108
+ version_requirements: *2165955380
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: sinatra
111
- requirement: &2153349840 !ruby/object:Gem::Requirement
111
+ requirement: &2165954620 !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements:
114
114
  - - ~>
@@ -116,10 +116,10 @@ dependencies:
116
116
  version: 1.2.6
117
117
  type: :development
118
118
  prerelease: false
119
- version_requirements: *2153349840
119
+ version_requirements: *2165954620
120
120
  - !ruby/object:Gem::Dependency
121
121
  name: rack-test
122
- requirement: &2153349080 !ruby/object:Gem::Requirement
122
+ requirement: &2165953860 !ruby/object:Gem::Requirement
123
123
  none: false
124
124
  requirements:
125
125
  - - ~>
@@ -127,10 +127,10 @@ dependencies:
127
127
  version: 0.6.0
128
128
  type: :development
129
129
  prerelease: false
130
- version_requirements: *2153349080
130
+ version_requirements: *2165953860
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: simplecov
133
- requirement: &2153348500 !ruby/object:Gem::Requirement
133
+ requirement: &2165953100 !ruby/object:Gem::Requirement
134
134
  none: false
135
135
  requirements:
136
136
  - - ~>
@@ -138,10 +138,10 @@ dependencies:
138
138
  version: 0.4.2
139
139
  type: :development
140
140
  prerelease: false
141
- version_requirements: *2153348500
141
+ version_requirements: *2165953100
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: hoe-manualgen
144
- requirement: &2153347960 !ruby/object:Gem::Requirement
144
+ requirement: &2165952460 !ruby/object:Gem::Requirement
145
145
  none: false
146
146
  requirements:
147
147
  - - ~>
@@ -149,10 +149,10 @@ dependencies:
149
149
  version: 0.2.0
150
150
  type: :development
151
151
  prerelease: false
152
- version_requirements: *2153347960
152
+ version_requirements: *2165952460
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: trollop
155
- requirement: &2153347420 !ruby/object:Gem::Requirement
155
+ requirement: &2165951760 !ruby/object:Gem::Requirement
156
156
  none: false
157
157
  requirements:
158
158
  - - ~>
@@ -160,10 +160,10 @@ dependencies:
160
160
  version: 1.16.2
161
161
  type: :development
162
162
  prerelease: false
163
- version_requirements: *2153347420
163
+ version_requirements: *2165951760
164
164
  - !ruby/object:Gem::Dependency
165
165
  name: highline
166
- requirement: &2153346780 !ruby/object:Gem::Requirement
166
+ requirement: &2165951060 !ruby/object:Gem::Requirement
167
167
  none: false
168
168
  requirements:
169
169
  - - ~>
@@ -171,10 +171,10 @@ dependencies:
171
171
  version: 1.6.2
172
172
  type: :development
173
173
  prerelease: false
174
- version_requirements: *2153346780
174
+ version_requirements: *2165951060
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: sysexits
177
- requirement: &2153346060 !ruby/object:Gem::Requirement
177
+ requirement: &2165950460 !ruby/object:Gem::Requirement
178
178
  none: false
179
179
  requirements:
180
180
  - - ~>
@@ -182,10 +182,10 @@ dependencies:
182
182
  version: 1.0.2
183
183
  type: :development
184
184
  prerelease: false
185
- version_requirements: *2153346060
185
+ version_requirements: *2165950460
186
186
  - !ruby/object:Gem::Dependency
187
187
  name: hoe
188
- requirement: &2153345500 !ruby/object:Gem::Requirement
188
+ requirement: &2165949880 !ruby/object:Gem::Requirement
189
189
  none: false
190
190
  requirements:
191
191
  - - ~>
@@ -193,7 +193,7 @@ dependencies:
193
193
  version: '2.12'
194
194
  type: :development
195
195
  prerelease: false
196
- version_requirements: *2153345500
196
+ version_requirements: *2165949880
197
197
  description: ! 'Inversion is a templating system for Ruby. It uses the "Inversion
198
198
  of Control" principle to decouple
199
199
 
metadata.gz.sig CHANGED
Binary file