bb_tag_closer 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -4,6 +4,8 @@ Automatically detects and closes bb_tags (the ones in forums) in the opposite or
4
4
 
5
5
  "[u]My Underlined Text" becomes "[u]My Underlined Text[/u]"
6
6
 
7
+ Tags are case insensitive.
8
+
7
9
  ## Installation
8
10
 
9
11
  This gem requires Rails 3.2 or later, it was developed and tested on Rails 3.2.9
@@ -22,11 +24,12 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- To use on a model, call close_tags. This will automatically close bb_tags on text (not string) attributes of the model. If you wish to manually specify which attributes to close bb_tags on, call close_tags_for like so:
27
+ To use on a model, call auto_close_bb_tags. This will automatically close bb_tags on text (not string) attributes of the model. If you wish to manually specify which attributes to close bb_tags on, call auto_close_bb_tags_for like so:
28
+
29
+ auto_close_bb_tags_for :attribute1, attribute2, :on => # callback you wish to close tags on, accepts validation, create, update, and save (is save by default)
26
30
 
27
- close_tags_for :attribute1, attribute2, :on => # callback you wish to close tags on, accepts validation, create, update, and save (is save by default)
31
+ If the attributes are protected by mass_assignment using the :as option such as attr_accessible :my_attribute, :as => :my_permission; use auto_close_bb_tags or close_tags_for :attribute1, :mass_assignment_keys => :my_permission or close_tags_for :attribute1, :mass_assignment_keys => [:my_permission1, :my_permission2]
28
32
 
29
- If the attributes are protected by mass_assignment using the :as option such as attr_accessible :my_attribute, :as => :my_permission; use close_tags or close_tags_for :attribute1, :mass_assignment_keys => :my_permission or close_tags_for :attribute1, :mass_assignment_keys => [:my_permission1, :my_permission2]
30
33
 
31
34
  BBTagCloser closes [b], [i], [u], [s], [quote], [url], [img], [email], [youtube], [size], and [color] tags by default, each is able to accept additional parameters such as [quote=foo]#...[/quote]
32
35
  To manually set the tags, call the following in an initializer file:
data/changelog.md CHANGED
@@ -5,4 +5,9 @@ Initial Release
5
5
  ## Version 1.0.2 ##
6
6
 
7
7
  Added ability to disable tag closing callback by specifying :no_callback => true
8
- Now with documentation.
8
+ Now with documentation.
9
+
10
+ ## Version 1.0.3 ##
11
+
12
+ Fixed bug where it mistook normal bracketed characters as bb_tags.
13
+ Fixed case sensitivity of bb_tags
data/lib/bb_tag_closer.rb CHANGED
@@ -15,7 +15,7 @@ module BBTagCloser
15
15
  module ClassMethods
16
16
 
17
17
  # ActiveRecord text attributes are considered taggable by default.
18
- # Using close_tags_for overrides default attributes with custom attributes.
18
+ # Using auto_close_bb_tags_for overrides default attributes with custom attributes.
19
19
 
20
20
  def taggable_fields
21
21
  columns.map {|c| {c.name.to_sym => c.type}}.delete_if {|i| not i.value? :text}.map(&:keys).flatten
@@ -29,7 +29,7 @@ module BBTagCloser
29
29
  # If custom mass_assignment is used such as attr_accessible :foo, :as => :bar
30
30
  # pass :mass_assignment_keys => :bar or :mass_assignment_keys => [:bar, :baz].
31
31
 
32
- def close_tags(options = {})
32
+ def auto_close_bb_tags(options = {})
33
33
  unless options[:no_callback]
34
34
  target = options[:on] ? "before_#{options[:on]}" : "before_save"
35
35
  send(target, :close_tags)
@@ -40,9 +40,9 @@ module BBTagCloser
40
40
  end
41
41
  end
42
42
 
43
- # Specify which attributes to close tags on. Accepts the same options as close_tags.
43
+ # Specify which attributes to close tags on. Accepts the same options as auto_close_bb_tags.
44
44
 
45
- def close_tags_for(*args)
45
+ def auto_close_bb_tags_for(*args)
46
46
  options = args.last.is_a?(Hash) ? args.pop : {}
47
47
  unless options[:no_callback]
48
48
  target = options[:on] ? "before_#{options[:on]}" : "before_save"
@@ -66,13 +66,13 @@ module BBTagCloser
66
66
 
67
67
  # Called during a callback specified in the :on paramater in close_tags or close_tags_for. Closes forum tags in the opposite order they were added by the user.
68
68
 
69
- def close_tags
69
+ def close_bb_tags
70
70
  text_attributes = self.class.taggable_fields
71
71
  text_attributes.each do |attribute|
72
- tags = Configuration.bb_tags && send(attribute).scan(Regexp.new "\\[(.*?)\\]").flatten.delete_if {|c| c.include? "/"}.map {|i| i.include?("=") ? i.slice(Regexp.new "(.*)\\=").chomp("=") : i}.reverse
72
+ tags = send(attribute).scan(Regexp.new "\\[(.*?)\\]").flatten.delete_if {|c| c.include? "/"}.map {|i| i.include?("=") ? i.slice(Regexp.new "(.*)\\=").chomp("=") : i}.reverse.map(&:downcase).delete_if { |x| not Configuration.bb_tags.include? x }
73
73
  tags.each do |tag|
74
- open_tags = send(attribute).scan(Regexp.new "\\[#{tag}=").length + send(attribute).scan(Regexp.new "\\[#{tag}\\]").length
75
- closed_tags = send(attribute).scan(Regexp.new "\\[\\/#{tag}\\]").length
74
+ open_tags = send(attribute).downcase.scan(Regexp.new "\\[#{tag}=").length + send(attribute).downcase.scan(Regexp.new "\\[#{tag}\\]").length
75
+ closed_tags = send(attribute).downcase.scan(Regexp.new "\\[\\/#{tag}\\]").length
76
76
  difference = open_tags - closed_tags
77
77
  if open_tags > closed_tags
78
78
  send(attribute) << "[/#{tag}]"
@@ -1,3 +1,3 @@
1
1
  module BBTagCloser
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
  class Post < ActiveRecord::Base
3
3
  include BBTagCloser
4
4
  attr_accessor :body
5
- close_tags_for :body
5
+ auto_close_bb_tags_for :body
6
6
 
7
7
  def initialize
8
8
  @body = ""
@@ -16,38 +16,51 @@ describe BBTagCloser do
16
16
 
17
17
  it "should close forum tags" do
18
18
  @post.body = "[u]test"
19
- @post.close_tags
19
+ @post.close_bb_tags
20
20
  @post.body.should == "[u]test[/u]"
21
21
  end
22
22
 
23
23
  it "should close multiple forum tags" do
24
24
  @post.body = "[u][b]test"
25
- @post.close_tags
25
+ @post.close_bb_tags
26
26
  @post.body.should == "[u][b]test[/b][/u]"
27
27
  end
28
28
 
29
29
  it "should close complex forum tags" do
30
30
  @post.body = "[quote=Fish]test"
31
- @post.close_tags
31
+ @post.close_bb_tags
32
32
  @post.body.should == "[quote=Fish]test[/quote]"
33
33
  end
34
34
 
35
35
  it "should close multiple forum tags of the same type" do
36
36
  @post.body = "[u][u]test"
37
- @post.close_tags
37
+ @post.close_bb_tags
38
38
  @post.body.should == "[u][u]test[/u][/u]"
39
39
  end
40
40
 
41
41
  it "should leave properly closed tags alone" do
42
42
  @post.body = "[u][u]test[/u][/u]"
43
- @post.close_tags
43
+ @post.close_bb_tags
44
44
  @post.body.should == "[u][u]test[/u][/u]"
45
45
  end
46
46
 
47
47
  it "should leave properly closed tags alone while closing others" do
48
48
  @post.body = "[u][b]test[/u]"
49
- @post.close_tags
49
+ @post.close_bb_tags
50
50
  @post.body.should == "[u][b]test[/u][/b]"
51
51
  end
52
52
 
53
+ it "should not try to close random brackets" do
54
+ @post.body = "[u][hi!]test[/u]"
55
+ @post.close_bb_tags
56
+ @post.body.should == "[u][hi!]test[/u]"
57
+ end
58
+
59
+ it "should be case insensitive" do
60
+ @post.body = "[U]test"
61
+ @post.close_bb_tags
62
+ @post.body.should == "[U]test[/u]"
63
+ end
64
+
65
+
53
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bb_tag_closer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -57,24 +57,6 @@ files:
57
57
  - Rakefile
58
58
  - bb_tag_closer.gemspec
59
59
  - changelog.md
60
- - doc/BBTagCloser.html
61
- - doc/BBTagCloser/ClassMethods.html
62
- - doc/BBTagCloser/Configuration.html
63
- - doc/BBTagCloser/Railtie.html
64
- - doc/_index.html
65
- - doc/class_list.html
66
- - doc/css/common.css
67
- - doc/css/full_list.css
68
- - doc/css/style.css
69
- - doc/file.README.html
70
- - doc/file_list.html
71
- - doc/frames.html
72
- - doc/index.html
73
- - doc/js/app.js
74
- - doc/js/full_list.js
75
- - doc/js/jquery.js
76
- - doc/method_list.html
77
- - doc/top-level-namespace.html
78
60
  - lib/bb_tag_closer.rb
79
61
  - lib/bb_tag_closer/railtie.rb
80
62
  - lib/bb_tag_closer/version.rb
data/doc/BBTagCloser.html DELETED
@@ -1,538 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
- <title>
7
- Module: BBTagCloser
8
-
9
- &mdash; Documentation by YARD 0.8.3
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- hasFrames = window.top.frames.main ? true : false;
19
- relpath = '';
20
- framesUrl = "frames.html#!" + escape(window.location.href);
21
- </script>
22
-
23
-
24
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
-
26
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
-
28
-
29
- </head>
30
- <body>
31
- <div id="header">
32
- <div id="menu">
33
-
34
- <a href="_index.html">Index (B)</a> &raquo;
35
-
36
-
37
- <span class="title">BBTagCloser</span>
38
-
39
-
40
- <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
- </div>
42
-
43
- <div id="search">
44
-
45
- <a class="full_list_link" id="class_list_link"
46
- href="class_list.html">
47
- Class List
48
- </a>
49
-
50
- <a class="full_list_link" id="method_list_link"
51
- href="method_list.html">
52
- Method List
53
- </a>
54
-
55
- <a class="full_list_link" id="file_list_link"
56
- href="file_list.html">
57
- File List
58
- </a>
59
-
60
- </div>
61
- <div class="clear"></div>
62
- </div>
63
-
64
- <iframe id="search_frame"></iframe>
65
-
66
- <div id="content"><h1>Module: BBTagCloser
67
-
68
-
69
-
70
- </h1>
71
-
72
- <dl class="box">
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
- <dt class="r1 last">Defined in:</dt>
82
- <dd class="r1 last">lib/bb_tag_closer.rb<span class="defines">,<br />
83
- lib/bb_tag_closer/version.rb,<br /> lib/bb_tag_closer/railtie.rb</span>
84
- </dd>
85
-
86
- </dl>
87
- <div class="clear"></div>
88
-
89
- <h2>Defined Under Namespace</h2>
90
- <p class="children">
91
-
92
-
93
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="BBTagCloser/ClassMethods.html" title="BBTagCloser::ClassMethods (module)">ClassMethods</a></span>
94
-
95
-
96
-
97
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="BBTagCloser/Configuration.html" title="BBTagCloser::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="BBTagCloser/Railtie.html" title="BBTagCloser::Railtie (class)">Railtie</a></span>
98
-
99
-
100
- </p>
101
-
102
- <h2>Constant Summary</h2>
103
-
104
- <dl class="constants">
105
-
106
- <dt id="VERSION-constant" class="">VERSION =
107
-
108
- </dt>
109
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1.0.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
110
-
111
- </dl>
112
-
113
-
114
-
115
-
116
-
117
- <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
118
- <ul class="summary">
119
-
120
- <li class="public ">
121
- <span class="summary_signature">
122
-
123
- <a href="#font_color-instance_method" title="#font_color (instance method)">- (Object) <strong>font_color</strong> </a>
124
-
125
-
126
-
127
- </span>
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
- <span class="summary_desc"><div class='inline'>
141
- <p>Returns the value of attribute font_color.</p>
142
- </div></span>
143
-
144
- </li>
145
-
146
-
147
- <li class="public ">
148
- <span class="summary_signature">
149
-
150
- <a href="#font_size-instance_method" title="#font_size (instance method)">- (Object) <strong>font_size</strong> </a>
151
-
152
-
153
-
154
- </span>
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
- <span class="summary_desc"><div class='inline'>
168
- <p>Returns the value of attribute font_size.</p>
169
- </div></span>
170
-
171
- </li>
172
-
173
-
174
- </ul>
175
-
176
-
177
-
178
-
179
-
180
- <h2>
181
- Class Method Summary
182
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
183
- </h2>
184
-
185
- <ul class="summary">
186
-
187
- <li class="public ">
188
- <span class="summary_signature">
189
-
190
- <a href="#configure-class_method" title="configure (class method)">+ (Object) <strong>configure</strong> {|BBTagCloser::Configuration| ... }</a>
191
-
192
-
193
-
194
- </span>
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
- <span class="summary_desc"><div class='inline'>
205
- <p>Sets configuration options.</p>
206
- </div></span>
207
-
208
- </li>
209
-
210
-
211
- <li class="public ">
212
- <span class="summary_signature">
213
-
214
- <a href="#included-class_method" title="included (class method)">+ (Object) <strong>included</strong>(base) </a>
215
-
216
-
217
-
218
- </span>
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
- <span class="summary_desc"><div class='inline'></div></span>
229
-
230
- </li>
231
-
232
-
233
- </ul>
234
-
235
- <h2>
236
- Instance Method Summary
237
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
238
- </h2>
239
-
240
- <ul class="summary">
241
-
242
- <li class="public ">
243
- <span class="summary_signature">
244
-
245
- <a href="#close_tags-instance_method" title="#close_tags (instance method)">- (Object) <strong>close_tags</strong> </a>
246
-
247
-
248
-
249
- </span>
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
- <span class="summary_desc"><div class='inline'>
260
- <p>Called during a callback specified in the :on paramater in close_tags or
261
- close_tags_for.</p>
262
- </div></span>
263
-
264
- </li>
265
-
266
-
267
- </ul>
268
-
269
-
270
-
271
- <div id="instance_attr_details" class="attr_details">
272
- <h2>Instance Attribute Details</h2>
273
-
274
-
275
- <span id="font_color=-instance_method"></span>
276
- <div class="method_details first">
277
- <h3 class="signature first" id="font_color-instance_method">
278
-
279
- - (<tt>Object</tt>) <strong>font_color</strong>
280
-
281
-
282
-
283
-
284
-
285
- </h3><div class="docstring">
286
- <div class="discussion">
287
-
288
- <p>Returns the value of attribute font_color</p>
289
-
290
-
291
- </div>
292
- </div>
293
- <div class="tags">
294
-
295
-
296
- </div><table class="source_code">
297
- <tr>
298
- <td>
299
- <pre class="lines">
300
-
301
-
302
- 7
303
- 8
304
- 9</pre>
305
- </td>
306
- <td>
307
- <pre class="code"><span class="info file"># File 'lib/bb_tag_closer.rb', line 7</span>
308
-
309
- <span class='kw'>def</span> <span class='id identifier rubyid_font_color'>font_color</span>
310
- <span class='ivar'>@font_color</span>
311
- <span class='kw'>end</span></pre>
312
- </td>
313
- </tr>
314
- </table>
315
- </div>
316
-
317
-
318
- <span id="font_size=-instance_method"></span>
319
- <div class="method_details ">
320
- <h3 class="signature " id="font_size-instance_method">
321
-
322
- - (<tt>Object</tt>) <strong>font_size</strong>
323
-
324
-
325
-
326
-
327
-
328
- </h3><div class="docstring">
329
- <div class="discussion">
330
-
331
- <p>Returns the value of attribute font_size</p>
332
-
333
-
334
- </div>
335
- </div>
336
- <div class="tags">
337
-
338
-
339
- </div><table class="source_code">
340
- <tr>
341
- <td>
342
- <pre class="lines">
343
-
344
-
345
- 6
346
- 7
347
- 8</pre>
348
- </td>
349
- <td>
350
- <pre class="code"><span class="info file"># File 'lib/bb_tag_closer.rb', line 6</span>
351
-
352
- <span class='kw'>def</span> <span class='id identifier rubyid_font_size'>font_size</span>
353
- <span class='ivar'>@font_size</span>
354
- <span class='kw'>end</span></pre>
355
- </td>
356
- </tr>
357
- </table>
358
- </div>
359
-
360
- </div>
361
-
362
-
363
- <div id="class_method_details" class="method_details_list">
364
- <h2>Class Method Details</h2>
365
-
366
-
367
- <div class="method_details first">
368
- <h3 class="signature first" id="configure-class_method">
369
-
370
- + (<tt>Object</tt>) <strong>configure</strong> {|BBTagCloser::Configuration| ... }
371
-
372
-
373
-
374
-
375
-
376
- </h3><div class="docstring">
377
- <div class="discussion">
378
-
379
- <p>Sets configuration options. Currently supports setting of custom bb_tags
380
- through BBTagCloser.configure {|config| config.bb_tags = ["u", "b", "s",
381
- "i", "quote", "url", "img", "email", "youtube", "size", "color", #
382
- additional tags ]}</p>
383
-
384
-
385
- </div>
386
- </div>
387
- <div class="tags">
388
-
389
- <p class="tag_title">Yields:</p>
390
- <ul class="yield">
391
-
392
- <li>
393
-
394
-
395
- <span class='type'>(<tt><span class='object_link'><a href="BBTagCloser/Configuration.html" title="BBTagCloser::Configuration (class)">BBTagCloser::Configuration</a></span></tt>)</span>
396
-
397
-
398
-
399
- </li>
400
-
401
- </ul>
402
-
403
- </div><table class="source_code">
404
- <tr>
405
- <td>
406
- <pre class="lines">
407
-
408
-
409
- 63
410
- 64
411
- 65</pre>
412
- </td>
413
- <td>
414
- <pre class="code"><span class="info file"># File 'lib/bb_tag_closer.rb', line 63</span>
415
-
416
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
417
- <span class='kw'>yield</span> <span class='const'>BBTagCloser</span><span class='op'>::</span><span class='const'>Configuration</span>
418
- <span class='kw'>end</span></pre>
419
- </td>
420
- </tr>
421
- </table>
422
- </div>
423
-
424
- <div class="method_details ">
425
- <h3 class="signature " id="included-class_method">
426
-
427
- + (<tt>Object</tt>) <strong>included</strong>(base)
428
-
429
-
430
-
431
-
432
-
433
- </h3><table class="source_code">
434
- <tr>
435
- <td>
436
- <pre class="lines">
437
-
438
-
439
- 10
440
- 11
441
- 12
442
- 13</pre>
443
- </td>
444
- <td>
445
- <pre class="code"><span class="info file"># File 'lib/bb_tag_closer.rb', line 10</span>
446
-
447
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_included'>included</span><span class='lparen'>(</span><span class='id identifier rubyid_base'>base</span><span class='rparen'>)</span>
448
- <span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_attr_accessible'>attr_accessible</span> <span class='symbol'>:font_size</span><span class='comma'>,</span> <span class='symbol'>:font_color</span>
449
- <span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span> <span class='const'>ClassMethods</span>
450
- <span class='kw'>end</span></pre>
451
- </td>
452
- </tr>
453
- </table>
454
- </div>
455
-
456
- </div>
457
-
458
- <div id="instance_method_details" class="method_details_list">
459
- <h2>Instance Method Details</h2>
460
-
461
-
462
- <div class="method_details first">
463
- <h3 class="signature first" id="close_tags-instance_method">
464
-
465
- - (<tt>Object</tt>) <strong>close_tags</strong>
466
-
467
-
468
-
469
-
470
-
471
- </h3><div class="docstring">
472
- <div class="discussion">
473
-
474
- <p>Called during a callback specified in the :on paramater in close_tags or
475
- close_tags_for. Closes forum tags in the opposite order they were added by
476
- the user.</p>
477
-
478
-
479
- </div>
480
- </div>
481
- <div class="tags">
482
-
483
-
484
- </div><table class="source_code">
485
- <tr>
486
- <td>
487
- <pre class="lines">
488
-
489
-
490
- 69
491
- 70
492
- 71
493
- 72
494
- 73
495
- 74
496
- 75
497
- 76
498
- 77
499
- 78
500
- 79
501
- 80
502
- 81
503
- 82</pre>
504
- </td>
505
- <td>
506
- <pre class="code"><span class="info file"># File 'lib/bb_tag_closer.rb', line 69</span>
507
-
508
- <span class='kw'>def</span> <span class='id identifier rubyid_close_tags'>close_tags</span>
509
- <span class='id identifier rubyid_text_attributes'>text_attributes</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_taggable_fields'>taggable_fields</span>
510
- <span class='id identifier rubyid_text_attributes'>text_attributes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attribute'>attribute</span><span class='op'>|</span>
511
- <span class='id identifier rubyid_tags'>tags</span> <span class='op'>=</span> <span class='const'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_bb_tags'>bb_tags</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\[(.*?)\\]</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_delete_if'>delete_if</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>(.*)\\=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_chomp'>chomp</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_i'>i</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reverse'>reverse</span>
512
- <span class='id identifier rubyid_tags'>tags</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_tag'>tag</span><span class='op'>|</span>
513
- <span class='id identifier rubyid_open_tags'>open_tags</span> <span class='op'>=</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_tag'>tag</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>+</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_tag'>tag</span><span class='rbrace'>}</span><span class='tstring_content'>\\]</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
514
- <span class='id identifier rubyid_closed_tags'>closed_tags</span> <span class='op'>=</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\[\\/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_tag'>tag</span><span class='rbrace'>}</span><span class='tstring_content'>\\]</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
515
- <span class='id identifier rubyid_difference'>difference</span> <span class='op'>=</span> <span class='id identifier rubyid_open_tags'>open_tags</span> <span class='op'>-</span> <span class='id identifier rubyid_closed_tags'>closed_tags</span>
516
- <span class='kw'>if</span> <span class='id identifier rubyid_open_tags'>open_tags</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_closed_tags'>closed_tags</span>
517
- <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_tag'>tag</span><span class='rbrace'>}</span><span class='tstring_content'>]</span><span class='tstring_end'>&quot;</span></span>
518
- <span class='kw'>end</span>
519
- <span class='kw'>end</span>
520
- <span class='kw'>end</span>
521
- <span class='kw'>end</span></pre>
522
- </td>
523
- </tr>
524
- </table>
525
- </div>
526
-
527
- </div>
528
-
529
- </div>
530
-
531
- <div id="footer">
532
- Generated on Wed Dec 5 22:27:56 2012 by
533
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
534
- 0.8.3 (ruby-1.9.3).
535
- </div>
536
-
537
- </body>
538
- </html>