libxslt-ruby 1.0.1-x86-mingw32 → 1.0.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,17 +6,17 @@ class TestDeprecated < Test::Unit::TestCase
6
6
  def setup()
7
7
  xsl_file = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
8
8
  xml_file = File.join(File.dirname(__FILE__), 'files/fuzface.xml')
9
-
9
+
10
10
  @xslt = XML::XSLT.file(xsl_file)
11
11
  @xslt.doc = XML::Document.file(xml_file)
12
12
  @stylesheet = @xslt.parse
13
13
  end
14
-
14
+
15
15
  def tear_down()
16
16
  @xslt = nil
17
17
  @stylesheet = nil
18
18
  end
19
-
19
+
20
20
  def test_constants
21
21
  assert_instance_of(Fixnum, XML::XSLT::MAX_DEPTH)
22
22
  assert_instance_of(Fixnum, XML::XSLT::MAX_SORT)
@@ -33,15 +33,15 @@ class TestDeprecated < Test::Unit::TestCase
33
33
  assert_instance_of(String, XML::XSLT::NAMESPACE_XALAN)
34
34
  assert_instance_of(String, XML::XSLT::NAMESPACE_NORM_SAXON)
35
35
  end
36
-
36
+
37
37
  def test_new
38
38
  xslt = XML::XSLT.new
39
39
  assert_instance_of(XML::XSLT::Stylesheet, xslt)
40
-
40
+
41
41
  xslt.filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
42
42
  assert_instance_of(String, xslt.filename)
43
43
  end
44
-
44
+
45
45
  def test_file_type
46
46
  assert_instance_of(XML::XSLT::Stylesheet, @xslt)
47
47
  end
@@ -49,21 +49,21 @@ class TestDeprecated < Test::Unit::TestCase
49
49
  def test_doc
50
50
  xsl_file = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
51
51
  xml_file = File.join(File.dirname(__FILE__), 'files/fuzface.xml')
52
-
52
+
53
53
  xslt = XML::XSLT.file(xsl_file)
54
54
  xslt.doc = XML::Document.file(xml_file)
55
55
  assert_instance_of(XML::Document, xslt.doc)
56
56
  end
57
-
57
+
58
58
  def test_parse
59
59
  xsl_file = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
60
60
  xml_file = File.join(File.dirname(__FILE__), 'files/fuzface.xml')
61
-
61
+
62
62
  xslt = XML::XSLT.file(xsl_file)
63
63
  stylesheet = xslt.parse
64
64
  assert_instance_of(XML::XSLT::Stylesheet, stylesheet)
65
65
  end
66
-
66
+
67
67
  def test_parse
68
68
  assert_instance_of(XML::XSLT::Stylesheet, @stylesheet)
69
69
  end
@@ -76,20 +76,22 @@ class TestDeprecated < Test::Unit::TestCase
76
76
 
77
77
  def test_save
78
78
  @stylesheet.apply
79
- @stylesheet.save("text.xml")
79
+ @stylesheet.save(file = 'text.xml')
80
+ ensure
81
+ File.unlink(file) if file && File.exist?(file)
80
82
  end
81
-
83
+
82
84
  def test_print_invalid
83
85
  @stylesheet.apply
84
86
  @stylesheet.print
85
87
  end
86
-
88
+
87
89
  def test_save_invalid
88
90
  assert_raises(ArgumentError) do
89
91
  @stylesheet.save("str")
90
92
  end
91
93
  end
92
-
94
+
93
95
  def test_print_invalid
94
96
  assert_raises(ArgumentError) do
95
97
  @stylesheet.print
@@ -0,0 +1,70 @@
1
+ # encoding: UTF-8
2
+ require 'test/unit'
3
+ require 'test_helper'
4
+
5
+ class TestExslt < Test::Unit::TestCase
6
+ def setup
7
+ @namespace = 'http://test.ext'
8
+ @name = 'ext-func'
9
+ @func = lambda { |xp| xp.to_a.join('|') }
10
+ end
11
+
12
+ def teardown
13
+ LibXSLT::XSLT.instance_variable_get(:@module_function_registry).clear
14
+ # or
15
+ #LibXSLT::XSLT.unregister_module_function(@namespace, @name)
16
+ end
17
+
18
+ def test_register
19
+ assert !LibXSLT::XSLT.registered_module_function?(@namespace, @name)
20
+ assert LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
21
+ assert LibXSLT::XSLT.registered_module_function?(@namespace, @name)
22
+ end
23
+
24
+ def test_register_no_block
25
+ assert_raises(ArgumentError, 'no block given') {
26
+ LibXSLT::XSLT.register_module_function(@namespace, @name)
27
+ }
28
+ end
29
+
30
+ def test_register_repeated
31
+ assert_equal @func, LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
32
+ assert_equal @func, LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
33
+ assert_not_equal @func, LibXSLT::XSLT.register_module_function(@namespace, @name) { |*| }
34
+ end
35
+
36
+ def test_unregister
37
+ test_register # need to register before we can unregister
38
+ assert LibXSLT::XSLT.unregister_module_function(@namespace, @name)
39
+ assert !LibXSLT::XSLT.registered_module_function?(@namespace, @name)
40
+ end
41
+
42
+ def test_unregister_no_register
43
+ assert !LibXSLT::XSLT.registered_module_function?(@namespace, @name)
44
+ assert !LibXSLT::XSLT.unregister_module_function(@namespace, @name)
45
+ end
46
+
47
+ def test_unregister_repeated
48
+ test_register # need to register before we can unregister
49
+ assert_equal @func, LibXSLT::XSLT.unregister_module_function(@namespace, @name)
50
+ assert_nil LibXSLT::XSLT.unregister_module_function(@namespace, @name)
51
+ end
52
+
53
+ def test_callback
54
+ doc = XML::Document.file(File.join(File.dirname(__FILE__), 'files/fuzface.xml'))
55
+ xpath = '/commentary/meta/author/*'
56
+ stylesheet = XSLT::Stylesheet.new(XML::Document.string(<<-EOT))
57
+ <?xml version="1.0" ?>
58
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="#{@namespace}">
59
+ <xsl:template match="/">
60
+ <xsl:element name="root">
61
+ <xsl:value-of select="ext:#{@name}(#{xpath})" />
62
+ </xsl:element>
63
+ </xsl:template>
64
+ </xsl:stylesheet>
65
+ EOT
66
+
67
+ assert LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
68
+ assert_equal @func[doc.find(xpath)], stylesheet.apply(doc).root.content
69
+ end
70
+ end
data/test/test_helper.rb CHANGED
@@ -1,12 +1,16 @@
1
- # encoding: UTF-8
2
-
3
- # To make testing/debugging easier, test within this source tree versus an installed gem
4
-
5
- dir = File.dirname(__FILE__)
6
- root = File.expand_path(File.join(dir, '..'))
7
- lib = File.expand_path(File.join(root, 'lib'))
8
-
9
- $LOAD_PATH << lib
10
-
11
- require 'xslt'
12
-
1
+ # encoding: UTF-8
2
+
3
+ # To make testing/debugging easier, test within this source tree versus an installed gem
4
+
5
+ dir = File.dirname(__FILE__)
6
+ root = File.expand_path(File.join(dir, '..'))
7
+ lib = File.expand_path(File.join(root, 'lib'))
8
+
9
+ $LOAD_PATH << lib
10
+
11
+ begin
12
+ require 'xslt'
13
+ rescue LoadError
14
+ require 'rubygems'
15
+ require 'xslt'
16
+ end
@@ -8,16 +8,16 @@ class TestStylesheet < Test::Unit::TestCase
8
8
  doc = XML::Document.file(filename)
9
9
  @stylesheet = XSLT::Stylesheet.new(doc)
10
10
  end
11
-
11
+
12
12
  def tear_down
13
13
  @stylesheet = nil
14
14
  end
15
-
15
+
16
16
  def doc
17
17
  filename = File.join(File.dirname(__FILE__), 'files/fuzface.xml')
18
18
  XML::Document.file(filename)
19
19
  end
20
-
20
+
21
21
  def test_class
22
22
  assert_instance_of(XSLT::Stylesheet, @stylesheet)
23
23
  end
@@ -25,7 +25,7 @@ class TestStylesheet < Test::Unit::TestCase
25
25
  def test_apply
26
26
  result = @stylesheet.apply(doc)
27
27
  assert_instance_of(XML::Document, result)
28
-
28
+
29
29
  paragraphs = result.find('//p')
30
30
  assert_equal(11, paragraphs.length)
31
31
  end
@@ -35,72 +35,72 @@ class TestStylesheet < Test::Unit::TestCase
35
35
  test_apply
36
36
  end
37
37
  end
38
-
38
+
39
39
  def test_params
40
40
  filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
41
41
  sdoc = XML::Document.file(filename)
42
-
42
+
43
43
  filename = File.join(File.dirname(__FILE__), 'files/params.xml')
44
44
  stylesheet = XSLT::Stylesheet.new(sdoc)
45
45
  doc = XML::Document.file(filename)
46
-
46
+
47
47
  # Start with no params
48
48
  result = stylesheet.apply(doc)
49
49
  assert_equal('<article>failure</article>', result.root.to_s)
50
-
50
+
51
51
  # Now try with params as hash. /doc is evaluated
52
52
  # as an xpath expression
53
53
  result = stylesheet.apply(doc, 'bar' => "/doc")
54
54
  assert_equal('<article>abc</article>', result.root.to_s)
55
-
55
+
56
56
  # Now try with params as hash. Note the double quote
57
57
  # on success - we want to pass a literal string and
58
58
  # not an xpath expression.
59
59
  result = stylesheet.apply(doc, 'bar' => "'success'")
60
60
  assert_equal('<article>success</article>', result.root.to_s)
61
-
61
+
62
62
  # Now try with params as an array.
63
63
  result = stylesheet.apply(doc, ['bar', "'success'"])
64
64
  assert_equal('<article>success</article>', result.root.to_s)
65
-
65
+
66
66
  # Now try with invalid array.
67
67
  result = stylesheet.apply(doc, ['bar'])
68
68
  assert_equal('<article>failure</article>', result.root.to_s)
69
69
  end
70
-
70
+
71
71
  # -- Memory Tests ----
72
72
  def test_doc_ownership
73
- 10.times do
73
+ 10.times do
74
74
  filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
75
75
  sdoc = XML::Document.file(filename)
76
76
  GC.start
77
77
  assert_equal(173, sdoc.to_s.length)
78
78
  end
79
- end
80
-
79
+ end
80
+
81
81
  def test_stylesheet_ownership
82
- 10.times do
82
+ 10.times do
83
83
  filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
84
84
  sdoc = XML::Document.file(filename)
85
85
  stylesheet = XSLT::Stylesheet.new(sdoc)
86
-
86
+
87
87
  sdoc = nil
88
88
  GC.start
89
-
89
+
90
90
  rdoc = stylesheet.apply(doc)
91
91
  assert_equal(5963, rdoc.to_s.length)
92
92
  end
93
93
  end
94
-
94
+
95
95
  def test_result_ownership
96
- 10.times do
96
+ 10.times do
97
97
  filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
98
98
  sdoc = XML::Document.file(filename)
99
99
  stylesheet = XSLT::Stylesheet.new(sdoc)
100
-
100
+
101
101
  rdoc = stylesheet.apply(doc)
102
102
  rdoc = nil
103
103
  GC.start
104
104
  end
105
- end
105
+ end
106
106
  end
data/test/test_suite.rb CHANGED
@@ -7,4 +7,5 @@ Dir.chdir(dir)
7
7
 
8
8
  require 'test_libxslt'
9
9
  require 'test_stylesheet'
10
- require 'test_deprecated'
10
+ require 'test_deprecated'
11
+ require 'test_exslt'
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libxslt-ruby
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease:
5
- version: 1.0.1
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 2
10
+ version: 1.0.2
6
11
  platform: x86-mingw32
7
12
  authors:
8
13
  - Charlie Savage
@@ -10,8 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-04-18 00:00:00 -06:00
14
- default_executable:
18
+ date: 2011-08-01 00:00:00 Z
15
19
  dependencies:
16
20
  - !ruby/object:Gem::Dependency
17
21
  name: libxml-ruby
@@ -21,10 +25,15 @@ dependencies:
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
24
- version: 2.0.2
28
+ hash: 9
29
+ segments:
30
+ - 2
31
+ - 1
32
+ - 1
33
+ version: 2.1.1
25
34
  type: :runtime
26
35
  version_requirements: *id001
27
- description: " The Libxslt-Ruby project provides Ruby language bindings for the GNOME \n XSLT C library. It is free software, released under the MIT License.\n"
36
+ description: " The Libxslt-Ruby project provides Ruby language bindings for the GNOME\n XSLT C library. It is free software, released under the MIT License.\n"
28
37
  email: libxml-devel@rubyforge.org
29
38
  executables: []
30
39
 
@@ -36,7 +45,7 @@ files:
36
45
  - CHANGES
37
46
  - LICENSE
38
47
  - Rakefile
39
- - README
48
+ - README.rdoc
40
49
  - libxslt-ruby.gemspec
41
50
  - setup.rb
42
51
  - lib/libxslt/deprecated.rb
@@ -44,9 +53,11 @@ files:
44
53
  - lib/xslt.rb
45
54
  - ext/libxslt/extconf.h
46
55
  - ext/libxslt/libxslt.h
56
+ - ext/libxslt/ruby_exslt.h
47
57
  - ext/libxslt/ruby_xslt_stylesheet.h
48
58
  - ext/libxslt/version.h
49
59
  - ext/libxslt/libxslt.c
60
+ - ext/libxslt/ruby_exslt.c
50
61
  - ext/libxslt/ruby_xslt_stylesheet.c
51
62
  - ext/vc/libxslt_ruby.sln
52
63
  - ext/vc/libxslt_ruby.vcxproj
@@ -57,17 +68,16 @@ files:
57
68
  - test/files/params.xsl
58
69
  - test/files/ramblings.xsl
59
70
  - test/test_deprecated.rb
71
+ - test/test_exslt.rb
60
72
  - test/test_helper.rb
61
73
  - test/test_libxslt.rb
62
74
  - test/test_stylesheet.rb
63
75
  - test/test_suite.rb
64
- - test/text.xml
65
76
  - ext/libxslt/extconf.rb
66
77
  - lib/1.8/libxslt_ruby.so
67
78
  - lib/1.9/libxslt_ruby.so
68
79
  - lib/libs/libexslt-0.dll
69
80
  - lib/libs/libxslt-1.dll
70
- has_rdoc: true
71
81
  homepage: http://libxslt.rubyforge.org/
72
82
  licenses: []
73
83
 
@@ -82,17 +92,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
92
  requirements:
83
93
  - - ">="
84
94
  - !ruby/object:Gem::Version
85
- version: 1.8.4
95
+ hash: 59
96
+ segments:
97
+ - 1
98
+ - 8
99
+ - 6
100
+ version: 1.8.6
86
101
  required_rubygems_version: !ruby/object:Gem::Requirement
87
102
  none: false
88
103
  requirements:
89
104
  - - ">="
90
105
  - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
91
109
  version: "0"
92
110
  requirements: []
93
111
 
94
112
  rubyforge_project: libxslt-ruby
95
- rubygems_version: 1.5.2
113
+ rubygems_version: 1.8.6
96
114
  signing_key:
97
115
  specification_version: 3
98
116
  summary: Ruby libxslt bindings
data/test/text.xml DELETED
@@ -1,134 +0,0 @@
1
- <?xml version="1.0"?>
2
- <html>
3
- <head>
4
- <title>Ramblings - Fuzface... - The Internet's a big place and here's some proof...</title>
5
- </head>
6
- <body><h1>Fuzface...</h1><h3>The Internet's a big place and here's some proof...</h3>
7
- By: SeanChittenden<br/>
8
- Date: $Date$<br/>
9
- <p>
10
- I think it's a tragedy that I'm going to start off my new
11
- commentary by talking about facial hair and the Internet.
12
- Something about that just screams pathetic, but whatever: it's
13
- humor and that's life.
14
- </p>
15
-
16
- <p>
17
- I've been working at home for a while now, which has been great.
18
- I've been doing a lot of reading, good work, contributing to the
19
- FreeBSD project, and living life at my own pace. The problem?
20
- I don't have to interact with people, so I've let my appearance
21
- slide a bit, most notably I've gone two weeks without shaving
22
- and I have an awful hairy face.
23
- </p>
24
-
25
- <p>
26
- Nothing is worse than going for a hard run, coming back, and
27
- then bending your head down so that the hairs under your chin
28
- touch the hairs on your neck. This has to be one of the most
29
- disgusting/gross feelings I've experienced in a while. While
30
- today wasn't the first time I'd experienced such a slimy tangled
31
- mess, it is the first time I seriously considered shaving part
32
- of my face, but not all of it: I was considering a beard.
33
- </p>
34
-
35
- <p>
36
- Alright, so it's 5pm and I'm a sweaty post-run mess (it was 110
37
- degrees in direct sunlight according to my thermometer) and
38
- considering the possibility of growing a beard. Swifty nift?
39
- Maybe. This is something I'd never done before, let alone
40
- seriously consider. Normally I'd call my dad for such manly
41
- advice, but he is: a) normally in another state, and; b) in
42
- another country right now probably growing a beard (he's
43
- notorious for coming back from a trip with a gnarly unshaven
44
- face, sometimes he'll shape it into a decent beard). So, what's
45
- a tech-junkie to do? Hop on the Internet and see if Google's
46
- able to provide me with some inspiration.
47
- </p>
48
-
49
- <p>
50
- Sure enough, I typed in "pictures of bearded men" and I was able
51
- to find something: 14,000 pages of something to be exact.
52
- Anyway, so most of these were rinky dink sites, a few of them
53
- had some promise. One guy was trying to start a tradition where
54
- everyone grows a beard for New Years. As I was scrolling down
55
- the page trying to find some pictures, my mind was having the
56
- following thought process: <i>This seems like a dumb
57
- idea... New Years provides a perfectly good excuse to kiss some
58
- total stranger that you've had your eye on for the duration of a
59
- New Years party. Why waste such an opportunity with a crappy
60
- kiss?</i> And at about this point I said this page sucks,
61
- and flipped back to my search results.
62
- </p>
63
-
64
- <p>
65
- Since I'd never done this before, I didn't know what was
66
- fashionably correct in terms of where a guy should shave under
67
- his neck, or what the deal was... I knew there were lots of
68
- styles out there, just none that I could picture in my mind
69
- (save maybe Santa Claus and a few really gnarly beards that are
70
- long enough to be used as full-body covering. Oooh! And don't
71
- forget the Russian and Amish beards, those stand out in my mind
72
- too.). Google, being pretty comprehensive, and the Internet
73
- being huge, found the exact screwball page I was looking for:
74
- http://fuzface-gallery.tripod.com/
75
- </p>
76
-
77
- <p>
78
- I don't know if I really should be amazed at the sheer number of
79
- entries that Google returned, or that the Internet is big enough
80
- to house such random gallery of crap, but it is and it never
81
- ceases to amaze me... it's almost as amazing as the fact that
82
- some bozo spent the time to create such a page. Don't people
83
- have lives? Oh wait, I just visited his page... so back to my
84
- diatribe...
85
- </p>
86
-
87
- <p>
88
- There were tons of faces, lots of men, lots of hair, and plenty
89
- of styles to choose from. Page after page of faces and hair.
90
- Ugh. This wasn't getting any where and I was now entertaining
91
- the rebound though of shaving my head. Time to close my browser
92
- and hop in the shower: I reak. So what'd I do? Well, after
93
- looking through enough of those pictures, I decided a few
94
- things:
95
- </p>
96
-
97
- <p>
98
- <ol><li>
99
- I'm amazed that the Internet is big enough to foster the
100
- creation of such random and utterly useless information. Then
101
- again, I've been on and using the Net since '95, so this
102
- shouldn't surprise me that much.
103
- </li><li>
104
- There are a lot of guys out there with varying tastes in,
105
- shall we say, "facial hair styles," most of which I find
106
- pretty unappealing.
107
- </li><li>
108
- I don't like beards. After one clogged drain, two
109
- reapplications of shaving cream, and a few pases with the
110
- razor, it took me about 5-10 minutes to get a nice cleanly
111
- shaven face.
112
- </li><li>
113
- &lt;crass comment&gt;And - back me up here fellas, you can
114
- sympathize with this feeling after you get done looking
115
- through a magazine for a hair-cut style (ladies.. just smile
116
- and nod and pretend you care) - after looking at a few dozen
117
- pictures of men, I was able to safely reaffirm my desire for
118
- heterosexual relations (translation from Bill Clintonese: have
119
- sex with a woman). And with that thought in mind, I began to
120
- pine for the college porn collection of old. Mmmm,
121
- Playboy.&lt;/crass comment&gt;
122
- </li></ol>
123
- </p>
124
-
125
- <p>
126
- ::grin:: Until next time. -Sean
127
- </p>
128
-
129
- <p>
130
- P.S. To the guys out there with beards, this is just my
131
- opinion: take it with a grain of salt.
132
- </p>
133
- </body>
134
- </html>