bluecloth 2.0.5 → 2.0.6.pre120

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2008, Michael Granger
1
+ Copyright (c) 2004-2010, Michael Granger
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README CHANGED
@@ -60,10 +60,10 @@ You can also install as a site library via the Rakefile:
60
60
 
61
61
  == Source
62
62
 
63
- You can check out the current development source with Subversion from
63
+ You can check out the current development source with Mercurial from
64
64
  the following URL:
65
65
 
66
- svn://deveiate.org/BlueCloth/trunk
66
+ http://repo.deveiate.org/BlueCloth
67
67
 
68
68
  You can report bugs, suggest improvements, or check on development
69
69
  activity at the project page:
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- #!rake
1
+ #!rake -*- ruby -*-
2
2
  #
3
3
  # BlueCloth rakefile
4
4
  #
5
5
  # Based on various other Rakefiles, especially one by Ben Bleything
6
6
  #
7
- # Copyright (c) 2007-2009 The FaerieMUD Consortium
7
+ # Copyright (c) 2007-2010 The FaerieMUD Consortium
8
8
  #
9
9
  # Authors:
10
10
  # * Michael Granger <ged@FaerieMUD.org>
@@ -21,13 +21,31 @@ BEGIN {
21
21
  $LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
22
22
  }
23
23
 
24
+ begin
25
+ require 'readline'
26
+ include Readline
27
+ rescue LoadError
28
+ # Fall back to a plain prompt
29
+ def readline( text )
30
+ $stderr.print( text.chomp )
31
+ return $stdin.gets
32
+ end
33
+ end
34
+
35
+ begin
36
+ require 'rubygems'
37
+ rescue LoadError
38
+ module Gem
39
+ class Specification; end
40
+ end
41
+ end
42
+
24
43
  require 'rbconfig'
25
44
  require 'rake'
26
- require 'rake/rdoctask'
27
45
  require 'rake/testtask'
28
46
  require 'rake/packagetask'
29
47
  require 'rake/clean'
30
- require 'rake/191_compat.rb'
48
+ # require 'rake/191_compat.rb'
31
49
 
32
50
  $dryrun = false
33
51
 
@@ -40,6 +58,8 @@ DOCSDIR = BASEDIR + 'docs'
40
58
  PKGDIR = BASEDIR + 'pkg'
41
59
  DATADIR = BASEDIR + 'data'
42
60
 
61
+ MANUALDIR = DOCSDIR + 'manual'
62
+
43
63
  PROJECT_NAME = 'BlueCloth'
44
64
  PKG_NAME = PROJECT_NAME.downcase
45
65
  PKG_SUMMARY = 'BlueCloth is a Ruby implementation of Markdown'
@@ -60,33 +80,42 @@ end
60
80
  PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
61
81
  GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
62
82
 
83
+ # Universal VCS constants
84
+ DEFAULT_EDITOR = 'vi'
85
+ COMMIT_MSG_FILE = 'commit-msg.txt'
86
+ FILE_INDENT = " " * 12
87
+ LOG_INDENT = " " * 3
88
+
63
89
  EXTCONF = EXTDIR + 'extconf.rb'
64
90
 
65
91
  ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
66
92
 
67
93
  TEXT_FILES = Rake::FileList.new( %w[Rakefile ChangeLog README LICENSE] )
68
- BIN_FILES = Rake::FileList.new( "#{BINDIR}/*" ).exclude( /\.svn/ )
69
- LIB_FILES = Rake::FileList.new( "#{LIBDIR}/**/*.rb" ).exclude( /\.svn/ )
70
- EXT_FILES = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" ).exclude( /\.svn/ )
71
- DATA_FILES = Rake::FileList.new( "#{DATADIR}/**/*" ).exclude( /\.svn/ )
94
+ BIN_FILES = Rake::FileList.new( "#{BINDIR}/*" )
95
+ LIB_FILES = Rake::FileList.new( "#{LIBDIR}/**/*.rb" )
96
+ EXT_FILES = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" )
97
+ DATA_FILES = Rake::FileList.new( "#{DATADIR}/**/*" )
72
98
 
73
99
  SPECDIR = BASEDIR + 'spec'
74
100
  SPECLIBDIR = SPECDIR + 'lib'
75
101
  SPEC_FILES = Rake::FileList.new( "#{SPECDIR}/**/*_spec.rb", "#{SPECLIBDIR}/**/*.rb" )
76
102
 
77
103
  TESTDIR = BASEDIR + 'tests'
78
- TEST_FILES = Rake::FileList.new( "#{TESTDIR}/**/*.tests.rb" ).exclude( /\.svn/ )
104
+ TEST_FILES = Rake::FileList.new( "#{TESTDIR}/**/*.tests.rb" )
79
105
 
80
106
  RAKE_TASKDIR = BASEDIR + 'rake'
81
107
  RAKE_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/*.rb" )
108
+ PKG_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/{191_compat,helpers,packaging,rdoc,testing}.rb" )
109
+ PKG_TASKLIBS.include( "#{RAKE_TASKDIR}/manual.rb" ) if MANUALDIR.exist?
110
+
111
+ RAKE_TASKLIBS_URL = 'http://repo.deveiate.org/rake-tasklibs'
82
112
 
83
113
  LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
84
114
 
85
115
  EXTRA_PKGFILES = Rake::FileList.new
86
- EXTRA_PKGFILES.include "#{BASEDIR}/LICENSE.discount"
87
- EXTRA_PKGFILES.include "#{BASEDIR}/spec/data/**/*.{txt,text,html}"
88
- EXTRA_PKGFILES.include "#{BASEDIR}/ext/VERSION"
89
- EXTRA_PKGFILES.exclude( /\.svn/ )
116
+ EXTRA_PKGFILES.include( "#{BASEDIR}/LICENSE.discount" )
117
+ EXTRA_PKGFILES.include( "#{BASEDIR}/spec/data/**/*.{txt,text,html}" )
118
+ EXTRA_PKGFILES.include( "#{BASEDIR}/ext/VERSION" )
90
119
 
91
120
  RELEASE_FILES = TEXT_FILES +
92
121
  SPEC_FILES +
@@ -98,8 +127,13 @@ RELEASE_FILES = TEXT_FILES +
98
127
  RAKE_TASKLIBS +
99
128
  EXTRA_PKGFILES
100
129
 
130
+
101
131
  RELEASE_FILES << LOCAL_RAKEFILE.to_s if LOCAL_RAKEFILE.exist?
102
132
 
133
+ RELEASE_ANNOUNCE_ADDRESSES = [
134
+ "Ruby-Talk List <ruby-talk@ruby-lang.org>",
135
+ ]
136
+
103
137
  COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
104
138
  RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
105
139
  RCOV_OPTS = [
@@ -111,23 +145,35 @@ RCOV_OPTS = [
111
145
  ]
112
146
 
113
147
 
114
- # Subversion constants -- directory names for releases and tags
115
- SVN_TRUNK_DIR = 'trunk'
116
- SVN_RELEASES_DIR = 'releases'
117
- SVN_BRANCHES_DIR = 'branches'
118
- SVN_TAGS_DIR = 'tags'
119
-
120
- SVN_DOTDIR = BASEDIR + '.svn'
121
- SVN_ENTRIES = SVN_DOTDIR + 'entries'
148
+ ### Load some task libraries that need to be loaded early
149
+ if !RAKE_TASKDIR.exist?
150
+ $stderr.puts "It seems you don't have the build task directory. Shall I fetch it "
151
+ ans = readline( "for you? [y]" )
152
+ ans = 'y' if !ans.nil? && ans.empty?
153
+
154
+ if ans =~ /^y/i
155
+ $stderr.puts "Okay, fetching #{RAKE_TASKLIBS_URL} into #{RAKE_TASKDIR}..."
156
+ system 'hg', 'clone', RAKE_TASKLIBS_URL, "./#{RAKE_TASKDIR}"
157
+ if ! $?.success?
158
+ fail "Damn. That didn't work. Giving up; maybe try manually fetching?"
159
+ end
160
+ else
161
+ $stderr.puts "Then I'm afraid I can't continue. Best of luck."
162
+ fail "Rake tasklibs not present."
163
+ end
122
164
 
165
+ RAKE_TASKLIBS.include( "#{RAKE_TASKDIR}/*.rb" )
166
+ end
123
167
 
124
- ### Load some task libraries that need to be loaded early
125
168
  require RAKE_TASKDIR + 'helpers.rb'
126
- require RAKE_TASKDIR + 'svn.rb'
127
- require RAKE_TASKDIR + 'verifytask.rb'
128
169
 
129
- # Define some constants that depend on the 'svn' tasklib
130
- PKG_BUILD = get_svn_rev( BASEDIR ) || 0
170
+ # Set the build ID if the mercurial executable is available
171
+ if hg = which( 'hg' )
172
+ id = IO.read('|-') or exec hg.to_s, 'id', '-n'
173
+ PKG_BUILD = 'pre' + (id.chomp[ /^[[:xdigit:]]+/ ] || '1')
174
+ else
175
+ PKG_BUILD = 'pre0'
176
+ end
131
177
  SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
132
178
  SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
133
179
 
@@ -139,11 +185,11 @@ RDOC_OPTIONS = [
139
185
  '-i', '.',
140
186
  '-m', 'README',
141
187
  '-t', PKG_NAME,
142
- '-W', 'http://deveiate.org/projects/BlueCloth/browser/trunk/'
188
+ '-W', 'http://deveiate.org/projects/BlueCloth/browser/'
143
189
  ]
144
190
 
145
191
  # Release constants
146
- SMTP_HOST = 'mail.faeriemud.org'
192
+ SMTP_HOST = "mail.faeriemud.org"
147
193
  SMTP_PORT = 465 # SMTP + SSL
148
194
 
149
195
  # Project constants
@@ -153,29 +199,23 @@ PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
153
199
  PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
154
200
  PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
155
201
 
156
- # Rubyforge stuff
157
- RUBYFORGE_GROUP = 'deveiate'
158
- RUBYFORGE_PROJECT = 'bluecloth'
159
-
160
202
  # Gem dependencies: gemname => version
161
203
  DEPENDENCIES = {
162
204
  }
163
205
 
164
206
  # Developer Gem dependencies: gemname => version
165
207
  DEVELOPMENT_DEPENDENCIES = {
166
- 'amatch' => '>= 0.2.3',
167
- 'rake' => '>= 0.8.1',
208
+ 'rake' => '>= 0.8.7',
168
209
  'rcodetools' => '>= 0.7.0.0',
169
- 'rcov' => '>= 0',
210
+ 'rcov' => '>= 0.8.1.2.0',
211
+ 'rdoc' => '>= 2.4.3',
170
212
  'RedCloth' => '>= 4.0.3',
171
- 'rspec' => '>= 0',
172
- 'rubyforge' => '>= 0',
213
+ 'rspec' => '>= 1.2.6',
173
214
  'termios' => '>= 0',
174
215
  'text-format' => '>= 1.0.0',
175
216
  'tmail' => '>= 1.2.3.1',
176
- 'ultraviolet' => '>= 0.10.2',
177
- 'libxml-ruby' => '>= 0.8.3',
178
- 'rdoc' => '>= 2.4.3',
217
+ 'diff-lcs' => '>= 1.1.2',
218
+ 'rake-compiler' => '>= 0.7.0',
179
219
  }
180
220
 
181
221
  # Non-gem requirements: packagename => version
@@ -196,9 +236,8 @@ GEMSPEC = Gem::Specification.new do |gem|
196
236
  ].join( "\n" )
197
237
 
198
238
  gem.authors = "Michael Granger"
199
- gem.email = "ged@FaerieMUD.org"
239
+ gem.email = ["ged@FaerieMUD.org"]
200
240
  gem.homepage = 'http://deveiate.org/projects/BlueCloth/'
201
- gem.rubyforge_project = RUBYFORGE_PROJECT
202
241
 
203
242
  gem.has_rdoc = true
204
243
  gem.rdoc_options = RDOC_OPTIONS
@@ -207,6 +246,7 @@ GEMSPEC = Gem::Specification.new do |gem|
207
246
  gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
208
247
  gem.executables = BIN_FILES.select {|pn| File.executable?(pn) }.
209
248
  collect {|pn| File.basename(pn) }
249
+ gem.require_paths << EXTDIR.relative_path_from( BASEDIR ).to_s if EXTDIR.exist?
210
250
 
211
251
  if EXTCONF.exist?
212
252
  gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s
@@ -214,38 +254,33 @@ GEMSPEC = Gem::Specification.new do |gem|
214
254
 
215
255
  gem.files = RELEASE_FILES
216
256
  gem.test_files = SPEC_FILES
217
-
257
+
218
258
  DEPENDENCIES.each do |name, version|
219
259
  version = '>= 0' if version.length.zero?
220
260
  gem.add_runtime_dependency( name, version )
221
261
  end
222
-
223
- # Developmental dependencies don't work as of RubyGems 1.2.0
224
- unless Gem::Version.new( Gem::RubyGemsVersion ) <= Gem::Version.new( "1.2.0" )
225
- DEVELOPMENT_DEPENDENCIES.each do |name, version|
226
- version = '>= 0' if version.length.zero?
227
- gem.add_development_dependency( name, version )
228
- end
229
- end
230
-
262
+
231
263
  REQUIREMENTS.each do |name, version|
232
264
  gem.requirements << [ name, version ].compact.join(' ')
233
265
  end
234
266
  end
235
267
 
236
- # Manual-generation config
237
- MANUALDIR = DOCSDIR + 'manual'
268
+
269
+ task :prerelease do
270
+ GEMSPEC.version.version += '.' + PKG_BUILD
271
+ end
272
+
238
273
 
239
274
  $trace = Rake.application.options.trace ? true : false
240
275
  $dryrun = Rake.application.options.dryrun ? true : false
241
-
276
+ $include_dev_dependencies = false
242
277
 
243
278
  # Load any remaining task libraries
244
279
  RAKE_TASKLIBS.each do |tasklib|
245
- next if tasklib.to_s =~ %r{/(helpers|svn|verifytask)\.rb$}
280
+ next if tasklib.to_s =~ %r{/helpers\.rb$}
246
281
  begin
247
282
  trace " loading tasklib %s" % [ tasklib ]
248
- require tasklib
283
+ import tasklib
249
284
  rescue ScriptError => err
250
285
  fail "Task library '%s' failed to load: %s: %s" %
251
286
  [ tasklib, err.class.name, err.message ]
@@ -271,19 +306,15 @@ task :default => [:clean, :local, :spec, :rdoc, :package]
271
306
  ### Task the local Rakefile can append to -- no-op by default
272
307
  task :local
273
308
 
274
-
275
309
  ### Task: clean
276
- CLEAN.include 'coverage'
277
- CLOBBER.include 'artifacts', 'coverage.info', PKGDIR
278
-
279
- # Target to hinge on ChangeLog updates
280
- file SVN_ENTRIES
310
+ CLEAN.include 'coverage', '**/*.orig', '**/*.rej'
311
+ CLOBBER.include 'artifacts', 'coverage.info', 'ChangeLog', PKGDIR
281
312
 
282
313
  ### Task: changelog
283
- file 'ChangeLog' => SVN_ENTRIES.to_s do |task|
314
+ file 'ChangeLog' do |task|
284
315
  log "Updating #{task.name}"
285
316
 
286
- changelog = make_svn_changelog()
317
+ changelog = make_changelog()
287
318
  File.open( task.name, 'w' ) do |fh|
288
319
  fh.print( changelog )
289
320
  end
@@ -296,13 +327,13 @@ task :cruise => [:clean, 'spec:quiet', :package] do |task|
296
327
  raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
297
328
  artifact_dir = ARTIFACTS_DIR.cleanpath + (CC_BUILD_LABEL || Time.now.strftime('%Y%m%d-%T'))
298
329
  artifact_dir.mkpath
299
-
330
+
300
331
  coverage = BASEDIR + 'coverage'
301
332
  if coverage.exist? && coverage.directory?
302
333
  $stderr.puts "Copying coverage stats..."
303
334
  FileUtils.cp_r( 'coverage', artifact_dir )
304
335
  end
305
-
336
+
306
337
  $stderr.puts "Copying packages..."
307
338
  FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
308
339
  end
@@ -311,7 +342,7 @@ end
311
342
  desc "Update the build system to the latest version"
312
343
  task :update_build do
313
344
  log "Updating the build system"
314
- sh 'svn', 'up', RAKE_TASKDIR
345
+ run 'hg', '-R', RAKE_TASKDIR, 'pull', '-u'
315
346
  log "Updating the Rakefile"
316
347
  sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
317
348
  end
data/Rakefile.local CHANGED
@@ -1,5 +1,7 @@
1
1
  #!rake
2
2
 
3
+ require 'rake/extensiontask'
4
+
3
5
  # C extension constants
4
6
  EXT_MAKEFILE = EXTDIR + 'Makefile'
5
7
  EXT_SOURCES = FileList[ EXTDIR + '*.c' ]
@@ -14,50 +16,28 @@ DOCFILES << 'LICENSE.discount'
14
16
  #####################################################################
15
17
 
16
18
  # Make both the default task and the spec task depend on building the extension
17
- task :local => :build
18
- task :spec => :build
19
+ task :local => :compile
20
+ task :spec => :compile
19
21
  namespace :spec do
20
- task :doc => [ :build ]
21
- task :quiet => [ :build ]
22
- task :html => [ :build ]
23
- task :text => [ :build ]
22
+ task :doc => [ :compile ]
23
+ task :quiet => [ :compile ]
24
+ task :html => [ :compile ]
25
+ task :text => [ :compile ]
24
26
  end
25
27
 
26
- desc "Make the Makefile for the C extension"
27
- file EXT_MAKEFILE.to_s => EXT_SOURCES do
28
- log "Configuring BlueCloth C extension"
29
- in_subdirectory( EXTDIR ) do
30
- ruby 'extconf.rb'
31
- end
32
- end
33
- CLOBBER.include( EXTDIR + 'mkmf.log', EXTDIR + 'conftest.dSYM', EXT_SO )
34
-
35
- desc "Build the C extension"
36
- task :build => EXT_SO
37
- file EXT_SO => [ EXT_MAKEFILE.to_s, *EXT_SOURCES ] do
38
- in_subdirectory( EXTDIR ) do
39
- sh 'make'
40
- end
28
+ ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
29
+
30
+ Rake::ExtensionTask.new do |ext|
31
+ ext.name = 'bluecloth_ext'
32
+ ext.gem_spec = GEMSPEC
33
+ ext.ext_dir = 'ext'
34
+ ext.lib_dir = 'lib'
35
+ ext.source_pattern = "*.{c,h}"
36
+ ext.cross_compile = true
37
+ ext.cross_platform = %w[i386-mswin32 i386-mingw32]
41
38
  end
42
39
 
43
- desc "Rebuild the C extension"
44
- task :rebuild => [ :clobber, :build ]
45
-
46
-
47
- task :clean do
48
- if EXT_MAKEFILE.exist?
49
- in_subdirectory( EXTDIR ) do
50
- sh 'make clean'
51
- end
52
- end
53
- end
54
-
55
- task :clobber do
56
- if EXT_MAKEFILE.exist?
57
- in_subdirectory( EXTDIR ) do
58
- sh 'make distclean'
59
- end
60
- end
61
- end
62
- CLOBBER.include( EXT_MAKEFILE )
40
+ WINFAT_DIRS = Rake::FileList[ LIBDIR + '{1.8,1.9}' ]
41
+
42
+ CLEAN.include( WINFAT_DIRS )
63
43
 
data/ext/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.4
1
+ 1.5.8
data/ext/bluecloth.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * BlueCloth -- a Ruby implementation of Markdown
3
- * $Id: bluecloth.c 123 2009-06-15 13:15:54Z deveiant $
3
+ * $Id$
4
4
  *
5
5
  * = Authors
6
6
  *
@@ -22,8 +22,7 @@
22
22
  *
23
23
  */
24
24
 
25
- #include "mkdio.h"
26
- #include "ruby.h"
25
+ #include "bluecloth.h"
27
26
 
28
27
  VALUE bluecloth_cBlueCloth;
29
28
  VALUE bluecloth_default_opthash;
@@ -146,7 +145,12 @@ bluecloth_s_allocate( VALUE klass ) {
146
145
  */
147
146
  static VALUE
148
147
  bluecloth_s_discount_version( VALUE klass ) {
148
+ #ifdef HAVE_RUBY_ENCODING_H
149
+ return rb_external_str_new_with_enc( markdown_version, strlen(markdown_version),
150
+ rb_default_external_encoding() );
151
+ #else
149
152
  return rb_str_new2( markdown_version );
153
+ #endif
150
154
  }
151
155
 
152
156
  /* --------------------------------------------------------------
@@ -201,6 +205,9 @@ bluecloth_initialize( int argc, VALUE *argv, VALUE self ) {
201
205
  opthash = text;
202
206
  text = rb_str_new( "", 0 );
203
207
  }
208
+ else {
209
+ text = rb_obj_as_string( text );
210
+ }
204
211
 
205
212
  /* Merge the options hash with the defaults and turn it into a flags int */
206
213
  if ( NIL_P(opthash) ) opthash = rb_hash_new();
@@ -217,6 +224,9 @@ bluecloth_initialize( int argc, VALUE *argv, VALUE self ) {
217
224
  rb_iv_set( self, "@text", textcopy );
218
225
  OBJ_FREEZE( fullhash );
219
226
  rb_iv_set( self, "@options", fullhash );
227
+ #ifdef HAVE_RUBY_ENCODING_H
228
+ rb_enc_copy( self, text );
229
+ #endif
220
230
 
221
231
  OBJ_INFECT( self, text );
222
232
  }
@@ -245,6 +255,9 @@ bluecloth_to_html( VALUE self ) {
245
255
  bluecloth_debug( "Pointer to results: %p, length = %d", output, length );
246
256
  result = rb_str_new( output, length );
247
257
 
258
+ #ifdef HAVE_RUBY_ENCODING_H
259
+ rb_enc_copy( result, self );
260
+ #endif
248
261
  OBJ_INFECT( result, self );
249
262
  return result;
250
263
  } else {
@@ -325,7 +338,8 @@ void Init_bluecloth_ext( void ) {
325
338
 
326
339
  /* The options hash that describes the options in effect when the object was created */
327
340
  rb_define_attr( bluecloth_cBlueCloth, "options", 1, 0 );
328
-
341
+
342
+
329
343
  /* --- Constants ----- */
330
344
 
331
345
  /* Do not process `[]' and remove A tags from the output. */