Skip to content

Commit

Permalink
Add a RedCloth::EXTENSION_LANGUAGE constant. [#114 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarber committed Mar 17, 2009
1 parent d363184 commit f04cdbb
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,5 +1,7 @@
=== Edge

* Added a RedCloth::EXTENSION_LANGUAGE constant so you can tell what version of the parser you are using. [Jason Garber]

* Added a NotCompiledError to give a friendlier message when people just unpack RedCloth into their projects. [Jason Garber]

* Added a pure-ruby version of the parser for times when you can't compile the C or Java extensions. You should avoid using it if at all possible because it is 32 times slower (and has some other problems, too)! [Jason Garber]
Expand Down
1 change: 1 addition & 0 deletions ext/redcloth_scan/redcloth_scan.c.rl
Expand Up @@ -214,6 +214,7 @@ redcloth_to(self, formatter)
void Init_redcloth_scan()
{
mRedCloth = rb_define_module("RedCloth");
rb_define_const( mRedCloth, "EXTENSION_LANGUAGE", STR_NEW2("C") );
/* A Textile document that can be converted to other formats. See
the README for Textile syntax. */
super_RedCloth = rb_define_class_under(mRedCloth, "TextileDoc", rb_cString);
Expand Down
1 change: 1 addition & 0 deletions ext/redcloth_scan/redcloth_scan.java.rl
Expand Up @@ -589,6 +589,7 @@ public class RedclothScanService implements BasicLibraryService {

public static void Init_redcloth_scan(Ruby runtime) {
RubyModule mRedCloth = runtime.defineModule("RedCloth");
mRedCloth.defineConstant("EXTENSION_LANGUAGE", runtime.newString("Java"));
RubyClass super_RedCloth = mRedCloth.defineClassUnder("TextileDoc", runtime.getString(), runtime.getString().getAllocator());
super_RedCloth.defineAnnotatedMethods(RedclothScanService.class);
super_RedCloth.defineClassUnder("ParseError",runtime.getClass("Exception"),runtime.getClass("Exception").getAllocator());
Expand Down
2 changes: 2 additions & 0 deletions ext/redcloth_scan/redcloth_scan.rb.rl
Expand Up @@ -17,6 +17,8 @@
}%%

module RedCloth
EXTENSION_LANGUAGE = "Ruby"

class TextileDoc < String
def to(formatter)
self.delete!("\r")
Expand Down
2 changes: 1 addition & 1 deletion lib/redcloth.rb
Expand Up @@ -14,7 +14,7 @@ class NotCompiledError < LoadError; end
begin
require 'redcloth_scan'
rescue LoadError
raise RedCloth::NotCompiledError, "RedCloth is extremely fast but must be compiled first. Installing the RedCloth gem is the easiest method."
raise RedCloth::NotCompiledError, "RedCloth uses native extensions. It's extremely fast but must be compiled. Installing the RedCloth gem is the easiest method."
end
require 'redcloth/version'
require 'redcloth/textile_doc'
Expand Down
2 changes: 1 addition & 1 deletion lib/redcloth/version.rb
Expand Up @@ -24,5 +24,5 @@ def ==(arg)
GEM_NAME = NAME
URL = "http://redcloth.org/"

DESCRIPTION = "#{NAME}-#{VERSION::FULL_VERSION} - Textile parser for Ruby.\n#{URL}"
DESCRIPTION = "#{NAME}-#{VERSION::FULL_VERSION}-#{EXTENSION_LANGUAGE} - Textile parser for Ruby.\n#{URL}"
end
6 changes: 6 additions & 0 deletions test/test_parser.rb
Expand Up @@ -20,6 +20,12 @@ def test_redcloth_version_to_s
assert RedCloth::VERSION == RedCloth::VERSION::STRING
end

def test_redcloth_has_extension_language
assert RedCloth.const_defined?("EXTENSION_LANGUAGE")
assert ! RedCloth::EXTENSION_LANGUAGE.empty?
assert_match(RedCloth::EXTENSION_LANGUAGE, RedCloth::DESCRIPTION)
end

def test_badly_formatted_table_does_not_segfault
assert_match(/td/, RedCloth.new(%Q{| one | two |\nthree | four |}).to_html)
end
Expand Down

0 comments on commit f04cdbb

Please sign in to comment.