[DRE-commits] [SCM] ruby-prawn.git branch, master, updated. upstream/1.0.0_rc1-44-g6e97afc
Cédric Boutillier
cedric.boutillier at gmail.com
Thu Nov 24 23:11:57 UTC 2011
The following commit has been merged in the master branch:
commit 55498942efd834d86b898f1984a28be74be51f5a
Author: Cédric Boutillier <cedric.boutillier at gmail.com>
Date: Tue Nov 15 23:49:25 2011 +0100
patch: use DATADIR to point to the content of data/
diff --git a/debian/patches/0200_replace_BASEDIR_data_by_DATADIR.patch b/debian/patches/0200_replace_BASEDIR_data_by_DATADIR.patch
new file mode 100644
index 0000000..9e89beb
--- /dev/null
+++ b/debian/patches/0200_replace_BASEDIR_data_by_DATADIR.patch
@@ -0,0 +1,771 @@
+Description: define Prawn::DATADIR as the name of the directory containing data
+ Upstream hardcoded the relative path with respect to prawn/core.rb of the
+ directory containing data.
+ A new constant, Prawn::DATADIR is introduced to permit using another
+ directory, and change its name just once.
+ The code (mainly comments and specs) is patched to make use of this new
+ constant instead of the hardcoded path
+Author: Cédric Boutillier <cedric.boutillier at gmail.com>
+Last-Update: 2011-11-15
+
+--- a/lib/prawn/document.rb
++++ b/lib/prawn/document.rb
+@@ -166,7 +166,7 @@
+ # pdf = Prawn::Document.new(:page_size => [200, 300])
+ #
+ # # New document, with background
+- # pdf = Prawn::Document.new(:background => "#{Prawn::BASEDIR}/data/images/pigs.jpg")
++ # pdf = Prawn::Document.new(:background => "#{Prawn::DATADIR}/images/pigs.jpg")
+ #
+ def initialize(options={},&block)
+ options = options.dup
+--- a/lib/prawn/images.rb
++++ b/lib/prawn/images.rb
+@@ -32,10 +32,10 @@
+ # <tt>:fit</tt>:: scale the dimensions of the image proportionally to fit inside [width,height]
+ #
+ # Prawn::Document.generate("image2.pdf", :page_layout => :landscape) do
+- # pigs = "#{Prawn::BASEDIR}/data/images/pigs.jpg"
++ # pigs = "#{Prawn::DATADIR}/images/pigs.jpg"
+ # image pigs, :at => [50,450], :width => 450
+ #
+- # dice = "#{Prawn::BASEDIR}/data/images/dice.png"
++ # dice = "#{Prawn::DATADIR}/images/dice.png"
+ # image dice, :at => [50, 450], :scale => 0.75
+ # end
+ #
+--- a/lib/prawn/core/text.rb
++++ b/lib/prawn/core/text.rb
+@@ -131,11 +131,11 @@
+ #
+ # Call with an empty array to turn off fallback fonts
+ #
+- # file = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
++ # file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+ # font_families["Kai"] = {
+ # :normal => { :file => file, :font => "Kai" }
+ # }
+- # file = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
++ # file = "#{Prawn::DATADIR}/fonts/Action Man.dfont"
+ # font_families["Action Man"] = {
+ # :normal => { :file => file, :font => "ActionMan" },
+ # }
+--- a/lib/prawn/font/afm.rb
++++ b/lib/prawn/font/afm.rb
+@@ -28,7 +28,7 @@
+ ".", "/usr/lib/afm",
+ "/usr/local/lib/afm",
+ "/usr/openwin/lib/fonts/afm/",
+- Prawn::BASEDIR+'/data/fonts/']
++ Prawn::DATADIR+'/fonts/']
+ end
+ end
+
+--- a/spec/template_spec.rb
++++ b/spec/template_spec.rb
+@@ -59,7 +59,7 @@
+ end
+
+ it "should have a single page object if importing a single page template" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/hexagon.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+ output = StringIO.new(@pdf.render)
+@@ -71,7 +71,7 @@
+ end
+
+ it "should have two content streams if importing a single page template" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/hexagon.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+ output = StringIO.new(@pdf.render)
+@@ -83,7 +83,7 @@
+ end
+
+ it "should not die if using this PDF as a template" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/complex_template.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/complex_template.pdf"
+
+ assert_nothing_raised do
+ @pdf = Prawn::Document.new(:template => filename)
+@@ -92,7 +92,7 @@
+
+
+ it "should have balance q/Q operators on all content streams" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/hexagon.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+ output = StringIO.new(@pdf.render)
+@@ -108,7 +108,7 @@
+ end
+
+ it "should allow text to be added to a single page template" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/hexagon.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+
+@@ -119,7 +119,7 @@
+ end
+
+ it "should allow PDFs with page resources behind an indirect object to be used as templates" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/resources_as_indirect_object.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/resources_as_indirect_object.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+
+@@ -131,7 +131,7 @@
+ end
+
+ it "should copy the PDF version from the template file" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/version_1_6.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/version_1_6.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+ str = @pdf.render
+@@ -139,9 +139,9 @@
+ end
+
+ it "should correctly add a TTF font to a template that has existing fonts" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/contains_ttf_font.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/contains_ttf_font.pdf"
+ @pdf = Prawn::Document.new(:template => filename)
+- @pdf.font "#{Prawn::BASEDIR}/data/fonts/Chalkboard.ttf"
++ @pdf.font "#{Prawn::DATADIR}/fonts/Chalkboard.ttf"
+ @pdf.move_down(40)
+ @pdf.text "Hi There"
+
+@@ -155,7 +155,7 @@
+ end
+
+ it "should correctly import a template file that is missing a MediaBox entry" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/page_without_mediabox.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/page_without_mediabox.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+ str = @pdf.render
+@@ -215,7 +215,7 @@
+ end
+
+ it "should have two content streams if importing a single page template" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/hexagon.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
+ @pdf = Prawn::Document.new()
+ @pdf.start_new_page(:template => filename)
+ output = StringIO.new(@pdf.render)
+@@ -226,7 +226,7 @@
+ end
+
+ it "should have balance q/Q operators on all content streams" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/hexagon.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
+
+ @pdf = Prawn::Document.new()
+ @pdf.start_new_page(:template => filename)
+@@ -254,7 +254,7 @@
+ end
+
+ it "should allow PDFs with page resources behind an indirect object to be used as templates" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/resources_as_indirect_object.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/resources_as_indirect_object.pdf"
+
+ @pdf = Prawn::Document.new()
+ @pdf.start_new_page(:template => filename)
+@@ -267,10 +267,10 @@
+ end
+
+ it "should correctly add a TTF font to a template that has existing fonts" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/contains_ttf_font.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/contains_ttf_font.pdf"
+ @pdf = Prawn::Document.new()
+ @pdf.start_new_page(:template => filename)
+- @pdf.font "#{Prawn::BASEDIR}/data/fonts/Chalkboard.ttf"
++ @pdf.font "#{Prawn::DATADIR}/fonts/Chalkboard.ttf"
+ @pdf.move_down(40)
+ @pdf.text "Hi There"
+
+@@ -286,7 +286,7 @@
+
+ context "using template_page option" do
+ it "uses the specified page option" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/multipage_template.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/multipage_template.pdf"
+ @pdf = Prawn::Document.new()
+ @pdf.start_new_page(:template => filename, :template_page => 2)
+ text = PDF::Inspector::Text.analyze(@pdf.render)
+--- a/spec/text_box_spec.rb
++++ b/spec/text_box_spec.rb
+@@ -74,7 +74,7 @@
+ @pdf.text_direction(:rtl)
+ @pdf.text_direction = :rtl
+ @pdf.text_direction = :rtl
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf", :size => 16) do
++ @pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf", :size => 16) do
+ @pdf.text "写个小"
+ end
+ text = PDF::Inspector::Text.analyze(@pdf.render)
+@@ -617,7 +617,7 @@
+ :height => bounding_height,
+ :document => @pdf
+ }
+- file = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
++ file = "#{Prawn::DATADIR}/fonts/Action Man.dfont"
+ @pdf.font_families["Action Man"] = {
+ :normal => { :file => file, :font => "ActionMan" },
+ :italic => { :file => file, :font => "ActionMan-Italic" },
+@@ -800,7 +800,7 @@
+ :height => 162.0,
+ :document => @pdf
+ }
+- @pdf.font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
++ @pdf.font "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+ @options[:overflow] = :truncate
+ text_box = Prawn::Text::Box.new(@text, @options)
+ text_box.render
+--- a/spec/text_at_spec.rb
++++ b/spec/text_at_spec.rb
+@@ -107,9 +107,9 @@
+ Prawn::Errors::IncompatibleStringEncoding)
+ end
+ it "should not raise an exception when a shift-jis string is rendered" do
+- datafile = "#{Prawn::BASEDIR}/data/shift_jis_text.txt"
++ datafile = "#{Prawn::DATADIR}/shift_jis_text.txt"
+ sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets }
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+ lambda { @pdf.draw_text(sjis_str, :at => [0, 0]) }.should.not.raise(
+ Prawn::Errors::IncompatibleStringEncoding)
+ end
+@@ -121,7 +121,7 @@
+ Prawn::Errors::IncompatibleStringEncoding)
+ end
+ it "should raise an exception when a shift-jis string is rendered" do
+- sjis_str = File.read("#{Prawn::BASEDIR}/data/shift_jis_text.txt")
++ sjis_str = File.read("#{Prawn::DATADIR}/shift_jis_text.txt")
+ lambda { @pdf.draw_text(sjis_str, :at => [0, 0]) }.should.raise(
+ Prawn::Errors::IncompatibleStringEncoding)
+ end
+--- a/spec/font_spec.rb
++++ b/spec/font_spec.rb
+@@ -24,7 +24,7 @@
+ it "should exclude newlines" do
+ create_pdf
+ # Use a TTF font that has a non-zero width for \n
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+
+ @pdf.width_of("\nhello world\n").should ==
+ @pdf.width_of("hello world")
+@@ -96,7 +96,7 @@
+ end
+
+ it "should allow font familes to be defined in a single dfont" do
+- file = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
++ file = "#{Prawn::DATADIR}/fonts/Action Man.dfont"
+ @pdf.font_families["Action Man"] = {
+ :normal => { :file => file, :font => "ActionMan" },
+ :italic => { :file => file, :font => "ActionMan-Italic" },
+@@ -253,15 +253,15 @@
+ end
+
+ it "should return true when present in a TTF font" do
+- font = @pdf.find_font("#{Prawn::BASEDIR}/data/fonts/Activa.ttf")
++ font = @pdf.find_font("#{Prawn::DATADIR}/fonts/Activa.ttf")
+ font.glyph_present?("H").should.be true
+ end
+
+ it "should return false when absent in a TTF font" do
+- font = @pdf.find_font("#{Prawn::BASEDIR}/data/fonts/Activa.ttf")
++ font = @pdf.find_font("#{Prawn::DATADIR}/fonts/Activa.ttf")
+ font.glyph_present?("再").should.be false
+
+- font = @pdf.find_font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf")
++ font = @pdf.find_font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+ font.glyph_present?("€").should.be false
+ end
+ end
+@@ -270,7 +270,7 @@
+
+ setup do
+ create_pdf
+- @activa = @pdf.find_font "#{Prawn::BASEDIR}/data/fonts/Activa.ttf"
++ @activa = @pdf.find_font "#{Prawn::DATADIR}/fonts/Activa.ttf"
+ end
+
+ it "should calculate string width taking into account accented characters" do
+@@ -336,7 +336,7 @@
+ it "should allow TTF fonts to be used alongside document transactions" do
+ lambda {
+ Prawn::Document.new do
+- font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
++ font "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
+ text "Hi there"
+ transaction { text "Nice, thank you" }
+ end
+@@ -346,7 +346,7 @@
+ it "should allow TTF fonts to be used inside transactions" do
+ pdf = Prawn::Document.new do
+ transaction do
+- font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
++ font "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
+ text "Hi there"
+ end
+ end
+@@ -364,7 +364,7 @@
+ describe "DFont fonts" do
+ setup do
+ create_pdf
+- @file = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
++ @file = "#{Prawn::DATADIR}/fonts/Action Man.dfont"
+ end
+
+ it "should list all named fonts" do
+@@ -403,7 +403,7 @@
+ describe "#character_count(text)" do
+ it "should work on TTF fonts" do
+ create_pdf
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+ @pdf.font.character_count("こんにちは世界").should == 7
+ @pdf.font.character_count("Hello, world!").should == 13
+ end
+--- a/spec/cell_spec.rb
++++ b/spec/cell_spec.rb
+@@ -509,7 +509,7 @@
+ describe "with default options" do
+ before(:each) do
+ @cell = Prawn::Table::Cell.make(@pdf,
+- :image => "#{Prawn::BASEDIR}/data/images/prawn.png")
++ :image => "#{Prawn::DATADIR}/images/prawn.png")
+ end
+
+ it "should create a Cell::Image" do
+@@ -525,7 +525,7 @@
+ describe "hash syntax" do
+ before(:each) do
+ @table = @pdf.make_table([[{
+- :image => "#{Prawn::BASEDIR}/data/images/prawn.png",
++ :image => "#{Prawn::DATADIR}/images/prawn.png",
+ :scale => 2,
+ :fit => [100, 200],
+ :image_width => 123,
+--- a/spec/formatted_text_box_spec.rb
++++ b/spec/formatted_text_box_spec.rb
+@@ -21,7 +21,7 @@
+ it "should not raise Encoding::CompatibilityError when keeping a TTF and an " +
+ "AFM font together" do
+ ruby_19 do
+- file = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
++ file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+ @pdf.font_families["Kai"] = {
+ :normal => { :file => file, :font => "Kai" }
+ }
+@@ -121,7 +121,7 @@
+ "a Chinese font and set of Chinese glyphs not in the current font" do
+ it "should change the font to the Chinese font for the Chinese glyphs" do
+ create_pdf
+- file = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
++ file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+ @pdf.font_families["Kai"] = {
+ :normal => { :file => file, :font => "Kai" }
+ }
+@@ -149,7 +149,7 @@
+ "an AFM font and Win-Ansi glyph not in the current Chinese font" do
+ it "should change the font to the AFM font for the Win-Ansi glyph" do
+ create_pdf
+- file = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
++ file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+ @pdf.font_families["Kai"] = {
+ :normal => { :file => file, :font => "Kai" }
+ }
+@@ -178,7 +178,7 @@
+ "level font" do
+ it "should use the fragment level font except for glyphs not in that font" do
+ create_pdf
+- file = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
++ file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+ @pdf.font_families["Kai"] = {
+ :normal => { :file => file, :font => "Kai" }
+ }
+@@ -205,7 +205,7 @@
+ describe "Text::Formatted::Box" do
+ before(:each) do
+ create_pdf
+- file = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
++ file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+ @pdf.font_families["Kai"] = {
+ :normal => { :file => file, :font => "Kai" }
+ }
+--- a/spec/text_spacing_spec.rb
++++ b/spec/text_spacing_spec.rb
+@@ -42,7 +42,7 @@
+ #
+ it "should calculate character spacing widths by characters, not bytes" do
+ create_pdf
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+
+ str = "こんにちは世界"
+ @pdf.character_spacing(0) do
+--- a/spec/png_spec.rb
++++ b/spec/png_spec.rb
+@@ -12,8 +12,8 @@
+ describe "When reading a greyscale PNG file (color type 0)" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/web-links.png"
+- @data_filename = "#{Prawn::BASEDIR}/data/images/web-links.dat"
++ @filename = "#{Prawn::DATADIR}/images/web-links.png"
++ @data_filename = "#{Prawn::DATADIR}/images/web-links.dat"
+ @img_data = File.binread(@filename)
+ end
+
+@@ -39,7 +39,7 @@
+ describe "When reading a greyscale PNG file with transparency (color type 0)" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/ruport_type0.png"
++ @filename = "#{Prawn::DATADIR}/images/ruport_type0.png"
+ @img_data = File.binread(@filename)
+ end
+
+@@ -56,8 +56,8 @@
+ describe "When reading an RGB PNG file (color type 2)" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/ruport.png"
+- @data_filename = "#{Prawn::BASEDIR}/data/images/ruport_data.dat"
++ @filename = "#{Prawn::DATADIR}/images/ruport.png"
++ @data_filename = "#{Prawn::DATADIR}/images/ruport_data.dat"
+ @img_data = File.binread(@filename)
+ end
+
+@@ -83,7 +83,7 @@
+ describe "When reading an RGB PNG file with transparency (color type 2)" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/arrow2.png"
++ @filename = "#{Prawn::DATADIR}/images/arrow2.png"
+ @img_data = File.binread(@filename)
+ end
+
+@@ -103,8 +103,8 @@
+ describe "When reading an indexed color PNG file (color type 3)" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/rails.png"
+- @data_filename = "#{Prawn::BASEDIR}/data/images/rails.dat"
++ @filename = "#{Prawn::DATADIR}/images/rails.png"
++ @data_filename = "#{Prawn::DATADIR}/images/rails.dat"
+ @img_data = File.binread(@filename)
+ end
+
+@@ -130,9 +130,9 @@
+ describe "When reading a greyscale+alpha PNG file (color type 4)" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/page_white_text.png"
+- @data_filename = "#{Prawn::BASEDIR}/data/images/page_white_text.dat"
+- @alpha_data_filename = "#{Prawn::BASEDIR}/data/images/page_white_text.alpha"
++ @filename = "#{Prawn::DATADIR}/images/page_white_text.png"
++ @data_filename = "#{Prawn::DATADIR}/images/page_white_text.dat"
++ @alpha_data_filename = "#{Prawn::DATADIR}/images/page_white_text.alpha"
+ @img_data = File.binread(@filename)
+ end
+
+@@ -166,9 +166,9 @@
+ describe "When reading an RGB+alpha PNG file (color type 6)" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/dice.png"
+- @data_filename = "#{Prawn::BASEDIR}/data/images/dice.dat"
+- @alpha_data_filename = "#{Prawn::BASEDIR}/data/images/dice.alpha"
++ @filename = "#{Prawn::DATADIR}/images/dice.png"
++ @data_filename = "#{Prawn::DATADIR}/images/dice.dat"
++ @alpha_data_filename = "#{Prawn::DATADIR}/images/dice.alpha"
+ @img_data = File.binread(@filename)
+ end
+
+@@ -202,10 +202,10 @@
+ describe "When reading a 16bit RGB+alpha PNG file (color type 6)" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/16bit.png"
+- @data_filename = "#{Prawn::BASEDIR}/data/images/16bit.dat"
++ @filename = "#{Prawn::DATADIR}/images/16bit.png"
++ @data_filename = "#{Prawn::DATADIR}/images/16bit.dat"
+ # alpha channel truncated to 8-bit
+- @alpha_data_filename = "#{Prawn::BASEDIR}/data/images/16bit.alpha"
++ @alpha_data_filename = "#{Prawn::DATADIR}/images/16bit.alpha"
+ @img_data = File.binread(@filename)
+ end
+
+--- a/spec/object_store_spec.rb
++++ b/spec/object_store_spec.rb
+@@ -35,7 +35,7 @@
+ end
+
+ it "should import all objects from a PDF that has an indirect reference in a stream dict" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/indirect_reference.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/indirect_reference.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.size.should == 8
+ end
+@@ -47,13 +47,13 @@
+ end
+
+ it "should raise Prawn::Errors::TemplateError when given a non PDF as a template" do
+- filename = "#{Prawn::BASEDIR}/data/images/dice.png"
++ filename = "#{Prawn::DATADIR}/images/dice.png"
+
+ lambda { Prawn::Core::ObjectStore.new(:template => filename) }.should.raise(Prawn::Errors::TemplateError)
+ end
+
+ it "should raise Prawn::Errors::TemplateError when given an encrypted PDF as a template" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/encrypted.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/encrypted.pdf"
+
+ lambda { Prawn::Core::ObjectStore.new(:template => filename) }.should.raise(Prawn::Errors::TemplateError)
+ end
+@@ -118,37 +118,37 @@
+
+ describe "Prawn::ObjectStorie#object_id_for_page" do
+ it "should return the object ID of an imported template page" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/hexagon.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.object_id_for_page(0).should == 4
+ end
+
+ it "should return the object ID of the first imported template page" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/two_hexagons.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/two_hexagons.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.object_id_for_page(1).should == 4
+ end
+
+ it "should return the object ID of the last imported template page" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/two_hexagons.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/two_hexagons.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.object_id_for_page(-1).should == 6
+ end
+
+ it "should return the object ID of the first page of a template that uses nested Pages" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/nested_pages.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/nested_pages.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.object_id_for_page(1).should == 5
+ end
+
+ it "should return the object ID of the last page of a template that uses nested Pages" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/nested_pages.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/nested_pages.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.object_id_for_page(-1).should == 8
+ end
+
+ it "should return nil if given an invalid page number" do
+- filename = "#{Prawn::BASEDIR}/data/pdfs/hexagon.pdf"
++ filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.object_id_for_page(10).should == nil
+ end
+--- a/spec/jpg_spec.rb
++++ b/spec/jpg_spec.rb
+@@ -9,7 +9,7 @@
+ describe "When reading a JPEG file" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/pigs.jpg"
++ @filename = "#{Prawn::DATADIR}/images/pigs.jpg"
+ @img_data = File.open(@filename, "rb") { |f| f.read }
+ end
+
+--- a/spec/images_spec.rb
++++ b/spec/images_spec.rb
+@@ -7,7 +7,7 @@
+ describe "the image() function" do
+
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/pigs.jpg"
++ @filename = "#{Prawn::DATADIR}/images/pigs.jpg"
+ create_pdf
+ end
+
+@@ -44,17 +44,17 @@
+ end
+
+ it "should raise an UnsupportedImageType if passed a BMP" do
+- filename = "#{Prawn::BASEDIR}/data/images/tru256.bmp"
++ filename = "#{Prawn::DATADIR}/images/tru256.bmp"
+ lambda { @pdf.image filename, :at => [100,100] }.should.raise(Prawn::Errors::UnsupportedImageType)
+ end
+
+ it "should raise an UnsupportedImageType if passed an interlaced PNG" do
+- filename = "#{Prawn::BASEDIR}/data/images/dice_interlaced.png"
++ filename = "#{Prawn::DATADIR}/images/dice_interlaced.png"
+ lambda { @pdf.image filename, :at => [100,100] }.should.raise(Prawn::Errors::UnsupportedImageType)
+ end
+
+ it "should bump PDF version to 1.5 or greater on embedding 16-bit PNGs" do
+- @pdf.image "#{Prawn::BASEDIR}/data/images/16bit.png"
++ @pdf.image "#{Prawn::DATADIR}/images/16bit.png"
+ @pdf.state.version.should >= 1.5
+ end
+
+@@ -63,7 +63,7 @@
+ # or anything. OS X Preview handles those files just fine.
+ #
+ it "should embed 8-bit alpha channels for 16-bit PNGs" do
+- @pdf.image "#{Prawn::BASEDIR}/data/images/16bit.png"
++ @pdf.image "#{Prawn::DATADIR}/images/16bit.png"
+
+ output = @pdf.render
+ output.should =~ /\/BitsPerComponent 16/
+--- a/spec/line_wrap_spec.rb
++++ b/spec/line_wrap_spec.rb
+@@ -51,7 +51,7 @@
+ end
+
+ it "should break on zero-width space" do
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+ array = [{ :text => "hello#{Prawn::Text::ZWSP}world" }]
+ @arranger.format_array = array
+ string = @line_wrap.wrap_line(:arranger => @arranger,
+@@ -61,7 +61,7 @@
+ end
+
+ it "should not display zero-width space" do
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+ array = [{ :text => "hello#{Prawn::Text::ZWSP}world" }]
+ @arranger.format_array = array
+ string = @line_wrap.wrap_line(:arranger => @arranger,
+@@ -116,7 +116,7 @@
+ expected.force_encoding("utf-8") if "".respond_to?(:force_encoding)
+ string.should == expected
+
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+ @line_wrap = Prawn::Core::Text::Formatted::LineWrap.new
+
+ string = "hello#{Prawn::Text::SHY}world"
+@@ -137,7 +137,7 @@
+ :document => @pdf)
+ string.should == "helloworld"
+
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+ @line_wrap = Prawn::Core::Text::Formatted::LineWrap.new
+
+ string = "hello#{Prawn::Text::SHY}world"
+@@ -166,7 +166,7 @@
+ :document => @pdf)
+ string.should == "hello"
+
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+ @line_wrap = Prawn::Core::Text::Formatted::LineWrap.new
+ enough_width_for_hello_world = 68
+
+@@ -205,7 +205,7 @@
+ expected.force_encoding("utf-8") if "".respond_to?(:force_encoding)
+ string.should == expected
+
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+ @line_wrap = Prawn::Core::Text::Formatted::LineWrap.new
+
+ string = "hello#{Prawn::Text::SHY}-"
+--- a/spec/text_spec.rb
++++ b/spec/text_spec.rb
+@@ -259,7 +259,7 @@
+
+ it "should not raise an exception when providing Pathname instance as font" do
+ lambda {
+- @pdf.font Pathname.new("#{Prawn::BASEDIR}/data/fonts/comicsans.ttf")
++ @pdf.font Pathname.new("#{Prawn::DATADIR}/fonts/comicsans.ttf")
+ }.should.not.raise(Prawn::Errors::UnknownFont)
+ end
+
+@@ -274,7 +274,7 @@
+
+ it "should correctly render a utf-8 string when using a TTF font" do
+ str = "©" # copyright symbol
+- @pdf.font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
++ @pdf.font "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
+ @pdf.text str
+
+ # grab the text from the rendered PDF and ensure it matches
+@@ -315,9 +315,9 @@
+ Prawn::Errors::IncompatibleStringEncoding)
+ end
+ it "should not raise an exception when a shift-jis string is rendered" do
+- datafile = "#{Prawn::BASEDIR}/data/shift_jis_text.txt"
++ datafile = "#{Prawn::DATADIR}/shift_jis_text.txt"
+ sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets }
+- @pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf")
++ @pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+ lambda { @pdf.text sjis_str }.should.not.raise(
+ Prawn::Errors::IncompatibleStringEncoding)
+ end
+@@ -329,7 +329,7 @@
+ Prawn::Errors::IncompatibleStringEncoding)
+ end
+ it "should raise an exception when a shift-jis string is rendered" do
+- sjis_str = File.read("#{Prawn::BASEDIR}/data/shift_jis_text.txt")
++ sjis_str = File.read("#{Prawn::DATADIR}/shift_jis_text.txt")
+ lambda { @pdf.text sjis_str }.should.raise(
+ Prawn::Errors::IncompatibleStringEncoding)
+ end
+--- a/spec/document_spec.rb
++++ b/spec/document_spec.rb
+@@ -89,7 +89,7 @@
+
+ describe "Background template feature" do
+ before(:each) do
+- @filename = "#{Prawn::BASEDIR}/data/images/pigs.jpg"
++ @filename = "#{Prawn::DATADIR}/images/pigs.jpg"
+ @pdf = Prawn::Document.new(:background => @filename)
+ end
+ it "should place a background image if it is in options block" do
+@@ -235,7 +235,7 @@
+ doc_uncompressed = Prawn::Document.new
+ doc_compressed = Prawn::Document.new(:compress => true)
+ [doc_compressed, doc_uncompressed].each do |pdf|
+- pdf.font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
++ pdf.font "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+ pdf.text "更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历" * 10
+ end
+
+--- a/lib/prawn/core.rb
++++ b/lib/prawn/core.rb
+@@ -29,7 +29,11 @@
+
+ # The base source directory for Prawn as installed on the system
+ #
+- BASEDIR = File.expand_path(File.join(dir, '..', '..'))
++ #
++ BASEDIR = File.expand_path(File.join(dir, '..'))
++ # Definition of a data directory that may be not in BASEDIR/data (Debian patch)
++ # /usr/lib/ruby/vendor_ruby/prawn -> /usr/share/ruby-prawn/
++ DATADIR = File.expand_path(File.join(dir, '..', '..', '..', '..', 'share', 'ruby-prawn'))
+
+ # Whe set to true, Prawn will verify hash options to ensure only valid keys
+ # are used. Off by default.
+--- a/lib/prawn/encoding.rb
++++ b/lib/prawn/encoding.rb
+@@ -84,7 +84,7 @@
+ ]
+
+ def initialize
+- @mapping_file = "#{Prawn::BASEDIR}/data/encodings/win_ansi.txt"
++ @mapping_file = "#{Prawn::DATADIR}/encodings/win_ansi.txt"
+ load_mapping if self.class.mapping.empty?
+ end
+
diff --git a/debian/patches/0210_change_spec_data_to_datadir_pdfs.patch b/debian/patches/0210_change_spec_data_to_datadir_pdfs.patch
new file mode 100644
index 0000000..0955cb6
--- /dev/null
+++ b/debian/patches/0210_change_spec_data_to_datadir_pdfs.patch
@@ -0,0 +1,80 @@
+Description: reflect the fact that spec/data moved to data/spec
+ The specs use some (one) pdf files stored in spec/data. In order to test the
+ library installed in debian/ruby-prawn/, these files are moved to data/spec, so
+ that they can be installed too (see debian/ruby-prawn.install).
+ The code of the specs has to be modified to find correctly the files which moved away.
+Author: Cédric Boutillier <cedric.boutillier at gmail.com>
+Last-Update: 2011-11-15
+
+--- a/spec/object_store_spec.rb
++++ b/spec/object_store_spec.rb
+@@ -16,20 +16,20 @@
+ end
+
+ it "should import objects from an existing PDF" do
+- filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
++ filename = "#{Prawn::DATADIR}/spec/curves.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.size.should == 5
+ end
+
+ it "should point to existing roots when importing objects from an existing PDF" do
+- filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
++ filename = "#{Prawn::DATADIR}/spec/curves.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.info.class.should == Prawn::Core::Reference
+ store.root.class.should == Prawn::Core::Reference
+ end
+
+ it "should initialize with pages when importing objects from an existing PDF" do
+- filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
++ filename = "#{Prawn::DATADIR}/spec/curves.pdf"
+ store = Prawn::Core::ObjectStore.new(:template => filename)
+ store.pages.data[:Count].should == 1
+ end
+--- a/spec/template_spec.rb
++++ b/spec/template_spec.rb
+@@ -2,7 +2,7 @@
+
+ describe "Document built from a template" do
+ it "should have the same page count as the source document" do
+- filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
++ filename = "#{Prawn::DATADIR}/spec/curves.pdf"
+ @pdf = Prawn::Document.new(:template => filename)
+ page_counter = PDF::Inspector::Page.analyze(@pdf.render)
+
+@@ -10,14 +10,14 @@
+ end
+
+ it "should have start with the Y cursor at the top of the document" do
+- filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
++ filename = "#{Prawn::DATADIR}/spec/curves.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+ (@pdf.y == nil).should == false
+ end
+
+ it "should respect margins set by Prawn" do
+- filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
++ filename = "#{Prawn::DATADIR}/spec/curves.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename, :margin => 0)
+ assert_equal @pdf.page.margins, { :left => 0,
+@@ -44,7 +44,7 @@
+ end
+
+ it "should not add an extra restore_graphics_state operator to the end of any content stream" do
+- filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
++ filename = "#{Prawn::DATADIR}/spec/curves.pdf"
+
+ @pdf = Prawn::Document.new(:template => filename)
+ output = StringIO.new(@pdf.render)
+@@ -165,7 +165,7 @@
+ end
+
+ describe "Document#start_new_page with :template option" do
+- filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
++ filename = "#{Prawn::DATADIR}/spec/curves.pdf"
+
+ it "should set the imported page's parent to the document pages catalog" do
+ @pdf = Prawn::Document.new()
diff --git a/debian/patches/series b/debian/patches/series
index c24f34d..0b0931e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
0100_remove_bundler_rubygems_stuff.patch
+0200_replace_BASEDIR_data_by_DATADIR.patch
+0210_change_spec_data_to_datadir_pdfs.patch
--
ruby-prawn.git
More information about the Pkg-ruby-extras-commits
mailing list