bb-ruby 0.8.5 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/History.txt +10 -0
  2. data/lib/bb-ruby.rb +10 -10
  3. data/test/test_bb-ruby.rb +1 -0
  4. metadata +1 -1
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.9 2009-05-20
2
+
3
+ * bugfix
4
+ * BBRuby.to_html was not working due to incorrect passing of splat params
5
+
6
+ == 0.8.5 2009-05-20
7
+
8
+ * bugfixes
9
+ * :disable and :enable were not working properly
10
+
1
11
  == 0.8.4 2009-01-03
2
12
 
3
13
  * Added YouTube widescreen video support as this is the new YouTube default
data/lib/bb-ruby.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module BBRuby
5
- VERSION = '0.8.5'
5
+ VERSION = '0.9'
6
6
 
7
7
  # allowable image formats
8
8
  @@imageformats = 'png|bmp|jpg|gif|jpeg'
@@ -240,10 +240,10 @@ module BBRuby
240
240
  # BBRuby.to_html(text, {}, true, :enable, :image, :bold, :quote)
241
241
  # BBRuby.to_html(text, {}, true, :disable, :image, :video, :color)
242
242
  #
243
- def to_html(text, tags_alternative_definition = {}, escape_html=true, method=:disable, *tags)
243
+ def to_html(text, tags_alternative_definition={}, escape_html=true, method=:disable, *tags)
244
244
  text = text.clone
245
245
 
246
- # escape < and > to remove any html
246
+ # escape "<, >, &" to remove any html
247
247
  if escape_html
248
248
  text.gsub!( '&', '&amp;' )
249
249
  text.gsub!( '<', '&lt;' )
@@ -254,11 +254,11 @@ module BBRuby
254
254
 
255
255
  # parse bbcode tags
256
256
  case method
257
- when :enable
258
- tags_definition.each_value { |t| text.gsub!(t[0], t[1]) if tags[0].include?(t[4]) }
259
- when :disable
260
- # this works nicely because the default is disable and the default set of tags is [] (so none disabled) :)
261
- tags_definition.each_value { |t| text.gsub!(t[0], t[1]) unless tags[0].include?(t[4]) }
257
+ when :enable
258
+ tags_definition.each_value { |t| text.gsub!(t[0], t[1]) if tags.include?(t[4]) }
259
+ when :disable
260
+ # this works nicely because the default is disable and the default set of tags is [] (so none disabled) :)
261
+ tags_definition.each_value { |t| text.gsub!(t[0], t[1]) unless tags.include?(t[4]) }
262
262
  end
263
263
 
264
264
  # parse spacing
@@ -322,11 +322,11 @@ class String
322
322
  # output = text.bbcode_to_html({}, false)
323
323
  #
324
324
  def bbcode_to_html(tags_alternative_definition = {}, escape_html=true, method=:disable, *tags)
325
- BBRuby.to_html(self, tags_alternative_definition, escape_html, method, tags)
325
+ BBRuby.to_html(self, tags_alternative_definition, escape_html, method, *tags)
326
326
  end
327
327
 
328
328
  # Replace the string contents with the HTML-converted markup
329
329
  def bbcode_to_html!(tags_alternative_definition = {}, escape_html=true, method=:disable, *tags)
330
- self.replace(BBRuby.to_html(self, tags_alternative_definition, escape_html, method, tags))
330
+ self.replace(BBRuby.to_html(self, tags_alternative_definition, escape_html, method, *tags))
331
331
  end
332
332
  end
data/test/test_bb-ruby.rb CHANGED
@@ -7,6 +7,7 @@ class TestBBRuby < Test::Unit::TestCase
7
7
  def test_strong
8
8
  assert_equal '<strong>simple</strong>', '[b]simple[/b]'.bbcode_to_html
9
9
  assert_equal '<strong>simple</strong>', '[b:7a9ca2c5c3]simple[/b:7a9ca2c5c3]'.bbcode_to_html
10
+ assert_equal %Q(<strong>simple</strong>), BBRuby.to_html( %Q([b:7a9ca2c5c3]simple[/b:7a9ca2c5c3]) )
10
11
  assert_equal "<strong>line 1<br />\nline 2</strong>", "[b:7a9ca2c5c3]line 1\nline 2[/b:7a9ca2c5c3]".bbcode_to_html
11
12
  assert_equal "<strong>1. text 1:</strong> text 2<br />\n<strong>2. text 3</strong>", "[b:post_uid0]1. text 1:[/b:post_uid0] text 2\n[b:post_uid0]2. text 3[/b:post_uid0]".bbcode_to_html
12
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bb-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: "0.9"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig P Jolicoeur