ruby-bbcode 0.0.3 → 1.0.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.
data/test/test_helper.rb CHANGED
@@ -1,7 +1,18 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
1
+ require 'ruby-bbcode'
2
+ require "test/unit"
3
3
 
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
- require "rails/test_help"
4
+ # This hack allows us to make all the private methods of a class public.
5
+ class Class
6
+ def publicize_methods
7
+ saved_private_instance_methods = self.private_instance_methods
8
+ self.class_eval { public(*saved_private_instance_methods) }
9
+ yield
10
+ self.class_eval { private(*saved_private_instance_methods) }
11
+ end
12
+ end
6
13
 
7
- Rails.backtrace_cleaner.remove_silencers!
14
+
15
+ # This is for measuring memory usage...
16
+ def get_current_memory_usage
17
+ `ps -o rss= -p #{Process.pid}`.to_i
18
+ end
@@ -0,0 +1,48 @@
1
+ require 'test_helper'
2
+ require 'debugging'
3
+
4
+ class RubyBbcodeTest < Test::Unit::TestCase
5
+ include ::RubyBBCode::Tags
6
+
7
+ def test_bbtree_to_v
8
+ text = "[i][b]a[/b][b]a[/b][b]a[/b][b]a[/b]item 1[/i][i]item 2[/i]"
9
+ visual = <<eos
10
+ i
11
+ b
12
+ "a"
13
+ b
14
+ "a"
15
+ b
16
+ "a"
17
+ b
18
+ "a"
19
+ "item 1"
20
+ i
21
+ "item 2"
22
+ eos
23
+
24
+ tags = @@tags
25
+ @tag_sifter = RubyBBCode::TagSifter.new(text, tags)
26
+ @tag_sifter.process_text
27
+
28
+ # manually include the debugging methods if they've been disabled for cleanliness purposes
29
+ @tag_sifter.bbtree.extend(::RubyBBCode::DebugBBTree) unless @tag_sifter.bbtree.respond_to? :to_v
30
+
31
+ assert_equal visual, @tag_sifter.bbtree.to_v
32
+ end
33
+
34
+ def test_bbtree_counting_nodes
35
+ text = "[ol][li][b][/b][b][/b][b][/b][b][/b]item 1[/li][li]item 2[/li][/ol]"
36
+ tags = @@tags
37
+
38
+ @tag_sifter = RubyBBCode::TagSifter.new(text, tags)
39
+
40
+ @tag_sifter.process_text
41
+
42
+ # manually include debugging methods if needed.
43
+ @tag_sifter.bbtree.extend(::RubyBBCode::DebugBBTree) unless @tag_sifter.bbtree.respond_to? :count_child_nodes
44
+
45
+ assert_equal 9, @tag_sifter.bbtree.count_child_nodes
46
+ end
47
+
48
+ end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ class TagSifterTest < Test::Unit::TestCase
4
+ def test_youtube_parser
5
+ url1 = "http://www.youtube.com/watch?v=E4Fbk52Mk1w"
6
+ just_an_id = 'E4Fbk52Mk1w'
7
+ url_without_http = "www.youtube.com/watch?v=E4Fbk52Mk1w"
8
+ url_without_www = "youtube.com/watch?v=E4Fbk52Mk1w"
9
+ url_with_feature = "http://www.youtube.com/watch?feature=player_embedded&v=E4Fbk52Mk1w"
10
+ mock_regex_matches = [/youtube.com.*[v]=([^&]*)/, /youtu.be\/([^&]*)/, /y2u.be\/([^&]*)/]
11
+
12
+ expected_output = 'E4Fbk52Mk1w'
13
+
14
+ RubyBBCode::TagSifter.publicize_methods do
15
+ ts = RubyBBCode::TagSifter.new "", ""
16
+ assert_equal expected_output,
17
+ ts.conduct_special_formatting(url1, mock_regex_matches)
18
+
19
+ assert_equal expected_output,
20
+ ts.conduct_special_formatting(just_an_id, mock_regex_matches)
21
+
22
+ assert_equal expected_output,
23
+ ts.conduct_special_formatting(url_without_http, mock_regex_matches)
24
+
25
+ assert_equal expected_output,
26
+ ts.conduct_special_formatting(url_without_www, mock_regex_matches)
27
+
28
+ assert_equal expected_output,
29
+ ts.conduct_special_formatting(url_with_feature, mock_regex_matches)
30
+ end
31
+
32
+ end
33
+
34
+ # I think the answer to this is creating a new tag named [youtube]
35
+ # but that captures specifically the .be or .com and treats them differently...
36
+ def test_youtubes_via_there_url_shortener
37
+ url_from_shortener = "http://youtu.be/E4Fbk52Mk1w"
38
+ directory_format = "http://youtube.googleapis.com/v/E4Fbk52Mk1w"
39
+ expected_output = 'E4Fbk52Mk1w'
40
+ mock_regex_matches = [/youtube.com.*[v]=([^&]*)/, /youtu.be\/([^&]*)/, /y2u.be\/([^&]*)/]
41
+
42
+
43
+ RubyBBCode::TagSifter.publicize_methods do
44
+ ts = RubyBBCode::TagSifter.new "", ""
45
+
46
+
47
+ assert_equal expected_output,
48
+ ts.conduct_special_formatting(url_from_shortener, mock_regex_matches) # 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...
49
+ end
50
+ end
51
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-bbcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,31 +9,76 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-14 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2014-10-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
14
46
  description: Convert BBCode to HTML and check whether the BBCode is valid.
15
- email:
16
- - maarten.bezemer@gmail.com
47
+ email: maarten.bezemer@gmail.com
17
48
  executables: []
18
49
  extensions: []
19
- extra_rdoc_files: []
50
+ extra_rdoc_files:
51
+ - README.textile
52
+ - CHANGELOG.md
53
+ - MIT-LICENSE
20
54
  files:
21
- - lib/tags/tags.rb
22
- - lib/ruby-bbcode/version.rb
23
55
  - lib/ruby-bbcode.rb
56
+ - lib/ruby-bbcode/tag_collection.rb
57
+ - lib/ruby-bbcode/bbtree.rb
58
+ - lib/ruby-bbcode/tag_node.rb
59
+ - lib/ruby-bbcode/tag_info.rb
60
+ - lib/ruby-bbcode/version.rb
61
+ - lib/ruby-bbcode/tag_sifter.rb
62
+ - lib/tags/tags.rb
24
63
  - MIT-LICENSE
25
64
  - Rakefile
26
65
  - README.textile
27
- - test/ruby_bbcode_test.rb
28
- - test/dummy/config/environments/test.rb
29
- - test/dummy/config/application.rb
30
- - test/dummy/config/boot.rb
31
- - test/dummy/config/environment.rb
66
+ - CHANGELOG.md
32
67
  - test/test_helper.rb
68
+ - test/current_test.rb
69
+ - test/unit/tag_sifter_test.rb
70
+ - test/unit/debugging_test.rb
71
+ - test/debugging.rb
72
+ - test/ruby_bbcode_test.rb
33
73
  homepage: http://github.com/veger/ruby-bbcode
34
- licenses: []
74
+ licenses:
75
+ - MIT
35
76
  post_install_message:
36
- rdoc_options: []
77
+ rdoc_options:
78
+ - --title
79
+ - Ruby BBCode
80
+ - --main
81
+ - README.md
37
82
  require_paths:
38
83
  - lib
39
84
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -50,14 +95,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
95
  version: '0'
51
96
  requirements: []
52
97
  rubyforge_project:
53
- rubygems_version: 1.8.11
98
+ rubygems_version: 1.8.23
54
99
  signing_key:
55
100
  specification_version: 3
56
- summary: ruby-bbcode-0.0.3
101
+ summary: ruby-bbcode-1.0.0
57
102
  test_files:
58
- - test/ruby_bbcode_test.rb
59
- - test/dummy/config/environments/test.rb
60
- - test/dummy/config/application.rb
61
- - test/dummy/config/boot.rb
62
- - test/dummy/config/environment.rb
63
103
  - test/test_helper.rb
104
+ - test/current_test.rb
105
+ - test/unit/tag_sifter_test.rb
106
+ - test/unit/debugging_test.rb
107
+ - test/debugging.rb
108
+ - test/ruby_bbcode_test.rb
@@ -1,14 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require
6
- require "ruby-bbcode"
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- # Configure the default encoding used in templates for Ruby 1.9.
11
- config.encoding = "utf-8"
12
- end
13
- end
14
-
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
9
-
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,15 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
-
5
- Dummy::Application.configure do
6
- # Log error messages when you accidentally call methods on nil
7
- config.whiny_nils = true
8
-
9
- # Print deprecation notices to the stderr
10
- config.active_support.deprecation = :stderr
11
- end
12
-
13
-
14
- # Initialize the rails application
15
- Dummy::Application.initialize!
@@ -1,39 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
13
-
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
16
-
17
- # Show full error reports and disable caching
18
- config.consider_all_requests_local = true
19
- config.action_controller.perform_caching = false
20
-
21
- # Raise exceptions instead of rendering exception templates
22
- config.action_dispatch.show_exceptions = false
23
-
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
-
27
- # Tell Action Mailer not to deliver emails to the real world.
28
- # The :test delivery method accumulates sent emails in the
29
- # ActionMailer::Base.deliveries array.
30
- config.action_mailer.delivery_method = :test
31
-
32
- # Use SQL instead of Active Record's schema dumper when creating the test database.
33
- # This is necessary if your schema can't be completely dumped by the schema dumper,
34
- # like if you have constraints or database-specific column types
35
- # config.active_record.schema_format = :sql
36
-
37
- # Print deprecation notices to the stderr
38
- config.active_support.deprecation = :stderr
39
- end