From 5347e2ce2ceab3246ef4cadbf67fc2c6c2f818c8 Mon Sep 17 00:00:00 2001 From: murphy Date: Sun, 11 Apr 2010 23:00:53 +0000 Subject: Converted binary to UNIX format, and some cleanup in the version history. --- Changes.textile | 29 +++--- bin/coderay | 196 +++++++++++++++++++++-------------------- etc/coderay-lib.tmproj | 8 +- test/scanners/coderay_suite.rb | 3 +- 4 files changed, 123 insertions(+), 113 deletions(-) diff --git a/Changes.textile b/Changes.textile index 8d5a78e..6842e10 100644 --- a/Changes.textile +++ b/Changes.textile @@ -1,4 +1,4 @@ -h1=. CodeRay Version Changes +h1=. CodeRay Version History p=. _This files lists all changes in the CodeRay library since the 0.8.4 release._ @@ -8,13 +8,6 @@ h2. Changes in 1.0 * *FIXED* some image links in the documentation * *IMPROVED* Ruby 1.9 support (_._ not in @$LOAD_PATH@) -h3. @coderay@ executable - -* *NEW* automatic TTY detection, uses @Terminal@ encoder. -* *NEW* optional 3rd parameter for the filename. -* *FIXED*: Warn about generated files. -* *FIXED*: Ensure linebreak after the output (was problematic for LoC counter). - h3. @Tokens::AbbreviationForKind@ * *RENAMED* from @ClassOfKind@. The term "token class" is no longer used in CodeRay. Instead, tokens have _kinds_. @@ -54,7 +47,6 @@ h3. @Encoders::TokenKindFilter@ h3. @Scanners::Scanner@ -* *FIXED* Ruby 1.9.2 compatibility problem (see revision 463). * *REMOVED* @String#to_unix@. h3. @Scanners::Debug@ @@ -81,7 +73,6 @@ h3. @Scanners::Diff@ h3. @Scanners::JavaScript@ * *IMPROVED*: Added @NaN@ and @Infinity@ to list of predefined constants. -* *FIXED*: Don't keep state of XML scanner between calls for E4X literals. h3. @Scanners::Java@ @@ -138,6 +129,24 @@ h3. Internal API changes * *FIXED* @Encoders::HTML#token@'s second parameter is no longer optional. +h2. Changes in 0.9.3 + +* *FIXED*: Documentation of Tokens. + ("#218":http://redmine.rubychan.de/issues/218) + +h3. @coderay@ executable + +* *NEW*: automatic TTY detection (uses @Term@ encoder) +* *NEW*: optional 3rd parameter for the filename +* *FIXED*: Converted to UNIX format. +* *FIXED*: Warn about generated files. +* *FIXED*: Ensure line break after the output (especially for LoC counter). + +h3. @Scanners::JavaScript@ + +* *FIXED*: Don't keep state of XML scanner between calls for E4X literals. + + h2. Changes in 0.9.2 * *NEW* Basic tests and a _Rakefile_ are now included in the Gem. [Flameeyes] diff --git a/bin/coderay b/bin/coderay index 24e662a..e895c7e 100644 --- a/bin/coderay +++ b/bin/coderay @@ -1,96 +1,100 @@ -#!/usr/bin/env ruby -# CodeRay Executable -# -# Version: 0.2 -# Author: murphy - -def err msg - $stderr.puts msg -end - -def read - if file = ARGV[2] - File.read file - else - $stdin.read - end -end - -begin - require 'coderay' - - if ARGV.empty? - puts <<-USAGE -CodeRay #{CodeRay::VERSION} (http://coderay.rubychan.de) -Usage: - coderay - [-] < file > output - coderay file [-] -Example: - coderay -ruby -statistic < foo.rb - coderay -ruby < foo.rb # colorized output on terminal - coderay codegen.c # generates codegen.c.html - USAGE - end - - first, second = ARGV - - if first - if first[/-(\w+)/] == first - lang = $1 - input = read - tokens = :scan - elsif first == '-' - lang = $1 - input = read - tokens = :scan - else - file = first - tokens = CodeRay.scan_file file - output_filename, output_ext = file, /#{Regexp.escape(File.extname(file))}$/ - end - else - puts 'No lang/file given.' - exit 1 - end - - if second - if second[/-(\w+)/] == second - format = $1 - else - raise 'invalid format (must be -xxx)' - end - else - if $stdout.tty? - format = :term - else - $stderr.puts 'No format given; setting to default (HTML Page).' - format = :page - end - end - - # TODO: allow streaming - if tokens == :scan - output = CodeRay::Duo[lang => format].highlight input #, :stream => true - else - output = tokens.encode format - end - out = $stdout - if output_filename - output_filename += '.' + CodeRay::Encoders[format]::FILE_EXTENSION - if File.exist? output_filename - err 'File %s already exists.' % output_filename - exit - else - out = File.open output_filename, 'w' - puts "Writing to #{output_filename}..." - end - end - out.puts output - -rescue => boom - err "Error: #{boom.message}\n" - err boom.backtrace - err '-' * 50 - err ARGV - exit 1 -end +#!/usr/bin/env ruby +# CodeRay Executable +# +# Version: 0.2 +# Author: murphy + +def err msg + $stderr.puts msg +end + +def read + if file = ARGV[2] + File.read file + else + $stdin.read + end +end + +begin + require 'coderay' + + if ARGV.empty? + puts <<-USAGE +CodeRay #{CodeRay::VERSION} (http://coderay.rubychan.de) + +Usage: + coderay - [-] < file > output + coderay file [-] + +Examples: + coderay -ruby -statistic < foo.rb + coderay -ruby < foo.rb # colorized output to terminal + coderay -ruby -page foo.rb # HTML page output to terminal + coderay -ruby -page foo.rb > foo.html # HTML page output to file + coderay codegen.c # generates codegen.c.html + USAGE + end + + first, second = ARGV + + if first + if first[/-(\w+)/] == first + lang = $1 + input = read + tokens = :scan + elsif first == '-' + lang = $1 + input = read + tokens = :scan + else + file = first + tokens = CodeRay.scan_file file + output_filename, output_ext = file, /#{Regexp.escape(File.extname(file))}$/ + end + else + puts 'No lang/file given.' + exit 1 + end + + if second + if second[/-(\w+)/] == second + format = $1 + else + raise 'invalid format (must be -xxx)' + end + else + if $stdout.tty? + format = :term + else + $stderr.puts 'No format given; setting to default (HTML Page).' + format = :page + end + end + + # TODO: allow streaming + if tokens == :scan + output = CodeRay::Duo[lang => format].highlight input #, :stream => true + else + output = tokens.encode format + end + out = $stdout + if output_filename + output_filename += '.' + CodeRay::Encoders[format]::FILE_EXTENSION + if File.exist? output_filename + err 'File %s already exists.' % output_filename + exit + else + out = File.open output_filename, 'w' + puts "Writing to #{output_filename}..." + end + end + out.puts output + +rescue => boom + err "Error: #{boom.message}\n" + err boom.backtrace + err '-' * 50 + err ARGV + exit 1 +end diff --git a/etc/coderay-lib.tmproj b/etc/coderay-lib.tmproj index db26fe0..db03710 100644 --- a/etc/coderay-lib.tmproj +++ b/etc/coderay-lib.tmproj @@ -26,9 +26,7 @@ filename ../diff lastUsed - 2010-03-31T22:10:55Z - selected - + 2010-04-02T06:59:44Z filename @@ -40,7 +38,7 @@ filename ../Changes.textile lastUsed - 2010-03-31T21:22:49Z + 2010-04-02T06:59:45Z filename @@ -118,7 +116,7 @@ filename ../test/scanners/coderay_suite.rb lastUsed - 2010-03-30T23:48:57Z + 2010-04-11T21:08:06Z filename diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index 9b7da98..aa46f9b 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -416,8 +416,7 @@ module CodeRay end File.open(actual_html, 'w') { |f| f.write highlighted } if okay - debug = $DEBUG - $DEBUG = false + debug, $DEBUG = $DEBUG, false FileUtils.copy(actual_html, name + '.expected.html') $DEBUG = debug end -- cgit v1.2.1