cifrado 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gitignore +18 -0
  3. data/CHANGELOG.md +44 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +247 -0
  7. data/RELEASE.md +10 -0
  8. data/Rakefile +21 -0
  9. data/TODO.md +6 -0
  10. data/bin/cifrado +7 -0
  11. data/cifrado.gemspec +31 -0
  12. data/gem-public_cert.pem +20 -0
  13. data/lib/cifrado.rb +48 -0
  14. data/lib/cifrado/cli.rb +140 -0
  15. data/lib/cifrado/cli/cinema.rb +81 -0
  16. data/lib/cifrado/cli/delete.rb +36 -0
  17. data/lib/cifrado/cli/download.rb +54 -0
  18. data/lib/cifrado/cli/jukebox.rb +94 -0
  19. data/lib/cifrado/cli/list.rb +64 -0
  20. data/lib/cifrado/cli/post.rb +10 -0
  21. data/lib/cifrado/cli/progressbar.rb +86 -0
  22. data/lib/cifrado/cli/saio.rb +11 -0
  23. data/lib/cifrado/cli/saio/base.rb +20 -0
  24. data/lib/cifrado/cli/saio/bootstrap.rb +118 -0
  25. data/lib/cifrado/cli/saio/destroy.rb +16 -0
  26. data/lib/cifrado/cli/saio/scripts/saio.sh.erb +445 -0
  27. data/lib/cifrado/cli/set_acl.rb +10 -0
  28. data/lib/cifrado/cli/setup.rb +64 -0
  29. data/lib/cifrado/cli/stat.rb +41 -0
  30. data/lib/cifrado/cli/upload.rb +269 -0
  31. data/lib/cifrado/config.rb +18 -0
  32. data/lib/cifrado/core_ext/ruby18_base64.rb +15 -0
  33. data/lib/cifrado/crypto_services.rb +218 -0
  34. data/lib/cifrado/file_splitter.rb +67 -0
  35. data/lib/cifrado/rate_limit.rb +23 -0
  36. data/lib/cifrado/streaming_downloader.rb +49 -0
  37. data/lib/cifrado/streaming_uploader.rb +57 -0
  38. data/lib/cifrado/swift_client.rb +313 -0
  39. data/lib/cifrado/utils.rb +59 -0
  40. data/lib/cifrado/version.rb +3 -0
  41. data/tests/cli/list_tests.rb +28 -0
  42. data/tests/cli/upload_multi_tests.rb +94 -0
  43. data/tests/cli/upload_tests.rb +167 -0
  44. data/tests/cli_tests.rb +2 -0
  45. data/tests/crypto_services_tests.rb +145 -0
  46. data/tests/file_splitter_tests.rb +61 -0
  47. data/tests/helper.rb +117 -0
  48. data/tests/swift_client/create_directory.rb +14 -0
  49. data/tests/swift_client/download_tests.rb +208 -0
  50. data/tests/swift_client/file_available.rb +25 -0
  51. data/tests/swift_client/head_tests.rb +34 -0
  52. data/tests/swift_client/match_tests.rb +29 -0
  53. data/tests/swift_client/upload_tests.rb +70 -0
  54. data/tests/swift_client_tests.rb +29 -0
  55. data/tests/utils_tests.rb +33 -0
  56. data/vendor/fog/.document +3 -0
  57. data/vendor/fog/.gitignore +23 -0
  58. data/vendor/fog/.irbrc +82 -0
  59. data/vendor/fog/.travis.yml +21 -0
  60. data/vendor/fog/README.cifrado +3 -0
  61. data/vendor/fog/README.md +156 -0
  62. data/vendor/fog/RELEASE.md +39 -0
  63. data/vendor/fog/changelog.txt +4156 -0
  64. data/vendor/fog/fog.gemspec +70 -0
  65. data/vendor/fog/lib/fog.rb +17 -0
  66. data/vendor/fog/lib/fog/cdn.rb +30 -0
  67. data/vendor/fog/lib/fog/compute.rb +127 -0
  68. data/vendor/fog/lib/fog/compute/models/server.rb +73 -0
  69. data/vendor/fog/lib/fog/core.rb +38 -0
  70. data/vendor/fog/lib/fog/core/attributes.rb +221 -0
  71. data/vendor/fog/lib/fog/core/collection.rb +145 -0
  72. data/vendor/fog/lib/fog/core/connection.rb +36 -0
  73. data/vendor/fog/lib/fog/core/credentials.rb +65 -0
  74. data/vendor/fog/lib/fog/core/current_machine.rb +34 -0
  75. data/vendor/fog/lib/fog/core/deprecated_connection_accessors.rb +41 -0
  76. data/vendor/fog/lib/fog/core/deprecation.rb +23 -0
  77. data/vendor/fog/lib/fog/core/errors.rb +108 -0
  78. data/vendor/fog/lib/fog/core/hmac.rb +48 -0
  79. data/vendor/fog/lib/fog/core/json.rb +34 -0
  80. data/vendor/fog/lib/fog/core/logger.rb +45 -0
  81. data/vendor/fog/lib/fog/core/mock.rb +92 -0
  82. data/vendor/fog/lib/fog/core/model.rb +79 -0
  83. data/vendor/fog/lib/fog/core/parser.rb +116 -0
  84. data/vendor/fog/lib/fog/core/provider.rb +35 -0
  85. data/vendor/fog/lib/fog/core/scp.rb +96 -0
  86. data/vendor/fog/lib/fog/core/service.rb +223 -0
  87. data/vendor/fog/lib/fog/core/ssh.rb +137 -0
  88. data/vendor/fog/lib/fog/core/time.rb +32 -0
  89. data/vendor/fog/lib/fog/core/timeout.rb +11 -0
  90. data/vendor/fog/lib/fog/core/wait_for.rb +15 -0
  91. data/vendor/fog/lib/fog/digitalocean.rb +9 -0
  92. data/vendor/fog/lib/fog/digitalocean/compute.rb +100 -0
  93. data/vendor/fog/lib/fog/digitalocean/examples/getting_started.md +106 -0
  94. data/vendor/fog/lib/fog/digitalocean/models/compute/flavor.rb +14 -0
  95. data/vendor/fog/lib/fog/digitalocean/models/compute/flavors.rb +25 -0
  96. data/vendor/fog/lib/fog/digitalocean/models/compute/image.rb +15 -0
  97. data/vendor/fog/lib/fog/digitalocean/models/compute/images.rb +25 -0
  98. data/vendor/fog/lib/fog/digitalocean/models/compute/region.rb +14 -0
  99. data/vendor/fog/lib/fog/digitalocean/models/compute/regions.rb +25 -0
  100. data/vendor/fog/lib/fog/digitalocean/models/compute/server.rb +150 -0
  101. data/vendor/fog/lib/fog/digitalocean/models/compute/servers.rb +27 -0
  102. data/vendor/fog/lib/fog/digitalocean/requests/compute/create_server.rb +49 -0
  103. data/vendor/fog/lib/fog/digitalocean/requests/compute/create_ssh_key.rb +26 -0
  104. data/vendor/fog/lib/fog/digitalocean/requests/compute/destroy_server.rb +28 -0
  105. data/vendor/fog/lib/fog/digitalocean/requests/compute/get_server_details.rb +25 -0
  106. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_flavors.rb +25 -0
  107. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_images.rb +25 -0
  108. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_regions.rb +25 -0
  109. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_servers.rb +25 -0
  110. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_ssh_keys.rb +25 -0
  111. data/vendor/fog/lib/fog/digitalocean/requests/compute/power_cycle_server.rb +25 -0
  112. data/vendor/fog/lib/fog/digitalocean/requests/compute/power_off_server.rb +25 -0
  113. data/vendor/fog/lib/fog/digitalocean/requests/compute/power_on_server.rb +25 -0
  114. data/vendor/fog/lib/fog/digitalocean/requests/compute/reboot_server.rb +25 -0
  115. data/vendor/fog/lib/fog/digitalocean/requests/compute/shutdown_server.rb +25 -0
  116. data/vendor/fog/lib/fog/dns.rb +59 -0
  117. data/vendor/fog/lib/fog/identity.rb +27 -0
  118. data/vendor/fog/lib/fog/image.rb +24 -0
  119. data/vendor/fog/lib/fog/local.rb +11 -0
  120. data/vendor/fog/lib/fog/local/models/storage/directories.rb +33 -0
  121. data/vendor/fog/lib/fog/local/models/storage/directory.rb +57 -0
  122. data/vendor/fog/lib/fog/local/models/storage/file.rb +131 -0
  123. data/vendor/fog/lib/fog/local/models/storage/files.rb +87 -0
  124. data/vendor/fog/lib/fog/local/storage.rb +103 -0
  125. data/vendor/fog/lib/fog/network.rb +26 -0
  126. data/vendor/fog/lib/fog/openstack.rb +214 -0
  127. data/vendor/fog/lib/fog/openstack/README.identity.md +69 -0
  128. data/vendor/fog/lib/fog/openstack/compute.rb +423 -0
  129. data/vendor/fog/lib/fog/openstack/identity.rb +299 -0
  130. data/vendor/fog/lib/fog/openstack/image.rb +217 -0
  131. data/vendor/fog/lib/fog/openstack/models/compute/address.rb +71 -0
  132. data/vendor/fog/lib/fog/openstack/models/compute/addresses.rb +33 -0
  133. data/vendor/fog/lib/fog/openstack/models/compute/flavor.rb +45 -0
  134. data/vendor/fog/lib/fog/openstack/models/compute/flavors.rb +28 -0
  135. data/vendor/fog/lib/fog/openstack/models/compute/host.rb +29 -0
  136. data/vendor/fog/lib/fog/openstack/models/compute/hosts.rb +32 -0
  137. data/vendor/fog/lib/fog/openstack/models/compute/image.rb +58 -0
  138. data/vendor/fog/lib/fog/openstack/models/compute/images.rb +33 -0
  139. data/vendor/fog/lib/fog/openstack/models/compute/key_pair.rb +60 -0
  140. data/vendor/fog/lib/fog/openstack/models/compute/key_pairs.rb +31 -0
  141. data/vendor/fog/lib/fog/openstack/models/compute/metadata.rb +68 -0
  142. data/vendor/fog/lib/fog/openstack/models/compute/metadatum.rb +29 -0
  143. data/vendor/fog/lib/fog/openstack/models/compute/network.rb +13 -0
  144. data/vendor/fog/lib/fog/openstack/models/compute/networks.rb +29 -0
  145. data/vendor/fog/lib/fog/openstack/models/compute/security_group.rb +44 -0
  146. data/vendor/fog/lib/fog/openstack/models/compute/security_groups.rb +27 -0
  147. data/vendor/fog/lib/fog/openstack/models/compute/server.rb +278 -0
  148. data/vendor/fog/lib/fog/openstack/models/compute/servers.rb +44 -0
  149. data/vendor/fog/lib/fog/openstack/models/compute/snapshot.rb +44 -0
  150. data/vendor/fog/lib/fog/openstack/models/compute/snapshots.rb +26 -0
  151. data/vendor/fog/lib/fog/openstack/models/compute/tenant.rb +24 -0
  152. data/vendor/fog/lib/fog/openstack/models/compute/tenants.rb +24 -0
  153. data/vendor/fog/lib/fog/openstack/models/compute/volume.rb +59 -0
  154. data/vendor/fog/lib/fog/openstack/models/compute/volumes.rb +26 -0
  155. data/vendor/fog/lib/fog/openstack/models/identity/ec2_credential.rb +44 -0
  156. data/vendor/fog/lib/fog/openstack/models/identity/ec2_credentials.rb +53 -0
  157. data/vendor/fog/lib/fog/openstack/models/identity/role.rb +50 -0
  158. data/vendor/fog/lib/fog/openstack/models/identity/roles.rb +21 -0
  159. data/vendor/fog/lib/fog/openstack/models/identity/tenant.rb +62 -0
  160. data/vendor/fog/lib/fog/openstack/models/identity/tenants.rb +29 -0
  161. data/vendor/fog/lib/fog/openstack/models/identity/user.rb +70 -0
  162. data/vendor/fog/lib/fog/openstack/models/identity/users.rb +32 -0
  163. data/vendor/fog/lib/fog/openstack/models/image/image.rb +91 -0
  164. data/vendor/fog/lib/fog/openstack/models/image/images.rb +60 -0
  165. data/vendor/fog/lib/fog/openstack/models/meta_parent.rb +33 -0
  166. data/vendor/fog/lib/fog/openstack/models/network/floating_ip.rb +52 -0
  167. data/vendor/fog/lib/fog/openstack/models/network/floating_ips.rb +34 -0
  168. data/vendor/fog/lib/fog/openstack/models/network/network.rb +47 -0
  169. data/vendor/fog/lib/fog/openstack/models/network/networks.rb +34 -0
  170. data/vendor/fog/lib/fog/openstack/models/network/port.rb +53 -0
  171. data/vendor/fog/lib/fog/openstack/models/network/ports.rb +34 -0
  172. data/vendor/fog/lib/fog/openstack/models/network/subnet.rb +56 -0
  173. data/vendor/fog/lib/fog/openstack/models/network/subnets.rb +34 -0
  174. data/vendor/fog/lib/fog/openstack/models/storage/directories.rb +39 -0
  175. data/vendor/fog/lib/fog/openstack/models/storage/directory.rb +50 -0
  176. data/vendor/fog/lib/fog/openstack/models/storage/file.rb +152 -0
  177. data/vendor/fog/lib/fog/openstack/models/storage/files.rb +94 -0
  178. data/vendor/fog/lib/fog/openstack/models/volume/volume.rb +47 -0
  179. data/vendor/fog/lib/fog/openstack/models/volume/volumes.rb +27 -0
  180. data/vendor/fog/lib/fog/openstack/network.rb +247 -0
  181. data/vendor/fog/lib/fog/openstack/requests/compute/add_fixed_ip.rb +29 -0
  182. data/vendor/fog/lib/fog/openstack/requests/compute/allocate_address.rb +42 -0
  183. data/vendor/fog/lib/fog/openstack/requests/compute/associate_address.rb +27 -0
  184. data/vendor/fog/lib/fog/openstack/requests/compute/attach_volume.rb +38 -0
  185. data/vendor/fog/lib/fog/openstack/requests/compute/boot_from_snapshot.rb +41 -0
  186. data/vendor/fog/lib/fog/openstack/requests/compute/change_server_password.rb +24 -0
  187. data/vendor/fog/lib/fog/openstack/requests/compute/confirm_resize_server.rb +24 -0
  188. data/vendor/fog/lib/fog/openstack/requests/compute/create_flavor.rb +85 -0
  189. data/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb +49 -0
  190. data/vendor/fog/lib/fog/openstack/requests/compute/create_key_pair.rb +49 -0
  191. data/vendor/fog/lib/fog/openstack/requests/compute/create_security_group.rb +52 -0
  192. data/vendor/fog/lib/fog/openstack/requests/compute/create_security_group_rule.rb +59 -0
  193. data/vendor/fog/lib/fog/openstack/requests/compute/create_server.rb +131 -0
  194. data/vendor/fog/lib/fog/openstack/requests/compute/create_volume.rb +54 -0
  195. data/vendor/fog/lib/fog/openstack/requests/compute/create_volume_snapshot.rb +47 -0
  196. data/vendor/fog/lib/fog/openstack/requests/compute/delete_flavor.rb +28 -0
  197. data/vendor/fog/lib/fog/openstack/requests/compute/delete_image.rb +40 -0
  198. data/vendor/fog/lib/fog/openstack/requests/compute/delete_key_pair.rb +31 -0
  199. data/vendor/fog/lib/fog/openstack/requests/compute/delete_metadata.rb +28 -0
  200. data/vendor/fog/lib/fog/openstack/requests/compute/delete_security_group.rb +33 -0
  201. data/vendor/fog/lib/fog/openstack/requests/compute/delete_security_group_rule.rb +31 -0
  202. data/vendor/fog/lib/fog/openstack/requests/compute/delete_server.rb +38 -0
  203. data/vendor/fog/lib/fog/openstack/requests/compute/delete_snapshot.rb +26 -0
  204. data/vendor/fog/lib/fog/openstack/requests/compute/delete_volume.rb +26 -0
  205. data/vendor/fog/lib/fog/openstack/requests/compute/detach_volume.rb +26 -0
  206. data/vendor/fog/lib/fog/openstack/requests/compute/disassociate_address.rb +27 -0
  207. data/vendor/fog/lib/fog/openstack/requests/compute/get_address.rb +41 -0
  208. data/vendor/fog/lib/fog/openstack/requests/compute/get_console_output.rb +28 -0
  209. data/vendor/fog/lib/fog/openstack/requests/compute/get_flavor_details.rb +43 -0
  210. data/vendor/fog/lib/fog/openstack/requests/compute/get_host_details.rb +74 -0
  211. data/vendor/fog/lib/fog/openstack/requests/compute/get_image_details.rb +33 -0
  212. data/vendor/fog/lib/fog/openstack/requests/compute/get_limits.rb +93 -0
  213. data/vendor/fog/lib/fog/openstack/requests/compute/get_metadata.rb +29 -0
  214. data/vendor/fog/lib/fog/openstack/requests/compute/get_quota.rb +31 -0
  215. data/vendor/fog/lib/fog/openstack/requests/compute/get_quota_defaults.rb +31 -0
  216. data/vendor/fog/lib/fog/openstack/requests/compute/get_security_group.rb +49 -0
  217. data/vendor/fog/lib/fog/openstack/requests/compute/get_server_details.rb +32 -0
  218. data/vendor/fog/lib/fog/openstack/requests/compute/get_server_volumes.rb +23 -0
  219. data/vendor/fog/lib/fog/openstack/requests/compute/get_snapshot_details.rb +39 -0
  220. data/vendor/fog/lib/fog/openstack/requests/compute/get_usage.rb +53 -0
  221. data/vendor/fog/lib/fog/openstack/requests/compute/get_vnc_console.rb +40 -0
  222. data/vendor/fog/lib/fog/openstack/requests/compute/get_volume_details.rb +42 -0
  223. data/vendor/fog/lib/fog/openstack/requests/compute/list_address_pools.rb +23 -0
  224. data/vendor/fog/lib/fog/openstack/requests/compute/list_addresses.rb +32 -0
  225. data/vendor/fog/lib/fog/openstack/requests/compute/list_all_addresses.rb +64 -0
  226. data/vendor/fog/lib/fog/openstack/requests/compute/list_flavors.rb +38 -0
  227. data/vendor/fog/lib/fog/openstack/requests/compute/list_flavors_detail.rb +38 -0
  228. data/vendor/fog/lib/fog/openstack/requests/compute/list_hosts.rb +32 -0
  229. data/vendor/fog/lib/fog/openstack/requests/compute/list_images.rb +33 -0
  230. data/vendor/fog/lib/fog/openstack/requests/compute/list_images_detail.rb +39 -0
  231. data/vendor/fog/lib/fog/openstack/requests/compute/list_key_pairs.rb +39 -0
  232. data/vendor/fog/lib/fog/openstack/requests/compute/list_metadata.rb +28 -0
  233. data/vendor/fog/lib/fog/openstack/requests/compute/list_private_addresses.rb +32 -0
  234. data/vendor/fog/lib/fog/openstack/requests/compute/list_public_addresses.rb +32 -0
  235. data/vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb +50 -0
  236. data/vendor/fog/lib/fog/openstack/requests/compute/list_servers.rb +37 -0
  237. data/vendor/fog/lib/fog/openstack/requests/compute/list_servers_detail.rb +44 -0
  238. data/vendor/fog/lib/fog/openstack/requests/compute/list_snapshots.rb +32 -0
  239. data/vendor/fog/lib/fog/openstack/requests/compute/list_tenants.rb +45 -0
  240. data/vendor/fog/lib/fog/openstack/requests/compute/list_usages.rb +43 -0
  241. data/vendor/fog/lib/fog/openstack/requests/compute/list_volumes.rb +51 -0
  242. data/vendor/fog/lib/fog/openstack/requests/compute/live_migrate_server.rb +31 -0
  243. data/vendor/fog/lib/fog/openstack/requests/compute/migrate_server.rb +24 -0
  244. data/vendor/fog/lib/fog/openstack/requests/compute/pause_server.rb +24 -0
  245. data/vendor/fog/lib/fog/openstack/requests/compute/reboot_server.rb +24 -0
  246. data/vendor/fog/lib/fog/openstack/requests/compute/rebuild_server.rb +31 -0
  247. data/vendor/fog/lib/fog/openstack/requests/compute/release_address.rb +34 -0
  248. data/vendor/fog/lib/fog/openstack/requests/compute/remove_fixed_ip.rb +29 -0
  249. data/vendor/fog/lib/fog/openstack/requests/compute/rescue_server.rb +24 -0
  250. data/vendor/fog/lib/fog/openstack/requests/compute/reset_server_state.rb +24 -0
  251. data/vendor/fog/lib/fog/openstack/requests/compute/resize_server.rb +24 -0
  252. data/vendor/fog/lib/fog/openstack/requests/compute/resume_server.rb +24 -0
  253. data/vendor/fog/lib/fog/openstack/requests/compute/revert_resize_server.rb +30 -0
  254. data/vendor/fog/lib/fog/openstack/requests/compute/server_action.rb +18 -0
  255. data/vendor/fog/lib/fog/openstack/requests/compute/server_actions.rb +27 -0
  256. data/vendor/fog/lib/fog/openstack/requests/compute/server_diagnostics.rb +25 -0
  257. data/vendor/fog/lib/fog/openstack/requests/compute/set_metadata.rb +45 -0
  258. data/vendor/fog/lib/fog/openstack/requests/compute/set_tenant.rb +21 -0
  259. data/vendor/fog/lib/fog/openstack/requests/compute/suspend_server.rb +24 -0
  260. data/vendor/fog/lib/fog/openstack/requests/compute/unpause_server.rb +24 -0
  261. data/vendor/fog/lib/fog/openstack/requests/compute/update_metadata.rb +46 -0
  262. data/vendor/fog/lib/fog/openstack/requests/compute/update_quota.rb +32 -0
  263. data/vendor/fog/lib/fog/openstack/requests/compute/update_server.rb +35 -0
  264. data/vendor/fog/lib/fog/openstack/requests/identity/add_user_to_tenant.rb +34 -0
  265. data/vendor/fog/lib/fog/openstack/requests/identity/check_token.rb +23 -0
  266. data/vendor/fog/lib/fog/openstack/requests/identity/create_ec2_credential.rb +58 -0
  267. data/vendor/fog/lib/fog/openstack/requests/identity/create_role.rb +37 -0
  268. data/vendor/fog/lib/fog/openstack/requests/identity/create_tenant.rb +32 -0
  269. data/vendor/fog/lib/fog/openstack/requests/identity/create_user.rb +47 -0
  270. data/vendor/fog/lib/fog/openstack/requests/identity/create_user_role.rb +26 -0
  271. data/vendor/fog/lib/fog/openstack/requests/identity/delete_ec2_credential.rb +44 -0
  272. data/vendor/fog/lib/fog/openstack/requests/identity/delete_role.rb +32 -0
  273. data/vendor/fog/lib/fog/openstack/requests/identity/delete_tenant.rb +31 -0
  274. data/vendor/fog/lib/fog/openstack/requests/identity/delete_user.rb +32 -0
  275. data/vendor/fog/lib/fog/openstack/requests/identity/delete_user_role.rb +26 -0
  276. data/vendor/fog/lib/fog/openstack/requests/identity/get_ec2_credential.rb +49 -0
  277. data/vendor/fog/lib/fog/openstack/requests/identity/get_role.rb +28 -0
  278. data/vendor/fog/lib/fog/openstack/requests/identity/get_tenant.rb +31 -0
  279. data/vendor/fog/lib/fog/openstack/requests/identity/get_tenants_by_id.rb +23 -0
  280. data/vendor/fog/lib/fog/openstack/requests/identity/get_tenants_by_name.rb +23 -0
  281. data/vendor/fog/lib/fog/openstack/requests/identity/get_user_by_id.rb +34 -0
  282. data/vendor/fog/lib/fog/openstack/requests/identity/get_user_by_name.rb +31 -0
  283. data/vendor/fog/lib/fog/openstack/requests/identity/list_ec2_credentials.rb +44 -0
  284. data/vendor/fog/lib/fog/openstack/requests/identity/list_endpoints_for_token.rb +23 -0
  285. data/vendor/fog/lib/fog/openstack/requests/identity/list_roles.rb +36 -0
  286. data/vendor/fog/lib/fog/openstack/requests/identity/list_roles_for_user_on_tenant.rb +30 -0
  287. data/vendor/fog/lib/fog/openstack/requests/identity/list_tenants.rb +45 -0
  288. data/vendor/fog/lib/fog/openstack/requests/identity/list_user_global_roles.rb +22 -0
  289. data/vendor/fog/lib/fog/openstack/requests/identity/list_users.rb +34 -0
  290. data/vendor/fog/lib/fog/openstack/requests/identity/remove_user_from_tenant.rb +20 -0
  291. data/vendor/fog/lib/fog/openstack/requests/identity/set_tenant.rb +21 -0
  292. data/vendor/fog/lib/fog/openstack/requests/identity/update_tenant.rb +28 -0
  293. data/vendor/fog/lib/fog/openstack/requests/identity/update_user.rb +36 -0
  294. data/vendor/fog/lib/fog/openstack/requests/identity/validate_token.rb +23 -0
  295. data/vendor/fog/lib/fog/openstack/requests/image/add_member_to_image.rb +23 -0
  296. data/vendor/fog/lib/fog/openstack/requests/image/create_image.rb +79 -0
  297. data/vendor/fog/lib/fog/openstack/requests/image/delete_image.rb +25 -0
  298. data/vendor/fog/lib/fog/openstack/requests/image/get_image.rb +45 -0
  299. data/vendor/fog/lib/fog/openstack/requests/image/get_image_by_id.rb +32 -0
  300. data/vendor/fog/lib/fog/openstack/requests/image/get_image_members.rb +29 -0
  301. data/vendor/fog/lib/fog/openstack/requests/image/get_shared_images.rb +29 -0
  302. data/vendor/fog/lib/fog/openstack/requests/image/list_public_images.rb +32 -0
  303. data/vendor/fog/lib/fog/openstack/requests/image/list_public_images_detailed.rb +31 -0
  304. data/vendor/fog/lib/fog/openstack/requests/image/remove_member_from_image.rb +23 -0
  305. data/vendor/fog/lib/fog/openstack/requests/image/set_tenant.rb +21 -0
  306. data/vendor/fog/lib/fog/openstack/requests/image/update_image.rb +70 -0
  307. data/vendor/fog/lib/fog/openstack/requests/image/update_image_members.rb +37 -0
  308. data/vendor/fog/lib/fog/openstack/requests/network/associate_floating_ip.rb +49 -0
  309. data/vendor/fog/lib/fog/openstack/requests/network/create_floating_ip.rb +50 -0
  310. data/vendor/fog/lib/fog/openstack/requests/network/create_network.rb +44 -0
  311. data/vendor/fog/lib/fog/openstack/requests/network/create_port.rb +52 -0
  312. data/vendor/fog/lib/fog/openstack/requests/network/create_subnet.rb +56 -0
  313. data/vendor/fog/lib/fog/openstack/requests/network/delete_floating_ip.rb +30 -0
  314. data/vendor/fog/lib/fog/openstack/requests/network/delete_network.rb +30 -0
  315. data/vendor/fog/lib/fog/openstack/requests/network/delete_port.rb +30 -0
  316. data/vendor/fog/lib/fog/openstack/requests/network/delete_subnet.rb +30 -0
  317. data/vendor/fog/lib/fog/openstack/requests/network/disassociate_floating_ip.rb +49 -0
  318. data/vendor/fog/lib/fog/openstack/requests/network/get_floating_ip.rb +42 -0
  319. data/vendor/fog/lib/fog/openstack/requests/network/get_network.rb +42 -0
  320. data/vendor/fog/lib/fog/openstack/requests/network/get_port.rb +48 -0
  321. data/vendor/fog/lib/fog/openstack/requests/network/get_subnet.rb +49 -0
  322. data/vendor/fog/lib/fog/openstack/requests/network/list_floating_ips.rb +27 -0
  323. data/vendor/fog/lib/fog/openstack/requests/network/list_networks.rb +27 -0
  324. data/vendor/fog/lib/fog/openstack/requests/network/list_ports.rb +27 -0
  325. data/vendor/fog/lib/fog/openstack/requests/network/list_subnets.rb +27 -0
  326. data/vendor/fog/lib/fog/openstack/requests/network/set_tenant.rb +21 -0
  327. data/vendor/fog/lib/fog/openstack/requests/network/update_network.rb +41 -0
  328. data/vendor/fog/lib/fog/openstack/requests/network/update_port.rb +44 -0
  329. data/vendor/fog/lib/fog/openstack/requests/network/update_subnet.rb +44 -0
  330. data/vendor/fog/lib/fog/openstack/requests/storage/copy_object.rb +27 -0
  331. data/vendor/fog/lib/fog/openstack/requests/storage/delete_container.rb +22 -0
  332. data/vendor/fog/lib/fog/openstack/requests/storage/delete_object.rb +23 -0
  333. data/vendor/fog/lib/fog/openstack/requests/storage/get_container.rb +44 -0
  334. data/vendor/fog/lib/fog/openstack/requests/storage/get_containers.rb +33 -0
  335. data/vendor/fog/lib/fog/openstack/requests/storage/get_object.rb +29 -0
  336. data/vendor/fog/lib/fog/openstack/requests/storage/get_object_https_url.rb +51 -0
  337. data/vendor/fog/lib/fog/openstack/requests/storage/head_container.rb +28 -0
  338. data/vendor/fog/lib/fog/openstack/requests/storage/head_containers.rb +25 -0
  339. data/vendor/fog/lib/fog/openstack/requests/storage/head_object.rb +23 -0
  340. data/vendor/fog/lib/fog/openstack/requests/storage/post_set_meta_temp_url_key.rb +37 -0
  341. data/vendor/fog/lib/fog/openstack/requests/storage/put_container.rb +22 -0
  342. data/vendor/fog/lib/fog/openstack/requests/storage/put_object.rb +30 -0
  343. data/vendor/fog/lib/fog/openstack/requests/storage/put_object_manifest.rb +25 -0
  344. data/vendor/fog/lib/fog/openstack/requests/volume/create_volume.rb +54 -0
  345. data/vendor/fog/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +47 -0
  346. data/vendor/fog/lib/fog/openstack/requests/volume/delete_snapshot.rb +26 -0
  347. data/vendor/fog/lib/fog/openstack/requests/volume/delete_volume.rb +26 -0
  348. data/vendor/fog/lib/fog/openstack/requests/volume/get_snapshot_details.rb +39 -0
  349. data/vendor/fog/lib/fog/openstack/requests/volume/get_volume_details.rb +42 -0
  350. data/vendor/fog/lib/fog/openstack/requests/volume/list_snapshots.rb +32 -0
  351. data/vendor/fog/lib/fog/openstack/requests/volume/list_volumes.rb +55 -0
  352. data/vendor/fog/lib/fog/openstack/requests/volume/set_tenant.rb +21 -0
  353. data/vendor/fog/lib/fog/openstack/storage.rb +162 -0
  354. data/vendor/fog/lib/fog/openstack/volume.rb +219 -0
  355. data/vendor/fog/lib/fog/providers.rb +2 -0
  356. data/vendor/fog/lib/fog/schema/data_validator.rb +154 -0
  357. data/vendor/fog/lib/fog/storage.rb +97 -0
  358. data/vendor/fog/lib/fog/version.rb +3 -0
  359. data/vendor/fog/lib/fog/volume.rb +25 -0
  360. metadata +576 -0
  361. metadata.gz.sig +0 -0
@@ -0,0 +1,70 @@
1
+ Gem::Specification.new do |s|
2
+ s.specification_version = 2 if s.respond_to? :specification_version=
3
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+
5
+ ## Leave these as is they will be modified for you by the rake gemspec task.
6
+ ## If your rubyforge_project name is different, then edit it and comment out
7
+ ## the sub! line in the Rakefile
8
+ s.name = 'fog'
9
+ s.version = '1.9.0'
10
+ s.date = '2013-01-19'
11
+ s.rubyforge_project = 'fog'
12
+
13
+ ## Make sure your summary is short. The description may be as long
14
+ ## as you like.
15
+ s.summary = "brings clouds to you"
16
+ s.description = "The Ruby cloud services library. Supports all major cloud providers including AWS, Rackspace, Linode, Blue Box, StormOnDemand, and many others. Full support for most AWS services including EC2, S3, CloudWatch, SimpleDB, ELB, and RDS."
17
+
18
+ ## List the primary authors. If there are a bunch of authors, it's probably
19
+ ## better to set the email to an email list or something. If you don't have
20
+ ## a custom homepage, consider using your GitHub URL or the like.
21
+ s.authors = ["geemus (Wesley Beary)"]
22
+ s.email = 'geemus@gmail.com'
23
+ s.homepage = 'http://github.com/fog/fog'
24
+
25
+ ## This sections is only necessary if you have C extensions.
26
+ # s.require_paths << 'ext'
27
+ # s.extensions = %w[ext/extconf.rb]
28
+
29
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
30
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
31
+ s.require_paths = %w[lib]
32
+
33
+ ## If your gem includes any executables, list them here.
34
+ s.executables = ["fog"]
35
+
36
+ ## Specify any RDoc options here. You'll want to add your README and
37
+ ## LICENSE files to the extra_rdoc_files list.
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.extra_rdoc_files = %w[README.md]
40
+
41
+ ## List your runtime dependencies here. Runtime dependencies are those
42
+ ## that are needed for an end user to actually USE your code.
43
+ s.add_dependency('builder')
44
+ s.add_dependency('excon', '~>0.14')
45
+ s.add_dependency('formatador', '~>0.2.0')
46
+ s.add_dependency('multi_json', '~>1.0')
47
+ s.add_dependency('mime-types')
48
+ s.add_dependency('net-scp', '~>1.0.4')
49
+ s.add_dependency('net-ssh', '>=2.1.3')
50
+ s.add_dependency('nokogiri', '~>1.5.0')
51
+ s.add_dependency('ruby-hmac')
52
+
53
+ ## List your development dependencies here. Development dependencies are
54
+ ## those that are only needed during development
55
+ s.add_development_dependency('jekyll')
56
+ s.add_development_dependency('rake')
57
+ s.add_development_dependency('rbvmomi')
58
+ s.add_development_dependency('yard')
59
+ s.add_development_dependency('thor')
60
+ s.add_development_dependency('rspec', '~>1.3.1')
61
+ s.add_development_dependency('rbovirt', '>=0.0.11')
62
+ s.add_development_dependency('shindo', '~>0.3.4')
63
+ s.add_development_dependency('virtualbox', '~>0.9.1')
64
+ s.add_development_dependency('fission')
65
+ s.add_development_dependency('pry')
66
+ # s.add_development_dependency('ruby-libvirt','~>0.4.0')
67
+
68
+ s.files = `git ls-files`.split("\n")
69
+ s.test_files = `git ls-files -- {spec,tests}/*`.split("\n")
70
+ end
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), 'fog', 'core')
2
+
3
+ module Fog
4
+ end
5
+
6
+ # FIXME: these should go away (force usage of Fog::[Compute, CDN, DNS, Storage] etc)
7
+ require 'fog/providers'
8
+ require 'fog/terremark'
9
+
10
+ require 'fog/compute'
11
+ require 'fog/identity'
12
+ require 'fog/image'
13
+ require 'fog/volume'
14
+ require 'fog/cdn'
15
+ require 'fog/dns'
16
+ require 'fog/network'
17
+ require 'fog/storage'
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module CDN
3
+
4
+ def self.[](provider)
5
+ self.new(:provider => provider)
6
+ end
7
+
8
+ def self.new(attributes)
9
+ attributes = attributes.dup # prevent delete from having side effects
10
+ case provider = attributes.delete(:provider).to_s.downcase.to_sym
11
+ when :aws
12
+ require 'fog/aws/cdn'
13
+ Fog::CDN::AWS.new(attributes)
14
+ when :hp
15
+ require 'fog/hp/cdn'
16
+ Fog::CDN::HP.new(attributes)
17
+ when :rackspace
18
+ require 'fog/rackspace/cdn'
19
+ Fog::CDN::Rackspace.new(attributes)
20
+ else
21
+ raise ArgumentError.new("#{provider} is not a recognized cdn provider")
22
+ end
23
+ end
24
+
25
+ def self.providers
26
+ Fog.services[:cdn]
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,127 @@
1
+ module Fog
2
+ module Compute
3
+
4
+ def self.[](provider)
5
+ self.new(:provider => provider)
6
+ end
7
+
8
+ def self.new(attributes)
9
+ attributes = attributes.dup # prevent delete from having side effects
10
+ provider = attributes.delete(:provider).to_s.downcase.to_sym
11
+
12
+ case provider
13
+ when :aws
14
+ require 'fog/aws/compute'
15
+ Fog::Compute::AWS.new(attributes)
16
+ when :bluebox
17
+ require 'fog/bluebox/compute'
18
+ Fog::Compute::Bluebox.new(attributes)
19
+ when :brightbox
20
+ require 'fog/brightbox/compute'
21
+ Fog::Compute::Brightbox.new(attributes)
22
+ when :cloudstack
23
+ require 'fog/cloudstack/compute'
24
+ Fog::Compute::Cloudstack.new(attributes)
25
+ when :clodo
26
+ require 'fog/clodo/compute'
27
+ Fog::Compute::Clodo.new(attributes)
28
+ when :digitalocean
29
+ require 'fog/digitalocean/compute'
30
+ Fog::Compute::DigitalOcean.new(attributes)
31
+ when :ecloud
32
+ require 'fog/ecloud/compute'
33
+ Fog::Compute::Ecloud.new(attributes)
34
+ when :glesys
35
+ require 'fog/glesys/compute'
36
+ Fog::Compute::Glesys.new(attributes)
37
+ when :gogrid
38
+ require 'fog/go_grid/compute'
39
+ Fog::Compute::GoGrid.new(attributes)
40
+ when :hp
41
+ require 'fog/hp/compute'
42
+ Fog::Compute::HP.new(attributes)
43
+ when :ibm
44
+ require 'fog/ibm/compute'
45
+ Fog::Compute::IBM.new(attributes)
46
+ when :joyent
47
+ require 'fog/joyent/compute'
48
+ Fog::Compute::Joyent.new(attributes)
49
+ when :libvirt
50
+ require 'fog/libvirt/compute'
51
+ Fog::Compute::Libvirt.new(attributes)
52
+ when :linode
53
+ require 'fog/linode/compute'
54
+ Fog::Compute::Linode.new(attributes)
55
+ when :new_servers
56
+ require 'fog/bare_metal_cloud/compute'
57
+ Fog::Logger.deprecation "`new_servers` is deprecated. Please use `bare_metal_cloud` instead."
58
+ Fog::Compute::BareMetalCloud.new(attributes)
59
+ when :baremetalcloud
60
+ require 'fog/bare_metal_cloud/compute'
61
+ Fog::Compute::BareMetalCloud.new(attributes)
62
+ when :ninefold
63
+ require 'fog/ninefold/compute'
64
+ Fog::Compute::Ninefold.new(attributes)
65
+ when :openstack
66
+ require 'fog/openstack/compute'
67
+ Fog::Compute::OpenStack.new(attributes)
68
+ when :ovirt
69
+ require 'fog/ovirt/compute'
70
+ Fog::Compute::Ovirt.new(attributes)
71
+ when :rackspace
72
+ version = attributes.delete(:version)
73
+ version = version.to_s.downcase.to_sym unless version.nil?
74
+ if version == :v2
75
+ require 'fog/rackspace/compute_v2'
76
+ Fog::Compute::RackspaceV2.new(attributes)
77
+ else
78
+ Fog::Logger.deprecation "First Gen Cloud Servers are deprecated. Please use `:version => :v2` attribute to use Next Gen Cloud Servers."
79
+ require 'fog/rackspace/compute'
80
+ Fog::Compute::Rackspace.new(attributes)
81
+ end
82
+ when :serverlove
83
+ require 'fog/serverlove/compute'
84
+ Fog::Compute::Serverlove.new(attributes)
85
+ when :stormondemand
86
+ require 'fog/storm_on_demand/compute'
87
+ Fog::Compute::StormOnDemand.new(attributes)
88
+ when :vcloud
89
+ require 'fog/vcloud/compute'
90
+ Fog::Vcloud::Compute.new(attributes)
91
+ when :virtualbox
92
+ require 'fog/virtual_box/compute'
93
+ Fog::Compute::VirtualBox.new(attributes)
94
+ when :vmfusion
95
+ require 'fog/vmfusion/compute'
96
+ Fog::Compute::Vmfusion.new(attributes)
97
+ when :voxel
98
+ require 'fog/voxel/compute'
99
+ Fog::Compute::Voxel.new(attributes)
100
+ when :vsphere
101
+ require 'fog/vsphere/compute'
102
+ Fog::Compute::Vsphere.new(attributes)
103
+ when :xenserver
104
+ require 'fog/xenserver/compute'
105
+ Fog::Compute::XenServer.new(attributes)
106
+ else
107
+ raise ArgumentError.new("#{provider} is not a recognized compute provider")
108
+ end
109
+ end
110
+
111
+ def self.providers
112
+ Fog.services[:compute]
113
+ end
114
+
115
+ def self.servers
116
+ servers = []
117
+ for provider in self.providers
118
+ begin
119
+ servers.concat(self[provider].servers)
120
+ rescue # ignore any missing credentials/etc
121
+ end
122
+ end
123
+ servers
124
+ end
125
+
126
+ end
127
+ end
@@ -0,0 +1,73 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Compute
5
+ class Server < Fog::Model
6
+
7
+ attr_writer :username, :private_key, :private_key_path, :public_key, :public_key_path
8
+
9
+ def username
10
+ @username ||= 'root'
11
+ end
12
+
13
+ def private_key_path
14
+ @private_key_path ||= Fog.credentials[:private_key_path]
15
+ @private_key_path &&= File.expand_path(@private_key_path)
16
+ end
17
+
18
+ def private_key
19
+ @private_key ||= private_key_path && File.read(private_key_path)
20
+ end
21
+
22
+ def public_key_path
23
+ @public_key_path ||= Fog.credentials[:public_key_path]
24
+ @public_key_path &&= File.expand_path(@public_key_path)
25
+ end
26
+
27
+ def public_key
28
+ @public_key ||= public_key_path && File.read(public_key_path)
29
+ end
30
+
31
+
32
+ def scp(local_path, remote_path, upload_options = {})
33
+ require 'net/scp'
34
+ requires :public_ip_address, :username
35
+
36
+ scp_options = {:port => ssh_port}
37
+ scp_options[:key_data] = [private_key] if private_key
38
+ Fog::SCP.new(public_ip_address, username, scp_options).upload(local_path, remote_path, upload_options)
39
+ end
40
+
41
+ alias_method :scp_upload, :scp
42
+
43
+ def scp_download(remote_path, local_path, download_options = {})
44
+ require 'net/scp'
45
+ requires :public_ip_address, :username
46
+
47
+ scp_options = {:port => ssh_port}
48
+ scp_options[:key_data] = [private_key] if private_key
49
+ Fog::SCP.new(public_ip_address, username, scp_options).download(remote_path, local_path, download_options)
50
+ end
51
+
52
+ def ssh(commands, options={}, &blk)
53
+ require 'net/ssh'
54
+ requires :public_ip_address, :username
55
+
56
+ options[:key_data] = [private_key] if private_key
57
+ options[:port] ||= ssh_port
58
+ Fog::SSH.new(public_ip_address, username, options).run(commands, &blk)
59
+ end
60
+
61
+ def ssh_port
62
+ 22
63
+ end
64
+
65
+ def sshable?
66
+ ready? && !public_ip_address.nil? && !!Timeout::timeout(8) { ssh 'pwd' }
67
+ rescue SystemCallError, Net::SSH::AuthenticationFailed, Timeout::Error
68
+ false
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,38 @@
1
+ __LIB_DIR__ = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
+
3
+ $LOAD_PATH.unshift __LIB_DIR__ unless
4
+ $LOAD_PATH.include?(__LIB_DIR__)
5
+
6
+ # external core dependencies
7
+ require 'base64'
8
+ require 'cgi'
9
+ require 'uri'
10
+ require 'excon'
11
+ require 'fileutils'
12
+ require 'formatador'
13
+ require 'openssl'
14
+ require 'time'
15
+ require 'timeout'
16
+
17
+ # internal core dependencies
18
+ require "fog/version"
19
+ require 'fog/core/attributes'
20
+ require 'fog/core/collection'
21
+ require 'fog/core/connection'
22
+ require 'fog/core/credentials'
23
+ require 'fog/core/current_machine'
24
+ require 'fog/core/deprecation'
25
+ require 'fog/core/errors'
26
+ require 'fog/core/hmac'
27
+ require 'fog/core/json'
28
+ require 'fog/core/logger'
29
+ require 'fog/core/model'
30
+ require 'fog/core/mock'
31
+ #require 'fog/core/parser' # FIXME: would be better to only load when nokogiri is required
32
+ require 'fog/core/provider'
33
+ require 'fog/core/service'
34
+ require 'fog/core/ssh'
35
+ require 'fog/core/scp'
36
+ require 'fog/core/time'
37
+ require 'fog/core/timeout'
38
+ require 'fog/core/wait_for'
@@ -0,0 +1,221 @@
1
+ module Fog
2
+ module Attributes
3
+ module ClassMethods
4
+
5
+ def _load(marshalled)
6
+ new(Marshal.load(marshalled))
7
+ end
8
+
9
+ def aliases
10
+ @aliases ||= {}
11
+ end
12
+
13
+ def attributes
14
+ @attributes ||= []
15
+ end
16
+
17
+ def attribute(name, options = {})
18
+ class_eval <<-EOS, __FILE__, __LINE__
19
+ def #{name}
20
+ attributes[:#{name}]
21
+ end
22
+ EOS
23
+ case options[:type]
24
+ when :boolean
25
+ class_eval <<-EOS, __FILE__, __LINE__
26
+ def #{name}=(new_#{name})
27
+ attributes[:#{name}] = case new_#{name}
28
+ when true,'true'
29
+ true
30
+ when false,'false'
31
+ false
32
+ end
33
+ end
34
+ EOS
35
+ when :float
36
+ class_eval <<-EOS, __FILE__, __LINE__
37
+ def #{name}=(new_#{name})
38
+ attributes[:#{name}] = new_#{name}.to_f
39
+ end
40
+ EOS
41
+ when :integer
42
+ class_eval <<-EOS, __FILE__, __LINE__
43
+ def #{name}=(new_#{name})
44
+ attributes[:#{name}] = new_#{name}.to_i
45
+ end
46
+ EOS
47
+ when :string
48
+ class_eval <<-EOS, __FILE__, __LINE__
49
+ def #{name}=(new_#{name})
50
+ attributes[:#{name}] = new_#{name}.to_s
51
+ end
52
+ EOS
53
+ when :time
54
+ class_eval <<-EOS, __FILE__, __LINE__
55
+ def #{name}=(new_#{name})
56
+ attributes[:#{name}] = if new_#{name}.nil? || new_#{name} == "" || new_#{name}.is_a?(Time)
57
+ new_#{name}
58
+ else
59
+ Time.parse(new_#{name})
60
+ end
61
+ end
62
+ EOS
63
+ when :array
64
+ class_eval <<-EOS, __FILE__, __LINE__
65
+ def #{name}=(new_#{name})
66
+ attributes[:#{name}] = [*new_#{name}]
67
+ end
68
+ EOS
69
+ else
70
+ if squash = options[:squash]
71
+ class_eval <<-EOS, __FILE__, __LINE__
72
+ def #{name}=(new_data)
73
+ if new_data.is_a?(Hash)
74
+ if new_data.has_key?(:'#{squash}')
75
+ attributes[:#{name}] = new_data[:'#{squash}']
76
+ elsif new_data.has_key?("#{squash}")
77
+ attributes[:#{name}] = new_data["#{squash}"]
78
+ else
79
+ attributes[:#{name}] = [ new_data ]
80
+ end
81
+ else
82
+ attributes[:#{name}] = new_data
83
+ end
84
+ end
85
+ EOS
86
+ else
87
+ class_eval <<-EOS, __FILE__, __LINE__
88
+ def #{name}=(new_#{name})
89
+ attributes[:#{name}] = new_#{name}
90
+ end
91
+ EOS
92
+ end
93
+ end
94
+ @attributes ||= []
95
+ @attributes |= [name]
96
+ for new_alias in [*options[:aliases]]
97
+ aliases[new_alias] = name
98
+ end
99
+ end
100
+
101
+ def identity(name, options = {})
102
+ @identity = name
103
+ self.attribute(name, options)
104
+ end
105
+
106
+ def ignore_attributes(*args)
107
+ @ignored_attributes = args.collect {|attr| attr.to_s }
108
+ end
109
+
110
+ def ignored_attributes
111
+ @ignored_attributes ||= []
112
+ end
113
+
114
+ end
115
+
116
+ module InstanceMethods
117
+
118
+ def _dump(level)
119
+ Marshal.dump(attributes)
120
+ end
121
+
122
+ def attributes
123
+ @attributes ||= {}
124
+ end
125
+
126
+ def dup
127
+ copy = super
128
+ copy.dup_attributes!
129
+ copy
130
+ end
131
+
132
+ def identity
133
+ send(self.class.instance_variable_get('@identity'))
134
+ end
135
+
136
+ def identity=(new_identity)
137
+ send("#{self.class.instance_variable_get('@identity')}=", new_identity)
138
+ end
139
+
140
+ def merge_attributes(new_attributes = {})
141
+ for key, value in new_attributes
142
+ unless self.class.ignored_attributes.include?(key)
143
+ if aliased_key = self.class.aliases[key]
144
+ send("#{aliased_key}=", value)
145
+ elsif self.respond_to?("#{key}=",true)
146
+ send("#{key}=", value)
147
+ else
148
+ attributes[key] = value
149
+ end
150
+ end
151
+ end
152
+ self
153
+ end
154
+
155
+ # Returns true if a remote resource has been assigned an
156
+ # identity and we can assume it has been persisted.
157
+ #
158
+ # @return [Boolean]
159
+ def persisted?
160
+ !!identity
161
+ end
162
+
163
+ # Returns true if a remote resource has not been assigned an
164
+ # identity.
165
+ #
166
+ # This was added for a ActiveRecord like feel but has been
167
+ # outdated by ActiveModel API using {#persisted?}
168
+ #
169
+ # @deprecated Use inverted form of {#persisted?}
170
+ # @return [Boolean]
171
+ def new_record?
172
+ Fog::Logger.deprecation("#new_record? is deprecated, use !persisted? instead [light_black](#{caller.first})[/]")
173
+ !persisted?
174
+ end
175
+
176
+ # check that the attributes specified in args exist and is not nil
177
+ def requires(*args)
178
+ missing = missing_attributes(args)
179
+ if missing.length == 1
180
+ raise(ArgumentError, "#{missing.first} is required for this operation")
181
+ elsif missing.any?
182
+ raise(ArgumentError, "#{missing[0...-1].join(", ")} and #{missing[-1]} are required for this operation")
183
+ end
184
+ end
185
+
186
+ def requires_one(*args)
187
+ missing = missing_attributes(args)
188
+ if missing.length == args.length
189
+ raise(ArgumentError, "#{missing[0...-1].join(", ")} or #{missing[-1]} are required for this operation")
190
+ end
191
+ end
192
+
193
+ protected
194
+
195
+ def missing_attributes(args)
196
+ missing = []
197
+ for arg in [:service] | args
198
+ unless send("#{arg}") || attributes.has_key?(arg)
199
+ missing << arg
200
+ end
201
+ end
202
+ missing
203
+ end
204
+
205
+ def dup_attributes!
206
+ @attributes = @attributes.dup if @attributes
207
+ end
208
+
209
+ private
210
+
211
+ def remap_attributes(attributes, mapping)
212
+ for key, value in mapping
213
+ if attributes.key?(key)
214
+ attributes[value] = attributes.delete(key)
215
+ end
216
+ end
217
+ end
218
+
219
+ end
220
+ end
221
+ end