garterbelt 0.0.6 → 0.0.7

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/TODO CHANGED
@@ -1,5 +1,11 @@
1
1
  increase performance ~10%
2
2
  partial passes down params from parent view
3
- anonymous view
3
+ anonymous views
4
4
 
5
- Rails Helpers
5
+ rails style helpers
6
+
7
+ render styles
8
+ - pretty: current and default
9
+ - compact: argument content in the tags, not new line
10
+ - minified: no new lines or indenting
11
+ - text only: no tags, appropriate new lines according to tag type
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
data/garterbelt.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{garterbelt}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kane Baccigalupi"]
@@ -44,12 +44,14 @@ Gem::Specification.new do |s|
44
44
  "lib/view.rb",
45
45
  "spec/garterbelt_spec.rb",
46
46
  "spec/integration/expectations/general_view.html",
47
+ "spec/integration/expectations/unescaping_view.html",
47
48
  "spec/integration/expectations/variables/view_with_user_and_params.html",
48
49
  "spec/integration/expectations/variables/view_with_user_email.html",
49
50
  "spec/integration/expectations/view_partial_nest.html",
50
51
  "spec/integration/expectations/view_with_forms.html",
51
52
  "spec/integration/expectations/view_with_tags.html",
52
53
  "spec/integration/templates/form.rb",
54
+ "spec/integration/templates/unescaping_view.rb",
53
55
  "spec/integration/templates/view_partial_nest.rb",
54
56
  "spec/integration/templates/view_with_cache.rb",
55
57
  "spec/integration/templates/view_with_forms.rb",
@@ -87,6 +89,7 @@ Gem::Specification.new do |s|
87
89
  s.test_files = [
88
90
  "spec/garterbelt_spec.rb",
89
91
  "spec/integration/templates/form.rb",
92
+ "spec/integration/templates/unescaping_view.rb",
90
93
  "spec/integration/templates/view_partial_nest.rb",
91
94
  "spec/integration/templates/view_with_cache.rb",
92
95
  "spec/integration/templates/view_with_forms.rb",
@@ -1,11 +1,12 @@
1
1
  module Garterbelt
2
2
  class Text < Renderer
3
- attr_accessor :content
3
+ attr_accessor :content, :escape
4
4
 
5
5
  def initialize(opts)
6
6
  super
7
7
  raise ArgumentError, ":content option required for #{self.class} initialization" unless opts[:content]
8
8
  self.content = opts[:content]
9
+ self.escape = view.escape
9
10
  end
10
11
 
11
12
  def raise_with_block_content
@@ -18,11 +19,7 @@ module Garterbelt
18
19
  end
19
20
 
20
21
  def escaped_content
21
- escape? ? ERB::Util.h(content) : content
22
- end
23
-
24
- def escape?
25
- !!view.escape
22
+ escape ? ERB::Util.h(content) : content
26
23
  end
27
24
  end
28
25
  end
@@ -0,0 +1,3 @@
1
+ You should check out my rad new site:<br>
2
+ <a class="user_generated_link" href="http://foo.com">http://foo.com</a><br>
3
+ It will blow your mind!
@@ -0,0 +1,12 @@
1
+ class UnescapingView < Garterbelt::View
2
+ requires :format_text
3
+
4
+ def content
5
+ format_text.gsub!(/<[^>]*>/, '')
6
+ format_text.gsub!(/\b((https?|mailto):(\/\/)?\S+)/, "<a class=\"user_generated_link\" href=\"\\1\">\\1</a>")
7
+ format_text.gsub!("\n", "<br>\n")
8
+ format_text.gsub!(/ {2,1000}/, '')
9
+
10
+ raw_text format_text
11
+ end
12
+ end
@@ -9,6 +9,13 @@ describe Garterbelt::View, "Integration" do
9
9
  ViewWithContentTags.new.render.should == file("view_with_tags")
10
10
  end
11
11
 
12
+ it 'properly unescapes text' do
13
+ format_text = "You should check out my rad new site:
14
+ http://foo.com
15
+ It will blow your mind!"
16
+ UnescapingView.new(:format_text => format_text).render.should == file('unescaping_view')
17
+ end
18
+
12
19
  describe 'variables' do
13
20
  it 'calls methods on passed objects' do
14
21
  user = Hashie::Mash.new(:email => 'foo@example.com')
@@ -10,7 +10,7 @@ require File.dirname(__FILE__) + "/../../lib/garterbelt"
10
10
  require File.dirname(__FILE__) + '/templates/garterbelt'
11
11
  require File.dirname(__FILE__) + '/templates/erector'
12
12
 
13
- TIMES = 10_000
13
+ TIMES = 500_000
14
14
 
15
15
  RBench.run(TIMES) do
16
16
  column :garterbelt
@@ -27,13 +27,31 @@ RBench.run(TIMES) do
27
27
  garterbelt { GarterbeltTemplate.new(:user => user).render }
28
28
  erector { ErectorTemplate.new(:user => user).to_html }
29
29
  end
30
-
31
- report "Simple Page, class level rendering" do
32
- garterbelt { GarterbeltTemplate.render(:user => user) }
33
- erector { ErectorTemplate.new(:user => user).to_html }
34
- end
35
30
  end
36
31
 
32
+ # 4/13/2011, more stuff checking for 0.0.6
33
+ # 10_000 GARTERBELT | ERECTOR | PERCENT DIFFERENCE
34
+ # --------------------------------------------------------------------------
35
+ # Simple Page Initializing 0.178 | 0.170 | 4.5% slower
36
+ # Simple Page Rendering 6.971 | 6.613 | 5.1% slower
37
+ #
38
+ # 50_000 GARTERBELT | ERECTOR | PERCENT DIFFERENCE
39
+ # --------------------------------------------------------------------------
40
+ # Simple Page Initializing 0.856 | 1.016 | 15.7% faster
41
+ # Simple Page Rendering 34.804 | 33.547 | 3.6% slower
42
+ #
43
+ # 100_000 GARTERBELT | ERECTOR | PERCENT DIFFERENCE
44
+ # --------------------------------------------------------------------------
45
+ # Simple Page Initializing 1.678 | 1.911 | 12% faster
46
+ # Simple Page Rendering 69.654 | 67.422 | 3.2% slower
47
+ #
48
+ # 500_0000 GARTERBELT | ERECTOR | PERCENT DIFFERENCE
49
+ # --------------------------------------------------------------------------
50
+ # Simple Page Initializing 8.465 | 9.656 | 12.4% faster
51
+ # Simple Page Rendering 350.409 | 338.026 | 3.5% slower
52
+
53
+
54
+
37
55
  # 4/13/2011, version 0.0.4, Removing RuPol from the lib, totally a flacid chick :(
38
56
  # more work on performance later
39
57
  # GARTERBELT | ERECTOR |
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garterbelt
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kane Baccigalupi
@@ -241,12 +241,14 @@ files:
241
241
  - lib/view.rb
242
242
  - spec/garterbelt_spec.rb
243
243
  - spec/integration/expectations/general_view.html
244
+ - spec/integration/expectations/unescaping_view.html
244
245
  - spec/integration/expectations/variables/view_with_user_and_params.html
245
246
  - spec/integration/expectations/variables/view_with_user_email.html
246
247
  - spec/integration/expectations/view_partial_nest.html
247
248
  - spec/integration/expectations/view_with_forms.html
248
249
  - spec/integration/expectations/view_with_tags.html
249
250
  - spec/integration/templates/form.rb
251
+ - spec/integration/templates/unescaping_view.rb
250
252
  - spec/integration/templates/view_partial_nest.rb
251
253
  - spec/integration/templates/view_with_cache.rb
252
254
  - spec/integration/templates/view_with_forms.rb
@@ -312,6 +314,7 @@ summary: Garterbelt is a Ruby HTML/XML markup framework. It is san DSL. Just all
312
314
  test_files:
313
315
  - spec/garterbelt_spec.rb
314
316
  - spec/integration/templates/form.rb
317
+ - spec/integration/templates/unescaping_view.rb
315
318
  - spec/integration/templates/view_partial_nest.rb
316
319
  - spec/integration/templates/view_with_cache.rb
317
320
  - spec/integration/templates/view_with_forms.rb