Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removing included/vendored gems

Don't need these here now that isolate used.
  • Loading branch information...
commit 0ba77675e9dbab906754f00d9b9f329a94dd9324 1 parent bfd9060
@ymendel ymendel authored
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  lib/htmlentities
View
21 lib/htmlentities-4.0.0/COPYING.txt
@@ -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.
View
47 lib/htmlentities-4.0.0/History.txt
@@ -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.
View
44 lib/htmlentities-4.0.0/README.txt
@@ -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.
-
View
165 lib/htmlentities-4.0.0/lib/htmlentities.rb
@@ -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
View
257 lib/htmlentities-4.0.0/lib/htmlentities/html4.rb
@@ -1,257 +0,0 @@
-class HTMLEntities
- MAPPINGS = {} unless defined? MAPPINGS
- MAPPINGS['html4'] = {
- 'Aacute' => 193,
- 'aacute' => 225,
- 'Acirc' => 194,
- 'acirc' => 226,
- 'acute' => 180,
- 'AElig' => 198,
- 'aelig' => 230,
- 'Agrave' => 192,
- 'agrave' => 224,
- 'alefsym' => 8501,
- 'Alpha' => 913,
- 'alpha' => 945,
- 'amp' => 38,
- 'and' => 8743,
- 'ang' => 8736,
- 'Aring' => 197,
- 'aring' => 229,
- 'asymp' => 8776,
- 'Atilde' => 195,
- 'atilde' => 227,
- 'Auml' => 196,
- 'auml' => 228,
- 'bdquo' => 8222,
- 'Beta' => 914,
- 'beta' => 946,
- 'brvbar' => 166,
- 'bull' => 8226,
- 'cap' => 8745,
- 'Ccedil' => 199,
- 'ccedil' => 231,
- 'cedil' => 184,
- 'cent' => 162,
- 'Chi' => 935,
- 'chi' => 967,
- 'circ' => 710,
- 'clubs' => 9827,
- 'cong' => 8773,
- 'copy' => 169,
- 'crarr' => 8629,
- 'cup' => 8746,
- 'curren' => 164,
- 'Dagger' => 8225,
- 'dagger' => 8224,
- 'dArr' => 8659,
- 'darr' => 8595,
- 'deg' => 176,
- 'Delta' => 916,
- 'delta' => 948,
- 'diams' => 9830,
- 'divide' => 247,
- 'Eacute' => 201,
- 'eacute' => 233,
- 'Ecirc' => 202,
- 'ecirc' => 234,
- 'Egrave' => 200,
- 'egrave' => 232,
- 'empty' => 8709,
- 'emsp' => 8195,
- 'ensp' => 8194,
- 'Epsilon' => 917,
- 'epsilon' => 949,
- 'equiv' => 8801,
- 'Eta' => 919,
- 'eta' => 951,
- 'ETH' => 208,
- 'eth' => 240,
- 'Euml' => 203,
- 'euml' => 235,
- 'euro' => 8364,
- 'exist' => 8707,
- 'fnof' => 402,
- 'forall' => 8704,
- 'frac12' => 189,
- 'frac14' => 188,
- 'frac34' => 190,
- 'frasl' => 8260,
- 'Gamma' => 915,
- 'gamma' => 947,
- 'ge' => 8805,
- 'gt' => 62,
- 'hArr' => 8660,
- 'harr' => 8596,
- 'hearts' => 9829,
- 'hellip' => 8230,
- 'Iacute' => 205,
- 'iacute' => 237,
- 'Icirc' => 206,
- 'icirc' => 238,
- 'iexcl' => 161,
- 'Igrave' => 204,
- 'igrave' => 236,
- 'image' => 8465,
- 'infin' => 8734,
- 'int' => 8747,
- 'Iota' => 921,
- 'iota' => 953,
- 'iquest' => 191,
- 'isin' => 8712,
- 'Iuml' => 207,
- 'iuml' => 239,
- 'Kappa' => 922,
- 'kappa' => 954,
- 'Lambda' => 923,
- 'lambda' => 955,
- 'lang' => 9001,
- 'laquo' => 171,
- 'lArr' => 8656,
- 'larr' => 8592,
- 'lceil' => 8968,
- 'ldquo' => 8220,
- 'le' => 8804,
- 'lfloor' => 8970,
- 'lowast' => 8727,
- 'loz' => 9674,
- 'lrm' => 8206,
- 'lsaquo' => 8249,
- 'lsquo' => 8216,
- 'lt' => 60,
- 'macr' => 175,
- 'mdash' => 8212,
- 'micro' => 181,
- 'middot' => 183,
- 'minus' => 8722,
- 'Mu' => 924,
- 'mu' => 956,
- 'nabla' => 8711,
- 'nbsp' => 160,
- 'ndash' => 8211,
- 'ne' => 8800,
- 'ni' => 8715,
- 'not' => 172,
- 'notin' => 8713,
- 'nsub' => 8836,
- 'Ntilde' => 209,
- 'ntilde' => 241,
- 'Nu' => 925,
- 'nu' => 957,
- 'Oacute' => 211,
- 'oacute' => 243,
- 'Ocirc' => 212,
- 'ocirc' => 244,
- 'OElig' => 338,
- 'oelig' => 339,
- 'Ograve' => 210,
- 'ograve' => 242,
- 'oline' => 8254,
- 'Omega' => 937,
- 'omega' => 969,
- 'Omicron' => 927,
- 'omicron' => 959,
- 'oplus' => 8853,
- 'or' => 8744,
- 'ordf' => 170,
- 'ordm' => 186,
- 'Oslash' => 216,
- 'oslash' => 248,
- 'Otilde' => 213,
- 'otilde' => 245,
- 'otimes' => 8855,
- 'Ouml' => 214,
- 'ouml' => 246,
- 'para' => 182,
- 'part' => 8706,
- 'permil' => 8240,
- 'perp' => 8869,
- 'Phi' => 934,
- 'phi' => 966,
- 'Pi' => 928,
- 'pi' => 960,
- 'piv' => 982,
- 'plusmn' => 177,
- 'pound' => 163,
- 'Prime' => 8243,
- 'prime' => 8242,
- 'prod' => 8719,
- 'prop' => 8733,
- 'Psi' => 936,
- 'psi' => 968,
- 'quot' => 34,
- 'radic' => 8730,
- 'rang' => 9002,
- 'raquo' => 187,
- 'rArr' => 8658,
- 'rarr' => 8594,
- 'rceil' => 8969,
- 'rdquo' => 8221,
- 'real' => 8476,
- 'reg' => 174,
- 'rfloor' => 8971,
- 'Rho' => 929,
- 'rho' => 961,
- 'rlm' => 8207,
- 'rsaquo' => 8250,
- 'rsquo' => 8217,
- 'sbquo' => 8218,
- 'Scaron' => 352,
- 'scaron' => 353,
- 'sdot' => 8901,
- 'sect' => 167,
- 'shy' => 173,
- 'Sigma' => 931,
- 'sigma' => 963,
- 'sigmaf' => 962,
- 'sim' => 8764,
- 'spades' => 9824,
- 'sub' => 8834,
- 'sube' => 8838,
- 'sum' => 8721,
- 'sup' => 8835,
- 'sup1' => 185,
- 'sup2' => 178,
- 'sup3' => 179,
- 'supe' => 8839,
- 'szlig' => 223,
- 'Tau' => 932,
- 'tau' => 964,
- 'there4' => 8756,
- 'Theta' => 920,
- 'theta' => 952,
- 'thetasym' => 977,
- 'thinsp' => 8201,
- 'THORN' => 222,
- 'thorn' => 254,
- 'tilde' => 732,
- 'times' => 215,
- 'trade' => 8482,
- 'Uacute' => 218,
- 'uacute' => 250,
- 'uArr' => 8657,
- 'uarr' => 8593,
- 'Ucirc' => 219,
- 'ucirc' => 251,
- 'Ugrave' => 217,
- 'ugrave' => 249,
- 'uml' => 168,
- 'upsih' => 978,
- 'Upsilon' => 933,
- 'upsilon' => 965,
- 'Uuml' => 220,
- 'uuml' => 252,
- 'weierp' => 8472,
- 'Xi' => 926,
- 'xi' => 958,
- 'Yacute' => 221,
- 'yacute' => 253,
- 'yen' => 165,
- 'Yuml' => 376,
- 'yuml' => 255,
- 'Zeta' => 918,
- 'zeta' => 950,
- 'zwj' => 8205,
- 'zwnj' => 8204
- }
-end
View
27 lib/htmlentities-4.0.0/lib/htmlentities/legacy.rb
@@ -1,27 +0,0 @@
-class HTMLEntities
- class << self
-
- #
- # Legacy compatibility class method allowing direct encoding of XHTML1 entities.
- # See HTMLEntities#encode for description of parameters.
- #
- def encode_entities(*args)
- xhtml1_entities.encode(*args)
- end
-
- #
- # Legacy compatibility class method allowing direct decoding of XHTML1 entities.
- # See HTMLEntities#decode for description of parameters.
- #
- def decode_entities(*args)
- xhtml1_entities.decode(*args)
- end
-
- private
-
- def xhtml1_entities
- @xhtml1_entities ||= new('xhtml1')
- end
-
- end
-end
View
26 lib/htmlentities-4.0.0/lib/htmlentities/string.rb
@@ -1,26 +0,0 @@
-require 'htmlentities'
-
-#
-# This file extends the String class with methods to allow encoding and decoding of
-# HTML/XML entities from/to their corresponding UTF-8 codepoints.
-#
-class String
-
- #
- # Decode XML and HTML 4.01 entities in a string into their UTF-8
- # equivalents.
- #
- def decode_entities
- return HTMLEntities.decode_entities(self)
- end
-
- #
- # Encode codepoints in a string into their corresponding entities. See
- # the documentation of HTMLEntities.encode_entities for a list of possible
- # instructions.
- #
- def encode_entities(*instructions)
- return HTMLEntities.encode_entities(self, *instructions)
- end
-
-end
View
258 lib/htmlentities-4.0.0/lib/htmlentities/xhtml1.rb
@@ -1,258 +0,0 @@
-class HTMLEntities
- MAPPINGS = {} unless defined? MAPPINGS
- MAPPINGS['xhtml1'] = {
- 'Aacute' => 193,
- 'aacute' => 225,
- 'Acirc' => 194,
- 'acirc' => 226,
- 'acute' => 180,
- 'AElig' => 198,
- 'aelig' => 230,
- 'Agrave' => 192,
- 'agrave' => 224,
- 'alefsym' => 8501,
- 'Alpha' => 913,
- 'alpha' => 945,
- 'amp' => 38,
- 'and' => 8743,
- 'ang' => 8736,
- 'apos' => 39,
- 'Aring' => 197,
- 'aring' => 229,
- 'asymp' => 8776,
- 'Atilde' => 195,
- 'atilde' => 227,
- 'Auml' => 196,
- 'auml' => 228,
- 'bdquo' => 8222,
- 'Beta' => 914,
- 'beta' => 946,
- 'brvbar' => 166,
- 'bull' => 8226,
- 'cap' => 8745,
- 'Ccedil' => 199,
- 'ccedil' => 231,
- 'cedil' => 184,
- 'cent' => 162,
- 'Chi' => 935,
- 'chi' => 967,
- 'circ' => 710,
- 'clubs' => 9827,
- 'cong' => 8773,
- 'copy' => 169,
- 'crarr' => 8629,
- 'cup' => 8746,
- 'curren' => 164,
- 'Dagger' => 8225,
- 'dagger' => 8224,
- 'dArr' => 8659,
- 'darr' => 8595,
- 'deg' => 176,
- 'Delta' => 916,
- 'delta' => 948,
- 'diams' => 9830,
- 'divide' => 247,
- 'Eacute' => 201,
- 'eacute' => 233,
- 'Ecirc' => 202,
- 'ecirc' => 234,
- 'Egrave' => 200,
- 'egrave' => 232,
- 'empty' => 8709,
- 'emsp' => 8195,
- 'ensp' => 8194,
- 'Epsilon' => 917,
- 'epsilon' => 949,
- 'equiv' => 8801,
- 'Eta' => 919,
- 'eta' => 951,
- 'ETH' => 208,
- 'eth' => 240,
- 'Euml' => 203,
- 'euml' => 235,
- 'euro' => 8364,
- 'exist' => 8707,
- 'fnof' => 402,
- 'forall' => 8704,
- 'frac12' => 189,
- 'frac14' => 188,
- 'frac34' => 190,
- 'frasl' => 8260,
- 'Gamma' => 915,
- 'gamma' => 947,
- 'ge' => 8805,
- 'gt' => 62,
- 'hArr' => 8660,
- 'harr' => 8596,
- 'hearts' => 9829,
- 'hellip' => 8230,
- 'Iacute' => 205,
- 'iacute' => 237,
- 'Icirc' => 206,
- 'icirc' => 238,
- 'iexcl' => 161,
- 'Igrave' => 204,
- 'igrave' => 236,
- 'image' => 8465,
- 'infin' => 8734,
- 'int' => 8747,
- 'Iota' => 921,
- 'iota' => 953,
- 'iquest' => 191,
- 'isin' => 8712,
- 'Iuml' => 207,
- 'iuml' => 239,
- 'Kappa' => 922,
- 'kappa' => 954,
- 'Lambda' => 923,
- 'lambda' => 955,
- 'lang' => 9001,
- 'laquo' => 171,
- 'lArr' => 8656,
- 'larr' => 8592,
- 'lceil' => 8968,
- 'ldquo' => 8220,
- 'le' => 8804,
- 'lfloor' => 8970,
- 'lowast' => 8727,
- 'loz' => 9674,
- 'lrm' => 8206,
- 'lsaquo' => 8249,
- 'lsquo' => 8216,
- 'lt' => 60,
- 'macr' => 175,
- 'mdash' => 8212,
- 'micro' => 181,
- 'middot' => 183,
- 'minus' => 8722,
- 'Mu' => 924,
- 'mu' => 956,
- 'nabla' => 8711,
- 'nbsp' => 160,
- 'ndash' => 8211,
- 'ne' => 8800,
- 'ni' => 8715,
- 'not' => 172,
- 'notin' => 8713,
- 'nsub' => 8836,
- 'Ntilde' => 209,
- 'ntilde' => 241,
- 'Nu' => 925,
- 'nu' => 957,
- 'Oacute' => 211,
- 'oacute' => 243,
- 'Ocirc' => 212,
- 'ocirc' => 244,
- 'OElig' => 338,
- 'oelig' => 339,
- 'Ograve' => 210,
- 'ograve' => 242,
- 'oline' => 8254,
- 'Omega' => 937,
- 'omega' => 969,
- 'Omicron' => 927,
- 'omicron' => 959,
- 'oplus' => 8853,
- 'or' => 8744,
- 'ordf' => 170,
- 'ordm' => 186,
- 'Oslash' => 216,
- 'oslash' => 248,
- 'Otilde' => 213,
- 'otilde' => 245,
- 'otimes' => 8855,
- 'Ouml' => 214,
- 'ouml' => 246,
- 'para' => 182,
- 'part' => 8706,
- 'permil' => 8240,
- 'perp' => 8869,
- 'Phi' => 934,
- 'phi' => 966,
- 'Pi' => 928,
- 'pi' => 960,
- 'piv' => 982,
- 'plusmn' => 177,
- 'pound' => 163,
- 'Prime' => 8243,
- 'prime' => 8242,
- 'prod' => 8719,
- 'prop' => 8733,
- 'Psi' => 936,
- 'psi' => 968,
- 'quot' => 34,
- 'radic' => 8730,
- 'rang' => 9002,
- 'raquo' => 187,
- 'rArr' => 8658,
- 'rarr' => 8594,
- 'rceil' => 8969,
- 'rdquo' => 8221,
- 'real' => 8476,
- 'reg' => 174,
- 'rfloor' => 8971,
- 'Rho' => 929,
- 'rho' => 961,
- 'rlm' => 8207,
- 'rsaquo' => 8250,
- 'rsquo' => 8217,
- 'sbquo' => 8218,
- 'Scaron' => 352,
- 'scaron' => 353,
- 'sdot' => 8901,
- 'sect' => 167,
- 'shy' => 173,
- 'Sigma' => 931,
- 'sigma' => 963,
- 'sigmaf' => 962,
- 'sim' => 8764,
- 'spades' => 9824,
- 'sub' => 8834,
- 'sube' => 8838,
- 'sum' => 8721,
- 'sup' => 8835,
- 'sup1' => 185,
- 'sup2' => 178,
- 'sup3' => 179,
- 'supe' => 8839,
- 'szlig' => 223,
- 'Tau' => 932,
- 'tau' => 964,
- 'there4' => 8756,
- 'Theta' => 920,
- 'theta' => 952,
- 'thetasym' => 977,
- 'thinsp' => 8201,
- 'THORN' => 222,
- 'thorn' => 254,
- 'tilde' => 732,
- 'times' => 215,
- 'trade' => 8482,
- 'Uacute' => 218,
- 'uacute' => 250,
- 'uArr' => 8657,
- 'uarr' => 8593,
- 'Ucirc' => 219,
- 'ucirc' => 251,
- 'Ugrave' => 217,
- 'ugrave' => 249,
- 'uml' => 168,
- 'upsih' => 978,
- 'Upsilon' => 933,
- 'upsilon' => 965,
- 'Uuml' => 220,
- 'uuml' => 252,
- 'weierp' => 8472,
- 'Xi' => 926,
- 'xi' => 958,
- 'Yacute' => 221,
- 'yacute' => 253,
- 'yen' => 165,
- 'Yuml' => 376,
- 'yuml' => 255,
- 'Zeta' => 918,
- 'zeta' => 950,
- 'zwj' => 8205,
- 'zwnj' => 8204
- }
-end
View
206 lib/htmlentities-4.0.0/test/entities_test.rb
@@ -1,206 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-require 'htmlentities'
-require 'test/unit'
-
-$KCODE = 'u'
-
-class HTMLEntities::EntitiesTest < Test::Unit::TestCase
-
- attr_reader :xhtml1_entities, :html4_entities
-
- def setup
- @xhtml1_entities = HTMLEntities.new('xhtml1')
- @html4_entities = HTMLEntities.new('html4')
- end
-
- class PseudoString
- def initialize(string)
- @string = string
- end
- def to_s
- @string
- end
- end
-
- def test_should_raise_exception_when_unknown_flavor_specified
- assert_raises(HTMLEntities::UnknownFlavor) do
- HTMLEntities.new('foo')
- end
- end
-
- def test_should_allow_symbol_for_flavor
- assert_nothing_raised do
- HTMLEntities.new(:xhtml1)
- end
- end
-
- def test_should_allow_upper_case_flavor
- assert_nothing_raised do
- HTMLEntities.new('XHTML1')
- end
- end
-
- def test_should_decode_basic_entities
- assert_decode('&', '&amp;')
- assert_decode('<', '&lt;')
- assert_decode('"', '&quot;')
- end
-
- def test_should_encode_basic_entities
- assert_encode('&amp;', '&', :basic)
- assert_encode('&quot;', '"')
- assert_encode('&lt;', '<', :basic)
- assert_encode('&lt;', '<')
- end
-
- def test_should_encode_basic_entities_to_decimal
- assert_encode('&#38;', '&', :decimal)
- assert_encode('&#34;', '"', :decimal)
- assert_encode('&#60;', '<', :decimal)
- assert_encode('&#62;', '>', :decimal)
- assert_encode('&#39;', "'", :decimal)
- end
-
- def test_should_encode_basic_entities_to_hexadecimal
- assert_encode('&#x26;', '&', :hexadecimal)
- assert_encode('&#x22;', '"', :hexadecimal)
- assert_encode('&#x3c;', '<', :hexadecimal)
- assert_encode('&#x3e;', '>', :hexadecimal)
- assert_encode('&#x27;', "'", :hexadecimal)
- end
-
- def test_should_decode_extended_named_entities
- assert_decode('±', '&plusmn;')
- assert_decode('ð', '&eth;')
- assert_decode('Œ', '&OElig;')
- assert_decode('œ', '&oelig;')
- end
-
- def test_should_encode_extended_named_entities
- assert_encode('&plusmn;', '±', :named)
- assert_encode('&eth;', 'ð', :named)
- assert_encode('&OElig;', 'Œ', :named)
- assert_encode('&oelig;', 'œ', :named)
- end
-
- def test_should_decode_decimal_entities
- assert_decode('', '&#8220;')
- assert_decode('', '&#8230;')
- assert_decode(' ', '&#32;')
- end
-
- def test_should_encode_decimal_entities
- assert_encode('&#8220;', '', :decimal)
- assert_encode('&#8230;', '', :decimal)
- end
-
- def test_should_decode_hexadecimal_entities
- assert_decode('', '&#x2212;')
- assert_decode('', '&#x2014;')
- assert_decode('`', '&#x0060;')
- assert_decode('`', '&#x60;')
- end
-
- def test_should_encode_hexadecimal_entities
- assert_encode('&#x2212;', '', :hexadecimal)
- assert_encode('&#x2014;', '', :hexadecimal)
- end
-
- def test_should_decode_text_with_mix_of_entities
- # Just a random headline - I needed something with accented letters.
- assert_decode(
- 'Le tabac pourrait bientôt être banni dans tous les lieux publics en France',
- 'Le tabac pourrait bient&ocirc;t &#234;tre banni dans tous les lieux publics en France'
- )
- assert_decode(
- '"bientôt" & 文字',
- '&quot;bient&ocirc;t&quot; &amp; &#25991;&#x5b57;'
- )
- end
-
- def test_should_encode_text_using_mix_of_entities
- assert_encode(
- '&quot;bient&ocirc;t&quot; &amp; &#x6587;&#x5b57;',
- '"bientôt" & 文字', :basic, :named, :hexadecimal
- )
- assert_encode(
- '&quot;bient&ocirc;t&quot; &amp; &#25991;&#23383;',
- '"bientôt" & 文字', :basic, :named, :decimal
- )
- end
-
- def test_should_sort_commands_when_encoding_using_mix_of_entities
- assert_encode(
- '&quot;bient&ocirc;t&quot; &amp; &#x6587;&#x5b57;',
- '"bientôt" & 文字', :named, :hexadecimal, :basic
- )
- assert_encode(
- '&quot;bient&ocirc;t&quot; &amp; &#25991;&#23383;',
- '"bientôt" & 文字', :decimal, :named, :basic
- )
- end
-
- def test_should_detect_illegal_encoding_command
- assert_raise(HTMLEntities::InstructionError) {
- HTMLEntities.encode_entities('foo', :bar, :baz)
- }
- end
-
- def test_should_decode_empty_string
- assert_decode('', '')
- end
-
- def test_should_skip_unknown_entity
- assert_decode('&bogus;', '&bogus;')
- end
-
- def test_should_decode_double_encoded_entity_once
- assert_decode('&amp;', '&amp;amp;')
- end
-
- def test_should_not_encode_normal_ASCII
- assert_encode('`', '`')
- assert_encode(' ', ' ')
- end
-
- def test_should_double_encode_existing_entity
- assert_encode('&amp;amp;', '&amp;')
- end
-
- # Faults found and patched by Moonwolf
- def test_should_decode_full_hexadecimal_range
- (0..127).each do |codepoint|
- assert_decode([codepoint].pack('U'), "&\#x#{codepoint.to_s(16)};")
- end
- end
-
- # Reported by Dallas DeVries and Johan Duflost
- def test_should_decode_named_entities_reported_as_missing_in_3_0_1
- assert_decode([178].pack('U'), '&sup2;')
- assert_decode([8226].pack('U'), '&bull;')
- assert_decode([948].pack('U'), '&delta;')
- end
-
- def test_should_ducktype_parameter_to_string_before_encoding
- pseudo_string = PseudoString.new('foo')
- assert_decode('foo', pseudo_string)
- end
-
- def test_should_ducktype_parameter_to_string_before_decoding
- pseudo_string = PseudoString.new('foo')
- assert_encode('foo', pseudo_string)
- end
-
- def assert_decode(expected, input)
- [xhtml1_entities, html4_entities].each do |coder|
- assert_equal(expected, coder.decode(input))
- end
- end
-
- def assert_encode(expected, input, *args)
- [xhtml1_entities, html4_entities].each do |coder|
- assert_equal(expected, coder.encode(input, *args))
- end
- end
-
-end
View
24 lib/htmlentities-4.0.0/test/html4_test.rb
@@ -1,24 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-require 'htmlentities'
-require 'test/unit'
-
-$KCODE = 'u'
-
-class HTMLEntities::HTML4Test < Test::Unit::TestCase
-
- attr_reader :html_entities
-
- def setup
- @html_entities = HTMLEntities.new('html4')
- end
-
- # Found by Marcos Kuhns
- def test_should_not_encode_apos_entity
- assert_equal "'", html_entities.encode("'", :basic)
- end
-
- def test_should_not_decode_apos_entity
- assert_equal "é&apos;", html_entities.decode("&eacute;&apos;")
- end
-
-end
View
34 lib/htmlentities-4.0.0/test/legacy_test.rb
@@ -1,34 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-require 'htmlentities'
-require 'test/unit'
-
-$KCODE = 'u'
-
-#
-# Test that version 3.x functionality still works
-#
-class HTMLEntities::LegacyTest < Test::Unit::TestCase
-
- def test_should_decode_via_legacy_interface
- assert_decode('&', '&amp;')
- assert_decode('±', '&plusmn;')
- assert_decode('', '&#8220;')
- assert_decode('', '&#x2014;')
- end
-
- def test_should_encode_via_legacy_interface
- assert_encode('&amp;', '&', :basic)
- assert_encode('&eth;', 'ð', :named)
- assert_encode('&#8230;', '', :decimal)
- assert_encode('&#x2212;', '', :hexadecimal)
- end
-
- def assert_encode(expected, *encode_args)
- assert_equal expected, HTMLEntities.encode_entities(*encode_args)
- end
-
- def assert_decode(expected, *decode_args)
- assert_equal expected, HTMLEntities.decode_entities(*decode_args)
- end
-
-end
View
94 lib/htmlentities-4.0.0/test/roundtrip_test.rb
@@ -1,94 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-require 'htmlentities'
-require 'test/unit'
-require 'htmlentities/xhtml1'
-require 'htmlentities/html4'
-
-class HTMLEntities::RoundtripTest < Test::Unit::TestCase
-
- attr_reader :xhtml1_entities, :html4_entities
-
- def setup
- @xhtml1_entities = HTMLEntities.new('xhtml1')
- @html4_entities = HTMLEntities.new('html4')
- end
-
- def test_should_roundtrip_xhtml1_entities_via_named_encoding
- each_mapping('xhtml1') do |name, string|
- assert_equal(
- string,
- xhtml1_entities.decode(xhtml1_entities.encode(string, :named))
- )
- end
- end
-
- def test_should_roundtrip_xhtml1_entities_via_basic_and_named_encoding
- each_mapping('xhtml1') do |name, string|
- assert_equal(
- string,
- xhtml1_entities.decode(xhtml1_entities.encode(string, :basic, :named))
- )
- end
- end
-
- def test_should_roundtrip_xhtml1_entities_via_basic_named_and_decimal_encoding
- each_mapping('xhtml1') do |name, string|
- assert_equal(
- string,
- xhtml1_entities.decode(xhtml1_entities.encode(string, :basic, :named, :decimal))
- )
- end
- end
-
- def test_should_roundtrip_xhtml1_entities_via_hexadecimal_encoding
- each_mapping('xhtml1') do |name, string|
- assert_equal(
- string,
- xhtml1_entities.decode(xhtml1_entities.encode(string, :hexadecimal))
- )
- end
- end
-
- def test_should_roundtrip_html4_entities_via_named_encoding
- each_mapping('html4') do |name, string|
- assert_equal(
- string,
- html4_entities.decode(html4_entities.encode(string, :named))
- )
- end
- end
-
- def test_should_roundtrip_html4_entities_via_basic_and_named_encoding
- each_mapping('html4') do |name, string|
- assert_equal(
- string,
- html4_entities.decode(html4_entities.encode(string, :basic, :named))
- )
- end
- end
-
- def test_should_roundtrip_html4_entities_via_basic_named_and_decimal_encoding
- each_mapping('html4') do |name, string|
- assert_equal(
- string,
- html4_entities.decode(html4_entities.encode(string, :basic, :named, :decimal))
- )
- end
- end
-
- def test_should_roundtrip_html4_entities_via_hexadecimal_encoding
- each_mapping('html4') do |name, string|
- assert_equal(
- string,
- html4_entities.decode(html4_entities.encode(string, :hexadecimal))
- )
- end
- end
-
- def each_mapping(flavor)
- HTMLEntities::MAPPINGS[flavor].each do |name, codepoint|
- yield name, [codepoint].pack('U')
- end
- end
-
-end
View
24 lib/htmlentities-4.0.0/test/string_test.rb
@@ -1,24 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-require 'htmlentities/string'
-require 'test/unit'
-
-$KCODE = 'u'
-
-class TestHTMLEntities < Test::Unit::TestCase
-
- def test_string_responds_correctly_to_decode_entities
- assert_equal('±', '&plusmn;'.decode_entities)
- end
-
- def test_string_responds_correctly_to_encode_entities_with_no_parameters
- assert_equal('&quot;', '"'.encode_entities)
- end
-
- def test_string_responds_correctly_to_encode_entities_with_multiple_parameters
- assert_equal(
- '&quot;bient&ocirc;t&quot; &amp; &#x6587;&#x5b57;',
- '"bientôt" & 文字'.encode_entities(:basic, :named, :hexadecimal)
- )
- end
-
-end
View
3  lib/htmlentities-4.0.0/test/test_all.rb
@@ -1,3 +0,0 @@
-Dir[File.dirname(__FILE__)+'/*_test.rb'].each do |test|
- require test
-end
View
23 lib/htmlentities-4.0.0/test/xhtml1_test.rb
@@ -1,23 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-require 'htmlentities'
-require 'test/unit'
-
-$KCODE = 'u'
-
-class HTMLEntities::XHTML1Test < Test::Unit::TestCase
-
- attr_reader :html_entities
-
- def setup
- @html_entities = HTMLEntities.new('xhtml1')
- end
-
- def test_should_encode_apos_entity
- assert_equal "&apos;", html_entities.encode("'", :basic)
- end
-
- def test_should_decode_apos_entity
- assert_equal "é'", html_entities.decode("&eacute;&apos;")
- end
-
-end
View
3  lib/mocha-0.5.5/COPYING
@@ -1,3 +0,0 @@
-Copyright Revieworld Ltd. 2006
-
-You may use, copy and redistribute this library under the same terms as Ruby itself (see http://www.ruby-lang.org/en/LICENSE.txt) or under the MIT license (see MIT-LICENSE file).
View
7 lib/mocha-0.5.5/MIT-LICENSE
@@ -1,7 +0,0 @@
-Copyright (c) 2006 Revieworld Ltd.
-
-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.
View
35 lib/mocha-0.5.5/README
@@ -1,35 +0,0 @@
-= Mocha
-
-Mocha is a library for mocking and stubbing using a syntax like that of JMock[http://www.jmock.org], and SchMock[http://rubyforge.org/projects/schmock]. Most commonly Mocha is used in conjunction with Test::Unit[http://www.ruby-doc.org/core/classes/Test/Unit.html], but it can be used in other contexts.
-
-One of its main advantages is that it allows you to mock and stub methods on _real_ (non-mock) classes and instances. You can for example stub ActiveRecord[http://api.rubyonrails.com/classes/ActiveRecord/Base.html] instance methods like +create+, +save+, +destroy+ and even class methods like +find+ to avoid hitting the database in unit tests.
-
-Mocha provides a unified, simple and readable syntax for both traditional mocking and for mocking with _real_ objects.
-
-Mocha has been harvested from projects at Reevoo[http://www.reevoo.com] by me (James[http://blog.floehopper.org]) and my colleagues Ben[http://www.reevoo.com/blogs/bengriffiths], Chris[http://blog.seagul.co.uk] and Paul[http://po-ru.com]. Mocha is in use on real-world Rails[http://www.rubyonrails.org] projects.
-
-== Download and Installation
-
-Install the gem with the following command...
-
- $ gem install mocha
-
-Or install the Rails[http://www.rubyonrails.org] plugin...
-
- $ script/plugin install svn://rubyforge.org/var/svn/mocha/trunk
-
-Or download Mocha from here - http://rubyforge.org/projects/mocha
-
-== Examples
-
-* Quick Start - {Usage Examples}[link:examples/misc.html]
-* Traditional mocking - {Star Trek Example}[link:examples/mocha.html]
-* Setting expectations on real classes - {Order Example}[link:examples/stubba.html]
-* More examples on {Floehopper's Blog}[http://blog.floehopper.org]
-* {Mailing List Archives}[http://rubyforge.org/pipermail/mocha-developer/]
-
-== License
-
-Copyright Revieworld Ltd. 2006
-
-You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].
View
188 lib/mocha-0.5.5/RELEASE
@@ -1,188 +0,0 @@
-= 0.5.5 (r167)
-
-- Renamed Matches parameter matcher to RegexpMatches for clarity.
-- Added noframes tag to rdoc index to assist Google.
-
-= 0.5.4 (r166)
-
-- Added matches parameter matcher for matching regular expressions.
-
-= 0.5.3 (r165)
-
-- Attempt to fix packaging problems by switching to newer version (1.15.1) of gnutar and setting COPY_EXTENDED_ATTRIBUTES_DISABLE environment variable.
-- Removed unused ExpectationSequenceError exception.
-- Added instance_of and kind_of parameter matchers.
-- Added Google Webmaster meta tag to rdoc template header.
-- Put Google Webmaster meta tag in the right header i.e. the one for the index page.
-
-= 0.5.2 (r159)
-
-- Fix bug 11885 - "never doesn't work with stub_everything" submitted by Alexander Lang. In fixing this bug, also fixed undiscoverd bug where expected & actual invocation counts were being incorrectly reported which seems to have been introduced when fixes were added for invocation dispatch (see MockedMethodDispatchAcceptanceTest).
-- Previously when an expectation did not allow more invocations, it was treated as not matching. Now we prefer matching expectations which allow more invocations, but still match expectations which cannot allow more invocations. I think this may be overcomplicating things, but let's see how it goes.
-
-= 0.5.1 (r149)
-
-- Fixed bug #11583 "Mocha 0.5.0 throwing unexpected warnings". Also switched on ruby warning for all rake test tasks. Fixed majority of warnings, but some left to fix.
-
-= 0.5.0 (r147)
-
-- Parameter Matchers - I’ve added a few Hamcrest-style parameter matchers which are designed to be used inside Expectation#with. The following matchers are currently available: anything(), includes(), has_key(), has_value(), has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually to get rid of the nasty parameter_block option on Expectation#with.
-
- object = mock()
- object.expects(:method).with(has_key('key_1'))
- object.method('key_1' => 1, 'key_2' => 2)
- # no verification error raised
-
- object = mock()
- object.expects(:method).with(has_key('key_1'))
- object.method('key_2' => 2)
- # verification error raised, because method was not called with Hash containing key: 'key_1'
-
-- Values Returned and Exceptions Raised on Consecutive Invocations - Allow multiple calls to Expectation#returns and Expectation#raises to build up a sequence of responses to invocations on the mock. Added syntactic sugar method Expectation#then to allow more readable expectations.
-
- object = mock()
- object.stubs(:method).returns(1, 2).then.raises(Exception).then.returns(4)
- object.method # => 1
- object.method # => 2
- object.method # => raises exception of class Exception
- object.method # => 4
-
-- Yields on Consecutive Invocations - Allow multiple calls to yields on single expectation to allow yield parameters to be specified for consecutive invocations.
-
- object = mock()
- object.stubs(:method).yields(1, 2).then.yields(3)
- object.method { |*values| p values } # => [1, 2]
- object.method { |*values| p values } # => [3]
-
-- Multiple Yields on Single Invocation - Added Expectation#multiple_yields to allow a mocked or stubbed method to yield multiple times for a single invocation.
-
- object = mock()
- object.stubs(:method).multiple_yields([1, 2], [3])
- object.method { |*values| p values } # => [1, 2] # => [3]
-
-- Invocation Dispatch - Expectations were already being matched in reverse order i.e. the most recently defined one was being found first. This is still the case, but we now stop matching an expectation when its maximum number of expected invocations is reached. c.f. JMock v1. A stub will never stop matching by default. Hopefully this means we can soon get rid of the need to pass a Proc to Expectation#returns.
-
- object = mock()
- object.stubs(:method).returns(2)
- object.expects(:method).once.returns(1)
- object.method # => 1
- object.method # => 2
- object.method # => 2
- # no verification error raised
-
- # The following should still work...
-
- Time.stubs(:now).returns(Time.parse('Mon Jan 01 00:00:00 UTC 2007'))
- Time.now # => Mon Jan 01 00:00:00 UTC 2007
- Time.stubs(:now).returns(Time.parse('Thu Feb 01 00:00:00 UTC 2007'))
- Time.now # => Thu Feb 01 00:00:00 UTC 2007
-
-- Deprecate passing an instance of Proc to Expectation#returns.
-- Explicitly include all Rakefile dependencies in project.
-- Fixed old Stubba example.
-- Fix so that it is possible for a stubbed method to raise an Interrupt exception without a message in Ruby 1.8.6
-- Added responds_like and quacks_like.
-- Capture standard object methods before Mocha adds any.
-- Added Expectation#once method to make interface less surprising.
-- Use Rake::TestTask to run tests. Created three separate tasks to run unit, integration & acceptance tests. Split inspect_test into one file per TestCase. Deleted superfluous all_tests file.
-- Fiddled with mocha_inspect and tests to give more sensible results on x86 platform.
-- Fixed bug #7834 "infinite_range.rb makes incorrect assumption about to_f" logged by James Moore.
-
-= 0.4.0 (r92)
-
-- Allow naming of mocks (patch from Chris Roos).
-- Specify multiple return values for consecutive calls.
-- Improved consistency of expectation error messages.
-- Allow mocking of Object instance methods e.g. kind_of?, type.
-- Provide aliased versions of #expects and #stubs to allow mocking of these methods.
-- Added at_least, at_most, at_most_once methods to expectation.
-- Allow expects and stubs to take a hash of method and return values.
-- Eliminate warning: "instance variable @yield not initialized" (patch from Xavier Shay).
-- Restore instance methods on partial mocks (patch from Chris Roos).
-- Allow stubbing of a method with non-word characters in its name (patch from Paul Battley).
-- Removed coupling to Test::Unit.
-- Allow specified exception instance to be raised (patch from Chris Roos).
-- Make mock object_id appear in hex like normal Ruby inspect (patch from Paul Battley).
-- Fix path to object.rb in rdoc rake task (patch from Tomas Pospisek).
-- Reverse order in which expectations are matched, so that last expectation is matched first. This allows e.g. a call to #stubs to be effectively overridden by a call to #expects (patch from Tobias Lutke).
-- Stubba & SmartTestCase modules incorporated into Mocha module so only need to require 'mocha' - no longer need to require 'stubba'.
-- AutoMocha removed.
-
-= 0.3.3
-
-- Quick bug fix to restore instance methods on partial mocks (for Kevin Clark).
-
-= 0.3.2
-
-- Examples added.
-
-= 0.3.1
-
-- Dual licensing with MIT license added.
-
-= 0.3.0
-
-* Rails plugin.
-* Auto-verify for expectations on concrete classes.
-* Include each expectation verification in the test result assertion count.
-* Filter out noise from assertion backtraces.
-* Point assertion backtrace to line where failing expectation was created.
-* New yields method for expectations.
-* Create stubs which stub all method calls.
-* Mocks now respond_to? expected methods.
-
-= 0.2.1
-
-* Rename MochaAcceptanceTest::Rover#move method to avoid conflict with Rake (in Ruby 1.8.4 only?)
-
-= 0.2.0
-
-* Small change to SetupAndTeardown#teardown_stubs suggested by Luke Redpath (http://www.lukeredpath.co.uk) to allow use of Stubba with RSpec (http://rspec.rubyforge.org).
-* Reorganized directory structure and extracted addition of setup and teardown methods into SmartTestCase mini-library.
-* Addition of auto-verify for Mocha (but not Stubba). This means there is more significance in the choice of expects or stubs in that any expects on a mock will automatically get verified.
-
-So instead of...
-
- wotsit = Mocha.new
- wotsit.expects(:thingummy).with(5).returns(10)
- doobrey = Doobrey.new(wotsit)
- doobrey.hoojamaflip
- wotsit.verify
-
-you need to do...
-
- wotsit = mock()
- wotsit.expects(:thingummy).with(5).returns(10)
- doobrey = Doobrey.new(wotsit)
- doobrey.hoojamaflip
- # no need to verify
-
-There are also shortcuts as follows...
-
-instead of...
-
- wotsit = Mocha.new
- wotsit.expects(:thingummy).returns(10)
- wotsit.expects(:summat).returns(25)
-
-you can have...
-
- wotsit = mock(:thingummy => 5, :summat => 25)
-
-and instead of...
-
- wotsit = Mocha.new
- wotsit.stubs(:thingummy).returns(10)
- wotsit.stubs(:summat).returns(25)
-
-you can have...
-
- wotsit = stub(:thingummy => 5, :summat => 25)
-
-= 0.1.2
-
-* Minor tweaks
-
-= 0.1.1
-
-* Initial release.
View
147 lib/mocha-0.5.5/Rakefile
@@ -1,147 +0,0 @@
-require 'rubygems'
-require 'rake/rdoctask'
-require 'rake/gempackagetask'
-require 'rake/testtask'
-require 'rake/contrib/sshpublisher'
-
-module Mocha
- VERSION = "0.5.5"
-end
-
-desc "Run all tests"
-task :default => :test_all
-
-task :test_all => [:test_unit, :test_integration, :test_acceptance]
-
-desc "Run unit tests"
-Rake::TestTask.new(:test_unit) do |t|
- t.libs << 'test'
- t.test_files = FileList['test/unit/**/*_test.rb']
- t.verbose = true
- t.warning = true
-end
-
-desc "Run integration tests"
-Rake::TestTask.new(:test_integration) do |t|
- t.libs << 'test'
- t.test_files = FileList['test/integration/*_test.rb']
- t.verbose = true
- t.warning = true
-end
-
-desc "Run acceptance tests"
-Rake::TestTask.new(:test_acceptance) do |t|
- t.libs << 'test'
- t.test_files = FileList['test/acceptance/*_test.rb']
- t.verbose = true
- t.warning = true
-end
-
-desc 'Generate RDoc'
-Rake::RDocTask.new do |task|
- task.main = 'README'
- task.title = "Mocha #{Mocha::VERSION}"
- task.rdoc_dir = 'doc'
- task.template = File.expand_path(File.join(File.dirname(__FILE__), "templates", "html_with_google_analytics"))
- task.rdoc_files.include('README', 'RELEASE', 'COPYING', 'MIT-LICENSE', 'agiledox.txt', 'lib/mocha/auto_verify.rb', 'lib/mocha/mock.rb', 'lib/mocha/expectation.rb', 'lib/mocha/object.rb', 'lib/mocha/parameter_matchers.rb', 'lib/mocha/parameter_matchers')
-end
-task :rdoc => :examples
-
-desc "Upload RDoc to RubyForge"
-task :publish_rdoc => [:rdoc, :examples] do
- Rake::SshDirPublisher.new("jamesmead@rubyforge.org", "/var/www/gforge-projects/mocha", "doc").upload
-end
-
-desc "Generate agiledox-like documentation for tests"
-file 'agiledox.txt' do
- File.open('agiledox.txt', 'w') do |output|
- tests = FileList['test/**/*_test.rb']
- tests.each do |file|
- m = %r".*/([^/].*)_test.rb".match(file)
- output << m[1]+" should:\n"
- test_definitions = File::readlines(file).select {|line| line =~ /.*def test.*/}
- test_definitions.sort.each do |definition|
- m = %r"test_(should_)?(.*)".match(definition)
- output << " - "+m[2].gsub(/_/," ") << "\n"
- end
- end
- end
-end
-
-desc "Convert example ruby files to syntax-highlighted html"
-task :examples do
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "vendor", "coderay-0.7.4.215", "lib"))
- require 'coderay'
- mkdir_p 'doc/examples'
- File.open('doc/examples/coderay.css', 'w') do |output|
- output << CodeRay::Encoders[:html]::CSS.new.stylesheet
- end
- ['mocha', 'stubba', 'misc'].each do |filename|
- File.open("doc/examples/#{filename}.html", 'w') do |file|
- file << "<html>"
- file << "<head>"
- file << %q(<link rel="stylesheet" media="screen" href="coderay.css" type="text/css">)
- file << "</head>"
- file << "<body>"
- file << CodeRay.scan_file("examples/#{filename}.rb").html.div
- file << "</body>"
- file << "</html>"
- end
- end
-end
-
-Gem::manage_gems
-
-specification = Gem::Specification.new do |s|
- s.name = "mocha"
- s.summary = "Mocking and stubbing library"
- s.version = Mocha::VERSION
- s.author = 'James Mead'
- s.description = <<-EOF
- Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.
- EOF
- s.email = 'mocha-developer@rubyforge.org'
- s.homepage = 'http://mocha.rubyforge.org'
- s.rubyforge_project = 'mocha'
-
- s.has_rdoc = true
- s.extra_rdoc_files = ['README', 'COPYING']
- s.rdoc_options << '--title' << 'Mocha' << '--main' << 'README' << '--line-numbers'
-
- s.autorequire = 'mocha'
- s.files = FileList['{lib,test,examples}/**/*.rb', '[A-Z]*'].exclude('TODO').to_a
-end
-
-Rake::GemPackageTask.new(specification) do |package|
- package.need_zip = true
- package.need_tar = true
-end
-
-task :verify_user do
- raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
-end
-
-task :verify_password do
- raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
-end
-
-desc "Publish package files on RubyForge."
-task :publish_packages => [:verify_user, :verify_password, :package] do
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "vendor", "meta_project-0.4.15", "lib"))
- require 'meta_project'
- require 'rake/contrib/xforge'
- release_files = FileList[
- "pkg/mocha-#{Mocha::VERSION}.gem",
- "pkg/mocha-#{Mocha::VERSION}.tgz",
- "pkg/mocha-#{Mocha::VERSION}.zip"
- ]
-
- Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new('mocha')) do |release|
- release.user_name = ENV['RUBYFORGE_USER']
- release.password = ENV['RUBYFORGE_PASSWORD']
- release.files = release_files.to_a
- release.release_name = "Mocha #{Mocha::VERSION}"
- release.release_changes = ''
- release.release_notes = ''
- end
-end
View
36 lib/mocha-0.5.5/examples/misc.rb
@@ -1,36 +0,0 @@
-# Mocking a class method
-
- product = Product.new
- Product.expects(:find).with(1).returns(product)
- assert_equal product, Product.find(1)
-
-# Mocking an instance method on a real object
-
- product = Product.new
- product.expects(:save).returns(true)
- assert product.save
-
-# Stubbing instance methods on real object
-
- prices = [stub(:pence => 1000), stub(:pence => 2000)]
- product = Product.new
- product.stubs(:prices).returns(prices)
- assert_equal [1000, 2000], product.prices.collect {|p| p.pence}
-
-# Stubbing an instance method on all instances of a class
-
- Product.any_instance.stubs(:name).returns('stubbed_name')
- product = Product.new
- assert_equal 'stubbed_name', product.name
-
-# Traditional mocking
-
- object = mock()
- object.expects(:expected_method).with(:p1, :p2).returns(:result)
- assert_equal :result, object.expected_method(:p1, :p2)
-
-# Shortcuts
-
- object = stub(:method1 => :result1, :method2 => :result2)
- assert_equal :result1, object.method1
- assert_equal :result2, object.method2
View
26 lib/mocha-0.5.5/examples/mocha.rb
@@ -1,26 +0,0 @@
-class Enterprise
-
- def initialize(dilithium)
- @dilithium = dilithium
- end
-
- def go(warp_factor)
- warp_factor.times { @dilithium.nuke(:anti_matter) }
- end
-
-end
-
-require 'test/unit'
-require 'rubygems'
-require 'mocha'
-
-class EnterpriseTest < Test::Unit::TestCase
-
- def test_should_boldly_go
- dilithium = mock()
- dilithium.expects(:nuke).with(:anti_matter).at_least_once # auto-verified at end of test
- enterprise = Enterprise.new(dilithium)
- enterprise.go(2)
- end
-
-end
View
65 lib/mocha-0.5.5/examples/stubba.rb
@@ -1,65 +0,0 @@
-class Order
-
- attr_accessor :shipped_on
-
- def total_cost
- line_items.inject(0) { |total, line_item| total + line_item.price } + shipping_cost
- end
-
- def total_weight
- line_items.inject(0) { |total, line_item| total + line_item.weight }
- end
-
- def shipping_cost
- total_weight * 5 + 10
- end
-
- class << self
-
- def find_all
- # Database.connection.execute('select * from orders...
- end
-
- def number_shipped_since(date)
- find_all.select { |order| order.shipped_on > date }.size
- end
-
- def unshipped_value
- find_all.inject(0) { |total, order| order.shipped_on ? total : total + order.total_cost }
- end
-
- end
-
-end
-
-require 'test/unit'
-require 'rubygems'
-require 'mocha'
-
-class OrderTest < Test::Unit::TestCase
-
- # illustrates stubbing instance method
- def test_should_calculate_shipping_cost_based_on_total_weight
- order = Order.new
- order.stubs(:total_weight).returns(10)
- assert_equal 60, order.shipping_cost
- end
-
- # illustrates stubbing class method
- def test_should_count_number_of_orders_shipped_after_specified_date
- now = Time.now; week_in_secs = 7 * 24 * 60 * 60
- order_1 = Order.new; order_1.shipped_on = now - 1 * week_in_secs
- order_2 = Order.new; order_2.shipped_on = now - 3 * week_in_secs
- Order.stubs(:find_all).returns([order_1, order_2])
- assert_equal 1, Order.number_shipped_since(now - 2 * week_in_secs)
- end
-
- # illustrates stubbing instance method for all instances of a class
- def test_should_calculate_value_of_unshipped_orders
- Order.stubs(:find_all).returns([Order.new, Order.new, Order.new])
- Order.any_instance.stubs(:shipped_on).returns(nil)
- Order.any_instance.stubs(:total_cost).returns(10)
- assert_equal 30, Order.unshipped_value
- end
-
-end
View
19 lib/mocha-0.5.5/lib/mocha.rb
@@ -1,19 +0,0 @@
-require 'mocha_standalone'
-require 'mocha/test_case_adapter'
-
-require 'test/unit/testcase'
-
-module Test
-
- module Unit
-
- class TestCase
-
- include Mocha::Standalone
- include Mocha::TestCaseAdapter
-
- end
-
- end
-
-end
View
35 lib/mocha-0.5.5/lib/mocha/any_instance_method.rb
@@ -1,35 +0,0 @@
-require 'mocha/class_method'
-
-module Mocha
-
- class AnyInstanceMethod < ClassMethod
-
- def unstub
- remove_new_method
- restore_original_method
- stubbee.any_instance.reset_mocha
- end
-
- def mock
- stubbee.any_instance.mocha
- end
-
- def hide_original_method
- stubbee.class_eval "alias_method :#{hidden_method}, :#{method}" if stubbee.method_defined?(method)
- end
-
- def define_new_method
- stubbee.class_eval "def #{method}(*args, &block); self.class.any_instance.mocha.method_missing(:#{method}, *args, &block); end"
- end
-
- def remove_new_method
- stubbee.class_eval "remove_method :#{method}"
- end
-
- def restore_original_method
- stubbee.class_eval "alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}" if stubbee.method_defined?(hidden_method)
- end
-
- end
-
-end
View
111 lib/mocha-0.5.5/lib/mocha/auto_verify.rb
@@ -1,111 +0,0 @@
-require 'mocha/mock'
-
-module Mocha # :nodoc:
-
- # Methods added to TestCase allowing creation of traditional mock objects.
- #
- # Mocks created this way will have their expectations automatically verified at the end of the test.
- #
- # See Mock for methods on mock objects.
- module AutoVerify
-
- def mocks # :nodoc:
- @mocks ||= []
- end
-
- def reset_mocks # :nodoc:
- @mocks = nil
- end
-
- # :call-seq: mock(name) -> mock object
- # mock(expected_methods = {}) -> mock object
- # mock(name, expected_methods = {}) -> mock object
- #
- # Creates a mock object.
- #
- # +name+ is a +String+ identifier for the mock object.
- #
- # +expected_methods+ is a +Hash+ with expected method name symbols as keys and corresponding return values as values.
- #
- # Note that (contrary to expectations set up by #stub) these expectations <b>must</b> be fulfilled during the test.
- # def test_product
- # product = mock('ipod_product', :manufacturer => 'ipod', :price => 100)
- # assert_equal 'ipod', product.manufacturer
- # assert_equal 100, product.price
- # # an error will be raised unless both Product#manufacturer and Product#price have been called
- # end
- def mock(*args)
- name, expectations = name_and_expectations_from_args(args)
- mock = Mock.new(false, name)
- mock.expects(expectations)
- mocks << mock
- mock