vagrant-fixed-ssh 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +46 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +723 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +121 -0
- data/Rakefile +18 -0
- data/bin/vagrant +60 -0
- data/config/default.rb +30 -0
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/keys/README.md +17 -0
- data/keys/vagrant +27 -0
- data/keys/vagrant.pub +1 -0
- data/lib/vagrant.rb +197 -0
- data/lib/vagrant/action.rb +63 -0
- data/lib/vagrant/action/box/destroy.rb +25 -0
- data/lib/vagrant/action/box/download.rb +84 -0
- data/lib/vagrant/action/box/package.rb +19 -0
- data/lib/vagrant/action/box/unpackage.rb +61 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +128 -0
- data/lib/vagrant/action/builtin.rb +171 -0
- data/lib/vagrant/action/env/set.rb +21 -0
- data/lib/vagrant/action/environment.rb +12 -0
- data/lib/vagrant/action/general/check_virtualbox.rb +28 -0
- data/lib/vagrant/action/general/package.rb +101 -0
- data/lib/vagrant/action/general/validate.rb +18 -0
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +53 -0
- data/lib/vagrant/action/vm/check_accessible.rb +23 -0
- data/lib/vagrant/action/vm/check_box.rb +33 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +38 -0
- data/lib/vagrant/action/vm/check_port_collisions.rb +89 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +18 -0
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +18 -0
- data/lib/vagrant/action/vm/customize.rb +36 -0
- data/lib/vagrant/action/vm/default_name.rb +22 -0
- data/lib/vagrant/action/vm/destroy.rb +19 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +20 -0
- data/lib/vagrant/action/vm/discard_state.rb +22 -0
- data/lib/vagrant/action/vm/export.rb +57 -0
- data/lib/vagrant/action/vm/forward_ports.rb +92 -0
- data/lib/vagrant/action/vm/halt.rb +32 -0
- data/lib/vagrant/action/vm/host_name.rb +21 -0
- data/lib/vagrant/action/vm/import.rb +48 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +21 -0
- data/lib/vagrant/action/vm/network.rb +403 -0
- data/lib/vagrant/action/vm/nfs.rb +196 -0
- data/lib/vagrant/action/vm/package.rb +23 -0
- data/lib/vagrant/action/vm/package_vagrantfile.rb +36 -0
- data/lib/vagrant/action/vm/provision.rb +61 -0
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +26 -0
- data/lib/vagrant/action/vm/prune_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/action/vm/sane_defaults.rb +78 -0
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +114 -0
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/action/warden.rb +92 -0
- data/lib/vagrant/box.rb +44 -0
- data/lib/vagrant/box_collection.rb +58 -0
- data/lib/vagrant/cli.rb +76 -0
- data/lib/vagrant/command.rb +24 -0
- data/lib/vagrant/command/base.rb +167 -0
- data/lib/vagrant/command/box.rb +58 -0
- data/lib/vagrant/command/box_add.rb +37 -0
- data/lib/vagrant/command/box_list.rb +28 -0
- data/lib/vagrant/command/box_remove.rb +27 -0
- data/lib/vagrant/command/box_repackage.rb +27 -0
- data/lib/vagrant/command/destroy.rb +64 -0
- data/lib/vagrant/command/gem.rb +39 -0
- data/lib/vagrant/command/halt.rb +39 -0
- data/lib/vagrant/command/init.rb +40 -0
- data/lib/vagrant/command/package.rb +75 -0
- data/lib/vagrant/command/provision.rb +40 -0
- data/lib/vagrant/command/reload.rb +39 -0
- data/lib/vagrant/command/resume.rb +33 -0
- data/lib/vagrant/command/ssh.rb +90 -0
- data/lib/vagrant/command/ssh_config.rb +51 -0
- data/lib/vagrant/command/start_mixins.rb +26 -0
- data/lib/vagrant/command/status.rb +36 -0
- data/lib/vagrant/command/suspend.rb +33 -0
- data/lib/vagrant/command/up.rb +40 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +230 -0
- data/lib/vagrant/config.rb +49 -0
- data/lib/vagrant/config/base.rb +82 -0
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +19 -0
- data/lib/vagrant/config/loader.rb +127 -0
- data/lib/vagrant/config/nfs.rb +8 -0
- data/lib/vagrant/config/package.rb +7 -0
- data/lib/vagrant/config/ssh.rb +27 -0
- data/lib/vagrant/config/top.rb +72 -0
- data/lib/vagrant/config/vagrant.rb +14 -0
- data/lib/vagrant/config/vm.rb +168 -0
- data/lib/vagrant/config/vm/provisioner.rb +52 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/data_store.rb +92 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/downloaders/base.rb +25 -0
- data/lib/vagrant/downloaders/file.rb +22 -0
- data/lib/vagrant/downloaders/http.rb +97 -0
- data/lib/vagrant/driver.rb +8 -0
- data/lib/vagrant/driver/virtualbox.rb +134 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +459 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +459 -0
- data/lib/vagrant/driver/virtualbox_4_2.rb +606 -0
- data/lib/vagrant/driver/virtualbox_base.rb +326 -0
- data/lib/vagrant/environment.rb +522 -0
- data/lib/vagrant/errors.rb +445 -0
- data/lib/vagrant/guest.rb +18 -0
- data/lib/vagrant/guest/arch.rb +56 -0
- data/lib/vagrant/guest/base.rb +99 -0
- data/lib/vagrant/guest/debian.rb +64 -0
- data/lib/vagrant/guest/fedora.rb +66 -0
- data/lib/vagrant/guest/freebsd.rb +86 -0
- data/lib/vagrant/guest/gentoo.rb +46 -0
- data/lib/vagrant/guest/linux.rb +118 -0
- data/lib/vagrant/guest/linux/config.rb +19 -0
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/openbsd.rb +20 -0
- data/lib/vagrant/guest/redhat.rb +67 -0
- data/lib/vagrant/guest/solaris.rb +118 -0
- data/lib/vagrant/guest/suse.rb +17 -0
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/hosts.rb +37 -0
- data/lib/vagrant/hosts/arch.rb +55 -0
- data/lib/vagrant/hosts/base.rb +66 -0
- data/lib/vagrant/hosts/bsd.rb +97 -0
- data/lib/vagrant/hosts/fedora.rb +47 -0
- data/lib/vagrant/hosts/freebsd.rb +41 -0
- data/lib/vagrant/hosts/gentoo.rb +20 -0
- data/lib/vagrant/hosts/linux.rb +94 -0
- data/lib/vagrant/hosts/opensuse.rb +30 -0
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/plugin.rb +81 -0
- data/lib/vagrant/provisioners.rb +12 -0
- data/lib/vagrant/provisioners/base.rb +44 -0
- data/lib/vagrant/provisioners/chef.rb +168 -0
- data/lib/vagrant/provisioners/chef_client.rb +132 -0
- data/lib/vagrant/provisioners/chef_solo.rb +234 -0
- data/lib/vagrant/provisioners/puppet.rb +176 -0
- data/lib/vagrant/provisioners/puppet_server.rb +78 -0
- data/lib/vagrant/provisioners/shell.rb +103 -0
- data/lib/vagrant/registry.rb +52 -0
- data/lib/vagrant/ssh.rb +126 -0
- data/lib/vagrant/test_helpers.rb +154 -0
- data/lib/vagrant/ui.rb +168 -0
- data/lib/vagrant/util.rb +12 -0
- data/lib/vagrant/util/ansi_escape_code_remover.rb +34 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/counter.rb +24 -0
- data/lib/vagrant/util/file_checksum.rb +38 -0
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/is_port_open.rb +38 -0
- data/lib/vagrant/util/line_ending_helpers.rb +14 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +68 -0
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/safe_exec.rb +36 -0
- data/lib/vagrant/util/safe_puts.rb +31 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/subprocess.rb +247 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +195 -0
- data/tasks/acceptance.rake +113 -0
- data/tasks/bundler.rake +3 -0
- data/tasks/test.rake +20 -0
- data/templates/commands/init/Vagrantfile.erb +99 -0
- data/templates/commands/ssh_config/config.erb +15 -0
- data/templates/config/validation_failed.erb +7 -0
- data/templates/guests/arch/network_dhcp.erb +7 -0
- data/templates/guests/arch/network_static.erb +7 -0
- data/templates/guests/debian/network_dhcp.erb +6 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/fedora/network_dhcp.erb +6 -0
- data/templates/guests/fedora/network_static.erb +13 -0
- data/templates/guests/freebsd/network_dhcp.erb +3 -0
- data/templates/guests/freebsd/network_static.erb +3 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +7 -0
- data/templates/locales/en.yml +759 -0
- data/templates/nfs/exports.erb +5 -0
- data/templates/nfs/exports_freebsd.erb +5 -0
- data/templates/nfs/exports_linux.erb +5 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/provisioners/chef_client/client.erb +32 -0
- data/templates/provisioners/chef_solo/solo.erb +25 -0
- data/test/acceptance/base.rb +48 -0
- data/test/acceptance/box_test.rb +99 -0
- data/test/acceptance/destroy_test.rb +37 -0
- data/test/acceptance/halt_test.rb +72 -0
- data/test/acceptance/init_test.rb +33 -0
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +17 -0
- data/test/acceptance/shared_folders_test.rb +84 -0
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +46 -0
- data/test/acceptance/support/config.rb +42 -0
- data/test/acceptance/support/isolated_environment.rb +117 -0
- data/test/acceptance/support/matchers/have_color.rb +9 -0
- data/test/acceptance/support/matchers/match_output.rb +14 -0
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +95 -0
- data/test/acceptance/support/shared/base_context.rb +72 -0
- data/test/acceptance/support/shared/command_examples.rb +33 -0
- data/test/acceptance/support/virtualbox.rb +36 -0
- data/test/acceptance/suspend_test.rb +56 -0
- data/test/acceptance/up_basic_test.rb +33 -0
- data/test/acceptance/up_with_box_url.rb +40 -0
- data/test/acceptance/vagrant_test.rb +47 -0
- data/test/acceptance/version_test.rb +15 -0
- data/test/buildbot/README.md +72 -0
- data/test/buildbot/buildbot_config/__init__.py +0 -0
- data/test/buildbot/buildbot_config/config/__init__.py +0 -0
- data/test/buildbot/buildbot_config/config/loader.py +24 -0
- data/test/buildbot/buildbot_config/config/master.py +24 -0
- data/test/buildbot/buildbot_config/config/slave.py +22 -0
- data/test/buildbot/buildbot_config/master/__init__.py +6 -0
- data/test/buildbot/buildbot_config/master/builders.py +78 -0
- data/test/buildbot/buildbot_config/master/buildsteps.py +100 -0
- data/test/buildbot/buildbot_config/master/change_sources.py +8 -0
- data/test/buildbot/buildbot_config/master/schedulers.py +32 -0
- data/test/buildbot/buildbot_config/master/slaves.py +60 -0
- data/test/buildbot/buildbot_config/master/status.py +52 -0
- data/test/buildbot/master/Makefile.sample +28 -0
- data/test/buildbot/master/buildbot.tac +36 -0
- data/test/buildbot/master/master.cfg +67 -0
- data/test/buildbot/master/public_html/bg_gradient.jpg +0 -0
- data/test/buildbot/master/public_html/default.css +545 -0
- data/test/buildbot/master/public_html/favicon.ico +0 -0
- data/test/buildbot/master/public_html/robots.txt +10 -0
- data/test/buildbot/master/public_html/static/css/bootstrap-1.4.0.min.css +356 -0
- data/test/buildbot/master/public_html/static/css/prettify.css +97 -0
- data/test/buildbot/master/public_html/static/css/syntax.css +60 -0
- data/test/buildbot/master/public_html/static/css/vagrant.base.css +205 -0
- data/test/buildbot/master/public_html/static/images/base_box_mac.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/getting-started/success.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/icons/error.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_chilling.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_holding.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_looking.png +0 -0
- data/test/buildbot/master/public_html/static/images/windows/alter_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/edit_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/environment_variables_button.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/port_and_ppk_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/ppk_selection.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/putty_first_screen.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/save_result.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/vbox_manage_default_location.jpg +0 -0
- data/test/buildbot/master/public_html/static/js/bootstrap-tabs.js +80 -0
- data/test/buildbot/master/public_html/static/js/jquery-1.7.min.js +4 -0
- data/test/buildbot/master/templates/authfail.html +9 -0
- data/test/buildbot/master/templates/build.html +205 -0
- data/test/buildbot/master/templates/builder.html +118 -0
- data/test/buildbot/master/templates/builders.html +33 -0
- data/test/buildbot/master/templates/buildslave.html +72 -0
- data/test/buildbot/master/templates/buildslaves.html +70 -0
- data/test/buildbot/master/templates/change.html +15 -0
- data/test/buildbot/master/templates/layouts/base.html +58 -0
- data/test/buildbot/master/templates/macros/box.html +37 -0
- data/test/buildbot/master/templates/macros/build_line.html +50 -0
- data/test/buildbot/master/templates/macros/change.html +81 -0
- data/test/buildbot/master/templates/macros/forms.html +300 -0
- data/test/buildbot/master/templates/root.html +42 -0
- data/test/buildbot/master/templates/waterfall.html +53 -0
- data/test/buildbot/requirements.txt +4 -0
- data/test/buildbot/scripts/deploy.sh +38 -0
- data/test/buildbot/scripts/setup.sh +107 -0
- data/test/buildbot/slave/buildbot.tac +43 -0
- data/test/buildbot/slave/info/admin +1 -0
- data/test/buildbot/slave/info/host +1 -0
- data/test/buildbot/tests/__init__.py +0 -0
- data/test/buildbot/tests/master/__init__.py +0 -0
- data/test/buildbot/tests/master/test_slaves.py +41 -0
- data/test/buildbot/vendor/choices-0.4.0.tar.gz +0 -0
- data/test/config/acceptance_boxes.yml +7 -0
- data/test/support/isolated_environment.rb +46 -0
- data/test/support/tempdir.rb +34 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +47 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +156 -0
- data/test/unit/vagrant/action/environment_test.rb +16 -0
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +92 -0
- data/test/unit/vagrant/box_collection_test.rb +56 -0
- data/test/unit/vagrant/box_test.rb +34 -0
- data/test/unit/vagrant/command/base_test.rb +150 -0
- data/test/unit/vagrant/config/base_test.rb +48 -0
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/ssh_test.rb +17 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +71 -0
- data/test/unit/vagrant/config_test.rb +27 -0
- data/test/unit/vagrant/data_store_test.rb +79 -0
- data/test/unit/vagrant/downloaders/base_test.rb +18 -0
- data/test/unit/vagrant/downloaders/file_test.rb +75 -0
- data/test/unit/vagrant/downloaders/http_test.rb +19 -0
- data/test/unit/vagrant/environment_test.rb +220 -0
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +74 -0
- data/test/unit/vagrant/util/ansi_escape_code_remover_test.rb +16 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +38 -0
- data/test/unit/vagrant/util/is_port_open_test.rb +53 -0
- data/test/unit/vagrant/util/line_endings_helper_test.rb +16 -0
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +106 -0
- data/test/unit/vagrant_test.rb +27 -0
- data/test/unit_legacy/locales/en.yml +8 -0
- data/test/unit_legacy/test_helper.rb +32 -0
- data/test/unit_legacy/vagrant/action/box/destroy_test.rb +18 -0
- data/test/unit_legacy/vagrant/action/box/download_test.rb +125 -0
- data/test/unit_legacy/vagrant/action/box/package_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/box/unpackage_test.rb +84 -0
- data/test/unit_legacy/vagrant/action/box/verify_test.rb +30 -0
- data/test/unit_legacy/vagrant/action/env/set_test.rb +24 -0
- data/test/unit_legacy/vagrant/action/general/package_test.rb +268 -0
- data/test/unit_legacy/vagrant/action/general/validate_test.rb +31 -0
- data/test/unit_legacy/vagrant/action/vm/boot_test.rb +66 -0
- data/test/unit_legacy/vagrant/action/vm/check_accessible_test.rb +61 -0
- data/test/unit_legacy/vagrant/action/vm/check_box_test.rb +61 -0
- data/test/unit_legacy/vagrant/action/vm/check_guest_additions_test.rb +9 -0
- data/test/unit_legacy/vagrant/action/vm/clean_machine_folder_test.rb +84 -0
- data/test/unit_legacy/vagrant/action/vm/clear_forwarded_ports_test.rb +52 -0
- data/test/unit_legacy/vagrant/action/vm/clear_nfs_exports_test.rb +22 -0
- data/test/unit_legacy/vagrant/action/vm/clear_shared_folders_test.rb +40 -0
- data/test/unit_legacy/vagrant/action/vm/customize_test.rb +37 -0
- data/test/unit_legacy/vagrant/action/vm/destroy_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +49 -0
- data/test/unit_legacy/vagrant/action/vm/discard_state_test.rb +45 -0
- data/test/unit_legacy/vagrant/action/vm/export_test.rb +107 -0
- data/test/unit_legacy/vagrant/action/vm/forward_ports_helpers_test.rb +77 -0
- data/test/unit_legacy/vagrant/action/vm/forward_ports_test.rb +197 -0
- data/test/unit_legacy/vagrant/action/vm/halt_test.rb +79 -0
- data/test/unit_legacy/vagrant/action/vm/host_name_test.rb +36 -0
- data/test/unit_legacy/vagrant/action/vm/import_test.rb +66 -0
- data/test/unit_legacy/vagrant/action/vm/match_mac_address_test.rb +40 -0
- data/test/unit_legacy/vagrant/action/vm/modify_test.rb +38 -0
- data/test/unit_legacy/vagrant/action/vm/network_test.rb +286 -0
- data/test/unit_legacy/vagrant/action/vm/nfs_helpers_test.rb +26 -0
- data/test/unit_legacy/vagrant/action/vm/nfs_test.rb +260 -0
- data/test/unit_legacy/vagrant/action/vm/package_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/vm/package_vagrantfile_test.rb +46 -0
- data/test/unit_legacy/vagrant/action/vm/provision_test.rb +65 -0
- data/test/unit_legacy/vagrant/action/vm/provisioner_cleanup_test.rb +56 -0
- data/test/unit_legacy/vagrant/action/vm/resume_test.rb +35 -0
- data/test/unit_legacy/vagrant/action/vm/share_folders_test.rb +144 -0
- data/test/unit_legacy/vagrant/action/vm/suspend_test.rb +35 -0
- data/test/unit_legacy/vagrant/action_test.rb +89 -0
- data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
- data/test/unit_legacy/vagrant/box_test.rb +74 -0
- data/test/unit_legacy/vagrant/cli_test.rb +35 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/unit_legacy/vagrant/command/group_base_test.rb +15 -0
- data/test/unit_legacy/vagrant/command/helpers_test.rb +88 -0
- data/test/unit_legacy/vagrant/command/init_test.rb +10 -0
- data/test/unit_legacy/vagrant/command/package_test.rb +27 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/unit_legacy/vagrant/config/error_recorder_test.rb +18 -0
- data/test/unit_legacy/vagrant/config/ssh_test.rb +12 -0
- data/test/unit_legacy/vagrant/config/vagrant_test.rb +35 -0
- data/test/unit_legacy/vagrant/config/vm/provisioner_test.rb +92 -0
- data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
- data/test/unit_legacy/vagrant/config_test.rb +148 -0
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
- data/test/unit_legacy/vagrant/environment_test.rb +539 -0
- data/test/unit_legacy/vagrant/errors_test.rb +42 -0
- data/test/unit_legacy/vagrant/hosts/base_test.rb +46 -0
- data/test/unit_legacy/vagrant/hosts/bsd_test.rb +53 -0
- data/test/unit_legacy/vagrant/hosts/linux_test.rb +54 -0
- data/test/unit_legacy/vagrant/plugin_test.rb +9 -0
- data/test/unit_legacy/vagrant/provisioners/base_test.rb +63 -0
- data/test/unit_legacy/vagrant/provisioners/chef_client_test.rb +190 -0
- data/test/unit_legacy/vagrant/provisioners/chef_solo_test.rb +115 -0
- data/test/unit_legacy/vagrant/provisioners/chef_test.rb +209 -0
- data/test/unit_legacy/vagrant/provisioners/puppet_server_test.rb +68 -0
- data/test/unit_legacy/vagrant/provisioners/puppet_test.rb +182 -0
- data/test/unit_legacy/vagrant/provisioners/shell_test.rb +79 -0
- data/test/unit_legacy/vagrant/ssh/session_test.rb +40 -0
- data/test/unit_legacy/vagrant/ssh_test.rb +304 -0
- data/test/unit_legacy/vagrant/systems/base_test.rb +18 -0
- data/test/unit_legacy/vagrant/systems/linux_test.rb +104 -0
- data/test/unit_legacy/vagrant/util/busy_test.rb +106 -0
- data/test/unit_legacy/vagrant/util/counter_test.rb +29 -0
- data/test/unit_legacy/vagrant/util/platform_test.rb +18 -0
- data/test/unit_legacy/vagrant/util/stacked_proc_runner_test.rb +43 -0
- data/test/unit_legacy/vagrant/util/template_renderer_test.rb +145 -0
- data/test/unit_legacy/vagrant/vm_test.rb +300 -0
- data/vagrant-fixed-ssh.gemspec +70 -0
- metadata +712 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Command
|
5
|
+
class Suspend < Base
|
6
|
+
def execute
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant suspend [vm-name]"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
@logger.debug("'suspend' each target VM...")
|
18
|
+
with_target_vms(argv) do |vm|
|
19
|
+
if vm.created?
|
20
|
+
@logger.info("Suspending: #{vm.name}")
|
21
|
+
vm.suspend
|
22
|
+
else
|
23
|
+
@logger.info("Not created: #{vm.name}. Not suspending.")
|
24
|
+
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Success, exit status 0
|
29
|
+
0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
require 'vagrant/command/start_mixins'
|
4
|
+
|
5
|
+
module Vagrant
|
6
|
+
module Command
|
7
|
+
class Up < Base
|
8
|
+
include StartMixins
|
9
|
+
|
10
|
+
def execute
|
11
|
+
options = {}
|
12
|
+
opts = OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: vagrant up [vm-name] [--[no-]provision] [-h]"
|
14
|
+
opts.separator ""
|
15
|
+
build_start_options(opts, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Parse the options
|
19
|
+
argv = parse_options(opts)
|
20
|
+
return if !argv
|
21
|
+
|
22
|
+
# Go over each VM and bring it up
|
23
|
+
@logger.debug("'Up' each target VM...")
|
24
|
+
with_target_vms(argv) do |vm|
|
25
|
+
if vm.created?
|
26
|
+
@logger.info("Booting: #{vm.name}")
|
27
|
+
vm.ui.info I18n.t("vagrant.commands.up.vm_created")
|
28
|
+
vm.start(options)
|
29
|
+
else
|
30
|
+
@logger.info("Creating: #{vm.name}")
|
31
|
+
vm.up(options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Success, exit status 0
|
36
|
+
0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Communication
|
3
|
+
# The base class for any classes that provide an API for communicating
|
4
|
+
# with the virtual machine.
|
5
|
+
#
|
6
|
+
# There are various stages that require Vagrant to copy files or
|
7
|
+
# run commands on the target system, and communication classes provide
|
8
|
+
# the abstraction necessary to perform these tasks, via SSH or some
|
9
|
+
# other mechanism.
|
10
|
+
#
|
11
|
+
# Any subclasses of this class **must** implement all of the methods
|
12
|
+
# below.
|
13
|
+
class Base
|
14
|
+
# Checks if the target machine is ready for communication.
|
15
|
+
#
|
16
|
+
# @return [Boolean]
|
17
|
+
def ready?
|
18
|
+
end
|
19
|
+
|
20
|
+
# Upload a file to the virtual machine.
|
21
|
+
#
|
22
|
+
# @param [String] from Path to a file to upload.
|
23
|
+
# @param [String] to Path to where to save this file.
|
24
|
+
def upload(from, to)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Execute a command on the remote machine.
|
28
|
+
#
|
29
|
+
# @param [String] command Command to execute.
|
30
|
+
# @yield [type, data] Realtime output of the command being executed.
|
31
|
+
# @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
|
32
|
+
# @yieldparam [String] data Data for the given output.
|
33
|
+
# @return [Integer] Exit code of the command.
|
34
|
+
def execute(command, opts=nil)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Execute a comand with super user privileges.
|
38
|
+
#
|
39
|
+
# See #execute for parameter information.
|
40
|
+
def sudo(command, opts=nil)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Executes a command and returns a boolean statement if it was successful
|
44
|
+
# or not.
|
45
|
+
#
|
46
|
+
# This is implemented by default as expecting `execute` to return 0.
|
47
|
+
def test(command, opts=nil)
|
48
|
+
# Disable error checking no matter what
|
49
|
+
opts = (opts || {}).merge(:error_check => false)
|
50
|
+
|
51
|
+
# Successful if the exit status is 0
|
52
|
+
execute(command, opts) == 0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
3
|
+
require 'log4r'
|
4
|
+
require 'net/ssh'
|
5
|
+
require 'net/scp'
|
6
|
+
|
7
|
+
require 'vagrant/util/ansi_escape_code_remover'
|
8
|
+
require 'vagrant/util/file_mode'
|
9
|
+
require 'vagrant/util/platform'
|
10
|
+
require 'vagrant/util/retryable'
|
11
|
+
|
12
|
+
module Vagrant
|
13
|
+
module Communication
|
14
|
+
# Provides communication with the VM via SSH.
|
15
|
+
class SSH < Base
|
16
|
+
include Util::ANSIEscapeCodeRemover
|
17
|
+
include Util::Retryable
|
18
|
+
|
19
|
+
def initialize(vm)
|
20
|
+
@vm = vm
|
21
|
+
@logger = Log4r::Logger.new("vagrant::communication::ssh")
|
22
|
+
@connection = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def ready?
|
26
|
+
@logger.debug("Checking whether SSH is ready...")
|
27
|
+
|
28
|
+
Timeout.timeout(@vm.config.ssh.timeout) do
|
29
|
+
connect
|
30
|
+
end
|
31
|
+
|
32
|
+
# If we reached this point then we successfully connected
|
33
|
+
@logger.info("SSH is ready!")
|
34
|
+
true
|
35
|
+
rescue Timeout::Error, Errors::SSHConnectionRefused, Net::SSH::Disconnect => e
|
36
|
+
# The above errors represent various reasons that SSH may not be
|
37
|
+
# ready yet. Return false.
|
38
|
+
@logger.info("SSH not up: #{e.inspect}")
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
|
42
|
+
def execute(command, opts=nil, &block)
|
43
|
+
opts = {
|
44
|
+
:error_check => true,
|
45
|
+
:error_class => Errors::VagrantError,
|
46
|
+
:error_key => :ssh_bad_exit_status,
|
47
|
+
:command => command,
|
48
|
+
:sudo => false
|
49
|
+
}.merge(opts || {})
|
50
|
+
|
51
|
+
# Connect via SSH and execute the command in the shell.
|
52
|
+
exit_status = connect do |connection|
|
53
|
+
shell_execute(connection, command, opts[:sudo], &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Check for any errors
|
57
|
+
if opts[:error_check] && exit_status != 0
|
58
|
+
# The error classes expect the translation key to be _key,
|
59
|
+
# but that makes for an ugly configuration parameter, so we
|
60
|
+
# set it here from `error_key`
|
61
|
+
error_opts = opts.merge(:_key => opts[:error_key])
|
62
|
+
raise opts[:error_class], error_opts
|
63
|
+
end
|
64
|
+
|
65
|
+
# Return the exit status
|
66
|
+
exit_status
|
67
|
+
end
|
68
|
+
|
69
|
+
def sudo(command, opts=nil, &block)
|
70
|
+
# Run `execute` but with the `sudo` option.
|
71
|
+
opts = { :sudo => true }.merge(opts || {})
|
72
|
+
execute(command, opts, &block)
|
73
|
+
end
|
74
|
+
|
75
|
+
def upload(from, to)
|
76
|
+
@logger.debug("Uploading: #{from} to #{to}")
|
77
|
+
|
78
|
+
# Do an SCP-based upload...
|
79
|
+
connect do |connection|
|
80
|
+
# Open file read only to fix issue #1036
|
81
|
+
scp = Net::SCP.new(connection)
|
82
|
+
scp.upload!(File.open(from, "r"), to)
|
83
|
+
end
|
84
|
+
rescue Net::SCP::Error => e
|
85
|
+
# If we get the exit code of 127, then this means SCP is unavailable.
|
86
|
+
raise Errors::SCPUnavailable if e.message =~ /\(127\)/
|
87
|
+
|
88
|
+
# Otherwise, just raise the error up
|
89
|
+
raise
|
90
|
+
end
|
91
|
+
|
92
|
+
protected
|
93
|
+
|
94
|
+
# Opens an SSH connection and yields it to a block.
|
95
|
+
def connect
|
96
|
+
if @connection && !@connection.closed?
|
97
|
+
# There is a chance that the socket is closed despite us checking
|
98
|
+
# 'closed?' above. To test this we need to send data through the
|
99
|
+
# socket.
|
100
|
+
begin
|
101
|
+
@connection.exec!("")
|
102
|
+
rescue IOError
|
103
|
+
@logger.info("Connection has been closed. Not re-using.")
|
104
|
+
@connection = nil
|
105
|
+
end
|
106
|
+
|
107
|
+
# If the @connection is still around, then it is valid,
|
108
|
+
# and we use it.
|
109
|
+
if @connection
|
110
|
+
@logger.debug("Re-using SSH connection.")
|
111
|
+
return yield @connection if block_given?
|
112
|
+
return
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
ssh_info = @vm.ssh.info
|
117
|
+
|
118
|
+
# Build the options we'll use to initiate the connection via Net::SSH
|
119
|
+
opts = {
|
120
|
+
:port => ssh_info[:port],
|
121
|
+
:keys => [ssh_info[:private_key_path]],
|
122
|
+
:keys_only => true,
|
123
|
+
:user_known_hosts_file => [],
|
124
|
+
:paranoid => false,
|
125
|
+
:config => false,
|
126
|
+
:forward_agent => ssh_info[:forward_agent]
|
127
|
+
}
|
128
|
+
|
129
|
+
# Check that the private key permissions are valid
|
130
|
+
@vm.ssh.check_key_permissions(ssh_info[:private_key_path])
|
131
|
+
|
132
|
+
# Connect to SSH, giving it a few tries
|
133
|
+
connection = nil
|
134
|
+
begin
|
135
|
+
# These are the exceptions that we retry because they represent
|
136
|
+
# errors that are generally fixed from a retry and don't
|
137
|
+
# necessarily represent immediate failure cases.
|
138
|
+
exceptions = [
|
139
|
+
Errno::ECONNREFUSED,
|
140
|
+
Errno::EHOSTUNREACH,
|
141
|
+
Net::SSH::Disconnect,
|
142
|
+
Timeout::Error
|
143
|
+
]
|
144
|
+
|
145
|
+
@logger.info("Connecting to SSH: #{ssh_info[:host]}:#{ssh_info[:port]}")
|
146
|
+
connection = retryable(:tries => @vm.config.ssh.max_tries, :on => exceptions) do
|
147
|
+
Net::SSH.start(ssh_info[:host], ssh_info[:username], opts)
|
148
|
+
end
|
149
|
+
rescue Net::SSH::AuthenticationFailed
|
150
|
+
# This happens if authentication failed. We wrap the error in our
|
151
|
+
# own exception.
|
152
|
+
raise Errors::SSHAuthenticationFailed
|
153
|
+
rescue Errno::ECONNREFUSED
|
154
|
+
# This is raised if we failed to connect the max amount of times
|
155
|
+
raise Errors::SSHConnectionRefused
|
156
|
+
rescue NotImplementedError
|
157
|
+
# This is raised if a private key type that Net-SSH doesn't support
|
158
|
+
# is used. Show a nicer error.
|
159
|
+
raise Errors::SSHKeyTypeNotSupported
|
160
|
+
end
|
161
|
+
|
162
|
+
@connection = connection
|
163
|
+
|
164
|
+
# This is hacky but actually helps with some issues where
|
165
|
+
# Net::SSH is simply not robust enough to handle... see
|
166
|
+
# issue #391, #455, etc.
|
167
|
+
sleep 4
|
168
|
+
|
169
|
+
# Yield the connection that is ready to be used and
|
170
|
+
# return the value of the block
|
171
|
+
return yield connection if block_given?
|
172
|
+
end
|
173
|
+
|
174
|
+
# Executes the command on an SSH connection within a login shell.
|
175
|
+
def shell_execute(connection, command, sudo=false)
|
176
|
+
@logger.info("Execute: #{command} (sudo=#{sudo.inspect})")
|
177
|
+
exit_status = nil
|
178
|
+
|
179
|
+
# Determine the shell to execute. If we are using `sudo` then we
|
180
|
+
# need to wrap the shell in a `sudo` call.
|
181
|
+
shell = "#{@vm.config.ssh.shell} -l"
|
182
|
+
shell = "sudo -H #{shell}" if sudo
|
183
|
+
|
184
|
+
# Open the channel so we can execute or command
|
185
|
+
channel = connection.open_channel do |ch|
|
186
|
+
ch.exec(shell) do |ch2, _|
|
187
|
+
# Setup the channel callbacks so we can get data and exit status
|
188
|
+
ch2.on_data do |ch3, data|
|
189
|
+
if block_given?
|
190
|
+
# Filter out the clear screen command
|
191
|
+
data = remove_ansi_escape_codes(data)
|
192
|
+
@logger.debug("stdout: #{data}")
|
193
|
+
yield :stdout, data
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
ch2.on_extended_data do |ch3, type, data|
|
198
|
+
if block_given?
|
199
|
+
# Filter out the clear screen command
|
200
|
+
data = remove_ansi_escape_codes(data)
|
201
|
+
@logger.debug("stderr: #{data}")
|
202
|
+
yield :stderr, data
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
ch2.on_request("exit-status") do |ch3, data|
|
207
|
+
exit_status = data.read_long
|
208
|
+
@logger.debug("Exit status: #{exit_status}")
|
209
|
+
end
|
210
|
+
|
211
|
+
# Set the terminal
|
212
|
+
ch2.send_data "export TERM=vt100\n"
|
213
|
+
|
214
|
+
# Output the command
|
215
|
+
ch2.send_data "#{command}\n"
|
216
|
+
|
217
|
+
# Remember to exit or this channel will hang open
|
218
|
+
ch2.send_data "exit\n"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
# Wait for the channel to complete
|
223
|
+
channel.wait
|
224
|
+
|
225
|
+
# Return the final exit status
|
226
|
+
return exit_status
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Config
|
3
|
+
autoload :Base, 'vagrant/config/base'
|
4
|
+
autoload :Container, 'vagrant/config/container'
|
5
|
+
autoload :ErrorRecorder, 'vagrant/config/error_recorder'
|
6
|
+
autoload :Loader, 'vagrant/config/loader'
|
7
|
+
autoload :Top, 'vagrant/config/top'
|
8
|
+
|
9
|
+
autoload :NFSConfig, 'vagrant/config/nfs'
|
10
|
+
autoload :PackageConfig, 'vagrant/config/package'
|
11
|
+
autoload :SSHConfig, 'vagrant/config/ssh'
|
12
|
+
autoload :VagrantConfig, 'vagrant/config/vagrant'
|
13
|
+
autoload :VMConfig, 'vagrant/config/vm'
|
14
|
+
|
15
|
+
CONFIGURE_MUTEX = Mutex.new
|
16
|
+
|
17
|
+
# This is the method which is called by all Vagrantfiles to configure Vagrant.
|
18
|
+
# This method expects a block which accepts a single argument representing
|
19
|
+
# an instance of the {Config::Top} class.
|
20
|
+
#
|
21
|
+
# Note that the block is not run immediately. Instead, it's proc is stored
|
22
|
+
# away for execution later.
|
23
|
+
def self.run(&block)
|
24
|
+
# Store it for later
|
25
|
+
@last_procs ||= []
|
26
|
+
@last_procs << block
|
27
|
+
end
|
28
|
+
|
29
|
+
# This is a method which will yield to a block and will capture all
|
30
|
+
# ``Vagrant.configure`` calls, returning an array of `Proc`s.
|
31
|
+
#
|
32
|
+
# Wrapping this around anytime you call code which loads configurations
|
33
|
+
# will force a mutex so that procs never get mixed up. This keeps
|
34
|
+
# the configuration loading part of Vagrant thread-safe.
|
35
|
+
def self.capture_configures
|
36
|
+
CONFIGURE_MUTEX.synchronize do
|
37
|
+
# Reset the last procs so that we start fresh
|
38
|
+
@last_procs = []
|
39
|
+
|
40
|
+
# Yield to allow the caller to do whatever loading needed
|
41
|
+
yield
|
42
|
+
|
43
|
+
# Return the last procs we've seen while still in the mutex,
|
44
|
+
# knowing we're safe.
|
45
|
+
return @last_procs
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Config
|
3
|
+
# The base class for all configuration classes. This implements
|
4
|
+
# basic things such as the environment instance variable which all
|
5
|
+
# config classes need as well as a basic `to_json` implementation.
|
6
|
+
class Base
|
7
|
+
# Loads configuration values from JSON back into the proper
|
8
|
+
# configuration classes. By default, this is done by simply
|
9
|
+
# iterating over all values in the JSON hash and assigning them
|
10
|
+
# to instance variables on the class.
|
11
|
+
def self.json_create(data)
|
12
|
+
data.inject(new) do |result, data|
|
13
|
+
key, value = data
|
14
|
+
result.instance_variable_set("@#{key}".to_sym, value) if key != "json_class"
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Allows setting options from a hash. By default this simply calls
|
20
|
+
# the `#{key}=` method on the config class with the value, which is
|
21
|
+
# the expected behavior most of the time.
|
22
|
+
def set_options(options)
|
23
|
+
options.each do |key, value|
|
24
|
+
send("#{key}=", value)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Merge another configuration object into this one.
|
29
|
+
#
|
30
|
+
# @param [Object] other The other configuration object to merge from,
|
31
|
+
# this must be the same type of object as this one.
|
32
|
+
# @return [Object] The merged object.
|
33
|
+
def merge(other)
|
34
|
+
result = self.class.new
|
35
|
+
instance_variables_hash.merge(other.instance_variables_hash).each do |key, value|
|
36
|
+
# Ignore keys that start with a double underscore. This allows
|
37
|
+
# configuration classes to still hold around internal state
|
38
|
+
# that isn't propagated.
|
39
|
+
if !key.start_with?("__")
|
40
|
+
result.instance_variable_set("@#{key}".to_sym, value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
result
|
45
|
+
end
|
46
|
+
|
47
|
+
# Called by {Top} after the configuration is loaded to validate
|
48
|
+
# the configuaration objects. Subclasses should implement this
|
49
|
+
# method and add any errors to the `errors` object given.
|
50
|
+
#
|
51
|
+
# @param [ErrorRecorder] errors
|
52
|
+
def validate(env, errors); end
|
53
|
+
|
54
|
+
# Converts the configuration to a raw hash by calling `#to_hash`
|
55
|
+
# on all instance variables (if it can) and putting them into
|
56
|
+
# a hash.
|
57
|
+
def to_hash
|
58
|
+
instance_variables_hash.inject({}) do |acc, data|
|
59
|
+
k,v = data
|
60
|
+
v = v.to_hash if v.respond_to?(:to_hash)
|
61
|
+
acc[k] = v
|
62
|
+
acc
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Converts to JSON, with the `json_class` field set so that when
|
67
|
+
# the JSON is parsed back, it can be loaded back into the proper class.
|
68
|
+
# See {json_create}.
|
69
|
+
def to_json(*a)
|
70
|
+
instance_variables_hash.to_json(*a)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns the instance variables as a hash of key-value pairs.
|
74
|
+
def instance_variables_hash
|
75
|
+
instance_variables.inject({}) do |acc, iv|
|
76
|
+
acc[iv.to_s[1..-1]] = instance_variable_get(iv)
|
77
|
+
acc
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|