bluecloth 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +629 -0
- data/LICENSE +27 -0
- data/LICENSE.discount +47 -0
- data/README +71 -0
- data/Rakefile +319 -0
- data/Rakefile.local +63 -0
- data/bin/bluecloth +84 -0
- data/ext/VERSION +1 -0
- data/ext/amalloc.h +29 -0
- data/ext/bluecloth.c +373 -0
- data/ext/config.h +47 -0
- data/ext/cstring.h +73 -0
- data/ext/docheader.c +43 -0
- data/ext/extconf.rb +45 -0
- data/ext/generate.c +1387 -0
- data/ext/markdown.c +939 -0
- data/ext/markdown.h +135 -0
- data/ext/mkdio.c +241 -0
- data/ext/mkdio.h +66 -0
- data/ext/resource.c +169 -0
- data/ext/version.c +28 -0
- data/lib/bluecloth.rb +148 -0
- data/rake/191_compat.rb +26 -0
- data/rake/dependencies.rb +76 -0
- data/rake/helpers.rb +412 -0
- data/rake/manual.rb +782 -0
- data/rake/packaging.rb +116 -0
- data/rake/publishing.rb +321 -0
- data/rake/rdoc.rb +40 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +639 -0
- data/rake/testing.rb +204 -0
- data/rake/verifytask.rb +64 -0
- data/rake/win32.rb +186 -0
- data/spec/bluecloth/101_changes_spec.rb +141 -0
- data/spec/bluecloth/autolinks_spec.rb +49 -0
- data/spec/bluecloth/blockquotes_spec.rb +143 -0
- data/spec/bluecloth/code_spans_spec.rb +164 -0
- data/spec/bluecloth/emphasis_spec.rb +164 -0
- data/spec/bluecloth/entities_spec.rb +65 -0
- data/spec/bluecloth/hrules_spec.rb +90 -0
- data/spec/bluecloth/images_spec.rb +92 -0
- data/spec/bluecloth/inline_html_spec.rb +238 -0
- data/spec/bluecloth/links_spec.rb +171 -0
- data/spec/bluecloth/lists_spec.rb +294 -0
- data/spec/bluecloth/paragraphs_spec.rb +75 -0
- data/spec/bluecloth/titles_spec.rb +305 -0
- data/spec/bluecloth_spec.rb +209 -0
- data/spec/bugfix_spec.rb +123 -0
- data/spec/contributions_spec.rb +85 -0
- data/spec/data/antsugar.txt +34 -0
- data/spec/data/markdowntest/Amps and angle encoding.html +17 -0
- data/spec/data/markdowntest/Amps and angle encoding.text +21 -0
- data/spec/data/markdowntest/Auto links.html +18 -0
- data/spec/data/markdowntest/Auto links.text +13 -0
- data/spec/data/markdowntest/Backslash escapes.html +118 -0
- data/spec/data/markdowntest/Backslash escapes.text +120 -0
- data/spec/data/markdowntest/Blockquotes with code blocks.html +15 -0
- data/spec/data/markdowntest/Blockquotes with code blocks.text +11 -0
- data/spec/data/markdowntest/Code Blocks.html +18 -0
- data/spec/data/markdowntest/Code Blocks.text +14 -0
- data/spec/data/markdowntest/Code Spans.html +5 -0
- data/spec/data/markdowntest/Code Spans.text +5 -0
- data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.html +8 -0
- data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/spec/data/markdowntest/Horizontal rules.html +71 -0
- data/spec/data/markdowntest/Horizontal rules.text +67 -0
- data/spec/data/markdowntest/Inline HTML (Advanced).html +15 -0
- data/spec/data/markdowntest/Inline HTML (Advanced).text +15 -0
- data/spec/data/markdowntest/Inline HTML (Simple).html +72 -0
- data/spec/data/markdowntest/Inline HTML (Simple).text +69 -0
- data/spec/data/markdowntest/Inline HTML comments.html +13 -0
- data/spec/data/markdowntest/Inline HTML comments.text +13 -0
- data/spec/data/markdowntest/Links, inline style.html +11 -0
- data/spec/data/markdowntest/Links, inline style.text +12 -0
- data/spec/data/markdowntest/Links, reference style.html +52 -0
- data/spec/data/markdowntest/Links, reference style.text +71 -0
- data/spec/data/markdowntest/Links, shortcut references.html +9 -0
- data/spec/data/markdowntest/Links, shortcut references.text +20 -0
- data/spec/data/markdowntest/Literal quotes in titles.html +3 -0
- data/spec/data/markdowntest/Literal quotes in titles.text +7 -0
- data/spec/data/markdowntest/Markdown Documentation - Basics.html +314 -0
- data/spec/data/markdowntest/Markdown Documentation - Basics.text +306 -0
- data/spec/data/markdowntest/Markdown Documentation - Syntax.html +942 -0
- data/spec/data/markdowntest/Markdown Documentation - Syntax.text +888 -0
- data/spec/data/markdowntest/Nested blockquotes.html +9 -0
- data/spec/data/markdowntest/Nested blockquotes.text +5 -0
- data/spec/data/markdowntest/Ordered and unordered lists.html +148 -0
- data/spec/data/markdowntest/Ordered and unordered lists.text +131 -0
- data/spec/data/markdowntest/Strong and em together.html +7 -0
- data/spec/data/markdowntest/Strong and em together.text +7 -0
- data/spec/data/markdowntest/Tabs.html +25 -0
- data/spec/data/markdowntest/Tabs.text +21 -0
- data/spec/data/markdowntest/Tidyness.html +8 -0
- data/spec/data/markdowntest/Tidyness.text +5 -0
- data/spec/data/ml-announce.txt +17 -0
- data/spec/data/re-overflow.txt +67 -0
- data/spec/data/re-overflow2.txt +281 -0
- data/spec/lib/constants.rb +5 -0
- data/spec/lib/helpers.rb +137 -0
- data/spec/lib/matchers.rb +235 -0
- data/spec/markdowntest_spec.rb +76 -0
- metadata +305 -0
data/rake/testing.rb
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
#
|
2
|
+
# Rake tasklib for testing tasks
|
3
|
+
# $Id: testing.rb 97 2009-04-03 17:02:28Z deveiant $
|
4
|
+
#
|
5
|
+
# Authors:
|
6
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
7
|
+
#
|
8
|
+
|
9
|
+
unless defined?( COVERAGE_MINIMUM )
|
10
|
+
if ENV['COVVERAGE_MINIMUM']
|
11
|
+
COVERAGE_MINIMUM = Float( ENV['COVERAGE_MINIMUM'] )
|
12
|
+
else
|
13
|
+
COVERAGE_MINIMUM = 85.0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
SPEC_FILES = [] unless defined?( SPEC_FILES )
|
17
|
+
TEST_FILES = [] unless defined?( TEST_FILES )
|
18
|
+
|
19
|
+
COMMON_SPEC_OPTS = ['-Du', '-b'] unless defined?( COMMON_SPEC_OPTS )
|
20
|
+
|
21
|
+
COVERAGE_TARGETDIR = BASEDIR + 'coverage' unless defined?( COVERAGE_TARGETDIR )
|
22
|
+
RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib' unless
|
23
|
+
defined?( RCOV_EXCLUDES )
|
24
|
+
|
25
|
+
|
26
|
+
desc "Run all defined tests"
|
27
|
+
task :test do
|
28
|
+
unless SPEC_FILES.empty?
|
29
|
+
log "Running specs"
|
30
|
+
Rake::Task['spec:quiet'].invoke
|
31
|
+
end
|
32
|
+
|
33
|
+
unless TEST_FILES.empty?
|
34
|
+
log "Running unit tests"
|
35
|
+
Rake::Task[:unittests].invoke
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
### RSpec specifications
|
41
|
+
begin
|
42
|
+
gem 'rspec', '>= 1.1.3'
|
43
|
+
|
44
|
+
require 'spec'
|
45
|
+
require 'spec/rake/spectask'
|
46
|
+
|
47
|
+
### Task: spec
|
48
|
+
desc "Run specs"
|
49
|
+
task :spec => 'spec:doc'
|
50
|
+
specfiles = SPEC_FILES.collect {|pn| pn.to_s }
|
51
|
+
|
52
|
+
namespace :spec do
|
53
|
+
desc "Run rspec every time there's a change to one of the files"
|
54
|
+
task :autotest do
|
55
|
+
require 'autotest/rspec'
|
56
|
+
|
57
|
+
autotester = Autotest::Rspec.new
|
58
|
+
autotester.run
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Generate regular color 'doc' spec output"
|
62
|
+
Spec::Rake::SpecTask.new( :doc ) do |task|
|
63
|
+
task.spec_files = specfiles
|
64
|
+
task.spec_opts = COMMON_SPEC_OPTS + ['-f', 's', '-c']
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Generate spec output with profiling"
|
68
|
+
Spec::Rake::SpecTask.new( :profile ) do |task|
|
69
|
+
task.spec_files = specfiles
|
70
|
+
task.spec_opts = COMMON_SPEC_OPTS + ['-f', 'o']
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Generate quiet non-colored plain-text output"
|
74
|
+
Spec::Rake::SpecTask.new( :quiet ) do |task|
|
75
|
+
task.spec_files = specfiles
|
76
|
+
task.spec_opts = COMMON_SPEC_OPTS + ['-f', 'p']
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Generate HTML output"
|
80
|
+
Spec::Rake::SpecTask.new( :html ) do |task|
|
81
|
+
task.spec_files = specfiles
|
82
|
+
task.spec_opts = COMMON_SPEC_OPTS + ['-f', 'h']
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
rescue LoadError => err
|
87
|
+
task :no_rspec do
|
88
|
+
$stderr.puts "Specification tasks not defined: %s" % [ err.message ]
|
89
|
+
end
|
90
|
+
|
91
|
+
task :spec => :no_rspec
|
92
|
+
namespace :spec do
|
93
|
+
task :autotest => :no_rspec
|
94
|
+
task :doc => :no_rspec
|
95
|
+
task :profile => :no_rspec
|
96
|
+
task :quiet => :no_rspec
|
97
|
+
task :html => :no_rspec
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
### Test::Unit tests
|
103
|
+
begin
|
104
|
+
require 'rake/testtask'
|
105
|
+
|
106
|
+
Rake::TestTask.new( :unittests ) do |task|
|
107
|
+
task.libs += [LIBDIR]
|
108
|
+
task.test_files = TEST_FILES
|
109
|
+
task.verbose = true
|
110
|
+
end
|
111
|
+
|
112
|
+
rescue LoadError => err
|
113
|
+
task :no_test do
|
114
|
+
$stderr.puts "Test tasks not defined: %s" % [ err.message ]
|
115
|
+
end
|
116
|
+
|
117
|
+
task :unittests => :no_rspec
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
### RCov (via RSpec) tasks
|
122
|
+
begin
|
123
|
+
gem 'rcov'
|
124
|
+
gem 'rspec', '>= 1.1.3'
|
125
|
+
|
126
|
+
require 'spec'
|
127
|
+
require 'rcov'
|
128
|
+
|
129
|
+
### Task: coverage (via RCov)
|
130
|
+
desc "Build test coverage reports"
|
131
|
+
unless SPEC_FILES.empty?
|
132
|
+
Spec::Rake::SpecTask.new( :coverage ) do |task|
|
133
|
+
task.spec_files = SPEC_FILES
|
134
|
+
task.libs += [LIBDIR]
|
135
|
+
task.spec_opts = ['-f', 'p', '-b']
|
136
|
+
task.rcov_opts = RCOV_OPTS
|
137
|
+
task.rcov = true
|
138
|
+
end
|
139
|
+
end
|
140
|
+
# unless TEST_FILES.empty?
|
141
|
+
# require 'rcov/rcovtask'
|
142
|
+
|
143
|
+
# Rcov::RcovTask.new do |task|
|
144
|
+
# task.libs += [LIBDIR]
|
145
|
+
# task.test_files = TEST_FILES
|
146
|
+
# task.verbose = true
|
147
|
+
# task.rcov_opts = RCOV_OPTS
|
148
|
+
# end
|
149
|
+
# end
|
150
|
+
|
151
|
+
|
152
|
+
### Task: rcov
|
153
|
+
task :rcov => :coverage
|
154
|
+
|
155
|
+
### Other coverage tasks
|
156
|
+
namespace :coverage do
|
157
|
+
desc "Generate a detailed text coverage report"
|
158
|
+
Spec::Rake::SpecTask.new( :text ) do |task|
|
159
|
+
task.spec_files = SPEC_FILES
|
160
|
+
task.rcov_opts = RCOV_OPTS + ['--text-report']
|
161
|
+
task.rcov = true
|
162
|
+
end
|
163
|
+
|
164
|
+
desc "Show differences in coverage from last run"
|
165
|
+
Spec::Rake::SpecTask.new( :diff ) do |task|
|
166
|
+
task.spec_files = SPEC_FILES
|
167
|
+
task.spec_opts = ['-f', 'p', '-b']
|
168
|
+
task.rcov_opts = RCOV_OPTS - ['--save'] + ['--text-coverage-diff']
|
169
|
+
task.rcov = true
|
170
|
+
end
|
171
|
+
|
172
|
+
### Task: verify coverage
|
173
|
+
desc "Build coverage statistics"
|
174
|
+
VerifyTask.new( :verify => :rcov ) do |task|
|
175
|
+
task.threshold = COVERAGE_MINIMUM
|
176
|
+
end
|
177
|
+
|
178
|
+
desc "Run RCov in 'spec-only' mode to check coverage from specs"
|
179
|
+
Spec::Rake::SpecTask.new( :speconly ) do |task|
|
180
|
+
task.spec_files = SPEC_FILES
|
181
|
+
task.rcov_opts = ['--exclude', RCOV_EXCLUDES, '--text-report', '--save']
|
182
|
+
task.rcov = true
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
CLOBBER.include( COVERAGE_TARGETDIR )
|
187
|
+
|
188
|
+
rescue LoadError => err
|
189
|
+
task :no_rcov do
|
190
|
+
$stderr.puts "Coverage tasks not defined: RSpec+RCov tasklib not available: %s" %
|
191
|
+
[ err.message ]
|
192
|
+
end
|
193
|
+
|
194
|
+
task :coverage => :no_rcov
|
195
|
+
task :clobber_coverage
|
196
|
+
task :rcov => :no_rcov
|
197
|
+
namespace :coverage do
|
198
|
+
task :text => :no_rcov
|
199
|
+
task :diff => :no_rcov
|
200
|
+
end
|
201
|
+
task :verify => :no_rcov
|
202
|
+
end
|
203
|
+
|
204
|
+
|
data/rake/verifytask.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#####################################################################
|
2
|
+
### S U B V E R S I O N T A S K S A N D H E L P E R S
|
3
|
+
#####################################################################
|
4
|
+
|
5
|
+
require 'rake/tasklib'
|
6
|
+
|
7
|
+
#
|
8
|
+
# Work around the inexplicable behaviour of the original RDoc::VerifyTask, which
|
9
|
+
# errors if your coverage isn't *exactly* the threshold.
|
10
|
+
#
|
11
|
+
|
12
|
+
# A task that can verify that the RCov coverage doesn't
|
13
|
+
# drop below a certain threshold. It should be run after
|
14
|
+
# running Spec::Rake::SpecTask.
|
15
|
+
class VerifyTask < Rake::TaskLib
|
16
|
+
|
17
|
+
COVERAGE_PERCENTAGE_PATTERN =
|
18
|
+
%r{<tt class='coverage_code'>(\d+\.\d+)%</tt>}
|
19
|
+
|
20
|
+
# Name of the task. Defaults to :verify_rcov
|
21
|
+
attr_accessor :name
|
22
|
+
|
23
|
+
# Path to the index.html file generated by RCov, which
|
24
|
+
# is the file containing the total coverage.
|
25
|
+
# Defaults to 'coverage/index.html'
|
26
|
+
attr_accessor :index_html
|
27
|
+
|
28
|
+
# Whether or not to output details. Defaults to true.
|
29
|
+
attr_accessor :verbose
|
30
|
+
|
31
|
+
# The threshold value (in percent) for coverage. If the
|
32
|
+
# actual coverage is not equal to this value, the task will raise an
|
33
|
+
# exception.
|
34
|
+
attr_accessor :threshold
|
35
|
+
|
36
|
+
def initialize( name=:verify )
|
37
|
+
@name = name
|
38
|
+
@index_html = 'coverage/index.html'
|
39
|
+
@verbose = true
|
40
|
+
yield self if block_given?
|
41
|
+
raise "Threshold must be set" if @threshold.nil?
|
42
|
+
define
|
43
|
+
end
|
44
|
+
|
45
|
+
def define
|
46
|
+
desc "Verify that rcov coverage is at least #{threshold}%"
|
47
|
+
|
48
|
+
task @name do
|
49
|
+
total_coverage = nil
|
50
|
+
if match = File.read( index_html ).match( COVERAGE_PERCENTAGE_PATTERN )
|
51
|
+
total_coverage = Float( match[1] )
|
52
|
+
else
|
53
|
+
raise "Couldn't find the coverage percentage in #{index_html}"
|
54
|
+
end
|
55
|
+
|
56
|
+
puts "Coverage: #{total_coverage}% (threshold: #{threshold}%)" if verbose
|
57
|
+
if total_coverage < threshold
|
58
|
+
raise "Coverage must be at least #{threshold}% but was #{total_coverage}%"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# vim: set nosta noet ts=4 sw=4:
|
data/rake/win32.rb
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
#
|
2
|
+
# Win32-specific tasks (cross-compiling, etc.)
|
3
|
+
#
|
4
|
+
# Thanks to some people that understand this stuff better than me for
|
5
|
+
# posting helpful blog posts. This stuff is an amalgam of stuff they did:
|
6
|
+
#
|
7
|
+
# * Mauricio Fernandez
|
8
|
+
# http://eigenclass.org/hiki/cross+compiling+rcovrt
|
9
|
+
#
|
10
|
+
# * Jeremy Hinegardner
|
11
|
+
# http://www.copiousfreetime.org/articles/2008/10/12/building-gems-for-windows.html
|
12
|
+
#
|
13
|
+
# * Aaron Patterson
|
14
|
+
# http://tenderlovemaking.com/2008/11/21/cross-compiling-ruby-gems-for-win32/
|
15
|
+
|
16
|
+
require 'rake'
|
17
|
+
require 'pathname'
|
18
|
+
require 'rubygems/platform'
|
19
|
+
require 'rbconfig'
|
20
|
+
require 'uri'
|
21
|
+
require 'net/ftp'
|
22
|
+
|
23
|
+
HOMEDIR = Pathname( '~' ).expand_path
|
24
|
+
RUBYVERSION = '1.8.6-p287'
|
25
|
+
RUBYVERSION_MAJORMINOR = RUBYVERSION[/^\d+\.\d+/]
|
26
|
+
|
27
|
+
RUBY_DL_BASE = "ftp://ftp.ruby-lang.org/pub/ruby/#{RUBYVERSION_MAJORMINOR}/"
|
28
|
+
RUBY_DL_URI = URI( RUBY_DL_BASE + "ruby-#{RUBYVERSION}.tar.gz" )
|
29
|
+
|
30
|
+
XCOMPILER_DIR = HOMEDIR + '.ruby_mingw32'
|
31
|
+
|
32
|
+
XCOMPILER_DL = XCOMPILER_DIR + "ruby-#{RUBYVERSION}.tar.gz"
|
33
|
+
XCOMPILER_SRC = XCOMPILER_DIR + "ruby-#{RUBYVERSION}"
|
34
|
+
|
35
|
+
XCOMPILER_BIN = XCOMPILER_DIR + 'bin'
|
36
|
+
XCOMPILER_LIB = XCOMPILER_DIR + 'lib'
|
37
|
+
XCOMPILER_RUBY = XCOMPILER_BIN + 'ruby.exe'
|
38
|
+
|
39
|
+
XCOMPILER_LOAD_PATH = XCOMPILER_LIB + "ruby/#{RUBYVERSION_MAJORMINOR}/i386-mingw32"
|
40
|
+
|
41
|
+
TAR_OPTS = { :compression => :gzip }
|
42
|
+
|
43
|
+
WIN32_GEMSPEC = GEMSPEC.dup
|
44
|
+
WIN32_GEMSPEC.files += FileList[ EXTDIR + '**.{dll,so}' ]
|
45
|
+
WIN32_GEMSPEC.platform = Gem::Platform.new( 'i386-mingw32' )
|
46
|
+
WIN32_GEMSPEC.extensions = []
|
47
|
+
|
48
|
+
|
49
|
+
CONFIGURE_CMD = %W[
|
50
|
+
env
|
51
|
+
ac_cv_func_getpgrp_void=no
|
52
|
+
ac_cv_func_setpgrp_void=yes
|
53
|
+
rb_cv_negative_time_t=no
|
54
|
+
ac_cv_func_memcmp_working=yes
|
55
|
+
rb_cv_binary_elf=no
|
56
|
+
./configure
|
57
|
+
--host=i386-mingw32
|
58
|
+
--target=i386-mingw32
|
59
|
+
--build=#{Gem::Platform.local}
|
60
|
+
--prefix=#{XCOMPILER_DIR}
|
61
|
+
]
|
62
|
+
|
63
|
+
### Archive::Tar::Reader#extract (as of 0.9.0) is broken w.r.t.
|
64
|
+
### permissions, so we have to do this ourselves.
|
65
|
+
def untar( tarfile, targetdir )
|
66
|
+
targetdir = Pathname( targetdir )
|
67
|
+
raise "No such directory: #{targetdir}" unless targetdir.directory?
|
68
|
+
|
69
|
+
reader = Archive::Tar::Reader.new( tarfile.to_s, TAR_OPTS )
|
70
|
+
|
71
|
+
mkdir_p( targetdir )
|
72
|
+
reader.each( true ) do |header, body|
|
73
|
+
path = targetdir + header[:path]
|
74
|
+
# trace "Header is: %p" % [ header ]
|
75
|
+
|
76
|
+
case header[:type]
|
77
|
+
when :file
|
78
|
+
trace " #{path}"
|
79
|
+
path.open( File::WRONLY|File::EXCL|File::CREAT|File::TRUNC, header[:mode] ) do |fio|
|
80
|
+
bytesize = header[:size]
|
81
|
+
fio.write( body[0,bytesize] )
|
82
|
+
end
|
83
|
+
|
84
|
+
when :directory
|
85
|
+
trace " #{path}"
|
86
|
+
path.mkpath
|
87
|
+
|
88
|
+
when :link
|
89
|
+
linktarget = targetdir + header[:dest]
|
90
|
+
trace " #{path} => #{linktarget}"
|
91
|
+
path.make_link( linktarget.to_s )
|
92
|
+
|
93
|
+
when :symlink
|
94
|
+
linktarget = targetdir + header[:dest]
|
95
|
+
trace " #{path} -> #{linktarget}"
|
96
|
+
path.make_symlink( linktarget )
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
begin
|
104
|
+
require 'archive/tar'
|
105
|
+
|
106
|
+
namespace :win32 do
|
107
|
+
directory XCOMPILER_DIR.to_s
|
108
|
+
|
109
|
+
file XCOMPILER_DL => XCOMPILER_DIR do
|
110
|
+
# openuri can't handle this -- passive ftp required?
|
111
|
+
# run 'wget', '-O', XCOMPILER_DL, RUBY_DL_URI
|
112
|
+
log "Downloading ruby distro from %s" % [ RUBY_DL_URI ]
|
113
|
+
ftp = Net::FTP.new( RUBY_DL_URI.host )
|
114
|
+
ftp.login
|
115
|
+
ftp.getbinaryfile( RUBY_DL_URI.path, XCOMPILER_DL, 4096 )
|
116
|
+
ftp.close
|
117
|
+
end
|
118
|
+
|
119
|
+
directory XCOMPILER_SRC.to_s
|
120
|
+
task XCOMPILER_SRC => [ XCOMPILER_DIR, XCOMPILER_DL ] do
|
121
|
+
if XCOMPILER_SRC.exist?
|
122
|
+
trace "Rake fails. #{XCOMPILER_SRC} already exists."
|
123
|
+
else
|
124
|
+
untar( XCOMPILER_DL, XCOMPILER_DIR )
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
file XCOMPILER_RUBY => XCOMPILER_SRC do
|
129
|
+
Dir.chdir( XCOMPILER_SRC ) do
|
130
|
+
unless File.exist?( 'Makefile.in.orig' )
|
131
|
+
File.open( 'Makefile.in.new', IO::CREAT|IO::WRONLY|IO::EXCL ) do |ofh|
|
132
|
+
IO.readlines( 'Makefile.in' ).each do |line|
|
133
|
+
next if line.include?( 0.chr )
|
134
|
+
trace " copying line: %p" % [ line ]
|
135
|
+
line.sub!( /ALT_SEPARATOR = ".*?"/, "ALT_SEPARATOR = 92.chr" )
|
136
|
+
ofh.write( line )
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
mv 'Makefile.in', 'Makefile.in.orig'
|
141
|
+
mv 'Makefile.in.new', 'Makefile.in'
|
142
|
+
end
|
143
|
+
|
144
|
+
run *CONFIGURE_CMD
|
145
|
+
run 'make', 'ruby'
|
146
|
+
run 'make', 'rubyw.exe'
|
147
|
+
run 'make', '-n', 'install'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
file XCOMPILER_LOAD_PATH => XCOMPILER_RUBY
|
152
|
+
|
153
|
+
desc "Cross-compile the library for Win32 systems, installing a cross-" +
|
154
|
+
"compiled Ruby if necessary"
|
155
|
+
task :build => [ EXTDIR, XCOMPILER_LOAD_PATH.to_s ] do
|
156
|
+
in_subdirectory( EXTDIR ) do
|
157
|
+
ruby "-I#{XCOMPILER_LOAD_PATH}", 'extconf.rb'
|
158
|
+
sh 'make'
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
desc "Build a binary gem for win32 systems"
|
163
|
+
task :gem => ['win32:build', PKGDIR.to_s] + WIN32_GEMSPEC.files do
|
164
|
+
when_writing( "Creating win32 GEM" ) do
|
165
|
+
pkgname = WIN32_GEMSPEC.file_name
|
166
|
+
builder = Gem::Builder.new( WIN32_GEMSPEC )
|
167
|
+
builder.build
|
168
|
+
mv pkgname, PKGDIR + pkgname, :verbose => $trace
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
rescue LoadError => err
|
174
|
+
task :no_win32_build do
|
175
|
+
abort "No win32 build: %s: %s" % [ err.class.name, err.message ]
|
176
|
+
end
|
177
|
+
|
178
|
+
namespace :win32 do
|
179
|
+
desc "Build a binary Gem for Win32 systems, installing a cross " +
|
180
|
+
"compiled Ruby if necessary"
|
181
|
+
task :build => :no_win32_build
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
|