abiquo-etk 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (530) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +87 -0
  6. data/TODO +6 -0
  7. data/VERSION +1 -0
  8. data/abiquo-etk.gemspec +577 -0
  9. data/abiquo-etk.spec +125 -0
  10. data/bin/abicli +90 -0
  11. data/bin/abiquo-check-16-install +129 -0
  12. data/bin/aetk-setup-rs +36 -0
  13. data/bin/aetk-setup-server +77 -0
  14. data/bin/aetk-setup-v2v +33 -0
  15. data/lib/abicli/commands/remote-services-settings.rb +24 -0
  16. data/lib/abicli/commands/server-settings.rb +22 -0
  17. data/lib/abicli/commands/set.rb +133 -0
  18. data/lib/abicli/commands/smoketest.rb +93 -0
  19. data/lib/abicli/commands/upload-template.rb +272 -0
  20. data/lib/abicli/commands/version.rb +5 -0
  21. data/lib/abiquo-etk.rb +191 -0
  22. data/lib/checks/01detect_abiquo.rb +4 -0
  23. data/lib/checks/abiquo_service.rb +34 -0
  24. data/lib/checks/abiquo_version.rb +24 -0
  25. data/lib/checks/components_installed.rb +6 -0
  26. data/lib/checks/firewall.rb +10 -0
  27. data/lib/checks/hv_passwords.rb +51 -0
  28. data/lib/checks/install_type.rb +8 -0
  29. data/lib/checks/java.rb +19 -0
  30. data/lib/checks/mysql.rb +33 -0
  31. data/lib/checks/nfs.rb +18 -0
  32. data/lib/checks/os_version.rb +5 -0
  33. data/lib/checks/virtualbox.rb +11 -0
  34. data/scripts/setup_rs +44 -0
  35. data/scripts/setup_v2v +1 -0
  36. data/vendor/activesupport-2.3.8/CHANGELOG +1367 -0
  37. data/vendor/activesupport-2.3.8/README +43 -0
  38. data/vendor/activesupport-2.3.8/lib/active_support/all.rb +8 -0
  39. data/vendor/activesupport-2.3.8/lib/active_support/backtrace_cleaner.rb +72 -0
  40. data/vendor/activesupport-2.3.8/lib/active_support/base64.rb +33 -0
  41. data/vendor/activesupport-2.3.8/lib/active_support/basic_object.rb +24 -0
  42. data/vendor/activesupport-2.3.8/lib/active_support/buffered_logger.rb +127 -0
  43. data/vendor/activesupport-2.3.8/lib/active_support/cache/compressed_mem_cache_store.rb +20 -0
  44. data/vendor/activesupport-2.3.8/lib/active_support/cache/drb_store.rb +14 -0
  45. data/vendor/activesupport-2.3.8/lib/active_support/cache/file_store.rb +72 -0
  46. data/vendor/activesupport-2.3.8/lib/active_support/cache/mem_cache_store.rb +143 -0
  47. data/vendor/activesupport-2.3.8/lib/active_support/cache/memory_store.rb +58 -0
  48. data/vendor/activesupport-2.3.8/lib/active_support/cache/strategy/local_cache.rb +104 -0
  49. data/vendor/activesupport-2.3.8/lib/active_support/cache/synchronized_memory_store.rb +47 -0
  50. data/vendor/activesupport-2.3.8/lib/active_support/cache.rb +248 -0
  51. data/vendor/activesupport-2.3.8/lib/active_support/callbacks.rb +279 -0
  52. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/access.rb +53 -0
  53. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/conversions.rb +197 -0
  54. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/extract_options.rb +20 -0
  55. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/grouping.rb +106 -0
  56. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/random_access.rb +22 -0
  57. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array/wrapper.rb +24 -0
  58. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/array.rb +15 -0
  59. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/base64/encoding.rb +16 -0
  60. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/base64.rb +4 -0
  61. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb +19 -0
  62. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/bigdecimal/conversions.rb +37 -0
  63. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/bigdecimal.rb +6 -0
  64. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/blank.rb +2 -0
  65. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +23 -0
  66. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/cgi.rb +5 -0
  67. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class/attribute_accessors.rb +61 -0
  68. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class/delegating_attributes.rb +47 -0
  69. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
  70. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class/removal.rb +50 -0
  71. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/class.rb +4 -0
  72. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date/behavior.rb +42 -0
  73. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date/calculations.rb +241 -0
  74. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date/conversions.rb +107 -0
  75. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date.rb +10 -0
  76. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date_time/calculations.rb +126 -0
  77. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date_time/conversions.rb +107 -0
  78. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/date_time.rb +12 -0
  79. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/duplicable.rb +43 -0
  80. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/enumerable.rb +120 -0
  81. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/exception.rb +45 -0
  82. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/file/atomic.rb +47 -0
  83. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/file.rb +5 -0
  84. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/float/rounding.rb +24 -0
  85. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/float/time.rb +27 -0
  86. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/float.rb +7 -0
  87. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/conversions.rb +247 -0
  88. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
  89. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/diff.rb +19 -0
  90. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/except.rb +25 -0
  91. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/indifferent_access.rb +143 -0
  92. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/keys.rb +52 -0
  93. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/reverse_merge.rb +35 -0
  94. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash/slice.rb +40 -0
  95. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/hash.rb +14 -0
  96. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/integer/even_odd.rb +29 -0
  97. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/integer/inflections.rb +20 -0
  98. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/integer/time.rb +45 -0
  99. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/integer.rb +9 -0
  100. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
  101. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  102. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/debugger.rb +16 -0
  103. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/reporting.rb +59 -0
  104. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb +24 -0
  105. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/kernel.rb +5 -0
  106. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb +38 -0
  107. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/logger.rb +145 -0
  108. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/aliasing.rb +74 -0
  109. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  110. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb +32 -0
  111. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/attribute_accessors.rb +67 -0
  112. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/delegation.rb +135 -0
  113. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/inclusion.rb +30 -0
  114. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/introspection.rb +90 -0
  115. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/loading.rb +23 -0
  116. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/model_naming.rb +25 -0
  117. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module/synchronization.rb +39 -0
  118. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/module.rb +23 -0
  119. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/name_error.rb +19 -0
  120. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/numeric/bytes.rb +50 -0
  121. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/numeric/conversions.rb +19 -0
  122. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/numeric/time.rb +81 -0
  123. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/numeric.rb +9 -0
  124. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/blank.rb +76 -0
  125. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/conversions.rb +15 -0
  126. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/extending.rb +80 -0
  127. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/instance_variables.rb +74 -0
  128. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb +14 -0
  129. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/misc.rb +90 -0
  130. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object/singleton_class.rb +13 -0
  131. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/object.rb +7 -0
  132. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
  133. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/pathname.rb +7 -0
  134. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/proc.rb +12 -0
  135. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/process/daemon.rb +25 -0
  136. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/process.rb +1 -0
  137. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range/blockless_step.rb +32 -0
  138. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range/conversions.rb +27 -0
  139. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range/include_range.rb +30 -0
  140. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range/overlaps.rb +15 -0
  141. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/range.rb +11 -0
  142. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb +41 -0
  143. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/access.rb +106 -0
  144. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/behavior.rb +13 -0
  145. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/bytesize.rb +5 -0
  146. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/conversions.rb +28 -0
  147. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/filters.rb +26 -0
  148. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/inflections.rb +167 -0
  149. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/iterators.rb +23 -0
  150. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/multibyte.rb +81 -0
  151. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/output_safety.rb +112 -0
  152. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/starts_ends_with.rb +33 -0
  153. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string/xchar.rb +11 -0
  154. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/string.rb +24 -0
  155. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/symbol.rb +14 -0
  156. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time/behavior.rb +13 -0
  157. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time/calculations.rb +313 -0
  158. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time/conversions.rb +90 -0
  159. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time/zones.rb +86 -0
  160. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/time.rb +46 -0
  161. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/try.rb +36 -0
  162. data/vendor/activesupport-2.3.8/lib/active_support/core_ext/uri.rb +16 -0
  163. data/vendor/activesupport-2.3.8/lib/active_support/core_ext.rb +8 -0
  164. data/vendor/activesupport-2.3.8/lib/active_support/dependencies.rb +625 -0
  165. data/vendor/activesupport-2.3.8/lib/active_support/deprecation.rb +197 -0
  166. data/vendor/activesupport-2.3.8/lib/active_support/duration.rb +100 -0
  167. data/vendor/activesupport-2.3.8/lib/active_support/gzip.rb +25 -0
  168. data/vendor/activesupport-2.3.8/lib/active_support/inflections.rb +56 -0
  169. data/vendor/activesupport-2.3.8/lib/active_support/inflector.rb +409 -0
  170. data/vendor/activesupport-2.3.8/lib/active_support/json/backends/jsongem.rb +37 -0
  171. data/vendor/activesupport-2.3.8/lib/active_support/json/backends/yajl.rb +40 -0
  172. data/vendor/activesupport-2.3.8/lib/active_support/json/backends/yaml.rb +87 -0
  173. data/vendor/activesupport-2.3.8/lib/active_support/json/decoding.rb +50 -0
  174. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/date.rb +22 -0
  175. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/date_time.rb +22 -0
  176. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/enumerable.rb +17 -0
  177. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/false_class.rb +7 -0
  178. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/hash.rb +56 -0
  179. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/nil_class.rb +7 -0
  180. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/numeric.rb +21 -0
  181. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/object.rb +10 -0
  182. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/regexp.rb +9 -0
  183. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/string.rb +9 -0
  184. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/symbol.rb +5 -0
  185. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/time.rb +22 -0
  186. data/vendor/activesupport-2.3.8/lib/active_support/json/encoders/true_class.rb +7 -0
  187. data/vendor/activesupport-2.3.8/lib/active_support/json/encoding.rb +111 -0
  188. data/vendor/activesupport-2.3.8/lib/active_support/json/variable.rb +10 -0
  189. data/vendor/activesupport-2.3.8/lib/active_support/json.rb +2 -0
  190. data/vendor/activesupport-2.3.8/lib/active_support/locale/en.yml +33 -0
  191. data/vendor/activesupport-2.3.8/lib/active_support/memoizable.rb +100 -0
  192. data/vendor/activesupport-2.3.8/lib/active_support/message_encryptor.rb +70 -0
  193. data/vendor/activesupport-2.3.8/lib/active_support/message_verifier.rb +79 -0
  194. data/vendor/activesupport-2.3.8/lib/active_support/multibyte/chars.rb +707 -0
  195. data/vendor/activesupport-2.3.8/lib/active_support/multibyte/exceptions.rb +8 -0
  196. data/vendor/activesupport-2.3.8/lib/active_support/multibyte/unicode_database.rb +71 -0
  197. data/vendor/activesupport-2.3.8/lib/active_support/multibyte/utils.rb +60 -0
  198. data/vendor/activesupport-2.3.8/lib/active_support/multibyte.rb +57 -0
  199. data/vendor/activesupport-2.3.8/lib/active_support/option_merger.rb +23 -0
  200. data/vendor/activesupport-2.3.8/lib/active_support/ordered_hash.rb +158 -0
  201. data/vendor/activesupport-2.3.8/lib/active_support/ordered_options.rb +19 -0
  202. data/vendor/activesupport-2.3.8/lib/active_support/rescuable.rb +108 -0
  203. data/vendor/activesupport-2.3.8/lib/active_support/secure_random.rb +199 -0
  204. data/vendor/activesupport-2.3.8/lib/active_support/string_inquirer.rb +21 -0
  205. data/vendor/activesupport-2.3.8/lib/active_support/test_case.rb +40 -0
  206. data/vendor/activesupport-2.3.8/lib/active_support/testing/assertions.rb +79 -0
  207. data/vendor/activesupport-2.3.8/lib/active_support/testing/declarative.rb +21 -0
  208. data/vendor/activesupport-2.3.8/lib/active_support/testing/default.rb +9 -0
  209. data/vendor/activesupport-2.3.8/lib/active_support/testing/deprecation.rb +57 -0
  210. data/vendor/activesupport-2.3.8/lib/active_support/testing/performance.rb +452 -0
  211. data/vendor/activesupport-2.3.8/lib/active_support/testing/setup_and_teardown.rb +91 -0
  212. data/vendor/activesupport-2.3.8/lib/active_support/time_with_zone.rb +335 -0
  213. data/vendor/activesupport-2.3.8/lib/active_support/values/time_zone.rb +412 -0
  214. data/vendor/activesupport-2.3.8/lib/active_support/values/unicode_tables.dat +0 -0
  215. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  216. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  217. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  218. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
  219. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
  220. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
  221. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
  222. data/vendor/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
  223. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/active_record/missing.rb +67 -0
  224. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/active_record/store_procs.rb +38 -0
  225. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/active_record/translation.rb +88 -0
  226. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/active_record.rb +66 -0
  227. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/base.rb +266 -0
  228. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cache.rb +76 -0
  229. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cascade.rb +58 -0
  230. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/chain.rb +75 -0
  231. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb +100 -0
  232. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/fallbacks.rb +69 -0
  233. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/fast.rb +69 -0
  234. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/gettext.rb +75 -0
  235. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/helpers.rb +68 -0
  236. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/interpolation_compiler.rb +119 -0
  237. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/links.rb +34 -0
  238. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/metadata.rb +73 -0
  239. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/pluralization.rb +57 -0
  240. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend/simple.rb +22 -0
  241. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/backend.rb +19 -0
  242. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/except.rb +8 -0
  243. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/slice.rb +8 -0
  244. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/object/meta_class.rb +5 -0
  245. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/string/interpolate.rb +99 -0
  246. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/exceptions.rb +61 -0
  247. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/gettext/po_parser.rb +329 -0
  248. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/gettext.rb +25 -0
  249. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/helpers/gettext.rb +65 -0
  250. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/helpers.rb +5 -0
  251. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/fallbacks.rb +98 -0
  252. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/tag/parents.rb +24 -0
  253. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/tag/rfc4646.rb +76 -0
  254. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/tag/simple.rb +41 -0
  255. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale/tag.rb +28 -0
  256. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/locale.rb +6 -0
  257. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n/version.rb +3 -0
  258. data/vendor/activesupport-2.3.8/lib/active_support/vendor/i18n-0.3.7/i18n.rb +335 -0
  259. data/vendor/activesupport-2.3.8/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb +1107 -0
  260. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +47 -0
  261. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +228 -0
  262. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +55 -0
  263. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +219 -0
  264. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +40 -0
  265. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +18 -0
  266. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  267. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  268. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  269. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  270. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  271. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +23 -0
  272. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +23 -0
  273. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +283 -0
  274. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +136 -0
  275. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +204 -0
  276. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +161 -0
  277. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +27 -0
  278. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +274 -0
  279. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  280. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +194 -0
  281. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +22 -0
  282. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +35 -0
  283. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  284. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +139 -0
  285. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +144 -0
  286. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +131 -0
  287. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +282 -0
  288. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +30 -0
  289. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +74 -0
  290. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +205 -0
  291. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  292. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +288 -0
  293. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +196 -0
  294. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +67 -0
  295. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  296. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +161 -0
  297. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  298. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  299. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
  300. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  301. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  302. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  303. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  304. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  305. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +20 -0
  306. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  307. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +30 -0
  308. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +20 -0
  309. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  310. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  311. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  312. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  313. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +163 -0
  314. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +18 -0
  315. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  316. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  317. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  318. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +34 -0
  319. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  320. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +33 -0
  321. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +59 -0
  322. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  323. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  324. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +121 -0
  325. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  326. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  327. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  328. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  329. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  330. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  331. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  332. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  333. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  334. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  335. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  336. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  337. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +29 -0
  338. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +193 -0
  339. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  340. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +37 -0
  341. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +185 -0
  342. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +16 -0
  343. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  344. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +185 -0
  345. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  346. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +188 -0
  347. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  348. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +232 -0
  349. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  350. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +197 -0
  351. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  352. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +276 -0
  353. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  354. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  355. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +168 -0
  356. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  357. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  358. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +288 -0
  359. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +211 -0
  360. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +170 -0
  361. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +181 -0
  362. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +232 -0
  363. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +187 -0
  364. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +176 -0
  365. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +215 -0
  366. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  367. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +13 -0
  368. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +173 -0
  369. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  370. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  371. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +183 -0
  372. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  373. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  374. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  375. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  376. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  377. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +22 -0
  378. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  379. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  380. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +25 -0
  381. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  382. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  383. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  384. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  385. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +52 -0
  386. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +51 -0
  387. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +44 -0
  388. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +98 -0
  389. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +56 -0
  390. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +292 -0
  391. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +508 -0
  392. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +56 -0
  393. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +40 -0
  394. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +94 -0
  395. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +198 -0
  396. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +129 -0
  397. data/vendor/activesupport-2.3.8/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +33 -0
  398. data/vendor/activesupport-2.3.8/lib/active_support/vendor.rb +36 -0
  399. data/vendor/activesupport-2.3.8/lib/active_support/version.rb +9 -0
  400. data/vendor/activesupport-2.3.8/lib/active_support/whiny_nil.rb +64 -0
  401. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/jdom.rb +162 -0
  402. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/libxml.rb +73 -0
  403. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/libxmlsax.rb +74 -0
  404. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/nokogiri.rb +72 -0
  405. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/nokogirisax.rb +73 -0
  406. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini/rexml.rb +108 -0
  407. data/vendor/activesupport-2.3.8/lib/active_support/xml_mini.rb +31 -0
  408. data/vendor/activesupport-2.3.8/lib/active_support.rb +60 -0
  409. data/vendor/activesupport-2.3.8/lib/activesupport.rb +2 -0
  410. data/vendor/addressable-2.2.1/CHANGELOG +95 -0
  411. data/vendor/addressable-2.2.1/LICENSE +20 -0
  412. data/vendor/addressable-2.2.1/README +60 -0
  413. data/vendor/addressable-2.2.1/Rakefile +42 -0
  414. data/vendor/addressable-2.2.1/lib/addressable/idna.rb +4871 -0
  415. data/vendor/addressable-2.2.1/lib/addressable/template.rb +1049 -0
  416. data/vendor/addressable-2.2.1/lib/addressable/uri.rb +2250 -0
  417. data/vendor/addressable-2.2.1/lib/addressable/version.rb +36 -0
  418. data/vendor/addressable-2.2.1/spec/addressable/idna_spec.rb +194 -0
  419. data/vendor/addressable-2.2.1/spec/addressable/template_spec.rb +2152 -0
  420. data/vendor/addressable-2.2.1/spec/addressable/uri_spec.rb +4203 -0
  421. data/vendor/addressable-2.2.1/spec/data/rfc3986.txt +3419 -0
  422. data/vendor/addressable-2.2.1/tasks/clobber.rake +2 -0
  423. data/vendor/addressable-2.2.1/tasks/gem.rake +84 -0
  424. data/vendor/addressable-2.2.1/tasks/git.rake +40 -0
  425. data/vendor/addressable-2.2.1/tasks/metrics.rake +22 -0
  426. data/vendor/addressable-2.2.1/tasks/rdoc.rake +26 -0
  427. data/vendor/addressable-2.2.1/tasks/rubyforge.rake +89 -0
  428. data/vendor/addressable-2.2.1/tasks/spec.rake +47 -0
  429. data/vendor/addressable-2.2.1/tasks/yard.rake +26 -0
  430. data/vendor/addressable-2.2.1/website/index.html +110 -0
  431. data/vendor/api_ruby_client/Gemfile +10 -0
  432. data/vendor/api_ruby_client/LICENSE +20 -0
  433. data/vendor/api_ruby_client/README +39 -0
  434. data/vendor/api_ruby_client/Rakefile +89 -0
  435. data/vendor/api_ruby_client/abiquo.gemspec +43 -0
  436. data/vendor/api_ruby_client/examples/create_dc_and_hv.rb +38 -0
  437. data/vendor/api_ruby_client/examples/hypervisor_resource.rb +16 -0
  438. data/vendor/api_ruby_client/examples/rack_resource.rb +38 -0
  439. data/vendor/api_ruby_client/lib/abiquo.rb +201 -0
  440. data/vendor/api_ruby_client/lib/core_ext.rb +28 -0
  441. data/vendor/api_ruby_client/lib/to_xml.rb +22 -0
  442. data/vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb +43 -0
  443. data/vendor/api_ruby_client/spec/acceptance/delete_resource_spec.rb +27 -0
  444. data/vendor/api_ruby_client/spec/acceptance/fetch_resource_collections_spec.rb +55 -0
  445. data/vendor/api_ruby_client/spec/acceptance/fetch_single_resources_spec.rb +47 -0
  446. data/vendor/api_ruby_client/spec/acceptance/from_xml_spec.rb +15 -0
  447. data/vendor/api_ruby_client/spec/acceptance/navigate_linked_resources_spec.rb +61 -0
  448. data/vendor/api_ruby_client/spec/acceptance/update_resource_spec.rb +26 -0
  449. data/vendor/api_ruby_client/spec/spec_helper.rb +32 -0
  450. data/vendor/api_ruby_client/spec/unit/to_xml_spec.rb +56 -0
  451. data/vendor/fattr-2.1.0/README +347 -0
  452. data/vendor/fattr-2.1.0/README.erb +82 -0
  453. data/vendor/fattr-2.1.0/Rakefile +242 -0
  454. data/vendor/fattr-2.1.0/a.rb +42 -0
  455. data/vendor/fattr-2.1.0/fattr.gemspec +29 -0
  456. data/vendor/fattr-2.1.0/lib/fattr.rb +193 -0
  457. data/vendor/fattr-2.1.0/samples/a.rb +21 -0
  458. data/vendor/fattr-2.1.0/samples/b.rb +22 -0
  459. data/vendor/fattr-2.1.0/samples/c.rb +12 -0
  460. data/vendor/fattr-2.1.0/samples/d.rb +34 -0
  461. data/vendor/fattr-2.1.0/samples/e.rb +17 -0
  462. data/vendor/fattr-2.1.0/samples/f.rb +21 -0
  463. data/vendor/fattr-2.1.0/samples/g.rb +15 -0
  464. data/vendor/fattr-2.1.0/samples/h.rb +29 -0
  465. data/vendor/fattr-2.1.0/test/fattr.rb +166 -0
  466. data/vendor/httpauth-0.1/LICENSE +16 -0
  467. data/vendor/httpauth-0.1/README +39 -0
  468. data/vendor/httpauth-0.1/Rakefile +76 -0
  469. data/vendor/httpauth-0.1/examples/client_digest_secure +132 -0
  470. data/vendor/httpauth-0.1/examples/server_digest_secure +47 -0
  471. data/vendor/httpauth-0.1/lib/httpauth/basic.rb +114 -0
  472. data/vendor/httpauth-0.1/lib/httpauth/constants.rb +14 -0
  473. data/vendor/httpauth-0.1/lib/httpauth/digest.rb +583 -0
  474. data/vendor/httpauth-0.1/lib/httpauth/exceptions.rb +6 -0
  475. data/vendor/httpauth-0.1/lib/httpauth.rb +4 -0
  476. data/vendor/options-2.3.0/README +186 -0
  477. data/vendor/options-2.3.0/README.erb +35 -0
  478. data/vendor/options-2.3.0/Rakefile +371 -0
  479. data/vendor/options-2.3.0/lib/options.rb +220 -0
  480. data/vendor/options-2.3.0/options.gemspec +26 -0
  481. data/vendor/options-2.3.0/samples/a.rb +15 -0
  482. data/vendor/options-2.3.0/samples/b.rb +50 -0
  483. data/vendor/options-2.3.0/samples/c.rb +20 -0
  484. data/vendor/options-2.3.0/samples/d.rb +17 -0
  485. data/vendor/options-2.3.0/spec/options_spec.rb +38 -0
  486. data/vendor/options-2.3.0/spec/spec_helper.rb +7 -0
  487. data/vendor/resourceful-1.0.1/History.txt +39 -0
  488. data/vendor/resourceful-1.0.1/MIT-LICENSE +21 -0
  489. data/vendor/resourceful-1.0.1/Manifest +43 -0
  490. data/vendor/resourceful-1.0.1/README.markdown +92 -0
  491. data/vendor/resourceful-1.0.1/Rakefile +91 -0
  492. data/vendor/resourceful-1.0.1/lib/resourceful/abstract_form_data.rb +18 -0
  493. data/vendor/resourceful-1.0.1/lib/resourceful/authentication_manager.rb +108 -0
  494. data/vendor/resourceful-1.0.1/lib/resourceful/cache_manager.rb +242 -0
  495. data/vendor/resourceful-1.0.1/lib/resourceful/exceptions.rb +34 -0
  496. data/vendor/resourceful-1.0.1/lib/resourceful/header.rb +355 -0
  497. data/vendor/resourceful-1.0.1/lib/resourceful/http_accessor.rb +103 -0
  498. data/vendor/resourceful-1.0.1/lib/resourceful/memcache_cache_manager.rb +75 -0
  499. data/vendor/resourceful-1.0.1/lib/resourceful/multipart_form_data.rb +46 -0
  500. data/vendor/resourceful-1.0.1/lib/resourceful/net_http_adapter.rb +84 -0
  501. data/vendor/resourceful-1.0.1/lib/resourceful/request.rb +235 -0
  502. data/vendor/resourceful-1.0.1/lib/resourceful/resource.rb +179 -0
  503. data/vendor/resourceful-1.0.1/lib/resourceful/response.rb +221 -0
  504. data/vendor/resourceful-1.0.1/lib/resourceful/simple.rb +36 -0
  505. data/vendor/resourceful-1.0.1/lib/resourceful/stubbed_resource_proxy.rb +47 -0
  506. data/vendor/resourceful-1.0.1/lib/resourceful/urlencoded_form_data.rb +17 -0
  507. data/vendor/resourceful-1.0.1/lib/resourceful/util.rb +6 -0
  508. data/vendor/resourceful-1.0.1/lib/resourceful.rb +26 -0
  509. data/vendor/resourceful-1.0.1/resourceful.gemspec +51 -0
  510. data/vendor/resourceful-1.0.1/spec/acceptance/authorization_spec.rb +16 -0
  511. data/vendor/resourceful-1.0.1/spec/acceptance/caching_spec.rb +190 -0
  512. data/vendor/resourceful-1.0.1/spec/acceptance/header_spec.rb +24 -0
  513. data/vendor/resourceful-1.0.1/spec/acceptance/redirecting_spec.rb +12 -0
  514. data/vendor/resourceful-1.0.1/spec/acceptance/resource_spec.rb +84 -0
  515. data/vendor/resourceful-1.0.1/spec/acceptance/resourceful_spec.rb +56 -0
  516. data/vendor/resourceful-1.0.1/spec/acceptance_shared_specs.rb +44 -0
  517. data/vendor/resourceful-1.0.1/spec/caching_spec.rb +89 -0
  518. data/vendor/resourceful-1.0.1/spec/old_acceptance_specs.rb +378 -0
  519. data/vendor/resourceful-1.0.1/spec/resourceful/header_spec.rb +153 -0
  520. data/vendor/resourceful-1.0.1/spec/resourceful/http_accessor_spec.rb +56 -0
  521. data/vendor/resourceful-1.0.1/spec/resourceful/multipart_form_data_spec.rb +77 -0
  522. data/vendor/resourceful-1.0.1/spec/resourceful/resource_spec.rb +20 -0
  523. data/vendor/resourceful-1.0.1/spec/resourceful/response_spec.rb +51 -0
  524. data/vendor/resourceful-1.0.1/spec/resourceful/urlencoded_form_data_spec.rb +44 -0
  525. data/vendor/resourceful-1.0.1/spec/resourceful_spec.rb +79 -0
  526. data/vendor/resourceful-1.0.1/spec/simple_sinatra_server.rb +74 -0
  527. data/vendor/resourceful-1.0.1/spec/simple_sinatra_server_spec.rb +98 -0
  528. data/vendor/resourceful-1.0.1/spec/spec.opts +3 -0
  529. data/vendor/resourceful-1.0.1/spec/spec_helper.rb +31 -0
  530. metadata +645 -0
@@ -0,0 +1,1049 @@
1
+ # encoding:utf-8
2
+ #--
3
+ # Addressable, Copyright (c) 2006-2010 Bob Aman
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ require "addressable/version"
26
+ require "addressable/uri"
27
+
28
+ module Addressable
29
+ ##
30
+ # This is an implementation of a URI template based on
31
+ # <a href="http://tinyurl.com/uritemplatedraft03">URI Template draft 03</a>.
32
+ class Template
33
+ # Constants used throughout the template code.
34
+ anything =
35
+ Addressable::URI::CharacterClasses::RESERVED +
36
+ Addressable::URI::CharacterClasses::UNRESERVED
37
+ OPERATOR_EXPANSION =
38
+ /\{-([a-zA-Z]+)\|([#{anything}]+)\|([#{anything}]+)\}/
39
+ VARIABLE_EXPANSION = /\{([#{anything}]+?)(?:=([#{anything}]+))?\}/
40
+
41
+ ##
42
+ # Raised if an invalid template value is supplied.
43
+ class InvalidTemplateValueError < StandardError
44
+ end
45
+
46
+ ##
47
+ # Raised if an invalid template operator is used in a pattern.
48
+ class InvalidTemplateOperatorError < StandardError
49
+ end
50
+
51
+ ##
52
+ # Raised if an invalid template operator is used in a pattern.
53
+ class TemplateOperatorAbortedError < StandardError
54
+ end
55
+
56
+ ##
57
+ # This class represents the data that is extracted when a Template
58
+ # is matched against a URI.
59
+ class MatchData
60
+ ##
61
+ # Creates a new MatchData object.
62
+ # MatchData objects should never be instantiated directly.
63
+ #
64
+ # @param [Addressable::URI] uri
65
+ # The URI that the template was matched against.
66
+ def initialize(uri, template, mapping) # :nodoc:
67
+ @uri = uri.dup.freeze
68
+ @template = template
69
+ @mapping = mapping.dup.freeze
70
+ end
71
+
72
+ ##
73
+ # @return [Addressable::URI]
74
+ # The URI that the Template was matched against.
75
+ attr_reader :uri
76
+
77
+ ##
78
+ # @return [Addressable::Template]
79
+ # The Template used for the match.
80
+ attr_reader :template
81
+
82
+ ##
83
+ # @return [Hash]
84
+ # The mapping that resulted from the match.
85
+ # Note that this mapping does not include keys or values for
86
+ # variables that appear in the Template, but are not present
87
+ # in the URI.
88
+ attr_reader :mapping
89
+
90
+ ##
91
+ # @return [Array]
92
+ # The list of variables that were present in the Template.
93
+ # Note that this list will include variables which do not appear
94
+ # in the mapping because they were not present in URI.
95
+ def variables
96
+ self.template.variables
97
+ end
98
+ alias_method :keys, :variables
99
+
100
+ ##
101
+ # @return [Array]
102
+ # The list of values that were captured by the Template.
103
+ # Note that this list will include nils for any variables which
104
+ # were in the Template, but did not appear in the URI.
105
+ def values
106
+ @values ||= self.variables.inject([]) do |accu, key|
107
+ accu << self.mapping[key]
108
+ accu
109
+ end
110
+ end
111
+ alias_method :captures, :values
112
+
113
+ ##
114
+ # Returns a <tt>String</tt> representation of the MatchData's state.
115
+ #
116
+ # @return [String] The MatchData's state, as a <tt>String</tt>.
117
+ def inspect
118
+ sprintf("#<%s:%#0x RESULT:%s>",
119
+ self.class.to_s, self.object_id, self.mapping.inspect)
120
+ end
121
+ end
122
+
123
+ ##
124
+ # Creates a new <tt>Addressable::Template</tt> object.
125
+ #
126
+ # @param [#to_str] pattern The URI Template pattern.
127
+ #
128
+ # @return [Addressable::Template] The initialized Template object.
129
+ def initialize(pattern)
130
+ if !pattern.respond_to?(:to_str)
131
+ raise TypeError, "Can't convert #{pattern.class} into String."
132
+ end
133
+ @pattern = pattern.to_str.freeze
134
+ end
135
+
136
+ ##
137
+ # @return [String] The Template object's pattern.
138
+ attr_reader :pattern
139
+
140
+ ##
141
+ # Returns a <tt>String</tt> representation of the Template object's state.
142
+ #
143
+ # @return [String] The Template object's state, as a <tt>String</tt>.
144
+ def inspect
145
+ sprintf("#<%s:%#0x PATTERN:%s>",
146
+ self.class.to_s, self.object_id, self.pattern)
147
+ end
148
+
149
+ ##
150
+ # Extracts a mapping from the URI using a URI Template pattern.
151
+ #
152
+ # @param [Addressable::URI, #to_str] uri
153
+ # The URI to extract from.
154
+ #
155
+ # @param [#restore, #match] processor
156
+ # A template processor object may optionally be supplied.
157
+ #
158
+ # The object should respond to either the <tt>restore</tt> or
159
+ # <tt>match</tt> messages or both. The <tt>restore</tt> method should take
160
+ # two parameters: [String] name and [String] value. The <tt>restore</tt>
161
+ # method should reverse any transformations that have been performed on the
162
+ # value to ensure a valid URI. The <tt>match</tt> method should take a
163
+ # single parameter: [String] name. The <tt>match</tt> method should return
164
+ # a <tt>String</tt> containing a regular expression capture group for
165
+ # matching on that particular variable. The default value is ".*?". The
166
+ # <tt>match</tt> method has no effect on multivariate operator expansions.
167
+ #
168
+ # @return [Hash, NilClass]
169
+ # The <tt>Hash</tt> mapping that was extracted from the URI, or
170
+ # <tt>nil</tt> if the URI didn't match the template.
171
+ #
172
+ # @example
173
+ # class ExampleProcessor
174
+ # def self.restore(name, value)
175
+ # return value.gsub(/\+/, " ") if name == "query"
176
+ # return value
177
+ # end
178
+ #
179
+ # def self.match(name)
180
+ # return ".*?" if name == "first"
181
+ # return ".*"
182
+ # end
183
+ # end
184
+ #
185
+ # uri = Addressable::URI.parse(
186
+ # "http://example.com/search/an+example+search+query/"
187
+ # )
188
+ # Addressable::Template.new(
189
+ # "http://example.com/search/{query}/"
190
+ # ).extract(uri, ExampleProcessor)
191
+ # #=> {"query" => "an example search query"}
192
+ #
193
+ # uri = Addressable::URI.parse("http://example.com/a/b/c/")
194
+ # Addressable::Template.new(
195
+ # "http://example.com/{first}/{second}/"
196
+ # ).extract(uri, ExampleProcessor)
197
+ # #=> {"first" => "a", "second" => "b/c"}
198
+ #
199
+ # uri = Addressable::URI.parse("http://example.com/a/b/c/")
200
+ # Addressable::Template.new(
201
+ # "http://example.com/{first}/{-list|/|second}/"
202
+ # ).extract(uri)
203
+ # #=> {"first" => "a", "second" => ["b", "c"]}
204
+ def extract(uri, processor=nil)
205
+ match_data = self.match(uri, processor)
206
+ return (match_data ? match_data.mapping : nil)
207
+ end
208
+
209
+ ##
210
+ # Extracts match data from the URI using a URI Template pattern.
211
+ #
212
+ # @param [Addressable::URI, #to_str] uri
213
+ # The URI to extract from.
214
+ #
215
+ # @param [#restore, #match] processor
216
+ # A template processor object may optionally be supplied.
217
+ #
218
+ # The object should respond to either the <tt>restore</tt> or
219
+ # <tt>match</tt> messages or both. The <tt>restore</tt> method should take
220
+ # two parameters: [String] name and [String] value. The <tt>restore</tt>
221
+ # method should reverse any transformations that have been performed on the
222
+ # value to ensure a valid URI. The <tt>match</tt> method should take a
223
+ # single parameter: [String] name. The <tt>match</tt> method should return
224
+ # a <tt>String</tt> containing a regular expression capture group for
225
+ # matching on that particular variable. The default value is ".*?". The
226
+ # <tt>match</tt> method has no effect on multivariate operator expansions.
227
+ #
228
+ # @return [Hash, NilClass]
229
+ # The <tt>Hash</tt> mapping that was extracted from the URI, or
230
+ # <tt>nil</tt> if the URI didn't match the template.
231
+ #
232
+ # @example
233
+ # class ExampleProcessor
234
+ # def self.restore(name, value)
235
+ # return value.gsub(/\+/, " ") if name == "query"
236
+ # return value
237
+ # end
238
+ #
239
+ # def self.match(name)
240
+ # return ".*?" if name == "first"
241
+ # return ".*"
242
+ # end
243
+ # end
244
+ #
245
+ # uri = Addressable::URI.parse(
246
+ # "http://example.com/search/an+example+search+query/"
247
+ # )
248
+ # match = Addressable::Template.new(
249
+ # "http://example.com/search/{query}/"
250
+ # ).match(uri, ExampleProcessor)
251
+ # match.variables
252
+ # #=> ["query"]
253
+ # match.captures
254
+ # #=> ["an example search query"]
255
+ #
256
+ # uri = Addressable::URI.parse("http://example.com/a/b/c/")
257
+ # match = Addressable::Template.new(
258
+ # "http://example.com/{first}/{second}/"
259
+ # ).match(uri, ExampleProcessor)
260
+ # match.variables
261
+ # #=> ["first", "second"]
262
+ # match.captures
263
+ # #=> ["a", "b/c"]
264
+ #
265
+ # uri = Addressable::URI.parse("http://example.com/a/b/c/")
266
+ # match = Addressable::Template.new(
267
+ # "http://example.com/{first}/{-list|/|second}/"
268
+ # ).match(uri)
269
+ # match.variables
270
+ # #=> ["first", "second"]
271
+ # match.captures
272
+ # #=> ["a", ["b", "c"]]
273
+ def match(uri, processor=nil)
274
+ uri = Addressable::URI.parse(uri)
275
+ mapping = {}
276
+
277
+ # First, we need to process the pattern, and extract the values.
278
+ expansions, expansion_regexp =
279
+ parse_template_pattern(pattern, processor)
280
+ unparsed_values = uri.to_str.scan(expansion_regexp).flatten
281
+
282
+ if uri.to_str == pattern
283
+ return Addressable::Template::MatchData.new(uri, self, mapping)
284
+ elsif expansions.size > 0 && expansions.size == unparsed_values.size
285
+ expansions.each_with_index do |expansion, index|
286
+ unparsed_value = unparsed_values[index]
287
+ if expansion =~ OPERATOR_EXPANSION
288
+ operator, argument, variables =
289
+ parse_template_expansion(expansion)
290
+ extract_method = "extract_#{operator}_operator"
291
+ if ([extract_method, extract_method.to_sym] &
292
+ private_methods).empty?
293
+ raise InvalidTemplateOperatorError,
294
+ "Invalid template operator: #{operator}"
295
+ else
296
+ begin
297
+ send(
298
+ extract_method.to_sym, unparsed_value, processor,
299
+ argument, variables, mapping
300
+ )
301
+ rescue TemplateOperatorAbortedError
302
+ return nil
303
+ end
304
+ end
305
+ else
306
+ name = expansion[VARIABLE_EXPANSION, 1]
307
+ value = unparsed_value
308
+ if processor != nil && processor.respond_to?(:restore)
309
+ value = processor.restore(name, value)
310
+ end
311
+ if mapping[name] == nil || mapping[name] == value
312
+ mapping[name] = value
313
+ else
314
+ return nil
315
+ end
316
+ end
317
+ end
318
+ return Addressable::Template::MatchData.new(uri, self, mapping)
319
+ else
320
+ return nil
321
+ end
322
+ end
323
+
324
+ ##
325
+ # Expands a URI template into another URI template.
326
+ #
327
+ # @param [Hash] mapping The mapping that corresponds to the pattern.
328
+ # @param [#validate, #transform] processor
329
+ # An optional processor object may be supplied.
330
+ #
331
+ # The object should respond to either the <tt>validate</tt> or
332
+ # <tt>transform</tt> messages or both. Both the <tt>validate</tt> and
333
+ # <tt>transform</tt> methods should take two parameters: <tt>name</tt> and
334
+ # <tt>value</tt>. The <tt>validate</tt> method should return <tt>true</tt>
335
+ # or <tt>false</tt>; <tt>true</tt> if the value of the variable is valid,
336
+ # <tt>false</tt> otherwise. An <tt>InvalidTemplateValueError</tt>
337
+ # exception will be raised if the value is invalid. The <tt>transform</tt>
338
+ # method should return the transformed variable value as a <tt>String</tt>.
339
+ # If a <tt>transform</tt> method is used, the value will not be percent
340
+ # encoded automatically. Unicode normalization will be performed both
341
+ # before and after sending the value to the transform method.
342
+ #
343
+ # @return [Addressable::Template] The partially expanded URI template.
344
+ #
345
+ # @example
346
+ # Addressable::Template.new(
347
+ # "http://example.com/{one}/{two}/"
348
+ # ).partial_expand({"one" => "1"}).pattern
349
+ # #=> "http://example.com/1/{two}/"
350
+ #
351
+ # Addressable::Template.new(
352
+ # "http://example.com/search/{-list|+|query}/"
353
+ # ).partial_expand(
354
+ # {"query" => "an example search query".split(" ")}
355
+ # ).pattern
356
+ # #=> "http://example.com/search/an+example+search+query/"
357
+ #
358
+ # Addressable::Template.new(
359
+ # "http://example.com/{-join|&|one,two}/"
360
+ # ).partial_expand({"one" => "1"}).pattern
361
+ # #=> "http://example.com/?one=1{-prefix|&two=|two}"
362
+ #
363
+ # Addressable::Template.new(
364
+ # "http://example.com/{-join|&|one,two,three}/"
365
+ # ).partial_expand({"one" => "1", "three" => 3}).pattern
366
+ # #=> "http://example.com/?one=1{-prefix|&two=|two}&three=3"
367
+ def partial_expand(mapping, processor=nil)
368
+ result = self.pattern.dup
369
+ transformed_mapping = transform_mapping(mapping, processor)
370
+ result.gsub!(
371
+ /#{OPERATOR_EXPANSION}|#{VARIABLE_EXPANSION}/
372
+ ) do |capture|
373
+ if capture =~ OPERATOR_EXPANSION
374
+ operator, argument, variables, default_mapping =
375
+ parse_template_expansion(capture, transformed_mapping)
376
+ expand_method = "expand_#{operator}_operator"
377
+ if ([expand_method, expand_method.to_sym] & private_methods).empty?
378
+ raise InvalidTemplateOperatorError,
379
+ "Invalid template operator: #{operator}"
380
+ else
381
+ send(
382
+ expand_method.to_sym, argument, variables,
383
+ default_mapping, true
384
+ )
385
+ end
386
+ else
387
+ varname, _, vardefault = capture.scan(/^\{(.+?)(=(.*))?\}$/)[0]
388
+ if transformed_mapping[varname]
389
+ transformed_mapping[varname]
390
+ elsif vardefault
391
+ "{#{varname}=#{vardefault}}"
392
+ else
393
+ "{#{varname}}"
394
+ end
395
+ end
396
+ end
397
+ return Addressable::Template.new(result)
398
+ end
399
+
400
+ ##
401
+ # Expands a URI template into a full URI.
402
+ #
403
+ # @param [Hash] mapping The mapping that corresponds to the pattern.
404
+ # @param [#validate, #transform] processor
405
+ # An optional processor object may be supplied.
406
+ #
407
+ # The object should respond to either the <tt>validate</tt> or
408
+ # <tt>transform</tt> messages or both. Both the <tt>validate</tt> and
409
+ # <tt>transform</tt> methods should take two parameters: <tt>name</tt> and
410
+ # <tt>value</tt>. The <tt>validate</tt> method should return <tt>true</tt>
411
+ # or <tt>false</tt>; <tt>true</tt> if the value of the variable is valid,
412
+ # <tt>false</tt> otherwise. An <tt>InvalidTemplateValueError</tt>
413
+ # exception will be raised if the value is invalid. The <tt>transform</tt>
414
+ # method should return the transformed variable value as a <tt>String</tt>.
415
+ # If a <tt>transform</tt> method is used, the value will not be percent
416
+ # encoded automatically. Unicode normalization will be performed both
417
+ # before and after sending the value to the transform method.
418
+ #
419
+ # @return [Addressable::URI] The expanded URI template.
420
+ #
421
+ # @example
422
+ # class ExampleProcessor
423
+ # def self.validate(name, value)
424
+ # return !!(value =~ /^[\w ]+$/) if name == "query"
425
+ # return true
426
+ # end
427
+ #
428
+ # def self.transform(name, value)
429
+ # return value.gsub(/ /, "+") if name == "query"
430
+ # return value
431
+ # end
432
+ # end
433
+ #
434
+ # Addressable::Template.new(
435
+ # "http://example.com/search/{query}/"
436
+ # ).expand(
437
+ # {"query" => "an example search query"},
438
+ # ExampleProcessor
439
+ # ).to_str
440
+ # #=> "http://example.com/search/an+example+search+query/"
441
+ #
442
+ # Addressable::Template.new(
443
+ # "http://example.com/search/{-list|+|query}/"
444
+ # ).expand(
445
+ # {"query" => "an example search query".split(" ")}
446
+ # ).to_str
447
+ # #=> "http://example.com/search/an+example+search+query/"
448
+ #
449
+ # Addressable::Template.new(
450
+ # "http://example.com/search/{query}/"
451
+ # ).expand(
452
+ # {"query" => "bogus!"},
453
+ # ExampleProcessor
454
+ # ).to_str
455
+ # #=> Addressable::Template::InvalidTemplateValueError
456
+ def expand(mapping, processor=nil)
457
+ result = self.pattern.dup
458
+ transformed_mapping = transform_mapping(mapping, processor)
459
+ result.gsub!(
460
+ /#{OPERATOR_EXPANSION}|#{VARIABLE_EXPANSION}/
461
+ ) do |capture|
462
+ if capture =~ OPERATOR_EXPANSION
463
+ operator, argument, variables, default_mapping =
464
+ parse_template_expansion(capture, transformed_mapping)
465
+ expand_method = "expand_#{operator}_operator"
466
+ if ([expand_method, expand_method.to_sym] & private_methods).empty?
467
+ raise InvalidTemplateOperatorError,
468
+ "Invalid template operator: #{operator}"
469
+ else
470
+ send(expand_method.to_sym, argument, variables, default_mapping)
471
+ end
472
+ else
473
+ varname, _, vardefault = capture.scan(/^\{(.+?)(=(.*))?\}$/)[0]
474
+ transformed_mapping[varname] || vardefault
475
+ end
476
+ end
477
+ return Addressable::URI.parse(result)
478
+ end
479
+
480
+ ##
481
+ # Returns an Array of variables used within the template pattern.
482
+ # The variables are listed in the Array in the order they appear within
483
+ # the pattern. Multiple occurrences of a variable within a pattern are
484
+ # not represented in this Array.
485
+ #
486
+ # @return [Array] The variables present in the template's pattern.
487
+ def variables
488
+ @variables ||= ordered_variable_defaults.map { |var, val| var }.uniq
489
+ end
490
+ alias_method :keys, :variables
491
+
492
+ ##
493
+ # Returns a mapping of variables to their default values specified
494
+ # in the template. Variables without defaults are not returned.
495
+ #
496
+ # @return [Hash] Mapping of template variables to their defaults
497
+ def variable_defaults
498
+ @variable_defaults ||=
499
+ Hash[*ordered_variable_defaults.reject { |k, v| v.nil? }.flatten]
500
+ end
501
+
502
+ private
503
+ def ordered_variable_defaults
504
+ @ordered_variable_defaults ||= (begin
505
+ expansions, expansion_regexp = parse_template_pattern(pattern)
506
+
507
+ expansions.inject([]) do |result, expansion|
508
+ case expansion
509
+ when OPERATOR_EXPANSION
510
+ _, _, variables, mapping = parse_template_expansion(expansion)
511
+ result.concat variables.map { |var| [var, mapping[var]] }
512
+ when VARIABLE_EXPANSION
513
+ result << [$1, $2]
514
+ end
515
+ result
516
+ end
517
+ end)
518
+ end
519
+
520
+ ##
521
+ # Transforms a mapping so that values can be substituted into the
522
+ # template.
523
+ #
524
+ # @param [Hash] mapping The mapping of variables to values.
525
+ # @param [#validate, #transform] processor
526
+ # An optional processor object may be supplied.
527
+ #
528
+ # The object should respond to either the <tt>validate</tt> or
529
+ # <tt>transform</tt> messages or both. Both the <tt>validate</tt> and
530
+ # <tt>transform</tt> methods should take two parameters: <tt>name</tt> and
531
+ # <tt>value</tt>. The <tt>validate</tt> method should return <tt>true</tt>
532
+ # or <tt>false</tt>; <tt>true</tt> if the value of the variable is valid,
533
+ # <tt>false</tt> otherwise. An <tt>InvalidTemplateValueError</tt> exception
534
+ # will be raised if the value is invalid. The <tt>transform</tt> method
535
+ # should return the transformed variable value as a <tt>String</tt>. If a
536
+ # <tt>transform</tt> method is used, the value will not be percent encoded
537
+ # automatically. Unicode normalization will be performed both before and
538
+ # after sending the value to the transform method.
539
+ #
540
+ # @return [Hash] The transformed mapping.
541
+ def transform_mapping(mapping, processor=nil)
542
+ return mapping.inject({}) do |accu, pair|
543
+ name, value = pair
544
+ value = value.to_s if Numeric === value || Symbol === value
545
+
546
+ unless value.respond_to?(:to_ary) || value.respond_to?(:to_str)
547
+ raise TypeError,
548
+ "Can't convert #{value.class} into String or Array."
549
+ end
550
+
551
+ if Symbol === name
552
+ name = name.to_s
553
+ elsif name.respond_to?(:to_str)
554
+ name = name.to_str
555
+ else
556
+ raise TypeError,
557
+ "Can't convert #{name.class} into String."
558
+ end
559
+ value = value.respond_to?(:to_ary) ? value.to_ary : value.to_str
560
+
561
+ # Handle unicode normalization
562
+ if value.kind_of?(Array)
563
+ value.map! { |val| Addressable::IDNA.unicode_normalize_kc(val) }
564
+ else
565
+ value = Addressable::IDNA.unicode_normalize_kc(value)
566
+ end
567
+
568
+ if processor == nil || !processor.respond_to?(:transform)
569
+ # Handle percent escaping
570
+ if value.kind_of?(Array)
571
+ transformed_value = value.map do |val|
572
+ Addressable::URI.encode_component(
573
+ val, Addressable::URI::CharacterClasses::UNRESERVED)
574
+ end
575
+ else
576
+ transformed_value = Addressable::URI.encode_component(
577
+ value, Addressable::URI::CharacterClasses::UNRESERVED)
578
+ end
579
+ end
580
+
581
+ # Process, if we've got a processor
582
+ if processor != nil
583
+ if processor.respond_to?(:validate)
584
+ if !processor.validate(name, value)
585
+ display_value = value.kind_of?(Array) ? value.inspect : value
586
+ raise InvalidTemplateValueError,
587
+ "#{name}=#{display_value} is an invalid template value."
588
+ end
589
+ end
590
+ if processor.respond_to?(:transform)
591
+ transformed_value = processor.transform(name, value)
592
+ if transformed_value.kind_of?(Array)
593
+ transformed_value.map! do |val|
594
+ Addressable::IDNA.unicode_normalize_kc(val)
595
+ end
596
+ else
597
+ transformed_value =
598
+ Addressable::IDNA.unicode_normalize_kc(transformed_value)
599
+ end
600
+ end
601
+ end
602
+
603
+ accu[name] = transformed_value
604
+ accu
605
+ end
606
+ end
607
+
608
+ ##
609
+ # Expands a URI Template opt operator.
610
+ #
611
+ # @param [String] argument The argument to the operator.
612
+ # @param [Array] variables The variables the operator is working on.
613
+ # @param [Hash] mapping The mapping of variables to values.
614
+ #
615
+ # @return [String] The expanded result.
616
+ def expand_opt_operator(argument, variables, mapping, partial=false)
617
+ variables_present = variables.any? do |variable|
618
+ mapping[variable] != [] &&
619
+ mapping[variable]
620
+ end
621
+ if partial && !variables_present
622
+ "{-opt|#{argument}|#{variables.join(",")}}"
623
+ elsif variables_present
624
+ argument
625
+ else
626
+ ""
627
+ end
628
+ end
629
+
630
+ ##
631
+ # Expands a URI Template neg operator.
632
+ #
633
+ # @param [String] argument The argument to the operator.
634
+ # @param [Array] variables The variables the operator is working on.
635
+ # @param [Hash] mapping The mapping of variables to values.
636
+ #
637
+ # @return [String] The expanded result.
638
+ def expand_neg_operator(argument, variables, mapping, partial=false)
639
+ variables_present = variables.any? do |variable|
640
+ mapping[variable] != [] &&
641
+ mapping[variable]
642
+ end
643
+ if partial && !variables_present
644
+ "{-neg|#{argument}|#{variables.join(",")}}"
645
+ elsif variables_present
646
+ ""
647
+ else
648
+ argument
649
+ end
650
+ end
651
+
652
+ ##
653
+ # Expands a URI Template prefix operator.
654
+ #
655
+ # @param [String] argument The argument to the operator.
656
+ # @param [Array] variables The variables the operator is working on.
657
+ # @param [Hash] mapping The mapping of variables to values.
658
+ #
659
+ # @return [String] The expanded result.
660
+ def expand_prefix_operator(argument, variables, mapping, partial=false)
661
+ if variables.size != 1
662
+ raise InvalidTemplateOperatorError,
663
+ "Template operator 'prefix' takes exactly one variable."
664
+ end
665
+ value = mapping[variables.first]
666
+ if !partial || value
667
+ if value.kind_of?(Array)
668
+ (value.map { |list_value| argument + list_value }).join("")
669
+ elsif value
670
+ argument + value.to_s
671
+ end
672
+ else
673
+ "{-prefix|#{argument}|#{variables.first}}"
674
+ end
675
+ end
676
+
677
+ ##
678
+ # Expands a URI Template suffix operator.
679
+ #
680
+ # @param [String] argument The argument to the operator.
681
+ # @param [Array] variables The variables the operator is working on.
682
+ # @param [Hash] mapping The mapping of variables to values.
683
+ #
684
+ # @return [String] The expanded result.
685
+ def expand_suffix_operator(argument, variables, mapping, partial=false)
686
+ if variables.size != 1
687
+ raise InvalidTemplateOperatorError,
688
+ "Template operator 'suffix' takes exactly one variable."
689
+ end
690
+ value = mapping[variables.first]
691
+ if !partial || value
692
+ if value.kind_of?(Array)
693
+ (value.map { |list_value| list_value + argument }).join("")
694
+ elsif value
695
+ value.to_s + argument
696
+ end
697
+ else
698
+ "{-suffix|#{argument}|#{variables.first}}"
699
+ end
700
+ end
701
+
702
+ ##
703
+ # Expands a URI Template join operator.
704
+ #
705
+ # @param [String] argument The argument to the operator.
706
+ # @param [Array] variables The variables the operator is working on.
707
+ # @param [Hash] mapping The mapping of variables to values.
708
+ #
709
+ # @return [String] The expanded result.
710
+ def expand_join_operator(argument, variables, mapping, partial=false)
711
+ if !partial
712
+ variable_values = variables.inject([]) do |accu, variable|
713
+ if !mapping[variable].kind_of?(Array)
714
+ if mapping[variable]
715
+ accu << variable + "=" + (mapping[variable])
716
+ end
717
+ else
718
+ raise InvalidTemplateOperatorError,
719
+ "Template operator 'join' does not accept Array values."
720
+ end
721
+ accu
722
+ end
723
+ variable_values.join(argument)
724
+ else
725
+ buffer = ""
726
+ state = :suffix
727
+ variables.each_with_index do |variable, index|
728
+ if !mapping[variable].kind_of?(Array)
729
+ if mapping[variable]
730
+ if buffer.empty? || buffer[-1..-1] == "}"
731
+ buffer << (variable + "=" + (mapping[variable]))
732
+ elsif state == :suffix
733
+ buffer << argument
734
+ buffer << (variable + "=" + (mapping[variable]))
735
+ else
736
+ buffer << (variable + "=" + (mapping[variable]))
737
+ end
738
+ else
739
+ if !buffer.empty? && (buffer[-1..-1] != "}" || state == :prefix)
740
+ buffer << "{-opt|#{argument}|#{variable}}"
741
+ state = :prefix
742
+ end
743
+ if buffer.empty? && variables.size == 1
744
+ # Evaluates back to itself
745
+ buffer << "{-join|#{argument}|#{variable}}"
746
+ else
747
+ buffer << "{-prefix|#{variable}=|#{variable}}"
748
+ end
749
+ if (index != (variables.size - 1) && state == :suffix)
750
+ buffer << "{-opt|#{argument}|#{variable}}"
751
+ elsif index != (variables.size - 1) &&
752
+ mapping[variables[index + 1]]
753
+ buffer << argument
754
+ state = :prefix
755
+ end
756
+ end
757
+ else
758
+ raise InvalidTemplateOperatorError,
759
+ "Template operator 'join' does not accept Array values."
760
+ end
761
+ end
762
+ buffer
763
+ end
764
+ end
765
+
766
+ ##
767
+ # Expands a URI Template list operator.
768
+ #
769
+ # @param [String] argument The argument to the operator.
770
+ # @param [Array] variables The variables the operator is working on.
771
+ # @param [Hash] mapping The mapping of variables to values.
772
+ #
773
+ # @return [String] The expanded result.
774
+ def expand_list_operator(argument, variables, mapping, partial=false)
775
+ if variables.size != 1
776
+ raise InvalidTemplateOperatorError,
777
+ "Template operator 'list' takes exactly one variable."
778
+ end
779
+ if !partial || mapping[variables.first]
780
+ values = mapping[variables.first]
781
+ if values
782
+ if values.kind_of?(Array)
783
+ values.join(argument)
784
+ else
785
+ raise InvalidTemplateOperatorError,
786
+ "Template operator 'list' only accepts Array values."
787
+ end
788
+ end
789
+ else
790
+ "{-list|#{argument}|#{variables.first}}"
791
+ end
792
+ end
793
+
794
+ ##
795
+ # Parses a URI template expansion <tt>String</tt>.
796
+ #
797
+ # @param [String] expansion The operator <tt>String</tt>.
798
+ # @param [Hash] mapping An optional mapping to merge defaults into.
799
+ #
800
+ # @return [Array]
801
+ # A tuple of the operator, argument, variables, and mapping.
802
+ def parse_template_expansion(capture, mapping={})
803
+ operator, argument, variables = capture[1...-1].split("|", -1)
804
+ operator.gsub!(/^\-/, "")
805
+ variables = variables.split(",", -1)
806
+ mapping = (variables.inject({}) do |accu, var|
807
+ varname, _, vardefault = var.scan(/^(.+?)(=(.*))?$/)[0]
808
+ accu[varname] = vardefault
809
+ accu
810
+ end).merge(mapping)
811
+ variables = variables.map { |var| var.gsub(/=.*$/, "") }
812
+ return operator, argument, variables, mapping
813
+ end
814
+
815
+ ##
816
+ # Generates the <tt>Regexp</tt> that parses a template pattern.
817
+ #
818
+ # @param [String] pattern The URI template pattern.
819
+ # @param [#match] processor The template processor to use.
820
+ #
821
+ # @return [Regexp]
822
+ # A regular expression which may be used to parse a template pattern.
823
+ def parse_template_pattern(pattern, processor=nil)
824
+ # Escape the pattern. The two gsubs restore the escaped curly braces
825
+ # back to their original form. Basically, escape everything that isn't
826
+ # within an expansion.
827
+ escaped_pattern = Regexp.escape(
828
+ pattern
829
+ ).gsub(/\\\{(.*?)\\\}/) do |escaped|
830
+ escaped.gsub(/\\(.)/, "\\1")
831
+ end
832
+
833
+ expansions = []
834
+
835
+ # Create a regular expression that captures the values of the
836
+ # variables in the URI.
837
+ regexp_string = escaped_pattern.gsub(
838
+ /#{OPERATOR_EXPANSION}|#{VARIABLE_EXPANSION}/
839
+ ) do |expansion|
840
+ expansions << expansion
841
+ if expansion =~ OPERATOR_EXPANSION
842
+ capture_group = "(.*)"
843
+ operator, argument, names, _ =
844
+ parse_template_expansion(expansion)
845
+ if processor != nil && processor.respond_to?(:match)
846
+ # We can only lookup the match values for single variable
847
+ # operator expansions. Besides, ".*" is usually the only
848
+ # reasonable value for multivariate operators anyways.
849
+ if ["prefix", "suffix", "list"].include?(operator)
850
+ capture_group = "(#{processor.match(names.first)})"
851
+ end
852
+ elsif operator == "prefix"
853
+ capture_group = "(#{Regexp.escape(argument)}.*?)"
854
+ elsif operator == "suffix"
855
+ capture_group = "(.*?#{Regexp.escape(argument)})"
856
+ end
857
+ capture_group
858
+ else
859
+ capture_group = "(.*?)"
860
+ if processor != nil && processor.respond_to?(:match)
861
+ name = expansion[/\{([^\}=]+)(=[^\}]+)?\}/, 1]
862
+ capture_group = "(#{processor.match(name)})"
863
+ end
864
+ capture_group
865
+ end
866
+ end
867
+
868
+ # Ensure that the regular expression matches the whole URI.
869
+ regexp_string = "^#{regexp_string}$"
870
+
871
+ return expansions, Regexp.new(regexp_string)
872
+ end
873
+
874
+ ##
875
+ # Extracts a URI Template opt operator.
876
+ #
877
+ # @param [String] value The unparsed value to extract from.
878
+ # @param [#restore] processor The processor object.
879
+ # @param [String] argument The argument to the operator.
880
+ # @param [Array] variables The variables the operator is working on.
881
+ # @param [Hash] mapping The mapping of variables to values.
882
+ #
883
+ # @return [String] The extracted result.
884
+ def extract_opt_operator(
885
+ value, processor, argument, variables, mapping)
886
+ if value != "" && value != argument
887
+ raise TemplateOperatorAbortedError,
888
+ "Value for template operator 'opt' was unexpected."
889
+ end
890
+ end
891
+
892
+ ##
893
+ # Extracts a URI Template neg operator.
894
+ #
895
+ # @param [String] value The unparsed value to extract from.
896
+ # @param [#restore] processor The processor object.
897
+ # @param [String] argument The argument to the operator.
898
+ # @param [Array] variables The variables the operator is working on.
899
+ # @param [Hash] mapping The mapping of variables to values.
900
+ #
901
+ # @return [String] The extracted result.
902
+ def extract_neg_operator(
903
+ value, processor, argument, variables, mapping)
904
+ if value != "" && value != argument
905
+ raise TemplateOperatorAbortedError,
906
+ "Value for template operator 'neg' was unexpected."
907
+ end
908
+ end
909
+
910
+ ##
911
+ # Extracts a URI Template prefix operator.
912
+ #
913
+ # @param [String] value The unparsed value to extract from.
914
+ # @param [#restore] processor The processor object.
915
+ # @param [String] argument The argument to the operator.
916
+ # @param [Array] variables The variables the operator is working on.
917
+ # @param [Hash] mapping The mapping of variables to values.
918
+ #
919
+ # @return [String] The extracted result.
920
+ def extract_prefix_operator(
921
+ value, processor, argument, variables, mapping)
922
+ if variables.size != 1
923
+ raise InvalidTemplateOperatorError,
924
+ "Template operator 'prefix' takes exactly one variable."
925
+ end
926
+ if value[0...argument.size] != argument
927
+ raise TemplateOperatorAbortedError,
928
+ "Value for template operator 'prefix' missing expected prefix."
929
+ end
930
+ values = value.split(argument, -1)
931
+ values << "" if value[-argument.size..-1] == argument
932
+ values.shift if values[0] == ""
933
+ values.pop if values[-1] == ""
934
+
935
+ if processor && processor.respond_to?(:restore)
936
+ values.map! { |value| processor.restore(variables.first, value) }
937
+ end
938
+ values = values.first if values.size == 1
939
+ if mapping[variables.first] == nil || mapping[variables.first] == values
940
+ mapping[variables.first] = values
941
+ else
942
+ raise TemplateOperatorAbortedError,
943
+ "Value mismatch for repeated variable."
944
+ end
945
+ end
946
+
947
+ ##
948
+ # Extracts a URI Template suffix operator.
949
+ #
950
+ # @param [String] value The unparsed value to extract from.
951
+ # @param [#restore] processor The processor object.
952
+ # @param [String] argument The argument to the operator.
953
+ # @param [Array] variables The variables the operator is working on.
954
+ # @param [Hash] mapping The mapping of variables to values.
955
+ #
956
+ # @return [String] The extracted result.
957
+ def extract_suffix_operator(
958
+ value, processor, argument, variables, mapping)
959
+ if variables.size != 1
960
+ raise InvalidTemplateOperatorError,
961
+ "Template operator 'suffix' takes exactly one variable."
962
+ end
963
+ if value[-argument.size..-1] != argument
964
+ raise TemplateOperatorAbortedError,
965
+ "Value for template operator 'suffix' missing expected suffix."
966
+ end
967
+ values = value.split(argument, -1)
968
+ values.pop if values[-1] == ""
969
+ if processor && processor.respond_to?(:restore)
970
+ values.map! { |value| processor.restore(variables.first, value) }
971
+ end
972
+ values = values.first if values.size == 1
973
+ if mapping[variables.first] == nil || mapping[variables.first] == values
974
+ mapping[variables.first] = values
975
+ else
976
+ raise TemplateOperatorAbortedError,
977
+ "Value mismatch for repeated variable."
978
+ end
979
+ end
980
+
981
+ ##
982
+ # Extracts a URI Template join operator.
983
+ #
984
+ # @param [String] value The unparsed value to extract from.
985
+ # @param [#restore] processor The processor object.
986
+ # @param [String] argument The argument to the operator.
987
+ # @param [Array] variables The variables the operator is working on.
988
+ # @param [Hash] mapping The mapping of variables to values.
989
+ #
990
+ # @return [String] The extracted result.
991
+ def extract_join_operator(value, processor, argument, variables, mapping)
992
+ unparsed_values = value.split(argument)
993
+ parsed_variables = []
994
+ for unparsed_value in unparsed_values
995
+ name = unparsed_value[/^(.+?)=(.+)$/, 1]
996
+ parsed_variables << name
997
+ parsed_value = unparsed_value[/^(.+?)=(.+)$/, 2]
998
+ if processor && processor.respond_to?(:restore)
999
+ parsed_value = processor.restore(name, parsed_value)
1000
+ end
1001
+ if mapping[name] == nil || mapping[name] == parsed_value
1002
+ mapping[name] = parsed_value
1003
+ else
1004
+ raise TemplateOperatorAbortedError,
1005
+ "Value mismatch for repeated variable."
1006
+ end
1007
+ end
1008
+ for variable in variables
1009
+ if !parsed_variables.include?(variable) && mapping[variable] != nil
1010
+ raise TemplateOperatorAbortedError,
1011
+ "Value mismatch for repeated variable."
1012
+ end
1013
+ end
1014
+ if (parsed_variables & variables) != parsed_variables
1015
+ raise TemplateOperatorAbortedError,
1016
+ "Template operator 'join' variable mismatch: " +
1017
+ "#{parsed_variables.inspect}, #{variables.inspect}"
1018
+ end
1019
+ end
1020
+
1021
+ ##
1022
+ # Extracts a URI Template list operator.
1023
+ #
1024
+ # @param [String] value The unparsed value to extract from.
1025
+ # @param [#restore] processor The processor object.
1026
+ # @param [String] argument The argument to the operator.
1027
+ # @param [Array] variables The variables the operator is working on.
1028
+ # @param [Hash] mapping The mapping of variables to values.
1029
+ #
1030
+ # @return [String] The extracted result.
1031
+ def extract_list_operator(value, processor, argument, variables, mapping)
1032
+ if variables.size != 1
1033
+ raise InvalidTemplateOperatorError,
1034
+ "Template operator 'list' takes exactly one variable."
1035
+ end
1036
+ values = value.split(argument, -1)
1037
+ values.pop if values[-1] == ""
1038
+ if processor && processor.respond_to?(:restore)
1039
+ values.map! { |value| processor.restore(variables.first, value) }
1040
+ end
1041
+ if mapping[variables.first] == nil || mapping[variables.first] == values
1042
+ mapping[variables.first] = values
1043
+ else
1044
+ raise TemplateOperatorAbortedError,
1045
+ "Value mismatch for repeated variable."
1046
+ end
1047
+ end
1048
+ end
1049
+ end