RedCloth 4.2.4.pre3-java → 4.2.5-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of RedCloth might be problematic. Click here for more details.

@@ -1,73 +0,0 @@
1
- class RagelProfiler
2
- MEM_CONVERSION = 1024
3
-
4
- COMMANDS = { :compile => %w(ragel rlgen-cd gcc-4.0 gnumake cc1),
5
- :test => %w(ruby) }
6
-
7
- FIELDS = %w(compile_time compile_max_rss test_time test_max_rss file_size)
8
-
9
- @@results = {}
10
-
11
- def initialize(name)
12
- @name = name
13
- @@results[name] = []
14
- end
15
-
16
- def measure(type)
17
- raise "not a valid type" unless COMMANDS.keys.include?(type)
18
- regex = COMMANDS[type].map {|c| Regexp.escape(c) }.join("|")
19
- t = Thread.new do
20
- Thread.current[:max] = 0
21
- loop do
22
- Thread.current[:max] = [run(regex), Thread.current[:max]].max
23
- sleep 0.5
24
- end
25
- end
26
- begin_time = Time.now
27
- yield
28
- total_time = Time.now - begin_time
29
-
30
- t.kill
31
- store_result(type, "time", total_time)
32
- store_result(type, "max_rss", t[:max])
33
- end
34
-
35
- def ext_size(file)
36
- store_result(:file, "size", File.size(file) / MEM_CONVERSION)
37
- end
38
-
39
- def self.results
40
- out = []
41
- out << "name\t" + FIELDS.join("\t")
42
- @@results.each do |name, results|
43
- out << [name, results ].flatten.join("\t")
44
- end
45
- out.join("\n")
46
- end
47
-
48
- private
49
-
50
- def store_result(type, metric, value)
51
- index = FIELDS.index("#{type.to_s}_#{metric}")
52
- @@results[@name][index] = "%.2f" % value
53
- end
54
-
55
- def run(ps_regex)
56
- ps_command = "ps axucww"
57
- ps_output = `#{ps_command}`
58
- fields = ps_output.to_a.first.downcase.split
59
- memory_index = fields.index("rss")
60
- pid_index = fields.index("pid")
61
- ppid_index = fields.index("ppid")
62
- total = ps_output.grep(/(#{ps_regex})\s+$/i).map do |com|
63
- Float(com.split[memory_index]).abs
64
- end.inject(0) { |s,v| s += v }
65
- if total
66
- return total/MEM_CONVERSION
67
- else
68
- STDERR.puts "Command not found. No processes found matching #{ps_regex}."
69
- end
70
-
71
- end
72
-
73
- end
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), 'helper')
4
-
5
- require 'erb'
6
- require 'w3c_validators'
7
-
8
- class ValidateFixtures < Test::Unit::TestCase
9
- include W3CValidators
10
-
11
- def setup
12
- @v = MarkupValidator.new
13
- sleep 1 # delay per WC3 request
14
- end
15
-
16
- HTML_4_0_TEMPLATE = <<EOD
17
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
18
- <html>
19
- <head>
20
- <title><%= test_name %></title>
21
- </head>
22
- <body>
23
- <%= content %>
24
- </body>
25
- </html>
26
- EOD
27
- XHTML_1_0_TEMPLATE = <<EOD
28
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
29
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
30
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
31
- <head>
32
- <title><%= test_name %></title>
33
- </head>
34
- <body>
35
- <%= content %>
36
- </body>
37
- </html>
38
- EOD
39
-
40
- fixtures.each do |name, doc|
41
- if doc['html'] && (doc['valid_html'].nil? || doc['valid_html'])
42
- define_method("test_html_output_validity_of_#{name}") do
43
- assert_produces_valid_html(name, doc['html'])
44
- end
45
- define_method("test_xhtml_output_validity_of_#{name}") do
46
- assert_produces_valid_xhtml(name, doc['html'])
47
- end
48
- end
49
- end
50
-
51
- private
52
- def assert_produces_valid_html(test_name, content)
53
- body = ERB.new(HTML_4_0_TEMPLATE, nil,'-%').result(binding)
54
- assert_validates(body)
55
- end
56
-
57
- def assert_produces_valid_xhtml(test_name, content)
58
- body = ERB.new(XHTML_1_0_TEMPLATE, nil,'-%').result(binding)
59
- assert_validates(body)
60
- end
61
-
62
- def assert_validates(body)
63
- results = @v.validate_text(body)
64
- errors = results.errors
65
- warnings = results.warnings.reject {|w| w.message_id == "247" } # NET-enabling start-tag requires SHORTTAG YES.
66
-
67
- assert(errors.empty?, "Validator errors: \n" +
68
- errors.collect {|e| "'#{e.to_s}'"}.join("\n"))
69
-
70
- assert(warnings.empty?, "Validator warnings: \n" +
71
- warnings.collect {|w| "'#{w.to_s}'"}.join("\n"))
72
- end
73
-
74
- end