trainbbcode 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +1 -0
- data/Rakefile +1 -1
- data/lib/trainbbcode/application_helper.rb +7 -0
- data/lib/trainbbcode/parse.rb +4 -4
- data/lib/trainbbcode/swear_filter.rb +19 -0
- data/lib/trainbbcode/tags.rb +1 -0
- data/lib/trainbbcode.rb +4 -2
- data/spec/trainbbcode_spec.rb +21 -0
- data/trainbbcode.gemspec +4 -4
- metadata +8 -3
data/Manifest
CHANGED
data/Rakefile
CHANGED
data/lib/trainbbcode/parse.rb
CHANGED
@@ -16,15 +16,15 @@ class TBBC
|
|
16
16
|
#Swear Filtering
|
17
17
|
input=swear_filter(input) unless @config[:swear_filter_enabled] == false
|
18
18
|
#Loading Custom Tags
|
19
|
-
begin
|
19
|
+
#begin
|
20
20
|
if @config[:custom_tags] then
|
21
21
|
@config[:custom_tags].each do |tag|
|
22
22
|
input=runtag(input,tag)
|
23
23
|
end
|
24
24
|
end
|
25
|
-
rescue
|
26
|
-
input+="<br />Custom Tags failed to run"
|
27
|
-
end
|
25
|
+
#rescue
|
26
|
+
#input+="<br />Custom Tags failed to run"
|
27
|
+
#end
|
28
28
|
#Loading Default Tags and applying them
|
29
29
|
if @config[:allow_defaults] then
|
30
30
|
TBBC::Tags.each do |tag|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class TBBC
|
2
|
+
|
3
|
+
SwearChracters = %w[! $ % ^ * ~]
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def swear_filter(input)
|
8
|
+
@config[:swear_words].each do |swear|
|
9
|
+
input=input.gsub(/#{swear}/,swear_string(swear))
|
10
|
+
end
|
11
|
+
input
|
12
|
+
end
|
13
|
+
|
14
|
+
def swear_string(s)
|
15
|
+
out=""
|
16
|
+
s.split("").map { |split| out+= SwearChracters[rand(SwearChracters.count)] }
|
17
|
+
out
|
18
|
+
end
|
19
|
+
end
|
data/lib/trainbbcode/tags.rb
CHANGED
data/lib/trainbbcode.rb
CHANGED
@@ -8,8 +8,10 @@ require 'rubygems'
|
|
8
8
|
require 'coderay'
|
9
9
|
|
10
10
|
#Helper Method
|
11
|
-
|
12
|
-
|
11
|
+
if defined? RAILS_ROOT then
|
12
|
+
require 'trainbbcode/application_helper.rb'
|
13
|
+
ActionView::Base.send :include, TBBCHelper
|
14
|
+
end
|
13
15
|
|
14
16
|
class TBBC
|
15
17
|
# Creates a new TBBC class with everything set to default
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'lib/trainbbcode.rb'
|
2
|
+
|
3
|
+
describe TBBC, "#parse" do
|
4
|
+
it "Should return <strong>BOLD</strong> for [b]BOLD[/b]" do
|
5
|
+
TBBC.new.parse("[b]BOLD[/b]").should == "<strong>BOLD</strong>"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe String, "#tbbc" do
|
10
|
+
it "Should return <i>italics</i> for [i]italics[/i]" do
|
11
|
+
"[i]italics[/i]".tbbc.should == "<i>italics</i>"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "Should return <strong>BOLD [i]italics[/i]</strong> when italics are disabled" do
|
15
|
+
"[b]BOLD [i]italics[/i][/b]".tbbc(:italic_enabled => false).should == "<strong>BOLD [i]italics[/i]</strong>"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "Should allow custom tags to run and return <strong><i>BOLD italics</i></strong> for [bi]BOLD italics[/bi]" do
|
19
|
+
"[bi]BOLD italics[/bi]".tbbc(:custom_tags => [[/\[bi\](.*?)\[\/bi\]/,'<strong><i>\1</i></strong>',true]]).should == "<strong><i>BOLD italics</i></strong>"
|
20
|
+
end
|
21
|
+
end
|
data/trainbbcode.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{trainbbcode}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Adam \"Arcath\" Laycock"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-10-06}
|
10
10
|
s.description = %q{Provides BBCode for Ruby.}
|
11
11
|
s.email = %q{adam@arcath.net}
|
12
|
-
s.extra_rdoc_files = ["README.rdoc", "lib/trainbbcode.rb", "lib/trainbbcode/configure.rb", "lib/trainbbcode/css.rb", "lib/trainbbcode/parse.rb", "lib/trainbbcode/string.rb", "lib/trainbbcode/tags.rb"]
|
13
|
-
s.files = ["README.rdoc", "Rakefile", "init.rb", "lib/trainbbcode.rb", "lib/trainbbcode/configure.rb", "lib/trainbbcode/css.rb", "lib/trainbbcode/parse.rb", "lib/trainbbcode/string.rb", "lib/trainbbcode/tags.rb", "
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/trainbbcode.rb", "lib/trainbbcode/application_helper.rb", "lib/trainbbcode/configure.rb", "lib/trainbbcode/css.rb", "lib/trainbbcode/parse.rb", "lib/trainbbcode/string.rb", "lib/trainbbcode/swear_filter.rb", "lib/trainbbcode/tags.rb"]
|
13
|
+
s.files = ["README.rdoc", "Rakefile", "init.rb", "lib/trainbbcode.rb", "lib/trainbbcode/application_helper.rb", "lib/trainbbcode/configure.rb", "lib/trainbbcode/css.rb", "lib/trainbbcode/parse.rb", "lib/trainbbcode/string.rb", "lib/trainbbcode/swear_filter.rb", "lib/trainbbcode/tags.rb", "spec/trainbbcode_spec.rb", "trainbbcode.gemspec", "Manifest"]
|
14
14
|
s.homepage = %q{http://www.arcath.net/}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Trainbbcode", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trainbbcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam "Arcath" Laycock
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-10-06 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -31,23 +31,28 @@ extensions: []
|
|
31
31
|
extra_rdoc_files:
|
32
32
|
- README.rdoc
|
33
33
|
- lib/trainbbcode.rb
|
34
|
+
- lib/trainbbcode/application_helper.rb
|
34
35
|
- lib/trainbbcode/configure.rb
|
35
36
|
- lib/trainbbcode/css.rb
|
36
37
|
- lib/trainbbcode/parse.rb
|
37
38
|
- lib/trainbbcode/string.rb
|
39
|
+
- lib/trainbbcode/swear_filter.rb
|
38
40
|
- lib/trainbbcode/tags.rb
|
39
41
|
files:
|
40
42
|
- README.rdoc
|
41
43
|
- Rakefile
|
42
44
|
- init.rb
|
43
45
|
- lib/trainbbcode.rb
|
46
|
+
- lib/trainbbcode/application_helper.rb
|
44
47
|
- lib/trainbbcode/configure.rb
|
45
48
|
- lib/trainbbcode/css.rb
|
46
49
|
- lib/trainbbcode/parse.rb
|
47
50
|
- lib/trainbbcode/string.rb
|
51
|
+
- lib/trainbbcode/swear_filter.rb
|
48
52
|
- lib/trainbbcode/tags.rb
|
49
|
-
-
|
53
|
+
- spec/trainbbcode_spec.rb
|
50
54
|
- trainbbcode.gemspec
|
55
|
+
- Manifest
|
51
56
|
has_rdoc: true
|
52
57
|
homepage: http://www.arcath.net/
|
53
58
|
licenses: []
|