undies 3.0.0.rc.2 → 3.0.0.rc.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- undies (3.0.0.rc.2)
4
+ undies (3.0.0.rc.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/undies/api.rb CHANGED
@@ -50,19 +50,19 @@ module Undies
50
50
  end
51
51
 
52
52
  def open_element(name, *args)
53
- Raw.new(Element::Open.new(name, *args).to_s)
53
+ Element::Open.new(name, *args)
54
54
  end
55
55
  alias_method :open_tag, :open_element
56
56
  alias_method :element, :open_element
57
57
  alias_method :tag, :open_element
58
58
 
59
59
  def closed_element(name, *args)
60
- Raw.new(Element::Closed.new(name, *args).to_s)
60
+ Element::Closed.new(name, *args)
61
61
  end
62
62
  alias_method :closed_tag, :closed_element
63
63
 
64
64
  SELF_CLOSING_TAGS.each do |tag|
65
- define_method(tag){ |*args| closed_element(tag, *args, &build) }
65
+ define_method(tag){ |*args| closed_element(tag, *args) }
66
66
  end
67
67
 
68
68
  OPEN_TAGS.each do |tag|
@@ -89,9 +89,7 @@ module Undies
89
89
  def __closed_element(name, *args)
90
90
  @_undies_io.
91
91
  current.
92
- element_node(ElementNode.new(
93
- @_undies_io, Element::Closed.new(name, *args)
94
- )).
92
+ element_node(ElementNode.new(@_undies_io, Element::Closed.new(name, *args))).
95
93
  element
96
94
  end
97
95
  alias_method :__closed_tag, :__closed_element
@@ -44,7 +44,6 @@ module Undies
44
44
 
45
45
  module CSSProxy
46
46
 
47
- # CSS proxy methods ============================================
48
47
  ID_METH_REGEX = /^([^_].+)!$/
49
48
  CLASS_METH_REGEX = /^([^_].+)$/
50
49
 
@@ -67,7 +66,6 @@ module Undies
67
66
  super
68
67
  end
69
68
  end
70
- # ==============================================================
71
69
 
72
70
  end
73
71
 
@@ -86,14 +84,15 @@ module Undies
86
84
 
87
85
  class Raw < ::String
88
86
 
89
- # A Raw string is one that is impervious to String#gsub and returns itself
90
- # when `to_s` is called.
87
+ # A Raw string is one that is impervious to String#gsub
88
+ # and returns itself when `to_s` is called. Used to circumvent
89
+ # the default html escaping of markup
91
90
 
92
- def gsub(*args, &block)
91
+ def gsub(*args)
93
92
  self
94
93
  end
95
94
 
96
- def gsub!(*args, &block)
95
+ def gsub!(*args)
97
96
  nil
98
97
  end
99
98
 
@@ -135,7 +134,7 @@ module Undies
135
134
  end
136
135
 
137
136
  def to_s
138
- "#{__start_tag}#{__content}#{__end_tag}"
137
+ Raw.new("#{__start_tag}#{__content}#{__end_tag}")
139
138
  end
140
139
 
141
140
  def ==(other)
@@ -193,7 +192,7 @@ module Undies
193
192
  def __end_tag; ''; end
194
193
 
195
194
  def to_s
196
- "#{__start_tag}"
195
+ Raw.new("#{__start_tag}")
197
196
  end
198
197
 
199
198
  def ==(other)
@@ -22,8 +22,8 @@ module Undies
22
22
  @start_tag_written = false
23
23
  end
24
24
 
25
- def attrs(*args, &block)
26
- @element.__attrs(*args, &block)
25
+ def attrs(*args)
26
+ @element.__attrs(*args)
27
27
  end
28
28
 
29
29
  def text(raw)
@@ -19,7 +19,7 @@ module Undies
19
19
  @cached = nil
20
20
  end
21
21
 
22
- def attrs(*args, &block)
22
+ def attrs(*args)
23
23
  raise RootAPIError, "can't call '__attrs' at the root node level"
24
24
  end
25
25
 
@@ -46,18 +46,21 @@ module Undies
46
46
  self.instance_variable_set("@#{k}", v)
47
47
  end
48
48
 
49
- # setup a source stack with the given source
50
- source = args.last.kind_of?(Source) ? args.pop : Source.new(Proc.new {})
51
- @_undies_source_stack = SourceStack.new(source)
52
-
53
49
  # push a root node onto the IO
54
50
  @_undies_io.push!(RootNode.new(@_undies_io)) if @_undies_io.empty?
55
51
 
56
- # yield to recursivley render the source stack
57
- __yield
52
+ # if given some source, build it
53
+ if args.last.kind_of?(Source)
54
+ # setup a source stack with the given source
55
+ @_undies_source_stack = SourceStack.new(args.pop)
56
+
57
+ # yield to recursivley render the source stack
58
+ __yield
59
+
60
+ # flush any elements that need to be built
61
+ __flush
62
+ end
58
63
 
59
- # flush any elements that need to be built
60
- __flush
61
64
  end
62
65
 
63
66
  end
@@ -1,3 +1,3 @@
1
1
  module Undies
2
- VERSION = "3.0.0.rc.2"
2
+ VERSION = "3.0.0.rc.3"
3
3
  end
@@ -96,7 +96,8 @@ class Undies::Template
96
96
  desc "using the captured element api methods"
97
97
 
98
98
  should "capture `element` output as Raw output" do
99
- assert_kind_of Undies::Raw, subject.closed_element(:br)
99
+ assert_kind_of Undies::Element::Closed, subject.closed_element(:br)
100
+ assert_kind_of Undies::Raw, subject.closed_element(:br).to_s
100
101
  end
101
102
 
102
103
  should "capture `element` output correctly" do
@@ -110,9 +111,9 @@ class Undies::Template
110
111
  should "capture and escape data approptiately" do
111
112
  elem = subject.open_element(:span, *[
112
113
  "stuff & <em>more stuff</em>",
113
- subject.strong(subject.i('ITALICS!!'), ' (here)')
114
+ subject.strong(subject.img.awesome, ' (here)')
114
115
  ])
115
- assert_equal "<span>stuff &amp; &lt;em&gt;more stuff&lt;&#x2F;em&gt;<strong><i>ITALICS!!</i> (here)</strong></span>", elem.to_s
116
+ assert_equal "<span>stuff &amp; &lt;em&gt;more stuff&lt;&#x2F;em&gt;<strong><img class=\"awesome\" /> (here)</strong></span>", elem.to_s
116
117
  end
117
118
 
118
119
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undies
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424113
4
+ hash: 15424115
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
10
  - rc
11
- - 2
12
- version: 3.0.0.rc.2
11
+ - 3
12
+ version: 3.0.0.rc.3
13
13
  platform: ruby
14
14
  authors:
15
15
  - Kelly Redding
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-04-18 00:00:00 Z
20
+ date: 2012-04-21 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  type: :development