brakeman 5.2.2 → 7.1.1

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 (952) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +153 -0
  3. data/README.md +9 -6
  4. data/bundle/load.rb +16 -15
  5. data/bundle/ruby/3.1.0/gems/csv-3.3.5/LICENSE.txt +33 -0
  6. data/bundle/ruby/3.1.0/gems/csv-3.3.5/NEWS.md +1009 -0
  7. data/bundle/ruby/3.1.0/gems/csv-3.3.5/README.md +55 -0
  8. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/core_ext/array.rb +9 -0
  9. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/core_ext/string.rb +9 -0
  10. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/fields_converter.rb +96 -0
  11. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/input_record_separator.rb +18 -0
  12. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/parser.rb +1302 -0
  13. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/row.rb +757 -0
  14. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/table.rb +1055 -0
  15. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/version.rb +6 -0
  16. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv/writer.rb +209 -0
  17. data/bundle/ruby/3.1.0/gems/csv-3.3.5/lib/csv.rb +3017 -0
  18. data/bundle/ruby/3.1.0/gems/haml-6.4.0/CHANGELOG.md +1681 -0
  19. data/bundle/ruby/3.1.0/gems/haml-6.4.0/FAQ.md +147 -0
  20. data/bundle/ruby/3.1.0/gems/haml-6.4.0/Gemfile +34 -0
  21. data/bundle/ruby/3.1.0/gems/haml-6.4.0/MIT-LICENSE +20 -0
  22. data/bundle/ruby/3.1.0/gems/haml-6.4.0/README.md +205 -0
  23. data/bundle/ruby/3.1.0/gems/haml-6.4.0/REFERENCE.md +1309 -0
  24. data/bundle/ruby/3.1.0/gems/haml-6.4.0/exe/haml +6 -0
  25. data/bundle/ruby/3.1.0/gems/haml-6.4.0/haml.gemspec +45 -0
  26. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/ambles.rb +20 -0
  27. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/attribute_builder.rb +162 -0
  28. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/attribute_compiler.rb +133 -0
  29. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/attribute_parser.rb +116 -0
  30. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/cli.rb +154 -0
  31. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/compiler/children_compiler.rb +155 -0
  32. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/compiler/comment_compiler.rb +51 -0
  33. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/compiler/doctype_compiler.rb +52 -0
  34. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/compiler/script_compiler.rb +114 -0
  35. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/compiler/silent_script_compiler.rb +24 -0
  36. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/compiler/tag_compiler.rb +76 -0
  37. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/compiler.rb +97 -0
  38. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/dynamic_merger.rb +67 -0
  39. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/engine.rb +59 -0
  40. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/error.rb +66 -0
  41. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/escape.rb +13 -0
  42. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/escape_any.rb +21 -0
  43. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/base.rb +12 -0
  44. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/cdata.rb +20 -0
  45. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/coffee.rb +17 -0
  46. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/css.rb +33 -0
  47. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/erb.rb +10 -0
  48. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/escaped.rb +22 -0
  49. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/javascript.rb +33 -0
  50. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/less.rb +20 -0
  51. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/markdown.rb +11 -0
  52. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/plain.rb +29 -0
  53. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/preserve.rb +22 -0
  54. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/ruby.rb +10 -0
  55. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/sass.rb +15 -0
  56. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/scss.rb +15 -0
  57. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/text_base.rb +25 -0
  58. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters/tilt_base.rb +59 -0
  59. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/filters.rb +75 -0
  60. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/force_escape.rb +29 -0
  61. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/helpers.rb +15 -0
  62. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/html.rb +22 -0
  63. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/identity.rb +13 -0
  64. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/object_ref.rb +35 -0
  65. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/parser.rb +991 -0
  66. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/rails_helpers.rb +53 -0
  67. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/rails_template.rb +62 -0
  68. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/railtie.rb +10 -0
  69. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/ruby_expression.rb +32 -0
  70. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/string_splitter.rb +140 -0
  71. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/template.rb +20 -0
  72. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/temple_line_counter.rb +31 -0
  73. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/util.rb +262 -0
  74. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/version.rb +4 -0
  75. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml/whitespace.rb +8 -0
  76. data/bundle/ruby/3.1.0/gems/haml-6.4.0/lib/haml.rb +13 -0
  77. data/bundle/ruby/3.1.0/gems/highline-3.1.2/Changelog.md +658 -0
  78. data/bundle/ruby/3.1.0/gems/highline-3.1.2/Gemfile +21 -0
  79. data/bundle/ruby/3.1.0/gems/highline-3.1.2/README.md +240 -0
  80. data/bundle/ruby/3.1.0/gems/highline-3.1.2/highline.gemspec +40 -0
  81. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/io_console_compatible.rb +37 -0
  82. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/list_renderer.rb +261 -0
  83. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/menu.rb +578 -0
  84. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/question/answer_converter.rb +100 -0
  85. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/question.rb +640 -0
  86. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/question_asker.rb +152 -0
  87. data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/style.rb +0 -0
  88. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/terminal/io_console.rb +36 -0
  89. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/terminal/unix_stty.rb +53 -0
  90. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/terminal.rb +192 -0
  91. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline/version.rb +6 -0
  92. data/bundle/ruby/3.1.0/gems/highline-3.1.2/lib/highline.rb +676 -0
  93. data/bundle/ruby/3.1.0/gems/parallel-1.27.0/lib/parallel/version.rb +4 -0
  94. data/bundle/ruby/3.1.0/gems/parallel-1.27.0/lib/parallel.rb +708 -0
  95. data/bundle/ruby/3.1.0/gems/reline-0.6.2/COPYING +56 -0
  96. data/bundle/ruby/3.1.0/gems/reline-0.6.2/README.md +94 -0
  97. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/config.rb +378 -0
  98. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/face.rb +199 -0
  99. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/history.rb +76 -0
  100. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/io/ansi.rb +322 -0
  101. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/io/dumb.rb +120 -0
  102. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/io/windows.rb +530 -0
  103. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/io.rb +55 -0
  104. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/key_actor/base.rb +37 -0
  105. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/key_actor/composite.rb +17 -0
  106. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/key_actor/emacs.rb +517 -0
  107. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/key_actor/vi_command.rb +518 -0
  108. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/key_actor/vi_insert.rb +517 -0
  109. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/key_actor.rb +8 -0
  110. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/key_stroke.rb +119 -0
  111. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/kill_ring.rb +125 -0
  112. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/line_editor.rb +2356 -0
  113. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/unicode/east_asian_width.rb +1292 -0
  114. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/unicode.rb +421 -0
  115. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline/version.rb +3 -0
  116. data/bundle/ruby/3.1.0/gems/reline-0.6.2/lib/reline.rb +527 -0
  117. data/bundle/ruby/3.1.0/gems/reline-0.6.2/license_of_rb-readline +25 -0
  118. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/LICENSE.txt +22 -0
  119. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/NEWS.md +843 -0
  120. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/README.md +57 -0
  121. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/attribute.rb +210 -0
  122. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/cdata.rb +68 -0
  123. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/child.rb +96 -0
  124. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/comment.rb +80 -0
  125. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/doctype.rb +306 -0
  126. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/document.rb +471 -0
  127. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/element.rb +2578 -0
  128. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/encoding.rb +48 -0
  129. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/entity.rb +142 -0
  130. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/formatters/pretty.rb +142 -0
  131. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/functions.rb +446 -0
  132. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/instruction.rb +79 -0
  133. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/namespace.rb +63 -0
  134. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/node.rb +80 -0
  135. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/parseexception.rb +53 -0
  136. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/parsers/baseparser.rb +949 -0
  137. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/parsers/pullparser.rb +213 -0
  138. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/parsers/sax2parser.rb +270 -0
  139. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/parsers/streamparser.rb +67 -0
  140. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/parsers/treeparser.rb +89 -0
  141. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/parsers/xpathparser.rb +739 -0
  142. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/quickpath.rb +267 -0
  143. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/rexml.rb +39 -0
  144. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/security.rb +28 -0
  145. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/source.rb +388 -0
  146. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/text.rb +420 -0
  147. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/validation/relaxng.rb +540 -0
  148. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/validation/validation.rb +144 -0
  149. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/xpath.rb +70 -0
  150. data/bundle/ruby/3.1.0/gems/rexml-3.4.4/lib/rexml/xpath_parser.rb +980 -0
  151. data/bundle/ruby/3.1.0/gems/ruby2ruby-2.5.2/History.rdoc +463 -0
  152. data/bundle/ruby/3.1.0/gems/ruby2ruby-2.5.2/lib/ruby2ruby.rb +1448 -0
  153. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/History.rdoc +1345 -0
  154. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/Manifest.txt +48 -0
  155. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/README.rdoc +113 -0
  156. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/compare/normalize.rb +219 -0
  157. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby20_parser.rb +10956 -0
  158. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby20_parser.y +2707 -0
  159. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby21_parser.rb +10981 -0
  160. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby21_parser.y +2724 -0
  161. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby22_parser.rb +11122 -0
  162. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby22_parser.y +2735 -0
  163. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby23_parser.rb +11163 -0
  164. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby23_parser.y +2737 -0
  165. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby24_parser.rb +11212 -0
  166. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby24_parser.y +2745 -0
  167. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby25_parser.rb +11212 -0
  168. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby25_parser.y +2745 -0
  169. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby26_parser.rb +11234 -0
  170. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby26_parser.y +2760 -0
  171. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby27_parser.rb +12963 -0
  172. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby27_parser.y +3360 -0
  173. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby30_parser.rb +13316 -0
  174. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby30_parser.y +3508 -0
  175. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby31_parser.rb +13649 -0
  176. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby31_parser.y +3542 -0
  177. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby32_parser.rb +13601 -0
  178. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby32_parser.y +3543 -0
  179. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby3_parser.yy +3635 -0
  180. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby_lexer.rb +1159 -0
  181. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby_lexer.rex.rb +399 -0
  182. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby_lexer_strings.rb +638 -0
  183. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby_parser.rb +100 -0
  184. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby_parser.yy +3501 -0
  185. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby_parser_extras.rb +1878 -0
  186. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/tools/munge.rb +256 -0
  187. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/tools/ripper.rb +46 -0
  188. data/bundle/ruby/3.1.0/gems/sexp_processor-4.17.4/History.rdoc +493 -0
  189. data/bundle/ruby/3.1.0/gems/sexp_processor-4.17.4/lib/pt_testcase.rb +3137 -0
  190. data/bundle/ruby/3.1.0/gems/sexp_processor-4.17.4/lib/sexp.rb +397 -0
  191. data/bundle/ruby/3.1.0/gems/sexp_processor-4.17.4/lib/sexp_matcher.rb +1100 -0
  192. data/bundle/ruby/3.1.0/gems/sexp_processor-4.17.4/lib/sexp_processor.rb +754 -0
  193. data/bundle/ruby/3.1.0/gems/sexp_processor-4.17.4/lib/strict_sexp.rb +149 -0
  194. data/bundle/ruby/3.1.0/gems/slim-5.2.1/CHANGES +496 -0
  195. data/bundle/ruby/3.1.0/gems/slim-5.2.1/Gemfile +43 -0
  196. data/bundle/ruby/3.1.0/gems/slim-5.2.1/LICENSE +21 -0
  197. data/bundle/ruby/3.1.0/gems/slim-5.2.1/README.jp.md +1276 -0
  198. data/bundle/ruby/3.1.0/gems/slim-5.2.1/README.md +1313 -0
  199. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/code_attributes.rb +68 -0
  200. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/command.rb +122 -0
  201. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/controls.rb +61 -0
  202. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/do_inserter.rb +34 -0
  203. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/embedded.rb +248 -0
  204. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/end_inserter.rb +63 -0
  205. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/engine.rb +42 -0
  206. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/erb_converter.rb +15 -0
  207. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/filter.rb +31 -0
  208. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/grammar.rb +24 -0
  209. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/include.rb +58 -0
  210. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/interpolation.rb +36 -0
  211. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/logic_less/context.rb +126 -0
  212. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/logic_less/filter.rb +81 -0
  213. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/logic_less.rb +6 -0
  214. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/parser.rb +535 -0
  215. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/railtie.rb +19 -0
  216. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/smart/escaper.rb +42 -0
  217. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/smart/filter.rb +97 -0
  218. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/smart/parser.rb +35 -0
  219. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/smart.rb +9 -0
  220. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/splat/builder.rb +115 -0
  221. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/splat/filter.rb +93 -0
  222. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/template.rb +6 -0
  223. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/translator.rb +119 -0
  224. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/version.rb +6 -0
  225. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim.rb +16 -0
  226. data/bundle/ruby/3.1.0/gems/slim-5.2.1/slim.gemspec +33 -0
  227. data/bundle/ruby/3.1.0/gems/temple-0.10.4/CHANGES +302 -0
  228. data/bundle/ruby/3.1.0/gems/temple-0.10.4/Gemfile +2 -0
  229. data/bundle/ruby/3.1.0/gems/temple-0.10.4/README.md +267 -0
  230. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/engine.rb +68 -0
  231. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/erb/engine.rb +18 -0
  232. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/erb/parser.rb +41 -0
  233. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/erb/template.rb +12 -0
  234. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/erb/trimming.rb +24 -0
  235. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/exceptions.rb +14 -0
  236. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filter.rb +10 -0
  237. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/ambles.rb +22 -0
  238. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/code_merger.rb +31 -0
  239. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/control_flow.rb +43 -0
  240. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/dynamic_inliner.rb +72 -0
  241. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/dynamic_merger.rb +69 -0
  242. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/encoding.rb +25 -0
  243. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/eraser.rb +23 -0
  244. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/escapable.rb +41 -0
  245. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/multi_flattener.rb +26 -0
  246. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/remove_bom.rb +14 -0
  247. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/static_analyzer.rb +31 -0
  248. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/static_merger.rb +38 -0
  249. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/string_splitter.rb +142 -0
  250. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/filters/validator.rb +16 -0
  251. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/generator.rb +91 -0
  252. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/generators/array.rb +22 -0
  253. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/generators/array_buffer.rb +30 -0
  254. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/generators/erb.rb +33 -0
  255. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/generators/rails_output_buffer.rb +35 -0
  256. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/generators/string_buffer.rb +26 -0
  257. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/grammar.rb +58 -0
  258. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/html/attribute_merger.rb +43 -0
  259. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/html/attribute_remover.rb +36 -0
  260. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/html/attribute_sorter.rb +22 -0
  261. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/html/dispatcher.rb +32 -0
  262. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/html/fast.rb +131 -0
  263. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/html/filter.rb +22 -0
  264. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/html/pretty.rb +104 -0
  265. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/html/safe.rb +24 -0
  266. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/map.rb +106 -0
  267. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/mixins/dispatcher.rb +162 -0
  268. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/mixins/engine_dsl.rb +146 -0
  269. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/mixins/grammar_dsl.rb +172 -0
  270. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/mixins/options.rb +88 -0
  271. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/mixins/template.rb +29 -0
  272. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/parser.rb +9 -0
  273. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/static_analyzer.rb +78 -0
  274. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/templates/rails.rb +31 -0
  275. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/templates/tilt.rb +39 -0
  276. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/templates.rb +12 -0
  277. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/utils.rb +91 -0
  278. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple/version.rb +4 -0
  279. data/bundle/ruby/3.1.0/gems/temple-0.10.4/lib/temple.rb +70 -0
  280. data/bundle/ruby/3.1.0/gems/temple-0.10.4/temple.gemspec +27 -0
  281. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/History.rdoc +149 -0
  282. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/README.md +417 -0
  283. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/cell.rb +94 -0
  284. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/row.rb +66 -0
  285. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/separator.rb +66 -0
  286. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/style.rb +284 -0
  287. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/table.rb +374 -0
  288. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/util.rb +13 -0
  289. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/version.rb +5 -0
  290. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table.rb +26 -0
  291. data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/terminal-table.gemspec +25 -0
  292. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/COPYING +19 -0
  293. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/_emacs_org.rb +2 -0
  294. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/_handlebars.rb +2 -0
  295. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/_jbuilder.rb +2 -0
  296. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/_org.rb +2 -0
  297. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/asciidoc.rb +15 -0
  298. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/babel.rb +8 -0
  299. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/builder.rb +42 -0
  300. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/cli.rb +134 -0
  301. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/coffee.rb +39 -0
  302. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/commonmarker.rb +95 -0
  303. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/creole.rb +16 -0
  304. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/csv.rb +53 -0
  305. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/erb.rb +65 -0
  306. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/erubi.rb +55 -0
  307. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/etanni.rb +28 -0
  308. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/haml.rb +94 -0
  309. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/kramdown.rb +13 -0
  310. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/liquid.rb +37 -0
  311. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/livescript.rb +11 -0
  312. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/mapping.rb +412 -0
  313. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/markaby.rb +43 -0
  314. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/nokogiri.rb +37 -0
  315. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/pandoc.rb +39 -0
  316. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/pipeline.rb +19 -0
  317. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/plain.rb +5 -0
  318. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/prawn.rb +28 -0
  319. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/radius.rb +41 -0
  320. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/rdiscount.rb +23 -0
  321. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/rdoc.rb +11 -0
  322. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/redcarpet.rb +31 -0
  323. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/redcloth.rb +13 -0
  324. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/rst-pandoc.rb +10 -0
  325. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/sass.rb +78 -0
  326. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/slim.rb +5 -0
  327. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/string.rb +27 -0
  328. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/template.rb +611 -0
  329. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/typescript.rb +19 -0
  330. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt/yajl.rb +81 -0
  331. data/bundle/ruby/3.1.0/gems/tilt-2.6.1/lib/tilt.rb +192 -0
  332. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/CHANGELOG.md +299 -0
  333. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/MIT-LICENSE.txt +22 -0
  334. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/README.md +194 -0
  335. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/data/display_width.marshal.gz +0 -0
  336. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/lib/unicode/display_width/constants.rb +10 -0
  337. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/lib/unicode/display_width/emoji_support.rb +55 -0
  338. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/lib/unicode/display_width/index.rb +34 -0
  339. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/lib/unicode/display_width/no_string_ext.rb +8 -0
  340. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/lib/unicode/display_width/reline_ext.rb +14 -0
  341. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/lib/unicode/display_width/string_ext.rb +9 -0
  342. data/bundle/ruby/3.1.0/gems/unicode-display_width-3.2.0/lib/unicode/display_width.rb +247 -0
  343. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/CHANGELOG.md +196 -0
  344. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/CODE_OF_CONDUCT.md +74 -0
  345. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/Gemfile +7 -0
  346. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/Gemfile.lock +33 -0
  347. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/MIT-LICENSE.txt +20 -0
  348. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/README.md +205 -0
  349. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/data/emoji.marshal.gz +0 -0
  350. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/data/generate_constants.rb +344 -0
  351. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/constants.rb +49 -0
  352. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex.rb +8 -0
  353. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_basic.rb +8 -0
  354. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_emoji_keycap.rb +8 -0
  355. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_include_mqe.rb +8 -0
  356. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_include_mqe_uqe.rb +8 -0
  357. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_include_text.rb +8 -0
  358. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_picto.rb +8 -0
  359. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_picto_no_emoji.rb +8 -0
  360. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_possible.rb +8 -0
  361. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_prop_component.rb +8 -0
  362. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_prop_emoji.rb +8 -0
  363. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_prop_modifier.rb +8 -0
  364. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_prop_modifier_base.rb +8 -0
  365. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_prop_presentation.rb +8 -0
  366. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_text.rb +8 -0
  367. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_text_presentation.rb +8 -0
  368. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_valid.rb +8 -0
  369. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_valid_include_text.rb +8 -0
  370. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_well_formed.rb +8 -0
  371. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated/regex_well_formed_include_text.rb +8 -0
  372. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex.rb +8 -0
  373. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_basic.rb +8 -0
  374. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_emoji_keycap.rb +8 -0
  375. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_include_mqe.rb +8 -0
  376. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_include_mqe_uqe.rb +8 -0
  377. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_include_text.rb +8 -0
  378. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_picto.rb +8 -0
  379. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_picto_no_emoji.rb +8 -0
  380. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_possible.rb +8 -0
  381. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_prop_component.rb +8 -0
  382. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_prop_emoji.rb +8 -0
  383. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_prop_modifier.rb +8 -0
  384. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_prop_modifier_base.rb +8 -0
  385. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_prop_presentation.rb +8 -0
  386. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_text.rb +8 -0
  387. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_text_presentation.rb +8 -0
  388. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_valid.rb +8 -0
  389. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_valid_include_text.rb +8 -0
  390. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_well_formed.rb +8 -0
  391. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/generated_native/regex_well_formed_include_text.rb +8 -0
  392. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/index.rb +14 -0
  393. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/lazy_constants.rb +56 -0
  394. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji/list.rb +13 -0
  395. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/lib/unicode/emoji.rb +111 -0
  396. data/bundle/ruby/3.1.0/gems/unicode-emoji-4.1.0/unicode-emoji.gemspec +22 -0
  397. data/lib/brakeman/app_tree.rb +98 -19
  398. data/lib/brakeman/checks/base_check.rb +7 -5
  399. data/lib/brakeman/checks/check_basic_auth.rb +4 -2
  400. data/lib/brakeman/checks/check_basic_auth_timing_attack.rb +2 -1
  401. data/lib/brakeman/checks/check_content_tag.rb +16 -9
  402. data/lib/brakeman/checks/check_cookie_serialization.rb +2 -1
  403. data/lib/brakeman/checks/check_create_with.rb +4 -2
  404. data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -3
  405. data/lib/brakeman/checks/check_csrf_token_forgery_cve.rb +2 -1
  406. data/lib/brakeman/checks/check_default_routes.rb +6 -3
  407. data/lib/brakeman/checks/check_deserialize.rb +6 -2
  408. data/lib/brakeman/checks/check_detailed_exceptions.rb +4 -2
  409. data/lib/brakeman/checks/check_digest_dos.rb +2 -1
  410. data/lib/brakeman/checks/check_divide_by_zero.rb +2 -1
  411. data/lib/brakeman/checks/check_dynamic_finders.rb +2 -1
  412. data/lib/brakeman/checks/check_eol_rails.rb +7 -0
  413. data/lib/brakeman/checks/check_eol_ruby.rb +5 -1
  414. data/lib/brakeman/checks/check_escape_function.rb +2 -1
  415. data/lib/brakeman/checks/check_evaluation.rb +45 -7
  416. data/lib/brakeman/checks/check_execute.rb +34 -3
  417. data/lib/brakeman/checks/check_file_access.rb +2 -1
  418. data/lib/brakeman/checks/check_file_disclosure.rb +2 -1
  419. data/lib/brakeman/checks/check_filter_skipping.rb +2 -1
  420. data/lib/brakeman/checks/check_force_ssl.rb +2 -1
  421. data/lib/brakeman/checks/check_forgery_setting.rb +4 -2
  422. data/lib/brakeman/checks/check_header_dos.rb +2 -1
  423. data/lib/brakeman/checks/check_i18n_xss.rb +2 -1
  424. data/lib/brakeman/checks/check_jruby_xml.rb +2 -1
  425. data/lib/brakeman/checks/check_json_encoding.rb +2 -1
  426. data/lib/brakeman/checks/check_json_entity_escape.rb +4 -2
  427. data/lib/brakeman/checks/check_json_parsing.rb +4 -2
  428. data/lib/brakeman/checks/check_link_to.rb +2 -1
  429. data/lib/brakeman/checks/check_link_to_href.rb +4 -2
  430. data/lib/brakeman/checks/check_mail_to.rb +2 -1
  431. data/lib/brakeman/checks/check_mass_assignment.rb +6 -3
  432. data/lib/brakeman/checks/check_mime_type_dos.rb +2 -1
  433. data/lib/brakeman/checks/check_model_attr_accessible.rb +3 -1
  434. data/lib/brakeman/checks/check_model_attributes.rb +4 -2
  435. data/lib/brakeman/checks/check_model_serialize.rb +2 -1
  436. data/lib/brakeman/checks/check_nested_attributes.rb +2 -1
  437. data/lib/brakeman/checks/check_nested_attributes_bypass.rb +2 -1
  438. data/lib/brakeman/checks/check_number_to_currency.rb +4 -2
  439. data/lib/brakeman/checks/check_page_caching_cve.rb +2 -1
  440. data/lib/brakeman/checks/check_pathname.rb +48 -0
  441. data/lib/brakeman/checks/check_permit_attributes.rb +2 -1
  442. data/lib/brakeman/checks/check_quote_table_name.rb +2 -1
  443. data/lib/brakeman/checks/check_ransack.rb +53 -0
  444. data/lib/brakeman/checks/check_redirect.rb +67 -31
  445. data/lib/brakeman/checks/check_regex_dos.rb +2 -1
  446. data/lib/brakeman/checks/check_render.rb +15 -3
  447. data/lib/brakeman/checks/check_render_dos.rb +2 -1
  448. data/lib/brakeman/checks/check_render_inline.rb +4 -2
  449. data/lib/brakeman/checks/check_response_splitting.rb +2 -1
  450. data/lib/brakeman/checks/check_reverse_tabnabbing.rb +2 -1
  451. data/lib/brakeman/checks/check_route_dos.rb +2 -1
  452. data/lib/brakeman/checks/check_safe_buffer_manipulation.rb +2 -1
  453. data/lib/brakeman/checks/check_sanitize_config_cve.rb +120 -0
  454. data/lib/brakeman/checks/check_sanitize_methods.rb +6 -3
  455. data/lib/brakeman/checks/check_secrets.rb +2 -1
  456. data/lib/brakeman/checks/check_select_tag.rb +2 -1
  457. data/lib/brakeman/checks/check_select_vulnerability.rb +2 -1
  458. data/lib/brakeman/checks/check_send.rb +2 -1
  459. data/lib/brakeman/checks/check_session_manipulation.rb +2 -1
  460. data/lib/brakeman/checks/check_session_settings.rb +8 -6
  461. data/lib/brakeman/checks/check_simple_format.rb +4 -2
  462. data/lib/brakeman/checks/check_single_quotes.rb +2 -1
  463. data/lib/brakeman/checks/check_skip_before_filter.rb +4 -2
  464. data/lib/brakeman/checks/check_sprockets_path_traversal.rb +2 -1
  465. data/lib/brakeman/checks/check_sql.rb +14 -5
  466. data/lib/brakeman/checks/check_sql_cves.rb +4 -2
  467. data/lib/brakeman/checks/check_ssl_verify.rb +2 -1
  468. data/lib/brakeman/checks/check_strip_tags.rb +6 -3
  469. data/lib/brakeman/checks/check_symbol_dos.rb +2 -1
  470. data/lib/brakeman/checks/check_symbol_dos_cve.rb +2 -1
  471. data/lib/brakeman/checks/check_template_injection.rb +2 -1
  472. data/lib/brakeman/checks/check_translate_bug.rb +2 -1
  473. data/lib/brakeman/checks/check_unsafe_reflection.rb +2 -1
  474. data/lib/brakeman/checks/check_unsafe_reflection_methods.rb +2 -1
  475. data/lib/brakeman/checks/check_unscoped_find.rb +10 -1
  476. data/lib/brakeman/checks/check_validation_regex.rb +2 -1
  477. data/lib/brakeman/checks/check_verb_confusion.rb +2 -1
  478. data/lib/brakeman/checks/check_weak_hash.rb +6 -3
  479. data/lib/brakeman/checks/check_weak_rsa_key.rb +112 -0
  480. data/lib/brakeman/checks/check_without_protection.rb +2 -1
  481. data/lib/brakeman/checks/check_xml_dos.rb +2 -1
  482. data/lib/brakeman/checks/check_yaml_parsing.rb +4 -2
  483. data/lib/brakeman/checks/eol_check.rb +4 -2
  484. data/lib/brakeman/commandline.rb +5 -0
  485. data/lib/brakeman/file_parser.rb +35 -2
  486. data/lib/brakeman/file_path.rb +4 -0
  487. data/lib/brakeman/messages.rb +1 -1
  488. data/lib/brakeman/options.rb +50 -5
  489. data/lib/brakeman/parsers/erubis_patch.rb +11 -0
  490. data/lib/brakeman/parsers/haml6_embedded.rb +23 -0
  491. data/lib/brakeman/parsers/rails2_erubis.rb +3 -0
  492. data/lib/brakeman/parsers/rails2_xss_plugin_erubis.rb +4 -0
  493. data/lib/brakeman/parsers/rails3_erubis.rb +5 -1
  494. data/lib/brakeman/parsers/slim_embedded.rb +2 -0
  495. data/lib/brakeman/parsers/template_parser.rb +32 -7
  496. data/lib/brakeman/processor.rb +2 -0
  497. data/lib/brakeman/processors/alias_processor.rb +160 -44
  498. data/lib/brakeman/processors/base_processor.rb +2 -0
  499. data/lib/brakeman/processors/gem_processor.rb +2 -2
  500. data/lib/brakeman/processors/haml6_template_processor.rb +92 -0
  501. data/lib/brakeman/processors/haml_template_processor.rb +8 -2
  502. data/lib/brakeman/processors/lib/file_type_detector.rb +9 -7
  503. data/lib/brakeman/processors/lib/find_all_calls.rb +1 -0
  504. data/lib/brakeman/processors/lib/module_helper.rb +31 -1
  505. data/lib/brakeman/processors/lib/rails3_config_processor.rb +1 -1
  506. data/lib/brakeman/processors/lib/render_helper.rb +38 -1
  507. data/lib/brakeman/processors/library_processor.rb +6 -0
  508. data/lib/brakeman/processors/template_processor.rb +1 -1
  509. data/lib/brakeman/report/ignore/config.rb +0 -1
  510. data/lib/brakeman/report/ignore/interactive.rb +2 -2
  511. data/lib/brakeman/report/pager.rb +2 -2
  512. data/lib/brakeman/report/report_codeclimate.rb +1 -1
  513. data/lib/brakeman/report/report_csv.rb +2 -0
  514. data/lib/brakeman/report/report_github.rb +1 -1
  515. data/lib/brakeman/report/report_html.rb +1 -1
  516. data/lib/brakeman/report/report_junit.rb +6 -59
  517. data/lib/brakeman/report/report_markdown.rb +1 -1
  518. data/lib/brakeman/report/report_sarif.rb +122 -2
  519. data/lib/brakeman/report/report_table.rb +7 -7
  520. data/lib/brakeman/report/report_tabs.rb +0 -1
  521. data/lib/brakeman/report/report_text.rb +10 -1
  522. data/lib/brakeman/report/templates/controller_warnings.html.erb +2 -0
  523. data/lib/brakeman/report/templates/header.html.erb +8 -3
  524. data/lib/brakeman/report/templates/ignored_warnings.html.erb +5 -3
  525. data/lib/brakeman/report/templates/model_warnings.html.erb +2 -0
  526. data/lib/brakeman/report/templates/security_warnings.html.erb +2 -0
  527. data/lib/brakeman/report/templates/view_warnings.html.erb +2 -0
  528. data/lib/brakeman/rescanner.rb +40 -388
  529. data/lib/brakeman/scanner.rb +182 -88
  530. data/lib/brakeman/tracker/config.rb +89 -34
  531. data/lib/brakeman/tracker/controller.rb +14 -10
  532. data/lib/brakeman/tracker/file_cache.rb +83 -0
  533. data/lib/brakeman/tracker.rb +27 -4
  534. data/lib/brakeman/util.rb +21 -7
  535. data/lib/brakeman/version.rb +1 -1
  536. data/lib/brakeman/warning.rb +6 -3
  537. data/lib/brakeman/warning_codes.rb +6 -0
  538. data/lib/brakeman.rb +33 -7
  539. data/lib/ruby_parser/bm_sexp.rb +5 -1
  540. metadata +515 -422
  541. data/bundle/ruby/2.7.0/gems/haml-5.2.2/CHANGELOG.md +0 -1505
  542. data/bundle/ruby/2.7.0/gems/haml-5.2.2/FAQ.md +0 -147
  543. data/bundle/ruby/2.7.0/gems/haml-5.2.2/Gemfile +0 -16
  544. data/bundle/ruby/2.7.0/gems/haml-5.2.2/MIT-LICENSE +0 -20
  545. data/bundle/ruby/2.7.0/gems/haml-5.2.2/README.md +0 -216
  546. data/bundle/ruby/2.7.0/gems/haml-5.2.2/REFERENCE.md +0 -1380
  547. data/bundle/ruby/2.7.0/gems/haml-5.2.2/TODO +0 -24
  548. data/bundle/ruby/2.7.0/gems/haml-5.2.2/haml.gemspec +0 -45
  549. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/attribute_builder.rb +0 -219
  550. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/attribute_compiler.rb +0 -237
  551. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/attribute_parser.rb +0 -150
  552. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/buffer.rb +0 -182
  553. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/compiler.rb +0 -330
  554. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/engine.rb +0 -238
  555. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/error.rb +0 -65
  556. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/escapable.rb +0 -77
  557. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/exec.rb +0 -347
  558. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/filters.rb +0 -399
  559. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/generator.rb +0 -42
  560. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/helpers/action_view_extensions.rb +0 -60
  561. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/helpers/action_view_mods.rb +0 -132
  562. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/helpers/action_view_xss_mods.rb +0 -60
  563. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/helpers/safe_erubi_template.rb +0 -20
  564. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/helpers/safe_erubis_template.rb +0 -33
  565. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/helpers/xss_mods.rb +0 -114
  566. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/helpers.rb +0 -709
  567. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/options.rb +0 -273
  568. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/parser.rb +0 -856
  569. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/plugin.rb +0 -54
  570. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/railtie.rb +0 -53
  571. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/sass_rails_filter.rb +0 -47
  572. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/template/options.rb +0 -27
  573. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/template.rb +0 -39
  574. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/temple_engine.rb +0 -124
  575. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/temple_line_counter.rb +0 -30
  576. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/util.rb +0 -258
  577. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/version.rb +0 -5
  578. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml.rb +0 -25
  579. data/bundle/ruby/2.7.0/gems/haml-5.2.2/yard/default/fulldoc/html/css/common.sass +0 -15
  580. data/bundle/ruby/2.7.0/gems/haml-5.2.2/yard/default/layout/html/footer.erb +0 -12
  581. data/bundle/ruby/2.7.0/gems/highline-2.0.3/Changelog.md +0 -620
  582. data/bundle/ruby/2.7.0/gems/highline-2.0.3/Gemfile +0 -22
  583. data/bundle/ruby/2.7.0/gems/highline-2.0.3/README.md +0 -202
  584. data/bundle/ruby/2.7.0/gems/highline-2.0.3/appveyor.yml +0 -37
  585. data/bundle/ruby/2.7.0/gems/highline-2.0.3/highline.gemspec +0 -35
  586. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/io_console_compatible.rb +0 -37
  587. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/list_renderer.rb +0 -261
  588. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/menu.rb +0 -576
  589. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/question/answer_converter.rb +0 -103
  590. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/question.rb +0 -630
  591. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/question_asker.rb +0 -150
  592. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/terminal/io_console.rb +0 -36
  593. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/terminal/unix_stty.rb +0 -51
  594. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/terminal.rb +0 -190
  595. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline/version.rb +0 -6
  596. data/bundle/ruby/2.7.0/gems/highline-2.0.3/lib/highline.rb +0 -650
  597. data/bundle/ruby/2.7.0/gems/parallel-1.22.1/lib/parallel/processor_count.rb +0 -44
  598. data/bundle/ruby/2.7.0/gems/parallel-1.22.1/lib/parallel/version.rb +0 -4
  599. data/bundle/ruby/2.7.0/gems/parallel-1.22.1/lib/parallel.rb +0 -612
  600. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/NEWS.md +0 -178
  601. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/README.md +0 -48
  602. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/attribute.rb +0 -205
  603. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/cdata.rb +0 -68
  604. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/child.rb +0 -97
  605. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/comment.rb +0 -80
  606. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/doctype.rb +0 -311
  607. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/document.rb +0 -451
  608. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/element.rb +0 -2599
  609. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/encoding.rb +0 -51
  610. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/entity.rb +0 -171
  611. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/formatters/pretty.rb +0 -142
  612. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/functions.rb +0 -447
  613. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/instruction.rb +0 -79
  614. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/namespace.rb +0 -59
  615. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/node.rb +0 -76
  616. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parseexception.rb +0 -52
  617. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb +0 -694
  618. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/pullparser.rb +0 -197
  619. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/sax2parser.rb +0 -273
  620. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/streamparser.rb +0 -61
  621. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/treeparser.rb +0 -101
  622. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/xpathparser.rb +0 -689
  623. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/quickpath.rb +0 -266
  624. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/rexml.rb +0 -37
  625. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/security.rb +0 -28
  626. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/source.rb +0 -298
  627. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/text.rb +0 -424
  628. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/validation/relaxng.rb +0 -539
  629. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/validation/validation.rb +0 -144
  630. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xpath.rb +0 -81
  631. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xpath_parser.rb +0 -974
  632. data/bundle/ruby/2.7.0/gems/ruby2ruby-2.4.4/History.rdoc +0 -435
  633. data/bundle/ruby/2.7.0/gems/ruby2ruby-2.4.4/lib/ruby2ruby.rb +0 -1309
  634. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/History.rdoc +0 -1297
  635. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/Manifest.txt +0 -46
  636. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/README.rdoc +0 -112
  637. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/compare/normalize.rb +0 -218
  638. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby20_parser.rb +0 -10973
  639. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby20_parser.y +0 -2683
  640. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby21_parser.rb +0 -10980
  641. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby21_parser.y +0 -2700
  642. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby22_parser.rb +0 -11123
  643. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby22_parser.y +0 -2711
  644. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby23_parser.rb +0 -11132
  645. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby23_parser.y +0 -2713
  646. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby24_parser.rb +0 -11231
  647. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby24_parser.y +0 -2721
  648. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby25_parser.rb +0 -11231
  649. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby25_parser.y +0 -2721
  650. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby26_parser.rb +0 -11253
  651. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby26_parser.y +0 -2736
  652. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby27_parser.rb +0 -12980
  653. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby27_parser.y +0 -3324
  654. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby30_parser.rb +0 -13242
  655. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby30_parser.y +0 -3447
  656. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby31_parser.rb +0 -13622
  657. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby31_parser.y +0 -3481
  658. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby3_parser.yy +0 -3536
  659. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_lexer.rb +0 -1144
  660. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_lexer.rex.rb +0 -399
  661. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_lexer_strings.rb +0 -638
  662. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_parser.rb +0 -98
  663. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_parser.yy +0 -3465
  664. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_parser_extras.rb +0 -1865
  665. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/tools/munge.rb +0 -250
  666. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/tools/ripper.rb +0 -44
  667. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/History.rdoc +0 -6
  668. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/Manifest.txt +0 -19
  669. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/README.rdoc +0 -54
  670. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby18_parser.rb +0 -5794
  671. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby18_parser.y +0 -1909
  672. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby19_parser.rb +0 -6186
  673. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby19_parser.y +0 -2117
  674. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rb +0 -1412
  675. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex +0 -179
  676. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex.rb +0 -323
  677. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser.rb +0 -30
  678. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser_extras.rb +0 -1388
  679. data/bundle/ruby/2.7.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy.rb +0 -5
  680. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/CHANGES.md +0 -154
  681. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/Gemfile +0 -11
  682. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/LICENSE.txt +0 -22
  683. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/README.md +0 -191
  684. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/bundle_install_all_ruby_versions.sh +0 -11
  685. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/deep.rb +0 -34
  686. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/libyaml_checker.rb +0 -36
  687. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb +0 -181
  688. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/date.rb +0 -37
  689. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/hexadecimal.rb +0 -12
  690. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/sexagesimal.rb +0 -26
  691. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_handler.rb +0 -99
  692. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_resolver.rb +0 -52
  693. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/resolver.rb +0 -94
  694. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -29
  695. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +0 -39
  696. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_hack.rb +0 -36
  697. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_node_monkeypatch.rb +0 -43
  698. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_resolver.rb +0 -38
  699. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_boolean.rb +0 -21
  700. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_date.rb +0 -13
  701. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_float.rb +0 -33
  702. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_integer.rb +0 -26
  703. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_nil.rb +0 -18
  704. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_symbol.rb +0 -17
  705. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/transformation_map.rb +0 -47
  706. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform.rb +0 -41
  707. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/version.rb +0 -3
  708. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml.rb +0 -94
  709. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/run_specs_all_ruby_versions.sh +0 -38
  710. data/bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/safe_yaml.gemspec +0 -19
  711. data/bundle/ruby/2.7.0/gems/sexp_processor-4.16.0/History.rdoc +0 -448
  712. data/bundle/ruby/2.7.0/gems/sexp_processor-4.16.0/lib/pt_testcase.rb +0 -3133
  713. data/bundle/ruby/2.7.0/gems/sexp_processor-4.16.0/lib/sexp.rb +0 -391
  714. data/bundle/ruby/2.7.0/gems/sexp_processor-4.16.0/lib/sexp_matcher.rb +0 -1100
  715. data/bundle/ruby/2.7.0/gems/sexp_processor-4.16.0/lib/sexp_processor.rb +0 -754
  716. data/bundle/ruby/2.7.0/gems/sexp_processor-4.16.0/lib/strict_sexp.rb +0 -148
  717. data/bundle/ruby/2.7.0/gems/slim-4.1.0/CHANGES +0 -460
  718. data/bundle/ruby/2.7.0/gems/slim-4.1.0/Gemfile +0 -70
  719. data/bundle/ruby/2.7.0/gems/slim-4.1.0/LICENSE +0 -21
  720. data/bundle/ruby/2.7.0/gems/slim-4.1.0/README.jp.md +0 -1289
  721. data/bundle/ruby/2.7.0/gems/slim-4.1.0/README.md +0 -1290
  722. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/code_attributes.rb +0 -67
  723. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/command.rb +0 -128
  724. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/controls.rb +0 -60
  725. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/do_inserter.rb +0 -33
  726. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/embedded.rb +0 -248
  727. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/end_inserter.rb +0 -62
  728. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/engine.rb +0 -39
  729. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/erb_converter.rb +0 -14
  730. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/filter.rb +0 -30
  731. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/grammar.rb +0 -23
  732. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/include.rb +0 -57
  733. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/interpolation.rb +0 -35
  734. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/logic_less/context.rb +0 -127
  735. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/logic_less/filter.rb +0 -80
  736. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/logic_less.rb +0 -5
  737. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/parser.rb +0 -548
  738. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/smart/escaper.rb +0 -42
  739. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/smart/filter.rb +0 -96
  740. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/smart/parser.rb +0 -34
  741. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/smart.rb +0 -8
  742. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/splat/builder.rb +0 -107
  743. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/splat/filter.rb +0 -91
  744. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/template.rb +0 -19
  745. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/translator.rb +0 -118
  746. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim/version.rb +0 -5
  747. data/bundle/ruby/2.7.0/gems/slim-4.1.0/lib/slim.rb +0 -14
  748. data/bundle/ruby/2.7.0/gems/slim-4.1.0/slim.gemspec +0 -24
  749. data/bundle/ruby/2.7.0/gems/temple-0.8.2/CHANGES +0 -260
  750. data/bundle/ruby/2.7.0/gems/temple-0.8.2/Gemfile +0 -3
  751. data/bundle/ruby/2.7.0/gems/temple-0.8.2/README.md +0 -267
  752. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/engine.rb +0 -67
  753. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/erb/engine.rb +0 -15
  754. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/erb/parser.rb +0 -40
  755. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/erb/template.rb +0 -11
  756. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/erb/trimming.rb +0 -23
  757. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/exceptions.rb +0 -13
  758. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filter.rb +0 -9
  759. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/code_merger.rb +0 -30
  760. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/control_flow.rb +0 -42
  761. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/dynamic_inliner.rb +0 -71
  762. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/encoding.rb +0 -24
  763. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb +0 -22
  764. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/escapable.rb +0 -40
  765. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/multi_flattener.rb +0 -25
  766. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/remove_bom.rb +0 -13
  767. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_analyzer.rb +0 -30
  768. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb +0 -37
  769. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/string_splitter.rb +0 -130
  770. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/validator.rb +0 -15
  771. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/generator.rb +0 -88
  772. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/generators/array.rb +0 -21
  773. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/generators/array_buffer.rb +0 -29
  774. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/generators/erb.rb +0 -32
  775. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/generators/rails_output_buffer.rb +0 -35
  776. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/generators/string_buffer.rb +0 -25
  777. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/grammar.rb +0 -57
  778. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/html/attribute_merger.rb +0 -42
  779. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/html/attribute_remover.rb +0 -35
  780. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/html/attribute_sorter.rb +0 -21
  781. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/html/dispatcher.rb +0 -31
  782. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/html/fast.rb +0 -130
  783. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/html/filter.rb +0 -21
  784. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/html/pretty.rb +0 -103
  785. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/html/safe.rb +0 -23
  786. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/map.rb +0 -105
  787. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/mixins/dispatcher.rb +0 -161
  788. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/mixins/engine_dsl.rb +0 -145
  789. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/mixins/grammar_dsl.rb +0 -170
  790. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/mixins/options.rb +0 -87
  791. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/mixins/template.rb +0 -28
  792. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/parser.rb +0 -8
  793. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/static_analyzer.rb +0 -77
  794. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/rails.rb +0 -26
  795. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb +0 -46
  796. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates.rb +0 -11
  797. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/utils.rb +0 -101
  798. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/version.rb +0 -3
  799. data/bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple.rb +0 -67
  800. data/bundle/ruby/2.7.0/gems/temple-0.8.2/temple.gemspec +0 -29
  801. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/History.rdoc +0 -85
  802. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/README.rdoc +0 -247
  803. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/lib/terminal-table/cell.rb +0 -94
  804. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/lib/terminal-table/row.rb +0 -52
  805. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/lib/terminal-table/separator.rb +0 -14
  806. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/lib/terminal-table/style.rb +0 -79
  807. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/lib/terminal-table/table.rb +0 -343
  808. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/lib/terminal-table/version.rb +0 -5
  809. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/lib/terminal-table.rb +0 -26
  810. data/bundle/ruby/2.7.0/gems/terminal-table-1.8.0/terminal-table.gemspec +0 -26
  811. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/COPYING +0 -18
  812. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/asciidoc.rb +0 -27
  813. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/babel.rb +0 -16
  814. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/bluecloth.rb +0 -24
  815. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/builder.rb +0 -37
  816. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/coffee.rb +0 -58
  817. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/commonmarker.rb +0 -78
  818. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/creole.rb +0 -25
  819. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/csv.rb +0 -65
  820. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/dummy.rb +0 -3
  821. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/erb.rb +0 -63
  822. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/erubi.rb +0 -32
  823. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/erubis.rb +0 -43
  824. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/etanni.rb +0 -27
  825. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/haml.rb +0 -86
  826. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/kramdown.rb +0 -25
  827. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/less.rb +0 -30
  828. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/liquid.rb +0 -44
  829. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/livescript.rb +0 -23
  830. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/mapping.rb +0 -293
  831. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/markaby.rb +0 -45
  832. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/maruku.rb +0 -22
  833. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/nokogiri.rb +0 -36
  834. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/pandoc.rb +0 -49
  835. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/plain.rb +0 -16
  836. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/prawn.rb +0 -43
  837. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/radius.rb +0 -48
  838. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/rdiscount.rb +0 -39
  839. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/rdoc.rb +0 -40
  840. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/redcarpet.rb +0 -83
  841. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/redcloth.rb +0 -23
  842. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/rst-pandoc.rb +0 -18
  843. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/sass.rb +0 -52
  844. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/sigil.rb +0 -34
  845. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/string.rb +0 -21
  846. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/template.rb +0 -297
  847. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/typescript.rb +0 -26
  848. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/wikicloth.rb +0 -22
  849. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/yajl.rb +0 -87
  850. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt.rb +0 -166
  851. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/CHANGELOG.md +0 -137
  852. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/MIT-LICENSE.txt +0 -22
  853. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/README.md +0 -124
  854. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
  855. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/constants.rb +0 -8
  856. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/index.rb +0 -12
  857. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/no_string_ext.rb +0 -7
  858. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/string_ext.rb +0 -17
  859. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width.rb +0 -51
  860. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/CHANGES.txt +0 -0
  861. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/MIT-LICENSE +0 -0
  862. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/README.txt +0 -0
  863. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/contrib/erubis +0 -0
  864. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/contrib/erubis-run.rb +0 -0
  865. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/contrib/inline-require +0 -0
  866. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/context.rb +0 -0
  867. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/converter.rb +0 -0
  868. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ec.rb +0 -0
  869. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ecpp.rb +0 -0
  870. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ejava.rb +0 -0
  871. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ejavascript.rb +0 -0
  872. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/enhanced.rb +0 -0
  873. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/eperl.rb +0 -0
  874. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb +0 -0
  875. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/eruby.rb +0 -0
  876. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/escheme.rb +0 -0
  877. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/optimized.rb +0 -0
  878. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine.rb +0 -0
  879. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/enhancer.rb +0 -0
  880. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/error.rb +0 -0
  881. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/evaluator.rb +0 -0
  882. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/generator.rb +0 -0
  883. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/helper.rb +0 -0
  884. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb +0 -0
  885. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/helpers/rails_helper.rb +0 -0
  886. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/local-setting.rb +0 -0
  887. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/main.rb +0 -0
  888. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/preprocessing.rb +0 -0
  889. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/tiny.rb +0 -0
  890. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/util.rb +0 -0
  891. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis.rb +0 -0
  892. /data/bundle/ruby/{2.7.0 → 3.1.0}/gems/erubis-2.7.0/setup.rb +0 -0
  893. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/AUTHORS +0 -0
  894. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/COPYING +0 -0
  895. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/LICENSE +0 -0
  896. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/TODO +0 -0
  897. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/builtin_styles.rb +0 -0
  898. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/color_scheme.rb +0 -0
  899. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/compatibility.rb +0 -0
  900. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/custom_errors.rb +0 -0
  901. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/import.rb +0 -0
  902. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/list.rb +0 -0
  903. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/menu/item.rb +0 -0
  904. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/paginator.rb +0 -0
  905. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/simulate.rb +0 -0
  906. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/statement.rb +0 -0
  907. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/string.rb +0 -0
  908. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/string_extensions.rb +0 -0
  909. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/template_renderer.rb +0 -0
  910. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/terminal/ncurses.rb +0 -0
  911. /data/bundle/ruby/{2.7.0/gems/highline-2.0.3 → 3.1.0/gems/highline-3.1.2}/lib/highline/wrapper.rb +0 -0
  912. /data/bundle/ruby/{2.7.0/gems/parallel-1.22.1 → 3.1.0/gems/parallel-1.27.0}/MIT-LICENSE.txt +0 -0
  913. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5/LICENSE.txt → 3.1.0/gems/reline-0.6.2/BSDL} +0 -0
  914. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/attlistdecl.rb +0 -0
  915. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/dtd/attlistdecl.rb +0 -0
  916. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/dtd/dtd.rb +0 -0
  917. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/dtd/elementdecl.rb +0 -0
  918. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/dtd/entitydecl.rb +0 -0
  919. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/dtd/notationdecl.rb +0 -0
  920. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/formatters/default.rb +0 -0
  921. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/formatters/transitive.rb +0 -0
  922. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/light/node.rb +0 -0
  923. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/output.rb +0 -0
  924. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/parent.rb +0 -0
  925. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/parsers/lightparser.rb +0 -0
  926. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/parsers/ultralightparser.rb +0 -0
  927. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/sax2listener.rb +0 -0
  928. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/streamlistener.rb +0 -0
  929. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/undefinednamespaceexception.rb +0 -0
  930. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/validation/validationexception.rb +0 -0
  931. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/xmldecl.rb +0 -0
  932. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml/xmltokens.rb +0 -0
  933. /data/bundle/ruby/{2.7.0/gems/rexml-3.2.5 → 3.1.0/gems/rexml-3.4.4}/lib/rexml.rb +0 -0
  934. /data/bundle/ruby/{2.7.0/gems/ruby2ruby-2.4.4 → 3.1.0/gems/ruby2ruby-2.5.2}/Manifest.txt +0 -0
  935. /data/bundle/ruby/{2.7.0/gems/ruby2ruby-2.4.4 → 3.1.0/gems/ruby2ruby-2.5.2}/README.rdoc +0 -0
  936. /data/bundle/ruby/{2.7.0/gems/ruby_parser-3.19.1 → 3.1.0/gems/ruby_parser-3.20.3}/debugging.md +0 -0
  937. /data/bundle/ruby/{2.7.0/gems/ruby_parser-3.19.1 → 3.1.0/gems/ruby_parser-3.20.3}/gauntlet.md +0 -0
  938. /data/bundle/ruby/{2.7.0/gems/ruby_parser-3.19.1 → 3.1.0/gems/ruby_parser-3.20.3}/lib/rp_extensions.rb +0 -0
  939. /data/bundle/ruby/{2.7.0/gems/ruby_parser-3.19.1 → 3.1.0/gems/ruby_parser-3.20.3}/lib/rp_stringscanner.rb +0 -0
  940. /data/bundle/ruby/{2.7.0/gems/ruby_parser-3.19.1 → 3.1.0/gems/ruby_parser-3.20.3}/lib/ruby_lexer.rex +0 -0
  941. /data/bundle/ruby/{2.7.0/gems/sexp_processor-4.16.0 → 3.1.0/gems/sexp_processor-4.17.4}/Manifest.txt +0 -0
  942. /data/bundle/ruby/{2.7.0/gems/sexp_processor-4.16.0 → 3.1.0/gems/sexp_processor-4.17.4}/README.rdoc +0 -0
  943. /data/bundle/ruby/{2.7.0/gems/sexp_processor-4.16.0 → 3.1.0/gems/sexp_processor-4.17.4}/lib/composite_sexp_processor.rb +0 -0
  944. /data/bundle/ruby/{2.7.0/gems/sexp_processor-4.16.0 → 3.1.0/gems/sexp_processor-4.17.4}/lib/unique.rb +0 -0
  945. /data/bundle/ruby/{2.7.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.4}/EXPRESSIONS.md +0 -0
  946. /data/bundle/ruby/{2.7.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.4}/LICENSE +0 -0
  947. /data/bundle/ruby/{2.7.0/gems/terminal-table-1.8.0 → 3.1.0/gems/terminal-table-4.0.0}/Gemfile +0 -0
  948. /data/bundle/ruby/{2.7.0/gems/terminal-table-1.8.0 → 3.1.0/gems/terminal-table-4.0.0}/LICENSE.txt +0 -0
  949. /data/bundle/ruby/{2.7.0/gems/terminal-table-1.8.0 → 3.1.0/gems/terminal-table-4.0.0}/Manifest +0 -0
  950. /data/bundle/ruby/{2.7.0/gems/terminal-table-1.8.0 → 3.1.0/gems/terminal-table-4.0.0}/Todo.rdoc +0 -0
  951. /data/bundle/ruby/{2.7.0/gems/terminal-table-1.8.0 → 3.1.0/gems/terminal-table-4.0.0}/lib/terminal-table/import.rb +0 -0
  952. /data/bundle/ruby/{2.7.0/gems/terminal-table-1.8.0 → 3.1.0/gems/terminal-table-4.0.0}/lib/terminal-table/table_helper.rb +0 -0
@@ -0,0 +1,2578 @@
1
+ # frozen_string_literal: false
2
+ require_relative "parent"
3
+ require_relative "namespace"
4
+ require_relative "attribute"
5
+ require_relative "cdata"
6
+ require_relative "xpath"
7
+ require_relative "parseexception"
8
+
9
+ module REXML
10
+ # An \REXML::Element object represents an XML element.
11
+ #
12
+ # An element:
13
+ #
14
+ # - Has a name (string).
15
+ # - May have a parent (another element).
16
+ # - Has zero or more children
17
+ # (other elements, text, CDATA, processing instructions, and comments).
18
+ # - Has zero or more siblings
19
+ # (other elements, text, CDATA, processing instructions, and comments).
20
+ # - Has zero or more named attributes.
21
+ #
22
+ # == In a Hurry?
23
+ #
24
+ # If you're somewhat familiar with XML
25
+ # and have a particular task in mind,
26
+ # you may want to see the
27
+ # {tasks pages}[../doc/rexml/tasks/tocs/master_toc_rdoc.html],
28
+ # and in particular, the
29
+ # {tasks page for elements}[../doc/rexml/tasks/tocs/element_toc_rdoc.html].
30
+ #
31
+ # === Name
32
+ #
33
+ # An element has a name, which is initially set when the element is created:
34
+ #
35
+ # e = REXML::Element.new('foo')
36
+ # e.name # => "foo"
37
+ #
38
+ # The name may be changed:
39
+ #
40
+ # e.name = 'bar'
41
+ # e.name # => "bar"
42
+ #
43
+ #
44
+ # === \Parent
45
+ #
46
+ # An element may have a parent.
47
+ #
48
+ # Its parent may be assigned explicitly when the element is created:
49
+ #
50
+ # e0 = REXML::Element.new('foo')
51
+ # e1 = REXML::Element.new('bar', e0)
52
+ # e1.parent # => <foo> ... </>
53
+ #
54
+ # Note: the representation of an element always shows the element's name.
55
+ # If the element has children, the representation indicates that
56
+ # by including an ellipsis (<tt>...</tt>).
57
+ #
58
+ # The parent may be assigned explicitly at any time:
59
+ #
60
+ # e2 = REXML::Element.new('baz')
61
+ # e1.parent = e2
62
+ # e1.parent # => <baz/>
63
+ #
64
+ # When an element is added as a child, its parent is set automatically:
65
+ #
66
+ # e1.add_element(e0)
67
+ # e0.parent # => <bar> ... </>
68
+ #
69
+ # For an element that has no parent, method +parent+ returns +nil+.
70
+ #
71
+ # === Children
72
+ #
73
+ # An element has zero or more children.
74
+ # The children are an ordered collection
75
+ # of all objects whose parent is the element itself.
76
+ #
77
+ # The children may include any combination of elements, text, comments,
78
+ # processing instructions, and CDATA.
79
+ # (This example keeps things clean by controlling whitespace
80
+ # via a +context+ setting.)
81
+ #
82
+ # xml_string = <<-EOT
83
+ # <root>
84
+ # <ele_0/>
85
+ # text 0
86
+ # <!--comment 0-->
87
+ # <?target_0 pi_0?>
88
+ # <![CDATA[cdata 0]]>
89
+ # <ele_1/>
90
+ # text 1
91
+ # <!--comment 1-->
92
+ # <?target_0 pi_1?>
93
+ # <![CDATA[cdata 1]]>
94
+ # </root>
95
+ # EOT
96
+ # context = {ignore_whitespace_nodes: :all, compress_whitespace: :all}
97
+ # d = REXML::Document.new(xml_string, context)
98
+ # root = d.root
99
+ # root.children.size # => 10
100
+ # root.each {|child| p "#{child.class}: #{child}" }
101
+ #
102
+ # Output:
103
+ #
104
+ # "REXML::Element: <ele_0/>"
105
+ # "REXML::Text: \n text 0\n "
106
+ # "REXML::Comment: comment 0"
107
+ # "REXML::Instruction: <?target_0 pi_0?>"
108
+ # "REXML::CData: cdata 0"
109
+ # "REXML::Element: <ele_1/>"
110
+ # "REXML::Text: \n text 1\n "
111
+ # "REXML::Comment: comment 1"
112
+ # "REXML::Instruction: <?target_0 pi_1?>"
113
+ # "REXML::CData: cdata 1"
114
+ #
115
+ # A child may be added using inherited methods
116
+ # Parent#insert_before or Parent#insert_after:
117
+ #
118
+ # xml_string = '<root><a/><c/><d/></root>'
119
+ # d = REXML::Document.new(xml_string)
120
+ # root = d.root
121
+ # c = d.root[1] # => <c/>
122
+ # root.insert_before(c, REXML::Element.new('b'))
123
+ # root.to_a # => [<a/>, <b/>, <c/>, <d/>]
124
+ #
125
+ # A child may be replaced using Parent#replace_child:
126
+ #
127
+ # root.replace_child(c, REXML::Element.new('x'))
128
+ # root.to_a # => [<a/>, <b/>, <x/>, <d/>]
129
+ #
130
+ # A child may be removed using Parent#delete:
131
+ #
132
+ # x = root[2] # => <x/>
133
+ # root.delete(x)
134
+ # root.to_a # => [<a/>, <b/>, <d/>]
135
+ #
136
+ # === Siblings
137
+ #
138
+ # An element has zero or more siblings,
139
+ # which are the other children of the element's parent.
140
+ #
141
+ # In the example above, element +ele_1+ is between a CDATA sibling
142
+ # and a text sibling:
143
+ #
144
+ # ele_1 = root[5] # => <ele_1/>
145
+ # ele_1.previous_sibling # => "cdata 0"
146
+ # ele_1.next_sibling # => "\n text 1\n "
147
+ #
148
+ # === \Attributes
149
+ #
150
+ # An element has zero or more named attributes.
151
+ #
152
+ # A new element has no attributes:
153
+ #
154
+ # e = REXML::Element.new('foo')
155
+ # e.attributes # => {}
156
+ #
157
+ # Attributes may be added:
158
+ #
159
+ # e.add_attribute('bar', 'baz')
160
+ # e.add_attribute('bat', 'bam')
161
+ # e.attributes.size # => 2
162
+ # e['bar'] # => "baz"
163
+ # e['bat'] # => "bam"
164
+ #
165
+ # An existing attribute may be modified:
166
+ #
167
+ # e.add_attribute('bar', 'bad')
168
+ # e.attributes.size # => 2
169
+ # e['bar'] # => "bad"
170
+ #
171
+ # An existing attribute may be deleted:
172
+ #
173
+ # e.delete_attribute('bar')
174
+ # e.attributes.size # => 1
175
+ # e['bar'] # => nil
176
+ #
177
+ # == What's Here
178
+ #
179
+ # To begin with, what's elsewhere?
180
+ #
181
+ # \Class \REXML::Element inherits from its ancestor classes:
182
+ #
183
+ # - REXML::Child
184
+ # - REXML::Parent
185
+ #
186
+ # \REXML::Element itself and its ancestors also include modules:
187
+ #
188
+ # - {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html]
189
+ # - REXML::Namespace
190
+ # - REXML::Node
191
+ # - REXML::XMLTokens
192
+ #
193
+ # === Methods for Creating an \Element
194
+ #
195
+ # ::new:: Returns a new empty element.
196
+ # #clone:: Returns a clone of another element.
197
+ #
198
+ # === Methods for Attributes
199
+ #
200
+ # {[attribute_name]}[#method-i-5B-5D]:: Returns an attribute value.
201
+ # #add_attribute:: Adds a new attribute.
202
+ # #add_attributes:: Adds multiple new attributes.
203
+ # #attribute:: Returns the attribute value for a given name and optional namespace.
204
+ # #delete_attribute:: Removes an attribute.
205
+ #
206
+ # === Methods for Children
207
+ #
208
+ # {[index]}[#method-i-5B-5D]:: Returns the child at the given offset.
209
+ # #add_element:: Adds an element as the last child.
210
+ # #delete_element:: Deletes a child element.
211
+ # #each_element:: Calls the given block with each child element.
212
+ # #each_element_with_attribute:: Calls the given block with each child element
213
+ # that meets given criteria,
214
+ # which can include the attribute name.
215
+ # #each_element_with_text:: Calls the given block with each child element
216
+ # that meets given criteria,
217
+ # which can include text.
218
+ # #get_elements:: Returns an array of element children that match a given xpath.
219
+ #
220
+ # === Methods for \Text Children
221
+ #
222
+ # #add_text:: Adds a text node to the element.
223
+ # #get_text:: Returns a text node that meets specified criteria.
224
+ # #text:: Returns the text string from the first node that meets specified criteria.
225
+ # #texts:: Returns an array of the text children of the element.
226
+ # #text=:: Adds, removes, or replaces the first text child of the element
227
+ #
228
+ # === Methods for Other Children
229
+ #
230
+ # #cdatas:: Returns an array of the cdata children of the element.
231
+ # #comments:: Returns an array of the comment children of the element.
232
+ # #instructions:: Returns an array of the instruction children of the element.
233
+ #
234
+ # === Methods for Namespaces
235
+ #
236
+ # #add_namespace:: Adds a namespace to the element.
237
+ # #delete_namespace:: Removes a namespace from the element.
238
+ # #namespace:: Returns the string namespace URI for the element.
239
+ # #namespaces:: Returns a hash of all defined namespaces in the element.
240
+ # #prefixes:: Returns an array of the string prefixes (names)
241
+ # of all defined namespaces in the element
242
+ #
243
+ # === Methods for Querying
244
+ #
245
+ # #document:: Returns the document, if any, that the element belongs to.
246
+ # #root:: Returns the most distant element (not document) ancestor of the element.
247
+ # #root_node:: Returns the most distant ancestor of the element.
248
+ # #xpath:: Returns the string xpath to the element
249
+ # relative to the most distant parent
250
+ # #has_attributes?:: Returns whether the element has attributes.
251
+ # #has_elements?:: Returns whether the element has elements.
252
+ # #has_text?:: Returns whether the element has text.
253
+ # #next_element:: Returns the next sibling that is an element.
254
+ # #previous_element:: Returns the previous sibling that is an element.
255
+ # #raw:: Returns whether raw mode is set for the element.
256
+ # #whitespace:: Returns whether whitespace is respected for the element.
257
+ # #ignore_whitespace_nodes:: Returns whether whitespace nodes
258
+ # are to be ignored for the element.
259
+ # #node_type:: Returns symbol <tt>:element</tt>.
260
+ #
261
+ # === One More Method
262
+ #
263
+ # #inspect:: Returns a string representation of the element.
264
+ #
265
+ # === Accessors
266
+ #
267
+ # #elements:: Returns the REXML::Elements object for the element.
268
+ # #attributes:: Returns the REXML::Attributes object for the element.
269
+ # #context:: Returns or sets the context hash for the element.
270
+ #
271
+ class Element < Parent
272
+ include Namespace
273
+
274
+ UNDEFINED = "UNDEFINED"; # The default name
275
+
276
+ # Mechanisms for accessing attributes and child elements of this
277
+ # element.
278
+ attr_reader :attributes, :elements
279
+ # The context holds information about the processing environment, such as
280
+ # whitespace handling.
281
+ attr_accessor :context
282
+
283
+ # :call-seq:
284
+ # Element.new(name = 'UNDEFINED', parent = nil, context = nil) -> new_element
285
+ # Element.new(element, parent = nil, context = nil) -> new_element
286
+ #
287
+ # Returns a new \REXML::Element object.
288
+ #
289
+ # When no arguments are given,
290
+ # returns an element with name <tt>'UNDEFINED'</tt>:
291
+ #
292
+ # e = REXML::Element.new # => <UNDEFINED/>
293
+ # e.class # => REXML::Element
294
+ # e.name # => "UNDEFINED"
295
+ #
296
+ # When only argument +name+ is given,
297
+ # returns an element of the given name:
298
+ #
299
+ # REXML::Element.new('foo') # => <foo/>
300
+ #
301
+ # When only argument +element+ is given, it must be an \REXML::Element object;
302
+ # returns a shallow copy of the given element:
303
+ #
304
+ # e0 = REXML::Element.new('foo')
305
+ # e1 = REXML::Element.new(e0) # => <foo/>
306
+ #
307
+ # When argument +parent+ is also given, it must be an REXML::Parent object:
308
+ #
309
+ # e = REXML::Element.new('foo', REXML::Parent.new)
310
+ # e.parent # => #<REXML::Parent @parent=nil, @children=[<foo/>]>
311
+ #
312
+ # When argument +context+ is also given, it must be a hash
313
+ # representing the context for the element;
314
+ # see {Element Context}[../doc/rexml/context_rdoc.html]:
315
+ #
316
+ # e = REXML::Element.new('foo', nil, {raw: :all})
317
+ # e.context # => {:raw=>:all}
318
+ #
319
+ def initialize( arg = UNDEFINED, parent=nil, context=nil )
320
+ super(parent)
321
+
322
+ @elements = Elements.new(self)
323
+ @attributes = Attributes.new(self)
324
+ @context = context
325
+
326
+ if arg.kind_of? String
327
+ self.name = arg
328
+ elsif arg.kind_of? Element
329
+ self.name = arg.expanded_name
330
+ arg.attributes.each_attribute{ |attribute|
331
+ @attributes << Attribute.new( attribute )
332
+ }
333
+ @context = arg.context
334
+ end
335
+ end
336
+
337
+ # :call-seq:
338
+ # inspect -> string
339
+ #
340
+ # Returns a string representation of the element.
341
+ #
342
+ # For an element with no attributes and no children, shows the element name:
343
+ #
344
+ # REXML::Element.new.inspect # => "<UNDEFINED/>"
345
+ #
346
+ # Shows attributes, if any:
347
+ #
348
+ # e = REXML::Element.new('foo')
349
+ # e.add_attributes({'bar' => 0, 'baz' => 1})
350
+ # e.inspect # => "<foo bar='0' baz='1'/>"
351
+ #
352
+ # Shows an ellipsis (<tt>...</tt>), if there are child elements:
353
+ #
354
+ # e.add_element(REXML::Element.new('bar'))
355
+ # e.add_element(REXML::Element.new('baz'))
356
+ # e.inspect # => "<foo bar='0' baz='1'> ... </>"
357
+ #
358
+ def inspect
359
+ rv = "<#@expanded_name"
360
+
361
+ @attributes.each_attribute do |attr|
362
+ rv << " "
363
+ attr.write( rv, 0 )
364
+ end
365
+
366
+ if children.size > 0
367
+ rv << "> ... </>"
368
+ else
369
+ rv << "/>"
370
+ end
371
+ end
372
+
373
+ # :call-seq:
374
+ # clone -> new_element
375
+ #
376
+ # Returns a shallow copy of the element, containing the name and attributes,
377
+ # but not the parent or children:
378
+ #
379
+ # e = REXML::Element.new('foo')
380
+ # e.add_attributes({'bar' => 0, 'baz' => 1})
381
+ # e.clone # => <foo bar='0' baz='1'/>
382
+ #
383
+ def clone
384
+ self.class.new self
385
+ end
386
+
387
+ # :call-seq:
388
+ # root_node -> document or element
389
+ #
390
+ # Returns the most distant ancestor of +self+.
391
+ #
392
+ # When the element is part of a document,
393
+ # returns the root node of the document.
394
+ # Note that the root node is different from the document element;
395
+ # in this example +a+ is document element and the root node is its parent:
396
+ #
397
+ # d = REXML::Document.new('<a><b><c/></b></a>')
398
+ # top_element = d.first # => <a> ... </>
399
+ # child = top_element.first # => <b> ... </>
400
+ # d.root_node == d # => true
401
+ # top_element.root_node == d # => true
402
+ # child.root_node == d # => true
403
+ #
404
+ # When the element is not part of a document, but does have ancestor elements,
405
+ # returns the most distant ancestor element:
406
+ #
407
+ # e0 = REXML::Element.new('foo')
408
+ # e1 = REXML::Element.new('bar')
409
+ # e1.parent = e0
410
+ # e2 = REXML::Element.new('baz')
411
+ # e2.parent = e1
412
+ # e2.root_node == e0 # => true
413
+ #
414
+ # When the element has no ancestor elements,
415
+ # returns +self+:
416
+ #
417
+ # e = REXML::Element.new('foo')
418
+ # e.root_node == e # => true
419
+ #
420
+ # Related: #root, #document.
421
+ #
422
+ def root_node
423
+ parent.nil? ? self : parent.root_node
424
+ end
425
+
426
+ # :call-seq:
427
+ # root -> element
428
+ #
429
+ # Returns the most distant _element_ (not document) ancestor of the element:
430
+ #
431
+ # d = REXML::Document.new('<a><b><c/></b></a>')
432
+ # top_element = d.first
433
+ # child = top_element.first
434
+ # top_element.root == top_element # => true
435
+ # child.root == top_element # => true
436
+ #
437
+ # For a document, returns the topmost element:
438
+ #
439
+ # d.root == top_element # => true
440
+ #
441
+ # Related: #root_node, #document.
442
+ #
443
+ def root
444
+ target = self
445
+ while target
446
+ return target.elements[1] if target.kind_of? Document
447
+ parent = target.parent
448
+ return target if parent.kind_of? Document or parent.nil?
449
+ target = parent
450
+ end
451
+ nil
452
+ end
453
+
454
+ # :call-seq:
455
+ # document -> document or nil
456
+ #
457
+ # If the element is part of a document, returns that document:
458
+ #
459
+ # d = REXML::Document.new('<a><b><c/></b></a>')
460
+ # top_element = d.first
461
+ # child = top_element.first
462
+ # top_element.document == d # => true
463
+ # child.document == d # => true
464
+ #
465
+ # If the element is not part of a document, returns +nil+:
466
+ #
467
+ # REXML::Element.new.document # => nil
468
+ #
469
+ # For a document, returns +self+:
470
+ #
471
+ # d.document == d # => true
472
+ #
473
+ # Related: #root, #root_node.
474
+ #
475
+ def document
476
+ root&.parent
477
+ end
478
+
479
+ # :call-seq:
480
+ # whitespace
481
+ #
482
+ # Returns +true+ if whitespace is respected for this element,
483
+ # +false+ otherwise.
484
+ #
485
+ # See {Element Context}[../doc/rexml/context_rdoc.html].
486
+ #
487
+ # The evaluation is tested against the element's +expanded_name+,
488
+ # and so is namespace-sensitive.
489
+ def whitespace
490
+ @whitespace = nil
491
+ if @context
492
+ if @context[:respect_whitespace]
493
+ @whitespace = (@context[:respect_whitespace] == :all or
494
+ @context[:respect_whitespace].include? expanded_name)
495
+ end
496
+ @whitespace = false if (@context[:compress_whitespace] and
497
+ (@context[:compress_whitespace] == :all or
498
+ @context[:compress_whitespace].include? expanded_name)
499
+ )
500
+ end
501
+ @whitespace = true unless @whitespace == false
502
+ @whitespace
503
+ end
504
+
505
+ # :call-seq:
506
+ # ignore_whitespace_nodes
507
+ #
508
+ # Returns +true+ if whitespace nodes are ignored for the element.
509
+ #
510
+ # See {Element Context}[../doc/rexml/context_rdoc.html].
511
+ #
512
+ def ignore_whitespace_nodes
513
+ @ignore_whitespace_nodes = false
514
+ if @context
515
+ if @context[:ignore_whitespace_nodes]
516
+ @ignore_whitespace_nodes =
517
+ (@context[:ignore_whitespace_nodes] == :all or
518
+ @context[:ignore_whitespace_nodes].include? expanded_name)
519
+ end
520
+ end
521
+ end
522
+
523
+ # :call-seq:
524
+ # raw
525
+ #
526
+ # Returns +true+ if raw mode is set for the element.
527
+ #
528
+ # See {Element Context}[../doc/rexml/context_rdoc.html].
529
+ #
530
+ # The evaluation is tested against +expanded_name+, and so is namespace
531
+ # sensitive.
532
+ def raw
533
+ @raw = (@context and @context[:raw] and
534
+ (@context[:raw] == :all or
535
+ @context[:raw].include? expanded_name))
536
+ @raw
537
+ end
538
+
539
+ #once :whitespace, :raw, :ignore_whitespace_nodes
540
+
541
+ #################################################
542
+ # Namespaces #
543
+ #################################################
544
+
545
+ # :call-seq:
546
+ # prefixes -> array_of_namespace_prefixes
547
+ #
548
+ # Returns an array of the string prefixes (names) of all defined namespaces
549
+ # in the element and its ancestors:
550
+ #
551
+ # xml_string = <<-EOT
552
+ # <root>
553
+ # <a xmlns:x='1' xmlns:y='2'>
554
+ # <b/>
555
+ # <c xmlns:z='3'/>
556
+ # </a>
557
+ # </root>
558
+ # EOT
559
+ # d = REXML::Document.new(xml_string, {compress_whitespace: :all})
560
+ # d.elements['//a'].prefixes # => ["x", "y"]
561
+ # d.elements['//b'].prefixes # => ["x", "y"]
562
+ # d.elements['//c'].prefixes # => ["x", "y", "z"]
563
+ #
564
+ def prefixes
565
+ prefixes = []
566
+ prefixes = parent.prefixes if parent
567
+ prefixes |= attributes.prefixes
568
+ prefixes
569
+ end
570
+
571
+ # :call-seq:
572
+ # namespaces -> array_of_namespace_names
573
+ #
574
+ # Returns a hash of all defined namespaces
575
+ # in the element and its ancestors:
576
+ #
577
+ # xml_string = <<-EOT
578
+ # <root>
579
+ # <a xmlns:x='1' xmlns:y='2'>
580
+ # <b/>
581
+ # <c xmlns:z='3'/>
582
+ # </a>
583
+ # </root>
584
+ # EOT
585
+ # d = REXML::Document.new(xml_string)
586
+ # d.elements['//a'].namespaces # => {"x"=>"1", "y"=>"2"}
587
+ # d.elements['//b'].namespaces # => {"x"=>"1", "y"=>"2"}
588
+ # d.elements['//c'].namespaces # => {"x"=>"1", "y"=>"2", "z"=>"3"}
589
+ #
590
+ def namespaces
591
+ namespaces_cache = document&.__send__(:namespaces_cache)
592
+ if namespaces_cache
593
+ namespaces_cache[self] ||= calculate_namespaces
594
+ else
595
+ calculate_namespaces
596
+ end
597
+ end
598
+
599
+ # :call-seq:
600
+ # namespace(prefix = nil) -> string_uri or nil
601
+ #
602
+ # Returns the string namespace URI for the element,
603
+ # possibly deriving from one of its ancestors.
604
+ #
605
+ # xml_string = <<-EOT
606
+ # <root>
607
+ # <a xmlns='1' xmlns:y='2'>
608
+ # <b/>
609
+ # <c xmlns:z='3'/>
610
+ # </a>
611
+ # </root>
612
+ # EOT
613
+ # d = REXML::Document.new(xml_string)
614
+ # b = d.elements['//b']
615
+ # b.namespace # => "1"
616
+ # b.namespace('y') # => "2"
617
+ # b.namespace('nosuch') # => nil
618
+ #
619
+ def namespace(prefix=nil)
620
+ if prefix.nil?
621
+ prefix = prefix()
622
+ end
623
+ prefix = (prefix == '') ? 'xmlns' : prefix.delete_prefix("xmlns:")
624
+ ns = namespaces[prefix]
625
+
626
+ ns = '' if ns.nil? and prefix == 'xmlns'
627
+ ns
628
+ end
629
+
630
+ # :call-seq:
631
+ # add_namespace(prefix, uri = nil) -> self
632
+ #
633
+ # Adds a namespace to the element; returns +self+.
634
+ #
635
+ # With the single argument +prefix+,
636
+ # adds a namespace using the given +prefix+ and the namespace URI:
637
+ #
638
+ # e = REXML::Element.new('foo')
639
+ # e.add_namespace('bar')
640
+ # e.namespaces # => {"xmlns"=>"bar"}
641
+ #
642
+ # With both arguments +prefix+ and +uri+ given,
643
+ # adds a namespace using both arguments:
644
+ #
645
+ # e.add_namespace('baz', 'bat')
646
+ # e.namespaces # => {"xmlns"=>"bar", "baz"=>"bat"}
647
+ #
648
+ def add_namespace( prefix, uri=nil )
649
+ unless uri
650
+ @attributes["xmlns"] = prefix
651
+ else
652
+ prefix = "xmlns:#{prefix}" unless prefix =~ /^xmlns:/
653
+ @attributes[ prefix ] = uri
654
+ end
655
+ self
656
+ end
657
+
658
+ # :call-seq:
659
+ # delete_namespace(namespace = 'xmlns') -> self
660
+ #
661
+ # Removes a namespace from the element.
662
+ #
663
+ # With no argument, removes the default namespace:
664
+ #
665
+ # d = REXML::Document.new "<a xmlns:foo='bar' xmlns='twiddle'/>"
666
+ # d.to_s # => "<a xmlns:foo='bar' xmlns='twiddle'/>"
667
+ # d.root.delete_namespace # => <a xmlns:foo='bar'/>
668
+ # d.to_s # => "<a xmlns:foo='bar'/>"
669
+ #
670
+ # With argument +namespace+, removes the specified namespace:
671
+ #
672
+ # d.root.delete_namespace('foo')
673
+ # d.to_s # => "<a/>"
674
+ #
675
+ # Does nothing if no such namespace is found:
676
+ #
677
+ # d.root.delete_namespace('nosuch')
678
+ # d.to_s # => "<a/>"
679
+ #
680
+ def delete_namespace namespace="xmlns"
681
+ namespace = "xmlns:#{namespace}" unless namespace == 'xmlns'
682
+ attribute = attributes.get_attribute(namespace)
683
+ attribute.remove unless attribute.nil?
684
+ self
685
+ end
686
+
687
+ #################################################
688
+ # Elements #
689
+ #################################################
690
+
691
+ # :call-seq:
692
+ # add_element(name, attributes = nil) -> new_element
693
+ # add_element(element, attributes = nil) -> element
694
+ #
695
+ # Adds a child element, optionally setting attributes
696
+ # on the added element; returns the added element.
697
+ #
698
+ # With string argument +name+, creates a new element with that name
699
+ # and adds the new element as a child:
700
+ #
701
+ # e0 = REXML::Element.new('foo')
702
+ # e0.add_element('bar')
703
+ # e0[0] # => <bar/>
704
+ #
705
+ #
706
+ # With argument +name+ and hash argument +attributes+,
707
+ # sets attributes on the new element:
708
+ #
709
+ # e0.add_element('baz', {'bat' => '0', 'bam' => '1'})
710
+ # e0[1] # => <baz bat='0' bam='1'/>
711
+ #
712
+ # With element argument +element+, adds that element as a child:
713
+ #
714
+ # e0 = REXML::Element.new('foo')
715
+ # e1 = REXML::Element.new('bar')
716
+ # e0.add_element(e1)
717
+ # e0[0] # => <bar/>
718
+ #
719
+ # With argument +element+ and hash argument +attributes+,
720
+ # sets attributes on the added element:
721
+ #
722
+ # e0.add_element(e1, {'bat' => '0', 'bam' => '1'})
723
+ # e0[1] # => <bar bat='0' bam='1'/>
724
+ #
725
+ def add_element element, attrs=nil
726
+ raise "First argument must be either an element name, or an Element object" if element.nil?
727
+ el = @elements.add(element)
728
+ attrs.each do |key, value|
729
+ el.attributes[key]=value
730
+ end if attrs.kind_of? Hash
731
+ el
732
+ end
733
+
734
+ # :call-seq:
735
+ # delete_element(index) -> removed_element or nil
736
+ # delete_element(element) -> removed_element or nil
737
+ # delete_element(xpath) -> removed_element or nil
738
+ #
739
+ # Deletes a child element.
740
+ #
741
+ # When 1-based integer argument +index+ is given,
742
+ # removes and returns the child element at that offset if it exists;
743
+ # indexing does not include text nodes;
744
+ # returns +nil+ if the element does not exist:
745
+ #
746
+ # d = REXML::Document.new '<a><b/>text<c/></a>'
747
+ # a = d.root # => <a> ... </>
748
+ # a.delete_element(1) # => <b/>
749
+ # a.delete_element(1) # => <c/>
750
+ # a.delete_element(1) # => nil
751
+ #
752
+ # When element argument +element+ is given,
753
+ # removes and returns that child element if it exists,
754
+ # otherwise returns +nil+:
755
+ #
756
+ # d = REXML::Document.new '<a><b/>text<c/></a>'
757
+ # a = d.root # => <a> ... </>
758
+ # c = a[2] # => <c/>
759
+ # a.delete_element(c) # => <c/>
760
+ # a.delete_element(c) # => nil
761
+ #
762
+ # When xpath argument +xpath+ is given,
763
+ # removes and returns the element at xpath if it exists,
764
+ # otherwise returns +nil+:
765
+ #
766
+ # d = REXML::Document.new '<a><b/>text<c/></a>'
767
+ # a = d.root # => <a> ... </>
768
+ # a.delete_element('//c') # => <c/>
769
+ # a.delete_element('//c') # => nil
770
+ #
771
+ def delete_element element
772
+ @elements.delete element
773
+ end
774
+
775
+ # :call-seq:
776
+ # has_elements?
777
+ #
778
+ # Returns +true+ if the element has one or more element children,
779
+ # +false+ otherwise:
780
+ #
781
+ # d = REXML::Document.new '<a><b/>text<c/></a>'
782
+ # a = d.root # => <a> ... </>
783
+ # a.has_elements? # => true
784
+ # b = a[0] # => <b/>
785
+ # b.has_elements? # => false
786
+ #
787
+ def has_elements?
788
+ !@elements.empty?
789
+ end
790
+
791
+ # :call-seq:
792
+ # each_element_with_attribute(attr_name, value = nil, max = 0, xpath = nil) {|e| ... }
793
+ #
794
+ # Calls the given block with each child element that meets given criteria.
795
+ #
796
+ # When only string argument +attr_name+ is given,
797
+ # calls the block with each child element that has that attribute:
798
+ #
799
+ # d = REXML::Document.new '<a><b id="1"/><c id="2"/><d id="1"/><e/></a>'
800
+ # a = d.root
801
+ # a.each_element_with_attribute('id') {|e| p e }
802
+ #
803
+ # Output:
804
+ #
805
+ # <b id='1'/>
806
+ # <c id='2'/>
807
+ # <d id='1'/>
808
+ #
809
+ # With argument +attr_name+ and string argument +value+ given,
810
+ # calls the block with each child element that has that attribute
811
+ # with that value:
812
+ #
813
+ # a.each_element_with_attribute('id', '1') {|e| p e }
814
+ #
815
+ # Output:
816
+ #
817
+ # <b id='1'/>
818
+ # <d id='1'/>
819
+ #
820
+ # With arguments +attr_name+, +value+, and integer argument +max+ given,
821
+ # calls the block with at most +max+ child elements:
822
+ #
823
+ # a.each_element_with_attribute('id', '1', 1) {|e| p e }
824
+ #
825
+ # Output:
826
+ #
827
+ # <b id='1'/>
828
+ #
829
+ # With all arguments given, including +xpath+,
830
+ # calls the block with only those child elements
831
+ # that meet the first three criteria,
832
+ # and also match the given +xpath+:
833
+ #
834
+ # a.each_element_with_attribute('id', '1', 2, '//d') {|e| p e }
835
+ #
836
+ # Output:
837
+ #
838
+ # <d id='1'/>
839
+ #
840
+ def each_element_with_attribute( key, value=nil, max=0, name=nil, &block ) # :yields: Element
841
+ each_with_something( proc {|child|
842
+ if value.nil?
843
+ child.attributes[key] != nil
844
+ else
845
+ child.attributes[key]==value
846
+ end
847
+ }, max, name, &block )
848
+ end
849
+
850
+ # :call-seq:
851
+ # each_element_with_text(text = nil, max = 0, xpath = nil) {|e| ... }
852
+ #
853
+ # Calls the given block with each child element that meets given criteria.
854
+ #
855
+ # With no arguments, calls the block with each child element that has text:
856
+ #
857
+ # d = REXML::Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
858
+ # a = d.root
859
+ # a.each_element_with_text {|e| p e }
860
+ #
861
+ # Output:
862
+ #
863
+ # <b> ... </>
864
+ # <c> ... </>
865
+ # <d> ... </>
866
+ #
867
+ # With the single string argument +text+,
868
+ # calls the block with each element that has exactly that text:
869
+ #
870
+ # a.each_element_with_text('b') {|e| p e }
871
+ #
872
+ # Output:
873
+ #
874
+ # <b> ... </>
875
+ # <c> ... </>
876
+ #
877
+ # With argument +text+ and integer argument +max+,
878
+ # calls the block with at most +max+ elements:
879
+ #
880
+ # a.each_element_with_text('b', 1) {|e| p e }
881
+ #
882
+ # Output:
883
+ #
884
+ # <b> ... </>
885
+ #
886
+ # With all arguments given, including +xpath+,
887
+ # calls the block with only those child elements
888
+ # that meet the first two criteria,
889
+ # and also match the given +xpath+:
890
+ #
891
+ # a.each_element_with_text('b', 2, '//c') {|e| p e }
892
+ #
893
+ # Output:
894
+ #
895
+ # <c> ... </>
896
+ #
897
+ def each_element_with_text( text=nil, max=0, name=nil, &block ) # :yields: Element
898
+ each_with_something( proc {|child|
899
+ if text.nil?
900
+ child.has_text?
901
+ else
902
+ child.text == text
903
+ end
904
+ }, max, name, &block )
905
+ end
906
+
907
+ # :call-seq:
908
+ # each_element {|e| ... }
909
+ #
910
+ # Calls the given block with each child element:
911
+ #
912
+ # d = REXML::Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
913
+ # a = d.root
914
+ # a.each_element {|e| p e }
915
+ #
916
+ # Output:
917
+ #
918
+ # <b> ... </>
919
+ # <c> ... </>
920
+ # <d> ... </>
921
+ # <e/>
922
+ #
923
+ def each_element( xpath=nil, &block ) # :yields: Element
924
+ @elements.each( xpath, &block )
925
+ end
926
+
927
+ # :call-seq:
928
+ # get_elements(xpath)
929
+ #
930
+ # Returns an array of the elements that match the given +xpath+:
931
+ #
932
+ # xml_string = <<-EOT
933
+ # <root>
934
+ # <a level='1'>
935
+ # <a level='2'/>
936
+ # </a>
937
+ # </root>
938
+ # EOT
939
+ # d = REXML::Document.new(xml_string)
940
+ # d.root.get_elements('//a') # => [<a level='1'> ... </>, <a level='2'/>]
941
+ #
942
+ def get_elements( xpath )
943
+ @elements.to_a( xpath )
944
+ end
945
+
946
+ # :call-seq:
947
+ # next_element
948
+ #
949
+ # Returns the next sibling that is an element if it exists,
950
+ # +niL+ otherwise:
951
+ #
952
+ # d = REXML::Document.new '<a><b/>text<c/></a>'
953
+ # d.root.elements['b'].next_element #-> <c/>
954
+ # d.root.elements['c'].next_element #-> nil
955
+ #
956
+ def next_element
957
+ element = next_sibling
958
+ element = element.next_sibling until element.nil? or element.kind_of? Element
959
+ element
960
+ end
961
+
962
+ # :call-seq:
963
+ # previous_element
964
+ #
965
+ # Returns the previous sibling that is an element if it exists,
966
+ # +niL+ otherwise:
967
+ #
968
+ # d = REXML::Document.new '<a><b/>text<c/></a>'
969
+ # d.root.elements['c'].previous_element #-> <b/>
970
+ # d.root.elements['b'].previous_element #-> nil
971
+ #
972
+ def previous_element
973
+ element = previous_sibling
974
+ element = element.previous_sibling until element.nil? or element.kind_of? Element
975
+ element
976
+ end
977
+
978
+
979
+ #################################################
980
+ # Text #
981
+ #################################################
982
+
983
+ # :call-seq:
984
+ # has_text? -> true or false
985
+ #
986
+ # Returns +true+ if the element has one or more text noded,
987
+ # +false+ otherwise:
988
+ #
989
+ # d = REXML::Document.new '<a><b/>text<c/></a>'
990
+ # a = d.root
991
+ # a.has_text? # => true
992
+ # b = a[0]
993
+ # b.has_text? # => false
994
+ #
995
+ def has_text?
996
+ not text().nil?
997
+ end
998
+
999
+ # :call-seq:
1000
+ # text(xpath = nil) -> text_string or nil
1001
+ #
1002
+ # Returns the text string from the first text node child
1003
+ # in a specified element, if it exists, +nil+ otherwise.
1004
+ #
1005
+ # With no argument, returns the text from the first text node in +self+:
1006
+ #
1007
+ # d = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
1008
+ # d.root.text.class # => String
1009
+ # d.root.text # => "some text "
1010
+ #
1011
+ # With argument +xpath+, returns text from the first text node
1012
+ # in the element that matches +xpath+:
1013
+ #
1014
+ # d.root.text(1) # => "this is bold!"
1015
+ #
1016
+ # Note that an element may have multiple text nodes,
1017
+ # possibly separated by other non-text children, as above.
1018
+ # Even so, the returned value is the string text from the first such node.
1019
+ #
1020
+ # Note also that the text note is retrieved by method get_text,
1021
+ # and so is always normalized text.
1022
+ #
1023
+ def text( path = nil )
1024
+ rv = get_text(path)
1025
+ rv&.value
1026
+ end
1027
+
1028
+ # :call-seq:
1029
+ # get_text(xpath = nil) -> text_node or nil
1030
+ #
1031
+ # Returns the first text node child in a specified element, if it exists,
1032
+ # +nil+ otherwise.
1033
+ #
1034
+ # With no argument, returns the first text node from +self+:
1035
+ #
1036
+ # d = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
1037
+ # d.root.get_text.class # => REXML::Text
1038
+ # d.root.get_text # => "some text "
1039
+ #
1040
+ # With argument +xpath+, returns the first text node from the element
1041
+ # that matches +xpath+:
1042
+ #
1043
+ # d.root.get_text(1) # => "this is bold!"
1044
+ #
1045
+ def get_text path = nil
1046
+ rv = nil
1047
+ if path
1048
+ element = @elements[ path ]
1049
+ rv = element.get_text unless element.nil?
1050
+ else
1051
+ rv = @children.find { |node| node.kind_of? Text }
1052
+ end
1053
+ rv
1054
+ end
1055
+
1056
+ # :call-seq:
1057
+ # text = string -> string
1058
+ # text = nil -> nil
1059
+ #
1060
+ # Adds, replaces, or removes the first text node child in the element.
1061
+ #
1062
+ # With string argument +string+,
1063
+ # creates a new \REXML::Text node containing that string,
1064
+ # honoring the current settings for whitespace and row,
1065
+ # then places the node as the first text child in the element;
1066
+ # returns +string+.
1067
+ #
1068
+ # If the element has no text child, the text node is added:
1069
+ #
1070
+ # d = REXML::Document.new '<a><b/></a>'
1071
+ # d.root.text = 'foo' #-> '<a><b/>foo</a>'
1072
+ #
1073
+ # If the element has a text child, it is replaced:
1074
+ #
1075
+ # d.root.text = 'bar' #-> '<a><b/>bar</a>'
1076
+ #
1077
+ # With argument +nil+, removes the first text child:
1078
+ #
1079
+ # d.root.text = nil #-> '<a><b/><c/></a>'
1080
+ #
1081
+ def text=( text )
1082
+ if text.kind_of? String
1083
+ text = Text.new( text, whitespace(), nil, raw() )
1084
+ elsif !text.nil? and !text.kind_of? Text
1085
+ text = Text.new( text.to_s, whitespace(), nil, raw() )
1086
+ end
1087
+ old_text = get_text
1088
+ if text.nil?
1089
+ old_text.remove unless old_text.nil?
1090
+ else
1091
+ if old_text.nil?
1092
+ self << text
1093
+ else
1094
+ old_text.replace_with( text )
1095
+ end
1096
+ end
1097
+ self
1098
+ end
1099
+
1100
+ # :call-seq:
1101
+ # add_text(string) -> nil
1102
+ # add_text(text_node) -> self
1103
+ #
1104
+ # Adds text to the element.
1105
+ #
1106
+ # When string argument +string+ is given, returns +nil+.
1107
+ #
1108
+ # If the element has no child text node,
1109
+ # creates a \REXML::Text object using the string,
1110
+ # honoring the current settings for whitespace and raw,
1111
+ # then adds that node to the element:
1112
+ #
1113
+ # d = REXML::Document.new('<a><b/></a>')
1114
+ # a = d.root
1115
+ # a.add_text('foo')
1116
+ # a.to_a # => [<b/>, "foo"]
1117
+ #
1118
+ # If the element has child text nodes,
1119
+ # appends the string to the _last_ text node:
1120
+ #
1121
+ # d = REXML::Document.new('<a>foo<b/>bar</a>')
1122
+ # a = d.root
1123
+ # a.add_text('baz')
1124
+ # a.to_a # => ["foo", <b/>, "barbaz"]
1125
+ # a.add_text('baz')
1126
+ # a.to_a # => ["foo", <b/>, "barbazbaz"]
1127
+ #
1128
+ # When text node argument +text_node+ is given,
1129
+ # appends the node as the last text node in the element;
1130
+ # returns +self+:
1131
+ #
1132
+ # d = REXML::Document.new('<a>foo<b/>bar</a>')
1133
+ # a = d.root
1134
+ # a.add_text(REXML::Text.new('baz'))
1135
+ # a.to_a # => ["foo", <b/>, "bar", "baz"]
1136
+ # a.add_text(REXML::Text.new('baz'))
1137
+ # a.to_a # => ["foo", <b/>, "bar", "baz", "baz"]
1138
+ #
1139
+ def add_text( text )
1140
+ if text.kind_of? String
1141
+ if @children[-1].kind_of? Text
1142
+ @children[-1] << text
1143
+ return
1144
+ end
1145
+ text = Text.new( text, whitespace(), nil, raw() )
1146
+ end
1147
+ self << text unless text.nil?
1148
+ self
1149
+ end
1150
+
1151
+ # :call-seq:
1152
+ # node_type -> :element
1153
+ #
1154
+ # Returns symbol <tt>:element</tt>:
1155
+ #
1156
+ # d = REXML::Document.new('<a/>')
1157
+ # a = d.root # => <a/>
1158
+ # a.node_type # => :element
1159
+ #
1160
+ def node_type
1161
+ :element
1162
+ end
1163
+
1164
+ # :call-seq:
1165
+ # xpath -> string_xpath
1166
+ #
1167
+ # Returns the string xpath to the element
1168
+ # relative to the most distant parent:
1169
+ #
1170
+ # d = REXML::Document.new('<a><b><c/></b></a>')
1171
+ # a = d.root # => <a> ... </>
1172
+ # b = a[0] # => <b> ... </>
1173
+ # c = b[0] # => <c/>
1174
+ # d.xpath # => ""
1175
+ # a.xpath # => "/a"
1176
+ # b.xpath # => "/a/b"
1177
+ # c.xpath # => "/a/b/c"
1178
+ #
1179
+ # If there is no parent, returns the expanded name of the element:
1180
+ #
1181
+ # e = REXML::Element.new('foo')
1182
+ # e.xpath # => "foo"
1183
+ #
1184
+ def xpath
1185
+ path_elements = []
1186
+ cur = self
1187
+ path_elements << __to_xpath_helper( self )
1188
+ while cur.parent
1189
+ cur = cur.parent
1190
+ path_elements << __to_xpath_helper( cur )
1191
+ end
1192
+ path_elements.reverse.join( "/" )
1193
+ end
1194
+
1195
+ #################################################
1196
+ # Attributes #
1197
+ #################################################
1198
+
1199
+ # :call-seq:
1200
+ # [index] -> object
1201
+ # [attr_name] -> attr_value
1202
+ # [attr_sym] -> attr_value
1203
+ #
1204
+ # With integer argument +index+ given,
1205
+ # returns the child at offset +index+, or +nil+ if none:
1206
+ #
1207
+ # d = REXML::Document.new '><root><a/>text<b/>more<c/></root>'
1208
+ # root = d.root
1209
+ # (0..root.size).each do |index|
1210
+ # node = root[index]
1211
+ # p "#{index}: #{node} (#{node.class})"
1212
+ # end
1213
+ #
1214
+ # Output:
1215
+ #
1216
+ # "0: <a/> (REXML::Element)"
1217
+ # "1: text (REXML::Text)"
1218
+ # "2: <b/> (REXML::Element)"
1219
+ # "3: more (REXML::Text)"
1220
+ # "4: <c/> (REXML::Element)"
1221
+ # "5: (NilClass)"
1222
+ #
1223
+ # With string argument +attr_name+ given,
1224
+ # returns the string value for the given attribute name if it exists,
1225
+ # otherwise +nil+:
1226
+ #
1227
+ # d = REXML::Document.new('<root attr="value"></root>')
1228
+ # root = d.root
1229
+ # root['attr'] # => "value"
1230
+ # root['nosuch'] # => nil
1231
+ #
1232
+ # With symbol argument +attr_sym+ given,
1233
+ # returns <tt>[attr_sym.to_s]</tt>:
1234
+ #
1235
+ # root[:attr] # => "value"
1236
+ # root[:nosuch] # => nil
1237
+ #
1238
+ def [](name_or_index)
1239
+ case name_or_index
1240
+ when String
1241
+ attributes[name_or_index]
1242
+ when Symbol
1243
+ attributes[name_or_index.to_s]
1244
+ else
1245
+ super
1246
+ end
1247
+ end
1248
+
1249
+
1250
+ # :call-seq:
1251
+ # attribute(name, namespace = nil)
1252
+ #
1253
+ # Returns the string value for the given attribute name.
1254
+ #
1255
+ # With only argument +name+ given,
1256
+ # returns the value of the named attribute if it exists, otherwise +nil+:
1257
+ #
1258
+ # xml_string = <<-EOT
1259
+ # <root xmlns="ns0">
1260
+ # <a xmlns="ns1" attr="value"></a>
1261
+ # <b xmlns="ns2" attr="value"></b>
1262
+ # <c attr="value"/>
1263
+ # </root>
1264
+ # EOT
1265
+ # d = REXML::Document.new(xml_string)
1266
+ # root = d.root
1267
+ # a = root[1] # => <a xmlns='ns1' attr='value'/>
1268
+ # a.attribute('attr') # => attr='value'
1269
+ # a.attribute('nope') # => nil
1270
+ #
1271
+ # With arguments +name+ and +namespace+ given,
1272
+ # returns the value of the named attribute if it exists, otherwise +nil+:
1273
+ #
1274
+ # xml_string = "<root xmlns:a='a' a:x='a:x' x='x'/>"
1275
+ # document = REXML::Document.new(xml_string)
1276
+ # document.root.attribute("x") # => x='x'
1277
+ # document.root.attribute("x", "a") # => a:x='a:x'
1278
+ #
1279
+ def attribute( name, namespace=nil )
1280
+ prefix = namespaces.key(namespace) if namespace
1281
+ prefix = nil if prefix == 'xmlns'
1282
+
1283
+ ret_val =
1284
+ attributes.get_attribute( prefix ? "#{prefix}:#{name}" : name )
1285
+
1286
+ return ret_val unless ret_val.nil?
1287
+ return nil if prefix.nil?
1288
+
1289
+ # now check that prefix'es namespace is not the same as the
1290
+ # default namespace
1291
+ return nil unless ( namespaces[ prefix ] == namespaces[ 'xmlns' ] )
1292
+
1293
+ attributes.get_attribute( name )
1294
+ end
1295
+
1296
+ # :call-seq:
1297
+ # has_attributes? -> true or false
1298
+ #
1299
+ # Returns +true+ if the element has attributes, +false+ otherwise:
1300
+ #
1301
+ # d = REXML::Document.new('<root><a attr="val"/><b/></root>')
1302
+ # a, b = *d.root
1303
+ # a.has_attributes? # => true
1304
+ # b.has_attributes? # => false
1305
+ #
1306
+ def has_attributes?
1307
+ !@attributes.empty?
1308
+ end
1309
+
1310
+ # :call-seq:
1311
+ # add_attribute(name, value) -> value
1312
+ # add_attribute(attribute) -> attribute
1313
+ #
1314
+ # Adds an attribute to this element, overwriting any existing attribute
1315
+ # by the same name.
1316
+ #
1317
+ # With string argument +name+ and object +value+ are given,
1318
+ # adds the attribute created with that name and value:
1319
+ #
1320
+ # e = REXML::Element.new
1321
+ # e.add_attribute('attr', 'value') # => "value"
1322
+ # e['attr'] # => "value"
1323
+ # e.add_attribute('attr', 'VALUE') # => "VALUE"
1324
+ # e['attr'] # => "VALUE"
1325
+ #
1326
+ # With only attribute object +attribute+ given,
1327
+ # adds the given attribute:
1328
+ #
1329
+ # a = REXML::Attribute.new('attr', 'value')
1330
+ # e.add_attribute(a) # => attr='value'
1331
+ # e['attr'] # => "value"
1332
+ # a = REXML::Attribute.new('attr', 'VALUE')
1333
+ # e.add_attribute(a) # => attr='VALUE'
1334
+ # e['attr'] # => "VALUE"
1335
+ #
1336
+ def add_attribute( key, value=nil )
1337
+ if key.kind_of? Attribute
1338
+ @attributes << key
1339
+ else
1340
+ @attributes[key] = value
1341
+ end
1342
+ end
1343
+
1344
+ # :call-seq:
1345
+ # add_attributes(hash) -> hash
1346
+ # add_attributes(array)
1347
+ #
1348
+ # Adds zero or more attributes to the element;
1349
+ # returns the argument.
1350
+ #
1351
+ # If hash argument +hash+ is given,
1352
+ # each key must be a string;
1353
+ # adds each attribute created with the key/value pair:
1354
+ #
1355
+ # e = REXML::Element.new
1356
+ # h = {'foo' => 'bar', 'baz' => 'bat'}
1357
+ # e.add_attributes(h)
1358
+ #
1359
+ # If argument +array+ is given,
1360
+ # each array member must be a 2-element array <tt>[name, value];
1361
+ # each name must be a string:
1362
+ #
1363
+ # e = REXML::Element.new
1364
+ # a = [['foo' => 'bar'], ['baz' => 'bat']]
1365
+ # e.add_attributes(a)
1366
+ #
1367
+ def add_attributes hash
1368
+ if hash.kind_of? Hash
1369
+ hash.each_pair {|key, value| @attributes[key] = value }
1370
+ elsif hash.kind_of? Array
1371
+ hash.each { |value| @attributes[ value[0] ] = value[1] }
1372
+ end
1373
+ end
1374
+
1375
+ # :call-seq:
1376
+ # delete_attribute(name) -> removed_attribute or nil
1377
+ #
1378
+ # Removes a named attribute if it exists;
1379
+ # returns the removed attribute if found, otherwise +nil+:
1380
+ #
1381
+ # e = REXML::Element.new('foo')
1382
+ # e.add_attribute('bar', 'baz')
1383
+ # e.delete_attribute('bar') # => <bar/>
1384
+ # e.delete_attribute('bar') # => nil
1385
+ #
1386
+ def delete_attribute(key)
1387
+ attr = @attributes.get_attribute(key)
1388
+ attr.remove unless attr.nil?
1389
+ end
1390
+
1391
+ #################################################
1392
+ # Other Utilities #
1393
+ #################################################
1394
+
1395
+ # :call-seq:
1396
+ # cdatas -> array_of_cdata_children
1397
+ #
1398
+ # Returns a frozen array of the REXML::CData children of the element:
1399
+ #
1400
+ # xml_string = <<-EOT
1401
+ # <root>
1402
+ # <![CDATA[foo]]>
1403
+ # <![CDATA[bar]]>
1404
+ # </root>
1405
+ # EOT
1406
+ # d = REXML::Document.new(xml_string)
1407
+ # cds = d.root.cdatas # => ["foo", "bar"]
1408
+ # cds.frozen? # => true
1409
+ # cds.map {|cd| cd.class } # => [REXML::CData, REXML::CData]
1410
+ #
1411
+ def cdatas
1412
+ find_all { |child| child.kind_of? CData }.freeze
1413
+ end
1414
+
1415
+ # :call-seq:
1416
+ # comments -> array_of_comment_children
1417
+ #
1418
+ # Returns a frozen array of the REXML::Comment children of the element:
1419
+ #
1420
+ # xml_string = <<-EOT
1421
+ # <root>
1422
+ # <!--foo-->
1423
+ # <!--bar-->
1424
+ # </root>
1425
+ # EOT
1426
+ # d = REXML::Document.new(xml_string)
1427
+ # cs = d.root.comments
1428
+ # cs.frozen? # => true
1429
+ # cs.map {|c| c.class } # => [REXML::Comment, REXML::Comment]
1430
+ # cs.map {|c| c.to_s } # => ["foo", "bar"]
1431
+ #
1432
+ def comments
1433
+ find_all { |child| child.kind_of? Comment }.freeze
1434
+ end
1435
+
1436
+ # :call-seq:
1437
+ # instructions -> array_of_instruction_children
1438
+ #
1439
+ # Returns a frozen array of the REXML::Instruction children of the element:
1440
+ #
1441
+ # xml_string = <<-EOT
1442
+ # <root>
1443
+ # <?target0 foo?>
1444
+ # <?target1 bar?>
1445
+ # </root>
1446
+ # EOT
1447
+ # d = REXML::Document.new(xml_string)
1448
+ # is = d.root.instructions
1449
+ # is.frozen? # => true
1450
+ # is.map {|i| i.class } # => [REXML::Instruction, REXML::Instruction]
1451
+ # is.map {|i| i.to_s } # => ["<?target0 foo?>", "<?target1 bar?>"]
1452
+ #
1453
+ def instructions
1454
+ find_all { |child| child.kind_of? Instruction }.freeze
1455
+ end
1456
+
1457
+ # :call-seq:
1458
+ # texts -> array_of_text_children
1459
+ #
1460
+ # Returns a frozen array of the REXML::Text children of the element:
1461
+ #
1462
+ # xml_string = '<root><a/>text<b/>more<c/></root>'
1463
+ # d = REXML::Document.new(xml_string)
1464
+ # ts = d.root.texts
1465
+ # ts.frozen? # => true
1466
+ # ts.map {|t| t.class } # => [REXML::Text, REXML::Text]
1467
+ # ts.map {|t| t.to_s } # => ["text", "more"]
1468
+ #
1469
+ def texts
1470
+ find_all { |child| child.kind_of? Text }.freeze
1471
+ end
1472
+
1473
+ # == DEPRECATED
1474
+ # See REXML::Formatters
1475
+ #
1476
+ # Writes out this element, and recursively, all children.
1477
+ # output::
1478
+ # output an object which supports '<< string'; this is where the
1479
+ # document will be written.
1480
+ # indent::
1481
+ # An integer. If -1, no indenting will be used; otherwise, the
1482
+ # indentation will be this number of spaces, and children will be
1483
+ # indented an additional amount. Defaults to -1
1484
+ # transitive::
1485
+ # If transitive is true and indent is >= 0, then the output will be
1486
+ # pretty-printed in such a way that the added whitespace does not affect
1487
+ # the parse tree of the document
1488
+ # ie_hack::
1489
+ # This hack inserts a space before the /> on empty tags to address
1490
+ # a limitation of Internet Explorer. Defaults to false
1491
+ #
1492
+ # out = ''
1493
+ # doc.write( out ) #-> doc is written to the string 'out'
1494
+ # doc.write( $stdout ) #-> doc written to the console
1495
+ def write(output=$stdout, indent=-1, transitive=false, ie_hack=false)
1496
+ Kernel.warn("#{self.class.name}#write is deprecated. See REXML::Formatters", uplevel: 1)
1497
+ formatter = if indent > -1
1498
+ if transitive
1499
+ require_relative "formatters/transitive"
1500
+ REXML::Formatters::Transitive.new( indent, ie_hack )
1501
+ else
1502
+ REXML::Formatters::Pretty.new( indent, ie_hack )
1503
+ end
1504
+ else
1505
+ REXML::Formatters::Default.new( ie_hack )
1506
+ end
1507
+ formatter.write( self, output )
1508
+ end
1509
+
1510
+ private
1511
+ def calculate_namespaces
1512
+ if parent
1513
+ parent.namespaces.merge(attributes.namespaces)
1514
+ else
1515
+ attributes.namespaces
1516
+ end
1517
+ end
1518
+
1519
+ def __to_xpath_helper node
1520
+ rv = node.expanded_name.clone
1521
+ if node.parent
1522
+ results = node.parent.find_all {|n|
1523
+ n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name
1524
+ }
1525
+ if results.length > 1
1526
+ idx = results.index( node )
1527
+ rv << "[#{idx+1}]"
1528
+ end
1529
+ end
1530
+ rv
1531
+ end
1532
+
1533
+ # A private helper method
1534
+ def each_with_something( test, max=0, name=nil )
1535
+ num = 0
1536
+ @elements.each( name ){ |child|
1537
+ yield child if test.call(child) and num += 1
1538
+ return if max>0 and num == max
1539
+ }
1540
+ end
1541
+ end
1542
+
1543
+ ########################################################################
1544
+ # ELEMENTS #
1545
+ ########################################################################
1546
+
1547
+ # A class which provides filtering of children for Elements, and
1548
+ # XPath search support. You are expected to only encounter this class as
1549
+ # the <tt>element.elements</tt> object. Therefore, you are
1550
+ # _not_ expected to instantiate this yourself.
1551
+ #
1552
+ # xml_string = <<-EOT
1553
+ # <?xml version="1.0" encoding="UTF-8"?>
1554
+ # <bookstore>
1555
+ # <book category="cooking">
1556
+ # <title lang="en">Everyday Italian</title>
1557
+ # <author>Giada De Laurentiis</author>
1558
+ # <year>2005</year>
1559
+ # <price>30.00</price>
1560
+ # </book>
1561
+ # <book category="children">
1562
+ # <title lang="en">Harry Potter</title>
1563
+ # <author>J K. Rowling</author>
1564
+ # <year>2005</year>
1565
+ # <price>29.99</price>
1566
+ # </book>
1567
+ # <book category="web">
1568
+ # <title lang="en">XQuery Kick Start</title>
1569
+ # <author>James McGovern</author>
1570
+ # <author>Per Bothner</author>
1571
+ # <author>Kurt Cagle</author>
1572
+ # <author>James Linn</author>
1573
+ # <author>Vaidyanathan Nagarajan</author>
1574
+ # <year>2003</year>
1575
+ # <price>49.99</price>
1576
+ # </book>
1577
+ # <book category="web" cover="paperback">
1578
+ # <title lang="en">Learning XML</title>
1579
+ # <author>Erik T. Ray</author>
1580
+ # <year>2003</year>
1581
+ # <price>39.95</price>
1582
+ # </book>
1583
+ # </bookstore>
1584
+ # EOT
1585
+ # d = REXML::Document.new(xml_string)
1586
+ # elements = d.root.elements
1587
+ # elements # => #<REXML::Elements @element=<bookstore> ... </>>
1588
+ #
1589
+ class Elements
1590
+ include Enumerable
1591
+ # :call-seq:
1592
+ # new(parent) -> new_elements_object
1593
+ #
1594
+ # Returns a new \Elements object with the given +parent+.
1595
+ # Does _not_ assign <tt>parent.elements = self</tt>:
1596
+ #
1597
+ # d = REXML::Document.new(xml_string)
1598
+ # eles = REXML::Elements.new(d.root)
1599
+ # eles # => #<REXML::Elements @element=<bookstore> ... </>>
1600
+ # eles == d.root.elements # => false
1601
+ #
1602
+ def initialize parent
1603
+ @element = parent
1604
+ end
1605
+
1606
+ # :call-seq:
1607
+ # parent
1608
+ #
1609
+ # Returns the parent element cited in creating the \Elements object.
1610
+ # This element is also the default starting point for searching
1611
+ # in the \Elements object.
1612
+ #
1613
+ # d = REXML::Document.new(xml_string)
1614
+ # elements = REXML::Elements.new(d.root)
1615
+ # elements.parent == d.root # => true
1616
+ #
1617
+ def parent
1618
+ @element
1619
+ end
1620
+
1621
+ # :call-seq:
1622
+ # elements[index] -> element or nil
1623
+ # elements[xpath] -> element or nil
1624
+ # elements[n, name] -> element or nil
1625
+ #
1626
+ # Returns the first \Element object selected by the arguments,
1627
+ # if any found, or +nil+ if none found.
1628
+ #
1629
+ # Notes:
1630
+ # - The +index+ is 1-based, not 0-based, so that:
1631
+ # - The first element has index <tt>1</tt>
1632
+ # - The _nth_ element has index +n+.
1633
+ # - The selection ignores non-\Element nodes.
1634
+ #
1635
+ # When the single argument +index+ is given,
1636
+ # returns the element given by the index, if any; otherwise, +nil+:
1637
+ #
1638
+ # d = REXML::Document.new(xml_string)
1639
+ # eles = d.root.elements
1640
+ # eles # => #<REXML::Elements @element=<bookstore> ... </>>
1641
+ # eles[1] # => <book category='cooking'> ... </>
1642
+ # eles.size # => 4
1643
+ # eles[4] # => <book category='web' cover='paperback'> ... </>
1644
+ # eles[5] # => nil
1645
+ #
1646
+ # The node at this index is not an \Element, and so is not returned:
1647
+ #
1648
+ # eles = d.root.first.first # => <title lang='en'> ... </>
1649
+ # eles.to_a # => ["Everyday Italian"]
1650
+ # eles[1] # => nil
1651
+ #
1652
+ # When the single argument +xpath+ is given,
1653
+ # returns the first element found via that +xpath+, if any; otherwise, +nil+:
1654
+ #
1655
+ # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>>
1656
+ # eles['/bookstore'] # => <bookstore> ... </>
1657
+ # eles['//book'] # => <book category='cooking'> ... </>
1658
+ # eles['//book [@category="children"]'] # => <book category='children'> ... </>
1659
+ # eles['/nosuch'] # => nil
1660
+ # eles['//nosuch'] # => nil
1661
+ # eles['//book [@category="nosuch"]'] # => nil
1662
+ # eles['.'] # => <bookstore> ... </>
1663
+ # eles['..'].class # => REXML::Document
1664
+ #
1665
+ # With arguments +n+ and +name+ given,
1666
+ # returns the _nth_ found element that has the given +name+,
1667
+ # or +nil+ if there is no such _nth_ element:
1668
+ #
1669
+ # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>>
1670
+ # eles[1, 'book'] # => <book category='cooking'> ... </>
1671
+ # eles[4, 'book'] # => <book category='web' cover='paperback'> ... </>
1672
+ # eles[5, 'book'] # => nil
1673
+ #
1674
+ def []( index, name=nil)
1675
+ if index.kind_of? Integer
1676
+ raise "index (#{index}) must be >= 1" if index < 1
1677
+ name = literalize(name) if name
1678
+ num = 0
1679
+ @element.find { |child|
1680
+ child.kind_of? Element and
1681
+ (name.nil? ? true : child.has_name?( name )) and
1682
+ (num += 1) == index
1683
+ }
1684
+ else
1685
+ XPath::first( @element, index )
1686
+ end
1687
+ end
1688
+
1689
+ # :call-seq:
1690
+ # elements[] = index, replacement_element -> replacement_element or nil
1691
+ #
1692
+ # Replaces or adds an element.
1693
+ #
1694
+ # When <tt>eles[index]</tt> exists, replaces it with +replacement_element+
1695
+ # and returns +replacement_element+:
1696
+ #
1697
+ # d = REXML::Document.new(xml_string)
1698
+ # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>>
1699
+ # eles[1] # => <book category='cooking'> ... </>
1700
+ # eles[1] = REXML::Element.new('foo')
1701
+ # eles[1] # => <foo/>
1702
+ #
1703
+ # Does nothing (or raises an exception)
1704
+ # if +replacement_element+ is not an \Element:
1705
+ # eles[2] # => <book category='web' cover='paperback'> ... </>
1706
+ # eles[2] = REXML::Text.new('bar')
1707
+ # eles[2] # => <book category='web' cover='paperback'> ... </>
1708
+ #
1709
+ # When <tt>eles[index]</tt> does not exist,
1710
+ # adds +replacement_element+ to the element and returns
1711
+ #
1712
+ # d = REXML::Document.new(xml_string)
1713
+ # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>>
1714
+ # eles.size # => 4
1715
+ # eles[50] = REXML::Element.new('foo') # => <foo/>
1716
+ # eles.size # => 5
1717
+ # eles[5] # => <foo/>
1718
+ #
1719
+ # Does nothing (or raises an exception)
1720
+ # if +replacement_element+ is not an \Element:
1721
+ #
1722
+ # eles[50] = REXML::Text.new('bar') # => "bar"
1723
+ # eles.size # => 5
1724
+ #
1725
+ def []=( index, element )
1726
+ previous = self[index]
1727
+ if previous.nil?
1728
+ @element.add element
1729
+ else
1730
+ previous.replace_with element
1731
+ end
1732
+ previous
1733
+ end
1734
+
1735
+ # :call-seq:
1736
+ # empty? -> true or false
1737
+ #
1738
+ # Returns +true+ if there are no children, +false+ otherwise.
1739
+ #
1740
+ # d = REXML::Document.new('')
1741
+ # d.elements.empty? # => true
1742
+ # d = REXML::Document.new(xml_string)
1743
+ # d.elements.empty? # => false
1744
+ #
1745
+ def empty?
1746
+ @element.find{ |child| child.kind_of? Element}.nil?
1747
+ end
1748
+
1749
+ # :call-seq:
1750
+ # index(element)
1751
+ #
1752
+ # Returns the 1-based index of the given +element+, if found;
1753
+ # otherwise, returns -1:
1754
+ #
1755
+ # d = REXML::Document.new(xml_string)
1756
+ # elements = d.root.elements
1757
+ # ele_1, ele_2, ele_3, ele_4 = *elements
1758
+ # elements.index(ele_4) # => 4
1759
+ # elements.delete(ele_3)
1760
+ # elements.index(ele_4) # => 3
1761
+ # elements.index(ele_3) # => -1
1762
+ #
1763
+ def index element
1764
+ rv = 0
1765
+ found = @element.find do |child|
1766
+ child.kind_of? Element and
1767
+ (rv += 1) and
1768
+ child == element
1769
+ end
1770
+ return rv if found == element
1771
+ -1
1772
+ end
1773
+
1774
+ # :call-seq:
1775
+ # delete(index) -> removed_element or nil
1776
+ # delete(element) -> removed_element or nil
1777
+ # delete(xpath) -> removed_element or nil
1778
+ #
1779
+ # Removes an element; returns the removed element, or +nil+ if none removed.
1780
+ #
1781
+ # With integer argument +index+ given,
1782
+ # removes the child element at that offset:
1783
+ #
1784
+ # d = REXML::Document.new(xml_string)
1785
+ # elements = d.root.elements
1786
+ # elements.size # => 4
1787
+ # elements[2] # => <book category='children'> ... </>
1788
+ # elements.delete(2) # => <book category='children'> ... </>
1789
+ # elements.size # => 3
1790
+ # elements[2] # => <book category='web'> ... </>
1791
+ # elements.delete(50) # => nil
1792
+ #
1793
+ # With element argument +element+ given,
1794
+ # removes that child element:
1795
+ #
1796
+ # d = REXML::Document.new(xml_string)
1797
+ # elements = d.root.elements
1798
+ # ele_1, ele_2, ele_3, ele_4 = *elements
1799
+ # elements.size # => 4
1800
+ # elements[2] # => <book category='children'> ... </>
1801
+ # elements.delete(ele_2) # => <book category='children'> ... </>
1802
+ # elements.size # => 3
1803
+ # elements[2] # => <book category='web'> ... </>
1804
+ # elements.delete(ele_2) # => nil
1805
+ #
1806
+ # With string argument +xpath+ given,
1807
+ # removes the first element found via that xpath:
1808
+ #
1809
+ # d = REXML::Document.new(xml_string)
1810
+ # elements = d.root.elements
1811
+ # elements.delete('//book') # => <book category='cooking'> ... </>
1812
+ # elements.delete('//book [@category="children"]') # => <book category='children'> ... </>
1813
+ # elements.delete('//nosuch') # => nil
1814
+ #
1815
+ def delete element
1816
+ if element.kind_of? Element
1817
+ @element.delete element
1818
+ else
1819
+ el = self[element]
1820
+ el.remove if el
1821
+ end
1822
+ end
1823
+
1824
+ # :call-seq:
1825
+ # delete_all(xpath)
1826
+ #
1827
+ # Removes all elements found via the given +xpath+;
1828
+ # returns the array of removed elements, if any, else +nil+.
1829
+ #
1830
+ # d = REXML::Document.new(xml_string)
1831
+ # elements = d.root.elements
1832
+ # elements.size # => 4
1833
+ # deleted_elements = elements.delete_all('//book [@category="web"]')
1834
+ # deleted_elements.size # => 2
1835
+ # elements.size # => 2
1836
+ # deleted_elements = elements.delete_all('//book')
1837
+ # deleted_elements.size # => 2
1838
+ # elements.size # => 0
1839
+ # elements.delete_all('//book') # => []
1840
+ #
1841
+ def delete_all( xpath )
1842
+ rv = []
1843
+ XPath::each( @element, xpath) {|element|
1844
+ rv << element if element.kind_of? Element
1845
+ }
1846
+ rv.each do |element|
1847
+ @element.delete element
1848
+ element.remove
1849
+ end
1850
+ rv
1851
+ end
1852
+
1853
+ # :call-seq:
1854
+ # add -> new_element
1855
+ # add(name) -> new_element
1856
+ # add(element) -> element
1857
+ #
1858
+ # Adds an element; returns the element added.
1859
+ #
1860
+ # With no argument, creates and adds a new element.
1861
+ # The new element has:
1862
+ #
1863
+ # - No name.
1864
+ # - \Parent from the \Elements object.
1865
+ # - Context from the that parent.
1866
+ #
1867
+ # Example:
1868
+ #
1869
+ # d = REXML::Document.new(xml_string)
1870
+ # elements = d.root.elements
1871
+ # parent = elements.parent # => <bookstore> ... </>
1872
+ # parent.context = {raw: :all}
1873
+ # elements.size # => 4
1874
+ # new_element = elements.add # => </>
1875
+ # elements.size # => 5
1876
+ # new_element.name # => nil
1877
+ # new_element.parent # => <bookstore> ... </>
1878
+ # new_element.context # => {:raw=>:all}
1879
+ #
1880
+ # With string argument +name+, creates and adds a new element.
1881
+ # The new element has:
1882
+ #
1883
+ # - Name +name+.
1884
+ # - \Parent from the \Elements object.
1885
+ # - Context from the that parent.
1886
+ #
1887
+ # Example:
1888
+ #
1889
+ # d = REXML::Document.new(xml_string)
1890
+ # elements = d.root.elements
1891
+ # parent = elements.parent # => <bookstore> ... </>
1892
+ # parent.context = {raw: :all}
1893
+ # elements.size # => 4
1894
+ # new_element = elements.add('foo') # => <foo/>
1895
+ # elements.size # => 5
1896
+ # new_element.name # => "foo"
1897
+ # new_element.parent # => <bookstore> ... </>
1898
+ # new_element.context # => {:raw=>:all}
1899
+ #
1900
+ # With argument +element+,
1901
+ # creates and adds a clone of the given +element+.
1902
+ # The new element has name, parent, and context from the given +element+.
1903
+ #
1904
+ # d = REXML::Document.new(xml_string)
1905
+ # elements = d.root.elements
1906
+ # elements.size # => 4
1907
+ # e0 = REXML::Element.new('foo')
1908
+ # e1 = REXML::Element.new('bar', e0, {raw: :all})
1909
+ # element = elements.add(e1) # => <bar/>
1910
+ # elements.size # => 5
1911
+ # element.name # => "bar"
1912
+ # element.parent # => <bookstore> ... </>
1913
+ # element.context # => {:raw=>:all}
1914
+ #
1915
+ def add element=nil
1916
+ if element.nil?
1917
+ Element.new("", self, @element.context)
1918
+ elsif not element.kind_of?(Element)
1919
+ Element.new(element, self, @element.context)
1920
+ else
1921
+ @element << element
1922
+ element.context = @element.context
1923
+ element
1924
+ end
1925
+ end
1926
+
1927
+ alias :<< :add
1928
+
1929
+ # :call-seq:
1930
+ # each(xpath = nil) {|element| ... } -> self
1931
+ #
1932
+ # Iterates over the elements.
1933
+ #
1934
+ # With no argument, calls the block with each element:
1935
+ #
1936
+ # d = REXML::Document.new(xml_string)
1937
+ # elements = d.root.elements
1938
+ # elements.each {|element| p element }
1939
+ #
1940
+ # Output:
1941
+ #
1942
+ # <book category='cooking'> ... </>
1943
+ # <book category='children'> ... </>
1944
+ # <book category='web'> ... </>
1945
+ # <book category='web' cover='paperback'> ... </>
1946
+ #
1947
+ # With argument +xpath+, calls the block with each element
1948
+ # that matches the given +xpath+:
1949
+ #
1950
+ # elements.each('//book [@category="web"]') {|element| p element }
1951
+ #
1952
+ # Output:
1953
+ #
1954
+ # <book category='web'> ... </>
1955
+ # <book category='web' cover='paperback'> ... </>
1956
+ #
1957
+ def each( xpath=nil )
1958
+ XPath::each( @element, xpath ) {|e| yield e if e.kind_of? Element }
1959
+ end
1960
+
1961
+ # :call-seq:
1962
+ # collect(xpath = nil) {|element| ... } -> array
1963
+ #
1964
+ # Iterates over the elements; returns the array of block return values.
1965
+ #
1966
+ # With no argument, iterates over all elements:
1967
+ #
1968
+ # d = REXML::Document.new(xml_string)
1969
+ # elements = d.root.elements
1970
+ # elements.collect {|element| element.size } # => [9, 9, 17, 9]
1971
+ #
1972
+ # With argument +xpath+, iterates over elements that match
1973
+ # the given +xpath+:
1974
+ #
1975
+ # xpath = '//book [@category="web"]'
1976
+ # elements.collect(xpath) {|element| element.size } # => [17, 9]
1977
+ #
1978
+ def collect( xpath=nil )
1979
+ collection = []
1980
+ XPath::each( @element, xpath ) {|e|
1981
+ collection << yield(e) if e.kind_of?(Element)
1982
+ }
1983
+ collection
1984
+ end
1985
+
1986
+ # :call-seq:
1987
+ # inject(xpath = nil, initial = nil) -> object
1988
+ #
1989
+ # Calls the block with elements; returns the last block return value.
1990
+ #
1991
+ # With no argument, iterates over the elements, calling the block
1992
+ # <tt>elements.size - 1</tt> times.
1993
+ #
1994
+ # - The first call passes the first and second elements.
1995
+ # - The second call passes the first block return value and the third element.
1996
+ # - The third call passes the second block return value and the fourth element.
1997
+ # - And so on.
1998
+ #
1999
+ # In this example, the block returns the passed element,
2000
+ # which is then the object argument to the next call:
2001
+ #
2002
+ # d = REXML::Document.new(xml_string)
2003
+ # elements = d.root.elements
2004
+ # elements.inject do |object, element|
2005
+ # p [elements.index(object), elements.index(element)]
2006
+ # element
2007
+ # end
2008
+ #
2009
+ # Output:
2010
+ #
2011
+ # [1, 2]
2012
+ # [2, 3]
2013
+ # [3, 4]
2014
+ #
2015
+ # With the single argument +xpath+, calls the block only with
2016
+ # elements matching that xpath:
2017
+ #
2018
+ # elements.inject('//book [@category="web"]') do |object, element|
2019
+ # p [elements.index(object), elements.index(element)]
2020
+ # element
2021
+ # end
2022
+ #
2023
+ # Output:
2024
+ #
2025
+ # [3, 4]
2026
+ #
2027
+ # With argument +xpath+ given as +nil+
2028
+ # and argument +initial+ also given,
2029
+ # calls the block once for each element.
2030
+ #
2031
+ # - The first call passes the +initial+ and the first element.
2032
+ # - The second call passes the first block return value and the second element.
2033
+ # - The third call passes the second block return value and the third element.
2034
+ # - And so on.
2035
+ #
2036
+ # In this example, the first object index is <tt>-1</tt>
2037
+ #
2038
+ # elements.inject(nil, 'Initial') do |object, element|
2039
+ # p [elements.index(object), elements.index(element)]
2040
+ # element
2041
+ # end
2042
+ #
2043
+ # Output:
2044
+ #
2045
+ # [-1, 1]
2046
+ # [1, 2]
2047
+ # [2, 3]
2048
+ # [3, 4]
2049
+ #
2050
+ # In this form the passed object can be used as an accumulator:
2051
+ #
2052
+ # elements.inject(nil, 0) do |total, element|
2053
+ # total += element.size
2054
+ # end # => 44
2055
+ #
2056
+ # With both arguments +xpath+ and +initial+ are given,
2057
+ # calls the block only with elements matching that xpath:
2058
+ #
2059
+ # elements.inject('//book [@category="web"]', 0) do |total, element|
2060
+ # total += element.size
2061
+ # end # => 26
2062
+ #
2063
+ def inject( xpath=nil, initial=nil )
2064
+ first = true
2065
+ XPath::each( @element, xpath ) {|e|
2066
+ if (e.kind_of? Element)
2067
+ if (first and initial == nil)
2068
+ initial = e
2069
+ first = false
2070
+ else
2071
+ initial = yield( initial, e ) if e.kind_of? Element
2072
+ end
2073
+ end
2074
+ }
2075
+ initial
2076
+ end
2077
+
2078
+ # :call-seq:
2079
+ # size -> integer
2080
+ #
2081
+ # Returns the count of \Element children:
2082
+ #
2083
+ # d = REXML::Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
2084
+ # d.root.elements.size # => 3 # Three elements.
2085
+ # d.root.size # => 6 # Three elements plus three text nodes..
2086
+ #
2087
+ def size
2088
+ count = 0
2089
+ @element.each {|child| count+=1 if child.kind_of? Element }
2090
+ count
2091
+ end
2092
+
2093
+ # :call-seq:
2094
+ # to_a(xpath = nil) -> array_of_elements
2095
+ #
2096
+ # Returns an array of element children (not including non-element children).
2097
+ #
2098
+ # With no argument, returns an array of all element children:
2099
+ #
2100
+ # d = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
2101
+ # elements = d.root.elements
2102
+ # elements.to_a # => [<b/>, <c/>] # Omits non-element children.
2103
+ # children = d.root.children
2104
+ # children # => ["sean", <b/>, "elliott", <c/>] # Includes non-element children.
2105
+ #
2106
+ # With argument +xpath+, returns an array of element children
2107
+ # that match the xpath:
2108
+ #
2109
+ # elements.to_a('//c') # => [<c/>]
2110
+ #
2111
+ def to_a( xpath=nil )
2112
+ rv = XPath.match( @element, xpath )
2113
+ return rv.find_all{|e| e.kind_of? Element} if xpath
2114
+ rv
2115
+ end
2116
+
2117
+ private
2118
+ # Private helper class. Removes quotes from quoted strings
2119
+ def literalize name
2120
+ name = name[1..-2] if name[0] == ?' or name[0] == ?" #'
2121
+ name
2122
+ end
2123
+ end
2124
+
2125
+ ########################################################################
2126
+ # ATTRIBUTES #
2127
+ ########################################################################
2128
+
2129
+ # A class that defines the set of Attributes of an Element and provides
2130
+ # operations for accessing elements in that set.
2131
+ class Attributes < Hash
2132
+
2133
+ # :call-seq:
2134
+ # new(element)
2135
+ #
2136
+ # Creates and returns a new \REXML::Attributes object.
2137
+ # The element given by argument +element+ is stored,
2138
+ # but its own attributes are not modified:
2139
+ #
2140
+ # ele = REXML::Element.new('foo')
2141
+ # attrs = REXML::Attributes.new(ele)
2142
+ # attrs.object_id == ele.attributes.object_id # => false
2143
+ #
2144
+ # Other instance methods in class \REXML::Attributes may refer to:
2145
+ #
2146
+ # - +element.document+.
2147
+ # - +element.prefix+.
2148
+ # - +element.expanded_name+.
2149
+ #
2150
+ def initialize element
2151
+ @element = element
2152
+ end
2153
+
2154
+ # :call-seq:
2155
+ # [name] -> attribute_value or nil
2156
+ #
2157
+ # Returns the value for the attribute given by +name+,
2158
+ # if it exists; otherwise +nil+.
2159
+ # The value returned is the unnormalized attribute value,
2160
+ # with entities expanded:
2161
+ #
2162
+ # xml_string = <<-EOT
2163
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2164
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2165
+ # </root>
2166
+ # EOT
2167
+ # d = REXML::Document.new(xml_string)
2168
+ # ele = d.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2169
+ # ele.attributes['att'] # => "<"
2170
+ # ele.attributes['bar:att'] # => "2"
2171
+ # ele.attributes['nosuch'] # => nil
2172
+ #
2173
+ # Related: get_attribute (returns an \Attribute object).
2174
+ #
2175
+ def [](name)
2176
+ attr = get_attribute(name)
2177
+ attr&.value
2178
+ end
2179
+
2180
+ # :call-seq:
2181
+ # to_a -> array_of_attribute_objects
2182
+ #
2183
+ # Returns an array of \REXML::Attribute objects representing
2184
+ # the attributes:
2185
+ #
2186
+ # xml_string = <<-EOT
2187
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2188
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2189
+ # </root>
2190
+ # EOT
2191
+ # d = REXML::Document.new(xml_string)
2192
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2193
+ # attrs = ele.attributes.to_a # => [foo:att='1', bar:att='2', att='&lt;']
2194
+ # attrs.first.class # => REXML::Attribute
2195
+ #
2196
+ def to_a
2197
+ enum_for(:each_attribute).to_a
2198
+ end
2199
+
2200
+ # :call-seq:
2201
+ # length
2202
+ #
2203
+ # Returns the count of attributes:
2204
+ #
2205
+ # xml_string = <<-EOT
2206
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2207
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2208
+ # </root>
2209
+ # EOT
2210
+ # d = REXML::Document.new(xml_string)
2211
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2212
+ # ele.attributes.length # => 3
2213
+ #
2214
+ def length
2215
+ c = 0
2216
+ each_attribute { c+=1 }
2217
+ c
2218
+ end
2219
+ alias :size :length
2220
+
2221
+ # :call-seq:
2222
+ # each_attribute {|attr| ... }
2223
+ #
2224
+ # Calls the given block with each \REXML::Attribute object:
2225
+ #
2226
+ # xml_string = <<-EOT
2227
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2228
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2229
+ # </root>
2230
+ # EOT
2231
+ # d = REXML::Document.new(xml_string)
2232
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2233
+ # ele.attributes.each_attribute do |attr|
2234
+ # p [attr.class, attr]
2235
+ # end
2236
+ #
2237
+ # Output:
2238
+ #
2239
+ # [REXML::Attribute, foo:att='1']
2240
+ # [REXML::Attribute, bar:att='2']
2241
+ # [REXML::Attribute, att='&lt;']
2242
+ #
2243
+ def each_attribute # :yields: attribute
2244
+ return to_enum(__method__) unless block_given?
2245
+ each_value do |val|
2246
+ if val.kind_of? Attribute
2247
+ yield val
2248
+ else
2249
+ val.each_value { |atr| yield atr }
2250
+ end
2251
+ end
2252
+ end
2253
+
2254
+ # :call-seq:
2255
+ # each {|expanded_name, value| ... }
2256
+ #
2257
+ # Calls the given block with each expanded-name/value pair:
2258
+ #
2259
+ # xml_string = <<-EOT
2260
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2261
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2262
+ # </root>
2263
+ # EOT
2264
+ # d = REXML::Document.new(xml_string)
2265
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2266
+ # ele.attributes.each do |expanded_name, value|
2267
+ # p [expanded_name, value]
2268
+ # end
2269
+ #
2270
+ # Output:
2271
+ #
2272
+ # ["foo:att", "1"]
2273
+ # ["bar:att", "2"]
2274
+ # ["att", "<"]
2275
+ #
2276
+ def each
2277
+ return to_enum(__method__) unless block_given?
2278
+ each_attribute do |attr|
2279
+ yield [attr.expanded_name, attr.value]
2280
+ end
2281
+ end
2282
+
2283
+ # :call-seq:
2284
+ # get_attribute(name) -> attribute_object or nil
2285
+ #
2286
+ # Returns the \REXML::Attribute object for the given +name+:
2287
+ #
2288
+ # xml_string = <<-EOT
2289
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2290
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2291
+ # </root>
2292
+ # EOT
2293
+ # d = REXML::Document.new(xml_string)
2294
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2295
+ # attrs = ele.attributes
2296
+ # attrs.get_attribute('foo:att') # => foo:att='1'
2297
+ # attrs.get_attribute('foo:att').class # => REXML::Attribute
2298
+ # attrs.get_attribute('bar:att') # => bar:att='2'
2299
+ # attrs.get_attribute('att') # => att='&lt;'
2300
+ # attrs.get_attribute('nosuch') # => nil
2301
+ #
2302
+ def get_attribute( name )
2303
+ attr = fetch( name, nil )
2304
+ if attr.nil?
2305
+ return nil if name.nil?
2306
+ # Look for prefix
2307
+ name =~ Namespace::NAMESPLIT
2308
+ prefix, n = $1, $2
2309
+ if prefix
2310
+ attr = fetch( n, nil )
2311
+ # check prefix
2312
+ if attr == nil
2313
+ elsif attr.kind_of? Attribute
2314
+ return attr if prefix == attr.prefix
2315
+ else
2316
+ attr = attr[ prefix ]
2317
+ return attr
2318
+ end
2319
+ end
2320
+ doctype = @element.document&.doctype
2321
+ if doctype
2322
+ expn = @element.expanded_name
2323
+ expn = doctype.name if expn.size == 0
2324
+ attr_val = doctype.attribute_of(expn, name)
2325
+ return Attribute.new( name, attr_val ) if attr_val
2326
+ end
2327
+ return nil
2328
+ end
2329
+ if attr.kind_of? Hash
2330
+ attr = attr[ @element.prefix ]
2331
+ end
2332
+ attr
2333
+ end
2334
+
2335
+ # :call-seq:
2336
+ # [name] = value -> value
2337
+ #
2338
+ # When +value+ is non-+nil+,
2339
+ # assigns that to the attribute for the given +name+,
2340
+ # overwriting the previous value if it exists:
2341
+ #
2342
+ # xml_string = <<-EOT
2343
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2344
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2345
+ # </root>
2346
+ # EOT
2347
+ # d = REXML::Document.new(xml_string)
2348
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2349
+ # attrs = ele.attributes
2350
+ # attrs['foo:att'] = '2' # => "2"
2351
+ # attrs['baz:att'] = '3' # => "3"
2352
+ #
2353
+ # When +value+ is +nil+, deletes the attribute if it exists:
2354
+ #
2355
+ # attrs['baz:att'] = nil
2356
+ # attrs.include?('baz:att') # => false
2357
+ #
2358
+ def []=( name, value )
2359
+ if value.nil? # Delete the named attribute
2360
+ attr = get_attribute(name)
2361
+ delete attr
2362
+ return
2363
+ end
2364
+
2365
+ unless value.kind_of? Attribute
2366
+ doctype = @element.document&.doctype
2367
+ if doctype
2368
+ value = Text::normalize( value, doctype )
2369
+ else
2370
+ value = Text::normalize( value, nil )
2371
+ end
2372
+ value = Attribute.new(name, value)
2373
+ end
2374
+ value.element = @element
2375
+ old_attr = fetch(value.name, nil)
2376
+ if old_attr.nil?
2377
+ store(value.name, value)
2378
+ elsif old_attr.kind_of? Hash
2379
+ old_attr[value.prefix] = value
2380
+ elsif old_attr.prefix != value.prefix
2381
+ store value.name, {old_attr.prefix => old_attr,
2382
+ value.prefix => value}
2383
+ else
2384
+ store value.name, value
2385
+ end
2386
+ @element
2387
+ end
2388
+
2389
+ # :call-seq:
2390
+ # prefixes -> array_of_prefix_strings
2391
+ #
2392
+ # Returns an array of prefix strings in the attributes.
2393
+ # The array does not include the default
2394
+ # namespace declaration, if one exists.
2395
+ #
2396
+ # xml_string = '<a xmlns="foo" xmlns:x="bar" xmlns:y="twee" z="glorp"/>'
2397
+ # d = REXML::Document.new(xml_string)
2398
+ # d.root.attributes.prefixes # => ["x", "y"]
2399
+ #
2400
+ def prefixes
2401
+ ns = []
2402
+ each_attribute do |attribute|
2403
+ ns << attribute.name if attribute.prefix == 'xmlns'
2404
+ end
2405
+ doctype = @element.document&.doctype
2406
+ if doctype
2407
+ expn = @element.expanded_name
2408
+ expn = doctype.name if expn.size == 0
2409
+ doctype.attributes_of(expn).each {
2410
+ |attribute|
2411
+ ns << attribute.name if attribute.prefix == 'xmlns'
2412
+ }
2413
+ end
2414
+ ns
2415
+ end
2416
+
2417
+ # :call-seq:
2418
+ # namespaces
2419
+ #
2420
+ # Returns a hash of name/value pairs for the namespaces:
2421
+ #
2422
+ # xml_string = '<a xmlns="foo" xmlns:x="bar" xmlns:y="twee" z="glorp"/>'
2423
+ # d = REXML::Document.new(xml_string)
2424
+ # d.root.attributes.namespaces # => {"xmlns"=>"foo", "x"=>"bar", "y"=>"twee"}
2425
+ #
2426
+ def namespaces
2427
+ namespaces = {}
2428
+ each_attribute do |attribute|
2429
+ namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
2430
+ end
2431
+ doctype = @element.document&.doctype
2432
+ if doctype
2433
+ expn = @element.expanded_name
2434
+ expn = doctype.name if expn.size == 0
2435
+ doctype.attributes_of(expn).each {
2436
+ |attribute|
2437
+ namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
2438
+ }
2439
+ end
2440
+ namespaces
2441
+ end
2442
+
2443
+ # :call-seq:
2444
+ # delete(name) -> element
2445
+ # delete(attribute) -> element
2446
+ #
2447
+ # Removes a specified attribute if it exists;
2448
+ # returns the attributes' element.
2449
+ #
2450
+ # When string argument +name+ is given,
2451
+ # removes the attribute of that name if it exists:
2452
+ #
2453
+ # xml_string = <<-EOT
2454
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2455
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2456
+ # </root>
2457
+ # EOT
2458
+ # d = REXML::Document.new(xml_string)
2459
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2460
+ # attrs = ele.attributes
2461
+ # attrs.delete('foo:att') # => <ele bar:att='2' att='&lt;'/>
2462
+ # attrs.delete('foo:att') # => <ele bar:att='2' att='&lt;'/>
2463
+ #
2464
+ # When attribute argument +attribute+ is given,
2465
+ # removes that attribute if it exists:
2466
+ #
2467
+ # attr = REXML::Attribute.new('bar:att', '2')
2468
+ # attrs.delete(attr) # => <ele att='&lt;'/> # => <ele att='&lt;'/>
2469
+ # attrs.delete(attr) # => <ele att='&lt;'/> # => <ele/>
2470
+ #
2471
+ def delete( attribute )
2472
+ name = nil
2473
+ prefix = nil
2474
+ if attribute.kind_of? Attribute
2475
+ name = attribute.name
2476
+ prefix = attribute.prefix
2477
+ else
2478
+ attribute =~ Namespace::NAMESPLIT
2479
+ prefix, name = $1, $2
2480
+ prefix = '' unless prefix
2481
+ end
2482
+ old = fetch(name, nil)
2483
+ if old.kind_of? Hash # the supplied attribute is one of many
2484
+ old.delete(prefix)
2485
+ if old.size == 1
2486
+ repl = nil
2487
+ old.each_value{|v| repl = v}
2488
+ store name, repl
2489
+ end
2490
+ elsif old # the supplied attribute is a top-level one
2491
+ super(name)
2492
+ end
2493
+ @element
2494
+ end
2495
+
2496
+ # :call-seq:
2497
+ # add(attribute) -> attribute
2498
+ #
2499
+ # Adds attribute +attribute+, replacing the previous
2500
+ # attribute of the same name if it exists;
2501
+ # returns +attribute+:
2502
+ #
2503
+ # xml_string = <<-EOT
2504
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2505
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2506
+ # </root>
2507
+ # EOT
2508
+ # d = REXML::Document.new(xml_string)
2509
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2510
+ # attrs = ele.attributes
2511
+ # attrs # => {"att"=>{"foo"=>foo:att='1', "bar"=>bar:att='2', ""=>att='&lt;'}}
2512
+ # attrs.add(REXML::Attribute.new('foo:att', '2')) # => foo:att='2'
2513
+ # attrs.add(REXML::Attribute.new('baz', '3')) # => baz='3'
2514
+ # attrs.include?('baz') # => true
2515
+ #
2516
+ def add( attribute )
2517
+ self[attribute.name] = attribute
2518
+ end
2519
+
2520
+ alias :<< :add
2521
+
2522
+ # :call-seq:
2523
+ # delete_all(name) -> array_of_removed_attributes
2524
+ #
2525
+ # Removes all attributes matching the given +name+;
2526
+ # returns an array of the removed attributes:
2527
+ #
2528
+ # xml_string = <<-EOT
2529
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2530
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2531
+ # </root>
2532
+ # EOT
2533
+ # d = REXML::Document.new(xml_string)
2534
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2535
+ # attrs = ele.attributes
2536
+ # attrs.delete_all('att') # => [att='&lt;']
2537
+ #
2538
+ def delete_all( name )
2539
+ rv = []
2540
+ each_attribute { |attribute|
2541
+ rv << attribute if attribute.expanded_name == name
2542
+ }
2543
+ rv.each{ |attr| attr.remove }
2544
+ rv
2545
+ end
2546
+
2547
+ # :call-seq:
2548
+ # get_attribute_ns(namespace, name)
2549
+ #
2550
+ # Returns the \REXML::Attribute object among the attributes
2551
+ # that matches the given +namespace+ and +name+:
2552
+ #
2553
+ # xml_string = <<-EOT
2554
+ # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
2555
+ # <ele foo:att='1' bar:att='2' att='&lt;'/>
2556
+ # </root>
2557
+ # EOT
2558
+ # d = REXML::Document.new(xml_string)
2559
+ # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
2560
+ # attrs = ele.attributes
2561
+ # attrs.get_attribute_ns('http://foo', 'att') # => foo:att='1'
2562
+ # attrs.get_attribute_ns('http://foo', 'nosuch') # => nil
2563
+ #
2564
+ def get_attribute_ns(namespace, name)
2565
+ result = nil
2566
+ each_attribute() { |attribute|
2567
+ if name == attribute.name &&
2568
+ namespace == attribute.namespace() &&
2569
+ ( !namespace.empty? || !attribute.fully_expanded_name.index(':') )
2570
+ # foo will match xmlns:foo, but only if foo isn't also an attribute
2571
+ result = attribute if !result or !namespace.empty? or
2572
+ !attribute.fully_expanded_name.index(':')
2573
+ end
2574
+ }
2575
+ result
2576
+ end
2577
+ end
2578
+ end