Permalink
Browse files

First pass at reorganizing the Ruby PDF Tools hierarchy.

  • Loading branch information...
1 parent 37a61ec commit 77c5919f45079f273be6bf390bb481dc3f4a7939 austin committed Feb 7, 2007
Sorry, we could not display the entire diff because it was too big.
View
110 ChangeLog
@@ -0,0 +1,110 @@
+= PDF::Writer Change Log
+
+== PDF::Writer 1.1.3: September 9, 2005
+* Fixed #2356 submitted by Matthew Thill. Margins set by the various margins
+ methods would behave incorrectly.
+
+== PDF::Writer 1.1.2: August 25, 2005
+* Thomas Gantner <thomas.gantner@gmx.net> found a problem with the
+ interpretation of the placement of page numbers and provided a patch.
+ Thanks!
+* Thomas also reported a problem with an inability to place page numbering on
+ the first page of a document, as well as strange results from not providing
+ a starting page number. This has been fixed. Also reported as #2204.
+* Modified PDF::Writer requirements to require color-tools version 1.3.0 or
+ later. This necessitates that Color constants be changed to Color::RGB
+ constants.
+* Updated supporting library documentation to include information on
+ color-tools version 1.3.
+* Fixed a bug with Graphics#transform_matrix truncating one of the transform
+ parameters.
+* Applied a fix to PDF::SimpleTable submitted by Mike Leddy in #2129 on the
+ RubyForge tracker.
+* Applied a partial fix for PNG with index-transparency provided by Marc
+ Vleugels in #2245 on the RubyForge tracker. NOTE: This does not solve the
+ transparency problem; at this point, PDF::Writer cannot be said to support
+ PNGs with transparency. This will be fixed in a later version of
+ PDF::Writer.
+
+== PDF::Writer 1.1.1: July 1, 2005
+* Fixed the packaging process; the .tar.gz files will no longer corrupt the
+ images.
+* Added the images and the manual (both raw and generated) to the demo
+ package.
+
+== PDF::Writer 1.1.0: June 29, 2005
+ NOTE: The first two changes are INCOMPATIBLE with previous versions of
+ PDF::Writer. If you find that your text is showing up at odd angles, negate
+ the value. That is, if you have 90 as your angle, use -90 (or 270) as your
+ angle and it will work like it used to.
+
+* Axis transformations in PDF::Writer::Graphics have been fixed.
+* Text axis transformation in PDF::Writer#add_text has been fixed.
+* Changed #text_width and #text_line_width so that the text value is the
+ first parameter and the size parameter is second, and is optional. The code
+ warns about it now, but it will break in PDF::Writer 2.0.
+* Changed #add_text and #add_text_wrap so that the text parameter is before
+ the now-optional size parameter. The code warns about it now, but it will
+ break in PDF::Writer 2.0.
+* Added #transform_matrix.
+* Fixed compression. NOTE: Compression must be set early in the documentation
+ process, or only some items will be compressed in the document. The various
+ #save_as methods have been changed to reflect this fact.
+* Enabled the placement of encoding differences dictionaries in the resulting
+ PDF document. This change should be considered experimental.
+* Added TTF licence checking. The embedding of a file not licenced for
+ inclusion in a document will continue, but a warning will be output to
+ standard error. This code has been gakked from FPDF (http://www.fpdf.org).
+* Properly supporting symbolic font flags now.
+* Added support and documentation for a separately downloadable demo package.
+* Expanded the installation documentation.
+* Added the ability to make images clickable links with any of the three
+ image insertion methods.
+
+== PDF::Writer 1.0.1: June 13, 2005
+* Fixed a few minor gem issues.
+* Renamed bin/manual to bin/techbook.
+* Fixed the manual.pwd locator for the default install.
+
+== PDF::Writer 1.0.0: June 12, 2005
+* Integrated ezwriter.rb functionality with writer.rb.
+* Factored out some functionality into modules and classes.
+* Added CMYK colour support to JPEG images.
+* Uses Color::CMYK (from color-utils) to provide CMYK support to drawing
+ capabilities.
+* Simplified the image API significantly.
+* Modified image support to properly handle full image flipping.
+* Fixed several multi-column issues.
+* Fixed a bug where new pages automatically started by overflowing text may
+ have resulted in writing the first line of text above the top margin. This
+ may need further testing and probably causes problems with column handling.
+* Fixed some page numbering issues.
+* Added several demos, including Ruby Quick Reference Sheets.
+* Scrubbed the API.
+* Updated the documentation.
+* Changed installer to setup.rb 3.3.1-modified.
+* Applied an image resize patch; the image will be resized manually before
+ checking to see if a new page is required. Thanks to Leslie Hensley.
+* Fixed a bug where entities would generate the width specified for the
+ component characters, not the represented characters.
+* Fixed a performance bug. Thanks again to Leslie Hensley.
+
+== PDF::Writer 0.1.2: CVS only
+* Fixed a problem with the improper reading of character numbers from .afm
+ files that are not default files. Other font issues remain but will be fixed
+ at a later date.
+
+== PDF::Writer 0.1.0: September, 2003
+* Initial technology preview.
+
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+# vim: sts=2 sw=2 ts=4 et ai tw=77
View
44 Demo-README
@@ -0,0 +1,44 @@
+= PDF::Writer Demo Programs
+This package is a collection of demo programs for PDF::Writer for Ruby version
+1.1.3, intended for users of the RubyGems package, because the demo programs
+are not easily accessible. This package includes:
+
+manual.pwd:: The text version of the PDF manual.
+manual.pdf:: A pregenerated version of the PDF manual.
+chunkybacon.rb:: A simple program to insert three images and two lines of
+ text
+code.rb:: An example of a custom text formatting tag. Note that this
+ tag doesn't *quite* work as it should because of an as-yet
+ unidentified bug in PDF::Writer's tag handling code.
+colornames.rb:: A program to generate colour names known to the color-tools
+ package.
+demo.rb:: Generates gradients and coloured text.
+gettysburg.rb:: Creates a PDF with the Gettysburg Address wrapped in a
+ rounded rectangle.
+hello.rb:: A simple "Hello, Ruby" application for PDF::Writer.
+individual-i.rb:: An example of drawing a vector graphic with PDF::Writer,
+ translated from the Individual I website's EPS version of
+ the logo.
+pac.rb:: A vector graphics image based on a famous video game.
+pagenumber.rb:: An example for showing PDF::Writer's page numbering.
+qr-language.rb:: Generates a quick reference sheet for the Ruby language.
+ Based on Ryan Davis's quick reference sheet.
+qr-library.rb:: Generates a quick reference sheet for the Ruby standard
+ library. Based on Ryan Davis's quick reference sheet.
+
+If PDF::Writer has been installed with RubyGems, then the demos will need to
+be run explicitly referencing RubyGems:
+
+ % ruby -rubygems chunkybacon.rb
+
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+# vim: sts=2 sw=2 ts=4 et ai tw=77
View
30 Install
@@ -0,0 +1,30 @@
+PDF::Writer requires both Transaction::Simple 1.3.0 or later and color-tools
+1.3.0 or later.
+
+Transaction::Simple:: http://rubyforge.org/frs/?group_id=295
+color-tools:: http://rubyforge.org/frs/?group_id=81
+
+Once these packages are installed, PDF::Writer can be installed with:
+
+ % ruby setup.rb
+
+Alternatively, you can use the RubyGems version of PDF::Writer available as
+pdf-writer-1.1.3.gem from the usual sources. The gem knows its dependencies
+on Transaction::Simple and color-tools and offers to install them.
+
+If you are using the RubyGems version of PDF::Writer, it is recommended that
+you download the demo programs from the RubyForge site for PDF::Writer.
+
+PDF::Writer:: http://rubyforge.org/projects/ruby-pdf/
+
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+# vim: sts=2 sw=2 ts=4 et ai tw=77
View
125 LICENCE
@@ -0,0 +1,125 @@
+= PDF::Writer for Ruby
+Homepage:: http://rubyforge.org/projects/ruby-pdf/
+Copyright:: Copyright � 2003�2005 Austin Ziegler.
+Summary:: MIT-style
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+* The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+== Works Included Under Other Licences
+=== pdf/writer/graphics/imageinfo.rb
+PDF::Writer includes a derivative of Keisuke Minami's ImageSize library,
+which can be found at rubycgi[http://www.rubycgi.org/tools/index.en.htm].
+This work�and only this or other named works�may be treated as under the Ruby
+licensing scheme (GPL 2 or later, Ruby's licence) as well as the overall
+PDF::Writer licence.
+
+=== Ruby Quick Reference Sheets
+PDF::Writer has demo programs that will create Quick Reference cards for
+Ruby. The content and output of these programs is copyright 2003�2005 Ryan
+Davis and is licensed under the Creative Commons
+Attribution-NonCommercial-ShareAlike[http://creativecommons.org/licenses/by-nc-sa/2.0/]
+licence.
+
+=== Images from "Why's (Poignant) Guide to Ruby"
+One of the demo programs uses images originally from "Why's (Poignant) Guide
+to Ruby"[http://poignantguide.net/ruby], with permission. These immages are
+released under the Creative Commons
+Attributions ShareAlike[http://creativecommons.org/licenses/by-sa/2.0/]
+licence.
+
+=== Adobe PostScript AFM Files
+pdf/writer/fonts/MustRead.html and the 14 PostScript(R) AFM files it
+accompanies may be used, copied, and distributed for any purpose and without
+charge, with or without modification, provided that all copyright notices are
+retained; that the AFM files are not distributed without this file; that all
+modifications to this file or any of the AFM files are prominently noted in
+the modified file(s); and that this paragraph is not modified. Adobe Systems
+has no responsibility or obligation to support the use of the AFM files.
+
+== Other Credits
+=== PDF::Writer
+PDF::Writer is based originally on the R & OS PDF class for
+PHP[http://www.ros.co.nz/pdf/], which is released as public domain.
+
+=== Standard Deviation Chart
+The standard deviation chart (pdf/charts/stddev.rb) class is based on
+work by Cris Ewing[mailto:cewing@u.washington.edu] of the University of
+Washington School of Medicine, originally created for the R & OS PDF class
+for PHP. He has graciously donated the code for PDF::Writer for Ruby.
+
+=== bluesmoke.jpg
+The logo image for PDF::Writer, bluesmoke.jpg, is modified from a picture
+taken by Matthew "TheSaint" Bowden[mailto:matthewbowden@gmail.com] and is
+available on the stock.xchng(R) at
+<http://www.sxc.hu/browse.phtml?f=view&id=275430>. Many thanks to Matthew for
+the use of this image.
+
+== Patents Covering the Adobe PDF Format
+=== ADOBE PATENTS
+This software is based on Adobe's PDF Reference, Third Edition, version 1.6.
+There may be limitations on the use of this library based on patent
+restrictions from Adobe. See bewlow for more information.
+
+=== UNISYS LZW PATENT
+This software does not fully conform to the Adobe PDF specification because
+no support for LZW is included in this software. At the time of original
+development of this software (2003), the Unisys LZW patent was still in
+effect outside of the United States. This will be modified in a future
+version of this software.
+
+== Patent Clarification Notice: Reading and Writing PDF Files
+Adobe has a number of patents covering technology that is disclosed in the
+Portable Document Format (PDF) Specification, version 1.6 and later, as
+documented in PDF Reference and associated Technical Notes (the
+"Specification". Adobe desires to promote the use of PDF for information
+interchange among diverse products and applications.
+
+Accordingly, the following patents are licensed on a royalty-free, non-
+exclusive basis for the term of each patent and for the sole purpose of
+developing software that produces, consumes, and interprets PDF files that
+are compliant with the Specification:
+
+U.S. Patent Numbers: 5,634,064; 5,737,599; 5,781,785; 5,819,301; 6,028,583;
+6,289,364; 6,421,460
+
+In addition, the following patent is licensed on a royalty-free, non-
+exclusive basis for its term and for the sole purpose of developing software
+that produces PDF files that are compliant with the Specification
+(specifically excluding, however, software that consumes and/or interprets
+PDF files):
+
+U.S. Patent Numbers: 5,860,074
+
+The above licenses are limited to only those rights required to implement the
+Specification and no others. That is to say, Adobe grants only those rights
+in the above patent(s) necessarily practiced to implement the Specification,
+and does not grant any rights not required to implement the Specification.
+The licenses do not grant the right to practice any patent covering other
+technologies, such as implementation techniques that are not explicitly
+disclosed in the Specification, nor does it allow the use of any patented
+feature for any purpose other than as set forth in the applicable license
+grant. Adobe has other patents in various fields, none of which are hereby
+licensed.
+
+$Id$
+# vim: sts=2 sw=2 ts=4 et ai tw=77
View
33 README
@@ -0,0 +1,33 @@
+= PDF::Writer for Ruby
+This library provides the ability to create PDF documents using only native
+Ruby libraries. There are several demo programs available in the demo/
+directory. The canonical documentation for PDF::Writer is "manual.pdf", which
+can be generated using bin/techbook (just "techbook" for RubyGem users) and
+the manual file "manual.pwd".
+
+Homepage:: http://rubyforge.org/projects/ruby-pdf/
+Copyright:: 2003�2005, Austin Ziegler
+
+This software is based on Adobe's PDF Reference, Fifth Edition, version 1.6.
+This and earlier editions are available from Adobe's PDF developer
+website[http://partners.adobe.com/public/developer/pdf/index_reference.html].
+
+== LICENCE NOTES
+Please read the file LICENCE for licensing restrictions on this library, as
+well as important patent considerations.
+
+== Requirements
+PDF::Writer requires Ruby 1.8.2 or better, color-tools 1.3.0 or better, and
+Transaction::Simple 1.3.0 or better.
+
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+# vim: sts=2 sw=2 ts=4 et ai tw=77
View
277 Rakefile
@@ -0,0 +1,277 @@
+#! /usr/bin/env rake
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+$LOAD_PATH.unshift('lib')
+
+require 'meta_project'
+require 'rake/gempackagetask'
+require 'rake/contrib/xforge'
+require 'rake/clean'
+
+require 'gmailer'
+
+require 'pdf/writer'
+require 'pdf/techbook'
+
+require 'archive/tar/minitar'
+require 'zlib'
+
+DISTDIR = "pdf-writer-#{PDF::Writer::VERSION}"
+TARDIST = "../#{DISTDIR}.tar.gz"
+DEMODIR = "pdf-writer-demo-#{PDF::Writer::VERSION}"
+DEMOTAR = "../#{DEMODIR}.tar.gz"
+
+DATE_RE = %r<(\d{4})[./-]?(\d{2})[./-]?(\d{2})(?:[\sT]?(\d{2})[:.]?(\d{2})[:.]?(\d{2})?)?>
+
+if ENV['RELEASE_DATE']
+ year, month, day, hour, minute, second = DATE_RE.match(ENV['RELEASE_DATE']).captures
+ year ||= 0
+ month ||= 0
+ day ||= 0
+ hour ||= 0
+ minute ||= 0
+ second ||= 0
+ ReleaseDate = Time.mktime(year, month, day, hour, minute, second)
+else
+ ReleaseDate = nil
+end
+
+task :test do |t|
+ require 'test/unit/testsuite'
+ require 'test/unit/ui/console/testrunner'
+
+ runner = Test::Unit::UI::Console::TestRunner
+
+ $LOAD_PATH.unshift('tests')
+ $stderr.puts "Checking for test cases:" if t.verbose
+ Dir['tests/tc_*.rb'].each do |testcase|
+ $stderr.puts "\t#{testcase}" if t.verbose
+ load testcase
+ end
+
+ suite = Test::Unit::TestSuite.new("PDF::Writer")
+
+ ObjectSpace.each_object(Class) do |testcase|
+ suite << testcase.suite if testcase < Test::Unit::TestCase
+ end
+
+ runner.run(suite)
+end
+
+spec = eval(File.read("pdf-writer.gemspec"))
+spec.version = PDF::Writer::VERSION
+desc "Build the RubyGem for PDF::Writer"
+task :gem => [ :test ]
+Rake::GemPackageTask.new(spec) do |g|
+ g.need_tar = false
+ g.need_zip = false
+ g.package_dir = ".."
+end
+
+desc "Look for TODO and FIXME tags in the code"
+task :todo do
+ rx = %r{#.*(FIXME|TODO|TBD|DEPRECATED)}
+ Pathname.new(File.dirname(__FILE__)).egrep(rx) do |match|
+ puts match
+ end
+end
+
+desc "Build the PDF::Writer manual.pdf"
+task :manual do
+ begin
+ PDF::TechBook.run %w(-z)
+ rescue Exception => ex
+ puts ex, $!, $?
+ end
+end
+
+desc "Build a PDF::Writer demo distribution .tar.gz."
+task :demotar => [ :manual, DEMOTAR ]
+file DEMOTAR do |t|
+ current = File.basename(Dir.pwd)
+ Dir.chdir("..") do
+ begin
+ files = %W(manual.pwd manual.pdf demo/**/* Demo-README LICENCE images/**/*)
+ files = FileList[files.map { |file| File.join(current, file) }].to_a
+ files.map! do |dd|
+ ddnew = dd.gsub(/^#{current}/, DEMODIR).gsub(%r{demo/}, '')
+ ddnew.gsub!(/Demo-README/, 'README')
+ mtime = ReleaseDate || File.stat(dd).mtime
+ if File.directory?(dd)
+ { :name => ddnew, :mode => 0755, :dir => true, :mtime => mtime }
+ else
+ if dd =~ %r{bin/}
+ mode = 0755
+ else
+ mode = 0644
+ end
+ data = File.open(dd, "rb") { |ff| ff.read }
+ data.gsub!(%r{../images/}, 'images/') if ddnew =~ /\.rb$/
+ { :name => ddnew, :mode => mode, :data => data, :size => data.size,
+ :mtime => mtime }
+ end
+ end
+
+ ff = File.open(t.name.gsub(%r{^\.\./}o, ''), "wb")
+ gz = Zlib::GzipWriter.new(ff)
+ tw = Archive::Tar::Minitar::Writer.new(gz)
+
+ files.each do |entry|
+ if entry[:dir]
+ tw.mkdir(entry[:name], entry)
+ else
+ tw.add_file_simple(entry[:name], entry) { |os| os.write(entry[:data]) }
+ end
+ end
+ ensure
+ tw.close if tw
+ gz.close if gz
+ end
+ end
+end
+
+desc "Build a PDF::Writer .tar.gz distribution."
+task :tar => [ TARDIST ]
+file TARDIST => [ :test ] do |t|
+ current = File.basename(Dir.pwd)
+ Dir.chdir("..") do
+ begin
+ files = %W(bin/**/* lib/**/* demo/**/* images/**/* ChangeLog README
+ LICENCE setup.rb pre-setup.rb metaconfig manual.pwd)
+ files = FileList[files.map { |file| File.join(current, file) }].to_a
+ files.map! do |dd|
+ ddnew = dd.gsub(/^#{current}/, DISTDIR)
+ mtime = ReleaseDate || File.stat(dd).mtime
+ if File.directory?(dd)
+ { :name => ddnew, :mode => 0755, :dir => true, :mtime => mtime }
+ else
+ if dd =~ %r{bin/}
+ mode = 0755
+ else
+ mode = 0644
+ end
+ data = File.open(dd, "rb") { |ff| ff.read }
+ { :name => ddnew, :mode => mode, :data => data, :size => data.size,
+ :mtime => mtime }
+ end
+ end
+
+ ff = File.open(t.name.gsub(%r{^\.\./}o, ''), "wb")
+ gz = Zlib::GzipWriter.new(ff)
+ tw = Archive::Tar::Minitar::Writer.new(gz)
+
+ files.each do |entry|
+ if entry[:dir]
+ tw.mkdir(entry[:name], entry)
+ else
+ tw.add_file_simple(entry[:name], entry) { |os| os.write(entry[:data]) }
+ end
+ end
+ ensure
+ tw.close if tw
+ gz.close if gz
+ end
+ end
+end
+task TARDIST => [ :test ]
+
+desc "Build the RDoc documentation for PDF::Writer"
+task :docs do
+ require 'rdoc/rdoc'
+ rdoc_options = %w(--title PDF::Writer --main README --line-numbers)
+ files = FileList[*%w(README LICENCE ChangeLog bin/**/*.rb lib/**/*.rb demo/**/*.rb)]
+ rdoc_options += files.to_a
+ RDoc::RDoc.new.document(rdoc_options)
+end
+
+task :verify_rubyforge do
+ raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
+ raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
+end
+
+task :verify_gmail do
+ raise "GMAIL_USER environment variable not set!" unless ENV['GMAIL_USER']
+ raise "GMAIL_PASSWORD environment variable not set!" unless ENV['GMAIL_PASSWORD']
+end
+
+Ruby_PDF = MetaProject::Project::XForge::RubyForge.new('ruby-pdf')
+PKG_VERSION = PDF::Writer::VERSION
+
+desc "Release files on RubyForge."
+task :release_files => [ :verify_rubyforge, :tar, :gem, :demotar ] do
+ release_files = FileList[TARDIST, DEMOTAR, "../#{DISTDIR}.gem"]
+ Rake::XForge::Release.new(Ruby_PDF) do |release|
+ release.user_name = ENV['RUBYFORGE_USER']
+ release.password = ENV['RUBYFORGE_PASSWORD']
+ release.files = release_files.to_a
+ release.release_name = "pdf-writer #{PDF::Writer::VERSION}"
+ release.package_name = "pdf-writer"
+
+ notes = []
+ File.open("README") do |file|
+ file.each do |line|
+ line.chomp!
+ line.gsub!(/^#.*$/, '') and next
+ notes << line
+ end
+ end
+ release.release_notes = notes.join("\n")
+
+ changes = []
+ File.open("ChangeLog") do |file|
+ current = true
+
+ file.each do |line|
+ line.chomp!
+ current = false if current and line =~ /^==/
+ break if line.empty? and not current
+ changes << line
+ end
+ end
+ release.release_changes = changes.join("\n")
+ end
+end
+
+desc "Publish news on RubyForge"
+task :publish_news => [ :verify_rubyforge, :tar, :gem, :demotar] do
+ Rake::XForge::NewsPublisher.new(Ruby_PDF) do |news|
+ news.user_name = ENV['RUBYFORGE_USER']
+ news.password = ENV['RUBYFORGE_PASSWORD']
+ news.subject = "PDF::Writer #{PDF::Writer::VERSION} Released"
+ news.changes_file = nil
+
+ details = []
+ File.open("Release-Announcement") do |file|
+ file.each do |line|
+ line.chomp!
+ break if line =~ /^=/
+ details << line
+ end
+ end
+ news.details = details.join("\n")
+ end
+end
+
+desc "Post a release announcement via GMail."
+#task :email_announcement => [ :verify_gmail, :tar, :gem, :demotar] do
+task :email_announcement => [ :verify_gmail ] do
+ GMailer.connect(ENV["GMAIL_USER"], ENV["GMAIL_PASSWORD"]) do |gmail|
+ gmail.send :to => "ruby-talk@ruby-lang.org",
+ :subject => "[ANN] PDF::Writer #{PDF::Writer::VERSION}",
+ :body => File.read("Release-Announcement")
+ end
+end
+
+desc "Release the latest version."
+task :release => [ :verify_rubyforge, :verify_gmail, :release_files,
+ :publish_news, :email_announcement, :docs ]
+
+desc "Build everything."
+task :default => [ :tar, :gem, :demotar, :docs ]
View
87 Release-Announcement
@@ -0,0 +1,87 @@
+I am pleased to announce the release of PDF::Writer 1.1.3. This release
+fixes margin setting bugs. I again have to thank the wonderful users of
+PDF::Writer:
+
+ * Matthew Thill found a bug with #margins_cm, #margins_mm, and
+ #margins_in. It was reported as #2356 and has been fixed.
+
+= What is PDF::Writer for Ruby?
+It provides the ability to create PDF documents using only native Ruby
+libraries. There are several demo programs available in the demo/
+directory. The canonical documentation for PDF::Writer is the 95-page
+manual "manual.pdf", which can be generated using bin/techbook (just
+"techbook" for RubyGem users) and the manual file "manual.pwd".
+
+Homepage:: http://ruby-pdf.rubyforge.org/pdf-writer/
+Download:: http://rubyforge.org/frs/?group_id=81
+Copyright:: 2003�2005, Austin Ziegler
+
+This software is based on Adobe's PDF Reference, Fifth Edition, version
+1.6. This and earlier editions are available from Adobe's PDF developer
+website[1].
+
+== LICENCE NOTES
+PDF::Writer is generally available under an MIT-style licence with few
+restrictions, but there are subtle restrictions on portions of the
+library, and there are patents for which some rights have been granted
+by Adobe. Please read the file LICENCE[2] for more information.
+
+== Requirements and Installation
+PDF::Writer requires Ruby 1.8.2 or better, color-tools 1.3.0[3] or
+better, and Transaction::Simple 1.3.0[4] or better.
+
+Once these packages are installed, PDF::Writer can be installed with:
+
+ % ruby setup.rb
+
+Alternatively, you can use the RubyGems version of PDF::Writer available
+as pdf-writer-1.1.3.gem from the usual sources. The gem knows its
+dependencies on Transaction::Simple and color-tools and offers to
+install them.
+
+== Demo Programs
+The demo programs are available as a separately downloadable package. If
+PDF::Writer has been installed with RubyGems, then the demos will need to be
+run explicitly referencing RubyGems:
+
+ % ruby -rubygems chunkybacon.rb
+
+== Whet your appetite:
+
+ # This is demo/hello.rb.
+ require 'pdf/writer'
+
+ pdf = PDF::Writer.new
+ pdf.select_font "Times-Roman"
+ pdf.text "Hello, Ruby.", :font_size => 72, :justification => :center
+
+ pdf.save_as("hello.pdf")
+
+ # This is demo/chunkybacon.rb.
+ require 'pdf/writer'
+
+ pdf = PDF::Writer.new
+ pdf.select_font "Times-Roman"
+ pdf.text "Chunky Bacon!!", :font_size => 72, :justification => :center
+
+ i0 = pdf.image "../images/chunkybacon.jpg", :resize => 0.75
+ i1 = pdf.image "../images/chunkybacon.png", :justification => :center,
+ :resize => 0.75
+ pdf.image i0, :justification => :right, :resize => 0.75
+
+ pdf.text "Chunky Bacon!!", :font_size => 72, :justification => :center
+
+ pdf.save_as("chunkybacon.pdf")
+
+== PDF::Writer 1.1.3: September 9, 2005
+* Fixed #2356 submitted by Matthew Thill. Margins set by the various margins
+ methods would behave incorrectly.
+
+-austin
+1: http://partners.adobe.com/public/developer/pdf/index_reference.html
+2: http://ruby-pdf.rubyforge.org/pdf-writer/licence.html
+3: http://rubyforge.org/frs/?group_id=295
+4: http://rubyforge.org/frs/?group_id=81
+--
+Austin Ziegler * halostatue@gmail.com
+ * Alternate: austin@halostatue.ca
View
36 demo/chunkybacon.rb
@@ -0,0 +1,36 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# Images used in this demo are copyright 2004 - 2005 Why the Lucky Stiff
+# and are from "Why's (Poignant) Guide to Ruby" at
+# <http://poignantguide.net/ruby> with permission.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+pdf = PDF::Writer.new
+pdf.select_font "Times-Roman"
+pdf.text "Chunky Bacon!!", :font_size => 72, :justification => :center
+
+i0 = pdf.image "../images/chunkybacon.jpg", :resize => 0.75
+i1 = pdf.image "../images/chunkybacon.png", :justification => :center, :resize => 0.75
+pdf.image i0, :justification => :right, :resize => 0.75
+
+pdf.text "Chunky Bacon!!", :font_size => 72, :justification => :center
+
+pdf.save_as("chunkybacon.pdf")
View
71 demo/code.rb
@@ -0,0 +1,71 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# The code in this file is highly experimental and is not generally ready
+# for use. I can't figure out why the stuff *after* is so far to the right.
+# I'll need to play with the X position some to get it right. This will NOT
+# make it into the 1.0 release. Maybe 1.1 or 1.2.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+pdf = PDF::Writer.new
+pdf.select_font "Times-Roman"
+
+class TagCodeFont
+ FONT_NAME = "Courier"
+ FONT_ENCODING = nil
+ FONT_SIZE_DIFF = 0.9
+
+ class << self
+ attr_accessor :font_name
+
+ def [](pdf, info)
+ @font_name ||= FONT_NAME
+ @font_encoding ||= FONT_ENCODING
+
+ case info[:status]
+ when :start, :start_line
+ @__fontinfo ||= {}
+ @__fontinfo[info[:cbid]] = {
+ :font => pdf.current_font,
+ :base_font => pdf.current_base_font,
+ :info => info
+ }
+
+ pdf.select_font(@font_name, @font_encoding)
+
+ { :font_change => true }
+ when :end, :end_line
+ fi = @__fontinfo[info[:cbid]]
+
+ pdf.font_size = fi[:font_size]
+ pdf.select_font(fi[:base_font])
+ pdf.select_font(fi[:font])
+ end
+ end
+ end
+end
+
+PDF::Writer::TAGS[:pair]["code"] = TagCodeFont
+
+pdf.text "Hello, <c:code>Ruby</c:code>.", :font_size => 72, :justification => :center
+pdf.move_pointer(80)
+pdf.text "This is a longer <c:code>sample of code font text</c:code>. What do you think?", :font_size => 12, :justification => :full
+
+pdf.save_as("code.pdf")
View
47 demo/colornames.rb
@@ -0,0 +1,47 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+require 'color/rgb/metallic'
+
+pdf = PDF::Writer.new
+
+pdf.start_columns 4
+
+colours = Color::RGB.constants.sort
+
+colours.each do |colour|
+ next if colour == "PDF_FORMAT_STR"
+ next if colour == "Metallic"
+ pdf.fill_color Color::RGB.const_get(colour)
+ pdf.text colour, :font_size => 24
+ pdf.fill_color Color::RGB::Black
+ pdf.text colour, :font_size => 12, :justification => :center
+end
+
+colours = Color::RGB::Metallic.constants.sort
+colours.each do |colour|
+ pdf.fill_color Color::RGB::Metallic.const_get(colour)
+ pdf.text colour, :font_size => 24
+ pdf.fill_color Color::RGB::Black
+ pdf.text colour, :font_size => 12, :justification => :center
+end
+
+pdf.save_as "colornames.pdf"
View
73 demo/demo.rb
@@ -0,0 +1,73 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+if ARGV.empty?
+ line = 'Ruby Rocks'
+else
+ line = ARGV.join(" ")
+end
+
+pdf = PDF::Writer.new
+
+ # Do some funky stuff in the background, in a nice light blue, which is
+ # bound to clash with something and some red for the hell of it
+x = 578
+r1 = 25
+
+40.step(1, -3) do |xw|
+ tone = 1.0 - (xw / 40.0) * 0.2
+
+ pdf.stroke_style(PDF::Writer::StrokeStyle.new(xw))
+ pdf.stroke_color(Color::RGB.from_fraction(tone, 1, tone))
+ pdf.circle_at(50, 750, r1).stroke
+ r1 += xw
+end
+
+40.step(1, -3) do |xw|
+ tone = 1.0 - (xw / 40.0) * 0.2
+
+ pdf.stroke_style(PDF::Writer::StrokeStyle.new(xw))
+ pdf.stroke_color(Color::RGB.from_fraction(tone, tone, 1))
+ pdf.line(x, 0, x, 842)
+ x = (x - xw - 2)
+end
+
+pdf.stroke_color(Color::RGB::Black)
+pdf.stroke_style(PDF::Writer::StrokeStyle.new(1))
+pdf.rectangle(20, 20, 558, 802)
+
+y = 800
+50.step(5, -5) do |size|
+ height = pdf.font_height(size)
+ y = y - height
+
+ pdf.add_text(30, y, line, size)
+end
+
+(0...360).step(20) do |angle|
+ pdf.fill_color(Color::RGB.from_fraction(rand, rand, rand))
+
+ pdf.add_text(300 + Math.cos(PDF::Math.deg2rad(angle)) * 40,
+ 300 + Math.sin(PDF::Math.deg2rad(angle)) * 40,
+ line, 20, angle)
+end
+
+pdf.save_as("demo.pdf")
View
66 demo/gettysburg.rb
@@ -0,0 +1,66 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+pdf = PDF::Writer.new
+
+GETTYSBURG = <<-'EOS'
+Four score and seven years ago our fathers brought forth on this
+continent a new nation, conceived in liberty and dedicated to the
+proposition that all men are created equal. Now we are engaged in
+a great civil war, testing whether that nation or any nation so
+conceived and so dedicated can long endure. We are met on a great
+battlefield of that war. We have come to dedicate a portion of
+that field as a final resting-place for those who here gave their
+lives that that nation might live. It is altogether fitting and
+proper that we should do this. But in a larger sense, we cannot
+dedicate, we cannot consecrate, we cannot hallow this ground.
+The brave men, living and dead who struggled here have consecrated
+it far above our poor power to add or detract. The world will
+little note nor long remember what we say here, but it can never
+forget what they did here. It is for us the living rather to be
+dedicated here to the unfinished work which they who fought here
+have thus far so nobly advanced. It is rather for us to be here
+dedicated to the great task remaining before us—that from these
+honored dead we take increased devotion to that cause for which
+they gave the last full measure of devotion—that we here highly
+resolve that these dead shall not have died in vain, that this
+nation under God shall have a new birth of freedom, and that
+government of the people, by the people, for the people shall
+not perish from the earth.
+EOS
+
+gba = GETTYSBURG.split($/).join(" ").squeeze(" ")
+
+pdf.text "The Gettysburg Address\n\n", :font_size => 36,
+ :justification => :center
+
+y0 = pdf.y + 18
+pdf.text gba, :justification => :full, :font_size => 14, :left => 50,
+ :right => 50
+pdf.move_pointer(36)
+pdf.text "U.S. President Abraham Lincoln, 19 November 1863",
+ :justification => :right, :right => 100
+pdf.text "Gettysburg, Pennsylvania", :justification => :right, :right => 100
+
+pdf.rounded_rectangle(pdf.left_margin + 25, y0, pdf.margin_width - 50,
+ y0 - pdf.y + 18, 10).stroke
+
+pdf.save_as("gettysburg.pdf")
View
26 demo/hello.rb
@@ -0,0 +1,26 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+pdf = PDF::Writer.new
+pdf.select_font "Times-Roman"
+pdf.text "Hello, Ruby.", :font_size => 72, :justification => :center
+
+pdf.save_as("hello.pdf")
View
89 demo/individual-i.rb
@@ -0,0 +1,89 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+require 'color/palette/monocontrast'
+
+class IndividualI
+ def initialize(size = 100)
+ @size = size
+ end
+
+ # The size of the "i" in points.
+ attr_accessor :size
+
+ def half_i(pdf)
+ pdf.move_to(0, 82)
+ pdf.line_to(0, 78)
+ pdf.line_to(9, 78)
+ pdf.line_to(9, 28)
+ pdf.line_to(0, 28)
+ pdf.line_to(0, 23)
+ pdf.line_to(18, 23)
+ pdf.line_to(18, 82)
+ pdf.fill
+ end
+ private :half_i
+
+ def draw(pdf, x, y)
+ pdf.save_state
+ pdf.translate_axis(x, y)
+ pdf.scale_axis(1 * (@size / 100.0), -1 * (@size / 100.0))
+
+ pdf.circle_at(20, 10, 7.5)
+ pdf.fill
+
+ half_i(pdf)
+
+ pdf.translate_axis(40, 0)
+ pdf.scale_axis(-1, 1)
+
+ half_i(pdf)
+
+ pdf.restore_state
+ end
+end
+
+pdf = PDF::Writer.new
+ii = IndividualI.new(24)
+
+x = pdf.absolute_left_margin
+y = pdf.absolute_top_margin
+
+bg = Color::RGB.from_fraction(rand, rand, rand)
+fg = Color::RGB.from_fraction(rand, rand, rand)
+pal = Color::Palette::MonoContrast.new(bg, fg)
+
+sz = 24
+
+(-5..5).each do |col|
+ pdf.fill_color pal.background[col]
+ ii.draw(pdf, x, y)
+ ii.size += sz
+ x += sz / 2.0
+ y -= sz / 2.0
+ pdf.fill_color pal.foreground[col]
+ ii.draw(pdf, x, y)
+ x += sz / 2.0
+ y -= sz / 2.0
+ ii.size += sz
+end
+
+pdf.save_as("individual-i.pdf")
View
70 demo/pac.rb
@@ -0,0 +1,70 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+pdf = PDF::Writer.new(:orientation => :landscape)
+
+pdf.fill_color Color::RGB::Black
+pdf.rectangle(0, 0, pdf.page_width, pdf.page_height).fill
+
+ # Wall
+pdf.fill_color Color::RGB::Magenta
+pdf.stroke_color Color::RGB::Cyan
+pdf.rounded_rectangle(20, 500, 750, 20, 10).close_fill_stroke
+pdf.rounded_rectangle(20, 200, 750, 20, 10).close_fill_stroke
+
+ # Body
+pdf.fill_color Color::RGB::Yellow
+pdf.stroke_color Color::RGB::Black
+pdf.circle_at(150, 350, 100).fill_stroke
+
+ # Mouth
+pdf.fill_color Color::RGB::Black
+pdf.segment_at(150, 350, 100, 100, 30, -30).close_fill_stroke
+
+ # Dot
+pdf.fill_color Color::RGB::Yellow
+pdf.circle_at(250, 350, 20).fill_stroke
+pdf.circle_at(300, 350, 10).fill_stroke
+pdf.circle_at(350, 350, 10).fill_stroke
+pdf.circle_at(400, 350, 10).fill_stroke
+pdf.circle_at(450, 350, 10).fill_stroke
+
+pdf.fill_color Color::RGB::Blue
+pdf.stroke_color Color::RGB::Cyan
+pdf.move_to(500, 250)
+pdf.line_to(500, 425)
+pdf.curve_to(550, 475, 600, 475, 650, 425)
+pdf.line_to(650, 250)
+pdf.line_to(625, 275)
+pdf.line_to(600, 250)
+pdf.line_to(575, 275)
+pdf.line_to(550, 250)
+pdf.line_to(525, 275)
+pdf.line_to(500, 250).fill_stroke
+
+pdf.fill_color Color::RGB::White
+pdf.rectangle(525, 375, 25, 25).fill
+pdf.rectangle(575, 375, 25, 25).fill
+pdf.fill_color Color::RGB::Black
+pdf.rectangle(525, 375, 10, 10).fill
+pdf.rectangle(575, 375, 10, 10).fill
+
+pdf.save_as("pac.pdf")
View
79 demo/pagenumber.rb
@@ -0,0 +1,79 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+def grey_page(pdf)
+ @page_num ||= 0
+ @page_num += 1
+ pdf.save_state
+ pdf.fill_color Color::RGB::Grey90
+ x = pdf.margin_x_middle - (pdf.text_width(@page_num, 48) / 2.0)
+ y = pdf.margin_y_middle - (pdf.font_height(48) / 2.0)
+ pdf.add_text(x, y, @page_num, 48)
+ pdf.restore_state
+end
+
+def make_page(pdf)
+ pdf.start_new_page
+ grey_page(pdf)
+end
+
+pdf = PDF::Writer.new(:paper => "A10")
+pdf.margins_pt 0
+pdf.select_font "Helvetica"
+
+x = pdf.absolute_x_middle
+
+grey_page(pdf) # Page 1: 99 of 99
+sa = pdf.start_page_numbering(x, 70, 9, :center, nil, 99)
+pdf.stop_page_numbering(true, :current, sa)
+make_page(pdf) # Page 2: 1 of 2
+sa = pdf.start_page_numbering(x, 60, 9, nil, nil, 1)
+make_page(pdf) # Page 3: 2 of 2
+pdf.stop_page_numbering(true, :current, sa)
+make_page(pdf) # Page 4: blank
+sb = pdf.start_page_numbering(x, 50, 9, :center, nil, 10)
+make_page(pdf) # Page 5: 10 of 12
+make_page(pdf) # Page 6: 11 of 12
+pdf.stop_page_numbering(true, :next, sb)
+make_page(pdf) # Page 7: 12 of 12
+sc = pdf.start_page_numbering(x, 40, 9, nil, nil, 1)
+make_page(pdf) # Page 8: 1 of 3
+make_page(pdf) # Page 9: 2 of 3
+make_page(pdf) # Page 10: 3 of 3
+pdf.stop_page_numbering(true, :current, sc)
+make_page(pdf) # Page 11: blank
+sd = pdf.start_page_numbering(x, 30, 9, nil, nil, 1)
+make_page(pdf) # Page 12: 1 of 6
+make_page(pdf) # Page 13: 2 of 6
+se = pdf.start_page_numbering(x, 20, 9, nil, nil, 5)
+sf = pdf.start_page_numbering(x, 10, 9, :right, nil, 1)
+make_page(pdf) # Page 14: 3 of 6, 5 of 10, 1 of 8
+make_page(pdf) # Page 15: 4 of 6, 6 of 10, 2 of 8
+make_page(pdf) # Page 16: 5 of 6, 7 of 10, 3 of 8
+pdf.stop_page_numbering(true, :next, sd)
+make_page(pdf) # Page 17: 6 of 6, 8 of 10, 4 of 8
+make_page(pdf) # Page 18: 9 of 10, 5 of 8
+pdf.stop_page_numbering(true, :next, se)
+pdf.stop_page_numbering(false, :current, sf)
+make_page(pdf) # Page 19: 10 of 10
+make_page(pdf) # Page 20: blank
+
+pdf.save_as("pagenumber.pdf")
View
580 demo/qr-language.rb
@@ -0,0 +1,580 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# This Quick Reference card program is copyright 2003–2005 Ryan
+# Davis and is licensed under the Creative Commons Attribution
+# NonCommercial
+# ShareAlike[http://creativecommons.org/licenses/by-nc-sa/2.0/] licence.
+#
+# See LICENCE in the main distribution for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+require 'pdf/quickref'
+
+if ARGV[0].nil?
+ paper = "LETTER"
+else
+ if PDF::Writer::PAGE_SIZES.has_key?(ARGV[0])
+ paper = ARGV[0]
+ else
+ puts <<-EOS
+usage: #{File.basename($0)} [paper-size]
+
+ paper-size must be one of the standard PDF::Writer page sizes.
+ Default paper-size is LETTER.
+ EOS
+ exit 0
+ end
+end
+
+PDF::QuickRef.make(paper, 3) do
+ pdf.compressed = true
+ pdf.info.author = "Ryan Davis"
+ pdf.info.title = "Ruby Language Quick Reference"
+ pdf.info.subject = "The Ruby Programming Language"
+
+ self.title_font_size = 13
+ self.h1_font_size = 10
+ self.h2_font_size = 8
+ self.h3_font_size = 7
+ self.h4_font_size = 6
+ self.body_font_size = 5
+
+ enc = {
+ :encoding => 'WinAnsiEncoding',
+ :differences => {
+ 148 => "copyright",
+ }
+ }
+ self.title_font_encoding = enc
+ self.heading_font_encoding = enc
+ self.body_font_encoding = enc
+ self.code_font_encoding = enc
+
+ title "Ruby Language QuickRef"
+ h1 "General Syntax Rules"
+ lines <<-'EOS'
+Comments start with a pound/sharp (#) character and go to EOL.
+Lines between ‘=beginand=end’ are skipped by the interpreter.
+Ruby programs are sequence of expressions.
+Each expression is delimited by semicolons (;) or newlines unless obviously incomplete (e.g. trailing ‘+’).
+Backslashes at the end of line does not terminate expression.
+ EOS
+
+ h1 "Reserved Words"
+ codelines <<-'EOS'
+alias and BEGIN begin break case
+class def defined do else elsif
+END end ensure false for if
+in module next nil not or
+redo rescue retry return self super
+then true undef unless until when
+while yield
+ EOS
+
+ h1 "Types"
+ body <<-'EOS'
+Basic types are numbers, strings, ranges, regexen, symbols, arrays, and
+hashes. Also included are files because they are used so often.
+ EOS
+
+ h2 "Numbers"
+ lines <<-'EOS'
+123 1_234 123.45 1.2e-3
+0xffff (hex) 0b01011 (binary) 0377 (octal)
+?a ASCII character
+?\C-a Control-a
+?\M-a Meta-a
+?\M-\C-a Meta-Control-a
+ EOS
+
+ h2 "Strings"
+ body <<-'EOS'
+In all of the %() cases below, you may use any matching characters or any
+single character for delimiters. %[], %!!, %@@, etc.
+ EOS
+ codelines <<-'EOS'
+'no interpolation'
+"#{interpolation} and backslashes\n"
+%q(no interpolation)
+%Q(interpolation and backslashes)
+%(interpolation and backslashes)
+`echo command interpretation with interpolation and backslashes`
+%x(echo command interpretation with interpolation and backslashes)
+ EOS
+
+ h3 "Backslashes"
+ pre <<-'EOS'
+ \t (tab), \n (newline), \r (carriage return),
+ \f (form feed), \b (backspace), \a (bell),
+ \e (escape), \s (whitespace), \nnn (octal),
+ \xnn (hexadecimal), \cx (control x),
+ \C-x (control x), \M-x (meta x),
+ \M-\C-x (meta control x)
+ EOS
+
+ h3 "Here Docs"
+ pre <<-'EOS'
+ &lt;&lt;identifier # interpolation
+ &lt;&lt;"identifier" # interpolation
+ &lt;&lt;'identifier' # no interpolation
+ &lt;&lt;-identifier # interpolation, indented end
+ &lt;&lt;-"identifier" # interpolation, indented end
+ &lt;&lt;-'identifier' # no interpolation, indented end
+ EOS
+
+ h2 "Symbols"
+ body <<-'EOS'
+A symbol (:symbol) is an immutable name used for identifiers,
+variables, and operators.
+ EOS
+
+ h2 "Ranges"
+ pre <<-'EOS'
+ 1..10
+ 'a'..'z'
+ (1..10) === 5 -&gt; true
+ (1..10) === 15 -&gt; false
+
+ # prints lines starting at 'start' and
+ # ending at 'end'
+ while gets
+ print if /start/../end/
+ end
+
+ class RangeThingy
+ def &lt;=&gt;(rhs)
+ # ...
+ end
+ def succ
+ # ...
+ end
+ end
+ range = RangeThingy.new(lower_bound) .. RangeThingy.new(upper_bound)
+ EOS
+
+ h2 "Regexen"
+ pre <<-'EOS'
+ /normal regex/[xim]
+ %r|alternate form|[xim]
+ Regex.new(pattern, options)
+ EOS
+ pairs <<-'EOS'
+. any character except newline
+[set] any single character of set
+[^set] any single character NOT of set
+* 0 or more previous regular expression
+*? 0 or more previous regular expression (non greedy)
++ 1 or more previous regular expression
++? 1 or more previous regular expression (non greedy)
+? 0 or 1 previous regular expression
+| alternation
+( ) grouping regular expressions
+^ beginning of a line or string
+$ end of a line or string
+#{m,n} at least m but most n previous regular expression
+#{m,n}? at least m but most n previous regular expression (non greedy)
+\A beginning of a string
+\b backspace (0x08, inside [] only)
+\B non-word boundary
+\b word boundary (outside [] only)
+\d digit, same as[0-9]
+\D non-digit
+\S non-whitespace character
+\s whitespace character[ \t\n\r\f]
+\W non-word character
+\w word character[0-9A-Za-z_]
+\z end of a string
+\Z end of a string, or before newline at the end
+(?# ) comment
+(?: ) grouping without backreferences
+(?= ) zero-width positive look-ahead assertion (?! ) zero-width negative look-ahead assertion
+(?ix-ix) turns on/off i/x options, localized in group if any.
+(?ix-ix: ) turns on/off i/x options, localized in non-capturing group.
+ EOS
+
+ h2 "Arrays"
+ pre <<-'EOS'
+ [1, 2, 3]
+ %w(foo bar baz) # no interpolation
+ %W(foo #{bar} baz) # interpolation
+ EOS
+ body <<-'EOS'
+Indexes may be negative, and they index backwards (-1 is the last element).
+ EOS
+
+ h2 "Hashes"
+ pre <<-'EOS'
+ { 1 =&gt; 2, 2 =&gt; 4, 3 =&gt; 6 }
+ { expr =&gt; expr, ... }
+ EOS
+
+ h2 "Files"
+ body "Common methods include:"
+ lines <<-'EOS'
+File.join(p1, p2, ... pN) =&gt; “p1/p2/.../pN” platform independent paths
+File.new(path, mode_string="r") =&gt; file
+File.new(path, mode_num [, perm_num]) =&gt; file
+File.open(filename, mode_string="r") {|file| block} -&gt; nil
+File.open(filename [, mode_num [, perm_num ]]) {|file| block} -&gt; nil
+IO.foreach(path, sepstring=$/) {|line| block}
+IO.readlines(path) =&gt; array
+ EOS
+
+ h3 "Mode Strings"
+ pairs <<-'EOS'
+r Read-only, starts at beginning of file (default mode).
+r+ Read-write, starts at beginning of file.
+w Write-only, truncates existing file to zero length or creates a new file for writing.
+w+ Read-write, truncates existing file to zero length or creates a new file for reading and writing.
+a Write-only, starts at end of file if file exists, otherwise creates a new file for writing.
+a+ Read-write, starts at end of file if file exists, otherwise creates a new file for reading and writing.
+b Binary file mode (may appear with any of the key letters listed above). Only <b>necessary</b> for DOS/Windows.
+ EOS
+
+ h1 "Variables and Constants"
+ pre <<-'EOS'
+ $global_variable
+ @instance_variable
+ [OtherClass::]CONSTANT
+ local_variable
+ EOS
+
+ h1 "Pseudo-variables"
+ pairs <<-'EOS'
+self the receiver of the current method
+nil the sole instance of NilClass (represents false)
+true the sole instance of TrueClass (typical true value)
+false the sole instance of FalseClass (represents false)
+__FILE__ the current source file name.
+__LINE__ the current line number in the source file.
+ EOS
+
+ h1 "Pre-defined Variables"
+ pairs <<-'EOS'
+$! The exception information message set by ‘raise’.
+$@ Array of backtrace of the last exception thrown.
+$&amp; The string matched by the last successful pattern match in this scope.
+$` The string to the left of the last successful match.
+$' The string to the right of the last successful match.
+$+ The last bracket matched by the last successful match.
+$1 The Nth group of the last successful match. May be &gt; 1.
+$~ The information about the last match in the current scope.
+$= The flag for case insensitive, nil by default.
+$/ The input record separator, newline by default.
+$\ The output record separator for the print and IO#write. Default is nil.
+$, The output field separator for the print and Array#join.
+$; The default separator for String#split.
+$. The current input line number of the last file that was read.
+$&lt; The virtual concatenation file of the files given on command line.
+$&gt; The default output for print, printf. $stdout by default.
+$_ The last input line of string by gets or readline.
+$0 Contains the name of the script being executed. May be assignable.
+$* Command line arguments given for the script sans args.
+$$ The process number of the Ruby running this script.
+$? The status of the last executed child process.
+$: Load path for scripts and binary modules by load or require.
+$" The array contains the module names loaded by require.
+$DEBUG The status of the -d switch.
+$FILENAME Current input file from $&lt;. Same as $&lt;.filename.
+$LOAD_PATH The alias to the $:.
+$stderr The current standard error output.
+$stdin The current standard input.
+$stdout The current standard output.
+$VERBOSE The verbose flag, which is set by the -v switch.
+$-0 The alias to $/.
+$-a True if option -a is set. Read-only variable.
+$-d The alias to $DEBUG.
+$-F The alias to $;.
+$-i In in-place-edit mode, this variable holds the extention, otherwise nil.
+$-I The alias to $:.
+$-l True if option -l is set. Read-only variable.
+$-p True if option -p is set. Read-only variable.
+$-v The alias to $VERBOSE.
+ EOS
+
+ h1 "Pre-defined Global Constants"
+ pairs <<-'EOS'
+TRUE The typical true value.
+FALSE The false itself.
+NIL The nil itself.
+STDIN The standard input. The default value for $stdin.
+STDOUT The standard output. The default value for $stdout.
+STDERR The standard error output. The default value for $stderr.
+ENV The hash contains current environment variables.
+ARGF The alias to the $&lt;.
+ARGV The alias to the $*.
+DATA The file object of the script, pointing just after __END__.
+RUBY_VERSION The ruby version string (VERSION was depricated).
+RUBY_RELEASE_DATE The relase date string.
+RUBY_PLATFORM The platform identifier.
+ EOS
+
+ h1 "Expressions"
+ h2 "Terms"
+ body <<-'EOS'
+Terms are expressions that may be a basic type (listed above), a shell
+command, variable reference, constant reference, or method invocation.
+ EOS
+
+ h2 "Operators and Precedence"
+ codelines <<-'EOS'
+::
+[]
+**
+- (unary) + (unary) ! ~
+* / %
++ -
+&lt;&lt; &gt;&gt;
+&amp;
+| ^
+&gt; &gt;= &lt; &lt;=
+&lt;=&gt; == === != =~ !~
+&amp;&amp;
+||
+.. ...
+= (+=, -=, ...)
+not
+and or
+ EOS
+
+ h2 "Control Expressions"
+ pre <<-'EOS'
+if bool-expr [then]
+ body
+elsif bool-expr [then]
+ body
+else
+ body
+end
+
+unless bool-expr [then]
+ body
+else
+ body
+end
+
+expr if bool-expr
+expr unless bool-expr
+
+case target-expr
+ # (comparisons may be regexen)
+ when comparison [, comparison]... [then]
+ body
+ when comparison [, comparison]... [then]
+ body
+ ...
+[else
+ body]
+end
+
+while bool-expr [do]
+ body
+end
+
+until bool-expr [do]
+ body
+end
+
+begin
+ body
+end while bool-expr
+
+begin
+ body
+end until bool-expr
+
+for name[, name]... in expr [do]
+ body
+end
+
+expr.each do | name[, name]... |
+ body
+end
+
+expr while bool-expr
+expr until bool-expr
+ EOS
+ pairs <<-'EOS'
+break terminates loop immediately.
+redo immediately repeats w/o rerunning the condition.
+next starts the next iteration through the loop.
+retry restarts the loop, rerunning the condition.
+ EOS
+
+ h1 "Invoking a Method"
+ body <<-'EOS'
+Nearly everything available in a method invocation is optional, consequently
+the syntax is very difficult to follow. Here are some examples:
+ EOS
+ lines <<-'EOS'
+method
+obj.method
+Class::method
+method(arg1, arg2)
+method(arg1, key1 =&gt; val1, key2 =&gt; val2, aval1, aval2) { block }
+method(arg1, *[arg2, arg3]) becomes: method(arg1, arg2, arg3)
+ EOS
+ pre <<-'EOS'
+call := [receiver ('::' | '.')] name [params] [block]
+params := ( [param]* [, hash] [*arr] [&amp;proc] )
+block := { body } | do body end
+ EOS
+
+ h1 "Defining a Class"
+ body "Class names begin with capital characters."
+ pre <<-'EOS'
+class Identifier [ &lt; Superclass ]; ... ; end
+
+ # Singleton classes, or idioclasses;
+ # add methods to a single instance
+ # obj can be self
+class &lt;&lt; obj; ...; end
+ EOS
+
+ h1 "Defining a Module"
+ body "Module names begin with capital characters."
+ pre "module Identifier; ...; end"
+
+ h1 "Defining a Method"
+ pre <<-'EOS'
+def method_name(arg_list); ...; end
+def expr.method_name(arg_list); ...; end
+ EOS
+ lines <<-'EOS'
+arg_list := ['('] [varname*] ['*' listname] ['&' blockname] [')']
+Arguments may have default values (varname = expr).
+Method definitions may not be nested.
+method_name may be an operator: &lt;=&gt;, ==, ===, =~, &lt;, &lt;=, &gt; &gt;=, +, -, *, /, %, **, &lt;&lt;, &gt;&gt;, ~, +@, -@, [], []= (the last takes two arguments)
+ EOS
+
+ h2 "Access Restriction"
+ pairs <<-'EOS'
+public totally accessable.
+protected accessable only by instances of class and direct descendants. Even through hasA relationships. (see below)
+private accessable only by instances of class.
+ EOS
+ body <<-'EOS'
+Restriction used without arguments set the default access control. Used with
+arguments, sets the access of the named methods and constants.
+ EOS
+ pre <<-'EOS'
+class A
+ protected
+ def protected_method; ...; end
+end
+class B &lt; A
+ public
+ def test_protected
+ myA = A.new
+ myA.protected_method
+ end
+end
+b = B.new.test_protected
+ EOS
+
+ h3 "Accessors"
+ body "Module provides the following utility methods:"
+ pairs <<-'EOS'
+attr_reader &lt;attribute&gt;[, &lt;attribute&gt;]... Creates a read-only accessor for each &lt;attribute&gt;.
+attr_writer &lt;attribute&gt;[, &lt;attribute&gt;]... Creates a write-only accessor for each &lt;attribute&gt;.
+attr &lt;attribute&gt; [, &lt;writable&gt;] Equivalent to "attr_reader &lt;attribute&gt;; attr_writer &lt;attribute&gt; if &lt;writable&gt;"
+attr_accessor &lt;attribute&gt;[, &lt;attribute&gt;]... Equivalent to "attr &lt;attribute&gt;, true" for each argument.
+ EOS
+
+ h2 "Aliasing"
+ pre "alias &lt;old&gt; &lt;new&gt;"
+ body <<-'EOS'
+Creates a new reference to whatever old referred to. old can be any existing
+method, operator, global. It may not be a local, instance, constant, or
+class variable.
+ EOS
+
+ h1 "Blocks, Closures, and Procs"
+ h2 "Blocks/Closures"
+ body "Blocks must follow a method invocation:"
+ pre <<-'EOS'
+invocation do ... end
+invocation do || ... end
+invocation do |arg_list| ... end
+invocation { ... }
+invocation { || ... }
+invocation { |arg_list| ... }
+ EOS
+ lines <<-'EOS'
+Blocks are full closures, remembering their variable context.
+Blocks are invoked via yield and may be passed arguments.
+Block arguments may not have default parameters.
+Brace form ({/}) has higher precedence and will bind to the last parameter if the invocation is made without parentheses.
+do/end form has lower precedence and will bind to the invocation even without parentheses.
+ EOS
+
+ h2 "Proc Objects"
+ body "See class Proc for more information. Created via:"
+ pre <<-'EOS'
+Kernel#proc (or Kernel#lambda)
+Proc#new
+&amp;block argument on a method
+ EOS
+
+ h2 "Exceptions"
+ pre <<-'EOS'
+begin
+ expr
+[ rescue [ exception_class [ =&gt; var ], ... ]
+ expr ]
+[ else
+ expr ]
+[ ensure
+ expr ]
+end
+
+raise [ exception_class, ] [ message ]
+ EOS
+ body <<-'EOS'
+The default exception_class for rescue is StandardError, not Exception.
+Raise without an exception_class raises a RuntimeError. All exception
+classes must inherit from Exception or one of its children (listed below).
+EOS
+ pairs <<-'EOS'
+StandardError LocalJumpError, SystemStackError, ZeroDivisionError, RangeError (FloatDomainError), SecurityError, ThreadError, IOError (EOFError), ArgumentError, IndexError, RuntimeError, TypeError, SystemCallError (Errno::*), RegexpError
+SignalException
+Interrupt
+NoMemoryError
+ScriptError LoadError, NameError, SyntaxError, NotImplementedError
+SystemExit
+ EOS
+
+ h2 "Catch and Throw"
+ pre <<-'EOS'
+catch :label do
+ expr
+ throw :label
+end
+ EOS
+
+ hline
+
+ x = pdf.absolute_right_margin + pdf.font_height(5)
+ y = pdf.absolute_bottom_margin
+ memo = %Q(Copyright © 2005 Ryan Davis with Austin Ziegler. PDF version by Austin Ziegler. Licensed under the <c:alink uri="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-NonCommercial-ShareAlike</c:alink> Licence. The original HTML version is at <c:alink uri="http://www.zenspider.com/Languages/Ruby/QuickRef.html">Zen Spider</c:alink>. Generated by <c:alink uri="http://rubyforge.org/projects/ruby-pdf/">PDF::Writer</c:alink> #{PDF::Writer::VERSION} and PDF::QuickRef #{PDF::QuickRef::VERSION}.)
+ pdf.add_text(x, y, memo, 5, 90)
+ x = pdf.absolute_right_margin - 32
+ y = pdf.absolute_bottom_margin + 24
+
+ save_as "Ruby-Language-QuickRef.pdf"
+end
View
380 demo/qr-library.rb
@@ -0,0 +1,380 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# This Quick Reference card program is copyright 2003–2005 Ryan
+# Davis and is licensed under the Creative Commons Attribution
+# NonCommercial
+# ShareAlike[http://creativecommons.org/licenses/by-nc-sa/2.0/] licence.
+#
+# See LICENCE in the main distribution for full licensing information.
+#
+# $Id$
+#++
+begin
+ require 'pdf/writer'
+rescue LoadError => le
+ if le.message =~ %r{pdf/writer$}
+ $LOAD_PATH.unshift("../lib")
+ require 'pdf/writer'
+ else
+ raise
+ end
+end
+
+require 'pdf/quickref'
+
+if ARGV[0].nil?
+ paper = "LETTER"
+else
+ if PDF::Writer::PAGE_SIZES.has_key?(ARGV[0])
+ paper = ARGV[0]
+ else
+ puts <<-EOS
+usage: #{File.basename($0)} [paper-size]
+
+ paper-size must be one of the standard PDF::Writer page sizes.
+ Default paper-size is LETTER.
+ EOS
+ exit 0
+ end
+end
+
+PDF::QuickRef.make(paper, 3) do
+ pdf.compressed = true
+ pdf.info.author = "Ryan Davis"
+ pdf.info.title = "Ruby Library Quick Reference"
+ pdf.info.subject = "The Ruby Standard Library"
+
+ self.title_font_size = 13
+ self.h1_font_size = 10
+ self.h2_font_size = 8
+ self.h3_font_size = 7
+ self.h4_font_size = 6
+ self.body_font_size = 5
+
+ enc = {
+ :encoding => 'WinAnsiEncoding',
+ :differences => {
+ 148 => "copyright",
+ }
+ }
+ self.title_font_encoding = enc
+ self.heading_font_encoding = enc
+ self.body_font_encoding = enc
+ self.code_font_encoding = enc
+
+ title "Ruby Standard Library QuickRef"
+ h1 "Class Hierarchy"
+ pairs <<-'EOS'
+Object The parent object class. Includes <b>Kernel</b>.
+ Array Ordered integer-indexed collection of any object. Includes <b>Enumerable</b>.
+ Hash An unordered associative collection; keys may be any object. Includes <b>Enumerable</b>.
+ String Holds and manipulates an arbitrary sequence of bytes, typically representing characters. Includes <b>Comparable</b> and <b>Enumerable</b>.
+ Symbol Names in the ruby interpreter.
+ IO Base input/output class for Ruby. Includes <b>Enumerable</b>.
+ File An abstraction of a file object for IO purposes.
+ File::Stat Encapsulates File status information. Includes <b>Comparable</b>.
+ Continuation Holds a return address and execution context, allowing for nonlocal returns to the execution context.
+ Exception The root exception class. StandardError The parent of exceptions that can be rescued without an exception specification. Children are: LocalJumpError, SystemStackError, ZeroDivisionError, RangeError (FloatDomainError), SecurityError, ThreadError, IOError (EOFError), ArgumentError, IndexError, RuntimeError, TypeError, SystemCallError (Errno::*), and RegexpError.
+ SignalException An exception raised from an OS signal.
+ Interrupt An interrupt exception.
+ NoMemoryError The interpreter is out of memory.
+ ScriptError Various script errors. Children are: LoadError, NameError, SyntaxError, and NotImplementedError.
+ SystemExit This exception is raised when Kernel#exit is called.
+ Proc Blocks of code bound to a set of local variables.
+ Numeric The base class that numbers are based on. Includes <b>Comparable</b>.
+ Float Real numbers using the native architecture’s double-precision floating point representation. Includes <b>Precision</b>
+ Integer The abstract class for the two whole number classes, Bignum and Fixnum. Includes <b>Precision</b>.
+ Bignum Holds large integers outside of Fixnum’s range. Autoconverts on overflow and underflow.
+ Fixnum Integer values that can fit in a native word (less one bit). Includes <b>Precision</b>.
+ Regexp Regular expression objects.
+ Module A collection of methods and constants that may be used as a namespace or mixed in to objects, other modules, or classes.
+ Class The base class for object classes.
+ Thread Encapsulates Ruby’s green threads.
+ ThreadGroup Allows the tracking of multiple threads as a group.
+ Method An instance of a method bound to a particular object. Calls are against that object.
+ UnboundMethod An method unassociated with an object, but can be bound against an object.
+ Struct A convenient way to bundle a number of attributes together, using accessor methods, without having to write an explicit class.
+ Time A class for encapsulating the concept of a moment in Time.
+ Dir Directory streams representing directories in the underlying file system.
+ Binding Encapsulate the execution context at some particular place in the code and retain this context for future use.
+ Range Represents an interval (a set of values with a start and an end).
+ MatchData A match for a regular expression. Returned by Regexp#match.
+ TrueClass The class of the global value <b>true</b>.
+ FalseClass The class of the global value <b>false</b>.
+ NilClass The class of the global value <b>nil</b>.
+ EOS
+
+ h1 "Modules"
+ pairs <<-'EOS'
+Comparable Used by classes whose objects may be ordered. Requires the definition of the <b>&lt;=&gt;</b> operator for useful.
+Enumerable Provides collection classes with traversal, search, and sort methods. Must provide <b>each</b>; for some methods, contained objects must implement <b>&lt;=&gt;</b>.
+Errno Errno is created by the Ruby runtime to map operating system errors to Ruby classes. Each error will be a subclass of SystemCallError in the Errno namespace.
+FileTest Implements file test operations similar to those used in File::Stat. It exists as a standalone module, and its methods are also insinuated into the File class.
+GC Provides an interface to Ruby’s mark and sweep garbage collection mechanism.
+Kernel Implements a whole host of useful methods that don’t quite belong to any object.
+Marshal Converts Ruby objects into a byte stream, allowing them to be stored outside the currently active script. This data may subsequently be read and the original objects reconstituted.
+Math Contains module functions for basic trigonometric and transcendental functions.
+ObjectSpace Contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator.
+Precision A mixin for concrete numeric classes with precision; the fineness of approximation of a real number.
+Process A collection of methods used to manipulate processes.
+ EOS
+
+ h1 "Standard Library"
+ pairs <<-'EOS'
+English Include to allow for alternate, less-cryptic global variables names.
+Env, importenv Imports environment variables as global variables.
+Win32API Access to the Win32API directly.
+abbrev Provides Abbrev::abbrev, to calculate the set of unique abbreviations for a given set of strings.
+base64 Provides conversion to and from base64 in the Base64 module. Top-level usage of base64 conversions is deprecated.
+benchmark Provides methods for benchmarking Ruby code.
+bigdecimal Large number arbitrary precision floating point support. Analagous to Bignum.
+bigdecimal/jacobian Computes Jacobian matrix of f at x.
+bigdecimal/ludcmp Provides LUSolve#ludecomp and #lusolve.
+bigdecimal/math Provides BigMath module.
+bigdecimal/newton Solves nonlinear algebraic equation system f = 0 by Newton’s method.
+bigdecimal/nlsolve Solving nonlinear algebraic equation system.
+bigdecimal/util BigDecimal utilities.
+cgi-lib CGI support library implemented as a delegator. Deprecated.
+cgi CGI support library.
+cgi/session Implements session support for CGI.
+cgi/session/pstore Implements session support for CGI using PStore.
+complex Implements the Complex class for complex numbers.
+csv CSV class for generating and parsing delimited data.
+date Provides Date and DateTime classes.
+date/format Provides date formatting utilities.
+delegate Delegation pattern; provides DelegateClass and SimpleDelegator.
+dl Dynamic definition of Ruby interfaces to dynamically loaded libraries. Also uses dl/import, dl/struct, dl/types, and dl/win32.
+drb “Distributed Ruby”. Has several other modules (drb/*).
+e2mmap Exception2MessageMapper module.
+erb Tiny “eRuby” embedded Ruby class.
+eregex Proof of concept extensions to regular expressions.
+fileutils Namespace for file utility methods: copying, moving, deleting, etc.
+finalize Finalizer wrapper methods.
+find Find module to for top-down traversal (and processing) of a set of file paths.
+forwardable Simple delegation of individual methods.
+ftools Extra tools for the file class. Deprecated, use fileutils.
+generator Convert an internal iterator to an external one.
+getoptlong Parses command-line options like the GNU getopt_long().
+getopts Obsolete option parser. getoptlong or optparse is preferred.
+gserver Implements a generic server.
+digest Cryptographic digest support: Digest::MD5 (digest/md5), Digest::RMD160 (digest/rmd160), Digest::SHA1 (digest/sha1), and Digest::SHA2 (digest/sha2) are all supported.
+enumerator Similar to Generator, creates an external enumerator from an enumerable method on an object.
+etc Provides access to user/group information. Called /etc because this information is traditionally in /etc/passwd on Unix.
+fcntl File control constants in the Fcntl namespace.
+nkf Network Kanji conversion filter.
+racc Ruby YACC. Only the runtime may be present in some installations.
+rbconfig Ruby compile-time configuration configuration constants.
+sdbm Ruby interface to SDBM.
+socket Socket support.
+stringio StringIO support; neither a String nor an IO, but a little of both.
+strscan Fast Ruby string scanner.
+syck Fast YAML parser.
+tcltklib Tcl/Tk support.
+tktul Tk utilities.
+win32ole Access to Win32’s OLE controls.
+ipaddr IPAddr class to manipulate IP addresses.
+jcode Helps handle Japanese (EUC/SJIS) strings.
+kconv Helps with Kanji conversion between JIS, SJIS, UTF-8, and UTF-16.
+logger Logger is a simple logging utility.
+mailread Reads a mail file and presents it as a class.
+mathn Extends Ruby with complex, rational, and matrix behaviour with additional behaviour.
+matrix Implements Matrix and Vector classes.
+md5 Deprecated. Use digest/md5 instead.
+mkmf Used to create Makefile for extension modules. Use with <b>ruby -r mkmf extconf.rb</b>.
+monitor An extensible module to monitor an object for changes.
+multi-tk Support for multiple Tk interpreters.
+mutex_m Allows a random object to be treated as a Mutex.
+net/ftp FTP client library.
+net/http HTTP client library.
+net/imap IMAP client library.
+net/pop POP3 client library.
+net/smtp SMTP client library.
+net/telnet Telnet client library.
+observer An implementation of the Observer or Publish/Subscribe pattern.
+open-uri A wrapper for Kernel#open to allow http:// and ftp:// URIs as arguments.
+open3 Spawns a program like popen, but with stderr.
+optparse Command-line option analysis. Preferred option parser in the standard library.
+ostruct OpenStruct, creates a Struct-like object with arbitrary attributes.
+parsearg Argument parser. Deprecated, uses getopts.
+parsedate Provides a parser for dates.
+pathname Represents a pathname to locate a file in a Unix filesystem. It does not represent the file, but the path name.
+ping A simple implementation of a ping-like utility using Ruby’s native socket support.
+pp Pretty printer for Ruby objects. Usable in place of #inspect.
+prettyprint Implementation of pretty printing algorithm.
+profile Ruby-based profiler. Use as <b>ruby -rprofile ...</b>.
+profiler The Ruby profiler implementation.
+pstore A filesystem “database” using Marshal formatting for storage.
+rational Implements rational numbers for Ruby (2 / 3 is 2 / 3, not 0.66 repeating).
+readbytes Adds IO#readbytes, reads fixed sized data and guarantees read data size.
+remote-tk Supports control of remote Tk interpreters.
+resolv-replace Replaces resolver behaviour on socket classes.
+resolv A resolver library written in Ruby.
+rexml/document Ruby Electric XML (REXML) parser.
+rinda/rinda A Ruby implementation of the Linda distributed computing paradigm. Uses drb.
+rss/* RSS 0.9 (rss/0.9), 1.0 (rss/1.0), or 2.0 (rss/2.0) interpreter.
+rss/maker/* RSS 0.9 (rss/maker/0.9), 1.0 (rss/maker/1.0), or 2.0 (rss/maker/2.0) maker.
+rubyunit Deprecated. Provides a wrapper for older RUnit classes to work as if they were Test::Unit classes.
+scanf scanf for Ruby.
+set An implementation of a Set calss for Ruby. A collection of unordered values with no duplicates.
+sha1 Deprecated. Use digest/sha1 instead.
+shell Provides shell-like interaction. (?)
+shellwords Splits text into an array of tokens like Unix shells do.
+singleton A module to implement the Singleton pattern.
+soap/soap Native Ruby SOAP library. wsdl/* provides for service discovery.
+sync A two-phase lock with counter.
+tcltk Direct manipulation of Tcl/Tk utilities in a namespace.
+tempfile Manipulates temporary files (that will be deleted when the need for them goes away).
+test/unit Native unit testing library, Test::Unit.
+thread Thread support classes.
+thwait Thread synchronization classes.
+time Extensions to the Time class to support RFC2822 and RFC2616 formats, as well as others.
+timeout An execution timeout.
+tk An interface to Tk.
+tkextlib/* Support for various Tk extensions (ICONS, bwidtget, itcl, itk, etc.).
+tmpdir Retrieve the temporary directory path.
+tracer Tracing Ruby programs
+tsort Support for topological sorting.
+un Replacements for common Unix commands. <b>ruby -run -e cp -- ...</b>, etc.
+uri Libraries for interpreting uniform resource indicators (URIs).
+weakref A Weak reference class that is not garbage collected.
+webrick Webserver toolkit.
+win32/registry Access to the Win32 Regsitry.
+win32/resolv An interface to DNS and DHCP on Win32.
+xmlrpc/* Support for XML-RPC clients and servers.
+xsd/* XML instance parser.
+yaml YAML support.
+ EOS
+
+ h1 "ruby"
+ h2 "Command-Line Options"
+ pairs <<-'EOS'
+-0[octal] specify record separator (\0, if no argument).
+-a autosplit mode with -n or -p (splits $_ into $F).
+-c check syntax only.
+-Cdirectory cd to directory, before executing your script.
+--copyright print the copyright and exit.
+-d set debugging flags (set $DEBUG to true).
+-e 'command' one line of script. Several -e’s allowed.
+-F regexp split() pattern for autosplit (-a).
+-h prints summary of the options.
+-i[extension] edit ARGV files in place (make backup if extension supplied).
+-Idirectory specify $LOAD_PATH directory (may be used more than once).
+-Kkcode specifies KANJI (Japanese) code-set.
+-l enable line ending processing.
+-n assume ‘while gets(); ... endloop around your script.
+-p assume loop like -n but print line also like sed.
+-rlibrary require the library, before executing your script.
+-s enable some switch parsing for switches after script name.
+-S look for the script using PATH environment variable.
+-T[level] turn on tainting checks.
+-v print version number, then turn on verbose mode.
+--version print the version and exit.
+-w turn warnings on for your script.
+-x[directory] strip off text before #! line and perhaps cd to directory.
+-X directory causes Ruby to switch to the directory.
+-y turns on compiler debug mode.
+ EOS
+
+ h2 "Environment Variables"
+ pairs <<-'EOS'
+DLN_LIBRARY_PATH Search path for dynamically loaded modules.
+RUBYLIB Additional search paths.
+RUBYLIB_PREFIX Add this prefix to each item in RUBYLIB. Windows only.
+RUBYOPT Additional command line options.
+RUBYPATH With -S, searches PATH, or this value for ruby programs.
+RUBYSHELL Shell to use when spawning.
+ EOS
+
+ h1 "irb"
+ pre "irb [options] [script [args]]"
+
+ h2 "irb Command-Line Options"
+ pairs <<-'EOS'
+-f Prevents the loading of ~/.irb.rc. Version 1.1 has a bug that swallows the next argument.
+-m Math mode. Overrides --inspect. Requires “mathn”.
+-d Sets $DEBUG to true. Same as “ruby -d ...”
+-r module Loads a module. Same as “ruby -r module ...”
+--inspect Turns on inspect mode. Default.
+--noinspect Turns off inspect mode.
+--readline Turns on readline support. Default.
+--noreadline Turns off readline support.
+--prompt[-mode] prompt Sets the prompt. ‘prompt’ must be one of ‘default’, ‘xmp’, ‘simple’, or ‘inf-ruby’.
+--noprompt Turns off the prompt.
+--inf-ruby-mode Turns on emacs support and turns off readline.
+--sample-book-mode, --simple-prompt Same as ‘--prompt simple’
+--tracer Turns on trace mode. Version 1.1 has a fatal bug with this flag.
+--back-trace-limit Sets the amount of backtrace to display in trace mode.
+--context-mode Sets the context mode (0-3) for multiple contexts. Defaults to 3. Not very clear how/why they differ.
+--single-irb Turns off multiple bindings (disables the irb command below), I think.
+--irb_debug level Sets internal debug level. For irb only.
+-v, --version Prints the version and exits.
+ EOS
+
+ h2 "irb commands"
+ body <<-'EOS'
+irb accepts arbitrary Ruby commands and the special commands described
+below.
+ EOS
+ pairs <<-'EOS'
+irb_exit Exits the current session, or the program if there are no other sessions.
+fork block forks and runs the given block.
+irb_change_binding args Changes to a secified binding.
+source file Loads a ruby file into the session.
+irb [obj] Starts a new session, with obj as self, if specified.
+conf[.key[= val]] Access the configuration of the session. May read and write single values.
+jobs Lists the known sessions.
+fg (session#|thread-id|obj|self) Switches to the specifed session.
+kill session Kills a specified session. Session may be specified the same as ‘fg’.
+xmp eval-string Evaluates the string and prints the string and result in a nice manner suitable for cut/paste operations. Only available with <b>require ‘irb/xmp’</b>.
+ EOS
+
+ h1 "Ruby Debugger"
+ pre "ruby -r debug ..."
+
+ h2 "Commands"
+ pairs <<-'EOS'
+b[reak] [file:]line Set breakpoint at given line in file (default current file).
+b[reak] [file:]name Set breakpoint at method in file.
+b[reak] Display breakpoints and watchpoints.
+wat[ch] expr Break when expression becomes true.
+del[ete] [nnn] Delete breakpoint nnn (default all).
+disp[lay] expr Display value of nnn every time debugger gets control.
+disp[lay] Show current displays.
+undisp[lay] [nnn] Remove display (default all).
+c[ont] Continue execution.
+s[tep] nnn=1 Execute next nnn lines, stepping into methods.
+n[ext] nnn=1 Execute next nnn lines, stepping over methods.
+fi[nish] Finish execution of the current function.
+q[uit] Exit the debugger.
+w[here] Display current stack frame.
+f[rame] Synonym for where.
+l[ist] [start--end] List source lines from start to end.
+up nnn=1 Move up nnn levels in the stack frame.
+down nnn=1 Move down nnn levels in the stack frame.
+v[ar] g[lobal] Display global variables.
+v[ar] l[ocal] Display local variables.
+v[ar] i[nstance] obj Display instance variables of obj.
+v[ar] c[onst] Name Display constants in class or module name.
+m[ethod] i[nstance] obj Display instance methods of obj.
+m[ethod] Name Display instance methods of the class or module name.
+th[read] l[ist] List all threads.
+th[read] [c[ur[rent]]] Display status of current thread.
+th[read] [c[ur[rent]]] nnn Make thread nnn current and stop it.
+th[read] stop nnn Make thread nnn current and stop it.
+th[read] resume nnn Resume thread nnn.
+[p] expr Evaluate expr in the current context. expr may include assignment to variables and method invocations.
+empty A null command repeats the last command.
+ EOS
+
+ x = pdf.absolute_right_margin + pdf.font_height(5)
+ y = pdf.absolute_bottom_margin
+ memo = %Q(Copyright © 2005 Ryan Davis with Austin Ziegler. PDF version by Austin Ziegler. Licensed under the <c:alink uri="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-NonCommercial-ShareAlike</c:alink> Licence. The original HTML version is at <c:alink uri="http://www.zenspider.com/Languages/Ruby/QuickRef.html">Zen Spider</c:alink>. Generated by <c:alink uri="http://rubyforge.org/projects/ruby-pdf/">PDF::Writer</c:alink> #{PDF::Writer::VERSION} and PDF::QuickRef #{PDF::QuickRef::VERSION}.)
+ pdf.add_text(x, y, memo, 5, 90)
+ x = pdf.absolute_right_margin - 32
+ y = pdf.absolute_bottom_margin + 24
+
+ save_as "Ruby-Library-QuickRef.pdf"
+end
View
BIN images/bluesmoke.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/chunkybacon.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/chunkybacon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
13 lib/pdf/charts.rb
@@ -0,0 +1,13 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+ # A namespace for charts that can be drawn on PDF::Writer canvases.
+module PDF::Charts
+end
View
431 lib/pdf/charts/stddev.rb
@@ -0,0 +1,431 @@
+#--
+# PDF::Writer for Ruby.
+# http://rubyforge.org/projects/ruby-pdf/
+# Copyright 2003 - 2005 Austin Ziegler.
+#
+# Licensed under a MIT-style licence. See LICENCE in the main distribution
+# for full licensing information.
+#
+# $Id$
+#++
+require 'pdf/writer'
+require 'pdf/charts'
+require 'ostruct'
+
+ # Creates a standard deviation chart. This is a type of chart that is
+ # effective for the display of survey results or other data that can
+ # easily be measured in terms of the average and the standard deviation
+ # from that average.
+ #
+ # The scale of responses is the vertical scale; the average data points
+ # and standard deviation values are the horizontal scale.
+class PDF::Charts::StdDev
+ VERSION = '1.1.3'
+
+ # A data element.
+ DataPoint