summaryrefslogtreecommitdiff
path: root/ruby/gem/script/txt2html
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731>2009-02-15 09:10:02 +0000
committerfrsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731>2009-02-15 09:10:02 +0000
commit6083300ea949855e1b2cd3cc4e92bf340c4e90e7 (patch)
treee8272be29b5154c1a1b6d41ad47750ed496d7b34 /ruby/gem/script/txt2html
parent01d40bbb765a30d32c24298a2b666152de8a283f (diff)
downloadmsgpack-python-6083300ea949855e1b2cd3cc4e92bf340c4e90e7.tar.gz
ruby binding: simplify gem package skeleton
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@102 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
Diffstat (limited to 'ruby/gem/script/txt2html')
-rwxr-xr-xruby/gem/script/txt2html82
1 files changed, 0 insertions, 82 deletions
diff --git a/ruby/gem/script/txt2html b/ruby/gem/script/txt2html
deleted file mode 100755
index 09c583f..0000000
--- a/ruby/gem/script/txt2html
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env ruby
-
-GEM_NAME = 'msgpack' # what ppl will type to install your gem
-RUBYFORGE_PROJECT = 'msgpack'
-
-require 'rubygems'
-begin
- require 'newgem'
- require 'rubyforge'
-rescue LoadError
- puts "\n\nGenerating the website requires the newgem RubyGem"
- puts "Install: gem install newgem\n\n"
- exit(1)
-end
-require 'redcloth'
-require 'syntax/convertors/html'
-require 'erb'
-require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
-
-version = MessagePack::VERSION::STRING
-download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
-
-def rubyforge_project_id
- RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
-end
-
-class Fixnum
- def ordinal
- # teens
- return 'th' if (10..19).include?(self % 100)
- # others
- case self % 10
- when 1: return 'st'
- when 2: return 'nd'
- when 3: return 'rd'
- else return 'th'
- end
- end
-end
-
-class Time
- def pretty
- return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
- end
-end
-
-def convert_syntax(syntax, source)
- return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
-end
-
-if ARGV.length >= 1
- src, template = ARGV
- template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
-else
- puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
- exit!
-end
-
-template = ERB.new(File.open(template).read)
-
-title = nil
-body = nil
-File.open(src) do |fsrc|
- title_text = fsrc.readline
- body_text_template = fsrc.read
- body_text = ERB.new(body_text_template).result(binding)
- syntax_items = []
- body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
- ident = syntax_items.length
- element, syntax, source = $1, $2, $3
- syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
- "syntax-temp-#{ident}"
- }
- title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
- body = RedCloth.new(body_text).to_html
- body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
-end
-stat = File.stat(src)
-created = stat.ctime
-modified = stat.mtime
-
-$stdout << template.result(binding)