typo 5.2.98 → 5.3

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 (302) hide show
  1. data/app/controllers/admin/sidebar_controller.rb +15 -3
  2. data/app/helpers/sidebar_helper.rb +9 -4
  3. data/app/models/feedback.rb +10 -2
  4. data/app/models/page_cache.rb +5 -1
  5. data/app/views/admin/blacklist/_blacklist_patterns.html.erb +2 -0
  6. data/app/views/admin/categories/new.html.erb +1 -1
  7. data/app/views/admin/content/_form.html.erb +3 -3
  8. data/app/views/admin/content/_simple_editor.html.erb +2 -0
  9. data/app/views/admin/content/_visual_editor.html.erb +2 -0
  10. data/app/views/admin/pages/_form.html.erb +5 -5
  11. data/app/views/admin/pages/_simple_editor.html.erb +2 -0
  12. data/app/views/admin/pages/_visual_editor.html.erb +2 -0
  13. data/app/views/articles/_comment_box.html.erb +1 -1
  14. data/app/views/articles/_comment_failed.html.erb +1 -1
  15. data/app/views/articles/read.html.erb +1 -1
  16. data/config/environment.rb +3 -2
  17. data/lib/tasks/release.rake +3 -4
  18. data/lib/typo_version.rb +1 -1
  19. data/public/stylesheets/administration.css +37 -2
  20. data/public/stylesheets/administration_rtl.css +316 -437
  21. data/vendor/actionwebservice/CHANGELOG +320 -0
  22. data/vendor/actionwebservice/MIT-LICENSE +21 -0
  23. data/vendor/actionwebservice/README +381 -0
  24. data/vendor/actionwebservice/Rakefile +173 -0
  25. data/vendor/actionwebservice/TODO +32 -0
  26. data/vendor/actionwebservice/examples/googlesearch/README +143 -0
  27. data/vendor/actionwebservice/examples/googlesearch/autoloading/google_search_api.rb +50 -0
  28. data/vendor/actionwebservice/examples/googlesearch/autoloading/google_search_controller.rb +57 -0
  29. data/vendor/actionwebservice/examples/googlesearch/delegated/google_search_service.rb +108 -0
  30. data/vendor/actionwebservice/examples/googlesearch/delegated/search_controller.rb +7 -0
  31. data/vendor/actionwebservice/examples/googlesearch/direct/google_search_api.rb +50 -0
  32. data/vendor/actionwebservice/examples/googlesearch/direct/search_controller.rb +58 -0
  33. data/vendor/actionwebservice/examples/metaWeblog/README +17 -0
  34. data/vendor/actionwebservice/examples/metaWeblog/apis/blogger_api.rb +60 -0
  35. data/vendor/actionwebservice/examples/metaWeblog/apis/blogger_service.rb +34 -0
  36. data/vendor/actionwebservice/examples/metaWeblog/apis/meta_weblog_api.rb +67 -0
  37. data/vendor/actionwebservice/examples/metaWeblog/apis/meta_weblog_service.rb +48 -0
  38. data/vendor/actionwebservice/examples/metaWeblog/controllers/xmlrpc_controller.rb +16 -0
  39. data/vendor/actionwebservice/generators/web_service/USAGE +28 -0
  40. data/vendor/actionwebservice/generators/web_service/templates/api_definition.rb +5 -0
  41. data/vendor/actionwebservice/generators/web_service/templates/controller.rb +8 -0
  42. data/vendor/actionwebservice/generators/web_service/templates/functional_test.rb +19 -0
  43. data/vendor/actionwebservice/generators/web_service/web_service_generator.rb +29 -0
  44. data/vendor/actionwebservice/lib/action_web_service.rb +66 -0
  45. data/vendor/actionwebservice/lib/action_web_service/api.rb +297 -0
  46. data/vendor/actionwebservice/lib/action_web_service/base.rb +38 -0
  47. data/vendor/actionwebservice/lib/action_web_service/casting.rb +144 -0
  48. data/vendor/actionwebservice/lib/action_web_service/client.rb +3 -0
  49. data/vendor/actionwebservice/lib/action_web_service/client/base.rb +28 -0
  50. data/vendor/actionwebservice/lib/action_web_service/client/soap_client.rb +113 -0
  51. data/vendor/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb +58 -0
  52. data/vendor/actionwebservice/lib/action_web_service/container.rb +3 -0
  53. data/vendor/actionwebservice/lib/action_web_service/container/action_controller_container.rb +93 -0
  54. data/vendor/actionwebservice/lib/action_web_service/container/delegated_container.rb +86 -0
  55. data/vendor/actionwebservice/lib/action_web_service/container/direct_container.rb +69 -0
  56. data/vendor/actionwebservice/lib/action_web_service/dispatcher.rb +2 -0
  57. data/vendor/actionwebservice/lib/action_web_service/dispatcher/abstract.rb +207 -0
  58. data/vendor/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +379 -0
  59. data/vendor/actionwebservice/lib/action_web_service/invocation.rb +202 -0
  60. data/vendor/actionwebservice/lib/action_web_service/protocol.rb +4 -0
  61. data/vendor/actionwebservice/lib/action_web_service/protocol/abstract.rb +112 -0
  62. data/vendor/actionwebservice/lib/action_web_service/protocol/discovery.rb +37 -0
  63. data/vendor/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb +176 -0
  64. data/vendor/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb +242 -0
  65. data/vendor/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb +122 -0
  66. data/vendor/actionwebservice/lib/action_web_service/scaffolding.rb +281 -0
  67. data/vendor/actionwebservice/lib/action_web_service/struct.rb +64 -0
  68. data/vendor/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb +26 -0
  69. data/vendor/actionwebservice/lib/action_web_service/support/signature_types.rb +226 -0
  70. data/vendor/actionwebservice/lib/action_web_service/templates/scaffolds/layout.html.erb +65 -0
  71. data/vendor/actionwebservice/lib/action_web_service/templates/scaffolds/methods.html.erb +6 -0
  72. data/vendor/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.html.erb +29 -0
  73. data/vendor/actionwebservice/lib/action_web_service/templates/scaffolds/result.html.erb +30 -0
  74. data/vendor/actionwebservice/lib/action_web_service/test_invoke.rb +110 -0
  75. data/vendor/actionwebservice/lib/action_web_service/version.rb +9 -0
  76. data/vendor/actionwebservice/lib/actionwebservice.rb +1 -0
  77. data/vendor/actionwebservice/setup.rb +1379 -0
  78. data/vendor/actionwebservice/test/abstract_client.rb +183 -0
  79. data/vendor/actionwebservice/test/abstract_dispatcher.rb +547 -0
  80. data/vendor/actionwebservice/test/abstract_unit.rb +33 -0
  81. data/vendor/actionwebservice/test/api_test.rb +102 -0
  82. data/vendor/actionwebservice/test/apis/auto_load_api.rb +3 -0
  83. data/vendor/actionwebservice/test/apis/broken_auto_load_api.rb +2 -0
  84. data/vendor/actionwebservice/test/base_test.rb +42 -0
  85. data/vendor/actionwebservice/test/casting_test.rb +86 -0
  86. data/vendor/actionwebservice/test/client_soap_test.rb +155 -0
  87. data/vendor/actionwebservice/test/client_xmlrpc_test.rb +153 -0
  88. data/vendor/actionwebservice/test/container_test.rb +73 -0
  89. data/vendor/actionwebservice/test/dispatcher_action_controller_soap_test.rb +137 -0
  90. data/vendor/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb +59 -0
  91. data/vendor/actionwebservice/test/fixtures/db_definitions/mysql.sql +8 -0
  92. data/vendor/actionwebservice/test/fixtures/users.yml +12 -0
  93. data/vendor/actionwebservice/test/gencov +3 -0
  94. data/vendor/actionwebservice/test/invocation_test.rb +185 -0
  95. data/vendor/actionwebservice/test/run +6 -0
  96. data/vendor/actionwebservice/test/scaffolded_controller_test.rb +146 -0
  97. data/vendor/actionwebservice/test/struct_test.rb +52 -0
  98. data/vendor/actionwebservice/test/test_invoke_test.rb +112 -0
  99. data/vendor/gems/calendar_date_select-1.15/.specification +56 -0
  100. data/vendor/gems/calendar_date_select-1.15/History.txt +237 -0
  101. data/vendor/gems/calendar_date_select-1.15/MIT-LICENSE +20 -0
  102. data/vendor/gems/calendar_date_select-1.15/Manifest.txt +42 -0
  103. data/vendor/gems/calendar_date_select-1.15/Rakefile +31 -0
  104. data/vendor/gems/calendar_date_select-1.15/Readme.txt +16 -0
  105. data/vendor/gems/calendar_date_select-1.15/init.rb +1 -0
  106. data/vendor/gems/calendar_date_select-1.15/js_test/functional/cds_test.html +334 -0
  107. data/vendor/gems/calendar_date_select-1.15/js_test/prototype.js +4184 -0
  108. data/vendor/gems/calendar_date_select-1.15/js_test/test.css +40 -0
  109. data/vendor/gems/calendar_date_select-1.15/js_test/unit/cds_helper_methods.html +46 -0
  110. data/vendor/gems/calendar_date_select-1.15/js_test/unittest.js +564 -0
  111. data/vendor/gems/calendar_date_select-1.15/lib/calendar_date_select.rb +33 -0
  112. data/vendor/gems/calendar_date_select-1.15/lib/calendar_date_select/calendar_date_select.rb +116 -0
  113. data/vendor/gems/calendar_date_select-1.15/lib/calendar_date_select/form_helpers.rb +225 -0
  114. data/vendor/gems/calendar_date_select-1.15/lib/calendar_date_select/includes_helper.rb +29 -0
  115. data/vendor/gems/calendar_date_select-1.15/public/blank_iframe.html +2 -0
  116. data/vendor/gems/calendar_date_select-1.15/public/images/calendar_date_select/calendar.gif +0 -0
  117. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/calendar_date_select.js +443 -0
  118. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/format_american.js +34 -0
  119. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/format_db.js +27 -0
  120. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/format_euro_24hr.js +7 -0
  121. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/format_euro_24hr_ymd.js +7 -0
  122. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/format_finnish.js +32 -0
  123. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/format_hyphen_ampm.js +37 -0
  124. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/format_iso_date.js +46 -0
  125. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/format_italian.js +24 -0
  126. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/locale/de.js +11 -0
  127. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/locale/fi.js +10 -0
  128. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/locale/fr.js +10 -0
  129. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/locale/pl.js +10 -0
  130. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/locale/pt.js +11 -0
  131. data/vendor/gems/calendar_date_select-1.15/public/javascripts/calendar_date_select/locale/ru.js +10 -0
  132. data/vendor/gems/calendar_date_select-1.15/public/stylesheets/calendar_date_select/blue.css +130 -0
  133. data/vendor/gems/calendar_date_select-1.15/public/stylesheets/calendar_date_select/default.css +135 -0
  134. data/vendor/gems/calendar_date_select-1.15/public/stylesheets/calendar_date_select/plain.css +128 -0
  135. data/vendor/gems/calendar_date_select-1.15/public/stylesheets/calendar_date_select/red.css +135 -0
  136. data/vendor/gems/calendar_date_select-1.15/public/stylesheets/calendar_date_select/silver.css +133 -0
  137. data/vendor/gems/calendar_date_select-1.15/spec/calendar_date_select/calendar_date_select_spec.rb +14 -0
  138. data/vendor/gems/calendar_date_select-1.15/spec/calendar_date_select/form_helpers_spec.rb +166 -0
  139. data/vendor/gems/calendar_date_select-1.15/spec/spec_helper.rb +26 -0
  140. data/vendor/gems/coderay-0.8.260/.specification +2 -1
  141. data/vendor/gems/htmlentities-4.0.0/.specification +68 -0
  142. data/vendor/gems/htmlentities-4.0.0/COPYING.txt +21 -0
  143. data/vendor/gems/htmlentities-4.0.0/History.txt +47 -0
  144. data/vendor/gems/htmlentities-4.0.0/README.txt +44 -0
  145. data/vendor/gems/htmlentities-4.0.0/lib/htmlentities.rb +165 -0
  146. data/vendor/gems/htmlentities-4.0.0/lib/htmlentities/html4.rb +257 -0
  147. data/vendor/gems/htmlentities-4.0.0/lib/htmlentities/legacy.rb +27 -0
  148. data/vendor/gems/htmlentities-4.0.0/lib/htmlentities/string.rb +26 -0
  149. data/vendor/gems/htmlentities-4.0.0/lib/htmlentities/xhtml1.rb +258 -0
  150. data/vendor/gems/htmlentities-4.0.0/test/entities_test.rb +206 -0
  151. data/vendor/gems/htmlentities-4.0.0/test/html4_test.rb +24 -0
  152. data/vendor/gems/htmlentities-4.0.0/test/legacy_test.rb +34 -0
  153. data/vendor/gems/htmlentities-4.0.0/test/roundtrip_test.rb +94 -0
  154. data/vendor/gems/htmlentities-4.0.0/test/string_test.rb +24 -0
  155. data/vendor/gems/htmlentities-4.0.0/test/test_all.rb +3 -0
  156. data/vendor/gems/htmlentities-4.0.0/test/xhtml1_test.rb +23 -0
  157. data/vendor/gems/json-1.1.3/.require_paths +4 -0
  158. data/vendor/gems/json-1.1.3/.specification +58 -0
  159. data/vendor/gems/json-1.1.3/CHANGES +93 -0
  160. data/vendor/gems/json-1.1.3/GPL +340 -0
  161. data/vendor/gems/json-1.1.3/README +78 -0
  162. data/vendor/gems/json-1.1.3/RUBY +58 -0
  163. data/vendor/gems/json-1.1.3/Rakefile +309 -0
  164. data/vendor/gems/json-1.1.3/TODO +1 -0
  165. data/vendor/gems/json-1.1.3/VERSION +1 -0
  166. data/vendor/gems/json-1.1.3/benchmarks/benchmark.txt +133 -0
  167. data/vendor/gems/json-1.1.3/benchmarks/benchmark_generator.rb +48 -0
  168. data/vendor/gems/json-1.1.3/benchmarks/benchmark_parser.rb +26 -0
  169. data/vendor/gems/json-1.1.3/benchmarks/benchmark_rails.rb +26 -0
  170. data/vendor/gems/json-1.1.3/bin/edit_json.rb +10 -0
  171. data/vendor/gems/json-1.1.3/bin/prettify_json.rb +76 -0
  172. data/vendor/gems/json-1.1.3/data/example.json +1 -0
  173. data/vendor/gems/json-1.1.3/data/index.html +38 -0
  174. data/vendor/gems/json-1.1.3/data/prototype.js +4184 -0
  175. data/vendor/gems/json-1.1.3/ext/json/ext/generator.bundle +0 -0
  176. data/vendor/gems/json-1.1.3/ext/json/ext/generator/Makefile +149 -0
  177. data/vendor/gems/json-1.1.3/ext/json/ext/generator/extconf.rb +9 -0
  178. data/vendor/gems/json-1.1.3/ext/json/ext/generator/generator.bundle +0 -0
  179. data/vendor/gems/json-1.1.3/ext/json/ext/generator/generator.c +875 -0
  180. data/vendor/gems/json-1.1.3/ext/json/ext/generator/generator.o +0 -0
  181. data/vendor/gems/json-1.1.3/ext/json/ext/generator/unicode.c +182 -0
  182. data/vendor/gems/json-1.1.3/ext/json/ext/generator/unicode.h +53 -0
  183. data/vendor/gems/json-1.1.3/ext/json/ext/generator/unicode.o +0 -0
  184. data/vendor/gems/json-1.1.3/ext/json/ext/parser.bundle +0 -0
  185. data/vendor/gems/json-1.1.3/ext/json/ext/parser/Makefile +149 -0
  186. data/vendor/gems/json-1.1.3/ext/json/ext/parser/extconf.rb +9 -0
  187. data/vendor/gems/json-1.1.3/ext/json/ext/parser/parser.bundle +0 -0
  188. data/vendor/gems/json-1.1.3/ext/json/ext/parser/parser.c +1758 -0
  189. data/vendor/gems/json-1.1.3/ext/json/ext/parser/parser.o +0 -0
  190. data/vendor/gems/json-1.1.3/ext/json/ext/parser/parser.rl +638 -0
  191. data/vendor/gems/json-1.1.3/ext/json/ext/parser/unicode.c +154 -0
  192. data/vendor/gems/json-1.1.3/ext/json/ext/parser/unicode.h +58 -0
  193. data/vendor/gems/json-1.1.3/ext/json/ext/parser/unicode.o +0 -0
  194. data/vendor/gems/json-1.1.3/install.rb +26 -0
  195. data/vendor/gems/json-1.1.3/lib/json.rb +235 -0
  196. data/vendor/gems/json-1.1.3/lib/json/Array.xpm +21 -0
  197. data/vendor/gems/json-1.1.3/lib/json/FalseClass.xpm +21 -0
  198. data/vendor/gems/json-1.1.3/lib/json/Hash.xpm +21 -0
  199. data/vendor/gems/json-1.1.3/lib/json/Key.xpm +73 -0
  200. data/vendor/gems/json-1.1.3/lib/json/NilClass.xpm +21 -0
  201. data/vendor/gems/json-1.1.3/lib/json/Numeric.xpm +28 -0
  202. data/vendor/gems/json-1.1.3/lib/json/String.xpm +96 -0
  203. data/vendor/gems/json-1.1.3/lib/json/TrueClass.xpm +21 -0
  204. data/vendor/gems/json-1.1.3/lib/json/add/core.rb +135 -0
  205. data/vendor/gems/json-1.1.3/lib/json/add/rails.rb +58 -0
  206. data/vendor/gems/json-1.1.3/lib/json/common.rb +354 -0
  207. data/vendor/gems/json-1.1.3/lib/json/editor.rb +1362 -0
  208. data/vendor/gems/json-1.1.3/lib/json/ext.rb +13 -0
  209. data/vendor/gems/json-1.1.3/lib/json/json.xpm +1499 -0
  210. data/vendor/gems/json-1.1.3/lib/json/pure.rb +75 -0
  211. data/vendor/gems/json-1.1.3/lib/json/pure/generator.rb +394 -0
  212. data/vendor/gems/json-1.1.3/lib/json/pure/parser.rb +259 -0
  213. data/vendor/gems/json-1.1.3/lib/json/version.rb +9 -0
  214. data/vendor/gems/json-1.1.3/tests/fixtures/fail1.json +1 -0
  215. data/vendor/gems/json-1.1.3/tests/fixtures/fail10.json +1 -0
  216. data/vendor/gems/json-1.1.3/tests/fixtures/fail11.json +1 -0
  217. data/vendor/gems/json-1.1.3/tests/fixtures/fail12.json +1 -0
  218. data/vendor/gems/json-1.1.3/tests/fixtures/fail13.json +1 -0
  219. data/vendor/gems/json-1.1.3/tests/fixtures/fail14.json +1 -0
  220. data/vendor/gems/json-1.1.3/tests/fixtures/fail18.json +1 -0
  221. data/vendor/gems/json-1.1.3/tests/fixtures/fail19.json +1 -0
  222. data/vendor/gems/json-1.1.3/tests/fixtures/fail2.json +1 -0
  223. data/vendor/gems/json-1.1.3/tests/fixtures/fail20.json +1 -0
  224. data/vendor/gems/json-1.1.3/tests/fixtures/fail21.json +1 -0
  225. data/vendor/gems/json-1.1.3/tests/fixtures/fail22.json +1 -0
  226. data/vendor/gems/json-1.1.3/tests/fixtures/fail23.json +1 -0
  227. data/vendor/gems/json-1.1.3/tests/fixtures/fail24.json +1 -0
  228. data/vendor/gems/json-1.1.3/tests/fixtures/fail25.json +1 -0
  229. data/vendor/gems/json-1.1.3/tests/fixtures/fail27.json +2 -0
  230. data/vendor/gems/json-1.1.3/tests/fixtures/fail28.json +2 -0
  231. data/vendor/gems/json-1.1.3/tests/fixtures/fail3.json +1 -0
  232. data/vendor/gems/json-1.1.3/tests/fixtures/fail4.json +1 -0
  233. data/vendor/gems/json-1.1.3/tests/fixtures/fail5.json +1 -0
  234. data/vendor/gems/json-1.1.3/tests/fixtures/fail6.json +1 -0
  235. data/vendor/gems/json-1.1.3/tests/fixtures/fail7.json +1 -0
  236. data/vendor/gems/json-1.1.3/tests/fixtures/fail8.json +1 -0
  237. data/vendor/gems/json-1.1.3/tests/fixtures/fail9.json +1 -0
  238. data/vendor/gems/json-1.1.3/tests/fixtures/pass1.json +56 -0
  239. data/vendor/gems/json-1.1.3/tests/fixtures/pass15.json +1 -0
  240. data/vendor/gems/json-1.1.3/tests/fixtures/pass16.json +1 -0
  241. data/vendor/gems/json-1.1.3/tests/fixtures/pass17.json +1 -0
  242. data/vendor/gems/json-1.1.3/tests/fixtures/pass2.json +1 -0
  243. data/vendor/gems/json-1.1.3/tests/fixtures/pass26.json +1 -0
  244. data/vendor/gems/json-1.1.3/tests/fixtures/pass3.json +6 -0
  245. data/vendor/gems/json-1.1.3/tests/runner.rb +25 -0
  246. data/vendor/gems/json-1.1.3/tests/test_json.rb +293 -0
  247. data/vendor/gems/json-1.1.3/tests/test_json_addition.rb +161 -0
  248. data/vendor/gems/json-1.1.3/tests/test_json_fixtures.rb +30 -0
  249. data/vendor/gems/json-1.1.3/tests/test_json_generate.rb +100 -0
  250. data/vendor/gems/json-1.1.3/tests/test_json_rails.rb +118 -0
  251. data/vendor/gems/json-1.1.3/tests/test_json_unicode.rb +61 -0
  252. data/vendor/gems/json-1.1.3/tools/fuzz.rb +140 -0
  253. data/vendor/gems/json-1.1.3/tools/server.rb +62 -0
  254. data/vendor/plugins/localization/bin/make_language.rb +2 -2
  255. data/vendor/plugins/localization/lib/localization.rb +2 -2
  256. data/vendor/plugins/will_paginate/CHANGELOG.rdoc +110 -0
  257. data/vendor/plugins/will_paginate/LICENSE +18 -0
  258. data/vendor/plugins/will_paginate/README.rdoc +107 -0
  259. data/vendor/plugins/will_paginate/Rakefile +62 -0
  260. data/vendor/plugins/will_paginate/examples/apple-circle.gif +0 -0
  261. data/vendor/plugins/will_paginate/examples/index.haml +69 -0
  262. data/vendor/plugins/will_paginate/examples/index.html +92 -0
  263. data/vendor/plugins/will_paginate/examples/pagination.css +90 -0
  264. data/vendor/plugins/will_paginate/examples/pagination.sass +91 -0
  265. data/vendor/plugins/will_paginate/init.rb +1 -0
  266. data/vendor/plugins/will_paginate/lib/will_paginate.rb +82 -0
  267. data/vendor/plugins/will_paginate/lib/will_paginate/array.rb +16 -0
  268. data/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +146 -0
  269. data/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +32 -0
  270. data/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +260 -0
  271. data/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb +170 -0
  272. data/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb +37 -0
  273. data/vendor/plugins/will_paginate/lib/will_paginate/version.rb +9 -0
  274. data/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +383 -0
  275. data/vendor/plugins/will_paginate/test/boot.rb +21 -0
  276. data/vendor/plugins/will_paginate/test/collection_test.rb +143 -0
  277. data/vendor/plugins/will_paginate/test/console +8 -0
  278. data/vendor/plugins/will_paginate/test/database.yml +22 -0
  279. data/vendor/plugins/will_paginate/test/finder_test.rb +476 -0
  280. data/vendor/plugins/will_paginate/test/fixtures/admin.rb +3 -0
  281. data/vendor/plugins/will_paginate/test/fixtures/developer.rb +14 -0
  282. data/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +13 -0
  283. data/vendor/plugins/will_paginate/test/fixtures/project.rb +15 -0
  284. data/vendor/plugins/will_paginate/test/fixtures/projects.yml +6 -0
  285. data/vendor/plugins/will_paginate/test/fixtures/replies.yml +29 -0
  286. data/vendor/plugins/will_paginate/test/fixtures/reply.rb +7 -0
  287. data/vendor/plugins/will_paginate/test/fixtures/schema.rb +38 -0
  288. data/vendor/plugins/will_paginate/test/fixtures/topic.rb +10 -0
  289. data/vendor/plugins/will_paginate/test/fixtures/topics.yml +30 -0
  290. data/vendor/plugins/will_paginate/test/fixtures/user.rb +2 -0
  291. data/vendor/plugins/will_paginate/test/fixtures/users.yml +35 -0
  292. data/vendor/plugins/will_paginate/test/helper.rb +37 -0
  293. data/vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb +36 -0
  294. data/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb +73 -0
  295. data/vendor/plugins/will_paginate/test/lib/load_fixtures.rb +11 -0
  296. data/vendor/plugins/will_paginate/test/lib/view_test_process.rb +165 -0
  297. data/vendor/plugins/will_paginate/test/tasks.rake +59 -0
  298. data/vendor/plugins/will_paginate/test/view_test.rb +363 -0
  299. data/vendor/plugins/will_paginate/will_paginate.gemspec +22 -0
  300. data/vendor/plugins/xml_sidebar/lib/xml_sidebar.rb +1 -1
  301. metadata +349 -16
  302. data/migrate.txt +0 -142
@@ -0,0 +1,149 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = .
7
+ topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+ prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
11
+ exec_prefix = $(prefix)
12
+ sitedir = $(DESTDIR)/Library/Ruby/Site
13
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
14
+ docdir = $(datarootdir)/doc/$(PACKAGE)
15
+ dvidir = $(docdir)
16
+ datarootdir = $(prefix)/share
17
+ archdir = $(rubylibdir)/$(arch)
18
+ sbindir = $(exec_prefix)/sbin
19
+ psdir = $(docdir)
20
+ localedir = $(datarootdir)/locale
21
+ htmldir = $(docdir)
22
+ datadir = $(datarootdir)
23
+ includedir = $(prefix)/include
24
+ infodir = $(DESTDIR)/usr/share/info
25
+ sysconfdir = $(prefix)/etc
26
+ mandir = $(DESTDIR)/usr/share/man
27
+ libdir = $(exec_prefix)/lib
28
+ sharedstatedir = $(prefix)/com
29
+ oldincludedir = $(DESTDIR)/usr/include
30
+ pdfdir = $(docdir)
31
+ sitearchdir = $(sitelibdir)/$(sitearch)
32
+ bindir = $(exec_prefix)/bin
33
+ localstatedir = $(prefix)/var
34
+ sitelibdir = $(sitedir)/$(ruby_version)
35
+ libexecdir = $(exec_prefix)/libexec
36
+
37
+ CC = gcc
38
+ LIBRUBY = $(LIBRUBY_SO)
39
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
40
+ LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
41
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)
42
+
43
+ RUBY_EXTCONF_H =
44
+ CFLAGS = -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -Wall
45
+ INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
46
+ CPPFLAGS =
47
+ CXXFLAGS = $(CFLAGS)
48
+ DLDFLAGS = -L. -arch ppc -arch i386
49
+ LDSHARED = cc -arch ppc -arch i386 -pipe -bundle -undefined dynamic_lookup
50
+ AR = ar
51
+ EXEEXT =
52
+
53
+ RUBY_INSTALL_NAME = ruby
54
+ RUBY_SO_NAME = ruby
55
+ arch = universal-darwin9.0
56
+ sitearch = universal-darwin9.0
57
+ ruby_version = 1.8
58
+ ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
59
+ RUBY = $(ruby)
60
+ RM = rm -f
61
+ MAKEDIRS = mkdir -p
62
+ INSTALL = /usr/bin/install -c
63
+ INSTALL_PROG = $(INSTALL) -m 0755
64
+ INSTALL_DATA = $(INSTALL) -m 644
65
+ COPY = cp
66
+
67
+ #### End of system configuration section. ####
68
+
69
+ preload =
70
+
71
+ libpath = . $(libdir)
72
+ LIBPATH = -L"." -L"$(libdir)"
73
+ DEFFILE =
74
+
75
+ CLEANFILES = mkmf.log
76
+ DISTCLEANFILES =
77
+
78
+ extout =
79
+ extout_prefix =
80
+ target_prefix =
81
+ LOCAL_LIBS =
82
+ LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lm
83
+ SRCS = generator.c unicode.c
84
+ OBJS = generator.o unicode.o
85
+ TARGET = generator
86
+ DLLIB = $(TARGET).bundle
87
+ EXTSTATIC =
88
+ STATIC_LIB =
89
+
90
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
91
+ RUBYLIBDIR = /Users/neuro/Documents/code/typo/master/vendor/gems/gems/json-1.1.3/ext/json/ext$(target_prefix)
92
+ RUBYARCHDIR = /Users/neuro/Documents/code/typo/master/vendor/gems/gems/json-1.1.3/ext/json/ext$(target_prefix)
93
+
94
+ TARGET_SO = $(DLLIB)
95
+ CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
96
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
97
+
98
+ all: $(DLLIB)
99
+ static: $(STATIC_LIB)
100
+
101
+ clean:
102
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
103
+
104
+ distclean: clean
105
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
106
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
107
+
108
+ realclean: distclean
109
+ install: install-so install-rb
110
+
111
+ install-so: $(RUBYARCHDIR)
112
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
113
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
114
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
115
+ install-rb: pre-install-rb install-rb-default
116
+ install-rb-default: pre-install-rb-default
117
+ pre-install-rb: Makefile
118
+ pre-install-rb-default: Makefile
119
+ $(RUBYARCHDIR):
120
+ $(MAKEDIRS) $@
121
+
122
+ site-install: site-install-so site-install-rb
123
+ site-install-so: install-so
124
+ site-install-rb: install-rb
125
+
126
+ .SUFFIXES: .c .m .cc .cxx .cpp .C .o
127
+
128
+ .cc.o:
129
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
130
+
131
+ .cxx.o:
132
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
133
+
134
+ .cpp.o:
135
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
136
+
137
+ .C.o:
138
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
139
+
140
+ .c.o:
141
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
142
+
143
+ $(DLLIB): $(OBJS)
144
+ @-$(RM) $@
145
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
146
+
147
+
148
+
149
+ $(OBJS): ruby.h defines.h
@@ -0,0 +1,9 @@
1
+ require 'mkmf'
2
+ require 'rbconfig'
3
+
4
+ if CONFIG['CC'] =~ /gcc/
5
+ $CFLAGS += ' -Wall'
6
+ #$CFLAGS += ' -O0 -ggdb'
7
+ end
8
+
9
+ create_makefile 'generator'
@@ -0,0 +1,875 @@
1
+ #include <string.h>
2
+ #include "ruby.h"
3
+ #include "st.h"
4
+ #include "unicode.h"
5
+ #include <math.h>
6
+
7
+ #define check_max_nesting(state, depth) do { \
8
+ long current_nesting = 1 + depth; \
9
+ if (state->max_nesting != 0 && current_nesting > state->max_nesting) \
10
+ rb_raise(eNestingError, "nesting of %ld is too deep", current_nesting); \
11
+ } while (0);
12
+
13
+ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
14
+ mHash, mArray, mInteger, mFloat, mString, mString_Extend,
15
+ mTrueClass, mFalseClass, mNilClass, eGeneratorError,
16
+ eCircularDatastructure, eNestingError;
17
+
18
+ static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
19
+ i_object_nl, i_array_nl, i_check_circular, i_max_nesting,
20
+ i_allow_nan, i_pack, i_unpack, i_create_id, i_extend;
21
+
22
+ typedef struct JSON_Generator_StateStruct {
23
+ VALUE indent;
24
+ VALUE space;
25
+ VALUE space_before;
26
+ VALUE object_nl;
27
+ VALUE array_nl;
28
+ int check_circular;
29
+ VALUE seen;
30
+ VALUE memo;
31
+ VALUE depth;
32
+ long max_nesting;
33
+ int flag;
34
+ int allow_nan;
35
+ } JSON_Generator_State;
36
+
37
+ #define GET_STATE(self) \
38
+ JSON_Generator_State *state; \
39
+ Data_Get_Struct(self, JSON_Generator_State, state);
40
+
41
+ /*
42
+ * Document-module: JSON::Ext::Generator
43
+ *
44
+ * This is the JSON generator implemented as a C extension. It can be
45
+ * configured to be used by setting
46
+ *
47
+ * JSON.generator = JSON::Ext::Generator
48
+ *
49
+ * with the method generator= in JSON.
50
+ *
51
+ */
52
+
53
+ static int hash_to_json_state_i(VALUE key, VALUE value, VALUE Vstate)
54
+ {
55
+ VALUE json, buf, Vdepth;
56
+ GET_STATE(Vstate);
57
+ buf = state->memo;
58
+ Vdepth = state->depth;
59
+
60
+ if (key == Qundef) return ST_CONTINUE;
61
+ if (state->flag) {
62
+ state->flag = 0;
63
+ rb_str_buf_cat2(buf, ",");
64
+ if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(buf, state->object_nl);
65
+ }
66
+ if (RSTRING_LEN(state->object_nl)) {
67
+ rb_str_buf_append(buf, rb_str_times(state->indent, Vdepth));
68
+ }
69
+ json = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 2, Vstate, Vdepth);
70
+ Check_Type(json, T_STRING);
71
+ rb_str_buf_append(buf, json);
72
+ OBJ_INFECT(buf, json);
73
+ if (RSTRING_LEN(state->space_before)) {
74
+ rb_str_buf_append(buf, state->space_before);
75
+ }
76
+ rb_str_buf_cat2(buf, ":");
77
+ if (RSTRING_LEN(state->space)) rb_str_buf_append(buf, state->space);
78
+ json = rb_funcall(value, i_to_json, 2, Vstate, Vdepth);
79
+ Check_Type(json, T_STRING);
80
+ state->flag = 1;
81
+ rb_str_buf_append(buf, json);
82
+ OBJ_INFECT(buf, json);
83
+ state->depth = Vdepth;
84
+ state->memo = buf;
85
+ return ST_CONTINUE;
86
+ }
87
+
88
+ inline static VALUE mHash_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
89
+ long depth, len = RHASH(self)->tbl->num_entries;
90
+ VALUE result;
91
+ GET_STATE(Vstate);
92
+
93
+ depth = 1 + FIX2LONG(Vdepth);
94
+ result = rb_str_buf_new(len);
95
+ state->memo = result;
96
+ state->depth = LONG2FIX(depth);
97
+ state->flag = 0;
98
+ rb_str_buf_cat2(result, "{");
99
+ if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(result, state->object_nl);
100
+ rb_hash_foreach(self, hash_to_json_state_i, Vstate);
101
+ if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(result, state->object_nl);
102
+ if (RSTRING_LEN(state->object_nl)) {
103
+ rb_str_buf_append(result, rb_str_times(state->indent, Vdepth));
104
+ }
105
+ rb_str_buf_cat2(result, "}");
106
+ return result;
107
+ }
108
+
109
+ static int hash_to_json_i(VALUE key, VALUE value, VALUE buf)
110
+ {
111
+ VALUE tmp;
112
+
113
+ if (key == Qundef) return ST_CONTINUE;
114
+ if (RSTRING_LEN(buf) > 1) rb_str_buf_cat2(buf, ",");
115
+ tmp = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 0);
116
+ Check_Type(tmp, T_STRING);
117
+ rb_str_buf_append(buf, tmp);
118
+ OBJ_INFECT(buf, tmp);
119
+ rb_str_buf_cat2(buf, ":");
120
+ tmp = rb_funcall(value, i_to_json, 0);
121
+ Check_Type(tmp, T_STRING);
122
+ rb_str_buf_append(buf, tmp);
123
+ OBJ_INFECT(buf, tmp);
124
+
125
+ return ST_CONTINUE;
126
+ }
127
+
128
+ /*
129
+ * call-seq: to_json(state = nil, depth = 0)
130
+ *
131
+ * Returns a JSON string containing a JSON object, that is unparsed from
132
+ * this Hash instance.
133
+ * _state_ is a JSON::State object, that can also be used to configure the
134
+ * produced JSON string output further.
135
+ * _depth_ is used to find out nesting depth, to indent accordingly.
136
+ */
137
+ static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
138
+ {
139
+ VALUE Vstate, Vdepth, result;
140
+ long depth;
141
+
142
+ rb_scan_args(argc, argv, "02", &Vstate, &Vdepth);
143
+ depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
144
+ if (NIL_P(Vstate)) {
145
+ long len = RHASH(self)->tbl->num_entries;
146
+ result = rb_str_buf_new(len);
147
+ rb_str_buf_cat2(result, "{");
148
+ rb_hash_foreach(self, hash_to_json_i, result);
149
+ rb_str_buf_cat2(result, "}");
150
+ } else {
151
+ GET_STATE(Vstate);
152
+ check_max_nesting(state, depth);
153
+ if (state->check_circular) {
154
+ VALUE self_id = rb_obj_id(self);
155
+ if (RTEST(rb_hash_aref(state->seen, self_id))) {
156
+ rb_raise(eCircularDatastructure,
157
+ "circular data structures not supported!");
158
+ }
159
+ rb_hash_aset(state->seen, self_id, Qtrue);
160
+ result = mHash_json_transfrom(self, Vstate, LONG2FIX(depth));
161
+ rb_hash_delete(state->seen, self_id);
162
+ } else {
163
+ result = mHash_json_transfrom(self, Vstate, LONG2FIX(depth));
164
+ }
165
+ }
166
+ OBJ_INFECT(result, self);
167
+ return result;
168
+ }
169
+
170
+ inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
171
+ long i, len = RARRAY_LEN(self);
172
+ VALUE shift, result;
173
+ long depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
174
+ VALUE delim = rb_str_new2(",");
175
+ GET_STATE(Vstate);
176
+
177
+ check_max_nesting(state, depth);
178
+ if (state->check_circular) {
179
+ VALUE self_id = rb_obj_id(self);
180
+ rb_hash_aset(state->seen, self_id, Qtrue);
181
+ result = rb_str_buf_new(len);
182
+ if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
183
+ shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
184
+
185
+ rb_str_buf_cat2(result, "[");
186
+ OBJ_INFECT(result, self);
187
+ rb_str_buf_append(result, state->array_nl);
188
+ for (i = 0; i < len; i++) {
189
+ VALUE element = RARRAY_PTR(self)[i];
190
+ if (RTEST(rb_hash_aref(state->seen, rb_obj_id(element)))) {
191
+ rb_raise(eCircularDatastructure,
192
+ "circular data structures not supported!");
193
+ }
194
+ OBJ_INFECT(result, element);
195
+ if (i > 0) rb_str_buf_append(result, delim);
196
+ rb_str_buf_append(result, shift);
197
+ element = rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1));
198
+ Check_Type(element, T_STRING);
199
+ rb_str_buf_append(result, element);
200
+ }
201
+ if (RSTRING_LEN(state->array_nl)) {
202
+ rb_str_buf_append(result, state->array_nl);
203
+ rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
204
+ }
205
+ rb_str_buf_cat2(result, "]");
206
+ rb_hash_delete(state->seen, self_id);
207
+ } else {
208
+ result = rb_str_buf_new(len);
209
+ OBJ_INFECT(result, self);
210
+ if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
211
+ shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
212
+
213
+ rb_str_buf_cat2(result, "[");
214
+ rb_str_buf_append(result, state->array_nl);
215
+ for (i = 0; i < len; i++) {
216
+ VALUE element = RARRAY_PTR(self)[i];
217
+ OBJ_INFECT(result, element);
218
+ if (i > 0) rb_str_buf_append(result, delim);
219
+ rb_str_buf_append(result, shift);
220
+ element = rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1));
221
+ Check_Type(element, T_STRING);
222
+ rb_str_buf_append(result, element);
223
+ }
224
+ rb_str_buf_append(result, state->array_nl);
225
+ if (RSTRING_LEN(state->array_nl)) {
226
+ rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
227
+ }
228
+ rb_str_buf_cat2(result, "]");
229
+ }
230
+ return result;
231
+ }
232
+
233
+ /*
234
+ * call-seq: to_json(state = nil, depth = 0)
235
+ *
236
+ * Returns a JSON string containing a JSON array, that is unparsed from
237
+ * this Array instance.
238
+ * _state_ is a JSON::State object, that can also be used to configure the
239
+ * produced JSON string output further.
240
+ * _depth_ is used to find out nesting depth, to indent accordingly.
241
+ */
242
+ static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
243
+ VALUE Vstate, Vdepth, result;
244
+
245
+ rb_scan_args(argc, argv, "02", &Vstate, &Vdepth);
246
+ if (NIL_P(Vstate)) {
247
+ long i, len = RARRAY_LEN(self);
248
+ result = rb_str_buf_new(2 + 2 * len);
249
+ rb_str_buf_cat2(result, "[");
250
+ OBJ_INFECT(result, self);
251
+ for (i = 0; i < len; i++) {
252
+ VALUE element = RARRAY_PTR(self)[i];
253
+ OBJ_INFECT(result, element);
254
+ if (i > 0) rb_str_buf_cat2(result, ",");
255
+ element = rb_funcall(element, i_to_json, 0);
256
+ Check_Type(element, T_STRING);
257
+ rb_str_buf_append(result, element);
258
+ }
259
+ rb_str_buf_cat2(result, "]");
260
+ } else {
261
+ result = mArray_json_transfrom(self, Vstate, Vdepth);
262
+ }
263
+ OBJ_INFECT(result, self);
264
+ return result;
265
+ }
266
+
267
+ /*
268
+ * call-seq: to_json(*)
269
+ *
270
+ * Returns a JSON string representation for this Integer number.
271
+ */
272
+ static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self)
273
+ {
274
+ return rb_funcall(self, i_to_s, 0);
275
+ }
276
+
277
+ /*
278
+ * call-seq: to_json(*)
279
+ *
280
+ * Returns a JSON string representation for this Float number.
281
+ */
282
+ static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
283
+ {
284
+ JSON_Generator_State *state = NULL;
285
+ VALUE Vstate, rest, tmp;
286
+ double value = RFLOAT(self)->value;
287
+ rb_scan_args(argc, argv, "01*", &Vstate, &rest);
288
+ if (!NIL_P(Vstate)) Data_Get_Struct(Vstate, JSON_Generator_State, state);
289
+ if (isinf(value)) {
290
+ if (!state || state->allow_nan) {
291
+ return rb_funcall(self, i_to_s, 0);
292
+ } else {
293
+ tmp = rb_funcall(self, i_to_s, 0);
294
+ rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
295
+ }
296
+ } else if (isnan(value)) {
297
+ if (!state || state->allow_nan) {
298
+ return rb_funcall(self, i_to_s, 0);
299
+ } else {
300
+ tmp = rb_funcall(self, i_to_s, 0);
301
+ rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
302
+ }
303
+ } else {
304
+ return rb_funcall(self, i_to_s, 0);
305
+ }
306
+ }
307
+
308
+ /*
309
+ * call-seq: String.included(modul)
310
+ *
311
+ * Extends _modul_ with the String::Extend module.
312
+ */
313
+ static VALUE mString_included_s(VALUE self, VALUE modul) {
314
+ return rb_funcall(modul, i_extend, 1, mString_Extend);
315
+ }
316
+
317
+ /*
318
+ * call-seq: to_json(*)
319
+ *
320
+ * This string should be encoded with UTF-8 A call to this method
321
+ * returns a JSON string encoded with UTF16 big endian characters as
322
+ * \u????.
323
+ */
324
+ static VALUE mString_to_json(int argc, VALUE *argv, VALUE self)
325
+ {
326
+ VALUE result = rb_str_buf_new(RSTRING_LEN(self));
327
+ rb_str_buf_cat2(result, "\"");
328
+ JSON_convert_UTF8_to_JSON(result, self, strictConversion);
329
+ rb_str_buf_cat2(result, "\"");
330
+ return result;
331
+ }
332
+
333
+ /*
334
+ * call-seq: to_json_raw_object()
335
+ *
336
+ * This method creates a raw object hash, that can be nested into
337
+ * other data structures and will be unparsed as a raw string. This
338
+ * method should be used, if you want to convert raw strings to JSON
339
+ * instead of UTF-8 strings, e. g. binary data.
340
+ */
341
+ static VALUE mString_to_json_raw_object(VALUE self) {
342
+ VALUE ary;
343
+ VALUE result = rb_hash_new();
344
+ rb_hash_aset(result, rb_funcall(mJSON, i_create_id, 0), rb_class_name(rb_obj_class(self)));
345
+ ary = rb_funcall(self, i_unpack, 1, rb_str_new2("C*"));
346
+ rb_hash_aset(result, rb_str_new2("raw"), ary);
347
+ return result;
348
+ }
349
+
350
+ /*
351
+ * call-seq: to_json_raw(*args)
352
+ *
353
+ * This method creates a JSON text from the result of a call to
354
+ * to_json_raw_object of this String.
355
+ */
356
+ static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self) {
357
+ VALUE obj = mString_to_json_raw_object(self);
358
+ Check_Type(obj, T_HASH);
359
+ return mHash_to_json(argc, argv, obj);
360
+ }
361
+
362
+ /*
363
+ * call-seq: json_create(o)
364
+ *
365
+ * Raw Strings are JSON Objects (the raw bytes are stored in an array for the
366
+ * key "raw"). The Ruby String can be created by this module method.
367
+ */
368
+ static VALUE mString_Extend_json_create(VALUE self, VALUE o) {
369
+ VALUE ary;
370
+ Check_Type(o, T_HASH);
371
+ ary = rb_hash_aref(o, rb_str_new2("raw"));
372
+ return rb_funcall(ary, i_pack, 1, rb_str_new2("C*"));
373
+ }
374
+
375
+ /*
376
+ * call-seq: to_json(state = nil, depth = 0)
377
+ *
378
+ * Returns a JSON string for true: 'true'.
379
+ */
380
+ static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self)
381
+ {
382
+ return rb_str_new2("true");
383
+ }
384
+
385
+ /*
386
+ * call-seq: to_json(state = nil, depth = 0)
387
+ *
388
+ * Returns a JSON string for false: 'false'.
389
+ */
390
+ static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self)
391
+ {
392
+ return rb_str_new2("false");
393
+ }
394
+
395
+ /*
396
+ * call-seq: to_json(state = nil, depth = 0)
397
+ *
398
+ */
399
+ static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self)
400
+ {
401
+ return rb_str_new2("null");
402
+ }
403
+
404
+ /*
405
+ * call-seq: to_json(*)
406
+ *
407
+ * Converts this object to a string (calling #to_s), converts
408
+ * it to a JSON string, and returns the result. This is a fallback, if no
409
+ * special method #to_json was defined for some object.
410
+ */
411
+ static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self)
412
+ {
413
+ VALUE string = rb_funcall(self, i_to_s, 0);
414
+ Check_Type(string, T_STRING);
415
+ return mString_to_json(argc, argv, string);
416
+ }
417
+
418
+ /*
419
+ * Document-class: JSON::Ext::Generator::State
420
+ *
421
+ * This class is used to create State instances, that are use to hold data
422
+ * while generating a JSON text from a a Ruby data structure.
423
+ */
424
+
425
+ static void State_mark(JSON_Generator_State *state)
426
+ {
427
+ rb_gc_mark_maybe(state->indent);
428
+ rb_gc_mark_maybe(state->space);
429
+ rb_gc_mark_maybe(state->space_before);
430
+ rb_gc_mark_maybe(state->object_nl);
431
+ rb_gc_mark_maybe(state->array_nl);
432
+ rb_gc_mark_maybe(state->seen);
433
+ rb_gc_mark_maybe(state->memo);
434
+ rb_gc_mark_maybe(state->depth);
435
+ }
436
+
437
+ static JSON_Generator_State *State_allocate()
438
+ {
439
+ JSON_Generator_State *state = ALLOC(JSON_Generator_State);
440
+ return state;
441
+ }
442
+
443
+ static VALUE cState_s_allocate(VALUE klass)
444
+ {
445
+ JSON_Generator_State *state = State_allocate();
446
+ return Data_Wrap_Struct(klass, State_mark, -1, state);
447
+ }
448
+
449
+ /*
450
+ * call-seq: configure(opts)
451
+ *
452
+ * Configure this State instance with the Hash _opts_, and return
453
+ * itself.
454
+ */
455
+ static inline VALUE cState_configure(VALUE self, VALUE opts)
456
+ {
457
+ VALUE tmp;
458
+ GET_STATE(self);
459
+ tmp = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
460
+ if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h");
461
+ if (NIL_P(tmp)) {
462
+ rb_raise(rb_eArgError, "opts has to be hash like or convertable into a hash");
463
+ }
464
+ opts = tmp;
465
+ tmp = rb_hash_aref(opts, ID2SYM(i_indent));
466
+ if (RTEST(tmp)) {
467
+ Check_Type(tmp, T_STRING);
468
+ state->indent = tmp;
469
+ }
470
+ tmp = rb_hash_aref(opts, ID2SYM(i_space));
471
+ if (RTEST(tmp)) {
472
+ Check_Type(tmp, T_STRING);
473
+ state->space = tmp;
474
+ }
475
+ tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
476
+ if (RTEST(tmp)) {
477
+ Check_Type(tmp, T_STRING);
478
+ state->space_before = tmp;
479
+ }
480
+ tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
481
+ if (RTEST(tmp)) {
482
+ Check_Type(tmp, T_STRING);
483
+ state->array_nl = tmp;
484
+ }
485
+ tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
486
+ if (RTEST(tmp)) {
487
+ Check_Type(tmp, T_STRING);
488
+ state->object_nl = tmp;
489
+ }
490
+ tmp = ID2SYM(i_check_circular);
491
+ if (st_lookup(RHASH(opts)->tbl, tmp, 0)) {
492
+ tmp = rb_hash_aref(opts, ID2SYM(i_check_circular));
493
+ state->check_circular = RTEST(tmp);
494
+ } else {
495
+ state->check_circular = 1;
496
+ }
497
+ tmp = ID2SYM(i_max_nesting);
498
+ state->max_nesting = 19;
499
+ if (st_lookup(RHASH(opts)->tbl, tmp, 0)) {
500
+ VALUE max_nesting = rb_hash_aref(opts, tmp);
501
+ if (RTEST(max_nesting)) {
502
+ Check_Type(max_nesting, T_FIXNUM);
503
+ state->max_nesting = FIX2LONG(max_nesting);
504
+ } else {
505
+ state->max_nesting = 0;
506
+ }
507
+ }
508
+ tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan));
509
+ state->allow_nan = RTEST(tmp);
510
+ return self;
511
+ }
512
+
513
+ /*
514
+ * call-seq: to_h
515
+ *
516
+ * Returns the configuration instance variables as a hash, that can be
517
+ * passed to the configure method.
518
+ */
519
+ static VALUE cState_to_h(VALUE self)
520
+ {
521
+ VALUE result = rb_hash_new();
522
+ GET_STATE(self);
523
+ rb_hash_aset(result, ID2SYM(i_indent), state->indent);
524
+ rb_hash_aset(result, ID2SYM(i_space), state->space);
525
+ rb_hash_aset(result, ID2SYM(i_space_before), state->space_before);
526
+ rb_hash_aset(result, ID2SYM(i_object_nl), state->object_nl);
527
+ rb_hash_aset(result, ID2SYM(i_array_nl), state->array_nl);
528
+ rb_hash_aset(result, ID2SYM(i_check_circular), state->check_circular ? Qtrue : Qfalse);
529
+ rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
530
+ rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
531
+ return result;
532
+ }
533
+
534
+
535
+ /*
536
+ * call-seq: new(opts = {})
537
+ *
538
+ * Instantiates a new State object, configured by _opts_.
539
+ *
540
+ * _opts_ can have the following keys:
541
+ *
542
+ * * *indent*: a string used to indent levels (default: ''),
543
+ * * *space*: a string that is put after, a : or , delimiter (default: ''),
544
+ * * *space_before*: a string that is put before a : pair delimiter (default: ''),
545
+ * * *object_nl*: a string that is put at the end of a JSON object (default: ''),
546
+ * * *array_nl*: a string that is put at the end of a JSON array (default: ''),
547
+ * * *check_circular*: true if checking for circular data structures
548
+ * should be done, false (the default) otherwise.
549
+ * * *allow_nan*: true if NaN, Infinity, and -Infinity should be
550
+ * generated, otherwise an exception is thrown, if these values are
551
+ * encountered. This options defaults to false.
552
+ */
553
+ static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
554
+ {
555
+ VALUE opts;
556
+ GET_STATE(self);
557
+
558
+ rb_scan_args(argc, argv, "01", &opts);
559
+ state->indent = rb_str_new2("");
560
+ state->space = rb_str_new2("");
561
+ state->space_before = rb_str_new2("");
562
+ state->array_nl = rb_str_new2("");
563
+ state->object_nl = rb_str_new2("");
564
+ if (NIL_P(opts)) {
565
+ state->check_circular = 1;
566
+ state->allow_nan = 0;
567
+ state->max_nesting = 19;
568
+ } else {
569
+ cState_configure(self, opts);
570
+ }
571
+ state->seen = rb_hash_new();
572
+ state->memo = Qnil;
573
+ state->depth = INT2FIX(0);
574
+ return self;
575
+ }
576
+
577
+ /*
578
+ * call-seq: from_state(opts)
579
+ *
580
+ * Creates a State object from _opts_, which ought to be Hash to create a
581
+ * new State instance configured by _opts_, something else to create an
582
+ * unconfigured instance. If _opts_ is a State object, it is just returned.
583
+ */
584
+ static VALUE cState_from_state_s(VALUE self, VALUE opts)
585
+ {
586
+ if (rb_obj_is_kind_of(opts, self)) {
587
+ return opts;
588
+ } else if (rb_obj_is_kind_of(opts, rb_cHash)) {
589
+ return rb_funcall(self, i_new, 1, opts);
590
+ } else {
591
+ return rb_funcall(self, i_new, 0);
592
+ }
593
+ }
594
+
595
+ /*
596
+ * call-seq: indent()
597
+ *
598
+ * This string is used to indent levels in the JSON text.
599
+ */
600
+ static VALUE cState_indent(VALUE self)
601
+ {
602
+ GET_STATE(self);
603
+ return state->indent;
604
+ }
605
+
606
+ /*
607
+ * call-seq: indent=(indent)
608
+ *
609
+ * This string is used to indent levels in the JSON text.
610
+ */
611
+ static VALUE cState_indent_set(VALUE self, VALUE indent)
612
+ {
613
+ GET_STATE(self);
614
+ Check_Type(indent, T_STRING);
615
+ return state->indent = indent;
616
+ }
617
+
618
+ /*
619
+ * call-seq: space()
620
+ *
621
+ * This string is used to insert a space between the tokens in a JSON
622
+ * string.
623
+ */
624
+ static VALUE cState_space(VALUE self)
625
+ {
626
+ GET_STATE(self);
627
+ return state->space;
628
+ }
629
+
630
+ /*
631
+ * call-seq: space=(space)
632
+ *
633
+ * This string is used to insert a space between the tokens in a JSON
634
+ * string.
635
+ */
636
+ static VALUE cState_space_set(VALUE self, VALUE space)
637
+ {
638
+ GET_STATE(self);
639
+ Check_Type(space, T_STRING);
640
+ return state->space = space;
641
+ }
642
+
643
+ /*
644
+ * call-seq: space_before()
645
+ *
646
+ * This string is used to insert a space before the ':' in JSON objects.
647
+ */
648
+ static VALUE cState_space_before(VALUE self)
649
+ {
650
+ GET_STATE(self);
651
+ return state->space_before;
652
+ }
653
+
654
+ /*
655
+ * call-seq: space_before=(space_before)
656
+ *
657
+ * This string is used to insert a space before the ':' in JSON objects.
658
+ */
659
+ static VALUE cState_space_before_set(VALUE self, VALUE space_before)
660
+ {
661
+ GET_STATE(self);
662
+ Check_Type(space_before, T_STRING);
663
+ return state->space_before = space_before;
664
+ }
665
+
666
+ /*
667
+ * call-seq: object_nl()
668
+ *
669
+ * This string is put at the end of a line that holds a JSON object (or
670
+ * Hash).
671
+ */
672
+ static VALUE cState_object_nl(VALUE self)
673
+ {
674
+ GET_STATE(self);
675
+ return state->object_nl;
676
+ }
677
+
678
+ /*
679
+ * call-seq: object_nl=(object_nl)
680
+ *
681
+ * This string is put at the end of a line that holds a JSON object (or
682
+ * Hash).
683
+ */
684
+ static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
685
+ {
686
+ GET_STATE(self);
687
+ Check_Type(object_nl, T_STRING);
688
+ return state->object_nl = object_nl;
689
+ }
690
+
691
+ /*
692
+ * call-seq: array_nl()
693
+ *
694
+ * This string is put at the end of a line that holds a JSON array.
695
+ */
696
+ static VALUE cState_array_nl(VALUE self)
697
+ {
698
+ GET_STATE(self);
699
+ return state->array_nl;
700
+ }
701
+
702
+ /*
703
+ * call-seq: array_nl=(array_nl)
704
+ *
705
+ * This string is put at the end of a line that holds a JSON array.
706
+ */
707
+ static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
708
+ {
709
+ GET_STATE(self);
710
+ Check_Type(array_nl, T_STRING);
711
+ return state->array_nl = array_nl;
712
+ }
713
+
714
+ /*
715
+ * call-seq: check_circular?
716
+ *
717
+ * Returns true, if circular data structures should be checked,
718
+ * otherwise returns false.
719
+ */
720
+ static VALUE cState_check_circular_p(VALUE self)
721
+ {
722
+ GET_STATE(self);
723
+ return state->check_circular ? Qtrue : Qfalse;
724
+ }
725
+
726
+ /*
727
+ * call-seq: max_nesting
728
+ *
729
+ * This integer returns the maximum level of data structure nesting in
730
+ * the generated JSON, max_nesting = 0 if no maximum is checked.
731
+ */
732
+ static VALUE cState_max_nesting(VALUE self)
733
+ {
734
+ GET_STATE(self);
735
+ return LONG2FIX(state->max_nesting);
736
+ }
737
+
738
+ /*
739
+ * call-seq: max_nesting=(depth)
740
+ *
741
+ * This sets the maximum level of data structure nesting in the generated JSON
742
+ * to the integer depth, max_nesting = 0 if no maximum should be checked.
743
+ */
744
+ static VALUE cState_max_nesting_set(VALUE self, VALUE depth)
745
+ {
746
+ GET_STATE(self);
747
+ Check_Type(depth, T_FIXNUM);
748
+ state->max_nesting = FIX2LONG(depth);
749
+ return Qnil;
750
+ }
751
+
752
+ /*
753
+ * call-seq: allow_nan?
754
+ *
755
+ * Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise
756
+ * returns false.
757
+ */
758
+ static VALUE cState_allow_nan_p(VALUE self)
759
+ {
760
+ GET_STATE(self);
761
+ return state->allow_nan ? Qtrue : Qfalse;
762
+ }
763
+
764
+ /*
765
+ * call-seq: seen?(object)
766
+ *
767
+ * Returns _true_, if _object_ was already seen during this generating run.
768
+ */
769
+ static VALUE cState_seen_p(VALUE self, VALUE object)
770
+ {
771
+ GET_STATE(self);
772
+ return rb_hash_aref(state->seen, rb_obj_id(object));
773
+ }
774
+
775
+ /*
776
+ * call-seq: remember(object)
777
+ *
778
+ * Remember _object_, to find out if it was already encountered (if a cyclic
779
+ * data structure is rendered).
780
+ */
781
+ static VALUE cState_remember(VALUE self, VALUE object)
782
+ {
783
+ GET_STATE(self);
784
+ return rb_hash_aset(state->seen, rb_obj_id(object), Qtrue);
785
+ }
786
+
787
+ /*
788
+ * call-seq: forget(object)
789
+ *
790
+ * Forget _object_ for this generating run.
791
+ */
792
+ static VALUE cState_forget(VALUE self, VALUE object)
793
+ {
794
+ GET_STATE(self);
795
+ return rb_hash_delete(state->seen, rb_obj_id(object));
796
+ }
797
+
798
+ /*
799
+ *
800
+ */
801
+ void Init_generator()
802
+ {
803
+ rb_require("json/common");
804
+ mJSON = rb_define_module("JSON");
805
+ mExt = rb_define_module_under(mJSON, "Ext");
806
+ mGenerator = rb_define_module_under(mExt, "Generator");
807
+ eGeneratorError = rb_path2class("JSON::GeneratorError");
808
+ eCircularDatastructure = rb_path2class("JSON::CircularDatastructure");
809
+ eNestingError = rb_path2class("JSON::NestingError");
810
+ cState = rb_define_class_under(mGenerator, "State", rb_cObject);
811
+ rb_define_alloc_func(cState, cState_s_allocate);
812
+ rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1);
813
+ rb_define_method(cState, "initialize", cState_initialize, -1);
814
+
815
+ rb_define_method(cState, "indent", cState_indent, 0);
816
+ rb_define_method(cState, "indent=", cState_indent_set, 1);
817
+ rb_define_method(cState, "space", cState_space, 0);
818
+ rb_define_method(cState, "space=", cState_space_set, 1);
819
+ rb_define_method(cState, "space_before", cState_space_before, 0);
820
+ rb_define_method(cState, "space_before=", cState_space_before_set, 1);
821
+ rb_define_method(cState, "object_nl", cState_object_nl, 0);
822
+ rb_define_method(cState, "object_nl=", cState_object_nl_set, 1);
823
+ rb_define_method(cState, "array_nl", cState_array_nl, 0);
824
+ rb_define_method(cState, "array_nl=", cState_array_nl_set, 1);
825
+ rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
826
+ rb_define_method(cState, "max_nesting", cState_max_nesting, 0);
827
+ rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1);
828
+ rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
829
+ rb_define_method(cState, "seen?", cState_seen_p, 1);
830
+ rb_define_method(cState, "remember", cState_remember, 1);
831
+ rb_define_method(cState, "forget", cState_forget, 1);
832
+ rb_define_method(cState, "configure", cState_configure, 1);
833
+ rb_define_method(cState, "to_h", cState_to_h, 0);
834
+
835
+ mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods");
836
+ mObject = rb_define_module_under(mGeneratorMethods, "Object");
837
+ rb_define_method(mObject, "to_json", mObject_to_json, -1);
838
+ mHash = rb_define_module_under(mGeneratorMethods, "Hash");
839
+ rb_define_method(mHash, "to_json", mHash_to_json, -1);
840
+ mArray = rb_define_module_under(mGeneratorMethods, "Array");
841
+ rb_define_method(mArray, "to_json", mArray_to_json, -1);
842
+ mInteger = rb_define_module_under(mGeneratorMethods, "Integer");
843
+ rb_define_method(mInteger, "to_json", mInteger_to_json, -1);
844
+ mFloat = rb_define_module_under(mGeneratorMethods, "Float");
845
+ rb_define_method(mFloat, "to_json", mFloat_to_json, -1);
846
+ mString = rb_define_module_under(mGeneratorMethods, "String");
847
+ rb_define_singleton_method(mString, "included", mString_included_s, 1);
848
+ rb_define_method(mString, "to_json", mString_to_json, -1);
849
+ rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1);
850
+ rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0);
851
+ mString_Extend = rb_define_module_under(mString, "Extend");
852
+ rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1);
853
+ mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass");
854
+ rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1);
855
+ mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass");
856
+ rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1);
857
+ mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass");
858
+ rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1);
859
+
860
+ i_to_s = rb_intern("to_s");
861
+ i_to_json = rb_intern("to_json");
862
+ i_new = rb_intern("new");
863
+ i_indent = rb_intern("indent");
864
+ i_space = rb_intern("space");
865
+ i_space_before = rb_intern("space_before");
866
+ i_object_nl = rb_intern("object_nl");
867
+ i_array_nl = rb_intern("array_nl");
868
+ i_check_circular = rb_intern("check_circular");
869
+ i_max_nesting = rb_intern("max_nesting");
870
+ i_allow_nan = rb_intern("allow_nan");
871
+ i_pack = rb_intern("pack");
872
+ i_unpack = rb_intern("unpack");
873
+ i_create_id = rb_intern("create_id");
874
+ i_extend = rb_intern("extend");
875
+ }