bb-ruby 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c30a3e4ceb89d5ea4c013c87591ba9da16508190
4
- data.tar.gz: a26ab728526bca28249248e1c3bd9d1d480896db
3
+ metadata.gz: e425b7b6390fbaa0035e4055b12a3b8321731152
4
+ data.tar.gz: f9872b3a94f7d1056b95a584a94bae4034ef6e88
5
5
  SHA512:
6
- metadata.gz: 33112019adeb61f541198d3dc3b118fd1adbdea1584233380fa5eace54d92fca879538e3577c7da472a7da0a9148187746b04ffabae99e8e1892f6446f977d28
7
- data.tar.gz: 8b54ee6e5b17dee86cf3311c01e7e32da4c6ff0a4b1684f03d1b2b3d69556310fd1eb416c5d4bed2a0c24f099da122ebfa7e35d1c47efa7c6fcaf6895a6ad047
6
+ metadata.gz: d48ec523dd3bba11fb0b89e276d3bd6108fc564b5e61f39dacfb8585fde58cbee50dcacd507a2bd1f091e9e08c5a6dadcbf71b68a668fd84312d4c5eecc72ba0
7
+ data.tar.gz: ad743f27403f0b04a0623a1c677d6a5cc216f632b29c9abcdf14682b7837abc64bf318e6d4f73d5850e5d535514b547607b5aaf7c61e942c5a03538c8e2599e9
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.3.0 2016-11-07
2
+
3
+ * Added #any_bb_tags? and .bbcode_formatted? methods
4
+ * Fixed typos in tag examples
5
+
1
6
  == 1.2.2 2016-06-17
2
7
 
3
8
  * Fix <iframe> to not be self-closing tag
data/lib/bb-ruby.rb CHANGED
@@ -40,7 +40,7 @@ module BBRuby
40
40
  /\[ins(:.+)?\](.*?)\[\/ins\1?\]/mi,
41
41
  '<ins>\2</ins>',
42
42
  'Inserted Text',
43
- '[ins]inserted text[/del]',
43
+ '[ins]inserted text[/ins]',
44
44
  :insert],
45
45
  'Code' => [
46
46
  /\[code(:.+)?\](.*?)\[\/code\1?\]/mi,
@@ -76,7 +76,7 @@ module BBRuby
76
76
  /\[li\](.*?)\[\/li\]/mi,
77
77
  '<li>\1</li>',
78
78
  'List item',
79
- 'See ol or ul',
79
+ '[li]list item[/li]',
80
80
  :listitem],
81
81
  'List Item (alternative)' => [
82
82
  /\[\*(:[^\[]+)?\]([^(\[|\<)]+)/mi,
@@ -118,7 +118,7 @@ module BBRuby
118
118
  /\[dd\](.*?)\[\/dd\]/mi,
119
119
  '<dd>\1</dd>',
120
120
  'Definition definitions',
121
- '[dd]my definition[/dd',
121
+ '[dd]my definition[/dd]',
122
122
  :definition],
123
123
  'Quote' => [
124
124
  /\[quote(:.*)?=(?:&quot;)?(.*?)(?:&quot;)?\](.*?)\[\/quote\1?\]/mi,
@@ -315,6 +315,11 @@ module BBRuby
315
315
  @@tags
316
316
  end
317
317
 
318
+ # Checks if text contains any bb tag
319
+ def any_bb_tags?(text)
320
+ tag_list.map{|k,v| v[0]}.any?{|regex| text.match(regex) }
321
+ end
322
+
318
323
  private
319
324
 
320
325
  def process_tags(text, tags_alternative_definition={}, escape_html=true, method=:disable, *tags)
@@ -373,7 +378,6 @@ module BBRuby
373
378
 
374
379
  end
375
380
 
376
-
377
381
  class String
378
382
  # Convert a string with BBCode markup into its corresponding HTML markup
379
383
  #
@@ -435,4 +439,8 @@ class String
435
439
  def bbcode_to_html_with_formatting!(tags_alternative_definition = {}, escape_html=true, method=:disable, *tags)
436
440
  self.replace(BBRuby.to_html_with_formatting(self, tags_alternative_definition, escape_html, method, *tags))
437
441
  end
442
+
443
+ def bbcode_formatted?
444
+ BBRuby.any_bb_tags?(self)
445
+ end
438
446
  end
@@ -1,3 +1,3 @@
1
1
  module BBRuby
2
- VERSION = '1.2.2'
2
+ VERSION = '1.3.0'
3
3
  end
data/test/bb-ruby_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #! /usr/bin/env ruby
2
2
  #coding: utf-8
3
3
 
4
- require 'test_helper.rb'
4
+ require_relative 'test_helper.rb'
5
5
 
6
6
  class TestBBRuby < Test::Unit::TestCase
7
7
 
@@ -352,4 +352,12 @@ class TestBBRuby < Test::Unit::TestCase
352
352
  def test_center_with_url
353
353
  assert_equal '<div style="text-align: center;">hello <a href="http://www.test.com">www.test.com</a></div>', '[center]hello www.test.com[/center]'.bbcode_to_html
354
354
  end
355
+
356
+ def test_any_tag_inclusion_from_examples
357
+ examples = BBRuby.tag_list.map{|k,v| v[3]}
358
+ examples.each do |example|
359
+ assert_equal true, example.bbcode_formatted?
360
+ end
361
+ assert_equal false, "There is no bb tags in this sentence!".bbcode_formatted?
362
+ end
355
363
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bb-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig P. Jolicoeur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-17 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake