From c175c28e09c2fc3b7f386917fde11d36a9acb378 Mon Sep 17 00:00:00 2001 From: no author Date: Mon, 26 Sep 2005 03:14:10 +0000 Subject: html_output.rb changed for silly old rdoc Rakefile and configs added --- Rakefile | 199 ++++++++++++++++++++++++++++ build | 1 + ftp.yaml | 2 + lib/coderay/encoders/helpers/html_output.rb | 2 +- 4 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 Rakefile create mode 100644 build create mode 100644 ftp.yaml diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..8a653e7 --- /dev/null +++ b/Rakefile @@ -0,0 +1,199 @@ +# excuse me, this is my first Rakefile :( [m] +require 'rake' +require 'rake/rdoctask2' +require 'rake/gempackagetask.rb' + +ROOT = '' +LIB_ROOT = ROOT + 'lib/' + +task :default => :same + +task :doc => [:deldoc, :rdoc] +task :deldoc do + rm_r 'doc' if File.directory? 'doc' +end + +desc 'Generate documentation for CodeRay' +Rake::RDocTask.new :rdoc do |rd| + rd.rdoc_dir = 'doc' + rd.main = ROOT + 'README' + rd.title = "CodeRay Documentation" + rd.options << '--line-numbers' << '--inline-source' << '--tab-width' << '2' + #rd.template = 'coderay' + rd.rdoc_files.add ROOT + 'README' + rd.rdoc_files.add *Dir[LIB_ROOT + '**/*.rb'] +# rd.rdoc_files.include ROOT + 'coderay/scanners/*.rb' +# rd.rdoc_files.include ROOT + 'coderay/scanners/helpers/*.rb' +# rd.rdoc_files.include ROOT + 'coderay/encoders/*.rb' +# rd.rdoc_files.include ROOT + 'coderay/encoders/helpers/*.rb' +# rd.rdoc_files.include ROOT + 'coderay/helpers/*.rb' +end + +desc 'Report code statistics (LOC) from the application' +task :stats => :copy_files do + require 'code_statistics' + CodeStatistics.new( + ["Main", "lib"] + ).to_s +end + +desc 'Test CodeRay' +task :test do + system 'ruby -w ./test/suite.rb' +end + +def gemspec + Gem::Specification.new do |s| + # Basic Information + s.name = s.rubyforge_project = 'coderay' + s.version = '0' + + s.platform = Gem::Platform::RUBY + s.requirements = ['strscan'] + s.date = Time.now.strftime '%Y-%m-%d' + s.has_rdoc = true + s.rdoc_options = '-SNw2', '-mREADME' + s.extra_rdoc_files = %w(./README) + + # Description + s.summary = <<-EOF + CodeRay is a fast syntax highlighter engine for many languages. + EOF + s.description = <<-EOF + CodeRay is a Ruby library for syntax highlighting. + I try to make CodeRay easy to use and intuitive, but at the same time + fully featured, complete, fast and efficient. + + Usage is simple: + require 'coderay' + code = 'some %q(weird (Ruby) can\'t shock) me!' + puts CodeRay.scan(code, :ruby).html + EOF + + # Files + s.require_path = 'lib' + s.autorequire = 'coderay' + + s.files = nil # defined later + + # Credits + s.author = 'murphy' + s.email = 'murphy@cYcnus.de' + s.homepage = 'http://ruby.cycnus.de' + end +end + +gemtask = Rake::GemPackageTask.new(gemspec) do |pkg| + pkg.need_zip = true + pkg.need_tar = true +end + +$: << './lib' +require 'coderay' +$version = CodeRay::Version + +desc 'Create a nightly build gem' +task :next => [:inc_build, :build, :make_gem] + +desc 'Create the gem again' +task :same => [:build, :make_gem] + +BUILD_FILE = 'build' +task :inc_build do + build = File.read(BUILD_FILE).to_i + File.open(BUILD_FILE, 'w') { |f| f.write build.succ } +end +task :build do + $version.sub!(/\d+$/) { |minor| minor.to_i - 1 } + $version << '.' << File.read(BUILD_FILE)[/\d+/] +end + +desc 'Create a release gem' +task :release => [:make_gem] + +task :make_gem => [:copy_files, :make_gemspec, :gem, :copy_gem, :upload_gem] + +desc 'Copy the gem files' +task :copy_files do + rm_r 'pkg' if File.exist? 'pkg' +end + +task :make_gemspec do + candidates = Dir['./**/*.rb'] + +# Dir['./demo/demo_*.rb'] + + Dir['./bin/*'] + +# Dir['./demo/bench/*'] + +# Dir['./test/*'] + + %w( ./README ./LICENSE) + s = gemtask.gem_spec + s.files = candidates #.delete_if { |item| item[/(?:CVS|rdoc)|~$/] } + gemtask.version = s.version = $version +end + +GEMDIR = '\gem_server\gems' +task :copy_gem do + $gemfile = "coderay-#$version.gem" + cp "pkg/#$gemfile", GEMDIR + system 'ruby -S generate_yaml_index.rb -d \gem_server' +end + +def g msg + $stderr.print msg +end +def gn msg = '' + $stderr.puts msg +end +def gd + gn 'done.' +end + +require 'net/ftp' +require 'yaml' +$username = YAML.load_file('ftp.yaml')[:username] +def cYcnus_ftp + Net::FTP.open('cycnus.de') do |ftp| + g 'ftp login, password needed: ' + ftp.login $username, $stdin.gets + gn 'logged in.' + yield ftp + end +end + +task :upload_gem do + gn 'Uploading gem:' + Dir.chdir '\gem_server' do + cYcnus_ftp do |ftp| + uploader = proc do |f| + g 'Uploading %s...' % f + ftp.putbinaryfile f, f + gd + end + ftp.chdir 'public_html/raindark/coderay' + %w(yaml yaml.Z).each &uploader + Dir.chdir 'gems' do + ftp.chdir 'gems' + uploader.call $gemfile + end + end + end + gn 'Gem successfully uploaded.' +end + +task :example do + Dir.chdir 'demo' do + g 'Highlighting self...' + system 'ruby -w highlight_self.rb -o -L' + gd + gn 'Uploading example:' + cYcnus_ftp do |ftp| + ftp.chdir 'public_html/raindark/coderay' + uploader = proc do |l, r| + g 'Uploading %s to %s...' % [l, r] + ftp.putbinaryfile l, r + gd + end + uploader.call 'highlight_self/all_in_one.html', 'example.html' + end + gn 'Example uploaded.' + end +end diff --git a/build b/build new file mode 100644 index 0000000..8e2afd3 --- /dev/null +++ b/build @@ -0,0 +1 @@ +17 \ No newline at end of file diff --git a/ftp.yaml b/ftp.yaml new file mode 100644 index 0000000..384846c --- /dev/null +++ b/ftp.yaml @@ -0,0 +1,2 @@ +--- +:username: f7837661 diff --git a/lib/coderay/encoders/helpers/html_output.rb b/lib/coderay/encoders/helpers/html_output.rb index e2b26e7..aa6a8c9 100644 --- a/lib/coderay/encoders/helpers/html_output.rb +++ b/lib/coderay/encoders/helpers/html_output.rb @@ -54,7 +54,7 @@ module CodeRay wrapper :div, :span, :page def wrapped_in - @wrapped_in || nil + @wrapped_in ||= nil end attr_writer :wrapped_in -- cgit v1.2.1