bbcodeizer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Bbcodeizer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/bbcodeizer.rb CHANGED
@@ -65,7 +65,8 @@ module BBCodeizer
65
65
  # Parses all bbcode in +text+ and returns a new HTML-formatted string.
66
66
  def bbcodeize(text)
67
67
  text = text.dup
68
- TagList.each do |tag|
68
+ @deactivated ||= Array.new
69
+ (TagList - @deactivated).each do |tag|
69
70
  if Tags.has_key?(tag)
70
71
  apply_tag(text, tag)
71
72
  else
@@ -80,7 +81,14 @@ module BBCodeizer
80
81
 
81
82
  # Configuration option to deactivate particular +tags+.
82
83
  def deactivate(*tags)
83
- tags.each { |t| TagList.delete(t) }
84
+ @deactivated ||= Array.new
85
+ @deactivated += tags
86
+ end
87
+
88
+ # Configuration option to reactivate particular +tags+.
89
+ def activate(*tags)
90
+ @deactivated ||= Array.new
91
+ @deactivated -= tags
84
92
  end
85
93
 
86
94
  # Configuration option to change the replacement string used for a particular +tag+. The source
@@ -5,4 +5,4 @@ module BBCodeizeHelper
5
5
  def bbcodeize(text)
6
6
  BBCodeizer.bbcodeize(text)
7
7
  end
8
- end
8
+ end
@@ -105,4 +105,20 @@ class BbcodeizerTest < Test::Unit::TestCase
105
105
  "<span style=\"color: red\">Red Text</span>",
106
106
  bbcodeize("[color=red]Red Text[/color]"))
107
107
  end
108
+
109
+ def test_deactivation
110
+ BBCodeizer.deactivate(:bold)
111
+ assert_equal(
112
+ "I am [b]really[/b] happy!",
113
+ bbcodeize("I am [b]really[/b] happy!"))
114
+ BBCodeizer.activate(:bold) # for future tests
115
+ end
116
+
117
+ def test_activation
118
+ BBCodeizer.deactivate(:bold)
119
+ BBCodeizer.activate(:bold)
120
+ assert_equal(
121
+ "I am <strong>really</strong> happy!",
122
+ bbcodeize("I am [b]really[/b] happy!"))
123
+ end
108
124
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bbcodeizer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jonathan Dance