mkrf 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. data/CHANGELOG +2 -0
  2. data/MIT-LICENSE +7 -0
  3. data/README +54 -0
  4. data/Rakefile +107 -0
  5. data/lib/mkrf.rb +4 -0
  6. data/lib/mkrf/availability.rb +219 -0
  7. data/lib/mkrf/generator.rb +146 -0
  8. data/test/abstract_unit.rb +4 -0
  9. data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
  10. data/test/fixtures/stdmkrf.h +1 -0
  11. data/test/sample_files/libtrivial/Rakefile +31 -0
  12. data/test/sample_files/libtrivial/extconf.rb +3 -0
  13. data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
  14. data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
  15. data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
  16. data/test/sample_files/libtrivial/mkrf.log +1 -0
  17. data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
  18. data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
  19. data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
  20. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
  21. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
  22. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
  23. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
  24. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
  25. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
  26. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
  27. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
  28. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
  29. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
  30. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
  31. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
  32. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
  33. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
  34. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
  35. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
  36. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
  37. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
  38. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
  39. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
  40. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
  41. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
  42. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
  43. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
  44. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
  45. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
  46. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
  47. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
  48. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
  49. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
  50. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
  51. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
  52. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
  53. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
  54. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
  55. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
  56. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
  57. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
  58. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
  59. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
  60. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
  61. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
  62. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
  63. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
  64. data/test/sample_files/syck-0.55/CHANGELOG +186 -0
  65. data/test/sample_files/syck-0.55/COPYING +54 -0
  66. data/test/sample_files/syck-0.55/Makefile +582 -0
  67. data/test/sample_files/syck-0.55/Makefile.am +5 -0
  68. data/test/sample_files/syck-0.55/Makefile.in +582 -0
  69. data/test/sample_files/syck-0.55/README +105 -0
  70. data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
  71. data/test/sample_files/syck-0.55/README.EXT +444 -0
  72. data/test/sample_files/syck-0.55/RELEASE +123 -0
  73. data/test/sample_files/syck-0.55/TODO +25 -0
  74. data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
  75. data/test/sample_files/syck-0.55/bootstrap +7 -0
  76. data/test/sample_files/syck-0.55/config.h +79 -0
  77. data/test/sample_files/syck-0.55/config.h.in +78 -0
  78. data/test/sample_files/syck-0.55/config.status +1197 -0
  79. data/test/sample_files/syck-0.55/config/README +14 -0
  80. data/test/sample_files/syck-0.55/config/depcomp +529 -0
  81. data/test/sample_files/syck-0.55/config/install-sh +323 -0
  82. data/test/sample_files/syck-0.55/config/missing +357 -0
  83. data/test/sample_files/syck-0.55/configure +6728 -0
  84. data/test/sample_files/syck-0.55/configure.in +36 -0
  85. data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
  86. data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
  87. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
  88. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
  89. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
  90. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
  91. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
  92. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
  93. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
  94. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
  95. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
  96. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
  97. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
  98. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
  99. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
  100. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
  101. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
  102. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
  103. data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
  104. data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
  105. data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
  106. data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
  107. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
  108. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
  109. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
  110. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
  111. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
  112. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
  113. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
  114. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
  115. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
  116. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
  117. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
  118. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
  119. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
  120. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
  121. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
  122. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
  123. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
  124. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
  125. data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
  126. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
  127. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
  128. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
  129. data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
  130. data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
  131. data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
  132. data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
  133. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
  134. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
  135. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
  136. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
  137. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
  138. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
  139. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
  140. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
  141. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
  142. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
  143. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
  144. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
  145. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
  146. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
  147. data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
  148. data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
  149. data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
  150. data/test/sample_files/syck-0.55/lib/Makefile +497 -0
  151. data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
  152. data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
  153. data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
  154. data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
  155. data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
  156. data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
  157. data/test/sample_files/syck-0.55/lib/gram.h +79 -0
  158. data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
  159. data/test/sample_files/syck-0.55/lib/gram.y +481 -0
  160. data/test/sample_files/syck-0.55/lib/handler.c +174 -0
  161. data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
  162. data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
  163. data/test/sample_files/syck-0.55/lib/node.c +407 -0
  164. data/test/sample_files/syck-0.55/lib/syck.c +504 -0
  165. data/test/sample_files/syck-0.55/lib/syck.h +458 -0
  166. data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
  167. data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
  168. data/test/sample_files/syck-0.55/lib/token.c +2707 -0
  169. data/test/sample_files/syck-0.55/lib/token.re +1139 -0
  170. data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
  171. data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
  172. data/test/sample_files/syck-0.55/stamp-h1 +1 -0
  173. data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
  174. data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
  175. data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
  176. data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
  177. data/test/sample_files/syck-0.55/tests/Makefile +480 -0
  178. data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
  179. data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
  180. data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
  181. data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
  182. data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
  183. data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
  184. data/test/test_availability.rb +68 -0
  185. data/test/test_generator.rb +74 -0
  186. metadata +252 -0
@@ -0,0 +1,4 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+
3
+ require 'test/unit'
4
+ require File.dirname(__FILE__) + '/../lib/mkrf'
@@ -0,0 +1 @@
1
+ #define DOWN_A_DIRECTORY
@@ -0,0 +1 @@
1
+ #define MKRF
@@ -0,0 +1,31 @@
1
+ require 'rake/clean'
2
+
3
+ CLEAN.include('*.o')
4
+ CLOBBER.include('libtrivial_so.bundle')
5
+
6
+ SRC = FileList[]
7
+ OBJ = SRC.ext('o')
8
+ CC = "gcc"
9
+
10
+ LDSHARED = "cc -dynamic -bundle -undefined suppress -flat_namespace"
11
+ LIBPATH = '-L"/usr/local/lib"'
12
+
13
+ INCLUDES = "-I/usr/local/include -I/usr/local/lib/ruby/1.8/i686-darwin8.6.1 -I/usr/local/lib/ruby/site_ruby/1.8 -I."
14
+
15
+ LIBS = "-lruby -ldl"
16
+
17
+ CFLAGS = " -fno-common -g -O2 -pipe -fno-common "
18
+
19
+ task :default => ['libtrivial_so.bundle']
20
+
21
+ rule '.o' => '.c' do |t|
22
+ sh "#{CC} #{CFLAGS} #{INCLUDES} -c -o #{t.name} #{t.source}"
23
+ end
24
+
25
+ rule '.so' => '.o' do |t|
26
+ sh "#{LDSHARED} #{LIBPATH} -o #{OBJ} #{LOCAL_LIBS} #{LIBS}"
27
+ end
28
+
29
+ file 'libtrivial_so.bundle' => OBJ do
30
+ sh "#{LDSHARED} #{LIBPATH} -o libtrivial_so.bundle #{OBJ} #{LIBS}"
31
+ end
@@ -0,0 +1,3 @@
1
+ require File.dirname(__FILE__) + '/../../../lib/mkrf'
2
+
3
+ Mkrf::Generator.new('libtrivial_so.bundle')
@@ -0,0 +1,5 @@
1
+ #include "ruby.h"
2
+
3
+ void Init_libtrivial() {
4
+ rb_define_class("MyClass", rb_cObject);
5
+ }
@@ -0,0 +1 @@
1
+ # Logfile created on Mon Jun 26 15:47:07 PDT 2006 by logger.rb/1.5.2.7
@@ -0,0 +1,74 @@
1
+ ===== 15.4.2006 Ross Bamford <rosco at roscopeco.co.uk>
2
+ * Implemented SAX parser callback handling
3
+
4
+ ===== 12.4.2006 Ross Bamford <rosco at roscopeco.co.uk>
5
+ * Integrated / tested community patches
6
+ * Defined XML::Node (hash) equality in terms of XML representation
7
+
8
+ ===== 12.4.2006 Tim Yamin <plasmaroo at gentoo.org> (patches)
9
+ * Fixed XML::Node#content inoperable bug
10
+ * Fixed memory leak in same
11
+
12
+ ===== 12.4.2006 Mark Van Holstyn <mvette13 at gmail.com> (patches)
13
+ * Added XML::Node::Set#first
14
+ * Added XML::Node::Set#empty?
15
+ * Fixes to XML::Node::Set#to_a
16
+ * Added XML::Node#find_first
17
+ * Added XML::Node#remove!
18
+
19
+ ===== 27.3.2006 Ross Bamford <rosco at roscopeco.co.uk>
20
+ * Integrated contributed XML::Parser.register_error_handler patch
21
+
22
+ ===== 27.2.2006 Ross Bamford <rosco at roscopeco.co.uk>
23
+ * Fixed all multiple symbol definitions for -fno-common.
24
+ * Removed OSX -fno-common workaround.
25
+
26
+ ===== 21.2.2006 Ross Bamford <rosco at roscopeco.co.uk>
27
+ * Patched extconf.rb with OSX -fno-common workaround
28
+ * Added gem and packaging support to Rakefile
29
+ * Moved version update to Rakefile
30
+ * Removed legacy project utility scripts
31
+
32
+ ===== 19.2.2006 Ross Bamford <rosco at roscopeco.co.uk>
33
+ * Fixed doublefree bug in ruby_xml_attr.
34
+ * Fixed small leak in parser
35
+
36
+ ===== 18.12.2005 Ross Bamford <rosco at roscopeco.co.uk>
37
+ * Updated for GCC 4.0 (community patches)
38
+ * Fixed default validation bug
39
+ * Refactored project, removed outdated files, cleaned up tests.
40
+ * Added RDoc documentation across .c files.
41
+ * Fixed up a few strings.
42
+
43
+ ===== 14.4.2004 Mangler Jurgen <et@wkv.at>
44
+ * ruby_xml_node.cz: fixed ruby_xml_node_property_set. The ill-behaviour
45
+ was, that there was added a second attribute of the same
46
+ name, when you were setting the value of an already existing
47
+ attribute.
48
+
49
+ ===== 17.3.2004 Lukas Svoboda <luks@fi.muni.cz>
50
+ * ruby_xml_node.c: ruby_xml_node_to_s now returns XML subtree dump.
51
+
52
+ ===== 27.2.2004 Martin Povolny <martin@solnet.cz>
53
+ * ruby_xml_node.c: added XML::Node.copy, this makes possible building
54
+ of xml documents from nodes taken from other xml documents
55
+ without making ruby SIGSEGV (see tests/copy_bug.rb).
56
+
57
+ ===== 26.2.2004 Martin Povolny <martin@solnet.cz>
58
+ * ruby_xml_dtd.c, ruby_xml_dtd.h, ruby_xml_schema.c, ruby_xml_schema.h:
59
+ more work on validation, now you can actually validate
60
+ document using dtd or xml schema, also solved warning and
61
+ error propagation (see tests/{dtd|schema}-test.rb).
62
+
63
+ ===== 30.12.2003 Martin Povolny <martin@solnet.cz>
64
+ * ruby_xml_dtd.c, ruby_xml_dtd.h, ruby_xml_schema.c, ruby_xml_schema.h:
65
+ prelimitary support for dtd and schema validation
66
+
67
+ ===== 15.9.2003 Martin Povolny <martin@solnet.cz>
68
+ * ruby_xml_input_cbg.c, libxml.c: added class InputCallbacks to make
69
+ possible registering custom input callbacks
70
+ handlers (xmlRegisterInputCallbacks) written in ruby
71
+
72
+ ===== 1.8.2003 Martin Povolny <martin@solnet.cz>
73
+ * ruby_xml_document.c: corrected argument handling in ruby_xml_document_find
74
+ * ruby_xml_node.c: corrected argument handling in ruby_xml_node_find
@@ -0,0 +1,22 @@
1
+ # $Id: LICENSE,v 1.3 2006/02/28 09:57:52 roscopeco Exp $
2
+
3
+ Copyright (c) 2002-2006 Sean Chittenden <sean@chittenden.org> and contributors
4
+ Copyright (c) 2001 Wai-Sun "Squidster" Chia <waisun.chia@compaq.com>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ of the Software, and to permit persons to whom the Software is furnished to do
11
+ so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,144 @@
1
+ == INSTALLATION
2
+
3
+ Installation is simple. Follow the following steps:
4
+
5
+ === Rubygems
6
+
7
+ gem install libxml-ruby
8
+
9
+ === Tarball/zip
10
+
11
+ $ rake test
12
+ $ rake install
13
+
14
+ If extconf yacks up an error, follow the instructions it provides.
15
+ You will need to chdir to ext/xml and run 'ruby extconf.rb' to provide
16
+ options, after which you can either use Rake for everything or
17
+ do with make (make && make install).
18
+
19
+ Once installed, look at the test scripts (tests/*.rb), and run
20
+ 'rake doc' to generate API documentation.
21
+ You can find the latest documentation at:
22
+
23
+ * http://libxml.rubyforge.org/doc
24
+
25
+ == DEPENDENCIES
26
+
27
+ libxml requires a few other libraries to be installed inorder to
28
+ function properly.
29
+
30
+ * libm (math routines: very standard)
31
+ * libz (zlib)
32
+ * libiconv
33
+ * libxml2
34
+
35
+ == USAGE
36
+
37
+ Basic usage for reading and writing documents.
38
+
39
+ === WRITING
40
+
41
+ Writing a simple document:
42
+
43
+ # require 'rubygems' # if installed via Gems
44
+ require 'xml/libxml'
45
+
46
+ doc = XML::Document.new()
47
+ doc.root = XML::Node.new('root_node')
48
+ root = doc.root
49
+
50
+ root << elem1 = XML::Node.new('elem1')
51
+ elem1['attr1'] = 'val1'
52
+ elem1['attr2'] = 'val2'
53
+
54
+ root << elem2 = XML::Node.new('elem2')
55
+ elem2['attr1'] = 'val1'
56
+ elem2['attr2'] = 'val2'
57
+
58
+ root << elem3 = XML::Node.new('elem3')
59
+ elem3 << elem4 = XML::Node.new('elem4')
60
+ elem3 << elem5 = XML::Node.new('elem5')
61
+
62
+ elem5 << elem6 = XML::Node.new('elem6')
63
+ elem6 << 'Content for element 6'
64
+
65
+ elem3['attr'] = 'baz'
66
+
67
+ # Namespace hack to reduce the numer of times XML:: is typed
68
+ include XML
69
+ root << elem7 = Node.new('foo')
70
+ 1.upto(10) do |i|
71
+ elem7 << n = Node.new('bar')
72
+ n << i
73
+ end
74
+
75
+ format = true
76
+ doc.save('output.xml', format)
77
+
78
+ The file output.xml contains:
79
+
80
+ <?xml version="1.0"?>
81
+ <root_node>
82
+ <elem1 attr1="val1" attr2="val2"/>
83
+ <elem2 attr1="val1" attr2="val2"/>
84
+ <elem3 attr="baz">
85
+ <elem4/>
86
+ <elem5>
87
+ <elem6>Content for element 6</elem6>
88
+ </elem5>
89
+ </elem3>
90
+ <foo>
91
+ <bar>1</bar>
92
+ <bar>2</bar>
93
+ <bar>3</bar>
94
+ <bar>4</bar>
95
+ <bar>5</bar>
96
+ <bar>6</bar>
97
+ <bar>7</bar>
98
+ <bar>8</bar>
99
+ <bar>9</bar>
100
+ <bar>10</bar>
101
+ </foo>
102
+ </root_node>
103
+
104
+ === READING
105
+
106
+ Reading XML is slightly more complex and there are many more ways to
107
+ perform this operation. This reads in and processes the above
108
+ generated XML document, output.xml. This script assumes that the
109
+ structure of the document is already known.
110
+
111
+ # require 'rubygems' # if installed via Gems
112
+ require 'xml/libxml'
113
+ doc = XML::Document.file('output.xml')
114
+ root = doc.root
115
+
116
+ puts "Root element name: #{root.name}"
117
+
118
+ elem3 = root.find('elem3').to_a.first
119
+ puts "Elem3: #{elem3['attr']}"
120
+
121
+ doc.find('//root_node/foo/bar').each do |node|
122
+ puts "Node path: #{node.path} \t Contents: #{node}"
123
+ end
124
+
125
+ And your terminal should look like:
126
+
127
+ Root element name: root_node
128
+ Elem3: baz
129
+ Node path: /root_node/foo/bar[1] Contents: 1
130
+ Node path: /root_node/foo/bar[2] Contents: 2
131
+ Node path: /root_node/foo/bar[3] Contents: 3
132
+ Node path: /root_node/foo/bar[4] Contents: 4
133
+ Node path: /root_node/foo/bar[5] Contents: 5
134
+ Node path: /root_node/foo/bar[6] Contents: 6
135
+ Node path: /root_node/foo/bar[7] Contents: 7
136
+ Node path: /root_node/foo/bar[8] Contents: 8
137
+ Node path: /root_node/foo/bar[9] Contents: 9
138
+ Node path: /root_node/foo/bar[10] Contents: 10
139
+
140
+ == MORE INFORMATION
141
+
142
+ If you have any questions, please send email to libxml-devel@rubyforge.org.
143
+
144
+ # $Id: README,v 1.5 2006/04/24 19:29:49 roscopeco Exp $
@@ -0,0 +1,76 @@
1
+ #include <string.h>
2
+ #include <libxml/xmlIO.h>
3
+ #include "ruby.h"
4
+
5
+ /*
6
+ int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
7
+ xmlInputOpenCallback openFunc,
8
+ xmlInputReadCallback readFunc,
9
+ xmlInputCloseCallback closeFunc);
10
+
11
+
12
+ int (*xmlInputMatchCallback) (char const *filename);
13
+ void* (*xmlInputOpenCallback) (char const *filename);
14
+ int (*xmlInputReadCallback) (void *context,
15
+ char *buffer,
16
+ int len);
17
+ int (*xmlInputCloseCallback) (void *context);
18
+ */
19
+
20
+ typedef struct deb_doc_context {
21
+ char *buffer;
22
+ char *bpos;
23
+ int remaining;
24
+ } deb_doc_context;
25
+
26
+ int deb_Match (char const *filename) {
27
+ fprintf( stderr, "deb_Match: %s\n", filename );
28
+ if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "deb://", 6)) {
29
+ return(1);
30
+ }
31
+ return(0);
32
+ }
33
+
34
+ void* deb_Open (char const *filename) {
35
+ deb_doc_context *deb_doc;
36
+ VALUE res;
37
+
38
+ deb_doc = (deb_doc_context*)malloc( sizeof(deb_doc_context) );
39
+
40
+ res = rb_funcall( rb_funcall( rb_mKernel, rb_intern("const_get"), 1, rb_str_new2("DEBSystem") ),
41
+ rb_intern("document_query"), 1, rb_str_new2(filename));
42
+ deb_doc->buffer = strdup( StringValuePtr(res) );
43
+ //deb_doc->buffer = strdup("<serepes>serepes</serepes>");
44
+
45
+ deb_doc->bpos = deb_doc->buffer;
46
+ deb_doc->remaining = strlen(deb_doc->buffer);
47
+ return deb_doc;
48
+ }
49
+
50
+ int deb_Read (void *context, char *buffer, int len) {
51
+ deb_doc_context *deb_doc;
52
+ int ret_len;
53
+ deb_doc = (deb_doc_context*)context;
54
+
55
+ if (len >= deb_doc->remaining) {
56
+ ret_len = deb_doc->remaining;
57
+ } else {
58
+ ret_len = len;
59
+ }
60
+ deb_doc->remaining -= ret_len;
61
+ strncpy( buffer, deb_doc->bpos, ret_len );
62
+ deb_doc->bpos += ret_len;
63
+
64
+ return ret_len;
65
+ }
66
+
67
+ int deb_Close (void *context) {
68
+ free( ((deb_doc_context*)context)->buffer );
69
+ free( context );
70
+ return 1;
71
+ }
72
+
73
+
74
+ void deb_register_cbg() {
75
+ xmlRegisterInputCallbacks( deb_Match, deb_Open, deb_Read, deb_Close );
76
+ }
@@ -0,0 +1,49 @@
1
+ require '../../../../../lib/mkrf'
2
+
3
+ def crash(str)
4
+ printf(" extconf failure: %s\n", str)
5
+ exit 1
6
+ end
7
+
8
+ Mkrf::Generator.new('libxml_so.bundle', '*.c') do |g|
9
+
10
+ g.include_library('socket','socket')
11
+ g.include_library('nsl','gethostbyname')
12
+
13
+ unless g.include_library('z', 'inflate')
14
+ crash('need zlib')
15
+ else
16
+ g.add_define('HAVE_ZLIB_H')
17
+ end
18
+
19
+ unless g.include_library('iconv','iconv_open') or
20
+ g.include_library('c','iconv_open') or
21
+ g.include_library('recode','iconv_open') or
22
+ g.include_library('iconv')
23
+ crash(<<-EOL)
24
+ need libiconv.
25
+
26
+ Install the libiconv or try passing one of the following options
27
+ to extconf.rb:
28
+
29
+ --with-iconv-dir=/path/to/iconv
30
+ --with-iconv-lib=/path/to/iconv/lib
31
+ --with-iconv-include=/path/to/iconv/include
32
+ EOL
33
+ end
34
+
35
+ g.include_library('xml2', 'xmlParseDoc')
36
+ has_header = g.include_header('libxml/xmlversion.h',
37
+ '/opt/include/libxml2',
38
+ '/usr/local/include/libxml2',
39
+ '/usr/include/libxml2')
40
+
41
+ unless g.include_library('xml2', 'xmlDocFormatDump')
42
+ crash('Your version of libxml2 is too old. Please upgrade.')
43
+ end
44
+
45
+ unless g.has_function? 'docbCreateFileParserCtxt'
46
+ crash('Need docbCreateFileParserCtxt')
47
+ end
48
+
49
+ end
@@ -0,0 +1,86 @@
1
+ /* $Id: libxml.c,v 1.2 2006/04/17 13:30:22 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "libxml.h"
6
+
7
+ /* Ruby's util.h has ruby_strdup */
8
+ #include "util.h"
9
+
10
+ #ifdef xmlMalloc
11
+ #undef xmlMalloc
12
+ #endif
13
+ #ifdef xmlRealloc
14
+ #undef xmlRealloc
15
+ #endif
16
+ #ifdef xmlMemStrdup
17
+ #undef xmlMemStrdup
18
+ #endif
19
+ #ifdef xmlMemFree
20
+ #undef xmlMemFree
21
+ #endif
22
+
23
+ #ifdef RubyMemMalloc
24
+ #undef RubyMemMalloc
25
+ #endif
26
+ #ifdef RubyMemRealloc
27
+ #undef RubyMemRealloc
28
+ #endif
29
+ #ifdef RubyMemStrdup
30
+ #undef RubyMemStrdup
31
+ #endif
32
+ #ifdef RubyMemFree
33
+ #undef RubyMemFree
34
+ #endif
35
+
36
+ #define RubyMemFree ruby_xfree
37
+ #define RubyMemRealloc ruby_xrealloc
38
+ #define RubyMemMalloc ruby_xmalloc
39
+ #define RubyMemStrdup ruby_strdup
40
+
41
+ VALUE mXML;
42
+
43
+ static xmlFreeFunc freeFunc = NULL;
44
+ static xmlMallocFunc mallocFunc = NULL;
45
+ static xmlReallocFunc reallocFunc = NULL;
46
+ static xmlStrdupFunc strdupFunc = NULL;
47
+
48
+ void
49
+ Init_libxml_so(void) {
50
+ /* Some libxml memory goo that should be done before anything else */
51
+ xmlMemGet((xmlFreeFunc *) & freeFunc,
52
+ (xmlMallocFunc *) & mallocFunc,
53
+ (xmlReallocFunc *) & reallocFunc,
54
+ (xmlStrdupFunc *) & strdupFunc);
55
+
56
+ if (xmlMemSetup((xmlFreeFunc)RubyMemFree, (xmlMallocFunc)RubyMemMalloc,
57
+ (xmlReallocFunc)RubyMemRealloc, (xmlStrdupFunc)RubyMemStrdup) != 0)
58
+ rb_fatal("could not install the memory handlers for libxml");
59
+ xmlInitParser();
60
+
61
+ mXML = rb_define_module("XML");
62
+
63
+ rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*)XML_XML_NAMESPACE));
64
+
65
+ ruby_init_parser();
66
+ ruby_init_xml_parser_context();
67
+ ruby_init_xml_attr();
68
+ ruby_init_xml_attribute();
69
+ ruby_init_xml_document();
70
+ ruby_init_xml_node();
71
+ ruby_init_xml_node_set();
72
+ ruby_init_xml_ns();
73
+ ruby_init_xml_sax_parser();
74
+ ruby_init_xml_tree();
75
+ ruby_init_xml_xinclude();
76
+ ruby_init_xml_xpath();
77
+ ruby_init_xml_xpath_context();
78
+ ruby_init_xml_xpointer();
79
+ ruby_init_xml_xpointer_context();
80
+ ruby_init_input_callbacks(); /* MUFF */
81
+ ruby_init_xml_dtd(); /* MUFF */
82
+ ruby_init_xml_schema(); /* MUFF */
83
+
84
+ ruby_xml_parser_default_substitute_entities_set(cXMLParser, Qtrue);
85
+ ruby_xml_parser_default_load_external_dtd_set(cXMLParser, Qtrue);
86
+ }