From ca131883431fe5020630ac4ca437c3da06d0afad Mon Sep 17 00:00:00 2001 From: why Date: Thu, 27 Jul 2006 02:00:52 +0000 Subject: [PATCH] * Rakefile: make gems off the REVISION number by default. * lib/hpricot/tag.rb: make sure the script tag (and other PCDATA wrappers) don't get output as empty elements. git-svn-id: https://code.whytheluckystiff.net/svn/hpricot/trunk@30 9e82565c-fa0a-db11-9fa0-00132028b6dc --- Rakefile | 12 ++++++------ lib/hpricot/tag.rb | 2 +- test/test_parser.rb | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index f21ceeb..8be3b81 100644 --- a/Rakefile +++ b/Rakefile @@ -7,8 +7,8 @@ require 'fileutils' include FileUtils NAME = "hpricot" -VERS = "0.3" -PKG_REVISION = ".0" +REV = File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil +VERS = "0.3" + (REV ? ".#{REV}" : "") CLEAN.include ['ext/hpricot_scan/*.{bundle,so,obj,pdb,lib,def,exp}', 'ext/hpricot_scan/Makefile', '**/.*.sw?', '*.gem', '.config'] @@ -40,7 +40,7 @@ end spec = Gem::Specification.new do |s| s.name = NAME - s.version = VERS + PKG_REVISION + s.version = VERS s.platform = Gem::Platform::RUBY s.has_rdoc = false s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"] @@ -110,7 +110,7 @@ PKG_FILES = FileList[ Win32Spec = Gem::Specification.new do |s| s.name = NAME - s.version = VERS + PKG_REVISION + s.version = VERS s.platform = Gem::Platform::WIN32 s.has_rdoc = false s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"] @@ -128,7 +128,7 @@ Win32Spec = Gem::Specification.new do |s| s.bindir = "bin" end -WIN32_PKG_DIR = "hpricot-" + VERS + PKG_REVISION +WIN32_PKG_DIR = "hpricot-" + VERS file WIN32_PKG_DIR => [:package] do sh "tar zxf pkg/#{WIN32_PKG_DIR}.tgz" @@ -146,7 +146,7 @@ task :rubygems_win32 => ["hpricot_scan_win32"] do Dir.chdir("#{WIN32_PKG_DIR}") do Gem::Builder.new(Win32Spec).build verbose(true) { - mv Dir["*.gem"].first, "../pkg/hpricot-#{VERS + PKG_REVISION}-mswin32.gem" + mv Dir["*.gem"].first, "../pkg/hpricot-#{VERS}-mswin32.gem" } end end diff --git a/lib/hpricot/tag.rb b/lib/hpricot/tag.rb index a3f2ae5..d9d1e2f 100644 --- a/lib/hpricot/tag.rb +++ b/lib/hpricot/tag.rb @@ -32,7 +32,7 @@ def empty?; @children.empty? end [m, "#{m}="].each { |m2| define_method(m2) { |*a| @stag.send(m2, *a) } } end def output(out) - if empty? + if empty? and ElementContent[@stag.name] != :CDATA @stag.output(out, :style => :empty) else @stag.output(out) diff --git a/test/test_parser.rb b/test/test_parser.rb index 7476879..9b2b564 100644 --- a/test/test_parser.rb +++ b/test/test_parser.rb @@ -9,6 +9,7 @@ def setup @basic = Hpricot.parse(TestFiles::BASIC) @boingboing = Hpricot.parse(TestFiles::BOINGBOING) @immob = Hpricot.parse(TestFiles::IMMOB) + @utf8 = Hpricot.parse(TestFiles::UTF8) end # def test_set_attr @@ -119,4 +120,7 @@ def test_body_newlines def test_javascripts assert_equal 3, (@immob/:script)[0].innerHTML.scan(/