bluecloth 2.0.6.pre120-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/ChangeLog +363 -0
  2. data/LICENSE +27 -0
  3. data/LICENSE.discount +47 -0
  4. data/README +81 -0
  5. data/Rakefile +349 -0
  6. data/Rakefile.local +43 -0
  7. data/bin/bluecloth +84 -0
  8. data/ext/Csio.c +61 -0
  9. data/ext/VERSION +1 -0
  10. data/ext/amalloc.h +29 -0
  11. data/ext/bluecloth.c +391 -0
  12. data/ext/bluecloth.h +19 -0
  13. data/ext/config.h +55 -0
  14. data/ext/css.c +76 -0
  15. data/ext/cstring.h +75 -0
  16. data/ext/docheader.c +43 -0
  17. data/ext/extconf.rb +52 -0
  18. data/ext/generate.c +1602 -0
  19. data/ext/markdown.c +1078 -0
  20. data/ext/markdown.h +146 -0
  21. data/ext/mkdio.c +303 -0
  22. data/ext/mkdio.h +79 -0
  23. data/ext/resource.c +155 -0
  24. data/ext/version.c +28 -0
  25. data/ext/xml.c +82 -0
  26. data/ext/xmlpage.c +48 -0
  27. data/lib/1.8/bluecloth_ext.so +0 -0
  28. data/lib/1.9/bluecloth_ext.so +0 -0
  29. data/lib/bluecloth.rb +164 -0
  30. data/rake/191_compat.rb +26 -0
  31. data/rake/dependencies.rb +76 -0
  32. data/rake/helpers.rb +434 -0
  33. data/rake/hg.rb +273 -0
  34. data/rake/manual.rb +782 -0
  35. data/rake/packaging.rb +126 -0
  36. data/rake/publishing.rb +269 -0
  37. data/rake/rdoc.rb +30 -0
  38. data/rake/style.rb +62 -0
  39. data/rake/svn.rb +668 -0
  40. data/rake/testing.rb +187 -0
  41. data/rake/verifytask.rb +64 -0
  42. data/rake/win32.rb +190 -0
  43. data/spec/bluecloth/101_changes_spec.rb +141 -0
  44. data/spec/bluecloth/autolinks_spec.rb +49 -0
  45. data/spec/bluecloth/blockquotes_spec.rb +145 -0
  46. data/spec/bluecloth/code_spans_spec.rb +164 -0
  47. data/spec/bluecloth/emphasis_spec.rb +164 -0
  48. data/spec/bluecloth/entities_spec.rb +65 -0
  49. data/spec/bluecloth/hrules_spec.rb +90 -0
  50. data/spec/bluecloth/images_spec.rb +92 -0
  51. data/spec/bluecloth/inline_html_spec.rb +238 -0
  52. data/spec/bluecloth/links_spec.rb +171 -0
  53. data/spec/bluecloth/lists_spec.rb +294 -0
  54. data/spec/bluecloth/paragraphs_spec.rb +75 -0
  55. data/spec/bluecloth/titles_spec.rb +305 -0
  56. data/spec/bluecloth_spec.rb +281 -0
  57. data/spec/bugfix_spec.rb +172 -0
  58. data/spec/contributions_spec.rb +85 -0
  59. data/spec/data/antsugar.txt +34 -0
  60. data/spec/data/markdowntest/Amps and angle encoding.html +17 -0
  61. data/spec/data/markdowntest/Amps and angle encoding.text +21 -0
  62. data/spec/data/markdowntest/Auto links.html +18 -0
  63. data/spec/data/markdowntest/Auto links.text +13 -0
  64. data/spec/data/markdowntest/Backslash escapes.html +118 -0
  65. data/spec/data/markdowntest/Backslash escapes.text +120 -0
  66. data/spec/data/markdowntest/Blockquotes with code blocks.html +15 -0
  67. data/spec/data/markdowntest/Blockquotes with code blocks.text +11 -0
  68. data/spec/data/markdowntest/Code Blocks.html +18 -0
  69. data/spec/data/markdowntest/Code Blocks.text +14 -0
  70. data/spec/data/markdowntest/Code Spans.html +5 -0
  71. data/spec/data/markdowntest/Code Spans.text +5 -0
  72. data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.html +8 -0
  73. data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.text +8 -0
  74. data/spec/data/markdowntest/Horizontal rules.html +71 -0
  75. data/spec/data/markdowntest/Horizontal rules.text +67 -0
  76. data/spec/data/markdowntest/Inline HTML (Advanced).html +15 -0
  77. data/spec/data/markdowntest/Inline HTML (Advanced).text +15 -0
  78. data/spec/data/markdowntest/Inline HTML (Simple).html +72 -0
  79. data/spec/data/markdowntest/Inline HTML (Simple).text +69 -0
  80. data/spec/data/markdowntest/Inline HTML comments.html +13 -0
  81. data/spec/data/markdowntest/Inline HTML comments.text +13 -0
  82. data/spec/data/markdowntest/Links, inline style.html +11 -0
  83. data/spec/data/markdowntest/Links, inline style.text +12 -0
  84. data/spec/data/markdowntest/Links, reference style.html +52 -0
  85. data/spec/data/markdowntest/Links, reference style.text +71 -0
  86. data/spec/data/markdowntest/Links, shortcut references.html +9 -0
  87. data/spec/data/markdowntest/Links, shortcut references.text +20 -0
  88. data/spec/data/markdowntest/Literal quotes in titles.html +3 -0
  89. data/spec/data/markdowntest/Literal quotes in titles.text +7 -0
  90. data/spec/data/markdowntest/Markdown Documentation - Basics.html +314 -0
  91. data/spec/data/markdowntest/Markdown Documentation - Basics.text +306 -0
  92. data/spec/data/markdowntest/Markdown Documentation - Syntax.html +942 -0
  93. data/spec/data/markdowntest/Markdown Documentation - Syntax.text +888 -0
  94. data/spec/data/markdowntest/Nested blockquotes.html +9 -0
  95. data/spec/data/markdowntest/Nested blockquotes.text +5 -0
  96. data/spec/data/markdowntest/Ordered and unordered lists.html +148 -0
  97. data/spec/data/markdowntest/Ordered and unordered lists.text +131 -0
  98. data/spec/data/markdowntest/Strong and em together.html +7 -0
  99. data/spec/data/markdowntest/Strong and em together.text +7 -0
  100. data/spec/data/markdowntest/Tabs.html +25 -0
  101. data/spec/data/markdowntest/Tabs.text +21 -0
  102. data/spec/data/markdowntest/Tidyness.html +8 -0
  103. data/spec/data/markdowntest/Tidyness.text +5 -0
  104. data/spec/data/ml-announce.txt +17 -0
  105. data/spec/data/re-overflow.txt +67 -0
  106. data/spec/data/re-overflow2.txt +281 -0
  107. data/spec/discount_spec.rb +184 -0
  108. data/spec/lib/constants.rb +5 -0
  109. data/spec/lib/helpers.rb +137 -0
  110. data/spec/lib/matchers.rb +235 -0
  111. data/spec/markdowntest_spec.rb +79 -0
  112. metadata +205 -0
data/rake/packaging.rb ADDED
@@ -0,0 +1,126 @@
1
+ #####################################################################
2
+ ### P A C K A G I N G T A S K S
3
+ #####################################################################
4
+
5
+ require 'rbconfig'
6
+ require 'pathname'
7
+ require 'rake/packagetask'
8
+ require 'rake/gempackagetask'
9
+
10
+
11
+ include Config
12
+
13
+ ### Task: gem
14
+ ### Task: package
15
+ Rake::PackageTask.new( PKG_NAME, PKG_VERSION ) do |task|
16
+ task.need_tar_gz = true
17
+ task.need_tar_bz2 = true
18
+ task.need_zip = true
19
+ task.package_dir = PKGDIR.to_s
20
+ task.package_files = RELEASE_FILES.collect {|f| f.to_s }
21
+ end
22
+ task :package => [:gem]
23
+
24
+
25
+ ### Task: gem
26
+ # gempath = PKGDIR + GEM_FILE_NAME
27
+ #
28
+ # desc "Build a RubyGem package (#{GEM_FILE_NAME})"
29
+ # task :gem => gempath.to_s
30
+ # file gempath.to_s => [PKGDIR.to_s] + GEMSPEC.files do
31
+ # when_writing( "Creating GEM" ) do
32
+ # Gem::Builder.new( GEMSPEC ).build
33
+ # verbose( true ) do
34
+ # mv GEM_FILE_NAME, gempath
35
+ # end
36
+ # end
37
+ # end
38
+ #
39
+
40
+ ### Task: install
41
+ desc "Install #{PKG_NAME} as a conventional library"
42
+ task :install => "spec:quiet" do
43
+ log "Installing #{PKG_NAME} as a conventional library"
44
+ sitelib = Pathname.new( CONFIG['sitelibdir'] )
45
+ sitearch = Pathname.new( CONFIG['sitearchdir'] )
46
+ Dir.chdir( LIBDIR ) do
47
+ LIB_FILES.collect {|path| Pathname(path) }.each do |libfile|
48
+ relpath = libfile.relative_path_from( LIBDIR )
49
+ target = sitelib + relpath
50
+ FileUtils.mkpath target.dirname,
51
+ :mode => 0755, :verbose => true, :noop => $dryrun unless target.dirname.directory?
52
+ FileUtils.install relpath, target,
53
+ :mode => 0644, :verbose => true, :noop => $dryrun
54
+ end
55
+ end
56
+ if EXTDIR.exist?
57
+ trace " looking for a binary extension (%s)" % [ EXTDIR + "*.#{Config::CONFIG['DLEXT']}" ]
58
+ Dir.chdir( EXTDIR ) do
59
+ Pathname.glob( "*.#{Config::CONFIG['DLEXT']}" ) do |dl|
60
+ trace " found: #{dl}"
61
+ target = sitearch + dl.basename
62
+ FileUtils.install dl, target,
63
+ :mode => 0755, :verbose => true, :noop => $dryrun
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+
70
+
71
+ ### Task: install_gem
72
+ desc "Install #{PKG_NAME} from a locally-built gem"
73
+ task :install_gem => [:package] do
74
+ $stderr.puts
75
+ installer = Gem::Installer.new( %{pkg/#{PKG_FILE_NAME}.gem} )
76
+ installer.install
77
+ end
78
+
79
+
80
+ ### Task: uninstall
81
+ desc "Uninstall #{PKG_NAME} if it's been installed as a conventional library"
82
+ task :uninstall do
83
+ log "Uninstalling conventionally-installed #{PKG_NAME} library files"
84
+ sitelib = Pathname.new( CONFIG['sitelibdir'] )
85
+ sitearch = Pathname.new( CONFIG['sitearchdir'] )
86
+
87
+ Dir.chdir( LIBDIR ) do
88
+ LIB_FILES.collect {|path| Pathname(path) }.each do |libfile|
89
+ relpath = libfile.relative_path_from( LIBDIR )
90
+ target = sitelib + relpath
91
+ FileUtils.rm_f target, :verbose => true, :noop => $dryrun
92
+ FileUtils.rm_rf( target.dirname, :verbose => true, :noop => $dryrun ) if
93
+ target.dirname.entries.empty?
94
+ end
95
+ end
96
+ if EXTDIR.exist?
97
+ trace " looking for a binary extension (%s)" % [ EXTDIR + "*.#{Config::CONFIG['DLEXT']}" ]
98
+ Dir.chdir( EXTDIR ) do
99
+ Pathname.glob( "*.#{Config::CONFIG['DLEXT']}" ) do |dl|
100
+ trace " found: #{dl}"
101
+ target = sitearch + dl.basename
102
+ FileUtils.rm target, :verbose => true, :noop => $dryrun
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+
109
+ ### Task: uninstall_gem
110
+ desc "Install the #{PKG_NAME} gem"
111
+ task :uninstall_gem => [:clean] do
112
+ uninstaller = Gem::Uninstaller.new( PKG_FILE_NAME )
113
+ uninstaller.uninstall
114
+ end
115
+
116
+
117
+
118
+ desc "Add development depdendencies to the gemspec -- this is meant to be chained " +
119
+ "together with :gem"
120
+ task :include_dev_dependencies do
121
+ DEVELOPMENT_DEPENDENCIES.each do |name, version|
122
+ version = '>= 0' if version.length.zero?
123
+ GEMSPEC.add_development_dependency( name, version )
124
+ end
125
+ end
126
+
@@ -0,0 +1,269 @@
1
+ #####################################################################
2
+ ### P U B L I C A T I O N T A S K S
3
+ #####################################################################
4
+
5
+ RELEASE_NOTES_FILE = 'release.notes'
6
+ RELEASE_ANNOUNCE_FILE = 'release.ann'
7
+
8
+ require 'net/smtp'
9
+ require 'net/protocol'
10
+ require 'openssl'
11
+
12
+ $publish_privately = false
13
+
14
+ ### Add SSL to Net::SMTP
15
+ class Net::SMTP
16
+ def ssl_start( helo='localhost.localdomain', user=nil, secret=nil, authtype=nil )
17
+ if block_given?
18
+ begin
19
+ do_ssl_start( helo, user, secret, authtype )
20
+ return yield( self )
21
+ ensure
22
+ do_finish
23
+ end
24
+ else
25
+ do_ssl_start( helo, user, secret, authtype )
26
+ return self
27
+ end
28
+ end
29
+
30
+
31
+ #######
32
+ private
33
+ #######
34
+
35
+ def do_ssl_start( helodomain, user, secret, authtype )
36
+ raise IOError, 'SMTP session already started' if @started
37
+ check_auth_args( user, secret, 'plain' ) if user or secret
38
+
39
+ # Open the connection
40
+ @debug_output << "opening connection to #{@address}...\n" if @debug_output
41
+ sock = timeout( @open_timeout ) { TCPsocket.new(@address, @port) }
42
+
43
+ # Wrap it in the SSL layer
44
+ ssl_context = OpenSSL::SSL::SSLContext.new
45
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
46
+ ssl_sock = OpenSSL::SSL::SSLSocket.new( sock, ssl_context )
47
+ ssl_sock.sync_close = true
48
+ ssl_sock.connect
49
+
50
+ # Wrap it in the message-oriented IO layer
51
+ sslmsgio = Net::InternetMessageIO.new( ssl_sock )
52
+ sslmsgio.read_timeout = @read_timeout
53
+ sslmsgio.debug_output = @debug_output
54
+
55
+ @socket = sslmsgio
56
+
57
+ check_response(critical { recv_response() })
58
+ begin
59
+ if @esmtp
60
+ ehlo helodomain
61
+ else
62
+ helo helodomain
63
+ end
64
+ rescue ProtocolError
65
+ if @esmtp
66
+ @esmtp = false
67
+ @error_occured = false
68
+ retry
69
+ end
70
+ raise
71
+ end
72
+ authenticate user, secret, authtype if user
73
+ @started = true
74
+ ensure
75
+ @socket.close if not @started and @socket and not @socket.closed?
76
+ end
77
+ end
78
+
79
+
80
+ begin
81
+ gem 'text-format'
82
+
83
+ require 'time'
84
+ require 'rake/tasklib'
85
+ require 'tmail'
86
+ require 'net/smtp'
87
+ require 'etc'
88
+ require 'socket'
89
+ require 'text/format'
90
+
91
+ ### Generate a valid RFC822 message-id
92
+ def gen_message_id
93
+ return "<%s.%s@%s>" % [
94
+ (Time.now.to_f * 10000).to_i.to_s( 36 ),
95
+ (rand( 2 ** 64 - 1 )).to_s( 36 ),
96
+ Socket.gethostname
97
+ ]
98
+ end
99
+
100
+
101
+ namespace :release do
102
+ task :default => [ :prep_release, :upload, :publish, :announce ]
103
+
104
+ desc "Re-publish the release with the current version number"
105
+ task :rerelease => [ :upload, :publish, :announce ]
106
+
107
+ desc "Re-run the publication tasks, but send notifications to debugging address"
108
+ task :test do
109
+ trace "Will publish privately"
110
+ $publish_privately = true
111
+ Rake::Task['release:rerelease'].invoke
112
+ end
113
+
114
+
115
+ desc "Generate the release notes"
116
+ task :notes => [RELEASE_NOTES_FILE]
117
+ file RELEASE_NOTES_FILE do |task|
118
+ last_tag = MercurialHelpers.get_tags.grep( /\d+\.\d+\.\d+/ ).
119
+ collect {|ver| vvec(ver) }.sort.last.unpack( 'N*' ).join('.')
120
+
121
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
122
+ fh.puts "Release Notes for #{PKG_VERSION}",
123
+ "--------------------------------", '', ''
124
+ end
125
+
126
+ edit task.name
127
+ end
128
+ CLOBBER.include( RELEASE_NOTES_FILE )
129
+
130
+
131
+ desc "Upload project documentation and packages to #{PROJECT_HOST}"
132
+ task :upload => [ :upload_docs, :upload_packages ]
133
+ task :project => :upload # the old name
134
+
135
+ desc "Publish the project docs to #{PROJECT_HOST}"
136
+ task :upload_docs => [ :rdoc ] do
137
+ when_writing( "Publishing docs to #{PROJECT_SCPDOCURL}" ) do
138
+ log "Uploading API documentation to %s:%s" % [ PROJECT_HOST, PROJECT_DOCDIR ]
139
+ run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
140
+ run 'scp', '-qCr', RDOCDIR, PROJECT_SCPDOCURL
141
+ end
142
+ end
143
+
144
+ desc "Publish the project packages to #{PROJECT_HOST}"
145
+ task :upload_packages => [ :package ] do
146
+ when_writing( "Uploading packages") do
147
+ pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
148
+ log "Uploading %d packages to #{PROJECT_SCPPUBURL}" % [ pkgs.length ]
149
+ pkgs.each do |pkgfile|
150
+ run 'scp', '-qC', pkgfile, PROJECT_SCPPUBURL
151
+ end
152
+ end
153
+ end
154
+
155
+
156
+ file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
157
+ relnotes = File.read( RELEASE_NOTES_FILE )
158
+ announce_body = %{
159
+
160
+ Version #{PKG_VERSION} of #{PKG_NAME} has been released.
161
+
162
+ #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
163
+
164
+ == Project Page
165
+
166
+ #{GEMSPEC.homepage}
167
+
168
+ == Installation
169
+
170
+ Via gems:
171
+
172
+ $ sudo gem install #{GEMSPEC.name}
173
+
174
+ or from source:
175
+
176
+ $ wget http://deveiate.org/code/#{PKG_FILE_NAME}.tar.gz
177
+ $ tar -xzvf #{PKG_FILE_NAME}.tar.gz
178
+ $ cd #{PKG_FILE_NAME}
179
+ $ sudo rake install
180
+
181
+ == Changes
182
+ #{relnotes}
183
+ }.gsub( /^\t+/, '' )
184
+
185
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
186
+ fh.print( announce_body )
187
+ end
188
+
189
+ edit task.name
190
+ end
191
+ CLOBBER.include( RELEASE_ANNOUNCE_FILE )
192
+
193
+
194
+ desc 'Send out a release announcement'
195
+ task :announce => [RELEASE_ANNOUNCE_FILE] do
196
+ email = TMail::Mail.new
197
+
198
+ if $publish_privately || RELEASE_ANNOUNCE_ADDRESSES.empty?
199
+ trace "Sending private announce mail"
200
+ email.to = 'rubymage@gmail.com'
201
+ else
202
+ trace "Sending public announce mail"
203
+ email.to = RELEASE_ANNOUNCE_ADDRESSES
204
+ email.bcc = 'rubymage@gmail.com'
205
+ end
206
+
207
+ email.from = GEMSPEC.email
208
+ email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
209
+ email.body = File.read( RELEASE_ANNOUNCE_FILE )
210
+ email.date = Time.new
211
+
212
+ email.message_id = gen_message_id()
213
+
214
+ log "About to send the following email:"
215
+ puts '---',
216
+ email.to_s,
217
+ '---'
218
+
219
+ ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
220
+ pwent = Etc.getpwuid( Process.euid )
221
+ curuser = pwent ? pwent.name : 'unknown'
222
+ username = prompt_with_default( "SMTP user", curuser )
223
+ password = prompt_for_password()
224
+
225
+ trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
226
+ smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
227
+ smtp.set_debug_output( $stdout )
228
+ smtp.esmtp = true
229
+
230
+ trace "connecting..."
231
+ smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
232
+ trace "sending message..."
233
+ smtp.send_message( email.to_s, email.from, email.to )
234
+ end
235
+ trace "done."
236
+ end
237
+ end
238
+
239
+
240
+ desc 'Publish the new release to Gemcutter'
241
+ task :publish => [:clean, :gem, :notes] do |task|
242
+ ask_for_confirmation( "Publish #{GEM_FILE_NAME} to Gemcutter?", false ) do
243
+ gempath = PKGDIR + GEM_FILE_NAME
244
+ sh 'gem', 'push', gempath
245
+ end
246
+ end
247
+ end
248
+
249
+ rescue LoadError => err
250
+ if !Object.const_defined?( :Gem )
251
+ require 'rubygems'
252
+ retry
253
+ end
254
+
255
+ task :no_release_tasks do
256
+ fail "Release tasks not defined: #{err.message}"
257
+ end
258
+
259
+ task :release => :no_release_tasks
260
+ task "release:announce" => :no_release_tasks
261
+ task "release:publish" => :no_release_tasks
262
+ task "release:notes" => :no_release_tasks
263
+ end
264
+
265
+ desc "Package up a release, publish it, and send out notifications"
266
+ task :release => 'release:default'
267
+ task :rerelease => 'release:rerelease'
268
+ task :testrelease => 'release:test'
269
+
data/rake/rdoc.rb ADDED
@@ -0,0 +1,30 @@
1
+ #
2
+ # RDoc Rake tasks
3
+
4
+ #
5
+
6
+ gem 'rdoc', '>= 2.4.3'
7
+
8
+ require 'rubygems'
9
+ require 'rdoc/rdoc'
10
+ require 'rake/clean'
11
+ require 'rdoc/task'
12
+
13
+ # Append docs/lib to the load path if it exists for a locally-installed Darkfish
14
+ DOCSLIB = DOCSDIR + 'lib'
15
+ $LOAD_PATH.unshift( DOCSLIB.to_s ) if DOCSLIB.exist?
16
+
17
+ # Make relative string paths of all the stuff we need to generate docs for
18
+ DOCFILES = Rake::FileList[ LIB_FILES + EXT_FILES + GEMSPEC.extra_rdoc_files ]
19
+
20
+
21
+ directory RDOCDIR.to_s
22
+ CLOBBER.include( RDOCDIR )
23
+
24
+ desc "Build API documentation in #{RDOCDIR}"
25
+ RDoc::Task.new do |task|
26
+ task.main = "README"
27
+ task.rdoc_files.include( DOCFILES )
28
+ task.rdoc_dir = RDOCDIR.to_s
29
+ task.options = RDOC_OPTIONS
30
+ end
data/rake/style.rb ADDED
@@ -0,0 +1,62 @@
1
+ #
2
+ # Style Fixup Rake Tasks
3
+
4
+ #
5
+ # Authors:
6
+ # * Michael Granger <ged@FaerieMUD.org>
7
+ #
8
+
9
+
10
+ ### Coding style checks and fixes
11
+ namespace :style do
12
+
13
+ BLANK_LINE = /^\s*$/
14
+ GOOD_INDENT = /^(\t\s*)?\S/
15
+
16
+ # A list of the files that have legitimate leading whitespace, etc.
17
+ PROBLEM_FILES = [ SPECDIR + 'config_spec.rb' ]
18
+
19
+ desc "Check source files for inconsistent indent and fix them"
20
+ task :fix_indent do
21
+ files = LIB_FILES + SPEC_FILES
22
+
23
+ badfiles = Hash.new {|h,k| h[k] = [] }
24
+
25
+ trace "Checking files for indentation"
26
+ files.each do |file|
27
+ if PROBLEM_FILES.include?( file )
28
+ trace " skipping problem file #{file}..."
29
+ next
30
+ end
31
+
32
+ trace " #{file}"
33
+ linecount = 0
34
+ file.each_line do |line|
35
+ linecount += 1
36
+
37
+ # Skip blank lines
38
+ next if line =~ BLANK_LINE
39
+
40
+ # If there's a line with incorrect indent, note it and skip to the
41
+ # next file
42
+ if line !~ GOOD_INDENT
43
+ trace " Bad line %d: %p" % [ linecount, line ]
44
+ badfiles[file] << [ linecount, line ]
45
+ end
46
+ end
47
+ end
48
+
49
+ if badfiles.empty?
50
+ log "No indentation problems found."
51
+ else
52
+ log "Found incorrect indent in #{badfiles.length} files:\n "
53
+ badfiles.each do |file, badlines|
54
+ log " #{file}:\n" +
55
+ " " + badlines.collect {|badline| "%5d: %p" % badline }.join( "\n " )
56
+ end
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+