Permalink
Browse files

Removing included/vendored gems

Don't need these here now that isolate used.
  • Loading branch information...
ymendel committed Dec 6, 2011
1 parent bfd9060 commit 0ba77675e9dbab906754f00d9b9f329a94dd9324
Showing with 0 additions and 12,956 deletions.
  1. +0 −1 lib/htmlentities
  2. +0 −21 lib/htmlentities-4.0.0/COPYING.txt
  3. +0 −47 lib/htmlentities-4.0.0/History.txt
  4. +0 −44 lib/htmlentities-4.0.0/README.txt
  5. +0 −165 lib/htmlentities-4.0.0/lib/htmlentities.rb
  6. +0 −257 lib/htmlentities-4.0.0/lib/htmlentities/html4.rb
  7. +0 −27 lib/htmlentities-4.0.0/lib/htmlentities/legacy.rb
  8. +0 −26 lib/htmlentities-4.0.0/lib/htmlentities/string.rb
  9. +0 −258 lib/htmlentities-4.0.0/lib/htmlentities/xhtml1.rb
  10. +0 −206 lib/htmlentities-4.0.0/test/entities_test.rb
  11. +0 −24 lib/htmlentities-4.0.0/test/html4_test.rb
  12. +0 −34 lib/htmlentities-4.0.0/test/legacy_test.rb
  13. +0 −94 lib/htmlentities-4.0.0/test/roundtrip_test.rb
  14. +0 −24 lib/htmlentities-4.0.0/test/string_test.rb
  15. +0 −3 lib/htmlentities-4.0.0/test/test_all.rb
  16. +0 −23 lib/htmlentities-4.0.0/test/xhtml1_test.rb
  17. +0 −3 lib/mocha-0.5.5/COPYING
  18. +0 −7 lib/mocha-0.5.5/MIT-LICENSE
  19. +0 −35 lib/mocha-0.5.5/README
  20. +0 −188 lib/mocha-0.5.5/RELEASE
  21. +0 −147 lib/mocha-0.5.5/Rakefile
  22. +0 −36 lib/mocha-0.5.5/examples/misc.rb
  23. +0 −26 lib/mocha-0.5.5/examples/mocha.rb
  24. +0 −65 lib/mocha-0.5.5/examples/stubba.rb
  25. +0 −19 lib/mocha-0.5.5/lib/mocha.rb
  26. +0 −35 lib/mocha-0.5.5/lib/mocha/any_instance_method.rb
  27. +0 −111 lib/mocha-0.5.5/lib/mocha/auto_verify.rb
  28. +0 −35 lib/mocha-0.5.5/lib/mocha/central.rb
  29. +0 −62 lib/mocha-0.5.5/lib/mocha/class_method.rb
  30. +0 −22 lib/mocha-0.5.5/lib/mocha/deprecation.rb
  31. +0 −17 lib/mocha-0.5.5/lib/mocha/exception_raiser.rb
  32. +0 −382 lib/mocha-0.5.5/lib/mocha/expectation.rb
  33. +0 −6 lib/mocha-0.5.5/lib/mocha/expectation_error.rb
  34. +0 −45 lib/mocha-0.5.5/lib/mocha/expectation_list.rb
  35. +0 −25 lib/mocha-0.5.5/lib/mocha/infinite_range.rb
  36. +0 −39 lib/mocha-0.5.5/lib/mocha/inspect.rb
  37. +0 −8 lib/mocha-0.5.5/lib/mocha/instance_method.rb
  38. +0 −9 lib/mocha-0.5.5/lib/mocha/is_a.rb
  39. +0 −7 lib/mocha-0.5.5/lib/mocha/metaclass.rb
  40. +0 −27 lib/mocha-0.5.5/lib/mocha/missing_expectation.rb
  41. +0 −200 lib/mocha-0.5.5/lib/mocha/mock.rb
  42. +0 −20 lib/mocha-0.5.5/lib/mocha/multiple_yields.rb
  43. +0 −11 lib/mocha-0.5.5/lib/mocha/no_yields.rb
  44. +0 −110 lib/mocha-0.5.5/lib/mocha/object.rb
  45. +0 −9 lib/mocha-0.5.5/lib/mocha/parameter_matchers.rb
  46. +0 −39 lib/mocha-0.5.5/lib/mocha/parameter_matchers/all_of.rb
  47. +0 −44 lib/mocha-0.5.5/lib/mocha/parameter_matchers/any_of.rb
  48. +0 −30 lib/mocha-0.5.5/lib/mocha/parameter_matchers/anything.rb
  49. +0 −39 lib/mocha-0.5.5/lib/mocha/parameter_matchers/has_entry.rb
  50. +0 −39 lib/mocha-0.5.5/lib/mocha/parameter_matchers/has_key.rb
  51. +0 −39 lib/mocha-0.5.5/lib/mocha/parameter_matchers/has_value.rb
  52. +0 −37 lib/mocha-0.5.5/lib/mocha/parameter_matchers/includes.rb
  53. +0 −39 lib/mocha-0.5.5/lib/mocha/parameter_matchers/instance_of.rb
  54. +0 −39 lib/mocha-0.5.5/lib/mocha/parameter_matchers/kind_of.rb
  55. +0 −40 lib/mocha-0.5.5/lib/mocha/parameter_matchers/regexp_matches.rb
  56. +0 −28 lib/mocha-0.5.5/lib/mocha/pretty_parameters.rb
  57. +0 −31 lib/mocha-0.5.5/lib/mocha/return_values.rb
  58. +0 −23 lib/mocha-0.5.5/lib/mocha/setup_and_teardown.rb
  59. +0 −24 lib/mocha-0.5.5/lib/mocha/single_return_value.rb
  60. +0 −18 lib/mocha-0.5.5/lib/mocha/single_yield.rb
  61. +0 −32 lib/mocha-0.5.5/lib/mocha/standalone.rb
  62. +0 −18 lib/mocha-0.5.5/lib/mocha/stub.rb
  63. +0 −49 lib/mocha-0.5.5/lib/mocha/test_case_adapter.rb
  64. +0 −31 lib/mocha-0.5.5/lib/mocha/yield_parameters.rb
  65. +0 −2 lib/mocha-0.5.5/lib/mocha_standalone.rb
  66. +0 −2 lib/mocha-0.5.5/lib/stubba.rb
  67. +0 −187 lib/mocha-0.5.5/test/acceptance/expected_invocation_count_acceptance_test.rb
  68. +0 −98 lib/mocha-0.5.5/test/acceptance/mocha_acceptance_test.rb
  69. +0 −71 lib/mocha-0.5.5/test/acceptance/mocked_methods_dispatch_acceptance_test.rb
  70. +0 −81 lib/mocha-0.5.5/test/acceptance/parameter_matcher_acceptance_test.rb
  71. +0 −131 lib/mocha-0.5.5/test/acceptance/standalone_acceptance_test.rb
  72. +0 −102 lib/mocha-0.5.5/test/acceptance/stubba_acceptance_test.rb
  73. +0 −36 lib/mocha-0.5.5/test/active_record_test_case.rb
  74. +0 −15 lib/mocha-0.5.5/test/deprecation_disabler.rb
  75. +0 −34 lib/mocha-0.5.5/test/execution_point.rb
  76. +0 −105 lib/mocha-0.5.5/test/integration/mocha_test_result_integration_test.rb
  77. +0 −89 lib/mocha-0.5.5/test/integration/stubba_integration_test.rb
  78. +0 −85 lib/mocha-0.5.5/test/integration/stubba_test_result_integration_test.rb
  79. +0 −18 lib/mocha-0.5.5/test/method_definer.rb
  80. +0 −12 lib/mocha-0.5.5/test/test_helper.rb
  81. +0 −31 lib/mocha-0.5.5/test/test_runner.rb
  82. +0 −124 lib/mocha-0.5.5/test/unit/any_instance_method_test.rb
  83. +0 −16 lib/mocha-0.5.5/test/unit/array_inspect_test.rb
  84. +0 −122 lib/mocha-0.5.5/test/unit/auto_verify_test.rb
  85. +0 −124 lib/mocha-0.5.5/test/unit/central_test.rb
  86. +0 −196 lib/mocha-0.5.5/test/unit/class_method_test.rb
  87. +0 −21 lib/mocha-0.5.5/test/unit/date_time_inspect_test.rb
  88. +0 −69 lib/mocha-0.5.5/test/unit/expectation_list_test.rb
  89. +0 −28 lib/mocha-0.5.5/test/unit/expectation_raiser_test.rb
  90. +0 −399 lib/mocha-0.5.5/test/unit/expectation_test.rb
  91. +0 −16 lib/mocha-0.5.5/test/unit/hash_inspect_test.rb
  92. +0 −53 lib/mocha-0.5.5/test/unit/infinite_range_test.rb
  93. +0 −22 lib/mocha-0.5.5/test/unit/metaclass_test.rb
  94. +0 −45 lib/mocha-0.5.5/test/unit/missing_expectation_test.rb
  95. +0 −316 lib/mocha-0.5.5/test/unit/mock_test.rb
  96. +0 −18 lib/mocha-0.5.5/test/unit/multiple_yields_test.rb
  97. +0 −18 lib/mocha-0.5.5/test/unit/no_yield_test.rb
  98. +0 −35 lib/mocha-0.5.5/test/unit/object_inspect_test.rb
  99. +0 −165 lib/mocha-0.5.5/test/unit/object_test.rb
  100. +0 −26 lib/mocha-0.5.5/test/unit/parameter_matchers/all_of_test.rb
  101. +0 −26 lib/mocha-0.5.5/test/unit/parameter_matchers/any_of_test.rb
  102. +0 −21 lib/mocha-0.5.5/test/unit/parameter_matchers/anything_test.rb
  103. +0 −25 lib/mocha-0.5.5/test/unit/parameter_matchers/has_entry_test.rb
  104. +0 −25 lib/mocha-0.5.5/test/unit/parameter_matchers/has_key_test.rb
  105. +0 −25 lib/mocha-0.5.5/test/unit/parameter_matchers/has_value_test.rb
  106. +0 −25 lib/mocha-0.5.5/test/unit/parameter_matchers/includes_test.rb
  107. +0 −25 lib/mocha-0.5.5/test/unit/parameter_matchers/instance_of_test.rb
  108. +0 −25 lib/mocha-0.5.5/test/unit/parameter_matchers/kind_of_test.rb
  109. +0 −25 lib/mocha-0.5.5/test/unit/parameter_matchers/regexp_matches_test.rb
  110. +0 −22 lib/mocha-0.5.5/test/unit/parameter_matchers/stub_matcher.rb
  111. +0 −32 lib/mocha-0.5.5/test/unit/pretty_parameters_test.rb
  112. +0 −63 lib/mocha-0.5.5/test/unit/return_values_test.rb
  113. +0 −76 lib/mocha-0.5.5/test/unit/setup_and_teardown_test.rb
  114. +0 −33 lib/mocha-0.5.5/test/unit/single_return_value_test.rb
  115. +0 −18 lib/mocha-0.5.5/test/unit/single_yield_test.rb
  116. +0 −11 lib/mocha-0.5.5/test/unit/string_inspect_test.rb
  117. +0 −24 lib/mocha-0.5.5/test/unit/stub_test.rb
  118. +0 −93 lib/mocha-0.5.5/test/unit/yield_parameters_test.rb
  119. +0 −3 lib/mocha/COPYING
  120. +0 −7 lib/mocha/MIT-LICENSE
  121. +0 −35 lib/mocha/README
  122. +0 −188 lib/mocha/RELEASE
  123. +0 −147 lib/mocha/Rakefile
  124. +0 −36 lib/mocha/examples/misc.rb
  125. +0 −26 lib/mocha/examples/mocha.rb
  126. +0 −65 lib/mocha/examples/stubba.rb
  127. +0 −19 lib/mocha/lib/mocha.rb
  128. +0 −35 lib/mocha/lib/mocha/any_instance_method.rb
  129. +0 −111 lib/mocha/lib/mocha/auto_verify.rb
  130. +0 −35 lib/mocha/lib/mocha/central.rb
  131. +0 −62 lib/mocha/lib/mocha/class_method.rb
  132. +0 −22 lib/mocha/lib/mocha/deprecation.rb
  133. +0 −17 lib/mocha/lib/mocha/exception_raiser.rb
  134. +0 −382 lib/mocha/lib/mocha/expectation.rb
  135. +0 −6 lib/mocha/lib/mocha/expectation_error.rb
  136. +0 −45 lib/mocha/lib/mocha/expectation_list.rb
  137. +0 −25 lib/mocha/lib/mocha/infinite_range.rb
  138. +0 −39 lib/mocha/lib/mocha/inspect.rb
  139. +0 −8 lib/mocha/lib/mocha/instance_method.rb
  140. +0 −9 lib/mocha/lib/mocha/is_a.rb
  141. +0 −7 lib/mocha/lib/mocha/metaclass.rb
  142. +0 −27 lib/mocha/lib/mocha/missing_expectation.rb
  143. +0 −200 lib/mocha/lib/mocha/mock.rb
  144. +0 −20 lib/mocha/lib/mocha/multiple_yields.rb
  145. +0 −11 lib/mocha/lib/mocha/no_yields.rb
  146. +0 −110 lib/mocha/lib/mocha/object.rb
  147. +0 −9 lib/mocha/lib/mocha/parameter_matchers.rb
  148. +0 −39 lib/mocha/lib/mocha/parameter_matchers/all_of.rb
  149. +0 −44 lib/mocha/lib/mocha/parameter_matchers/any_of.rb
  150. +0 −30 lib/mocha/lib/mocha/parameter_matchers/anything.rb
  151. +0 −39 lib/mocha/lib/mocha/parameter_matchers/has_entry.rb
  152. +0 −39 lib/mocha/lib/mocha/parameter_matchers/has_key.rb
  153. +0 −39 lib/mocha/lib/mocha/parameter_matchers/has_value.rb
  154. +0 −37 lib/mocha/lib/mocha/parameter_matchers/includes.rb
  155. +0 −39 lib/mocha/lib/mocha/parameter_matchers/instance_of.rb
  156. +0 −39 lib/mocha/lib/mocha/parameter_matchers/kind_of.rb
  157. +0 −40 lib/mocha/lib/mocha/parameter_matchers/regexp_matches.rb
  158. +0 −28 lib/mocha/lib/mocha/pretty_parameters.rb
  159. +0 −31 lib/mocha/lib/mocha/return_values.rb
  160. +0 −23 lib/mocha/lib/mocha/setup_and_teardown.rb
  161. +0 −24 lib/mocha/lib/mocha/single_return_value.rb
  162. +0 −18 lib/mocha/lib/mocha/single_yield.rb
  163. +0 −32 lib/mocha/lib/mocha/standalone.rb
  164. +0 −18 lib/mocha/lib/mocha/stub.rb
  165. +0 −49 lib/mocha/lib/mocha/test_case_adapter.rb
  166. +0 −31 lib/mocha/lib/mocha/yield_parameters.rb
  167. +0 −2 lib/mocha/lib/mocha_standalone.rb
  168. +0 −2 lib/mocha/lib/stubba.rb
  169. +0 −187 lib/mocha/test/acceptance/expected_invocation_count_acceptance_test.rb
  170. +0 −98 lib/mocha/test/acceptance/mocha_acceptance_test.rb
  171. +0 −71 lib/mocha/test/acceptance/mocked_methods_dispatch_acceptance_test.rb
  172. +0 −81 lib/mocha/test/acceptance/parameter_matcher_acceptance_test.rb
  173. +0 −131 lib/mocha/test/acceptance/standalone_acceptance_test.rb
  174. +0 −102 lib/mocha/test/acceptance/stubba_acceptance_test.rb
  175. +0 −36 lib/mocha/test/active_record_test_case.rb
  176. +0 −15 lib/mocha/test/deprecation_disabler.rb
  177. +0 −34 lib/mocha/test/execution_point.rb
  178. +0 −105 lib/mocha/test/integration/mocha_test_result_integration_test.rb
  179. +0 −89 lib/mocha/test/integration/stubba_integration_test.rb
  180. +0 −85 lib/mocha/test/integration/stubba_test_result_integration_test.rb
  181. +0 −18 lib/mocha/test/method_definer.rb
  182. +0 −12 lib/mocha/test/test_helper.rb
  183. +0 −31 lib/mocha/test/test_runner.rb
  184. +0 −124 lib/mocha/test/unit/any_instance_method_test.rb
  185. +0 −16 lib/mocha/test/unit/array_inspect_test.rb
  186. +0 −122 lib/mocha/test/unit/auto_verify_test.rb
  187. +0 −124 lib/mocha/test/unit/central_test.rb
  188. +0 −196 lib/mocha/test/unit/class_method_test.rb
  189. +0 −21 lib/mocha/test/unit/date_time_inspect_test.rb
  190. +0 −69 lib/mocha/test/unit/expectation_list_test.rb
  191. +0 −28 lib/mocha/test/unit/expectation_raiser_test.rb
  192. +0 −399 lib/mocha/test/unit/expectation_test.rb
  193. +0 −16 lib/mocha/test/unit/hash_inspect_test.rb
  194. +0 −53 lib/mocha/test/unit/infinite_range_test.rb
  195. +0 −22 lib/mocha/test/unit/metaclass_test.rb
  196. +0 −45 lib/mocha/test/unit/missing_expectation_test.rb
  197. +0 −316 lib/mocha/test/unit/mock_test.rb
  198. +0 −18 lib/mocha/test/unit/multiple_yields_test.rb
  199. +0 −18 lib/mocha/test/unit/no_yield_test.rb
  200. +0 −35 lib/mocha/test/unit/object_inspect_test.rb
  201. +0 −165 lib/mocha/test/unit/object_test.rb
  202. +0 −26 lib/mocha/test/unit/parameter_matchers/all_of_test.rb
  203. +0 −26 lib/mocha/test/unit/parameter_matchers/any_of_test.rb
  204. +0 −21 lib/mocha/test/unit/parameter_matchers/anything_test.rb
  205. +0 −25 lib/mocha/test/unit/parameter_matchers/has_entry_test.rb
  206. +0 −25 lib/mocha/test/unit/parameter_matchers/has_key_test.rb
  207. +0 −25 lib/mocha/test/unit/parameter_matchers/has_value_test.rb
  208. +0 −25 lib/mocha/test/unit/parameter_matchers/includes_test.rb
  209. +0 −25 lib/mocha/test/unit/parameter_matchers/instance_of_test.rb
  210. +0 −25 lib/mocha/test/unit/parameter_matchers/kind_of_test.rb
  211. +0 −25 lib/mocha/test/unit/parameter_matchers/regexp_matches_test.rb
  212. +0 −22 lib/mocha/test/unit/parameter_matchers/stub_matcher.rb
  213. +0 −32 lib/mocha/test/unit/pretty_parameters_test.rb
  214. +0 −63 lib/mocha/test/unit/return_values_test.rb
  215. +0 −76 lib/mocha/test/unit/setup_and_teardown_test.rb
  216. +0 −33 lib/mocha/test/unit/single_return_value_test.rb
  217. +0 −18 lib/mocha/test/unit/single_yield_test.rb
  218. +0 −11 lib/mocha/test/unit/string_inspect_test.rb
  219. +0 −24 lib/mocha/test/unit/stub_test.rb
  220. +0 −93 lib/mocha/test/unit/yield_parameters_test.rb
View
@@ -1,21 +0,0 @@
-== Licence (MIT)
-
-Copyright (c) 2005-2006 Paul Battley
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
@@ -1,47 +0,0 @@
-== 4.0.0 (2007-03-15)
-* New instantiation-based interface (but legacy interface is preserved for
- compatibility.
-* Handles HTML4 as well as XHTML1 (the former lacks the ' entity).
-* Encodes basic entities numerically when :basic isn't specified and :decimal
- or :hexadecimal is.
-* Performs a maximum of two gsub passes instead of three when encoding, which
- should be more efficient on long strings.
-
-== 3.1.0 (2007-01-19)
-* Now understands all the entities referred to in the XHTML 1.0 DTD (253
- entities compared with 131 in version 3.0.1).
-* Calls to_s on parameters to play nicely with Rails 1.2.1.
-* Entity mapping data is now lazily loaded.
-
-== 3.0.1 (2005-04-08)
-* Improved documentation.
-
-== 3.0.0 (2005-04-08)
-* Changed licence to MIT due to confusion with previous 'Fair' licence (my
- intention was to be liberal, not obscure).
-* Moved basic functionality out of String class; for previous behaviour,
- require 'htmlentities/string'.
-* Changed version numbering scheme.
-* Now available as a Gem.
-
-== 2.2 (2005-11-07)
-* Important bug fixes -- thanks to Moonwolf.
-* Decoding hexadecimal entities now accepts 'f' as a hex digit. (D'oh!)
-* Decimal decoding edge cases addressed.
-* Test cases added.
-
-== 2.1 (2005-10-31)
-* Removed some unnecessary code in basic entity encoding.
-* Improved handling of encoding: commands are now automatically sorted, so the
- user doesn't have to worry about their order.
-* Now using setup.rb.
-* Tests moved to separate file.
-
-== 2.0 (2005-08-23)
-* Added encoding to entities.
-* Decoding interface unchanged.
-* Fixed a bug with handling high codepoints.
-
-== 1.0 (2005-08-03)
-* Initial release.
-* Decoding only.
@@ -1,44 +0,0 @@
-== HTMLEntities
-
-HTML entity encoding and decoding for Ruby
-
-The HTMLEntities module facilitates encoding and decoding of
-(X)HTML entities from/to their corresponding UTF-8 codepoints.
-
-To install (requires root/admin privileges):
-
- ruby setup.rb
-
-Alternatively, you can just use the gem.
-
-== Licence
-
-This code is free to use under the terms of the MIT licence:
-
- Copyright (c) 2007 Paul Battley
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to
- deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- sell copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- IN THE SOFTWARE.
-
-If you'd like to negotiate a different licence for a specific use, just
-contact me -- I'll almost certainly permit it.
-
-== Contact
-
-Comments are welcome. Send an email to pbattley@gmail.com.
-
@@ -1,165 +0,0 @@
-require 'htmlentities/legacy'
-
-#
-# HTML entity encoding and decoding for Ruby
-#
-
-class HTMLEntities
-
- VERSION = '4.0.0'
- FLAVORS = %w[html4 xhtml1]
- INSTRUCTIONS = [:basic, :named, :decimal, :hexadecimal]
-
- class InstructionError < RuntimeError
- end
- class UnknownFlavor < RuntimeError
- end
-
- #
- # Create a new HTMLEntities coder for the specified flavor.
- # Available flavors are 'html4' and 'xhtml1' (the default).
- # The only difference in functionality between the two is in the handling of the apos
- # (apostrophe) named entity, which is not defined in HTML4.
- #
- def initialize(flavor='xhtml1')
- @flavor = flavor.to_s.downcase
- raise UnknownFlavor, "Unknown flavor #{flavor}" unless FLAVORS.include?(@flavor)
- end
-
- #
- # Decode entities in a string into their UTF-8
- # equivalents. Obviously, if your string is not already in UTF-8, you'd
- # better convert it before using this method, or the output will be mixed
- # up.
- #
- # Unknown named entities will not be converted
- #
- def decode(source)
- return source.to_s.gsub(named_entity_regexp) {
- (cp = map[$1]) ? [cp].pack('U') : $&
- }.gsub(/&#([0-9]{1,7});|&#x([0-9a-f]{1,6});/i) {
- $1 ? [$1.to_i].pack('U') : [$2.to_i(16)].pack('U')
- }
- end
-
- #
- # Encode codepoints into their corresponding entities. Various operations
- # are possible, and may be specified in order:
- #
- # :basic :: Convert the five XML entities ('"<>&)
- # :named :: Convert non-ASCII characters to their named HTML 4.01 equivalent
- # :decimal :: Convert non-ASCII characters to decimal entities (e.g. &#1234;)
- # :hexadecimal :: Convert non-ASCII characters to hexadecimal entities (e.g. # &#x12ab;)
- #
- # You can specify the commands in any order, but they will be executed in
- # the order listed above to ensure that entity ampersands are not
- # clobbered and that named entities are replaced before numeric ones.
- #
- # If no instructions are specified, :basic will be used.
- #
- # Examples:
- # encode_entities(str) - XML-safe
- # encode_entities(str, :basic, :decimal) - XML-safe and 7-bit clean
- # encode_entities(str, :basic, :named, :decimal) - 7-bit clean, with all
- # non-ASCII characters replaced with their named entity where possible, and
- # decimal equivalents otherwise.
- #
- # Note: It is the program's responsibility to ensure that the source
- # contains valid UTF-8 before calling this method.
- #
- def encode(source, *instructions)
- string = source.to_s.dup
- if (instructions.empty?)
- instructions = [:basic]
- elsif (unknown_instructions = instructions - INSTRUCTIONS) != []
- raise InstructionError,
- "unknown encode_entities command(s): #{unknown_instructions.inspect}"
- end
-
- basic_entity_encoder =
- if instructions.include?(:basic) || instructions.include?(:named)
- :encode_named
- elsif instructions.include?(:decimal)
- :encode_decimal
- else instructions.include?(:hexadecimal)
- :encode_hexadecimal
- end
- string.gsub!(basic_entity_regexp){ __send__(basic_entity_encoder, $&) }
-
- extended_entity_encoders = []
- if instructions.include?(:named)
- extended_entity_encoders << :encode_named
- end
- if instructions.include?(:decimal)
- extended_entity_encoders << :encode_decimal
- elsif instructions.include?(:hexadecimal)
- extended_entity_encoders << :encode_hexadecimal
- end
- unless extended_entity_encoders.empty?
- string.gsub!(extended_entity_regexp){
- encode_extended(extended_entity_encoders, $&)
- }
- end
-
- return string
- end
-
-private
-
- def map
- @map ||= (require "htmlentities/#{@flavor}"; HTMLEntities::MAPPINGS[@flavor])
- end
-
- def basic_entity_regexp
- @basic_entity_regexp ||= (
- case @flavor
- when /^html/
- /[<>"&]/
- else
- /[<>'"&]/
- end
- )
- end
-
- def extended_entity_regexp
- @extended_entity_regexp ||= (
- regexp = '[\x00-\x1f]|[\xc0-\xfd][\x80-\xbf]+'
- regexp += "|'" if @flavor == 'html4'
- Regexp.new(regexp)
- )
- end
-
- def named_entity_regexp
- @named_entity_regexp ||= (
- min_length = map.keys.map{ |a| a.length }.min
- max_length = map.keys.map{ |a| a.length }.max
- /&([a-z][a-z0-9]{#{min_length-1},#{max_length-1}});/i
- )
- end
-
- def reverse_map
- @reverse_map ||= map.invert
- end
-
- def encode_named(char)
- cp = char.unpack('U')[0]
- (e = reverse_map[cp]) && "&#{e};"
- end
-
- def encode_decimal(char)
- "&##{char.unpack('U')[0]};"
- end
-
- def encode_hexadecimal(char)
- "&#x#{char.unpack('U')[0].to_s(16)};"
- end
-
- def encode_extended(encoders, char)
- encoders.each do |encoder|
- encoded = __send__(encoder, char)
- return encoded if encoded
- end
- return char
- end
-
-end
Oops, something went wrong.

0 comments on commit 0ba7767

Please sign in to comment.