Skip to content

Commit

Permalink
Fix example_helper.rb require on all examples
Browse files Browse the repository at this point in the history
Since '.' is no longer in the $LOAD_PATH in Ruby 1.9.2, we have to run
an expand_path over the resulting path from File.dirname(__FILE__).

Closes prawnpdf#154.
  • Loading branch information
bradediger committed Sep 27, 2010
1 parent c0224cb commit 0e9df5c
Show file tree
Hide file tree
Showing 75 changed files with 163 additions and 88 deletions.
5 changes: 3 additions & 2 deletions examples/bounding_box/bounding_boxes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This example demonstrates the basic functionality of Prawn's bounding boxes.
# Note that top level bounding boxes are positioned relative to the margin_box.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("bounding_boxes.pdf") do

Expand Down Expand Up @@ -40,4 +41,4 @@
end
end

end
end
3 changes: 2 additions & 1 deletion examples/bounding_box/indentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This example demonstrates the basic functionality of Prawn's bounding boxes.
# Note that top level bounding boxes are positioned relative to the margin_box.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("indentation.pdf") do

Expand Down
5 changes: 3 additions & 2 deletions examples/bounding_box/russian_boxes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# can simplify calculations. See the other files in examples/bounding_box
# for more basic uses.

require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

class Array
def combine(arr)
Expand Down Expand Up @@ -33,4 +34,4 @@ def recurse_bounding_box(pdf, max_depth=5, depth=1)

Prawn::Document.generate("russian_boxes.pdf") do |pdf|
recurse_bounding_box(pdf)
end
end
3 changes: 2 additions & 1 deletion examples/bounding_box/stretched_nesting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This example demonstrates how nested bounding boxes work when the outer box is
# stretchy and includes several inner boxes of different sizes.

require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("stretched_nesting.pdf", :page_layout => :landscape) do

Expand Down
3 changes: 2 additions & 1 deletion examples/general/background.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# generating a new Document. Image is assumed to be pre-fit for your page
# size, and will not be rescaled.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

img = "#{Prawn::BASEDIR}/data/images/letterhead.jpg"

Expand Down
3 changes: 2 additions & 1 deletion examples/general/canvas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Demonstrates how to enable absolute positioning in Prawn by temporarily
# removing the margin_box via Document#canvas()
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("canvas.pdf") do
canvas do
Expand Down
3 changes: 2 additions & 1 deletion examples/general/context_sensitive_headers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

# Ex. Generate a roster of meeting attendees given a set of meetings.
# Attendees for a meeting may overflow to accross page boundaries but
Expand Down
3 changes: 2 additions & 1 deletion examples/general/float.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "#{File.dirname(__FILE__)}/../example_helper"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate('float.pdf') do
float do
Expand Down
3 changes: 2 additions & 1 deletion examples/general/margin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# This demonstrates the Prawn options for document and page margin, similar to CSS shorthand.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

LOREM = ("Lorem ipsum dolor sit amet, consectetur adipisicing elit, "+
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "+
Expand Down
3 changes: 2 additions & 1 deletion examples/general/measurement_units.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# its particular implementation, though some might find that interesting as
# well.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

require "prawn/measurement_extensions"

Expand Down
3 changes: 2 additions & 1 deletion examples/general/metadata-info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Demonstrates how to set metadata properties via the info option
# It allows one to specify no standard properties
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate "metadata-info.pdf",
:info => {
Expand Down
3 changes: 2 additions & 1 deletion examples/general/multi_page_layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This demonstrates that Prawn can modify page size, margins and layout for
# each individual page, via Document#start_new_page()
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("multi-layout.pdf", :page_layout => :landscape) do |pdf|
pdf.text "This is on a landscaped page"
Expand Down
3 changes: 2 additions & 1 deletion examples/general/outlines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This example demonstrates the use of the the outlines option for a new document
# it sets an initial outline item with a title
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate('outlines.pdf') do
text "Page 1. This is the first Chapter. "
Expand Down
3 changes: 2 additions & 1 deletion examples/general/page_geometry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# documents. The style used here is a bit out of date, see
# multi_page_layout.rb for a more modern example.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

def pdf(*options)
Prawn::Document.new(*options)
Expand Down
3 changes: 2 additions & 1 deletion examples/general/page_numbering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This example demonstrates how to add a "page k of n"
# template to your documents.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("page_with_numbering.pdf") do
text "Hai"
Expand Down
3 changes: 2 additions & 1 deletion examples/general/repeaters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# they should be pretty efficient.
#
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("repeat.pdf", :skip_page_creation => true) do

Expand Down
3 changes: 2 additions & 1 deletion examples/general/stamp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# Demonstrate use of stamps
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("stamp.pdf", :skip_page_creation => true) do

Expand Down
3 changes: 2 additions & 1 deletion examples/general/templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This sample demonstrates the use of the :template option when generating
# a new Document. The template PDF file is imported into a new document.

require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

filename = "#{Prawn::BASEDIR}/reference_pdfs/curves.pdf"

Expand Down
3 changes: 2 additions & 1 deletion examples/graphics/basic_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# For positioning images alongside flowing text, see the image_flow.rb
# example.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("basic_images.pdf", :page_layout => :landscape) do
stef = "#{Prawn::BASEDIR}/data/images/stef.jpg"
Expand Down
3 changes: 2 additions & 1 deletion examples/graphics/cmyk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# Demonstrates Prawn's support for CMYK images and colors.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("cmyk.pdf", :page_layout => :landscape) do
fill_color 50, 100, 0, 0
Expand Down
5 changes: 3 additions & 2 deletions examples/graphics/curves.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#
# Demonstrates simple curve and circle usage
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

pdf = Prawn::Document.new
pdf.move_to [100,100]
pdf.stroke_curve_to [50,50], :bounds => [[60,90], [60, 90]]
pdf.fill_circle_at [200,200], :radius => 10
pdf.render_file "curves.pdf"
pdf.render_file "curves.pdf"
5 changes: 3 additions & 2 deletions examples/graphics/hexagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#
# Draws and fills a Hexagon using Document#polygon
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

pdf = Prawn::Document.new

pdf.fill_color "ff0000"
pdf.fill_polygon [100, 250], [200, 300], [300, 250],
[300, 150], [200, 100], [100, 150]

pdf.render_file "hexagon.pdf"
pdf.render_file "hexagon.pdf"
5 changes: 3 additions & 2 deletions examples/graphics/image_fit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
# The image will be scaled down to fit within the box, while preserving
# the aspect ratio.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("image_fit.pdf", :page_layout => :landscape) do

pigs = "#{Prawn::BASEDIR}/data/images/pigs.jpg"
stroke_rectangle [50,450], 200, 200
image pigs, :at => [50,450], :fit => [200,200]

end
end
3 changes: 2 additions & 1 deletion examples/graphics/image_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# useful when used in combination with flowing text, where the exact final
# position of the image is not known ahead of time.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("image-flow.pdf", :page_layout => :landscape) do
self.font_size = 8
Expand Down
5 changes: 3 additions & 2 deletions examples/graphics/image_position.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#
# Demonstrates vertical and horizontal positioning of images.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"

require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("image_position.pdf", :page_layout => :landscape) do

dice = "#{Prawn::BASEDIR}/data/images/dice.png"
Expand Down
3 changes: 2 additions & 1 deletion examples/graphics/line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# The very first Prawn example. Here for nostalgia's sake.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

pdf = Prawn::Document.new
pdf.line_width = 10
Expand Down
5 changes: 3 additions & 2 deletions examples/graphics/png_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# PNG files come in different flavours - 5 of them. This example embeds
# one of each type as proof that they all work.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

images = [
["Type 0", "#{Prawn::BASEDIR}/data/images/web-links.png"],
Expand All @@ -19,4 +20,4 @@
text header
image file, :at => [50,450]
end
end
end
5 changes: 3 additions & 2 deletions examples/graphics/polygons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# Basic polygon drawing example. See also: hexagon.rb
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

pdf = Prawn::Document.new

Expand All @@ -13,4 +14,4 @@
pdf.stroke_rectangle [0,600], 5*i, 10*i
end

pdf.render_file "pretty_polygons.pdf"
pdf.render_file "pretty_polygons.pdf"
3 changes: 2 additions & 1 deletion examples/graphics/remote_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Demonstrates how to use open-uri and Document#image to embed remote image
# files.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

require "open-uri"

Expand Down
3 changes: 2 additions & 1 deletion examples/graphics/rounded_polygons.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

def radian(degree)
Math::PI/180*degree
Expand Down
3 changes: 2 additions & 1 deletion examples/graphics/rounded_rectangle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Rounded rectangle example demonstrating both stroke and stroke and fill.
# A rectangle with rounded join_style is added just for comparison.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

pdf = Prawn::Document.new
pdf.font_size 8
Expand Down
5 changes: 3 additions & 2 deletions examples/graphics/ruport_style_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# These helpers will be familiar to Ruport users, and now are supported
# directly in Prawn. Run the example to see how they work.
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

# Demonstrates some features stolen from Ruport::Formatter::PDF
Prawn::Document.generate("ruport.pdf") do
Expand All @@ -16,4 +17,4 @@
stroke_horizontal_line 50, 100
stroke_horizontal_line 50, 100, :at => 300
stroke_vertical_line 300, 50, :at => 250
end
end
3 changes: 2 additions & 1 deletion examples/graphics/stroke_bounds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
# Feature borrowed from Josh Knowle's pt at:
# http://github.com/joshknowles/pt/tree/master
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("stroke_bounds.pdf") do
stroke_bounds
Expand Down
3 changes: 2 additions & 1 deletion examples/graphics/stroke_cap_and_join.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# Stroke dashing can be applied to any line or curve

require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("stroke_cap_and_join.pdf") do
self.line_width = 25
Expand Down
3 changes: 2 additions & 1 deletion examples/graphics/stroke_dash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# Stroke dashing can be applied to any line or curve

require "#{File.dirname(__FILE__)}/../example_helper.rb"
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Document.generate("stroke_dash.pdf") do
self.line_width = 1
Expand Down
Loading

0 comments on commit 0e9df5c

Please sign in to comment.