ruby-bbcode 2.0.3 → 2.1.0

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.
@@ -1,33 +1,37 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class RubyBbcodeValidityTest < Minitest::Test
4
+ def before_setup
5
+ RubyBBCode.reset
6
+ end
7
+
4
8
  def test_multiple_errors
5
9
  input = '[b]Bold not closed, [li]Illegal list item[/li]'
6
10
  errors = input.bbcode_check_validity
7
11
  assert_equal 2, errors.length
8
- assert_includes errors, "[b] not closed"
9
- assert_includes errors, "[li] can only be used in [ul] and [ol], so using it in a [b] tag is not allowed"
12
+ assert_includes errors, '[b] not closed'
13
+ assert_includes errors, '[li] can only be used in [ul] and [ol], so using it in a [b] tag is not allowed'
10
14
  end
11
15
 
12
16
  def test_illegal_items
13
17
  assert_equal ['[li] can only be used in [ul] and [ol]'],
14
- '[li]Illegal item[/li]'.bbcode_check_validity
18
+ '[li]Illegal item[/li]'.bbcode_check_validity
15
19
  assert_equal ['[li] can only be used in [ul] and [ol], so using it in a [b] tag is not allowed'],
16
- '[b][li]Illegal item[/li][/b]'.bbcode_check_validity
20
+ '[b][li]Illegal item[/li][/b]'.bbcode_check_validity
17
21
  end
18
22
 
19
23
  def test_illegal_list_contents
20
24
  assert_equal ['[ul] can only contain [li] and [*] tags, so "Illegal list" is not allowed'],
21
- '[ul]Illegal list[/ul]'.bbcode_check_validity
25
+ '[ul]Illegal list[/ul]'.bbcode_check_validity
22
26
  assert_equal ['[ul] can only contain [li] and [*] tags, so [b] is not allowed'],
23
- '[ul][b]Illegal list[/b][/ul]'.bbcode_check_validity
27
+ '[ul][b]Illegal list[/b][/ul]'.bbcode_check_validity
24
28
  end
25
29
 
26
30
  def test_illegal_list_contents_text_between_list_items
27
31
  assert_equal ['[ul] can only contain [li] and [*] tags, so "Illegal text" is not allowed'],
28
- '[ul][li]item[/li]Illegal text[/ul]'.bbcode_check_validity
32
+ '[ul][li]item[/li]Illegal text[/ul]'.bbcode_check_validity
29
33
  assert_equal ['[ul] can only contain [li] and [*] tags, so "Illegal text" is not allowed'],
30
- '[ul][li]item[/li]Illegal text[li]item[/li][/ul]'.bbcode_check_validity
34
+ '[ul][li]item[/li]Illegal text[li]item[/li][/ul]'.bbcode_check_validity
31
35
  end
32
36
 
33
37
  def test_unordered_list_omit_closing
@@ -71,15 +75,15 @@ class RubyBbcodeValidityTest < Minitest::Test
71
75
  end
72
76
 
73
77
  def test_no_ending_tag
74
- assert_equal ["[b] not closed"], "this [b]should not be bold".bbcode_check_validity
78
+ assert_equal ['[b] not closed'], 'this [b]should not be bold'.bbcode_check_validity
75
79
  end
76
80
 
77
81
  def test_no_start_tag
78
- assert_equal ["Closing tag [/b] doesn't match an opening tag"], "this should not be bold[/b]".bbcode_check_validity
82
+ assert_equal ["Closing tag [/b] doesn't match an opening tag"], 'this should not be bold[/b]'.bbcode_check_validity
79
83
  end
80
84
 
81
85
  def test_different_start_and_ending_tags
82
- assert_equal ["Closing tag [/i] doesn't match [b]", "[b] not closed"], "this [b]should not do formatting[/i]".bbcode_check_validity
86
+ assert_equal ["Closing tag [/i] doesn't match [b]", '[b] not closed'], 'this [b]should not do formatting[/i]'.bbcode_check_validity
83
87
  end
84
88
 
85
89
  def test_failing_between_texts
@@ -94,10 +98,10 @@ class RubyBbcodeValidityTest < Minitest::Test
94
98
 
95
99
  def test_addition_of_tags
96
100
  mydef = {
97
- :test => {
98
- :description => 'This is a test',
99
- :example => '[test]Test here[/test]',
100
- :param_tokens => [{:token => :param}]
101
+ test: {
102
+ description: 'This is a test',
103
+ example: '[test]Test here[/test]',
104
+ param_tokens: [{ token: :param }]
101
105
  }
102
106
  }
103
107
  # Currently, unknown tags are treated as text and no (missing) parameter values are checked for bbcode_check_validity
@@ -106,14 +110,13 @@ class RubyBbcodeValidityTest < Minitest::Test
106
110
  assert 'pre [test]Test here[/test] post'.bbcode_check_validity(mydef)
107
111
  end
108
112
 
109
- # TODO: This stack level problem should be validated during the validations
110
- #def test_stack_level_too_deep
113
+ # TODO: This stack level problem should be validated during the validations
114
+ # def test_stack_level_too_deep
111
115
  # num = 2300 # increase this number if the test starts failing. It's very near the tipping point
112
116
  # openers = "[s]hi i'm" * num
113
117
  # closers = "[/s]" * num
114
118
  # assert_raise( SystemStackError ) do
115
119
  # (openers+closers).bbcode_to_html
116
120
  # end
117
- #end
118
-
121
+ # end
119
122
  end
@@ -2,19 +2,18 @@ require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
4
  require 'ruby-bbcode'
5
- require "minitest/autorun"
5
+ require 'minitest/autorun'
6
6
 
7
7
  # This hack allows us to make all the private methods of a class public.
8
8
  class Class
9
9
  def publicize_methods
10
- saved_private_instance_methods = self.private_instance_methods
11
- self.class_eval { public(*saved_private_instance_methods) }
10
+ saved_private_instance_methods = private_instance_methods
11
+ class_eval { public(*saved_private_instance_methods) }
12
12
  yield
13
- self.class_eval { private(*saved_private_instance_methods) }
13
+ class_eval { private(*saved_private_instance_methods) }
14
14
  end
15
15
  end
16
16
 
17
-
18
17
  # This is for measuring memory usage...
19
18
  def get_current_memory_usage
20
19
  `ps -o rss= -p #{Process.pid}`.to_i
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ class ConfigurationTest < MiniTest::Test
4
+ def before_setup
5
+ RubyBBCode.reset
6
+ end
7
+
8
+ def test_configuration
9
+ refute_equal :ignore, RubyBBCode.configuration.ignore_unknown_tags
10
+
11
+ RubyBBCode.configuration.ignore_unknown_tags = :ignore
12
+
13
+ assert_equal :ignore, RubyBBCode.configuration.ignore_unknown_tags
14
+ end
15
+
16
+ def test_configuration_reset
17
+ refute_equal :exception, RubyBBCode.configuration.ignore_unknown_tags
18
+
19
+ RubyBBCode.configuration.ignore_unknown_tags = :exception
20
+
21
+ assert_equal :exception, RubyBBCode.configuration.ignore_unknown_tags
22
+
23
+ RubyBBCode.reset
24
+
25
+ refute_equal :exception, RubyBBCode.configuration.ignore_unknown_tags
26
+ end
27
+
28
+ def test_configuration_block
29
+ refute_equal :ignore, RubyBBCode.configuration.ignore_unknown_tags
30
+
31
+ RubyBBCode.configure do |config|
32
+ config.ignore_unknown_tags = :ignore
33
+ end
34
+
35
+ assert_equal :ignore, RubyBBCode.configuration.ignore_unknown_tags
36
+ end
37
+ end
@@ -3,35 +3,34 @@ require 'test_helper'
3
3
  class TagSifterTest < MiniTest::Test
4
4
  include RubyBBCode::Tags
5
5
  def test_youtube_parser
6
- url1 = "http://www.youtube.com/watch?v=E4Fbk52Mk1w"
6
+ url1 = 'http://www.youtube.com/watch?v=E4Fbk52Mk1w'
7
7
  just_an_id = 'E4Fbk52Mk1w'
8
- url_without_http = "www.youtube.com/watch?v=E4Fbk52Mk1w"
9
- url_without_www = "youtube.com/watch?v=E4Fbk52Mk1w"
10
- url_with_feature = "http://www.youtube.com/watch?feature=player_embedded&v=E4Fbk52Mk1w"
8
+ url_without_http = 'www.youtube.com/watch?v=E4Fbk52Mk1w'
9
+ url_without_www = 'youtube.com/watch?v=E4Fbk52Mk1w'
10
+ url_with_feature = 'http://www.youtube.com/watch?feature=player_embedded&v=E4Fbk52Mk1w'
11
11
  mock_regex_matches = @@tags[:youtube][:url_matches]
12
12
 
13
13
  expected_output = 'E4Fbk52Mk1w'
14
14
 
15
15
  RubyBBCode::TagSifter.publicize_methods do
16
- ts = RubyBBCode::TagSifter.new "", ""
16
+ ts = RubyBBCode::TagSifter.new '', ''
17
17
  assert_equal expected_output, ts.match_url_id(url1, mock_regex_matches)
18
18
  assert_equal expected_output, ts.match_url_id(just_an_id, mock_regex_matches)
19
19
  assert_equal expected_output, ts.match_url_id(url_without_http, mock_regex_matches)
20
20
  assert_equal expected_output, ts.match_url_id(url_without_www, mock_regex_matches)
21
21
  assert_equal expected_output, ts.match_url_id(url_with_feature, mock_regex_matches)
22
22
  end
23
-
24
23
  end
25
24
 
26
25
  # I think the answer to this is creating a new tag named [youtube]
27
26
  # but that captures specifically the .be or .com and treats them differently...
28
27
  def test_youtubes_via_there_url_shortener
29
- url_from_shortener = "http://youtu.be/E4Fbk52Mk1w"
28
+ url_from_shortener = 'http://youtu.be/E4Fbk52Mk1w'
30
29
  expected_output = 'E4Fbk52Mk1w'
31
30
  mock_regex_matches = @@tags[:youtube][:url_matches]
32
31
 
33
32
  RubyBBCode::TagSifter.publicize_methods do
34
- ts = RubyBBCode::TagSifter.new "", ""
33
+ ts = RubyBBCode::TagSifter.new '', ''
35
34
 
36
35
  # this test is now hopelessly broken because generating an ID from a link requires that @bbtree.current_node.definition be properly populated with regex matches...
37
36
  assert_equal expected_output, ts.match_url_id(url_from_shortener, mock_regex_matches)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-bbcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten Bezemer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-07 00:00:00.000000000 Z
11
+ date: 2019-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,7 +25,21 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.2.2
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: irb
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rdoc
56
+ name: minitest
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: minitest
70
+ name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,19 +81,33 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: coveralls
84
+ name: rdoc
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: 0.8.0
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: 0.8.0
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: solargraph
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: term-ansicolor
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -109,6 +137,7 @@ files:
109
137
  - Rakefile
110
138
  - lib/ruby-bbcode.rb
111
139
  - lib/ruby-bbcode/bbtree.rb
140
+ - lib/ruby-bbcode/configuration.rb
112
141
  - lib/ruby-bbcode/tag_collection.rb
113
142
  - lib/ruby-bbcode/tag_info.rb
114
143
  - lib/ruby-bbcode/tag_node.rb
@@ -121,6 +150,7 @@ files:
121
150
  - test/ruby_bbcode_html_test.rb
122
151
  - test/ruby_bbcode_validity_test.rb
123
152
  - test/test_helper.rb
153
+ - test/unit/configuration_test.rb
124
154
  - test/unit/tag_sifter_test.rb
125
155
  - test/unit/tags_test.rb
126
156
  homepage: http://github.com/veger/ruby-bbcode
@@ -146,14 +176,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
176
  - !ruby/object:Gem::Version
147
177
  version: '0'
148
178
  requirements: []
149
- rubygems_version: 3.0.2
179
+ rubygems_version: 3.0.3
150
180
  signing_key:
151
181
  specification_version: 4
152
- summary: ruby-bbcode-2.0.3
182
+ summary: ruby-bbcode-2.1.0
153
183
  test_files:
154
- - test/unit/tag_sifter_test.rb
155
184
  - test/unit/tags_test.rb
185
+ - test/unit/tag_sifter_test.rb
186
+ - test/unit/configuration_test.rb
187
+ - test/test_helper.rb
156
188
  - test/ruby_bbcode_validity_test.rb
157
189
  - test/ruby_bbcode_bbcode_test.rb
158
- - test/test_helper.rb
159
190
  - test/ruby_bbcode_html_test.rb