erector 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 8
4
- :patch: 0
4
+ :patch: 1
@@ -59,7 +59,7 @@ module Erector
59
59
  texts_hash[t] = options.delete(t) if options.has_key? t
60
60
  end
61
61
  texts_hash.each do |t, texts|
62
- texts.each do |text|
62
+ [texts].flatten.each do |text|
63
63
  deps << interpret_args(t, text, options)
64
64
  end
65
65
  end
@@ -79,9 +79,10 @@ module Erector
79
79
 
80
80
  def render_with_externals(options_to_external_renderer = {})
81
81
  output = Erector::Output.new
82
- self.to_a(:output => output)
82
+ self.to_a(:output => output) # render all the externals onto this new output buffer
83
83
  nested_widgets = output.widgets.to_a
84
- externals = ExternalRenderer.new({:classes => nested_widgets}.merge(options_to_external_renderer)).to_html(:output => output)
84
+ renderer = ExternalRenderer.new({:classes => nested_widgets}.merge(options_to_external_renderer))
85
+ externals = renderer.to_a(:output => output)
85
86
  output.to_a
86
87
  end
87
88
 
@@ -62,11 +62,11 @@ module Erector
62
62
  end
63
63
 
64
64
  def to_s
65
- RawString.new(buffer.to_s)
65
+ RawString.new(buffer.kind_of?(String) ? buffer : buffer.join)
66
66
  end
67
67
 
68
68
  def to_a
69
- buffer.to_a
69
+ buffer.kind_of?(Array) ? buffer : [buffer]
70
70
  end
71
71
 
72
72
  def newline
@@ -34,7 +34,7 @@ begin
34
34
  instance_variables_for_widget_assignment_for(cell)
35
35
  end
36
36
  end
37
- rescue NameError
37
+ rescue NameError, ArgumentError
38
38
  end
39
39
 
40
40
  module Erector
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  ##
2
4
  # Erector view framework
3
5
  module Erector
@@ -231,7 +231,9 @@ require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
231
231
  widget.new.to_html(:content_method_name => :bar).should == "bar"
232
232
  end
233
233
 
234
- it "works when passing an existing output as a parameter to to_html"
234
+ it "works when passing an existing output as a parameter to to_html" do
235
+ pending
236
+ end
235
237
  end
236
238
 
237
239
  describe '#widget' do
@@ -98,6 +98,7 @@ module ExternalsSpec
98
98
  x[1].text.should == "bar.js"
99
99
  x[1].type.should == :js
100
100
  end
101
+
101
102
  it "adds multiple files from hash of different types" do
102
103
  x = Test.send :interpret_args, :js => ["foo.js", "bar.js"], :css=>'file.css'
103
104
  x.size.should == 3
@@ -105,6 +106,7 @@ module ExternalsSpec
105
106
  x.map(&:text).include?('bar.js')
106
107
  x.map(&:text).include?('file.css')
107
108
  end
109
+
108
110
  it "adds multiple files from hash and preserves the options" do
109
111
  x = Test.send :interpret_args, :js => ["foo.js", "bar.js"], :foo=>false
110
112
  x.size.should == 2
@@ -211,7 +213,7 @@ module ExternalsSpec
211
213
 
212
214
  it "#render_with_externals sticks the externals for all its rendered sub-widgets at the end of the output buffer" do
213
215
  s = Dinner.new.render_with_externals
214
- s.to_s.should ==
216
+ s.join.should ==
215
217
  "<span>dinner</span>" +
216
218
  "<span>dessert</span>" +
217
219
  "<link href=\"/dessert.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />" +
@@ -222,7 +224,7 @@ module ExternalsSpec
222
224
  it "#render_externals returns externals for all rendered sub-widgets to an output buffer" do
223
225
  widget = Dinner.new
224
226
  widget.to_html
225
- widget.render_externals.to_s.should ==
227
+ widget.render_externals.join.should ==
226
228
  "<link href=\"/dessert.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />" +
227
229
  "<script src=\"/dinner.js\" type=\"text/javascript\"></script>" +
228
230
  "<script src=\"/dessert.js\" type=\"text/javascript\"></script>"
@@ -115,7 +115,7 @@ describe Erector::HTML do
115
115
  object = ['a', 'b']
116
116
  erector do
117
117
  element 'div', object
118
- end.should == "<div>#{object.to_s}</div>"
118
+ end.should == "<div>#{CGI.escapeHTML object.to_s}</div>"
119
119
  end
120
120
  end
121
121
 
@@ -224,11 +224,12 @@ describe Erector::HTML do
224
224
 
225
225
  context "with a non-string, non-raw" do
226
226
  it "calls to_s and quotes" do
227
+ array = [7, "foo&bar"]
227
228
  erector do
228
229
  element 'a' do
229
- text [7, "foo&bar"]
230
+ text array
230
231
  end
231
- end.should == "<a>7foo&amp;bar</a>"
232
+ end.should == "<a>#{CGI.escapeHTML array.to_s}</a>"
232
233
  end
233
234
  end
234
235
  end
@@ -380,7 +381,7 @@ describe Erector::HTML do
380
381
  # be pretty confusing when this method can already take either a name or number
381
382
  lambda {
382
383
  erector { text character([]) }
383
- }.should raise_error("Unrecognized argument to character: ")
384
+ }.should raise_error("Unrecognized argument to character: #{[].to_s}")
384
385
  end
385
386
  end
386
387
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erector
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 0
10
- version: 0.8.0
9
+ - 1
10
+ version: 0.8.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pivotal Labs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-09 00:00:00 -07:00
18
+ date: 2010-07-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency