[BREAKS BUILD] Database schema, Rakefile and contents of config directory are brought inline with 0.14.2 defaults

This commit is contained in:
Alexey Verkhovsky 2005-11-02 05:34:07 +00:00
parent 3703c1e1b3
commit 0b05368359
59 changed files with 156 additions and 9972 deletions

17
config/boot.rb Normal file
View file

@ -0,0 +1,17 @@
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath.to_s
end
RAILS_ROOT = root_path
end
if File.directory?("#{RAILS_ROOT}/vendor/rails")
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
else
require 'rubygems'
require 'initializer'
end
Rails::Initializer.run(:set_load_path)

View file

@ -1,65 +0,0 @@
production:
adapter: sqlite3
dbfile: db/prod.db
development:
adapter: sqlite3
dbfile: db/dev.db
test:
adapter: sqlite3
dbfile: db/test.db
# Sample Sqlite 2 Config
#production:
# adapter: sqlite
# dbfile: db/prod.db
#development:
# adapter: sqlite
# dbfile: db/dev.db
#test:
# adapter: sqlite
# dbfile: db/test.db
# Sample Postgresql Config
#production:
# adapter: postgresql
# host: localhost
# database: instiki_prod
# username: user
# password: pass
#
#development:
# adapter: postgresql
# host: localhost
# database: instiki_dev
# username: user
# password: pass
#
#test:
# adapter: postgresql
# host: localhost
# database: instiki_test
# username: user
# password: pass
# Sample MySQL Config
#production:
# adapter: mysql
# host: localhost
# database: instiki_prod
# username: user
# password: pass
#
#development:
# adapter: mysql
# host: localhost
# database: instiki_dev
# username: user
# password: pass
#
#test:
# adapter: mysql
# host: localhost
# database: instiki_test
# username: user
# password: pass

View file

@ -1,95 +1,34 @@
# Load the Rails framework and configure your application. # Bootstrap the Rails environment, frameworks, and default configuration
# You can include your own configuration at the end of this file. require File.join(File.dirname(__FILE__), 'boot')
#
# Be sure to restart your webserver when you modify this file.
if RUBY_VERSION < '1.8.2' Rails::Initializer.run do |config|
puts 'Instiki requires Ruby 1.8.2+' # Skip frameworks you're not going to use
exit config.frameworks -= [ :action_web_service, :action_mailer ]
# Use the database for sessions instead of the file system
# (create the session table with 'rake create_sessions_table')
config.action_controller.session_store = :active_record_store
# Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application)
# config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
# Make Active Record use UTC-base instead of local time
config.active_record.default_timezone = :utc
# Use Active Record's schema dumper instead of SQL when creating the test database
# (enables use of different database adapters for development and test environments)
config.active_record.schema_format = :ruby
# See Rails::Configuration for more options
end end
# Instiki-specific configuration below
require_dependency 'instiki_errors'
# Enable UTF-8 support # Enable UTF-8 support
$KCODE = 'u' $KCODE = 'u'
require 'jcode' require 'jcode'
# The path to the root directory of your application.
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
# The environment your application is currently running. Don't set
# this here; put it in your webserver's configuration as the RAILS_ENV
# environment variable instead.
#
# See config/environments/*.rb for environment-specific configuration.
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
# Load the Rails framework. Mock classes for testing come first.
ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
# Then model subdirectories.
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
# Followed by the standard includes.
ADDITIONAL_LOAD_PATHS.concat %w(
app
app/models
app/controllers
app/helpers
app/apis
components
config
lib
vendor
vendor/rails/railties
vendor/rails/railties/lib
vendor/rails/actionpack/lib
vendor/rails/activesupport/lib
vendor/rails/activerecord/lib
vendor/rails/actionmailer/lib
vendor/rails/actionwebservice/lib
vendor/RedCloth-3.0.3/lib
vendor/rubyzip-0.5.8/lib
).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
# Prepend to $LOAD_PATH
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
# Require Rails libraries.
require 'rubygems' unless File.directory?("#{RAILS_ROOT}/vendor/rails")
require 'active_support'
require 'active_record'
require 'action_controller'
require 'action_mailer'
require 'action_web_service'
# Environment-specific configuration.
require_dependency "environments/#{RAILS_ENV}"
ActiveRecord::Base.configurations = File.open("#{RAILS_ROOT}/config/database.yml") { |f| YAML::load(f) }
ActiveRecord::Base.establish_connection
# Configure defaults if the included environment did not.
begin
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
RAILS_DEFAULT_LOGGER.level = (RAILS_ENV == 'production' ? Logger::INFO : Logger::DEBUG)
rescue StandardError
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
RAILS_DEFAULT_LOGGER.level = Logger::WARN
RAILS_DEFAULT_LOGGER.warn(
"Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " +
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
)
end
[ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER }
[ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" }
# Set up routes.
ActionController::Routing::Routes.reload
Controllers = Dependencies::LoadingModule.root(
File.join(RAILS_ROOT, 'app', 'controllers'),
File.join(RAILS_ROOT, 'components')
)
require_dependency 'instiki_errors'

View file

@ -1,14 +1,17 @@
# In the development environment your application's code is reloaded on # In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development # every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes. # since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil. # Log error messages when you accidentally call methods on nil.
require 'active_support/whiny_nil' config.whiny_nils = true
# Reload code; show full error reports; disable caching. # Enable the breakpoint server that script/breakpointer connects to
Dependencies.mechanism = :load config.breakpoint_server = true
ActionController::Base.consider_all_requests_local = true
ActionController::Base.perform_caching = false
# The breakpoint server port that script/breakpointer connects to. # Show full error reports and disable caching
BREAKPOINT_SERVER_PORT = 42531 config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

View file

@ -1,3 +1,17 @@
Dependencies.mechanism = :require # The production environment is meant for finished, "live" apps.
ActionController::Base.consider_all_requests_local = false # Code is not reloaded between requests
ActionController::Base.perform_caching = true config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# Disable delivery errors if you bad email addresses should just be ignored
# config.action_mailer.raise_delivery_errors = false

View file

@ -1,4 +1,23 @@
Dependencies.mechanism = :require # The test environment is used exclusively to run your application's
ActionController::Base.consider_all_requests_local = true # test suite. You never need to work with it otherwise. Remember that
ActionController::Base.perform_caching = false # your test database is "scratch space" for the test suite and is wiped
FileYard.restrict_upload_access = false # and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Tell ActionMailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Overwrite the default settings for fixtures in tests. See Fixtures
# for more details about these settings.
# config.transactional_fixtures = true
# config.instantiated_fixtures = false
# config.pre_loaded_fixtures = false

55
db/schema.rb Normal file
View file

@ -0,0 +1,55 @@
# This file is autogenerated. Instead of editing this file, please use the
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
ActiveRecord::Schema.define() do
create_table "pages", :force => true do |t|
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
t.column "web_id", :integer, :null => false
t.column "locked_by", :string, :limit => 60
t.column "name", :string, :limit => 60
t.column "locked_at", :datetime
end
create_table "revisions", :force => true do |t|
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
t.column "revised_at", :datetime, :null => false
t.column "page_id", :integer, :null => false
t.column "content", :text, :null => false
t.column "author", :string, :limit => 60
t.column "ip", :string, :limit => 60
end
create_table "system", :force => true do |t|
t.column "password", :string, :limit => 60
end
create_table "webs", :force => true do |t|
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
t.column "name", :string, :limit => 60, :null => false
t.column "address", :string, :limit => 60, :null => false
t.column "password", :string, :limit => 60
t.column "additional_style", :string
t.column "allow_uploads", :integer, :default => 1
t.column "published", :integer, :default => 0
t.column "count_pages", :integer, :default => 0
t.column "markup", :string, :limit => 50, :default => "textile"
t.column "color", :string, :limit => 6, :default => "008B26"
t.column "max_upload_size", :integer, :default => 100
t.column "safe_mode", :integer, :default => 0
t.column "brackets_only", :integer, :default => 0
end
create_table "wiki_references", :force => true do |t|
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
t.column "page_id", :integer, :null => false
t.column "referenced_name", :string, :limit => 60, :null => false
t.column "link_type", :string, :limit => 1, :null => false
end
end

View file

@ -1,134 +1,10 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake' require 'rake'
require 'rake/testtask' require 'rake/testtask'
require 'rake/rdoctask' require 'rake/rdoctask'
$VERBOSE = nil require 'tasks/rails'
TEST_CHANGES_SINCE = Time.now - 600
desc "Run all the tests on a fresh test database"
task :default => [ :test_units, :test_functional ]
desc 'Require application environment.'
task :environment do
unless defined? RAILS_ROOT
require File.dirname(__FILE__) + '/config/environment'
end
end
desc "Generate API documentation, show coding stats"
task :doc => [ :appdoc, :stats ]
desc "Run the unit tests in test/unit"
Rake::TestTask.new("test_units") { |t|
t.libs << "test"
t.pattern = 'test/unit/**/*_test.rb'
t.verbose = true
}
desc "Run the functional tests in test/functional"
Rake::TestTask.new("test_functional") { |t|
t.libs << "test"
t.pattern = 'test/functional/**/*_test.rb'
t.verbose = true
}
desc "Generate documentation for the application"
Rake::RDocTask.new("appdoc") { |rdoc|
rdoc.rdoc_dir = 'doc/app'
rdoc.title = "Rails Application Documentation"
rdoc.options << '--line-numbers --inline-source'
rdoc.rdoc_files.include('doc/README_FOR_APP')
rdoc.rdoc_files.include('app/**/*.rb')
}
desc "Generate documentation for the Rails framework"
Rake::RDocTask.new("apidoc") { |rdoc|
rdoc.rdoc_dir = 'doc/api'
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
rdoc.title = "Rails Framework Documentation"
rdoc.options << '--line-numbers --inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('CHANGELOG')
rdoc.rdoc_files.include('vendor/rails/railties/CHANGELOG')
rdoc.rdoc_files.include('vendor/rails/railties/MIT-LICENSE')
rdoc.rdoc_files.include('vendor/rails/activerecord/README')
rdoc.rdoc_files.include('vendor/rails/activerecord/CHANGELOG')
rdoc.rdoc_files.include('vendor/rails/activerecord/lib/active_record/**/*.rb')
rdoc.rdoc_files.exclude('vendor/rails/activerecord/lib/active_record/vendor/*')
rdoc.rdoc_files.include('vendor/rails/actionpack/README')
rdoc.rdoc_files.include('vendor/rails/actionpack/CHANGELOG')
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_controller/**/*.rb')
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_view/**/*.rb')
rdoc.rdoc_files.include('vendor/rails/actionmailer/README')
rdoc.rdoc_files.include('vendor/rails/actionmailer/CHANGELOG')
rdoc.rdoc_files.include('vendor/rails/actionmailer/lib/action_mailer/base.rb')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/README')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/CHANGELOG')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service.rb')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/*.rb')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/api/*.rb')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/client/*.rb')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/container/*.rb')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/dispatcher/*.rb')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/protocol/*.rb')
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/support/*.rb')
rdoc.rdoc_files.include('vendor/rails/activesupport/README')
rdoc.rdoc_files.include('vendor/rails/activesupport/CHANGELOG')
rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb')
}
desc "Report code statistics (KLOCs, etc) from the application"
task :stats => [ :environment ] do
require 'code_statistics'
CodeStatistics.new(
["Helpers", "app/helpers"],
["Controllers", "app/controllers"],
["APIs", "app/apis"],
["Components", "components"],
["Functionals", "test/functional"],
["Models", "app/models"],
["Units", "test/unit"]
).to_s
end
desc "Empty the test database"
task :purge_test_database => :environment do
abcs = ActiveRecord::Base.configurations
case abcs["test"]["adapter"]
when "mysql"
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
when "postgresql"
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
`dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
`createdb -T template0 -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
when "sqlite","sqlite3"
File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"])
when "sqlserver"
dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
else
raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
end
end
desc "Clears all *.log files in log/"
task :clear_logs => :environment do
FileList["log/*.log"].each do |log_file|
f = File.open(log_file, "w")
f.close
end
end
desc "Migrate the database according to the migrate scripts in db/migrate (only supported on PG/MySQL). A specific version can be targetted with VERSION=x"
task :migrate => :environment do
ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/db/migrate/', ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
end
task :ft => :test_functional
task :ut => :test_units

View file

@ -1,52 +0,0 @@
require 'rubygems'
spec = Gem::Specification.new do |s|
## Basic Information
s.name = 'RedCloth'
s.version = "3.0.3"
s.platform = Gem::Platform::RUBY
s.summary = <<-TXT
RedCloth is a module for using Textile and Markdown in Ruby. Textile and Markdown are text formats.
A very simple text format. Another stab at making readable text that can be converted to HTML.
TXT
s.description = <<-TXT
No need to use verbose HTML to build your docs, your blogs, your pages. Textile gives you readable text while you're writing and beautiful text for your readers. And if you need to break out into HTML, Textile will allow you to do so.
Textile also handles some subtleties of formatting which will enhance your document's readability:
* Single- and double-quotes around words or phrases are converted to curly quotations, much easier on
the eye. "Observe!"
* Double hyphens are replaced with an em-dash. Observe -- very nice!
* Single hyphens are replaced with en-dashes. Observe - so cute!
* Triplets of periods become an ellipsis. Observe...
* The letter 'x' becomes a dimension sign when used alone. Observe: 2 x 2.
* Conversion of ==(TM)== to (TM), ==(R)== to (R), ==(C)== to (C).
For more on Textile's language, hop over to "A Textile Reference":http://hobix.com/textile/. For more
on Markdown, see "Daring Fireball's page":http://daringfireball.net/projects/markdown/.
TXT
## Include tests, libs, docs
s.files = ['bin/**/*', 'tests/**/*', 'lib/**/*', 'docs/**/*', 'run-tests.rb'].collect do |dirglob|
Dir.glob(dirglob)
end.flatten.delete_if {|item| item.include?("CVS")}
## Load-time details
s.require_path = 'lib'
s.autorequire = 'redcloth'
## Author and project details
s.author = "Why the Lucky Stiff"
s.email = "why@ruby-lang.org"
s.rubyforge_project = "redcloth"
s.homepage = "http://www.whytheluckystiff.net/ruby/redcloth/"
end

View file

@ -1,3 +0,0 @@
#!/usr/local/bin/ruby18
require 'redcloth'
puts RedCloth.new( ARGF.read ).to_html

View file

@ -1,149 +0,0 @@
--- %YAML:1.0
- version: 3.0.3
date: 2005-02-06
changes:
- Stack overflow regexp on code inlines obliterated.
- Citations scaled back.
- Toggle span tags on CAPS with :no_span_tags accessor.
- version: 3.0.2
date: 2005-02-02
changes:
- Stack overflow Regexps replaced.
- All code blocks protected from formatting.
- Hard breaks working.
- Filter HTML now uses detailed cleaner.
- version: 3.0.1
date: 2004-11-15
changes:
- Using `float' rather than `text-align' to align image blocks.
- Shelving more HTML attributes to prevent them from clashing with Textile glyphs.
- Simplifying the block regexp.
- version: 3.0
date: 2004-10-26
changes:
- Broke up the Textile engine into smaller parts, recoded central block parser.
- Added preliminary support for Markdown.
- Added support for custom Textile prefixes.
- RedCloth now generates XHTML fragments.
- Complete HTML documents should now work, RedCloth ignores complex HTML.
- version: 2.0.12
date: 2004-08-09
changes:
- Escaping tighter for <pre> tags that share a single line.
- No more String#htmlesc!. Moved to RedCloth#htmlesc.
- Pruned out the code that was handling multibyte.
- version: 2.0.11
date: 2004-06-01
changes:
- Fixed the new 2.0-style aliased links.
- Lines starting with div opening or closing tags aren't given paragraph tags.
- Escaped some sample markup that was being translated by RDoc.
- Subtle changes to the quick tags to help them interact with surrounding HTML better.
- Ensure angle brackets inside code quick tags get escaped.
- New patch and test by F. Ros to fix <pre> tags with class settings.
- Commented out encode_entities and fix_entities, they do nothing now. Thanks, Denis.
- Scaled back QTAGS a back to avoid mixing up hyphens and dels. Thanks, Denis.
- Work on the references to ensure they are generating at least XHTML 1.0 Transitional.
- version: 2.0.10
date: 2004-05-26
changes:
- Table and list problems. Rewrote the <pre> handling code.. again.
- version: 2.0.9
date: 2004-05-26
changes:
- Improved RDoc. Ri documentation is auto-installed now!
- Links were consuming closing HTML tags. (See latest test in tests/links.yml.)
- Further speed patch from Denis. Good good.
- Patch by F. Ros to fix <pre> tags with class settings.
- version: 2.0.8
date: 2004-05-22
changes:
- First scan of the glyphs() method only scans for pre|notextile|code, the
deeper passes scan for all HTML. Now inlines work around HTML tags!
(What a pain!)
- Moved tables and blocks into glyphs to keep them shielded from the parser
if they are in <pre> tags.
- Patch by Denis Mertz to speed up RedCloth by compiling the various RegExps
only once. Thanks, David!
- version: 2.0.7
date: 2004-04-21
changes:
- New REFERENCE and QUICK-REFERENCE. See http://hobix.com/textile/.
- Lists rewritten to accomplish better line folding.
- Better, greedier links.
- Additional link and list tests.
- version: 2.0.6
date: 2004-04-16
changes:
- Bold and strong tags were mixed up. '*' is now strong. '**' is bold.
They were swapped until now.
- Horizontal alignments were pretty buggy. Combining alignments with
indents was totally broken.
- Fixed table problem. Now glyphs are handled between tables and blocks.
- Nested <pre> and <code> tags are now escaped. Much better handling of
HTML inside <pre> tags. Really: quite nice.
- Patch from Florian Gross to fix an html filtration inconsistency.
- version: 2.0.5
date: 2004-04-14
changes:
- Added safe mode (patch courtesy of Florian Gross).
- Added line folding (suggested by Jim Menard).
- Fixing notextile tags to work multi-line.
- Ambiguity with em-dash and block opener.
- Footnote bug. (Thanks, Jim Menard!)
- version: 2.0.4
date: 2004-04-08
changes:
- Scaled back aggresiveness of the inline matching to aid the em-dash.
- Scaled back footnotes to stay out of array indices.
- version: 2.0.3
date: 2004-04-02
changes:
- Handling of pre, code, notextile was all wrong. Also, got rid of the goofed up
split then collect. Now using gsub! and recursion to handle inlines and glyphs.
- Better acronym support.
- Suppression of Regexp warnings.
- Single- and double-quoted string wierdness. Thanks, Bret Pettichord.
- version: 2.0.2
date: 2004-03-08
changes:
- Fixed broken lists, broken tables.
- code/pre tags now escape properly, glyphs are working, spans are working when surrounded by html tags.
- Fixed classes and ids.
- Restricted notextile tags to a single line.
- version: 2.0.1
date: 2004-02-10
changes:
- Unmatched closing slash on regexps in ruby 1.6.8.
- Fixes to bulleted lists.
- version: 2.0
date: 2004-02-06
changes:
- Complete rewrite of RedCloth, against beta2 from textism.com.
- version: 0.41
date: 2003-06-20
changes:
- Newlines were outputing as escaped.
- version: 0.4
date: 2003-06-20
changes:
- Initial public release.
- Integration of YAML-based PyTextile tests.

View file

@ -1,25 +0,0 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Textile nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View file

@ -1,108 +0,0 @@
p=. !redcloth3-title.png!
<div id="sidebar">
h4. Get RedCloth 3
p(example1). *Stable version:* "2.0.11":http://rubyforge.org/frs/download.php/698/redcloth-2.0.11.tar.gz
p(example1). *Unstable version:* "3.0.2":http://rubyforge.org/frs/download.php/2852/RedCloth-3.0.2.tar.gz
Take a complete tour of Textile at "A Textile Reference":http://hobix.com/textile/.
For fast syntax checking, try the "Quick Reference":http://hobix.com/textile/quick.html.
p(example1). Upgrade with "RubyGems":http://rubygems.rubyforge.org/! Try:
@gem install RedCloth@.
See the "project page":http://rubyforge.org/projects/redcloth/ for bug reporting, old releases and CVS instructions. "Documentation":http://redcloth.rubyforge.org/rdoc/ is also hosted at RubyForge.
h4. RedCloth Links
"Instiki":http://www.instiki.org is the greatest Wiki ever! Uses RedCloth for its markup!
"Hobix":http://hobix.com is a lovely little blogging package which uses RedCloth for blog entries.
<div id="css-buttons">
* "(css-button w3c)%W3C% xhtml 1.0(Valid XHTML 1.0!)":http://validator.w3.org/check?uri=referer
* "(css-button w3c w3c2)%W3C% valid css(Valid CSS!)":http://jigsaw.w3.org/css-validator/check/referer
</div>
</div>
RedCloth is a module for using Textile in Ruby. Textile is a text format. A very simple text format. Another stab at making readable text that can be converted to HTML.
h2. What is Textile?
Textile is a simple markup language.
table{width:400px}.
|_. textile|_. to|_. html|
| <notextile>_a phrase_</notextile> |->|_a phrase_|
| <notextile>*a phrase*</notextile> |->|*a phrase*|
| <notextile>_*a phrase*_</notextile> |->|_*a phrase*_|
| <notextile>"Google":http://google.com</notextile> |->|"Google":http://google.com|
No need to use verbose HTML to build your docs, your blogs, your pages. Textile gives you readable text while you're writing and beautiful text for your readers. And if you need to break out into HTML, Textile will allow you to do so.
Textile also handles some subtleties of formatting which will enhance your document's readability:
* Single- and double-quotes around words or phrases are converted to curly quotations, much easier on
the eye. "Observe!"
* Double hyphens are replaced with an em-dash. Observe -- very nice!
* Single hyphens are replaced with en-dashes. Observe - so cute!
* Triplets of periods become an ellipsis. Observe...
* The letter 'x' becomes a dimension sign when used alone. Observe: 2 x 2.
* Conversion of <notextile>(TM)</notextile> to (TM), <notextile>(R)</notextile> to (R), <notextile>(C)</notextile> to (C).
For more on Textile's language, hop over to "A Textile Reference":http://hobix.com/textile/.
h2. Using RedCloth
The RedCloth class is an extension of Ruby's String class. Use it like you would a String:
<pre>
>> r = RedCloth.new "*strong text* and _emphasized text_"
=> "*strong text* and _emphasized text_"
>> r.gsub!( 'text', 'words' )
=> "*strong words* and _emphasized words_"
</pre>
To generate HTML from your RedCloth object, use the @RedCloth#to_html@ method:
<pre>
>> r.to_html
=> "<p><strong>strong words</strong> and <em>emphasized words</em></p>"
</pre>
h2. Installing RedCloth
To install RedCloth via RubyGems:
<pre>
gem install RedCloth
</pre>
Or "download RedCloth":http://rubyforge.org/frs/download.php/2852/RedCloth-3.0.2.tar.gz and simply run the install.rb like so:
<pre>
ruby install.rb config
ruby install.rb setup
sudo ruby install.rb install
</pre>
h2. Acknowledgements
Textile is (c) 2003 Dean Allen. All rights reserved. You can read more "here":http://www.textism.com/tools/textile/.
RedCloth is also based on PyTextile, which is: Copyright (c) 2003, "Mark Pilgrim":http://diveintomark.org/. All rights reserved. You can read more about PyTextile "here":http://dealmeida.net/projects/textile.

View file

@ -1,216 +0,0 @@
---
- A Textile Reference:
- Textile is a simple text markup. Simple symbols mark words' emphasis. Blocks of text
can be easily tagged as headers, quotes, or lists. A Textile document can then be
converted to HTML(Hypertext Markup Language) for viewing on the web.
- You can try Textile out on the "Textile home page":http://www.textism.com/tools/textile/.
Textile is also available as "RedCloth":http://whytheluckystiff.net/ruby/redcloth/ for
Ruby or "PyTextile":http://dealmeida.net/projects/textile for Python.
- Also refer to the "*Quick Reference*":javascript:quickRedReference(); for this guide.
- h4. Reading the Examples
- In each section below, examples are provided to clearly illustrate. In each example,
the Textile example is followed by the raw HTML it is translated into, followed by how
the HTML appears in the browser.
-
- Textile example
- Converted to HTML
- Browser-view
- Writing in Textile:
- Textile looks for paragraphs in your text. Paragraphs are separated by one blank line.
Every paragraph is translated as an HTML paragraph.
- !!example "A single paragraph.\n\nFollowed by another."
- h4. Using HTML in Textile
- You can certainly use HTML tags inside your Textile documents. HTML will only be escaped
if it's found in a @pre@ or @code@ block.
- !!example "I am <b>very</b> serious.\n\n<pre>\n I am <b>very</b> serious.\n</pre>"
- h4. Line Breaks
- Line breaks are converted to HTML breaks.
- !!example "I spoke.\nAnd none replied."
- Line breaks can be disabled in RedCloth by turning on @fold_lines@.
- h4. Entities
- Single- and double-quotes around words or phrases are converted to curly quotations, much easier on the eye.
- !!example '"Observe!"'
- Double hyphens are replaced with an em-dash.
- !!example Observe -- very nice!
- Single hyphens are replaced with en-dashes.
- !!example Observe - tiny and brief.
- Triplets of periods become an ellipsis.
- !!example Observe...
- The letter 'x' becomes a dimension sign when used alone.
- !!example 'Observe: 2 x 2.'
- Conversion of trademark and copyright symbols.
- !!example 'one(TM), two(R), three(C).'
- Quick Block Modifiers:
- Blocks of text default to being treated as paragraphs. But modifers can be affixed
to the beginning of a block to change its treatment.
- h4. Headers
- To make an entire paragraph into a Header, place "h<em>n</em>." at
its beginning, where _n_ is a number from 1-6.
- !!example h1. Header 1
- !!example h2. Header 2
- !!example h3. Header 3
- h4. Block Quotes
- To make an entire paragraph into a block quotation, place
"bq." before it.
- !!example "An old text\n\nbq. A block quotation.\n\nAny old text"
- h4. Footnotes
- Numeric references within text to footnotes appear between square brackets.
- !!example This is covered elsewhere[1].
- To create the footnote that corresponds to its reference within the text, begin a new paragraph with fn and the
footnote's number, followed by a dot and a space.
- !!example fn1. Down here, in fact.
- Quick Phrase Modifiers:
- h4. Structural Emphasis
- Emphasis to text is added by surrounding a phrase with underscores. In HTML, this often
appears as <em>italics</em>.
- !!example I _believe_ every word.
- Strength can be give to text by surrounding with asterisks. In HTML, this strength appears
as <strong>bold</strong>.
- !!example And then? She *fell*!
- Both italics and bold can be forced by doubling the underscores or asterisks.
- !!example "I __know__.\nI **really** __know__."
- Use double question marks to indicate _citation_. The title of a book, for instance.
- !!example "??Cat's Cradle?? by Vonnegut"
- Code phrases can be surrounded by at-symbols.
- !!example "Convert with @r.to_html@"
- To indicate a passage which has been deleted, surround the passage with hypens.
- !!example "I'm -sure- not sure."
- Pluses around a passage indicate its insertion.
- !!example "You are a +pleasant+ child."
- To superscript a phrase, surround with carets.
- !!example "a ^2^ + b ^2^ = c ^2^"
- To subscript, surround with tildes.
- !!example "log ~2~ x"
- h4. HTML-Specific
- Lastly, if you find yourself needing to customize the style of a passage, use percent symbols
to translate the passage as an HTML span.
- !!example I'm %unaware% of most soft drinks.
- This way, you can apply style settings, as described in the next section to arbitrary phrases.
- !!example "I'm %{color:red}unaware%\nof most soft drinks."
- Attributes:
- Tailoring Textile to suit your needs is quite easy. Attributes allow you to provide CSS(Cascading
Style Sheets) information about any phrase.
- h4. Block Attributes
- A block can be tagged with a CSS class by circling the class in parentheses and
placing it just before the period which marks the block.
- !!example p(example1). An example
- An element ID can be given by prefixing the ID with a pound symbol and using it in place of
the class.
- !!example p(#big-red). Red here
- Class and ID can be combined by placing the class first.
- !!example p(example1#big-red2). Red here
- Style settings can be provided directly by surrounding them in curly braces.
- !!example p{color:blue;margin:30px}. Spacey blue
- Language designations can be given between angel brackets.
- !!example p[fr]. rouge
- h4. Phrase Attributes
- All block attributes can be applied to phrases as well by placing them just inside the
opening modifier.
- !!example "I seriously *{color:red}blushed*\nwhen I _(big)sprouted_ that\ncorn stalk from my\n%[es]cabeza%."
- h4. Block Alignments
- Text inside blocks can be aligned in four basic ways.
- !!example p<. align left
- !!example p>. align right
- !!example p=. centered
- !!example p<>. justified
- Indentation can also be specified by provide a single left paren for every 1em to the left. A single right
paren for every 1em to the right.
- !!example p(. left ident 1em
- !!example p((. left ident 2em
- !!example p))). right ident 3em
- h4. Combining Alignments
- Identation may be coupled with alignment.
- !!example "h2()>. Bingo."
- And, furthermore, coupled with language settings and CSS styles.
- !!example "h3()>[no]{color:red}. Bingo"
- h4. HTML in Textile
- Textile is designed for quickening the simple markups. For more complex formatting, you are encouraged
to break out into HTML.
- For example, long code blocks belong between @pre@ and @code@ tags. Please also indent your code inside
the tags to be sure that all Textile processors out there will ignore the contents.
- !!example |
<pre>
<code>
a.gsub!( /</, '' )
</code>
</pre>
- You may also choose to surround sections with @div@ tags to separate your document into sections.
"Instiki":http://www.instiki.org/ uses this technique to float a sidebar to the right.
- !!example |
<div style="float:right;">
h3. Sidebar
"Hobix":http://hobix.com/
"Ruby":http://ruby-lang.org/
</div>
The main text of the
page goes here and will
stay to the left of the
sidebar.
- Lists:
- h4. Numeric Lists
- To make a numbered list, place each item in its own paragraph, preceded by "#".
- !!example "# A first item\n# A second item\n# A third"
- These lists may be nested by increasing the number of pound symbols preceding child entries.
- !!example "# Fuel could be:\n## Coal\n## Gasoline\n## Electricity\n# Humans need only:\n## Water\n## Protein"
- h4. Bulleted Lists
- Bulleted lists use an asterisk in place of the pound.
- !!example "* A first item\n* A second item\n* A third"
- These lists may be nested in like manner.
- !!example "* Fuel could be:\n** Coal\n** Gasoline\n** Electricity\n* Humans need only:\n** Water\n** Protein"
- External References:
- h4. Hypertext Links
- Basic links are comprised of a phrase which is linked to a URL(Universal Resource Locator). Place the
descriptive phrase in quotation marks. Follow it immediately by a colon and the URL.
- !!example I searched "Google":http://google.com.
- Notice, the link won't include any trailing punctuation.
- h4. Link Aliases
- If you are using the same link several times in your document, or you'd just like to be a tad more
organized, you can use a link alias. Place the URL anywhere in your document, beginning with its
alias in square brackets. Then, use the alias in place of the URL, using the link format above.
- !!example |
I am crazy about "Hobix":hobix
and "it's":hobix "all":hobix I ever
"link to":hobix!
[hobix]http://hobix.com
- h4. Embedded Images
- You can embed an image in your Textile document by surrounding its URL with exclamation marks.
- !!example "!http://hobix.com/sample.jpg!"
- URLs may be relative.
- A title for the image can also be provided in parens, just before the closing exclamation.
- !!example "!openwindow1.gif(Bunny.)!"
- The title also acts as *alt* text should the image not be found.
- Links can be attached to images with a colon.
- !!example "!openwindow1.gif!:http://hobix.com/"
- h4. Image Alignments
- Alignments can be applied as well to images.
- !!example "!>obake.gif!\n\nAnd others sat all round the small\nmachine and paid it to sing to them."
- h4. Acronyms
- Definitions for acronyms can be provided by following an acronym with its definition in parens.
- !!example We use CSS(Cascading Style Sheets).
- Tables:
- Simple tables can be built by separating fields with pipe characters
- !!example "| name | age | sex |\n| joan | 24 | f |\n| archie | 29 | m |\n| bella | 45 | f |"
- Specify header cells by marking them with an underscore and period.
- !!example "|_. name |_. age |_. sex |\n| joan | 24 | f |\n| archie | 29 | m |\n| bella | 45 | f |"
- h4. Cell Attributes
- The period used above marks the end of a cell's attributes. Other attributes can be applied as well.
- !!example "|_. attribute list |\n|<. align left |\n|>. align right|\n|=. center |\n|<>. justify |\n|^. valign top |\n|~. bottom |"
- You can also specify colspans with a backslash, followed by the cell width.
- !!example "|\\2. spans two cols |\n| col 1 | col 2 |"
- Rowspan is specified by a forward slash, followed by the row height.
- !!example "|/3. spans 3 rows | a |\n| b |\n| c |"
- All block attributes can be applied to table cells as well.
- !!example "|{background:#ddd}. Grey cell|"
- h4. Table and Row Attributes
- Table-wide attributes can be applied before the first row of the table. On its own line, followed by
a period.
- !!example "table{border:1px solid black}.\n|This|is|a|row|\n|This|is|a|row|"
- Attributes can be applied to a single row by supplying the attribute before the row starts, using a
@table@ modifier and following it by a period.
- !!example "|This|is|a|row|\n{background:#ddd}. |This|is|grey|row|"

View file

@ -1,359 +0,0 @@
$:.unshift '../lib'
require 'yaml'
require 'redcloth'
class String
#
# Flexible HTML escaping
#
def htmlesc!( mode )
gsub!( '&', '&amp;' )
gsub!( '"', '&quot;' ) if mode != :NoQuotes
gsub!( "'", '&#039;' ) if mode == :Quotes
gsub!('<', '&lt;')
gsub!('>', '&gt;')
end
end
def a_name( phrase )
phrase.downcase.
gsub( /\W+/, '-' )
end
file_name = ARGV.shift
case file_name
when 'README'
puts <<-HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RedCloth [Textile Humane Web Text for Ruby]</title>
<style type="text/css">
BODY {
margin: 10px 60px 40px 60px;
font-family: georgia, serif;
font-size: 12pt;
}
TABLE {
padding: 15px;
width: 250px;
}
TH {
text-align: left;
}
TD {
border-top: solid 1px #eee;
}
H4 {
border: solid 1px #caa;
margin: 10px 15px 5px 10px;
padding: 5px;
color: white;
background-color: #333;
font-weight: bold;
font-size: 12pt;
}
P {
margin: 10px 15px 5px 15px;
}
P.example1 {
background-color: #FEE;
font-weight: bold;
font-size: 9pt;
padding: 5px;
}
P.example2 {
border: solid 1px #DDD;
background-color: #EEE;
font-size: 9pt;
padding: 5px;
}
.big {
font-size: 15pt;
}
#big-red {
font-size: 15pt;
color: red;
}
#big-red2 {
font-size: 15pt;
color: red;
}
#sidebar {
float: right;
font-family: verdana, arial, sans-serif;
font-size: 10pt;
border-left: solid 1px #999;
margin-left: 10px;
width: 200px;
}
/* VARIATION BUTTON STYLING (v2.0) - SIZABLE SIZE */
#css-buttons ul{list-style: none;margin: 0 0 10px 0;padding: 0;}
#css-buttons li{border: 1px solid #999; margin: 5px 0 0 20px; width:9.0em;}
head:first-child+body #css-buttons li{padding-right:2px;}
#css-buttons li a{color: #333; text-decoration: none;}
.css-button {
display:block;
font: 0.8em verdana, arial, sans-serif;
padding: 2px 0 2px 0px; border: 1px solid white;
text-decoration: none; width:100%;
background: #ddd;color: #333;
}
.css-button span {
font: bold 1.0em verdana, arial, sans-serif;
padding: 2px 3px 2px 3px; color: #fff;
}
/* BUTTON LOGO STYLING */
.rss span{background:#f60;}
.w3c span {background: #fff; color: #069; font: bold 1.1em helvetica, arial, Sans-Serif;}
.w3c2{background: #fc6;color: black !important;}
</style>
</head>
<body>
HTML
puts RedCloth.new( File.open( file_name ).read ).to_html
puts "</body>"
puts "</html>"
when 'QUICK-REFERENCE'
YAML::add_private_type( "example" ) do |type, val|
esc = val.dup
esc.htmlesc!( :NoQuotes )
[ :example, esc.gsub( /\n/, '<br />' ),
RedCloth.new( val ).to_html ]
end
content = YAML::load( File.open( 'REFERENCE' ) )
sections = content.collect { |c| c.keys.first }
sections.shift
puts <<-HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Textile Quick Reference</title>
<style type="text/css">
BODY {
margin: 5px;
}
TABLE {
font-family: georgia, serif;
font-size: 10pt;
padding: 5px;
width: 200px;
}
TH {
padding-top: 10px;
}
TD {
border-top: solid 1px #eee;
}
H1 {
font-size: 18pt;
}
H4 {
color: #999;
background-color: #fee;
border: solid 1px #caa;
margin: 10px 15px 5px 10px;
padding: 5px;
}
P {
margin: 2px 5px 2px 5px;
}
TD.example1 PRE {
background-color: #FEE;
font-family: georgia, serif;
font-size: 8pt;
padding: 5px;
padding: 5px;
}
TD.example3 {
border: solid 1px #DDD;
background-color: #EEE;
font-size: 8pt;
padding: 5px;
}
.big {
font-size: 12pt;
}
#big-red {
font-size: 12pt;
color: red;
}
#big-red2 {
font-size: 15pt;
color: red;
}
</style>
</head>
<body>
<table>
<tr><th colspan='3'><h1>Textile Quick Reference</h1></th></tr>
<tr><th colspan='3'>Sections: #{ sections.collect { |s| "<a href='##{ a_name( s ) }'>#{ s.gsub( /\s/, '&nbsp;' ) }</a>" }.join( ' | ' ) }</th></tr>
HTML
ct = 0
content.each do |section|
section.each do |header, parags|
puts "<tr><th colspan='5'><a name='#{ a_name( header ) }'>#{ header }</a></th></tr>" if ct.nonzero?
parags.each do |p|
if p.is_a?( Array ) and p[0] == :example
puts "<tr><td class='example1'><pre>#{ p[1] }</pre></td><td>&rarr;</td>" +
"<td class='example2'>#{ p[2] }</td></tr>"
end
end
end
ct += 1
end
puts "</table>"
puts "</body>"
puts "</html>"
when 'REFERENCE'
YAML::add_private_type( "example" ) do |type, val|
esc = val.dup
esc.htmlesc!( :NoQuotes )
[ esc.gsub( /\n/, '<br />' ),
RedCloth.new( val ).to_html.
gsub( /;(\w)/, '; \1' ).
htmlesc!( :NoQuotes ).
gsub( /\n/, '<br />' ),
RedCloth.new( val ).to_html ]
end
content = YAML::load( File.open( file_name ) )
sections = content.collect { |c| c.keys.first }
sections.shift
puts <<-HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Textile Reference</title>
<style type="text/css">
BODY {
margin: 10px 30px;
}
TABLE {
font-family: georgia, serif;
font-size: 11pt;
padding: 15px;
}
TH {
border-bottom: solid 1px black;
font-size: 24pt;
font-weight: bold;
padding-top: 30px;
}
H1 {
font-size: 42pt;
}
H4 {
color: #666;
background-color: #fee;
border: solid 1px #caa;
margin: 10px 0px 5px 0px;
padding: 5px;
}
P {
margin: 10px 15px 5px 15px;
}
TD.sections {
background: black;
color: white;
font-family: georgia, serif;
font-weight: bold;
font-size: 9pt;
padding: 5px;
}
TD.sections A { color: #CCEEFF; }
TD.sections A:link { color: #CCEEFF; }
TD.sections A:visited { color: #CCEEFF; }
TD.sections A:active { color: #EEEEEE; }
TD.sections A:hover { color: #EEEEEE; }
TD.example1 PRE {
background-color: #B30;
color: white;
font-family: georgia, serif;
font-weight: bold;
font-size: 9pt;
padding: 5px;
}
TD.example2 P {
border: solid 1px #DDD;
background-color: #EEE;
font-family: georgia, serif;
font-size: 9pt;
padding: 5px;
}
TD.example3 {
border: solid 1px #EED;
background-color: #FFE;
padding: 5px;
}
.big {
font-size: 15pt;
}
#big-red {
font-size: 15pt;
color: red
}
</style>
<script type="text/javascript">
function quickRedReference() {
window.open(
"quick.html",
"redRef",
"height=600,width=550,channelmode=0,dependent=0," +
"directories=0,fullscreen=0,location=0,menubar=0," +
"resizable=0,scrollbars=1,status=1,toolbar=0"
);
}
</script>
</head>
<body>
<table>
HTML
ct = 0
content.each do |section|
section.each do |header, parags|
if ct.zero?
puts "<tr><th colspan='3'><h1>#{ header }</h1></th></tr>"
puts "<tr><td class='sections' colspan='3'>Sections: #{ sections.collect { |s| "<a href='##{ a_name( s ) }'>#{ s.gsub( /\s/, '&nbsp;' ) }</a>" }.join( ' | ' ) }</td></tr>"
else
puts "<tr><th colspan='3'><a name='#{ a_name( header ) }'><small>#{ ct }.</small></a><br />#{ header }</th></tr>"
end
parags.each do |p|
if p.is_a? Array
puts "<tr><td class='example1' valign='top'><pre>#{ p[0] }</pre></td><td>&rarr;</td>" +
"<td class='example2'><p>#{ p[1] }</p></td></tr><tr><td colspan='2'></td>" +
"<td class='example3'>#{ p[2] }</td></tr>"
else
puts "<tr><td class='explain' colspan='3'>"
puts RedCloth.new( p ).to_html
puts "</td></tr>"
end
end
unless ct.zero?
puts "<tr><td colspan='5' style='border-bottom: solid 1px #eee;'></td></tr>"
end
end
ct += 1
end
puts "</table>"
puts "</body>"
puts "</html>"
end

File diff suppressed because it is too large Load diff

View file

@ -1,26 +0,0 @@
#!/usr/bin/env ruby
require 'lib/redcloth'
require 'yaml'
Dir["tests/*.yml"].each do |testfile|
YAML::load_documents( File.open( testfile ) ) do |doc|
if doc['in'] and doc['out']
red = RedCloth.new( doc['in'] )
html = if testfile =~ /markdown/
red.to_html( :markdown )
else
red.to_html
end
puts "---"
html.gsub!( /\n+/, "\n" )
doc['out'].gsub!( /\n+/, "\n" )
if html == doc['out']
puts "success: true"
else
puts "out: "; p html
puts "expected: "; p doc['out']
end
end
end
end

View file

@ -1,105 +0,0 @@
---
in: 'This is an empty dictionary: @{}@'
out: '<p>This is an empty dictionary: <code>{}</code></p>'
---
in: |-
Testing nested pre tags...
<pre>
<code>
Good code here.
<pre>
a = 1
</pre>
Bad code here.
<script language="JavaScript">
window.open( "about:blank" );
</script>
</code>
</pre>
out: |-
<p>Testing nested pre tags&#8230;</p>
<pre>
<code>
Good code here.
&lt;pre&gt;
a = 1
&lt;/pre&gt;
Bad code here.
&lt;script language="JavaScript"&gt;
window.open( "about:blank" );
&lt;/script&gt;
</code>
</pre>
---
in: |-
<pre>
*** test
</pre>
out: |-
<pre>
*** test
</pre>
---
in: |-
<notextile>
*** test
</notextile>
out: |-
*** test
---
in: '*this <span></span> is strong*'
out: '<p><strong>this <span></span> is strong</strong></p>'
---
in: '*this <span>test</span> is strong*'
out: '<p><strong>this <span>test</span> is strong</strong></p>'
---
in: <pre class="code"> __inline__</pre>
out: <pre class="code"> __inline__</pre>
---
in: |-
* @foo@
* @bar@
* and @x@ is also.
out: "<ul>\n\t<li><code>foo</code></li>\n\t\t<li><code>bar</code></li>\n\t\t<li>and <code>x</code> is also.</li>\n\t</ul>"
---
in: |-
<pre class="code"> <hello> </pre>
<pre class="code"> <hello> </pre>
out: |-
<pre class="code"> &lt;hello&gt; </pre>
<pre class="code"> &lt;hello&gt; </pre>
---
in: |
Test of Markdown-style indented code.
a = [1, 2, 3]
a.each do |x|
puts "test number", x,
"and more!"
end
Paragraph 2.
Paragraph 3.
out: |-
<p>Test of Markdown-style indented code.</p>
<pre><code>a = [1, 2, 3]
a.each do |x|
puts "test number", x,
"and more!"
end</code></pre>
<p>Paragraph 2.</p>
<p>Paragraph 3.</p>

View file

@ -1,171 +0,0 @@
---
in: This is an !image.jpg!
out: <p>This is an <img src="image.jpg" alt="" /></p>
---
in: This is an !image.jpg(with alt text)!
out: <p>This is an <img src="image.jpg" title="with alt text" alt="with alt text" /></p>
---
in: This is an !http://example.com/i/image.jpg!
out: <p>This is an <img src="http://example.com/i/image.jpg" alt="" /></p>
---
in: This is an !http://example.com/i/image.jpg#a1!
out: <p>This is an <img src="http://example.com/i/image.jpg#a1" alt="" /></p>
---
in: This is an !image.jpg!.
out: <p>This is an <img src="image.jpg" alt="" />.</p>
---
in: This is an !image.jpg(with alt text)!.
out: <p>This is an <img src="image.jpg" title="with alt text" alt="with alt text" />.</p>
---
in: This is an !http://example.com/i/image.jpg!.
out: <p>This is an <img src="http://example.com/i/image.jpg" alt="" />.</p>
---
in: This is an !http://example.com/i/image.jpg#a1!.
out: <p>This is an <img src="http://example.com/i/image.jpg#a1" alt="" />.</p>
---
in: This is not an image!!!
out: <p>This is not an image!!!</p>
---
in: This is an !http://example.com/i/image.jpg!:#1
out: <p>This is an <a href="#1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:#a
out: <p>This is an <a href="#a"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:#a1
out: <p>This is an <a href="#a1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:#a10
out: <p>This is an <a href="#a10"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html
out: <p>This is an <a href="index.html"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html#1
out: <p>This is an <a href="index.html#1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html#a1
out: <p>This is an <a href="index.html#a1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html#a10
out: <p>This is an <a href="index.html#a10"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar
out: <p>This is an <a href="index.html?foo=bar"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar#1
out: <p>This is an <a href="index.html?foo=bar#1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar#a
out: <p>This is an <a href="index.html?foo=bar#a"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar#a1
out: <p>This is an <a href="index.html?foo=bar#a1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:index.html?foo=bar#a10
out: <p>This is an <a href="index.html?foo=bar#a10"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/
out: <p>This is an <a href="http://example.com/"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/#1
out: <p>This is an <a href="http://example.com/#1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/#a
out: <p>This is an <a href="http://example.com/#a"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/#a1
out: <p>This is an <a href="http://example.com/#a1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/#a10
out: <p>This is an <a href="http://example.com/#a10"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html
out: <p>This is an <a href="http://example.com/index.html"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html#1
out: <p>This is an <a href="http://example.com/index.html#1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html#a
out: <p>This is an <a href="http://example.com/index.html#a"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html#a1
out: <p>This is an <a href="http://example.com/index.html#a1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html#a10
out: <p>This is an <a href="http://example.com/index.html#a10"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar
out: <p>This is an <a href="http://example.com/index.html?foo=bar"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar#1
out: <p>This is an <a href="http://example.com/index.html?foo=bar#1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar#a
out: <p>This is an <a href="http://example.com/index.html?foo=bar#a"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar#a1
out: <p>This is an <a href="http://example.com/index.html?foo=bar#a1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar#a10
out: <p>This is an <a href="http://example.com/index.html?foo=bar#a10"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#1
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a1
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a1"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a10
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a10"><img src="http://example.com/i/image.jpg" alt="" /></a></p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b"><img src="http://example.com/i/image.jpg" alt="" /></a>.</p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#1.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#1"><img src="http://example.com/i/image.jpg" alt="" /></a>.</p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a"><img src="http://example.com/i/image.jpg" alt="" /></a>.</p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a1.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a1"><img src="http://example.com/i/image.jpg" alt="" /></a>.</p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a10.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a10"><img src="http://example.com/i/image.jpg" alt="" /></a>.</p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b, but this is not.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b"><img src="http://example.com/i/image.jpg" alt="" /></a>, but this is not.</p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#1, but this is not.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#1"><img src="http://example.com/i/image.jpg" alt="" /></a>, but this is not.</p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a, but this is not.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a"><img src="http://example.com/i/image.jpg" alt="" /></a>, but this is not.</p>
---
in: This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a1, but this is not.
out: <p>This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a1"><img src="http://example.com/i/image.jpg" alt="" /></a>, but this is not.</p>
---
in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a10) This is not.
out: <p>(This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a10"><img src="http://example.com/i/image.jpg" alt="" /></a>) This is not.</p>
---
in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b) This is not.
out: <p>(This is an <a href="http://example.com/index.html?foo=bar&#38;a=b"><img src="http://example.com/i/image.jpg" alt="" /></a>) This is not.</p>
---
in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#1) This is not.
out: <p>(This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#1"><img src="http://example.com/i/image.jpg" alt="" /></a>) This is not.</p>
---
in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a) This is not.
out: <p>(This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a"><img src="http://example.com/i/image.jpg" alt="" /></a>) This is not.</p>
---
in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a1) This is not.
out: <p>(This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a1"><img src="http://example.com/i/image.jpg" alt="" /></a>) This is not.</p>
---
in: (This is an !http://example.com/i/image.jpg!:http://example.com/index.html?foo=bar&a=b#a10) This is not.
out: <p>(This is an <a href="http://example.com/index.html?foo=bar&#38;a=b#a10"><img src="http://example.com/i/image.jpg" alt="" /></a>) This is not.</p>

View file

@ -1,39 +0,0 @@
--- # Bugs filed at http://www.instiki.org/show/BugReports
in: |-
_Hi, <span class="newWikiWord">Joe Bob<a href="../show/JoeBob">?</a></span>, this should all be in italic!_
out: |-
<p><em>Hi, <span class="newWikiWord">Joe Bob<a href="../show/JoeBob">?</a></span>, this should all be in italic!</em></p>
---
in: '*this <span>span</span> is strong*'
out: '<p><strong>this <span>span</span> is strong</strong></p>'
---
in: '*this <span>Camel Thing<a href="../show/CamelThing">?</a></span> is strong*'
out: '<p><strong>this <span>Camel Thing<a href="../show/CamelThing">?</a></span> is strong</strong></p>'
---
in: '_this <span>span</span> is italic_'
out: '<p><em>this <span>span</span> is italic</em></p>'
---
in: '%{color:red}nested span because of <span><span class="newWikiWord">Camel Word<a href="../show/CamelWord">?</a></span></span>%'
out: '<p><span style="color:red;">nested span because of <span><span class="newWikiWord">Camel Word<a href="../show/CamelWord">?</a></span></span></span></p>'
---
in: |-
h2. Version History
* "Version
0.0":http://www.threewordslong.com/render-0-8-9b.patch - Early version using MD5 hashes.
* "Version
0.1":http://www.threewordslong.com/chunk-0-1.patch.gz - First cut of new system. Much cleaner.
* "Version 0.2":http://www.threewordslong.com/chunk-0-2.patch.gz - Fixed problem with "authors" page and some tests.
out: |-
<h2>Version History</h2>
<ul>
<li><a href="http://www.threewordslong.com/render-0-8-9b.patch">Version
0.0</a> &#8211; Early version using <span class="caps">MD5</span> hashes.</li>
<li><a href="http://www.threewordslong.com/chunk-0-1.patch.gz">Version
0.1</a> &#8211; First cut of new system. Much cleaner.</li>
<li><a href="http://www.threewordslong.com/chunk-0-2.patch.gz">Version 0.2</a> &#8211; Fixed problem with &#8220;authors&#8221; page and some tests.</li>
</ul>
---
in: "--richSeymour --whyTheLuckyStiff"
out: "<p>&#8212;richSeymour&#8212;whyTheLuckyStiff</p>"

View file

@ -1,155 +0,0 @@
---
in: '"link text":#1'
out: <p><a href="#1">link text</a></p>
---
in: '"link text":#a'
out: <p><a href="#a">link text</a></p>
---
in: '"link text":#a1'
out: <p><a href="#a1">link text</a></p>
---
in: '"link text":#a10'
out: <p><a href="#a10">link text</a></p>
---
in: '"link text":index.html'
out: <p><a href="index.html">link text</a></p>
---
in: '"link text":index.html#1'
out: <p><a href="index.html#1">link text</a></p>
---
in: '"link text":index.html#a'
out: <p><a href="index.html#a">link text</a></p>
---
in: '"link text":index.html#a1'
out: <p><a href="index.html#a1">link text</a></p>
---
in: '"link text":index.html#a10'
out: <p><a href="index.html#a10">link text</a></p>
---
in: '"link text":http://example.com/'
out: <p><a href="http://example.com/">link text</a></p>
---
in: '"link text":http://example.com/#1'
out: <p><a href="http://example.com/#1">link text</a></p>
---
in: '"link text":http://example.com/#a'
out: <p><a href="http://example.com/#a">link text</a></p>
---
in: '"link text":http://example.com/#a1'
out: <p><a href="http://example.com/#a1">link text</a></p>
---
in: '"link text":http://example.com/#a10'
out: <p><a href="http://example.com/#a10">link text</a></p>
---
in: '"link text":http://example.com/index.html'
out: <p><a href="http://example.com/index.html">link text</a></p>
---
in: '"link text":http://example.com/index.html#a'
out: <p><a href="http://example.com/index.html#a">link text</a></p>
---
in: '"link text":http://example.com/index.html#1'
out: <p><a href="http://example.com/index.html#1">link text</a></p>
---
in: '"link text":http://example.com/index.html#a1'
out: <p><a href="http://example.com/index.html#a1">link text</a></p>
---
in: '"link text":http://example.com/index.html#a10'
out: <p><a href="http://example.com/index.html#a10">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar'
out: <p><a href="http://example.com/?foo=bar">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar#a'
out: <p><a href="http://example.com/?foo=bar#a">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar#1'
out: <p><a href="http://example.com/?foo=bar#1">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar#a1'
out: <p><a href="http://example.com/?foo=bar#a1">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar#a10'
out: <p><a href="http://example.com/?foo=bar#a10">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar&a=b'
out: <p><a href="http://example.com/?foo=bar&#38;a=b">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar&a=b#1'
out: <p><a href="http://example.com/?foo=bar&#38;a=b#1">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar&a=b#a'
out: <p><a href="http://example.com/?foo=bar&#38;a=b#a">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar&a=b#a1'
out: <p><a href="http://example.com/?foo=bar&#38;a=b#a1">link text</a></p>
---
in: '"link text":http://example.com/?foo=bar&a=b#a10'
out: <p><a href="http://example.com/?foo=bar&#38;a=b#a10">link text</a></p>
---
in: 'This is a "link":http://example.com/'
out: <p>This is a <a href="http://example.com/">link</a></p>
---
in: 'This is a "link":http://example.com/.'
out: <p>This is a <a href="http://example.com/">link</a>.</p>
---
in: 'This is a "link":http://example.com/index.html.'
out: <p>This is a <a href="http://example.com/index.html">link</a>.</p>
---
in: 'This is a "link":http://example.com/index.html#a.'
out: <p>This is a <a href="http://example.com/index.html#a">link</a>.</p>
---
in: 'This is a "link":http://example.com/index.html#1.'
out: <p>This is a <a href="http://example.com/index.html#1">link</a>.</p>
---
in: 'This is a "link":http://example.com/index.html#a1.'
out: <p>This is a <a href="http://example.com/index.html#a1">link</a>.</p>
---
in: 'This is a "link":http://example.com/index.html#a10.'
out: <p>This is a <a href="http://example.com/index.html#a10">link</a>.</p>
---
in: 'This is a "link":http://example.com/?foo=bar.'
out: <p>This is a <a href="http://example.com/?foo=bar">link</a>.</p>
---
in: 'This is a "link":http://example.com/?foo=bar#1.'
out: <p>This is a <a href="http://example.com/?foo=bar#1">link</a>.</p>
---
in: 'This is a "link":http://example.com/?foo=bar#a.'
out: <p>This is a <a href="http://example.com/?foo=bar#a">link</a>.</p>
---
in: 'This is a "link":http://example.com/?foo=bar#a1.'
out: <p>This is a <a href="http://example.com/?foo=bar#a1">link</a>.</p>
---
in: 'This is a "link":http://example.com/?foo=bar#a10.'
out: <p>This is a <a href="http://example.com/?foo=bar#a10">link</a>.</p>
---
in: 'This is a "link":http://example.com/?foo=bar#a10, but this is not.'
out: <p>This is a <a href="http://example.com/?foo=bar#a10">link</a>, but this is not.</p>
---
in: '(This is a "link":http://example.com/?foo=bar#a10) but this is not.'
out: <p>(This is a <a href="http://example.com/?foo=bar#a10">link</a>) but this is not.</p>
---
in: '"link text(link title)":http://example.com/'
out: <p><a href="http://example.com/" title="link title">link text</a></p>
# ---
# in: '"link text(link title) ":http://example.com/'
# out: <p>&#8220;link text(link title) &#8220;:http://example.com/</p>
# comments: this is a real test and should pass
---
in: '"(link) text(link title)":http://example.com/'
out: <p><a href="http://example.com/" class="link" title="link title"> text</a></p>
comments: link text can not contain parentheses
---
in: '"Dive Into XML":http://www.xml.com/pub/au/164'
out: <p><a href="http://www.xml.com/pub/au/164">Dive Into <span class="caps">XML</span></a></p>
---
in: '"Lab Exercises":../lab/exercises/exercises.html.'
out: <p><a href="../lab/exercises/exercises.html">Lab Exercises</a>.</p>
---
in: 'Go to "discuss":http://www.dreammoods.com/cgibin/cutecast/cutecast.pl?forum=1&thread=26627 to discuss.'
out: <p>Go to <a href="http://www.dreammoods.com/cgibin/cutecast/cutecast.pl?forum=1&#38;thread=26627">discuss</a> to discuss.</p>
---
in: '* "rubylang":http://www.ruby-lang.org/en/'
out: "<ul>\n\t<li><a href=\"http://www.ruby-lang.org/en/\">rubylang</a></li>\n\t</ul>"
---
in: 'The ION coding style document found at "IONCodingStyleGuide.doc":http://perforce:8081/@md=d&cd=//&c=82E@//depot/systest/system/main/pub/doc/IONCodingStyleGuide.doc?ac=22 codifies a couple of rules to ensure reasonably consistent code and documentation of libraries in ION. Test text'
out: <p>The <span class="caps">ION</span> coding style document found at <a href="http://perforce:8081/@md=d&#38;cd=//&#38;c=82E@//depot/systest/system/main/pub/doc/IONCodingStyleGuide.doc?ac=22">IONCodingStyleGuide.doc</a> codifies a couple of rules to ensure reasonably consistent code and documentation of libraries in <span class="caps">ION</span>. Test text</p>

View file

@ -1,77 +0,0 @@
--- # Bret Pettichord, Thanks.
in: |-
* first line
* second
line
* third line
out: |-
<ul>
<li>first line</li>
<li>second
line</li>
<li>third line</li>
</ul>
---
in: |-
p. start
* one
and one
* two
and two
* three
p. end
out: |-
<p>start</p>
<ul>
<li>one
and one</li>
<li>two
and two</li>
<li>three</li>
</ul>
<p>end</p>
---
in: |-
Funky:
* Testing
*# number
*##* bullet
*# number
*# number
yeah number
#* bullet
*** okay
****# what
out: |-
<p>Funky:</p>
<ul>
<li>Testing
<ol>
<li>number
<ul>
<li>bullet</li>
</ul>
</li>
<li>number</li>
<li>number
yeah number</li>
<ul>
<li>bullet
<ul>
<li>okay
<ol>
<li>what</li>
</ul></li>
</ol></li>
</ul></li>
</ul></li>
</ol>
---
in: "* command run: @time ruby run-tests.rb > toto@"
out: "<ul>\n\t<li>command run: <code>time ruby run-tests.rb &gt; toto</code></li>\n\t</ul>"

View file

@ -1,218 +0,0 @@
in: |
This is a regular paragraph.
<table>
<tr>
<td>Foo</td>
</tr>
</table>
This is another regular paragraph.
out: |-
<p>This is a regular paragraph.</p>
<table>
<tr>
<td>Foo</td>
</tr>
</table>
<p>This is another regular paragraph.</p>
---
in: '"Larry Bird":http://images.google.com/images?num=30&q=larry+bird'
out: '<p>"Larry Bird":http://images.google.com/images?num=30&#38;q=larry+bird</p>'
---
in: '&copy;'
out: <p>&copy;</p>
---
in: AT&T
out: <p>AT&#38;T</p>
# We don't do this.
# ---
# in: 4 < 5
# out: 4 &lt; 5
---
in: |
This is an H1
=============
This is an H2
-------------
out: |-
<h1>This is an H1</h1>
<h2>This is an H2</h2>
---
in: |
# This is an H1
## This is an H2
###### This is an H6
out: |-
<h1>This is an H1</h1>
<h2>This is an H2</h2>
<h6>This is an H6</h6>
---
in: |
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
>
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
> id sem consectetuer libero luctus adipiscing.
out: |-
<blockquote>
<p>This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p>
<p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
id sem consectetuer libero luctus adipiscing.</p>
</blockquote>
---
in: |
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
>
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
id sem consectetuer libero luctus adipiscing.
out: |-
<blockquote>
<p>This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p>
<p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
id sem consectetuer libero luctus adipiscing.</p>
</blockquote>
---
in: |
> This is the first level of quoting.
>
> > This is nested blockquote.
>
> Back to the first level.
out: |-
<blockquote>
<p>This is the first level of quoting.</p>
<blockquote>
<p>This is nested blockquote.</p>
</blockquote>
<p>Back to the first level.</p>
</blockquote>
---
in: |
> ## This is a header.
>
> 1. This is the first list item.
> 2. This is the second list item.
>
> Here's some example code:
>
> return shell_exec("echo $input | $markdown_script");
out: |-
<blockquote>
<h2>This is a header.</h2>
<p>1. This is the first list item.
2. This is the second list item.</p>
<p>Here's some example code:</p>
<pre><code>return shell_exec("echo $input | $markdown_script");</code></pre>
</blockquote>
---
in: |
* * *
***
*****
- - -
---------------------------------------
_ _ _
out: |-
<hr />
<hr />
<hr />
<hr />
<hr />
<hr />
---
in: |
This is [an example](http://example.com/ "Title") inline link.
[This link](http://example.net/) has no title attribute.
out: |-
<p>This is <a href="http://example.com/" title="Title">an example</a> inline link.</p>
<p><a href="http://example.net/">This link</a> has no title attribute.</p>
---
in: See my [About](/about/) page for details.
out: <p>See my <a href="/about/">About</a> page for details.</p>
---
in: |
This is [an example][id] reference-style link.
This is [an example] [id] reference-style link.
[id]: http://example.com/ "Optional Title Here"
out: |-
<p>This is <a href="http://example.com/" title="Optional Title Here">an example</a> reference-style link.</p>
<p>This is <a href="http://example.com/" title="Optional Title Here">an example</a> reference-style link.</p>
---
in: |
[Google][]
[Google]: http://google.com/
out: <p><a href="http://google.com/">Google</a></p>
---
in: |
Visit [Daring Fireball][] for more information.
[Daring Fireball]: http://daringfireball.net/
out: <p>Visit <a href="http://daringfireball.net/">Daring Fireball</a> for more information.</p>
---
in: |
I get 10 times more traffic from [Google] [1] than from
[Yahoo] [2] or [MSN] [3].
[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[3]: http://search.msn.com/ "MSN Search"
out: |-
<p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
---
in: |
I get 10 times more traffic from [Google][] than from
[Yahoo][] or [MSN][].
[google]: http://google.com/ "Google"
[yahoo]: http://search.yahoo.com/ "Yahoo Search"
[msn]: http://search.msn.com/ "MSN Search"
out: |-
<p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>

View file

@ -1,64 +0,0 @@
--- # Tests from the (Poignant Guide)
in: >
h3. False
!<i/blix-neg.gif(Shape of a cat.)!
_The cat Trady Blix. Frozen in emptiness. Immaculate whiskers rigid. Placid
eyes of lake. Tail of warm icicle. Sponsored by a Very Powerful Pause Button._
The darkness surrounding Blix can be called *negative space*. Hang on to that phrase.
Let it suggest that the emptiness has a negative connotation. In a similar way,
@nil@ has a slightly sour note that it whistles.
Generally speaking, everything in Ruby has a positive charge to it. This spark
flows through strings, numbers, regexps, all of it. Only two keywords wear a
shady cloak: @nil@ and @false@ draggin us down.
You can test that charge with an @if@ keyword. It looks very much like the
@do@ blocks we saw in the last chapter, in that both end with an @end@.
<pre>
if plastic_cup
print "Plastic cup is on the up 'n' up!"
end
</pre>
If @plastic_cup@ contains either @nil@ or @false@, you won't see anything print
to the screen. They're not on the @if@ guest list. So @if@ isn't going to run
any of the code it's protecting.
But @nil@ and @false@ need not walk away in shame. They may be of questionable
character, but @unless@ runs a smaller establishment that caters to the bedraggled.
The @unless@ keyword has a policy of only allowing those with a negative charge in.
Who are: @nil@ and @false@.
<pre>
unless plastic_cup
print "Plastic cup is on the down low."
end
</pre>
You can also use @if@ and @unless@ at the end of a single line of code, if that's
all that is being protected.
<pre>
print "Yeah, plastic cup is up again!" if plastic_cup
print "Hardly. It's down." unless plastic_cup
</pre>
Now that you've met @false@, I'm sure you can see what's on next.
out: "<h3>False</h3>\n\n\t<p style=\"float:left\"><img src=\"i/blix-neg.gif\" title=\"Shape of a cat.\" alt=\"Shape of a cat.\" /></p>\n\n\t<p><em>The cat Trady Blix. Frozen in emptiness. Immaculate whiskers rigid. Placid eyes of lake. Tail of warm icicle. Sponsored by a Very Powerful Pause Button.</em></p>\n\n\t<p>The darkness surrounding Blix can be called <strong>negative space</strong>. Hang on to that phrase. Let it suggest that the emptiness has a negative connotation. In a similar way, <code>nil</code> has a slightly sour note that it whistles.</p>\n\n\t<p>Generally speaking, everything in Ruby has a positive charge to it. This spark flows through strings, numbers, regexps, all of it. Only two keywords wear a shady cloak: <code>nil</code> and <code>false</code> draggin us down.</p>\n\n\t<p>You can test that charge with an <code>if</code> keyword. It looks very much like the <code>do</code> blocks we saw in the last chapter, in that both end with an <code>end</code>.</p>\n\n\n<pre>\n if plastic_cup\n print \"Plastic cup is on the up 'n' up!\" \n end\n</pre>\n\t<p>If <code>plastic_cup</code> contains either <code>nil</code> or <code>false</code>, you won&#8217;t see anything print to the screen. They&#8217;re not on the <code>if</code> guest list. So <code>if</code> isn&#8217;t going to run any of the code it&#8217;s protecting.</p>\n\n\t<p>But <code>nil</code> and <code>false</code> need not walk away in shame. They may be of questionable character, but <code>unless</code> runs a smaller establishment that caters to the bedraggled. The <code>unless</code> keyword has a policy of only allowing those with a negative charge in. Who are: <code>nil</code> and <code>false</code>.</p>\n\n\n<pre>\n unless plastic_cup\n print \"Plastic cup is on the down low.\" \n end\n</pre>\n\t<p>You can also use <code>if</code> and <code>unless</code> at the end of a single line of code, if that&#8217;s all that is being protected.</p>\n\n\n<pre>\n print \"Yeah, plastic cup is up again!\" if plastic_cup\n print \"Hardly. It's down.\" unless plastic_cup\n</pre>\n\t<p>Now that you&#8217;ve met <code>false</code>, I&#8217;m sure you can see what&#8217;s on next.</p>"

View file

@ -1,198 +0,0 @@
in: |
{background:#ddd}. |S|Target|Complete|App|Milestone|
|!/i/g.gif!|11/18/04|11/18/04|070|XML spec complete|
|!/i/g.gif!|11/29/04|11/29/04|011|XML spec complete (KH is on schedule)|
|!/i/g.gif!|11/29/04|11/29/04|051|XML spec complete (KH is on schedule)|
|!/i/g.gif!|11/29/04|11/29/04|081|XML spec complete (KH is on schedule)|
|!/i/g.gif!|11/19/04|11/22/04|070|Preprocessor complete|
|!/i/g.gif!|11/22/04|11/22/04|070|Dialog pass 1 builds an index file|
|!/i/g.gif!|11/24/04|11/24/04|070|Dialog pass 2 98% complete|
|!/i/g.gif!|11/30/04|11/30/04|070|Feature complete. Passes end-to-end smoke test.|
|!/i/g.gif!|11/30/04|11/30/04|011|Preprocessor updates complete|
|!/i/g.gif!|11/30/04|11/30/04|051|Preprocessor updates complete|
|!/i/g.gif!|11/30/04|11/29/04|081|Preprocessor updates complete|
|!/i/w.gif!|12/02/04|.|011|Dialog pass 1 and 2 complete (98+%)|
|!/i/w.gif!|12/02/04|.|051|Dialog pass 1 and 2 complete (98+%)|
|!/i/w.gif!|12/02/04|.|081|Dialog pass 1 and 2 complete (98+%)|
|!/i/w.gif!|12/03/04|.|011|Feature complete|
|!/i/w.gif!|12/03/04|.|051|Feature complete|
|!/i/w.gif!|12/03/04|.|081|Feature complete|
|!/i/w.gif!|12/10/04|.|011|Deployed to Napa test workstation. Passes smoke test.|
|!/i/w.gif!|12/10/04|.|051|Deployed to Napa test workstation. Passes smoke test.|
|!/i/w.gif!|12/10/04|.|081|Deployed to Napa test workstation. Passes smoke test.|
|!/i/w.gif!|12/10/04|.|070|Deployed to Napa test workstation. Passes smoke test.|
|!/i/w.gif!|12/17/04|.|011|System testing complete. Begin testing with live customer data.|
|!/i/w.gif!|12/17/04|.|051|System testing complete. Begin testing with live customer data.|
|!/i/w.gif!|12/17/04|.|081|System testing complete. Begin testing with live customer data.|
|!/i/w.gif!|12/17/04|.|070|System testing complete. Begin testing with live customer data.|
out: |-
<table>
<tr style="background:#ddd;">
<td>S</td>
<td>Target</td>
<td>Complete</td>
<td>App</td>
<td>Milestone</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/18/04</td>
<td>11/18/04</td>
<td>070</td>
<td>XML spec complete</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/29/04</td>
<td>11/29/04</td>
<td>011</td>
<td>XML spec complete (KH is on schedule)</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/29/04</td>
<td>11/29/04</td>
<td>051</td>
<td>XML spec complete (KH is on schedule)</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/29/04</td>
<td>11/29/04</td>
<td>081</td>
<td>XML spec complete (KH is on schedule)</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/19/04</td>
<td>11/22/04</td>
<td>070</td>
<td>Preprocessor complete</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/22/04</td>
<td>11/22/04</td>
<td>070</td>
<td>Dialog pass 1 builds an index file</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/24/04</td>
<td>11/24/04</td>
<td>070</td>
<td>Dialog pass 2 98% complete</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/30/04</td>
<td>11/30/04</td>
<td>070</td>
<td>Feature complete. Passes end-to-end smoke test.</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/30/04</td>
<td>11/30/04</td>
<td>011</td>
<td>Preprocessor updates complete</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/30/04</td>
<td>11/30/04</td>
<td>051</td>
<td>Preprocessor updates complete</td>
</tr>
<tr>
<td><img src="/i/g.gif" alt="" /></td>
<td>11/30/04</td>
<td>11/29/04</td>
<td>081</td>
<td>Preprocessor updates complete</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/02/04</td>
<td>011</td>
<td>Dialog pass 1 and 2 complete (98+%)</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/02/04</td>
<td>051</td>
<td>Dialog pass 1 and 2 complete (98+%)</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/02/04</td>
<td>081</td>
<td>Dialog pass 1 and 2 complete (98+%)</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/03/04</td>
<td>011</td>
<td>Feature complete</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/03/04</td>
<td>051</td>
<td>Feature complete</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/03/04</td>
<td>081</td>
<td>Feature complete</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/10/04</td>
<td>011</td>
<td>Deployed to Napa test workstation. Passes smoke test.</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/10/04</td>
<td>051</td>
<td>Deployed to Napa test workstation. Passes smoke test.</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/10/04</td>
<td>081</td>
<td>Deployed to Napa test workstation. Passes smoke test.</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/10/04</td>
<td>070</td>
<td>Deployed to Napa test workstation. Passes smoke test.</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/17/04</td>
<td>011</td>
<td>System testing complete. Begin testing with live customer data.</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/17/04</td>
<td>051</td>
<td>System testing complete. Begin testing with live customer data.</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/17/04</td>
<td>081</td>
<td>System testing complete. Begin testing with live customer data.</td>
</tr>
<tr>
<td><img src="/i/w.gif" alt="" /></td>
<td>12/17/04</td>
<td>070</td>
<td>System testing complete. Begin testing with live customer data.</td>
</tr>
</table>

View file

@ -1,397 +0,0 @@
---
in: h1. Header 1
out: <h1>Header 1</h1>
---
in: h2. Header 2
out: <h2>Header 2</h2>
---
in: h3. Header 3
out: <h3>Header 3</h3>
---
in: |-
Any old text.
bq. A block quotation.
Any old text.
out: |-
<p>Any old text.</p>
<blockquote>
<p>A block quotation.</p>
</blockquote>
<p>Any old text.</p>
---
in: This is covered elsewhere[1].
out: <p>This is covered elsewhere<sup><a href="#fn1">1</a></sup>.</p>
---
in: fn1. Down here, in fact.
out: <p id="fn1"><sup>1</sup> Down here, in fact.</p>
---
in: |-
# A first item
# A second item
# A third item
# A fourth item
out: |-
<ol>
<li>A first item</li>
<li>A second item</li>
<li>A third item</li>
<li>A fourth item</li>
</ol>
---
in: |-
* A first item
* A second item
* A third item
* A fourth item
out: |-
<ul>
<li>A first item</li>
<li>A second item</li>
<li>A third item</li>
<li>A fourth item</li>
</ul>
---
in: _a phrase_
out: <p><em>a phrase</em></p>
---
in: __a phrase__
out: <p><i>a phrase</i></p>
---
in: '*a phrase*'
out: <p><strong>a phrase</strong></p>
---
in: '**a phrase**'
out: <p><b>a phrase</b></p>
---
in: Nabokov's ??Pnin??
out: <p>Nabokov&#8217;s <cite>Pnin</cite></p>
---
in: -a phrase-
out: <p><del>a phrase</del></p>
---
in: +a phrase+
out: <p><ins>a phrase</ins></p>
---
in: ^a phrase^
out: <p><sup>a phrase</sup></p>
---
in: ~a phrase~
out: <p><sub>a phrase</sub></p>
# ---
# in: %(caps)SPAN%
# out: <p><span class="caps">SPAN</span>
---
in: %{color:red}red%
out: <p><span style="color:red;">red</span></p>
---
in: %[fr]rouge%
out: <p><span lang="fr">rouge</span></p>
---
in: _(big)red_
out: <p><em class="big">red</em></p>
---
in: p(bob). A paragraph
out: <p class="bob">A paragraph</p>
---
in: p{color:#ddd}. A paragraph
out: <p style="color:#ddd;">A paragraph</p>
---
in: p[fr]. A paragraph
out: <p lang="fr">A paragraph</p>
---
in: h2()>. right-aligned header2, indented 1em both side
out: <h2 style="padding-left:1em;padding-right:1em;text-align:right;">right-aligned header2, indented 1em both side</h2>
---
in: h3=. centered header
out: <h3 style="text-align:center;">centered header</h3>
---
in: '!>/image.gif! right-aligned image'
out: <p style="float:right"><img src="/image.gif" alt="" /> right-aligned image</p>
---
in: p[no]{color:red}. A Norse of a different colour.
out: <p style="color:red;" lang="no">A Norse of a different colour.</p>
---
in: |-
|This|is|a|simple|table|
|This|is|a|simple|row|
out: |-
<table>
<tr>
<td>This</td>
<td>is</td>
<td>a</td>
<td>simple</td>
<td>table</td>
</tr>
<tr>
<td>This</td>
<td>is</td>
<td>a</td>
<td>simple</td>
<td>row</td>
</tr>
</table>
---
in: |-
table{border:1px solid black}.
|This|is|a|row|
|This|is|a|row|
out: |-
<table style="border:1px solid black;">
<tr>
<td>This</td>
<td>is</td>
<td>a</td>
<td>row</td>
</tr>
<tr>
<td>This</td>
<td>is</td>
<td>a</td>
<td>row</td>
</tr>
</table>
---
in: '{background:#ddd}. |This|is|a|row|'
out: |-
<table>
<tr style="background:#ddd;">
<td>This</td>
<td>is</td>
<td>a</td>
<td>row</td>
</tr>
</table>
---
in: |-
|{background:#ddd}. Cell with gray background|
|\2. Cell spanning 2 columns|
|/3. Cell spanning 3 rows|
|>. Right-aligned cell|
out: |-
<table>
<tr>
<td style="background:#ddd;">Cell with gray background</td>
</tr>
<tr>
<td colspan="2">Cell spanning 2 columns</td>
</tr>
<tr>
<td rowspan="3">Cell spanning 3 rows</td>
</tr>
<tr>
<td style="text-align:right;">Right-aligned cell</td>
</tr>
</table>
# ---
# in: |-
# This is a "link":bob to Bob's website.
#
# [bob]http://itsbob.com/index.html
---
in: ACLU(American Civil Liberties Union)
out: <p><acronym title="American Civil Liberties Union">ACLU</acronym></p>
---
in: |-
h2{color:green}. This is a title
h3. This is a subhead
p{color:red}. This is some text of dubious character. Isn't the use of "quotes" just lazy writing -- and theft of 'intellectual property' besides? I think the time has come to see a block quote.
bq[fr]. This is a block quote. I'll admit it's not the most exciting block quote ever devised.
Simple list:
#{color:blue} one
# two
# three
Multi-level list:
# one
## aye
## bee
## see
# two
## x
## y
# three
Mixed list:
* Point one
* Point two
## Step 1
## Step 2
## Step 3
* Point three
** Sub point 1
** Sub point 2
Well, that went well. How about we insert an <a href="/" title="watch out">old-fashioned hypertext link</a>? Will the quote marks in the tags get messed up? No!
"This is a link (optional title)":http://www.textism.com
table{border:1px solid black}.
|_. this|_. is|_. a|_. header|
<{background:gray}. |\2. this is|{background:red;width:200px}. a|^<>{height:200px}. row|
|this|<>{padding:10px}. is|^. another|(bob#bob). row|
An image:
!/common/textist.gif(optional alt text)!
# Librarians rule
# Yes they do
# But you knew that
Some more text of dubious character. Here is a noisome string of CAPITAL letters. Here is something we want to _emphasize_.
That was a linebreak. And something to indicate *strength*. Of course I could use <em>my own HTML tags</em> if I <strong>felt</strong> like it.
h3. Coding
This <code>is some code, "isn't it"</code>. Watch those quote marks! Now for some preformatted text:
<pre>
<code>
$text = str_replace("<p>%::%</p>","",$text);
$text = str_replace("%::%</p>","",$text);
$text = str_replace("%::%","",$text);
</code>
</pre>
This isn't code.
So you see, my friends:
* The time is now
* The time is not later
* The time is not yesterday
* We must act
out: |-
<h2 style="color:green;">This is a title</h2>
<h3>This is a subhead</h3>
<p style="color:red;">This is some text of dubious character. Isn&#8217;t the use of &#8220;quotes&#8221; just lazy writing&#8212;and theft of &#8216;intellectual property&#8217; besides? I think the time has come to see a block quote.</p>
<blockquote>
<p lang="fr">This is a block quote. I&#8217;ll admit it&#8217;s not the most exciting block quote ever devised.</p>
</blockquote>
<p>Simple list:</p>
<ol style="color:blue;">
<li>one</li>
<li>two</li>
<li>three</li>
</ol>
<p>Multi-level list:</p>
<ol>
<li>one
<ol>
<li>aye</li>
<li>bee</li>
<li>see</li>
</ol>
</li>
<li>two
<ol>
<li>x</li>
<li>y</li>
</ol>
</li>
<li>three</li>
</ol>
<p>Mixed list:</p>
<ul>
<li>Point one</li>
<li>Point two
<ol>
<li>Step 1</li>
<li>Step 2</li>
<li>Step 3</li>
</ol>
</li>
<li>Point three
<ul>
<li>Sub point 1</li>
<li>Sub point 2</li>
</ul></li>
</ul>
<p>Well, that went well. How about we insert an <a href="/" title="watch out">old-fashioned hypertext link</a>? Will the quote marks in the tags get messed up? No!</p>
<p><a href="http://www.textism.com" title="optional title">This is a link</a></p>
<table style="border:1px solid black;">
<tr>
<th>this</th>
<th>is</th>
<th>a</th>
<th>header</th>
</tr>
<tr style="background:gray;text-align:left;">
<td colspan="2">this is</td>
<td style="background:red;width:200px;">a</td>
<td style="vertical-align:top;height:200px;text-align:justify;">row</td>
</tr>
<tr>
<td>this</td>
<td style="padding:10px;text-align:justify;">is</td>
<td style="vertical-align:top;">another</td>
<td class="bob" id="bob">row</td>
</tr>
</table>
<p>An image:</p>
<p><img src="/common/textist.gif" title="optional alt text" alt="optional alt text" /></p>
<ol>
<li>Librarians rule</li>
<li>Yes they do</li>
<li>But you knew that</li>
</ol>
<p>Some more text of dubious character. Here is a noisome string of <span class="caps">CAPITAL</span> letters. Here is something we want to <em>emphasize</em>.
That was a linebreak. And something to indicate <strong>strength</strong>. Of course I could use <em>my own <span class="caps">HTML</span> tags</em> if I <strong>felt</strong> like it.</p>
<h3>Coding</h3>
<p>This <code>is some code, "isn't it"</code>. Watch those quote marks! Now for some preformatted text:</p>
<pre>
<code>
$text = str_replace("&lt;p&gt;%::%&lt;/p&gt;","",$text);
$text = str_replace("%::%&lt;/p&gt;","",$text);
$text = str_replace("%::%","",$text);
</code>
</pre>
<p>This isn&#8217;t code.</p>
<p>So you see, my friends:</p>
<ul>
<li>The time is now</li>
<li>The time is not later</li>
<li>The time is not yesterday</li>
<li>We must act</li>
</ul>

File diff suppressed because it is too large Load diff

View file

@ -1,110 +0,0 @@
= Version 0.5.8
Fixed install script.
= Version 0.5.7
install.rb no longer assumes it is being run from the toplevel source
dir. Directory structure changed to reflect common ruby library
project structure. Migrated from RubyUnit to Test::Unit format. Now
uses Rake to build source packages and gems and run unit tests.
= Version 0.5.6
Fix for FreeBSD 4.9 which returns Errno::EFBIG instead of
Errno::EINVAL for some invalid seeks. Fixed 'version needed to
extract'-field incorrect in local headers.
= Version 0.5.5
Fix for a problem with writing zip files that concerns only ruby 1.8.1.
= Version 0.5.4
Significantly reduced memory footprint when modifying zip files.
= Version 0.5.3
Added optimization to avoid decompressing and recompressing individual
entries when modifying a zip archive.
= Version 0.5.2
Fixed ZipFile corruption bug in ZipFile class. Added basic unix
extra-field support.
= Version 0.5.1
Fixed ZipFile.get_output_stream bug.
= Version 0.5.0
List of changes:
* Ruby 1.8.0 and ruby-zlib 0.6.0 compatibility
* Changed method names from camelCase to rubys underscore style.
* Installs to zip/ subdir instead of directly to site_ruby
* Added ZipFile.directory and ZipFile.file - each method return an
object that can be used like Dir and File only for the contents of the
zip file.
* Added sample application zipfind which works like Find.find, only
Zip::ZipFind.find traverses into zip archives too.
Bug fixes:
* AbstractInputStream.each_line with non-default separator
= Version 0.5.0a
Source reorganized. Added ziprequire, which can be used to load ruby
modules from a zip file, in a fashion similar to jar files in
Java. Added gtkRubyzip, another sample application. Implemented
ZipInputStream.lineno and ZipInputStream.rewind
Bug fixes:
* Read and write date and time information correctly for zip entries.
* Fixed read() using separate buffer, causing mix of gets/readline/read to
cause problems.
= Version 0.4.2
Performance optimizations. Test suite runs in half the time.
= Version 0.4.1
Windows compatibility fixes.
= Version 0.4.0
Zip::ZipFile is now mutable and provides a more convenient way of
modifying zip archives than Zip::ZipOutputStream. Operations for
adding, extracting, renaming, replacing and removing entries to zip
archives are now available.
Runs without warnings with -w switch.
Install script install.rb added.
= Version 0.3.1
Rudimentary support for writing zip archives.
= Version 0.2.2
Fixed and extended unit test suite. Updated to work with ruby/zlib
0.5. It doesn't work with earlier versions of ruby/zlib.
= Version 0.2.0
Class ZipFile added. Where ZipInputStream is used to read the
individual entries in a zip file, ZipFile reads the central directory
in the zip archive, so you can get to any entry in the zip archive
without having to skipping through all the preceeding entries.
= Version 0.1.0
First working version of ZipInputStream.

View file

@ -1,70 +0,0 @@
= rubyzip
rubyzip is a ruby library for reading and writing zip files.
= Install
If you have rubygems you can install rubyzip directly from the gem
repository
gem install rubyzip
Otherwise obtain the source (see below) and run
ruby install.rb
To run the unit tests you need to have test::unit installed
rake test
= Documentation
There is more than one way to access or create a zip archive with
rubyzip. The basic API is modeled after the classes in
java.util.zip from the Java SDK. This means there are classes such
as Zip::ZipInputStream, Zip::ZipOutputStream and
Zip::ZipFile. Zip::ZipInputStream provides a basic interface for
iterating through the entries in a zip archive and reading from the
entries in the same way as from a regular File or IO
object. ZipOutputStream is the corresponding basic output
facility. Zip::ZipFile provides a mean for accessing the archives
central directory and provides means for accessing any entry without
having to iterate through the archive. Unlike Java's
java.util.zip.ZipFile rubyzip's Zip::ZipFile is mutable, which means
it can be used to change zip files as well.
Another way to access a zip archive with rubyzip is to use rubyzip's
Zip::ZipFileSystem API. Using this API files can be read from and
written to the archive in much the same manner as ruby's builtin
classes allows files to be read from and written to the file system.
rubyzip also features the
zip/ziprequire.rb[link:files/lib/zip/ziprequire_rb.html] module which
allows ruby to load ruby modules from zip archives.
For details about the specific behaviour of classes and methods refer
to the test suite. Finally you can generate the rdoc documentation or
visit http://rubyzip.sourceforge.net.
= License
rubyzip is distributed under the same license as ruby. See
http://www.ruby-lang.org/en/LICENSE.txt
= Website and Project Home
http://rubyzip.sourceforge.net
http://sourceforge.net/projects/rubyzip
== Download (tarballs and gems)
http://sourceforge.net/project/showfiles.php?group_id=43107&package_id=35377
= Authors
Thomas Sondergaard (thomas at sondergaard.cc)
extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)

View file

@ -1,110 +0,0 @@
# Rakefile for RubyGems -*- ruby -*-
require 'rubygems'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/sshpublisher'
require 'net/ftp'
PKG_NAME = 'rubyzip'
PKG_VERSION = File.read('lib/zip/zip.rb').match(/\s+VERSION\s*=\s*'(.*)'/)[1]
PKG_FILES = FileList.new
PKG_FILES.add %w{ README NEWS TODO ChangeLog install.rb Rakefile }
PKG_FILES.add %w{ samples/*.rb }
PKG_FILES.add %w{ test/*.rb }
PKG_FILES.add %w{ test/data/* }
PKG_FILES.exclude "test/data/generated"
PKG_FILES.add %w{ lib/**/*.rb }
def clobberFromCvsIgnore(path)
CLOBBER.add File.readlines(path+'/.cvsignore').map {
|f| File.join(path, f.chomp)
}
end
clobberFromCvsIgnore '.'
clobberFromCvsIgnore 'samples'
clobberFromCvsIgnore 'test'
clobberFromCvsIgnore 'test/data'
task :default => [:test]
desc "Run unit tests"
task :test do
ruby %{-C test alltests.rb}
end
# Shortcuts for test targets
task :ut => [:test]
spec = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.author = "Thomas Sondergaard"
s.email = "thomas(at)sondergaard.cc"
s.homepage = "http://rubyzip.sourceforge.net/"
s.platform = Gem::Platform::RUBY
s.summary = "rubyzip is a ruby module for reading and writing zip files"
s.files = PKG_FILES.to_a #Dir.glob("{samples,lib,test,docs}/**/*").delete_if {|item| item.include?("CVS") || item.include?("rdoc") || item =~ /~$/ }
s.require_path = 'lib'
s.autorequire = 'zip/zip'
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
Rake::RDocTask.new do |rd|
rd.main = "README"
rd.rdoc_files.add %W{ lib/zip/*.rb README NEWS TODO ChangeLog }
rd.options << "--title 'rubyzip documentation' --webcvs http://cvs.sourceforge.net/viewcvs.py/rubyzip/rubyzip/"
# rd.options << "--all"
end
desc "Publish documentation"
task :pdoc => [:rdoc] do
Rake::SshFreshDirPublisher.
new("thomas@rubyzip.sourceforge.net", "rubyzip/htdocs", "html").upload
end
desc "Publish package"
task :ppackage => [:package] do
Net::FTP.open("upload.sourceforge.net",
"ftp",
ENV['USER']+"@"+ENV['HOSTNAME']) {
|ftpclient|
ftpclient.chdir "incoming"
Dir['pkg/*.{tgz,zip,gem}'].each {
|e|
ftpclient.putbinaryfile(e, File.basename(e))
}
}
end
desc "Generate the ChangeLog file"
task :ChangeLog do
puts "Updating ChangeLog"
system %{cvs2cl}
end
desc "Make a release"
task :release => [:tag_release, :pdoc, :ppackage] do
end
desc "Make a release tag"
task :tag_release do
tag = "release-#{PKG_VERSION.gsub('.','-')}"
puts "Checking for tag '#{tag}'"
if (Regexp.new("^\\s+#{tag}") =~ `cvs log README`)
abort "Tag '#{tag}' already exists"
end
puts "Tagging module with '#{tag}'"
system("cvs tag #{tag}")
end

View file

@ -1,9 +0,0 @@
* Fix problem with mixing AbstractInputStream::gets and AbstractInputStream::read
* Implement ZipFsDir.glob
* ZipFile.checkIntegrity method
* non-MSDOS permission attributes
** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
* Packager version, required unpacker version in zip headers
** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
* implement storing attributes and ownership information

View file

@ -1,22 +0,0 @@
#!/usr/bin/env ruby
$VERBOSE = true
require 'rbconfig'
require 'find'
require 'ftools'
include Config
files = %w{ stdrubyext.rb ioextras.rb zip.rb zipfilesystem.rb ziprequire.rb tempfile_bugfixed.rb }
INSTALL_DIR = File.join(CONFIG["sitelibdir"], "zip")
File.makedirs(INSTALL_DIR)
SOURCE_DIR = File.join(File.dirname($0), "lib/zip")
files.each {
|filename|
installPath = File.join(INSTALL_DIR, filename)
File::install(File.join(SOURCE_DIR, filename), installPath, 0644, true)
}

View file

@ -1,69 +0,0 @@
#!/usr/bin/env ruby
$: << "../lib"
system("zip example.zip example.rb gtkRubyzip.rb")
require 'zip/zip'
####### Using ZipInputStream alone: #######
Zip::ZipInputStream.open("example.zip") {
|zis|
entry = zis.get_next_entry
print "First line of '#{entry.name} (#{entry.size} bytes): "
puts "'#{zis.gets.chomp}'"
entry = zis.get_next_entry
print "First line of '#{entry.name} (#{entry.size} bytes): "
puts "'#{zis.gets.chomp}'"
}
####### Using ZipFile to read the directory of a zip file: #######
zf = Zip::ZipFile.new("example.zip")
zf.each_with_index {
|entry, index|
puts "entry #{index} is #{entry.name}, size = #{entry.size}, compressed size = #{entry.compressed_size}"
# use zf.get_input_stream(entry) to get a ZipInputStream for the entry
# entry can be the ZipEntry object or any object which has a to_s method that
# returns the name of the entry.
}
####### Using ZipOutputStream to write a zip file: #######
Zip::ZipOutputStream.open("exampleout.zip") {
|zos|
zos.put_next_entry("the first little entry")
zos.puts "Hello hello hello hello hello hello hello hello hello"
zos.put_next_entry("the second little entry")
zos.puts "Hello again"
# Use rubyzip or your zip client of choice to verify
# the contents of exampleout.zip
}
####### Using ZipFile to change a zip file: #######
Zip::ZipFile.open("exampleout.zip") {
|zf|
zf.add("thisFile.rb", "example.rb")
zf.rename("thisFile.rb", "ILikeThisName.rb")
zf.add("Again", "example.rb")
}
# Lets check
Zip::ZipFile.open("exampleout.zip") {
|zf|
puts "Changed zip file contains: #{zf.entries.join(', ')}"
zf.remove("Again")
puts "Without 'Again': #{zf.entries.join(', ')}"
}
# For other examples, look at zip.rb and ziptest.rb
# Copyright (C) 2002 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

View file

@ -1,34 +0,0 @@
#!/usr/bin/env ruby
$: << "../lib"
require 'zip/zipfilesystem'
require 'ftools'
EXAMPLE_ZIP = "filesystem.zip"
File.delete(EXAMPLE_ZIP) if File.exists?(EXAMPLE_ZIP)
Zip::ZipFile.open(EXAMPLE_ZIP, Zip::ZipFile::CREATE) {
|zf|
zf.file.open("file1.txt", "w") { |os| os.write "first file1.txt" }
zf.dir.mkdir("dir1")
zf.dir.chdir("dir1")
zf.file.open("file1.txt", "w") { |os| os.write "second file1.txt" }
puts zf.file.read("file1.txt")
puts zf.file.read("../file1.txt")
zf.dir.chdir("..")
zf.file.open("file2.txt", "w") { |os| os.write "first file2.txt" }
puts "Entries: #{zf.entries.join(', ')}"
}
Zip::ZipFile.open(EXAMPLE_ZIP) {
|zf|
puts "Entries from reloaded zip: #{zf.entries.join(', ')}"
}
# For other examples, look at zip.rb and ziptest.rb
# Copyright (C) 2003 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

View file

@ -1,86 +0,0 @@
#!/usr/bin/env ruby
$: << "../lib"
$VERBOSE = true
require 'gtk'
require 'zip/zip'
class MainApp < Gtk::Window
def initialize
super()
set_usize(400, 256)
set_title("rubyzip")
signal_connect(Gtk::Window::SIGNAL_DESTROY) { Gtk.main_quit }
box = Gtk::VBox.new(false, 0)
add(box)
@zipfile = nil
@buttonPanel = ButtonPanel.new
@buttonPanel.openButton.signal_connect(Gtk::Button::SIGNAL_CLICKED) {
show_file_selector
}
@buttonPanel.extractButton.signal_connect(Gtk::Button::SIGNAL_CLICKED) {
puts "Not implemented!"
}
box.pack_start(@buttonPanel, false, false, 0)
sw = Gtk::ScrolledWindow.new
sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
box.pack_start(sw, true, true, 0)
@clist = Gtk::CList.new(["Name", "Size", "Compression"])
@clist.set_selection_mode(Gtk::SELECTION_BROWSE)
@clist.set_column_width(0, 120)
@clist.set_column_width(1, 120)
@clist.signal_connect(Gtk::CList::SIGNAL_SELECT_ROW) {
|w, row, column, event|
@selected_row = row
}
sw.add(@clist)
end
class ButtonPanel < Gtk::HButtonBox
attr_reader :openButton, :extractButton
def initialize
super
set_layout(Gtk::BUTTONBOX_START)
set_spacing(0)
@openButton = Gtk::Button.new("Open archive")
@extractButton = Gtk::Button.new("Extract entry")
pack_start(@openButton)
pack_start(@extractButton)
end
end
def show_file_selector
@fileSelector = Gtk::FileSelection.new("Open zip file")
@fileSelector.show
@fileSelector.ok_button.signal_connect(Gtk::Button::SIGNAL_CLICKED) {
open_zip(@fileSelector.filename)
@fileSelector.destroy
}
@fileSelector.cancel_button.signal_connect(Gtk::Button::SIGNAL_CLICKED) {
@fileSelector.destroy
}
end
def open_zip(filename)
@zipfile = Zip::ZipFile.open(filename)
@clist.clear
@zipfile.each {
|entry|
@clist.append([ entry.name,
entry.size.to_s,
(100.0*entry.compressedSize/entry.size).to_s+"%" ])
}
end
end
mainApp = MainApp.new()
mainApp.show_all
Gtk.main

View file

@ -1,13 +0,0 @@
#!/usr/bin/env ruby
$: << "../lib"
require 'zip/zip'
include Zip
ZipOutputStream.open('simple.zip') {
|zos|
ze = zos.put_next_entry 'entry.txt'
zos.puts "Hello world"
}

View file

@ -1,74 +0,0 @@
#!/usr/bin/env ruby
$VERBOSE = true
$: << "../lib"
require 'zip/zip'
require 'find'
module Zip
module ZipFind
def self.find(path, zipFilePattern = /\.zip$/i)
Find.find(path) {
|fileName|
yield(fileName)
if zipFilePattern.match(fileName) && File.file?(fileName)
begin
Zip::ZipFile.foreach(fileName) {
|zipEntry|
yield(fileName + File::SEPARATOR + zipEntry.to_s)
}
rescue Errno::EACCES => ex
puts ex
end
end
}
end
def self.find_file(path, fileNamePattern, zipFilePattern = /\.zip$/i)
self.find(path, zipFilePattern) {
|fileName|
yield(fileName) if fileNamePattern.match(fileName)
}
end
end
end
if __FILE__ == $0
module ZipFindConsoleRunner
PATH_ARG_INDEX = 0;
FILENAME_PATTERN_ARG_INDEX = 1;
ZIPFILE_PATTERN_ARG_INDEX = 2;
def self.run(args)
check_args(args)
Zip::ZipFind.find_file(args[PATH_ARG_INDEX],
args[FILENAME_PATTERN_ARG_INDEX],
args[ZIPFILE_PATTERN_ARG_INDEX]) {
|fileName|
report_entry_found fileName
}
end
def self.check_args(args)
if (args.size != 3)
usage
exit
end
end
def self.usage
puts "Usage: #{$0} PATH ZIPFILENAME_PATTERN FILNAME_PATTERN"
end
def self.report_entry_found(fileName)
puts fileName
end
end
ZipFindConsoleRunner.run(ARGV)
end

View file

@ -1,9 +0,0 @@
#!/usr/bin/env ruby
$VERBOSE = true
require 'stdrubyexttest'
require 'ioextrastest'
require 'ziptest'
require 'zipfilesystemtest'
require 'ziprequiretest'

View file

@ -1,46 +0,0 @@
AUTOMAKE_OPTIONS = gnu
EXTRA_DIST = test.zip
CXXFLAGS= -g
noinst_LIBRARIES = libzipios.a
bin_PROGRAMS = test_zip test_izipfilt test_izipstream
# test_flist
libzipios_a_SOURCES = backbuffer.h fcol.cpp fcol.h \
fcol_common.h fcolexceptions.cpp fcolexceptions.h \
fileentry.cpp fileentry.h flist.cpp \
flist.h flistentry.cpp flistentry.h \
flistscanner.h ifiltstreambuf.cpp ifiltstreambuf.h \
inflatefilt.cpp inflatefilt.h izipfilt.cpp \
izipfilt.h izipstream.cpp izipstream.h \
zipfile.cpp zipfile.h ziphead.cpp \
ziphead.h flistscanner.ll
# test_flist_SOURCES = test_flist.cpp
test_izipfilt_SOURCES = test_izipfilt.cpp
test_izipstream_SOURCES = test_izipstream.cpp
test_zip_SOURCES = test_zip.cpp
# Notice that libzipios.a is not specified as -L. -lzipios
# If it was, automake would not include it as a dependency.
# test_flist_LDADD = libzipios.a
test_izipfilt_LDADD = libzipios.a -lz
test_zip_LDADD = libzipios.a -lz
test_izipstream_LDADD = libzipios.a -lz
flistscanner.cc : flistscanner.ll
$(LEX) -+ -PFListScanner -o$@ $^

File diff suppressed because it is too large Load diff

View file

@ -1,7 +0,0 @@
#!/usr/bin/env ruby
class NotZippedRuby
def returnTrue
true
end
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,155 +0,0 @@
#!/usr/bin/env ruby
$VERBOSE = true
class TestFiles
RANDOM_ASCII_FILE1 = "data/generated/randomAscii1.txt"
RANDOM_ASCII_FILE2 = "data/generated/randomAscii2.txt"
RANDOM_ASCII_FILE3 = "data/generated/randomAscii3.txt"
RANDOM_BINARY_FILE1 = "data/generated/randomBinary1.bin"
RANDOM_BINARY_FILE2 = "data/generated/randomBinary2.bin"
EMPTY_TEST_DIR = "data/generated/emptytestdir"
ASCII_TEST_FILES = [ RANDOM_ASCII_FILE1, RANDOM_ASCII_FILE2, RANDOM_ASCII_FILE3 ]
BINARY_TEST_FILES = [ RANDOM_BINARY_FILE1, RANDOM_BINARY_FILE2 ]
TEST_DIRECTORIES = [ EMPTY_TEST_DIR ]
TEST_FILES = [ ASCII_TEST_FILES, BINARY_TEST_FILES, EMPTY_TEST_DIR ].flatten!
def TestFiles.create_test_files(recreate)
if (recreate ||
! (TEST_FILES.inject(true) { |accum, element| accum && File.exists?(element) }))
Dir.mkdir "data/generated" rescue Errno::EEXIST
ASCII_TEST_FILES.each_with_index {
|filename, index|
create_random_ascii(filename, 1E4 * (index+1))
}
BINARY_TEST_FILES.each_with_index {
|filename, index|
create_random_binary(filename, 1E4 * (index+1))
}
ensure_dir(EMPTY_TEST_DIR)
end
end
private
def TestFiles.create_random_ascii(filename, size)
File.open(filename, "wb") {
|file|
while (file.tell < size)
file << rand
end
}
end
def TestFiles.create_random_binary(filename, size)
File.open(filename, "wb") {
|file|
while (file.tell < size)
file << [rand].pack("V")
end
}
end
def TestFiles.ensure_dir(name)
if File.exists?(name)
return if File.stat(name).directory?
File.delete(name)
end
Dir.mkdir(name)
end
end
# For representation and creation of
# test data
class TestZipFile
attr_accessor :zip_name, :entry_names, :comment
def initialize(zip_name, entry_names, comment = "")
@zip_name=zip_name
@entry_names=entry_names
@comment = comment
end
def TestZipFile.create_test_zips(recreate)
files = Dir.entries("data/generated")
if (recreate ||
! (files.index(File.basename(TEST_ZIP1.zip_name)) &&
files.index(File.basename(TEST_ZIP2.zip_name)) &&
files.index(File.basename(TEST_ZIP3.zip_name)) &&
files.index(File.basename(TEST_ZIP4.zip_name)) &&
files.index("empty.txt") &&
files.index("short.txt") &&
files.index("longAscii.txt") &&
files.index("longBinary.bin") ))
raise "failed to create test zip '#{TEST_ZIP1.zip_name}'" unless
system("zip #{TEST_ZIP1.zip_name} data/file2.txt")
raise "failed to remove entry from '#{TEST_ZIP1.zip_name}'" unless
system("zip #{TEST_ZIP1.zip_name} -d data/file2.txt")
File.open("data/generated/empty.txt", "w") {}
File.open("data/generated/short.txt", "w") { |file| file << "ABCDEF" }
ziptestTxt=""
File.open("data/file2.txt") { |file| ziptestTxt=file.read }
File.open("data/generated/longAscii.txt", "w") {
|file|
while (file.tell < 1E5)
file << ziptestTxt
end
}
testBinaryPattern=""
File.open("data/generated/empty.zip") { |file| testBinaryPattern=file.read }
testBinaryPattern *= 4
File.open("data/generated/longBinary.bin", "wb") {
|file|
while (file.tell < 3E5)
file << testBinaryPattern << rand
end
}
raise "failed to create test zip '#{TEST_ZIP2.zip_name}'" unless
system("zip #{TEST_ZIP2.zip_name} #{TEST_ZIP2.entry_names.join(' ')}")
# without bash system interprets everything after echo as parameters to
# echo including | zip -z ...
raise "failed to add comment to test zip '#{TEST_ZIP2.zip_name}'" unless
system("bash -c \"echo #{TEST_ZIP2.comment} | zip -z #{TEST_ZIP2.zip_name}\"")
raise "failed to create test zip '#{TEST_ZIP3.zip_name}'" unless
system("zip #{TEST_ZIP3.zip_name} #{TEST_ZIP3.entry_names.join(' ')}")
raise "failed to create test zip '#{TEST_ZIP4.zip_name}'" unless
system("zip #{TEST_ZIP4.zip_name} #{TEST_ZIP4.entry_names.join(' ')}")
end
rescue
raise $!.to_s +
"\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" +
"to create test data. If you don't have it you can download\n" +
"the necessary test files at http://sf.net/projects/rubyzip."
end
TEST_ZIP1 = TestZipFile.new("data/generated/empty.zip", [])
TEST_ZIP2 = TestZipFile.new("data/generated/4entry.zip", %w{ data/generated/longAscii.txt data/generated/empty.txt data/generated/short.txt data/generated/longBinary.bin},
"my zip comment")
TEST_ZIP3 = TestZipFile.new("data/generated/test1.zip", %w{ data/file1.txt })
TEST_ZIP4 = TestZipFile.new("data/generated/zipWithDir.zip", [ "data/file1.txt",
TestFiles::EMPTY_TEST_DIR])
end
END {
TestFiles::create_test_files(ARGV.index("recreate") != nil ||
ARGV.index("recreateonly") != nil)
TestZipFile::create_test_zips(ARGV.index("recreate") != nil ||
ARGV.index("recreateonly") != nil)
exit if ARGV.index("recreateonly") != nil
}

View file

@ -1,208 +0,0 @@
#!/usr/bin/env ruby
$VERBOSE = true
$: << "../lib"
require 'test/unit'
require 'zip/ioextras'
include IOExtras
class FakeIOTest < Test::Unit::TestCase
class FakeIOUsingClass
include FakeIO
end
def test_kind_of?
obj = FakeIOUsingClass.new
assert(obj.kind_of?(Object))
assert(obj.kind_of?(FakeIOUsingClass))
assert(obj.kind_of?(IO))
assert(!obj.kind_of?(Fixnum))
assert(!obj.kind_of?(String))
end
end
class AbstractInputStreamTest < Test::Unit::TestCase
# AbstractInputStream subclass that provides a read method
TEST_LINES = [ "Hello world#{$/}",
"this is the second line#{$/}",
"this is the last line"]
TEST_STRING = TEST_LINES.join
class TestAbstractInputStream
include AbstractInputStream
def initialize(aString)
super()
@contents = aString
@readPointer = 0
end
def read(charsToRead)
retVal=@contents[@readPointer, charsToRead]
@readPointer+=charsToRead
return retVal
end
def produce_input
read(100)
end
def input_finished?
@contents[@readPointer] == nil
end
end
def setup
@io = TestAbstractInputStream.new(TEST_STRING)
end
def test_gets
assert_equal(TEST_LINES[0], @io.gets)
assert_equal(1, @io.lineno)
assert_equal(TEST_LINES[1], @io.gets)
assert_equal(2, @io.lineno)
assert_equal(TEST_LINES[2], @io.gets)
assert_equal(3, @io.lineno)
assert_equal(nil, @io.gets)
assert_equal(4, @io.lineno)
end
def test_getsMultiCharSeperator
assert_equal("Hell", @io.gets("ll"))
assert_equal("o world#{$/}this is the second l", @io.gets("d l"))
end
def test_each_line
lineNumber=0
@io.each_line {
|line|
assert_equal(TEST_LINES[lineNumber], line)
lineNumber+=1
}
end
def test_readlines
assert_equal(TEST_LINES, @io.readlines)
end
def test_readline
test_gets
begin
@io.readline
fail "EOFError expected"
rescue EOFError
end
end
end
class AbstractOutputStreamTest < Test::Unit::TestCase
class TestOutputStream
include AbstractOutputStream
attr_accessor :buffer
def initialize
@buffer = ""
end
def << (data)
@buffer << data
self
end
end
def setup
@outputStream = TestOutputStream.new
@origCommaSep = $,
@origOutputSep = $\
end
def teardown
$, = @origCommaSep
$\ = @origOutputSep
end
def test_write
count = @outputStream.write("a little string")
assert_equal("a little string", @outputStream.buffer)
assert_equal("a little string".length, count)
count = @outputStream.write(". a little more")
assert_equal("a little string. a little more", @outputStream.buffer)
assert_equal(". a little more".length, count)
end
def test_print
$\ = nil # record separator set to nil
@outputStream.print("hello")
assert_equal("hello", @outputStream.buffer)
@outputStream.print(" world.")
assert_equal("hello world.", @outputStream.buffer)
@outputStream.print(" You ok ", "out ", "there?")
assert_equal("hello world. You ok out there?", @outputStream.buffer)
$\ = "\n"
@outputStream.print
assert_equal("hello world. You ok out there?\n", @outputStream.buffer)
@outputStream.print("I sure hope so!")
assert_equal("hello world. You ok out there?\nI sure hope so!\n", @outputStream.buffer)
$, = "X"
@outputStream.buffer = ""
@outputStream.print("monkey", "duck", "zebra")
assert_equal("monkeyXduckXzebra\n", @outputStream.buffer)
$\ = nil
@outputStream.buffer = ""
@outputStream.print(20)
assert_equal("20", @outputStream.buffer)
end
def test_printf
@outputStream.printf("%d %04x", 123, 123)
assert_equal("123 007b", @outputStream.buffer)
end
def test_putc
@outputStream.putc("A")
assert_equal("A", @outputStream.buffer)
@outputStream.putc(65)
assert_equal("AA", @outputStream.buffer)
end
def test_puts
@outputStream.puts
assert_equal("\n", @outputStream.buffer)
@outputStream.puts("hello", "world")
assert_equal("\nhello\nworld\n", @outputStream.buffer)
@outputStream.buffer = ""
@outputStream.puts("hello\n", "world\n")
assert_equal("hello\nworld\n", @outputStream.buffer)
@outputStream.buffer = ""
@outputStream.puts(["hello\n", "world\n"])
assert_equal("hello\nworld\n", @outputStream.buffer)
@outputStream.buffer = ""
@outputStream.puts(["hello\n", "world\n"], "bingo")
assert_equal("hello\nworld\nbingo\n", @outputStream.buffer)
@outputStream.buffer = ""
@outputStream.puts(16, 20, 50, "hello")
assert_equal("16\n20\n50\nhello\n", @outputStream.buffer)
end
end
# Copyright (C) 2002-2004 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

View file

@ -1,52 +0,0 @@
#!/usr/bin/env ruby
$VERBOSE = true
$: << "../lib"
require 'test/unit'
require 'zip/stdrubyext'
class ModuleTest < Test::Unit::TestCase
def test_select_map
assert_equal([2, 4, 8, 10], [1, 2, 3, 4, 5].select_map { |e| e == 3 ? nil : 2*e })
end
end
class StringExtensionsTest < Test::Unit::TestCase
def test_starts_with
assert("hello".starts_with(""))
assert("hello".starts_with("h"))
assert("hello".starts_with("he"))
assert(! "hello".starts_with("hello there"))
assert(! "hello".starts_with(" he"))
assert_raise(TypeError, "type mismatch: NilClass given") {
"hello".starts_with(nil)
}
end
def test_ends_with
assert("hello".ends_with("o"))
assert("hello".ends_with("lo"))
assert("hello".ends_with("hello"))
assert(!"howdy".ends_with("o"))
assert(!"howdy".ends_with("oy"))
assert(!"howdy".ends_with("howdy doody"))
assert(!"howdy".ends_with("doody howdy"))
end
def test_ensure_end
assert_equal("hello!", "hello!".ensure_end("!"))
assert_equal("hello!", "hello!".ensure_end("o!"))
assert_equal("hello!", "hello".ensure_end("!"))
assert_equal("hello!", "hel".ensure_end("lo!"))
end
end
# Copyright (C) 2002, 2003 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

View file

@ -1,829 +0,0 @@
#!/usr/bin/env ruby
$VERBOSE = true
$: << "../lib"
require 'zip/zipfilesystem'
require 'test/unit'
module ExtraAssertions
def assert_forwarded(anObject, method, retVal, *expectedArgs)
callArgs = nil
setCallArgsProc = proc { |args| callArgs = args }
anObject.instance_eval <<-"end_eval"
alias #{method}_org #{method}
def #{method}(*args)
ObjectSpace._id2ref(#{setCallArgsProc.object_id}).call(args)
ObjectSpace._id2ref(#{retVal.object_id})
end
end_eval
assert_equal(retVal, yield) # Invoke test
assert_equal(expectedArgs, callArgs)
ensure
anObject.instance_eval "alias #{method} #{method}_org"
end
end
include Zip
class ZipFsFileNonmutatingTest < Test::Unit::TestCase
def setup
@zipFile = ZipFile.new("data/zipWithDirs.zip")
end
def teardown
@zipFile.close if @zipFile
end
def test_umask
assert_equal(File.umask, @zipFile.file.umask)
@zipFile.file.umask(0006)
end
def test_exists?
assert(! @zipFile.file.exists?("notAFile"))
assert(@zipFile.file.exists?("file1"))
assert(@zipFile.file.exists?("dir1"))
assert(@zipFile.file.exists?("dir1/"))
assert(@zipFile.file.exists?("dir1/file12"))
assert(@zipFile.file.exist?("dir1/file12")) # notice, tests exist? alias of exists? !
@zipFile.dir.chdir "dir1/"
assert(!@zipFile.file.exists?("file1"))
assert(@zipFile.file.exists?("file12"))
end
def test_open_read
blockCalled = false
@zipFile.file.open("file1", "r") {
|f|
blockCalled = true
assert_equal("this is the entry 'file1' in my test archive!",
f.readline.chomp)
}
assert(blockCalled)
blockCalled = false
@zipFile.dir.chdir "dir2"
@zipFile.file.open("file21", "r") {
|f|
blockCalled = true
assert_equal("this is the entry 'dir2/file21' in my test archive!",
f.readline.chomp)
}
assert(blockCalled)
@zipFile.dir.chdir "/"
assert_raise(Errno::ENOENT) {
@zipFile.file.open("noSuchEntry")
}
begin
is = @zipFile.file.open("file1")
assert_equal("this is the entry 'file1' in my test archive!",
is.readline.chomp)
ensure
is.close if is
end
end
def test_new
begin
is = @zipFile.file.new("file1")
assert_equal("this is the entry 'file1' in my test archive!",
is.readline.chomp)
ensure
is.close if is
end
begin
is = @zipFile.file.new("file1") {
fail "should not call block"
}
ensure
is.close if is
end
end
def test_symlink
assert_raise(NotImplementedError) {
@zipFile.file.symlink("file1", "aSymlink")
}
end
def test_size
assert_raise(Errno::ENOENT) { @zipFile.file.size("notAFile") }
assert_equal(72, @zipFile.file.size("file1"))
assert_equal(0, @zipFile.file.size("dir2/dir21"))
assert_equal(72, @zipFile.file.stat("file1").size)
assert_equal(0, @zipFile.file.stat("dir2/dir21").size)
end
def test_size?
assert_equal(nil, @zipFile.file.size?("notAFile"))
assert_equal(72, @zipFile.file.size?("file1"))
assert_equal(nil, @zipFile.file.size?("dir2/dir21"))
assert_equal(72, @zipFile.file.stat("file1").size?)
assert_equal(nil, @zipFile.file.stat("dir2/dir21").size?)
end
def test_file?
assert(@zipFile.file.file?("file1"))
assert(@zipFile.file.file?("dir2/file21"))
assert(! @zipFile.file.file?("dir1"))
assert(! @zipFile.file.file?("dir1/dir11"))
assert(@zipFile.file.stat("file1").file?)
assert(@zipFile.file.stat("dir2/file21").file?)
assert(! @zipFile.file.stat("dir1").file?)
assert(! @zipFile.file.stat("dir1/dir11").file?)
end
include ExtraAssertions
def test_dirname
assert_forwarded(File, :dirname, "retVal", "a/b/c/d") {
@zipFile.file.dirname("a/b/c/d")
}
end
def test_basename
assert_forwarded(File, :basename, "retVal", "a/b/c/d") {
@zipFile.file.basename("a/b/c/d")
}
end
def test_split
assert_forwarded(File, :split, "retVal", "a/b/c/d") {
@zipFile.file.split("a/b/c/d")
}
end
def test_join
assert_equal("a/b/c", @zipFile.file.join("a/b", "c"))
assert_equal("a/b/c/d", @zipFile.file.join("a/b", "c/d"))
assert_equal("/c/d", @zipFile.file.join("", "c/d"))
assert_equal("a/b/c/d", @zipFile.file.join("a", "b", "c", "d"))
end
def test_utime
t_now = Time.now
t_bak = @zipFile.file.mtime("file1")
@zipFile.file.utime(t_now, "file1")
assert_equal(t_now, @zipFile.file.mtime("file1"))
@zipFile.file.utime(t_bak, "file1")
assert_equal(t_bak, @zipFile.file.mtime("file1"))
end
def assert_always_false(operation)
assert(! @zipFile.file.send(operation, "noSuchFile"))
assert(! @zipFile.file.send(operation, "file1"))
assert(! @zipFile.file.send(operation, "dir1"))
assert(! @zipFile.file.stat("file1").send(operation))
assert(! @zipFile.file.stat("dir1").send(operation))
end
def assert_true_if_entry_exists(operation)
assert(! @zipFile.file.send(operation, "noSuchFile"))
assert(@zipFile.file.send(operation, "file1"))
assert(@zipFile.file.send(operation, "dir1"))
assert(@zipFile.file.stat("file1").send(operation))
assert(@zipFile.file.stat("dir1").send(operation))
end
def test_pipe?
assert_always_false(:pipe?)
end
def test_blockdev?
assert_always_false(:blockdev?)
end
def test_symlink?
assert_always_false(:symlink?)
end
def test_socket?
assert_always_false(:socket?)
end
def test_chardev?
assert_always_false(:chardev?)
end
def test_truncate
assert_raise(StandardError, "truncate not supported") {
@zipFile.file.truncate("file1", 100)
}
end
def assert_e_n_o_e_n_t(operation, args = ["NoSuchFile"])
assert_raise(Errno::ENOENT) {
@zipFile.file.send(operation, *args)
}
end
def test_ftype
assert_e_n_o_e_n_t(:ftype)
assert_equal("file", @zipFile.file.ftype("file1"))
assert_equal("directory", @zipFile.file.ftype("dir1/dir11"))
assert_equal("directory", @zipFile.file.ftype("dir1/dir11/"))
end
def test_link
assert_raise(NotImplementedError) {
@zipFile.file.link("file1", "someOtherString")
}
end
def test_directory?
assert(! @zipFile.file.directory?("notAFile"))
assert(! @zipFile.file.directory?("file1"))
assert(! @zipFile.file.directory?("dir1/file11"))
assert(@zipFile.file.directory?("dir1"))
assert(@zipFile.file.directory?("dir1/"))
assert(@zipFile.file.directory?("dir2/dir21"))
assert(! @zipFile.file.stat("file1").directory?)
assert(! @zipFile.file.stat("dir1/file11").directory?)
assert(@zipFile.file.stat("dir1").directory?)
assert(@zipFile.file.stat("dir1/").directory?)
assert(@zipFile.file.stat("dir2/dir21").directory?)
end
def test_chown
assert_equal(2, @zipFile.file.chown(1,2, "dir1", "file1"))
assert_equal(1, @zipFile.file.stat("dir1").uid)
assert_equal(2, @zipFile.file.stat("dir1").gid)
assert_equal(2, @zipFile.file.chown(nil, nil, "dir1", "file1"))
end
def test_zero?
assert(! @zipFile.file.zero?("notAFile"))
assert(! @zipFile.file.zero?("file1"))
assert(@zipFile.file.zero?("dir1"))
blockCalled = false
ZipFile.open("data/generated/4entry.zip") {
|zf|
blockCalled = true
assert(zf.file.zero?("data/generated/empty.txt"))
}
assert(blockCalled)
assert(! @zipFile.file.stat("file1").zero?)
assert(@zipFile.file.stat("dir1").zero?)
blockCalled = false
ZipFile.open("data/generated/4entry.zip") {
|zf|
blockCalled = true
assert(zf.file.stat("data/generated/empty.txt").zero?)
}
assert(blockCalled)
end
def test_expand_path
ZipFile.open("data/zipWithDirs.zip") {
|zf|
assert_equal("/", zf.file.expand_path("."))
zf.dir.chdir "dir1"
assert_equal("/dir1", zf.file.expand_path("."))
assert_equal("/dir1/file12", zf.file.expand_path("file12"))
assert_equal("/", zf.file.expand_path(".."))
assert_equal("/dir2/dir21", zf.file.expand_path("../dir2/dir21"))
}
end
def test_mtime
assert_equal(Time.at(1027694306),
@zipFile.file.mtime("dir2/file21"))
assert_equal(Time.at(1027690863),
@zipFile.file.mtime("dir2/dir21"))
assert_raise(Errno::ENOENT) {
@zipFile.file.mtime("noSuchEntry")
}
assert_equal(Time.at(1027694306),
@zipFile.file.stat("dir2/file21").mtime)
assert_equal(Time.at(1027690863),
@zipFile.file.stat("dir2/dir21").mtime)
end
def test_ctime
assert_nil(@zipFile.file.ctime("file1"))
assert_nil(@zipFile.file.stat("file1").ctime)
end
def test_atime
assert_nil(@zipFile.file.atime("file1"))
assert_nil(@zipFile.file.stat("file1").atime)
end
def test_readable?
assert(! @zipFile.file.readable?("noSuchFile"))
assert(@zipFile.file.readable?("file1"))
assert(@zipFile.file.readable?("dir1"))
assert(@zipFile.file.stat("file1").readable?)
assert(@zipFile.file.stat("dir1").readable?)
end
def test_readable_real?
assert(! @zipFile.file.readable_real?("noSuchFile"))
assert(@zipFile.file.readable_real?("file1"))
assert(@zipFile.file.readable_real?("dir1"))
assert(@zipFile.file.stat("file1").readable_real?)
assert(@zipFile.file.stat("dir1").readable_real?)
end
def test_writable?
assert(! @zipFile.file.writable?("noSuchFile"))
assert(@zipFile.file.writable?("file1"))
assert(@zipFile.file.writable?("dir1"))
assert(@zipFile.file.stat("file1").writable?)
assert(@zipFile.file.stat("dir1").writable?)
end
def test_writable_real?
assert(! @zipFile.file.writable_real?("noSuchFile"))
assert(@zipFile.file.writable_real?("file1"))
assert(@zipFile.file.writable_real?("dir1"))
assert(@zipFile.file.stat("file1").writable_real?)
assert(@zipFile.file.stat("dir1").writable_real?)
end
def test_executable?
assert(! @zipFile.file.executable?("noSuchFile"))
assert(! @zipFile.file.executable?("file1"))
assert(@zipFile.file.executable?("dir1"))
assert(! @zipFile.file.stat("file1").executable?)
assert(@zipFile.file.stat("dir1").executable?)
end
def test_executable_real?
assert(! @zipFile.file.executable_real?("noSuchFile"))
assert(! @zipFile.file.executable_real?("file1"))
assert(@zipFile.file.executable_real?("dir1"))
assert(! @zipFile.file.stat("file1").executable_real?)
assert(@zipFile.file.stat("dir1").executable_real?)
end
def test_owned?
assert_true_if_entry_exists(:owned?)
end
def test_grpowned?
assert_true_if_entry_exists(:grpowned?)
end
def test_setgid?
assert_always_false(:setgid?)
end
def test_setuid?
assert_always_false(:setgid?)
end
def test_sticky?
assert_always_false(:sticky?)
end
def test_readlink
assert_raise(NotImplementedError) {
@zipFile.file.readlink("someString")
}
end
def test_stat
s = @zipFile.file.stat("file1")
assert(s.kind_of?(File::Stat)) # It pretends
assert_raise(Errno::ENOENT, "No such file or directory - noSuchFile") {
@zipFile.file.stat("noSuchFile")
}
end
def test_lstat
assert(@zipFile.file.lstat("file1").file?)
end
def test_chmod
assert_raise(Errno::ENOENT, "No such file or directory - noSuchFile") {
@zipFile.file.chmod(0644, "file1", "NoSuchFile")
}
assert_equal(2, @zipFile.file.chmod(0644, "file1", "dir1"))
end
def test_pipe
assert_raise(NotImplementedError) {
@zipFile.file.pipe
}
end
def test_foreach
ZipFile.open("data/generated/zipWithDir.zip") {
|zf|
ref = []
File.foreach("data/file1.txt") { |e| ref << e }
index = 0
zf.file.foreach("data/file1.txt") {
|l|
assert_equal(ref[index], l)
index = index.next
}
assert_equal(ref.size, index)
}
ZipFile.open("data/generated/zipWithDir.zip") {
|zf|
ref = []
File.foreach("data/file1.txt", " ") { |e| ref << e }
index = 0
zf.file.foreach("data/file1.txt", " ") {
|l|
assert_equal(ref[index], l)
index = index.next
}
assert_equal(ref.size, index)
}
end
def test_popen
assert_equal(File.popen("ls") { |f| f.read },
@zipFile.file.popen("ls") { |f| f.read })
end
# Can be added later
# def test_select
# fail "implement test"
# end
def test_readlines
ZipFile.open("data/generated/zipWithDir.zip") {
|zf|
assert_equal(File.readlines("data/file1.txt"),
zf.file.readlines("data/file1.txt"))
}
end
def test_read
ZipFile.open("data/generated/zipWithDir.zip") {
|zf|
assert_equal(File.read("data/file1.txt"),
zf.file.read("data/file1.txt"))
}
end
end
class ZipFsFileStatTest < Test::Unit::TestCase
def setup
@zipFile = ZipFile.new("data/zipWithDirs.zip")
end
def teardown
@zipFile.close if @zipFile
end
def test_blocks
assert_equal(nil, @zipFile.file.stat("file1").blocks)
end
def test_ino
assert_equal(0, @zipFile.file.stat("file1").ino)
end
def test_uid
assert_equal(0, @zipFile.file.stat("file1").uid)
end
def test_gid
assert_equal(0, @zipFile.file.stat("file1").gid)
end
def test_ftype
assert_equal("file", @zipFile.file.stat("file1").ftype)
assert_equal("directory", @zipFile.file.stat("dir1").ftype)
end
def test_mode
assert_equal(0600, @zipFile.file.stat("file1").mode & 0777)
assert_equal(0600, @zipFile.file.stat("file1").mode & 0777)
assert_equal(0755, @zipFile.file.stat("dir1").mode & 0777)
assert_equal(0755, @zipFile.file.stat("dir1").mode & 0777)
end
def test_dev
assert_equal(0, @zipFile.file.stat("file1").dev)
end
def test_rdev
assert_equal(0, @zipFile.file.stat("file1").rdev)
end
def test_rdev_major
assert_equal(0, @zipFile.file.stat("file1").rdev_major)
end
def test_rdev_minor
assert_equal(0, @zipFile.file.stat("file1").rdev_minor)
end
def test_nlink
assert_equal(1, @zipFile.file.stat("file1").nlink)
end
def test_blksize
assert_nil(@zipFile.file.stat("file1").blksize)
end
end
class ZipFsFileMutatingTest < Test::Unit::TestCase
TEST_ZIP = "zipWithDirs_copy.zip"
def setup
File.copy("data/zipWithDirs.zip", TEST_ZIP)
end
def teardown
end
def test_delete
do_test_delete_or_unlink(:delete)
end
def test_unlink
do_test_delete_or_unlink(:unlink)
end
def test_open_write
ZipFile.open(TEST_ZIP) {
|zf|
zf.file.open("test_open_write_entry", "w") {
|f|
blockCalled = true
f.write "This is what I'm writing"
}
assert_equal("This is what I'm writing",
zf.file.read("test_open_write_entry"))
# Test with existing entry
zf.file.open("file1", "w") {
|f|
blockCalled = true
f.write "This is what I'm writing too"
}
assert_equal("This is what I'm writing too",
zf.file.read("file1"))
}
end
def test_rename
ZipFile.open(TEST_ZIP) {
|zf|
assert_raise(Errno::ENOENT, "") {
zf.file.rename("NoSuchFile", "bimse")
}
zf.file.rename("file1", "newNameForFile1")
}
ZipFile.open(TEST_ZIP) {
|zf|
assert(! zf.file.exists?("file1"))
assert(zf.file.exists?("newNameForFile1"))
}
end
def do_test_delete_or_unlink(symbol)
ZipFile.open(TEST_ZIP) {
|zf|
assert(zf.file.exists?("dir2/dir21/dir221/file2221"))
zf.file.send(symbol, "dir2/dir21/dir221/file2221")
assert(! zf.file.exists?("dir2/dir21/dir221/file2221"))
assert(zf.file.exists?("dir1/file11"))
assert(zf.file.exists?("dir1/file12"))
zf.file.send(symbol, "dir1/file11", "dir1/file12")
assert(! zf.file.exists?("dir1/file11"))
assert(! zf.file.exists?("dir1/file12"))
assert_raise(Errno::ENOENT) { zf.file.send(symbol, "noSuchFile") }
assert_raise(Errno::EISDIR) { zf.file.send(symbol, "dir1/dir11") }
assert_raise(Errno::EISDIR) { zf.file.send(symbol, "dir1/dir11/") }
}
ZipFile.open(TEST_ZIP) {
|zf|
assert(! zf.file.exists?("dir2/dir21/dir221/file2221"))
assert(! zf.file.exists?("dir1/file11"))
assert(! zf.file.exists?("dir1/file12"))
assert(zf.file.exists?("dir1/dir11"))
assert(zf.file.exists?("dir1/dir11/"))
}
end
end
class ZipFsDirectoryTest < Test::Unit::TestCase
TEST_ZIP = "zipWithDirs_copy.zip"
def setup
File.copy("data/zipWithDirs.zip", TEST_ZIP)
end
def test_delete
ZipFile.open(TEST_ZIP) {
|zf|
assert_raise(Errno::ENOENT, "No such file or directory - NoSuchFile.txt") {
zf.dir.delete("NoSuchFile.txt")
}
assert_raise(Errno::EINVAL, "Invalid argument - file1") {
zf.dir.delete("file1")
}
assert(zf.file.exists?("dir1"))
zf.dir.delete("dir1")
assert(! zf.file.exists?("dir1"))
}
end
def test_mkdir
ZipFile.open(TEST_ZIP) {
|zf|
assert_raise(Errno::EEXIST, "File exists - dir1") {
zf.dir.mkdir("file1")
}
assert_raise(Errno::EEXIST, "File exists - dir1") {
zf.dir.mkdir("dir1")
}
assert(!zf.file.exists?("newDir"))
zf.dir.mkdir("newDir")
assert(zf.file.directory?("newDir"))
assert(!zf.file.exists?("newDir2"))
zf.dir.mkdir("newDir2", 3485)
assert(zf.file.directory?("newDir2"))
}
end
def test_pwd_chdir_entries
ZipFile.open(TEST_ZIP) {
|zf|
assert_equal("/", zf.dir.pwd)
assert_raise(Errno::ENOENT, "No such file or directory - no such dir") {
zf.dir.chdir "no such dir"
}
assert_raise(Errno::EINVAL, "Invalid argument - file1") {
zf.dir.chdir "file1"
}
assert_equal(["dir1", "dir2", "file1"].sort, zf.dir.entries(".").sort)
zf.dir.chdir "dir1"
assert_equal("/dir1", zf.dir.pwd)
assert_equal(["dir11", "file11", "file12"], zf.dir.entries(".").sort)
zf.dir.chdir "../dir2/dir21"
assert_equal("/dir2/dir21", zf.dir.pwd)
assert_equal(["dir221"].sort, zf.dir.entries(".").sort)
}
end
def test_foreach
ZipFile.open(TEST_ZIP) {
|zf|
blockCalled = false
assert_raise(Errno::ENOENT, "No such file or directory - noSuchDir") {
zf.dir.foreach("noSuchDir") { |e| blockCalled = true }
}
assert(! blockCalled)
assert_raise(Errno::ENOTDIR, "Not a directory - file1") {
zf.dir.foreach("file1") { |e| blockCalled = true }
}
assert(! blockCalled)
entries = []
zf.dir.foreach(".") { |e| entries << e }
assert_equal(["dir1", "dir2", "file1"].sort, entries.sort)
entries = []
zf.dir.foreach("dir1") { |e| entries << e }
assert_equal(["dir11", "file11", "file12"], entries.sort)
}
end
def test_chroot
ZipFile.open(TEST_ZIP) {
|zf|
assert_raise(NotImplementedError) {
zf.dir.chroot
}
}
end
# Globbing not supported yet
#def test_glob
# # test alias []-operator too
# fail "implement test"
#end
def test_open_new
ZipFile.open(TEST_ZIP) {
|zf|
assert_raise(Errno::ENOTDIR, "Not a directory - file1") {
zf.dir.new("file1")
}
assert_raise(Errno::ENOENT, "No such file or directory - noSuchFile") {
zf.dir.new("noSuchFile")
}
d = zf.dir.new(".")
assert_equal(["file1", "dir1", "dir2"].sort, d.entries.sort)
d.close
zf.dir.open("dir1") {
|d|
assert_equal(["dir11", "file11", "file12"].sort, d.entries.sort)
}
}
end
end
class ZipFsDirIteratorTest < Test::Unit::TestCase
FILENAME_ARRAY = [ "f1", "f2", "f3", "f4", "f5", "f6" ]
def setup
@dirIt = ZipFileSystem::ZipFsDirIterator.new(FILENAME_ARRAY)
end
def test_close
@dirIt.close
assert_raise(IOError, "closed directory") {
@dirIt.each { |e| p e }
}
assert_raise(IOError, "closed directory") {
@dirIt.read
}
assert_raise(IOError, "closed directory") {
@dirIt.rewind
}
assert_raise(IOError, "closed directory") {
@dirIt.seek(0)
}
assert_raise(IOError, "closed directory") {
@dirIt.tell
}
end
def test_each
# Tested through Enumerable.entries
assert_equal(FILENAME_ARRAY, @dirIt.entries)
end
def test_read
FILENAME_ARRAY.size.times {
|i|
assert_equal(FILENAME_ARRAY[i], @dirIt.read)
}
end
def test_rewind
@dirIt.read
@dirIt.read
assert_equal(FILENAME_ARRAY[2], @dirIt.read)
@dirIt.rewind
assert_equal(FILENAME_ARRAY[0], @dirIt.read)
end
def test_tell_seek
@dirIt.read
@dirIt.read
pos = @dirIt.tell
valAtPos = @dirIt.read
@dirIt.read
@dirIt.seek(pos)
assert_equal(valAtPos, @dirIt.read)
end
end
# Copyright (C) 2002, 2003 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

View file

@ -1,43 +0,0 @@
#!/usr/bin/env ruby
$VERBOSE = true
$: << "../lib"
require 'test/unit'
require 'zip/ziprequire'
$: << 'data/rubycode.zip' << 'data/rubycode2.zip'
class ZipRequireTest < Test::Unit::TestCase
def test_require
assert(require('data/notzippedruby'))
assert(!require('data/notzippedruby'))
assert(require('zippedruby1'))
assert(!require('zippedruby1'))
assert(require('zippedruby2'))
assert(!require('zippedruby2'))
assert(require('zippedruby3'))
assert(!require('zippedruby3'))
c1 = NotZippedRuby.new
assert(c1.returnTrue)
assert(ZippedRuby1.returnTrue)
assert(!ZippedRuby2.returnFalse)
assert_equal(4, ZippedRuby3.multiplyValues(2, 2))
end
def test_get_resource
get_resource("aResource.txt") {
|f|
assert_equal("Nothing exciting in this file!", f.read)
}
end
end
# Copyright (C) 2002 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

File diff suppressed because it is too large Load diff