blackwinter-libxslt-ruby 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,81 @@
1
+ == 0.9.1 / 2008-11-24 Charlie Savage
2
+
3
+ * Support libxml-ruby bindings 0.9.3 and above which has a changed
4
+ external api.
5
+
6
+ * Remove unused xslt transform wrapper class.
7
+
8
+ == 0.9.0 / 2008-11-18 Charlie Savage
9
+
10
+ * Add back in support for exslt.
11
+
12
+ * Support libxml-ruby bindings 0.9.0.
13
+
14
+ == 0.8.2 / 2008-07-21 Charlie Savage
15
+
16
+ * To use LibXSLT you can either require 'xslt' or require 'libxslt'.
17
+ The differences is that require 'xslt' mixes the LibXML and
18
+ LIBXSLT modules into the global namespace, thereby allowing
19
+ you to write code such as:
20
+ stylesheet = XSLT::Stylesheet.new(XML::Document.new). Note that
21
+ this is different from 0.8.0 release and may require updating your code.
22
+
23
+ * Support for libxml-ruby 0.8.2
24
+
25
+ * Improved Windows support - libxslt-ruby should now work out of the box.
26
+
27
+ == 0.8.0 / 2008-07-10 Charlie Savage
28
+
29
+ * Fix memory errors when reusing a stylehseet
30
+
31
+ * Added support for setting xsl::param values
32
+
33
+ * Updated RDocs.
34
+
35
+ * Moved to LibXSLT namespace
36
+
37
+
38
+ == 0.7.0 / 2008-07-10 Charlie Savage
39
+
40
+ * Ability to reuse the same stylesheet multiple times
41
+
42
+ * Simpler api
43
+
44
+ * Compatibility layer for pre-0.7.0 versions
45
+
46
+ * Major rewrite, resulting in significantly less code
47
+
48
+ * Updated RDocs.
49
+
50
+
51
+ == 0.6.0 / 2008-07-01 Charlie Savage
52
+
53
+ * Now packaged as a separate gem
54
+
55
+ * Windows support (both lots of memory fixes and binaries)
56
+
57
+ * New libxslt.rb ruby wrapper, so programs can simply say require 'xslt'
58
+
59
+
60
+ == 0.5.0 / 2006-02-27 Ross Bamford <rosco at roscopeco.co.uk>
61
+
62
+ * Source layout for Rubygem release
63
+
64
+ * Fixed unit tests (set_up to setup, directory handling)
65
+
66
+ * Updated extconf to remove shell-script dependency
67
+
68
+ * Fixed multiple symbol declarations for -fno-common
69
+
70
+
71
+ == 0.4.0 / 2003-12-15 Martin Povolny <martin@solnet.cz>
72
+
73
+ * libxslt.c: added call to exsltRegisterAll to enable exslt extensions
74
+
75
+ * extconf.rb: added -lexslt
76
+
77
+ == 0.3.0 / 2004-02-01 Martin Povolny <martin@solnet.cz>
78
+
79
+ * libxslt.c: added call to ruby_init_xslt_transform_context() to make it
80
+ work on ruby1.8
81
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ # $Id$
2
+
3
+ Copyright (c) 2002-2006 Sean Chittenden <sean@chittenden.org> and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README ADDED
@@ -0,0 +1,164 @@
1
+ = libxslt-ruby
2
+
3
+ == Overview
4
+
5
+ The libxslt gem provides Ruby language bindings for GNOME's Libxslt
6
+ toolkit. It is free software, released under the MIT License.
7
+
8
+
9
+ == Requirements
10
+
11
+ libxslt-ruby requires Ruby 1.8.4 or higher. It is dependent on
12
+ the following libraries to function properly:
13
+
14
+ * libm (math routines: very standard)
15
+ * libz (zlib)
16
+ * libiconv
17
+ * libxml2
18
+ * libxslt
19
+ * libxml-ruby bindings
20
+
21
+ If you are running Linux or Unix you'll need a C compiler so the extension
22
+ can be compiled when it is installed. If you are running Windows, then install the Windows specific RubyGem which
23
+ includes an already built extension.
24
+
25
+ !!!NOTE!!! The libxml-ruby and libxslt-ruby bindings must absolutely, positively,
26
+ without a doubt share the same libxml2 library. This is because libxslt modifies
27
+ XML documents created by libxml2. If there are two copies of libxml2 on your
28
+ system, then when XML documents allocated in copy #1 are manipulated by copy #2,
29
+ a segmentation fault will occur. So make sure that your system has only one copy of libxml2
30
+ installed.
31
+
32
+
33
+ == INSTALLATION
34
+
35
+ The easiest way to install libxslt-ruby is via Ruby Gems. To install:
36
+
37
+ <tt>gem install libxslt-ruby</tt>
38
+
39
+ If you are running Windows, make sure to install the Win32 RubyGem which
40
+ includes an already built binary file. The binary is built against
41
+ libxml2 version 2.6.32, iconv version 1.11 and libxslt version 1.1.24.
42
+ Binaries for libxml2 and iconv are provided in the libxml-ruby bindings,
43
+ while a binary for libxslt is provided in the libxslt-ruby bindings.
44
+
45
+ The Windows binaries are biult with MingW. The gem also includes
46
+ a Microsoft VC++ 2005 solution. If you wish to run a debug version
47
+ of libxml-ruby on Windows, then it is highly recommended
48
+ you use VC++.
49
+
50
+
51
+ == USAGE
52
+
53
+ For in-depth information about using libxslt-ruby please refer
54
+ to its online Rdoc documentation.
55
+
56
+ All libxslt classes are in the LibXSLT::XSLT module. The simplest
57
+ way to use libxslt is to require 'xslt'. This will mixin the
58
+ LibXML and LibXSLT modules into the global namespace, allowing you to
59
+ write code like this:
60
+
61
+ require 'xslt'
62
+ document = XML::Document.new
63
+ stylesheett = XSLT::Stylesheet.new(document)
64
+
65
+ If you prefer not to add the LibXSLT module to the global namepace, then
66
+ write your code like this:
67
+
68
+ require 'libxslt'
69
+
70
+ class MyClass
71
+ def some_method
72
+ document = LibXML::XML::Document.new
73
+ stylesheett = LibXSLT::XSLT::Stylesheet.new(document)
74
+ end
75
+ end
76
+
77
+ Given an XML file like:
78
+
79
+ <?xml version="1.0" encoding="UTF-8"?>
80
+ <?xml-stylesheet href="fuzface.xsl" type="text/xsl"?>
81
+
82
+ <commentary>
83
+ <meta>
84
+ <author>
85
+ <first_name>Sean</first_name>
86
+ <last_name>Chittenden</last_name>
87
+ <email>sean@chittenden.org</email>
88
+ </author>
89
+ <version>$Version$</version>
90
+ <date>$Date$</date>
91
+ <id>$Id$</id> <title>Fuzface...</title>
92
+ <subtitle>The Internet's a big place and here's some proof...</subtitle>
93
+ </meta>
94
+
95
+ <body>
96
+ <para>
97
+ I think it's a tragedy that I'm going to start off my new
98
+ commentary by talking about facial hair and the Internet.
99
+ Something about that just screams pathetic, but whatever: it's
100
+ humor and that's life.
101
+ </para>
102
+ </body>
103
+ </commentary>
104
+
105
+ And an XSLT file like this:
106
+
107
+ <?xml version="1.0" ?>
108
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
109
+ <xsl:template match="/">
110
+ <xsl:element name="html">
111
+ <xsl:element name="head">
112
+ <xsl:element name="title">Ramblings - <xsl:value-of select="commentary/meta/title" /> - <xsl:value-of select="commentary/meta/subtitle" /></xsl:element>
113
+ </xsl:element>
114
+
115
+ <xsl:element name="body">
116
+ <xsl:element name="h1"><xsl:value-of select="commentary/meta/title" /></xsl:element>
117
+ <xsl:element name="h3"><xsl:value-of select="commentary/meta/subtitle" /></xsl:element>
118
+ By: <xsl:value-of select="commentary/meta/author/first_name" /> <xsl:value-of select="commentary/meta/author/last_name" /><xsl:element name="br" />
119
+ Date: <xsl:value-of select="commentary/meta/date" /><xsl:element name="br" />
120
+
121
+ <xsl:for-each select="./commentary/body">
122
+ <xsl:apply-templates />
123
+ </xsl:for-each>
124
+
125
+ </xsl:element>
126
+ </xsl:element>
127
+ </xsl:template>
128
+
129
+ <xsl:template match="para">
130
+ <xsl:element name="p">
131
+ <xsl:value-of select="." />
132
+ </xsl:element>
133
+ </xsl:template>
134
+ </xsl:stylesheet>
135
+
136
+ We can easily transform the XML with the following ruby code:
137
+
138
+ require 'xslt'
139
+
140
+ # Create a new XSL Transform
141
+ stylesheet_doc = XML::Document.file('files/fuzface.xsl')
142
+ stylesheet = LibXSLT::Stylesheet.new(stylesheet_doc)
143
+
144
+ # Transform a xml document
145
+ xml_doc = XML::Document.file('files/fuzface.xml')
146
+ result = stylesheet.apply(xml_doc)
147
+
148
+ You can then print, save or manipulate the returned document.
149
+
150
+ == License
151
+
152
+ See LICENSE for license information.
153
+
154
+ == DOCUMENTATION
155
+
156
+ RDoc comments are included - run 'rake doc' to generate documentation.
157
+ You can find the latest documentation at:
158
+
159
+ * http://libxsl.rubyforge.org/
160
+
161
+ == MORE INFORMATION
162
+
163
+ For more information please refer to the documentation. If you have any
164
+ questions, please send email to libxml-devel@rubyforge.org.
data/Rakefile ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "rake/extensiontask"
5
+ require "rake/testtask"
6
+ require 'rdoc/task'
7
+ require "grancher/task"
8
+ require "yaml"
9
+
10
+ GEM_NAME = "libxslt-ruby"
11
+ SO_NAME = "libxslt_ruby"
12
+
13
+ # Read the spec file
14
+ spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
15
+
16
+ # Setup compile tasks
17
+ Rake::ExtensionTask.new do |ext|
18
+ ext.gem_spec = spec
19
+ ext.name = SO_NAME
20
+ ext.ext_dir = "ext/libxslt"
21
+ ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
22
+ ext.config_options << "--with-xml2-include=C:/MinGW/local/include/libxml2"
23
+ ext.config_options << "--with-xslt-include=C:/MinGW/local/include/libxslt"
24
+ ext.config_options << "--with-exslt-include=C:/MinGW/local/include/libexslt"
25
+ end
26
+
27
+ # Setup generic gem
28
+ Gem::PackageTask.new(spec) do |pkg|
29
+ pkg.package_dir = 'pkg'
30
+ pkg.need_tar = false
31
+ end
32
+
33
+ # Setup Windows Gem
34
+ if RUBY_PLATFORM.match(/win32|mingw32/)
35
+ binaries = (FileList['lib/**/*.so',
36
+ 'lib/**/*dll'])
37
+
38
+ # Windows specification
39
+ win_spec = spec.clone
40
+ win_spec.platform = Gem::Platform::CURRENT
41
+ win_spec.files += binaries.to_a
42
+
43
+ # Unset extensions
44
+ win_spec.extensions = nil
45
+
46
+ # Rake task to build the windows package
47
+ Gem::PackageTask.new(win_spec) do |pkg|
48
+ pkg.package_dir = 'pkg'
49
+ pkg.need_tar = false
50
+ end
51
+ end
52
+
53
+ # RDoc Task
54
+ desc "Generate rdoc documentation"
55
+ RDoc::Task.new("rdoc") do |rdoc|
56
+ rdoc.rdoc_dir = 'doc'
57
+ rdoc.title = "libxml-xslt"
58
+ # Show source inline with line numbers
59
+ rdoc.options << "--line-numbers"
60
+ # Make the readme file the start page for the generated html
61
+ rdoc.options << '--main' << 'README'
62
+ rdoc.rdoc_files.include('doc/*.rdoc',
63
+ 'ext/**/*.c',
64
+ 'lib/**/*.rb',
65
+ 'CHANGES',
66
+ 'README',
67
+ 'LICENSE')
68
+ end
69
+
70
+ # Test Task
71
+ Rake::TestTask.new do |t|
72
+ t.libs << "test"
73
+ t.test_files = FileList['test/test*.rb'].exclude('test/test_suite.rb')
74
+ t.verbose = true
75
+ end
@@ -0,0 +1,146 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ # See the LICENSE file for copyright and distribution information
4
+
5
+ require 'mkmf'
6
+ require 'rbconfig'
7
+
8
+ require 'rubygems'
9
+ $preload = nil
10
+ $INCFLAGS << " -I/usr/local/include"
11
+ $LIBPATH.push(Config::CONFIG['libdir'])
12
+
13
+ def crash(str)
14
+ print(" extconf failure: %s\n", str)
15
+ exit 1
16
+ end
17
+
18
+ # Directories
19
+ dir_config('iconv')
20
+ dir_config('zlib')
21
+ dir_config('xml2')
22
+ dir_config('xslt')
23
+ dir_config('exslt')
24
+ dir_config('libxml-ruby')
25
+
26
+ # First get zlib
27
+ unless have_library('z', 'inflate') or
28
+ have_library('zlib', 'inflate') or
29
+ have_library('zlib1', 'inflate') or
30
+ have_library('libz', 'inflate')
31
+ crash('need zlib')
32
+ else
33
+ $defs.push('-DHAVE_ZLIB_H')
34
+ end
35
+
36
+ unless have_library('iconv','iconv_open') or
37
+ have_library('iconv','libiconv_open') or
38
+ have_library('libiconv', 'libiconv_open') or
39
+ have_library('libiconv', 'iconv_open') or
40
+ have_library('c','iconv_open') or
41
+ have_library('recode','iconv_open') or
42
+ have_library('iconv')
43
+ crash(<<-EOL)
44
+ need libiconv.
45
+
46
+ Install the libiconv or try passing one of the following options
47
+ to extconf.rb:
48
+
49
+ --with-iconv-dir=/path/to/iconv
50
+ --with-iconv-lib=/path/to/iconv/lib
51
+ --with-iconv-include=/path/to/iconv/include
52
+ EOL
53
+ end
54
+
55
+
56
+ unless (have_library('xml2', 'xmlXPtrNewRange') or
57
+ have_library('libxml2', 'xmlXPtrNewRange') or
58
+ find_library('xml2', 'xmlXPtrNewRange', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
59
+ (have_header('libxml/xmlversion.h') or
60
+ find_header('libxml/xmlversion.h',
61
+ '/opt/include/libxml2',
62
+ '/usr/local/include/libxml2',
63
+ '/usr/include/libxml2'))
64
+ crash(<<-EOL)
65
+ need libxml2.
66
+
67
+ Install the library or try one of the following options to extconf.rb:
68
+
69
+ --with-xml2-dir=/path/to/libxml2
70
+ --with-xml2-lib=/path/to/libxml2/lib
71
+ --with-xml2-include=/path/to/libxml2/include
72
+ EOL
73
+ end
74
+
75
+ unless (have_library('xslt','xsltApplyStylesheet') or
76
+ have_library('libxslt','xsltApplyStylesheet') or
77
+ find_library('xslt', 'xsltApplyStylesheet', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
78
+ (have_header('xslt.h') or
79
+ find_header('xslt.h',
80
+ '/opt/include/libxslt',
81
+ '/usr/local/include/libxslt',
82
+ '/usr/include/libxslt'))
83
+ crash(<<-EOL)
84
+ need libxslt.
85
+
86
+ Install the library or try one of the following options to extconf.rb:
87
+
88
+ --with-xslt-dir=/path/to/libxslt
89
+ --with-xslt-lib=/path/to/libxslt/lib
90
+ --with-xslt-include=/path/to/libxslt/include
91
+ EOL
92
+ end
93
+
94
+ unless (have_library('exslt','exsltRegisterAll') or
95
+ have_library('libexslt','exsltRegisterAll') or
96
+ find_library('exslt', 'exsltRegisterAll', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
97
+ (have_header('exslt.h') or
98
+ find_header('exslt.h',
99
+ '/opt/include/libexslt',
100
+ '/usr/local/include/libexslt',
101
+ '/usr/include/libexslt'))
102
+ crash(<<-EOL)
103
+ Need libexslt.
104
+ Install the library or try one of the following options to extconf.rb:
105
+ --with-exslt-dir=/path/to/libexslt
106
+ --with-exslt-lib=/path/to/libexslt/lib
107
+ --with-exslt-include=/path/to/libexslt/include
108
+ EOL
109
+ end
110
+
111
+ # Figure out where libxml-ruby is installed
112
+ gem_specs = Gem.source_index.find_name('libxml-ruby')
113
+ if gem_specs.empty?
114
+ crash(<<-EOL)
115
+ libxml-ruby bindings must be installed
116
+ EOL
117
+ end
118
+
119
+ gem_specs = gem_specs.sort_by {|spec| spec.version}.reverse
120
+ libxml_ruby_path = gem_specs.first.full_gem_path
121
+
122
+ $INCFLAGS += " -I#{libxml_ruby_path}/ext"
123
+
124
+ unless have_header('libxml/ruby_libxml.h')
125
+ crash(<<-EOL)
126
+ Need headers for libxml-ruby.
127
+ EOL
128
+ end
129
+
130
+ if RUBY_PLATFORM.match(/win32|mingw32/)
131
+ RUBY_VERSION =~ /(\d+.\d+)/
132
+ $LIBPATH << File.join(libxml_ruby_path, "lib")
133
+ $LIBPATH << File.join(libxml_ruby_path, "lib", $1)
134
+
135
+ headers = ['iconv.h', 'libxml/ruby_libxml.h']
136
+ unless have_library(':libxml_ruby.so', 'Init_libxml_ruby', headers)
137
+ crash(<<-EOL)
138
+ Need libxml-ruby
139
+ Please install libxml-ruby or specify the path to the gem via:
140
+ --with-libxml-ruby=/path/to/libxml-ruby gem
141
+ EOL
142
+ end
143
+ end
144
+
145
+ create_header()
146
+ create_makefile("libxslt_ruby")