summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
commit686113531d23f30e9973d659c456ae33eb9cff1f (patch)
treef225de7251a8b49b8d183dd168bab0a0addbe23f /lib
parentd1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff)
downloadchef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/api_client.rb22
-rw-r--r--lib/chef/api_client/registration.rb2
-rw-r--r--lib/chef/api_client_v1.rb22
-rw-r--r--lib/chef/application.rb5
-rw-r--r--lib/chef/application/apply.rb7
-rw-r--r--lib/chef/application/client.rb15
-rw-r--r--lib/chef/application/knife.rb6
-rw-r--r--lib/chef/application/solo.rb11
-rw-r--r--lib/chef/application/windows_service.rb16
-rw-r--r--lib/chef/application/windows_service_manager.rb4
-rw-r--r--lib/chef/audit/audit_reporter.rb4
-rw-r--r--lib/chef/audit/control_group_data.rb9
-rw-r--r--lib/chef/audit/logger.rb2
-rw-r--r--lib/chef/audit/runner.rb1
-rw-r--r--lib/chef/chef_class.rb5
-rw-r--r--lib/chef/chef_fs/chef_fs_data_store.rb20
-rw-r--r--lib/chef/chef_fs/config.rb9
-rw-r--r--lib/chef/chef_fs/data_handler/data_handler_base.rb8
-rw-r--r--lib/chef/chef_fs/file_pattern.rb18
-rw-r--r--lib/chef/chef_fs/file_system.rb6
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb6
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb1
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb4
-rw-r--r--lib/chef/chef_fs/file_system/memory/memory_file.rb1
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/file_system_entry.rb8
-rw-r--r--lib/chef/chef_fs/knife.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer/flatten_enumerable.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer/parallel_enumerable.rb2
-rw-r--r--lib/chef/chef_fs/path_utils.rb5
-rw-r--r--lib/chef/client.rb14
-rw-r--r--lib/chef/constants.rb1
-rw-r--r--lib/chef/cookbook/chefignore.rb3
-rw-r--r--lib/chef/cookbook/cookbook_collection.rb4
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb2
-rw-r--r--lib/chef/cookbook/file_vendor.rb1
-rw-r--r--lib/chef/cookbook/metadata.rb100
-rw-r--r--lib/chef/cookbook/remote_file_vendor.rb2
-rw-r--r--lib/chef/cookbook/synchronizer.rb4
-rw-r--r--lib/chef/cookbook/syntax_check.rb8
-rw-r--r--lib/chef/cookbook_loader.rb6
-rw-r--r--lib/chef/cookbook_manifest.rb3
-rw-r--r--lib/chef/cookbook_site_streaming_uploader.rb14
-rw-r--r--lib/chef/cookbook_uploader.rb8
-rw-r--r--lib/chef/cookbook_version.rb21
-rw-r--r--lib/chef/daemon.rb4
-rw-r--r--lib/chef/data_bag.rb8
-rw-r--r--lib/chef/data_bag_item.rb14
-rw-r--r--lib/chef/deprecation/provider/cookbook_file.rb1
-rw-r--r--lib/chef/deprecation/provider/file.rb12
-rw-r--r--lib/chef/deprecation/provider/remote_directory.rb2
-rw-r--r--lib/chef/deprecation/provider/remote_file.rb2
-rw-r--r--lib/chef/dsl/chef_provisioning.rb2
-rw-r--r--lib/chef/dsl/cheffish.rb2
-rw-r--r--lib/chef/dsl/data_query.rb4
-rw-r--r--lib/chef/dsl/declare_resource.rb6
-rw-r--r--lib/chef/dsl/definitions.rb3
-rw-r--r--lib/chef/dsl/include_attribute.rb2
-rw-r--r--lib/chef/dsl/platform_introspection.rb12
-rw-r--r--lib/chef/dsl/powershell.rb2
-rw-r--r--lib/chef/dsl/reboot_pending.rb13
-rw-r--r--lib/chef/dsl/registry_helper.rb6
-rw-r--r--lib/chef/dsl/resources.rb5
-rw-r--r--lib/chef/encrypted_data_bag_item.rb2
-rw-r--r--lib/chef/encrypted_data_bag_item/assertions.rb2
-rw-r--r--lib/chef/encrypted_data_bag_item/encryptor.rb6
-rw-r--r--lib/chef/environment.rb14
-rw-r--r--lib/chef/event_dispatch/base.rb4
-rw-r--r--lib/chef/event_dispatch/dispatcher.rb2
-rw-r--r--lib/chef/event_dispatch/dsl.rb1
-rw-r--r--lib/chef/exceptions.rb10
-rw-r--r--lib/chef/file_cache.rb6
-rw-r--r--lib/chef/file_content_management/deploy.rb1
-rw-r--r--lib/chef/file_content_management/deploy/mv_unix.rb1
-rw-r--r--lib/chef/file_content_management/deploy/mv_windows.rb2
-rw-r--r--lib/chef/file_content_management/tempfile.rb2
-rw-r--r--lib/chef/formatters/base.rb3
-rw-r--r--lib/chef/formatters/doc.rb7
-rw-r--r--lib/chef/formatters/error_descriptor.rb2
-rw-r--r--lib/chef/formatters/error_inspectors/api_error_formatting.rb23
-rw-r--r--lib/chef/formatters/error_inspectors/compile_error_inspector.rb16
-rw-r--r--lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb7
-rw-r--r--lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb2
-rw-r--r--lib/chef/formatters/error_inspectors/node_load_error_inspector.rb15
-rw-r--r--lib/chef/formatters/error_inspectors/registration_error_inspector.rb32
-rw-r--r--lib/chef/formatters/error_inspectors/resource_failure_inspector.rb11
-rw-r--r--lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb18
-rw-r--r--lib/chef/formatters/minimal.rb7
-rw-r--r--lib/chef/guard_interpreter/default_guard_interpreter.rb1
-rw-r--r--lib/chef/guard_interpreter/resource_guard_interpreter.rb8
-rw-r--r--lib/chef/handler/json_file.rb2
-rw-r--r--lib/chef/http.rb29
-rw-r--r--lib/chef/http/auth_credentials.rb8
-rw-r--r--lib/chef/http/authenticator.rb8
-rw-r--r--lib/chef/http/basic_client.rb16
-rw-r--r--lib/chef/http/cookie_manager.rb4
-rw-r--r--lib/chef/http/decompressor.rb6
-rw-r--r--lib/chef/http/http_request.rb7
-rw-r--r--lib/chef/http/json_input.rb6
-rw-r--r--lib/chef/http/json_output.rb4
-rw-r--r--lib/chef/http/json_to_model_output.rb2
-rw-r--r--lib/chef/http/remote_request_id.rb6
-rw-r--r--lib/chef/http/socketless_chef_zero_client.rb5
-rw-r--r--lib/chef/http/validate_content_length.rb4
-rw-r--r--lib/chef/json_compat.rb2
-rw-r--r--lib/chef/key.rb36
-rw-r--r--lib/chef/knife.rb14
-rw-r--r--lib/chef/knife/bootstrap.rb12
-rw-r--r--lib/chef/knife/bootstrap/chef_vault_handler.rb2
-rw-r--r--lib/chef/knife/client_key_create.rb2
-rw-r--r--lib/chef/knife/client_key_delete.rb2
-rw-r--r--lib/chef/knife/client_key_edit.rb3
-rw-r--r--lib/chef/knife/client_key_list.rb2
-rw-r--r--lib/chef/knife/client_key_show.rb2
-rw-r--r--lib/chef/knife/configure.rb4
-rw-r--r--lib/chef/knife/cookbook_bulk_delete.rb3
-rw-r--r--lib/chef/knife/cookbook_create.rb12
-rw-r--r--lib/chef/knife/cookbook_delete.rb2
-rw-r--r--lib/chef/knife/cookbook_download.rb1
-rw-r--r--lib/chef/knife/cookbook_show.rb4
-rw-r--r--lib/chef/knife/cookbook_site_download.rb1
-rw-r--r--lib/chef/knife/cookbook_site_install.rb2
-rw-r--r--lib/chef/knife/cookbook_site_list.rb8
-rw-r--r--lib/chef/knife/cookbook_site_search.rb7
-rw-r--r--lib/chef/knife/cookbook_site_share.rb3
-rw-r--r--lib/chef/knife/cookbook_site_show.rb7
-rw-r--r--lib/chef/knife/cookbook_test.rb1
-rw-r--r--lib/chef/knife/cookbook_upload.rb9
-rw-r--r--lib/chef/knife/core/cookbook_scm_repo.rb5
-rw-r--r--lib/chef/knife/core/gem_glob_loader.rb6
-rw-r--r--lib/chef/knife/core/generic_presenter.rb15
-rw-r--r--lib/chef/knife/core/hashed_command_loader.rb2
-rw-r--r--lib/chef/knife/core/node_presenter.rb7
-rw-r--r--lib/chef/knife/core/status_presenter.rb4
-rw-r--r--lib/chef/knife/core/subcommand_loader.rb5
-rw-r--r--lib/chef/knife/core/text_formatter.rb4
-rw-r--r--lib/chef/knife/core/ui.rb9
-rw-r--r--lib/chef/knife/data_bag_delete.rb2
-rw-r--r--lib/chef/knife/data_bag_edit.rb3
-rw-r--r--lib/chef/knife/data_bag_from_file.rb1
-rw-r--r--lib/chef/knife/data_bag_list.rb4
-rw-r--r--lib/chef/knife/delete.rb1
-rw-r--r--lib/chef/knife/deps.rb6
-rw-r--r--lib/chef/knife/diff.rb1
-rw-r--r--lib/chef/knife/download.rb1
-rw-r--r--lib/chef/knife/edit.rb1
-rw-r--r--lib/chef/knife/environment_compare.rb34
-rw-r--r--lib/chef/knife/environment_from_file.rb1
-rw-r--r--lib/chef/knife/help.rb4
-rw-r--r--lib/chef/knife/index_rebuild.rb1
-rw-r--r--lib/chef/knife/key_create.rb2
-rw-r--r--lib/chef/knife/key_edit.rb2
-rw-r--r--lib/chef/knife/key_list.rb2
-rw-r--r--lib/chef/knife/node_bulk_delete.rb8
-rw-r--r--lib/chef/knife/node_create.rb3
-rw-r--r--lib/chef/knife/node_delete.rb1
-rw-r--r--lib/chef/knife/node_edit.rb2
-rw-r--r--lib/chef/knife/node_environment_set.rb2
-rw-r--r--lib/chef/knife/node_from_file.rb6
-rw-r--r--lib/chef/knife/node_list.rb2
-rw-r--r--lib/chef/knife/node_run_list_add.rb2
-rw-r--r--lib/chef/knife/node_show.rb1
-rw-r--r--lib/chef/knife/raw.rb2
-rw-r--r--lib/chef/knife/rehash.rb4
-rw-r--r--lib/chef/knife/role_bulk_delete.rb5
-rw-r--r--lib/chef/knife/role_create.rb2
-rw-r--r--lib/chef/knife/role_delete.rb1
-rw-r--r--lib/chef/knife/role_edit.rb3
-rw-r--r--lib/chef/knife/role_env_run_list_add.rb4
-rw-r--r--lib/chef/knife/role_env_run_list_remove.rb16
-rw-r--r--lib/chef/knife/role_env_run_list_replace.rb2
-rw-r--r--lib/chef/knife/role_from_file.rb5
-rw-r--r--lib/chef/knife/role_list.rb1
-rw-r--r--lib/chef/knife/role_run_list_add.rb4
-rw-r--r--lib/chef/knife/role_run_list_remove.rb16
-rw-r--r--lib/chef/knife/role_run_list_replace.rb2
-rw-r--r--lib/chef/knife/role_show.rb3
-rw-r--r--lib/chef/knife/search.rb4
-rw-r--r--lib/chef/knife/serve.rb2
-rw-r--r--lib/chef/knife/ssh.rb14
-rw-r--r--lib/chef/knife/ssl_check.rb3
-rw-r--r--lib/chef/knife/ssl_fetch.rb6
-rw-r--r--lib/chef/knife/status.rb10
-rw-r--r--lib/chef/knife/upload.rb1
-rw-r--r--lib/chef/knife/user_create.rb4
-rw-r--r--lib/chef/knife/user_delete.rb3
-rw-r--r--lib/chef/knife/user_edit.rb3
-rw-r--r--lib/chef/knife/user_key_create.rb2
-rw-r--r--lib/chef/knife/user_key_delete.rb2
-rw-r--r--lib/chef/knife/user_key_edit.rb3
-rw-r--r--lib/chef/knife/user_key_list.rb2
-rw-r--r--lib/chef/knife/user_key_show.rb2
-rw-r--r--lib/chef/knife/user_reregister.rb3
-rw-r--r--lib/chef/knife/user_show.rb2
-rw-r--r--lib/chef/knife/xargs.rb3
-rw-r--r--lib/chef/local_mode.rb2
-rw-r--r--lib/chef/log.rb2
-rw-r--r--lib/chef/log/syslog.rb3
-rw-r--r--lib/chef/log/winevt.rb2
-rw-r--r--lib/chef/mash.rb7
-rw-r--r--lib/chef/mixin/command.rb8
-rw-r--r--lib/chef/mixin/command/unix.rb8
-rw-r--r--lib/chef/mixin/command/windows.rb5
-rw-r--r--lib/chef/mixin/convert_to_class_name.rb8
-rw-r--r--lib/chef/mixin/deprecation.rb45
-rw-r--r--lib/chef/mixin/descendants_tracker.rb3
-rw-r--r--lib/chef/mixin/get_source_from_package.rb1
-rw-r--r--lib/chef/mixin/language_include_attribute.rb1
-rw-r--r--lib/chef/mixin/language_include_recipe.rb1
-rw-r--r--lib/chef/mixin/params_validate.rb7
-rw-r--r--lib/chef/mixin/path_sanity.rb2
-rw-r--r--lib/chef/mixin/powershell_type_coercions.rb18
-rw-r--r--lib/chef/mixin/properties.rb10
-rw-r--r--lib/chef/mixin/provides.rb2
-rw-r--r--lib/chef/mixin/securable.rb31
-rw-r--r--lib/chef/mixin/template.rb9
-rw-r--r--lib/chef/mixin/uris.rb1
-rw-r--r--lib/chef/mixin/why_run.rb5
-rw-r--r--lib/chef/mixin/windows_architecture_helper.rb1
-rw-r--r--lib/chef/mixin/windows_env_helper.rb1
-rw-r--r--lib/chef/mixin/xml_escape.rb10
-rw-r--r--lib/chef/mixins.rb1
-rw-r--r--lib/chef/monkey_patches/net-ssh-multi.rb4
-rw-r--r--lib/chef/monkey_patches/net_http.rb2
-rw-r--r--lib/chef/monkey_patches/webrick-utils.rb4
-rw-r--r--lib/chef/monkey_patches/win32/registry.rb2
-rw-r--r--lib/chef/monologger.rb2
-rw-r--r--lib/chef/node.rb32
-rw-r--r--lib/chef/node/attribute.rb558
-rw-r--r--lib/chef/node/attribute_collections.rb6
-rw-r--r--lib/chef/node/immutable_collections.rb2
-rw-r--r--lib/chef/node_map.rb14
-rw-r--r--lib/chef/null_logger.rb2
-rw-r--r--lib/chef/org.rb18
-rw-r--r--lib/chef/platform/provider_mapping.rb42
-rw-r--r--lib/chef/platform/query_helpers.rb1
-rw-r--r--lib/chef/platform/rebooter.rb2
-rw-r--r--lib/chef/platform/service_helpers.rb2
-rw-r--r--lib/chef/policy_builder/dynamic.rb6
-rw-r--r--lib/chef/policy_builder/expand_node_object.rb4
-rw-r--r--lib/chef/policy_builder/policyfile.rb5
-rw-r--r--lib/chef/property.rb21
-rw-r--r--lib/chef/provider.rb4
-rw-r--r--lib/chef/provider/apt_update.rb1
-rw-r--r--lib/chef/provider/cron.rb6
-rw-r--r--lib/chef/provider/deploy.rb11
-rw-r--r--lib/chef/provider/deploy/revision.rb4
-rw-r--r--lib/chef/provider/dsc_resource.rb6
-rw-r--r--lib/chef/provider/dsc_script.rb6
-rw-r--r--lib/chef/provider/env.rb18
-rw-r--r--lib/chef/provider/execute.rb6
-rw-r--r--lib/chef/provider/file.rb6
-rw-r--r--lib/chef/provider/git.rb28
-rw-r--r--lib/chef/provider/group.rb2
-rw-r--r--lib/chef/provider/group/aix.rb2
-rw-r--r--lib/chef/provider/group/dscl.rb10
-rw-r--r--lib/chef/provider/group/groupadd.rb2
-rw-r--r--lib/chef/provider/group/groupmod.rb2
-rw-r--r--lib/chef/provider/group/windows.rb2
-rw-r--r--lib/chef/provider/http_request.rb12
-rw-r--r--lib/chef/provider/ifconfig.rb3
-rw-r--r--lib/chef/provider/ifconfig/aix.rb3
-rw-r--r--lib/chef/provider/ifconfig/debian.rb2
-rw-r--r--lib/chef/provider/link.rb4
-rw-r--r--lib/chef/provider/mdadm.rb2
-rw-r--r--lib/chef/provider/mount/aix.rb6
-rw-r--r--lib/chef/provider/mount/mount.rb8
-rw-r--r--lib/chef/provider/mount/solaris.rb2
-rw-r--r--lib/chef/provider/osx_profile.rb13
-rw-r--r--lib/chef/provider/package.rb6
-rw-r--r--lib/chef/provider/package/aix.rb6
-rw-r--r--lib/chef/provider/package/chocolatey.rb12
-rw-r--r--lib/chef/provider/package/dpkg.rb8
-rw-r--r--lib/chef/provider/package/easy_install.rb16
-rw-r--r--lib/chef/provider/package/freebsd/base.rb4
-rw-r--r--lib/chef/provider/package/freebsd/pkg.rb4
-rw-r--r--lib/chef/provider/package/freebsd/pkgng.rb2
-rw-r--r--lib/chef/provider/package/freebsd/port.rb4
-rw-r--r--lib/chef/provider/package/macports.rb1
-rw-r--r--lib/chef/provider/package/openbsd.rb6
-rw-r--r--lib/chef/provider/package/pacman.rb5
-rw-r--r--lib/chef/provider/package/paludis.rb2
-rw-r--r--lib/chef/provider/package/portage.rb9
-rw-r--r--lib/chef/provider/package/rubygems.rb30
-rw-r--r--lib/chef/provider/package/smartos.rb4
-rw-r--r--lib/chef/provider/package/windows.rb4
-rw-r--r--lib/chef/provider/package/windows/msi.rb12
-rw-r--r--lib/chef/provider/package/yum.rb53
-rw-r--r--lib/chef/provider/package/zypper.rb4
-rw-r--r--lib/chef/provider/powershell_script.rb6
-rw-r--r--lib/chef/provider/registry_key.rb8
-rw-r--r--lib/chef/provider/remote_directory.rb4
-rw-r--r--lib/chef/provider/remote_file/cache_control_data.rb3
-rw-r--r--lib/chef/provider/remote_file/http.rb2
-rw-r--r--lib/chef/provider/remote_file/local_file.rb2
-rw-r--r--lib/chef/provider/route.rb366
-rw-r--r--lib/chef/provider/service.rb14
-rw-r--r--lib/chef/provider/service/aix.rb2
-rw-r--r--lib/chef/provider/service/aixinit.rb10
-rw-r--r--lib/chef/provider/service/arch.rb6
-rw-r--r--lib/chef/provider/service/debian.rb17
-rw-r--r--lib/chef/provider/service/freebsd.rb2
-rw-r--r--lib/chef/provider/service/macosx.rb2
-rw-r--r--lib/chef/provider/service/openbsd.rb2
-rw-r--r--lib/chef/provider/service/redhat.rb2
-rw-r--r--lib/chef/provider/service/simple.rb3
-rw-r--r--lib/chef/provider/service/solaris.rb2
-rw-r--r--lib/chef/provider/service/upstart.rb4
-rw-r--r--lib/chef/provider/service/windows.rb5
-rw-r--r--lib/chef/provider/subversion.rb12
-rw-r--r--lib/chef/provider/template_finder.rb1
-rw-r--r--lib/chef/provider/user.rb3
-rw-r--r--lib/chef/provider/user/aix.rb3
-rw-r--r--lib/chef/provider/user/dscl.rb35
-rw-r--r--lib/chef/provider/user/pw.rb2
-rw-r--r--lib/chef/provider/user/useradd.rb2
-rw-r--r--lib/chef/provider/user/windows.rb8
-rw-r--r--lib/chef/provider/windows_script.rb2
-rw-r--r--lib/chef/recipe.rb1
-rw-r--r--lib/chef/resource.rb60
-rw-r--r--lib/chef/resource/action_class.rb2
-rw-r--r--lib/chef/resource/bash.rb2
-rw-r--r--lib/chef/resource/batch.rb2
-rw-r--r--lib/chef/resource/breakpoint.rb3
-rw-r--r--lib/chef/resource/chef_gem.rb2
-rw-r--r--lib/chef/resource/chocolatey_package.rb2
-rw-r--r--lib/chef/resource/conditional.rb8
-rw-r--r--lib/chef/resource/cookbook_file.rb6
-rw-r--r--lib/chef/resource/cron.rb34
-rw-r--r--lib/chef/resource/csh.rb2
-rw-r--r--lib/chef/resource/deploy.rb82
-rw-r--r--lib/chef/resource/directory.rb6
-rw-r--r--lib/chef/resource/dsc_resource.rb11
-rw-r--r--lib/chef/resource/dsc_script.rb22
-rw-r--r--lib/chef/resource/env.rb8
-rw-r--r--lib/chef/resource/erl_call.rb12
-rw-r--r--lib/chef/resource/execute.rb24
-rw-r--r--lib/chef/resource/file.rb2
-rw-r--r--lib/chef/resource/file/verification.rb6
-rw-r--r--lib/chef/resource/git.rb4
-rw-r--r--lib/chef/resource/group.rb17
-rw-r--r--lib/chef/resource/http_request.rb8
-rw-r--r--lib/chef/resource/ifconfig.rb26
-rw-r--r--lib/chef/resource/ksh.rb2
-rw-r--r--lib/chef/resource/link.rb13
-rw-r--r--lib/chef/resource/log.rb6
-rw-r--r--lib/chef/resource/macosx_service.rb6
-rw-r--r--lib/chef/resource/mdadm.rb17
-rw-r--r--lib/chef/resource/mount.rb30
-rw-r--r--lib/chef/resource/ohai.rb6
-rw-r--r--lib/chef/resource/osx_profile.rb10
-rw-r--r--lib/chef/resource/perl.rb2
-rw-r--r--lib/chef/resource/portage_package.rb2
-rw-r--r--lib/chef/resource/powershell_script.rb6
-rw-r--r--lib/chef/resource/python.rb2
-rw-r--r--lib/chef/resource/reboot.rb6
-rw-r--r--lib/chef/resource/registry_key.rb12
-rw-r--r--lib/chef/resource/remote_directory.rb19
-rw-r--r--lib/chef/resource/remote_file.rb16
-rw-r--r--lib/chef/resource/route.rb24
-rw-r--r--lib/chef/resource/ruby.rb2
-rw-r--r--lib/chef/resource/ruby_block.rb4
-rw-r--r--lib/chef/resource/scm.rb37
-rw-r--r--lib/chef/resource/script.rb10
-rw-r--r--lib/chef/resource/service.rb32
-rw-r--r--lib/chef/resource/subversion.rb4
-rw-r--r--lib/chef/resource/template.rb16
-rw-r--r--lib/chef/resource/user.rb28
-rw-r--r--lib/chef/resource/windows_package.rb2
-rw-r--r--lib/chef/resource/windows_script.rb2
-rw-r--r--lib/chef/resource/windows_service.rb8
-rw-r--r--lib/chef/resource_collection.rb6
-rw-r--r--lib/chef/resource_collection/resource_collection_serialization.rb2
-rw-r--r--lib/chef/resource_collection/resource_set.rb4
-rw-r--r--lib/chef/resource_collection/stepable_iterator.rb6
-rw-r--r--lib/chef/resource_definition.rb4
-rw-r--r--lib/chef/resource_definition_list.rb2
-rw-r--r--lib/chef/resource_reporter.rb12
-rw-r--r--lib/chef/resource_resolver.rb1
-rw-r--r--lib/chef/rest.rb12
-rw-r--r--lib/chef/role.rb23
-rw-r--r--lib/chef/run_context.rb8
-rw-r--r--lib/chef/run_context/cookbook_compiler.rb7
-rw-r--r--lib/chef/run_list.rb10
-rw-r--r--lib/chef/run_list/run_list_expansion.rb26
-rw-r--r--lib/chef/run_list/run_list_item.rb3
-rw-r--r--lib/chef/run_list/versioned_recipe_list.rb4
-rw-r--r--lib/chef/run_lock.rb4
-rw-r--r--lib/chef/run_status.rb2
-rw-r--r--lib/chef/runner.rb7
-rw-r--r--lib/chef/search/query.rb10
-rw-r--r--lib/chef/server_api.rb2
-rw-r--r--lib/chef/shell.rb9
-rw-r--r--lib/chef/shell/ext.rb56
-rw-r--r--lib/chef/shell/model_wrapper.rb7
-rw-r--r--lib/chef/shell/shell_session.rb6
-rw-r--r--lib/chef/shell_out.rb2
-rw-r--r--lib/chef/tasks/chef_repo.rake1
-rw-r--r--lib/chef/user.rb26
-rw-r--r--lib/chef/user_v1.rb36
-rw-r--r--lib/chef/util/backup.rb4
-rw-r--r--lib/chef/util/dsc/configuration_generator.rb8
-rw-r--r--lib/chef/util/dsc/lcm_output_parser.rb6
-rw-r--r--lib/chef/util/dsc/local_configuration_manager.rb4
-rw-r--r--lib/chef/util/dsc/resource_info.rb30
-rw-r--r--lib/chef/util/dsc/resource_store.rb139
-rw-r--r--lib/chef/util/editor.rb1
-rw-r--r--lib/chef/util/powershell/cmdlet.rb228
-rw-r--r--lib/chef/util/powershell/cmdlet_result.rb66
-rw-r--r--lib/chef/util/selinux.rb2
-rw-r--r--lib/chef/util/windows/net_group.rb1
-rw-r--r--lib/chef/util/windows/net_use.rb4
-rw-r--r--lib/chef/util/windows/net_user.rb7
-rw-r--r--lib/chef/version/platform.rb4
-rw-r--r--lib/chef/version_class.rb4
-rw-r--r--lib/chef/version_constraint.rb6
-rw-r--r--lib/chef/whitelist.rb2
-rw-r--r--lib/chef/win32/api.rb2
-rw-r--r--lib/chef/win32/api/crypto.rb6
-rw-r--r--lib/chef/win32/api/error.rb12
-rw-r--r--lib/chef/win32/api/file.rb19
-rw-r--r--lib/chef/win32/api/installer.rb19
-rw-r--r--lib/chef/win32/api/net.rb2
-rw-r--r--lib/chef/win32/api/registry.rb2
-rw-r--r--lib/chef/win32/api/security.rb27
-rw-r--r--lib/chef/win32/file.rb10
-rw-r--r--lib/chef/win32/file/info.rb1
-rw-r--r--lib/chef/win32/file/version_info.rb2
-rw-r--r--lib/chef/win32/net.rb10
-rw-r--r--lib/chef/win32/registry.rb15
-rw-r--r--lib/chef/win32/security.rb11
-rw-r--r--lib/chef/win32/security/acl.rb6
-rw-r--r--lib/chef/win32/security/sid.rb38
-rw-r--r--lib/chef/win32/unicode.rb4
-rw-r--r--lib/chef/win32/version.rb38
440 files changed, 2329 insertions, 2469 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb
index bff5e0b378..27701c6b68 100644
--- a/lib/chef/api_client.rb
+++ b/lib/chef/api_client.rb
@@ -49,7 +49,7 @@ class Chef
#
# @params [Optional String] The name must be alpha-numeric plus - and _.
# @return [String] The current value of the name.
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(
:name,
arg,
@@ -61,7 +61,7 @@ class Chef
#
# @params [Optional True/False] Should be true or false - default is false.
# @return [True/False] The current value
- def admin(arg=nil)
+ def admin(arg = nil)
set_or_return(
:admin,
arg,
@@ -73,7 +73,7 @@ class Chef
#
# @params [Optional String] The string representation of the public key.
# @return [String] The current value.
- def public_key(arg=nil)
+ def public_key(arg = nil)
set_or_return(
:public_key,
arg,
@@ -86,7 +86,7 @@ class Chef
# @params [Boolean] whether or not the client is a validator. If
# `nil`, retrieves the already-set value.
# @return [Boolean] The current value
- def validator(arg=nil)
+ def validator(arg = nil)
set_or_return(
:validator,
arg,
@@ -98,7 +98,7 @@ class Chef
#
# @params [Optional String] The string representation of the private key.
# @return [String] The current value.
- def private_key(arg=nil)
+ def private_key(arg = nil)
set_or_return(
:private_key,
arg,
@@ -150,7 +150,7 @@ class Chef
end
def self.http_api
- Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"})
+ Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" })
end
def self.reregister(name)
@@ -158,7 +158,7 @@ class Chef
api_client.reregister
end
- def self.list(inflate=false)
+ def self.list(inflate = false)
if inflate
response = Hash.new
Chef::Search::Query.new.search(:client) do |n|
@@ -189,11 +189,11 @@ class Chef
# Save this client via the REST API, returns a hash including the private key
def save
begin
- http_api.put("clients/#{name}", { :name => self.name, :admin => self.admin, :validator => self.validator})
+ http_api.put("clients/#{name}", { :name => self.name, :admin => self.admin, :validator => self.validator })
rescue Net::HTTPServerException => e
# If that fails, go ahead and try and update it
if e.response.code == "404"
- http_api.post("clients", {:name => self.name, :admin => self.admin, :validator => self.validator })
+ http_api.post("clients", { :name => self.name, :admin => self.admin, :validator => self.validator })
else
raise e
end
@@ -222,11 +222,11 @@ class Chef
def inspect
"Chef::ApiClient name:'#{name}' admin:'#{admin.inspect}' validator:'#{validator}' " +
- "public_key:'#{public_key}' private_key:'#{private_key}'"
+ "public_key:'#{public_key}' private_key:'#{private_key}'"
end
def http_api
- @http_api ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"})
+ @http_api ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" })
end
end
diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb
index 98ab1c01c2..8547b4afa4 100644
--- a/lib/chef/api_client/registration.rb
+++ b/lib/chef/api_client/registration.rb
@@ -180,7 +180,7 @@ class Chef
end
def file_flags
- base_flags = File::CREAT|File::TRUNC|File::RDWR
+ base_flags = File::CREAT | File::TRUNC | File::RDWR
# Windows doesn't have symlinks, so it doesn't have NOFOLLOW
if defined?(File::NOFOLLOW) && !Chef::Config[:follow_client_key_symlink]
base_flags |= File::NOFOLLOW
diff --git a/lib/chef/api_client_v1.rb b/lib/chef/api_client_v1.rb
index b177ec1284..ce624ad671 100644
--- a/lib/chef/api_client_v1.rb
+++ b/lib/chef/api_client_v1.rb
@@ -44,7 +44,7 @@ class Chef
include Chef::Mixin::ParamsValidate
include Chef::Mixin::ApiVersionRequestHandling
- SUPPORTED_API_VERSIONS = [0,1]
+ SUPPORTED_API_VERSIONS = [0, 1]
# Create a new Chef::ApiClientV1 object.
def initialize
@@ -57,22 +57,22 @@ class Chef
end
def chef_rest_v0
- @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0", :inflate_json_class => false})
+ @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0", :inflate_json_class => false })
end
def chef_rest_v1
- @chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "1", :inflate_json_class => false})
+ @chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "1", :inflate_json_class => false })
end
def self.http_api
- Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "1", :inflate_json_class => false})
+ Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "1", :inflate_json_class => false })
end
# Gets or sets the client name.
#
# @params [Optional String] The name must be alpha-numeric plus - and _.
# @return [String] The current value of the name.
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(
:name,
arg,
@@ -84,7 +84,7 @@ class Chef
#
# @params [Optional True/False] Should be true or false - default is false.
# @return [True/False] The current value
- def admin(arg=nil)
+ def admin(arg = nil)
set_or_return(
:admin,
arg,
@@ -96,7 +96,7 @@ class Chef
#
# @params [Optional String] The string representation of the public key.
# @return [String] The current value.
- def public_key(arg=nil)
+ def public_key(arg = nil)
set_or_return(
:public_key,
arg,
@@ -109,7 +109,7 @@ class Chef
# @params [Boolean] whether or not the client is a validator. If
# `nil`, retrieves the already-set value.
# @return [Boolean] The current value
- def validator(arg=nil)
+ def validator(arg = nil)
set_or_return(
:validator,
arg,
@@ -122,7 +122,7 @@ class Chef
#
# @params [Optional String] The string representation of the private key.
# @return [String] The current value.
- def private_key(arg=nil)
+ def private_key(arg = nil)
set_or_return(
:private_key,
arg,
@@ -134,7 +134,7 @@ class Chef
#
# @params [Optional True/False] Should be true or false - default is false.
# @return [True/False] The current value
- def create_key(arg=nil)
+ def create_key(arg = nil)
set_or_return(
:create_key,
arg,
@@ -186,7 +186,7 @@ class Chef
api_client.reregister
end
- def self.list(inflate=false)
+ def self.list(inflate = false)
if inflate
response = Hash.new
Chef::Search::Query.new.search(:client) do |n|
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index c5a128a179..c2adcda524 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -154,7 +154,7 @@ class Chef
def configure_stdout_logger
stdout_logger = MonoLogger.new(STDOUT)
stdout_logger.formatter = Chef::Log.logger.formatter
- Chef::Log.loggers << stdout_logger
+ Chef::Log.loggers << stdout_logger
end
# Based on config and whether or not STDOUT is a tty, should we setup a
@@ -232,6 +232,7 @@ class Chef
end
private
+
def can_fork?
# win32-process gem exposes some form of :fork for Process
# class. So we are separately ensuring that the platform we're
@@ -297,7 +298,7 @@ class Chef
rescue Exception => error
Chef::Log.fatal("Configuration error #{error.class}: #{error.message}")
filtered_trace = error.backtrace.grep(/#{Regexp.escape(config_file_path)}/)
- filtered_trace.each {|line| Chef::Log.fatal(" " + line )}
+ filtered_trace.each { |line| Chef::Log.fatal(" " + line ) }
Chef::Application.fatal!("Aborting due to error in '#{config_file_path}'", 2)
end
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index 04dc1dae34..38b00f293c 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -82,13 +82,12 @@ class Chef::Application::Apply < Chef::Application
:show_options => true,
:exit => 0
-
option :version,
:short => "-v",
:long => "--version",
:description => "Show chef version",
:boolean => true,
- :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
+ :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
:exit => 0
option :why_run,
@@ -187,9 +186,9 @@ class Chef::Application::Apply < Chef::Application
Chef::Application.exit! "No recipe file provided", 1
end
@recipe_filename = ARGV[0]
- @recipe_text,@recipe_fh = read_recipe_file @recipe_filename
+ @recipe_text, @recipe_fh = read_recipe_file @recipe_filename
end
- recipe,run_context = get_recipe_and_run_context
+ recipe, run_context = get_recipe_and_run_context
recipe.instance_eval(@recipe_text, @recipe_filename, 1)
runner = Chef::Runner.new(run_context)
begin
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index ea091276d1..a3cac2782a 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -181,7 +181,7 @@ class Chef::Application::Client < Chef::Application
:long => "--version",
:description => "Show chef version",
:boolean => true,
- :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
+ :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
:exit => 0
option :override_runlist,
@@ -402,6 +402,7 @@ class Chef::Application::Client < Chef::Application
end
private
+
def interval_run_chef_client
if Chef::Config[:daemonize]
Chef::Daemon.daemonize("chef-client")
@@ -461,16 +462,16 @@ class Chef::Application::Client < Chef::Application
def unforked_interval_error_message
"Unforked chef-client interval runs are disabled in Chef 12." +
- "\nConfiguration settings:" +
- "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
- "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ "\nConfiguration settings:" +
+ "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
def audit_mode_settings_explanation
"\n* To enable audit mode after converge, use command line option `--audit-mode enabled` or set `audit_mode :enabled` in your config file." +
- "\n* To disable audit mode, use command line option `--audit-mode disabled` or set `audit_mode :disabled` in your config file." +
- "\n* To only run audit mode, use command line option `--audit-mode audit-only` or set `audit_mode :audit_only` in your config file." +
- "\nAudit mode is disabled by default."
+ "\n* To disable audit mode, use command line option `--audit-mode disabled` or set `audit_mode :disabled` in your config file." +
+ "\n* To only run audit mode, use command line option `--audit-mode audit-only` or set `audit_mode :audit_only` in your config file." +
+ "\nAudit mode is disabled by default."
end
def unrecognized_audit_mode(mode)
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index bb1e1f7918..849a011ab3 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -38,7 +38,7 @@ class Chef::Application::Knife < Chef::Application
:short => "-V",
:long => "--verbose",
:description => "More verbose output. Use twice for max verbosity",
- :proc => Proc.new { verbosity_level += 1},
+ :proc => Proc.new { verbosity_level += 1 },
:default => 0
option :color,
@@ -131,7 +131,7 @@ class Chef::Application::Knife < Chef::Application
:long => "--version",
:description => "Show chef version",
:boolean => true,
- :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
+ :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
:exit => 0
option :fips,
@@ -191,7 +191,7 @@ class Chef::Application::Knife < Chef::Application
ARGV[0] =~ /^(--version|-v)$/
end
- def print_help_and_exit(exitcode=1, fatal_message=nil)
+ def print_help_and_exit(exitcode = 1, fatal_message = nil)
Chef::Log.error(fatal_message) if fatal_message
begin
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 54d31a5faa..dbf843125e 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -145,7 +145,7 @@ class Chef::Application::Solo < Chef::Application
:long => "--version",
:description => "Show chef version",
:boolean => true,
- :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
+ :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
:exit => 0
option :override_runlist,
@@ -211,7 +211,7 @@ class Chef::Application::Solo < Chef::Application
Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval]
if Chef::Config[:recipe_url]
- cookbooks_path = Array(Chef::Config[:cookbook_path]).detect{|e| e =~ /\/cookbooks\/*$/ }
+ cookbooks_path = Array(Chef::Config[:cookbook_path]).detect { |e| e =~ /\/cookbooks\/*$/ }
recipes_path = File.expand_path(File.join(cookbooks_path, ".."))
Chef::Log.debug "Cleanup path #{recipes_path} before extract recipes into it"
@@ -254,7 +254,6 @@ class Chef::Application::Solo < Chef::Application
end
end
-
private
def for_ezra
@@ -312,8 +311,8 @@ EOH
def unforked_interval_error_message
"Unforked chef-client interval runs are disabled in Chef 12." +
- "\nConfiguration settings:" +
- "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
- "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ "\nConfiguration settings:" +
+ "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
end
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index 0032114136..b955dd31b8 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -187,12 +187,12 @@ class Chef
Chef::Log.info "Starting chef-client in a new process"
# Pass config params to the new process
config_params = " --no-fork"
- config_params += " -c #{Chef::Config[:config_file]}" unless Chef::Config[:config_file].nil?
+ config_params += " -c #{Chef::Config[:config_file]}" unless Chef::Config[:config_file].nil?
# log_location might be an event logger and if so we cannot pass as a command argument
# but shed no tears! If the logger is an event logger, it must have been configured
# as such in the config file and chef-client will use that when no arg is passed here
config_params += " -L #{resolve_log_location}" if resolve_log_location.is_a?(String)
-
+
# Starts a new process and waits till the process exits
result = shell_out(
@@ -204,8 +204,8 @@ class Chef
Chef::Log.debug "#{result.stderr}"
rescue Mixlib::ShellOut::CommandTimeout => e
Chef::Log.error "chef-client timed out\n(#{e})"
- Chef::Log.error(<<-EOF)
- Your chef-client run timed out. You can increase the time chef-client is given
+ Chef::Log.error(<<-EOF)
+ Your chef-client run timed out. You can increase the time chef-client is given
to complete by configuring windows_service.watchdog_timeout in your client.rb.
EOF
rescue Mixlib::ShellOut::ShellCommandFailed => e
@@ -225,12 +225,12 @@ class Chef
# Lifted from Chef::Application, with addition of optional startup parameters
# for playing nicely with Windows Services
- def reconfigure(startup_parameters=[])
+ def reconfigure(startup_parameters = [])
configure_chef startup_parameters
configure_logging
Chef::Config[:chef_server_url] = config[:chef_server_url] if config.has_key? :chef_server_url
- unless Chef::Config[:exception_handlers].any? {|h| Chef::Handler::ErrorReport === h}
+ unless Chef::Config[:exception_handlers].any? { |h| Chef::Handler::ErrorReport === h }
Chef::Config[:exception_handlers] << Chef::Handler::ErrorReport.new
end
@@ -251,7 +251,7 @@ class Chef
def configure_stdout_logger
stdout_logger = MonoLogger.new(STDOUT)
stdout_logger.formatter = Chef::Log.logger.formatter
- Chef::Log.loggers << stdout_logger
+ Chef::Log.loggers << stdout_logger
end
# Based on config and whether or not STDOUT is a tty, should we setup a
@@ -334,5 +334,5 @@ end
# To run this file as a service, it must be called as a script from within
# the Windows Service framework. In that case, kick off the main loop!
if __FILE__ == $0
- Chef::Application::WindowsService.mainloop
+ Chef::Application::WindowsService.mainloop
end
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb
index 7a89766cb4..74ee395139 100644
--- a/lib/chef/application/windows_service_manager.rb
+++ b/lib/chef/application/windows_service_manager.rb
@@ -67,7 +67,7 @@ class Chef
:long => "--version",
:description => "Show chef version",
:boolean => true,
- :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
+ :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
:exit => 0
def initialize(service_options)
@@ -169,7 +169,7 @@ class Chef
return ::Win32::Service.exists?(@service_name)
end
- def take_action(action=nil, desired_state=nil)
+ def take_action(action = nil, desired_state = nil)
if service_exists?
if current_state != desired_state
::Win32::Service.send(action, @service_name)
diff --git a/lib/chef/audit/audit_reporter.rb b/lib/chef/audit/audit_reporter.rb
index e647f143ae..a40cae93dd 100644
--- a/lib/chef/audit/audit_reporter.rb
+++ b/lib/chef/audit/audit_reporter.rb
@@ -154,13 +154,13 @@ class Chef
end
def headers(additional_headers = {})
- options = {"X-Ops-Audit-Report-Protocol-Version" => PROTOCOL_VERSION}
+ options = { "X-Ops-Audit-Report-Protocol-Version" => PROTOCOL_VERSION }
options.merge(additional_headers)
end
def encode_gzip(data)
"".tap do |out|
- Zlib::GzipWriter.wrap(StringIO.new(out)){|gz| gz << data }
+ Zlib::GzipWriter.wrap(StringIO.new(out)) { |gz| gz << data }
end
end
diff --git a/lib/chef/audit/control_group_data.rb b/lib/chef/audit/control_group_data.rb
index 688341adad..4dffbdf3dd 100644
--- a/lib/chef/audit/control_group_data.rb
+++ b/lib/chef/audit/control_group_data.rb
@@ -49,7 +49,7 @@ class Chef
class ControlGroupData
attr_reader :name, :status, :number_succeeded, :number_failed, :controls, :metadata
- def initialize(name, metadata={})
+ def initialize(name, metadata = {})
@status = "success"
@controls = []
@number_succeeded = 0
@@ -58,7 +58,6 @@ class Chef
@metadata = metadata
end
-
def example_success(control_data)
@number_succeeded += 1
control = create_control(control_data)
@@ -80,7 +79,7 @@ class Chef
def to_hash
# We sort it so the examples appear in the output in the same order
# they appeared in the recipe
- controls.sort! {|x,y| x.line_number <=> y.line_number}
+ controls.sort! { |x, y| x.line_number <=> y.line_number }
h = {
:name => name,
:status => status,
@@ -105,7 +104,7 @@ class Chef
group[:id] = SecureRandom.uuid
group[:controls].collect!.with_index do |c, i|
# i is zero-indexed, and we want the display one-indexed
- c[:sequence_number] = i+1
+ c[:sequence_number] = i + 1
c
end
group
@@ -117,7 +116,7 @@ class Chef
attr_reader :name, :resource_type, :resource_name, :context, :line_number
attr_accessor :status, :details
- def initialize(control_data={})
+ def initialize(control_data = {})
control_data.each do |k, v|
self.instance_variable_set("@#{k}", v)
end
diff --git a/lib/chef/audit/logger.rb b/lib/chef/audit/logger.rb
index 9e1b779f5b..759683ccc8 100644
--- a/lib/chef/audit/logger.rb
+++ b/lib/chef/audit/logger.rb
@@ -20,7 +20,7 @@ require "stringio"
class Chef
class Audit
class Logger
- def self.puts(message="")
+ def self.puts(message = "")
@buffer ||= StringIO.new
@buffer.puts(message)
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index 561c50734c..100a72d2e1 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -52,6 +52,7 @@ class Chef
end
private
+
# Prepare to run audits:
# - Require files
# - Configure RSpec
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb
index 29996b7b7f..f019448bd8 100644
--- a/lib/chef/chef_class.rb
+++ b/lib/chef/chef_class.rb
@@ -178,14 +178,17 @@ class Chef
# these slurp in the resource+provider world, so be exceedingly lazy about requiring them
@provider_priority_map ||= Chef::Platform::ProviderPriorityMap.instance
end
+
# @api private
def resource_priority_map
@resource_priority_map ||= Chef::Platform::ResourcePriorityMap.instance
end
+
# @api private
def provider_handler_map
@provider_handler_map ||= Chef::Platform::ProviderHandlerMap.instance
end
+
# @api private
def resource_handler_map
@resource_handler_map ||= Chef::Platform::ResourceHandlerMap.instance
@@ -204,7 +207,7 @@ class Chef
#
# @api private this will likely be removed in favor of an as-yet unwritten
# `Chef.log`
- def log_deprecation(message, location=nil)
+ def log_deprecation(message, location = nil)
location ||= Chef::Log.caller_location
# `run_context.events` is the primary deprecation target if we're in a
# run. If we are not yet in a run, print to `Chef::Log`.
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb
index 389cea472e..7cf7d5f8d9 100644
--- a/lib/chef/chef_fs/chef_fs_data_store.rb
+++ b/lib/chef/chef_fs/chef_fs_data_store.rb
@@ -154,7 +154,7 @@ class Chef
# Generally will be a +ChefFS::FileSystem::ChefRepositoryFileSystemRoot+
# object, created from +ChefFS::Config.local_fs+.
#
- def initialize(chef_fs, chef_config=Chef::Config)
+ def initialize(chef_fs, chef_config = Chef::Config)
@chef_fs = chef_fs
@memory_store = ChefZero::DataStore::MemoryStore.new
@repo_mode = chef_config[:repo_mode]
@@ -260,7 +260,7 @@ class Chef
end
end
- def get(path, request=nil)
+ def get(path, request = nil)
if use_memory_store?(path)
@memory_store.get(path)
@@ -335,11 +335,11 @@ class Chef
if cookbook_type == "cookbook_artifacts"
result["metadata"] = result["metadata"].to_hash
- result["metadata"].delete_if do |key,value|
+ result["metadata"].delete_if do |key, value|
value == [] ||
- (value == {} && !%w{dependencies attributes recipes}.include?(key)) ||
- (value == "" && %w{source_url issues_url}.include?(key)) ||
- (value == false && key == "privacy")
+ (value == {} && !%w{dependencies attributes recipes}.include?(key)) ||
+ (value == "" && %w{source_url issues_url}.include?(key)) ||
+ (value == false && key == "privacy")
end
end
@@ -537,8 +537,8 @@ class Chef
result = with_entry([ path[0] ]) do |entry|
# list /cookbooks/name = filter /cookbooks/name-version down to name
entry.children.map { |child| split_name_version(child.name) }.
- select { |name, version| name == path[1] }.
- map { |name, version| version }
+ select { |name, version| name == path[1] }.
+ map { |name, version| version }
end
if result.empty?
raise ChefZero::DataStore::DataNotFoundError.new(path)
@@ -651,7 +651,7 @@ class Chef
name_version = entry_name.split("-")
name = name_version[0..-2].join("-")
version = name_version[-1]
- [name,version]
+ [name, version]
end
def to_chef_fs_path(path)
@@ -798,7 +798,7 @@ class Chef
end
end
- def get_dir(path, create=false)
+ def get_dir(path, create = false)
result = Chef::ChefFS::FileSystem.resolve_path(chef_fs, path.join("/"))
if result.exists?
result
diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb
index 19cea3b4ea..5eae0501a1 100644
--- a/lib/chef/chef_fs/config.rb
+++ b/lib/chef/chef_fs/config.rb
@@ -44,7 +44,7 @@ class Chef
"policies" => "policy",
"policy_groups" => "policy_group",
}
- INFLECTIONS.each { |k,v| k.freeze; v.freeze }
+ INFLECTIONS.each { |k, v| k.freeze; v.freeze }
INFLECTIONS.freeze
# ChefFS supports three modes of operation: "static", "everything", and
@@ -74,7 +74,6 @@ class Chef
EVERYTHING_MODE_OBJECT_NAMES = (CHEF_11_OSS_STATIC_OBJECTS + CHEF_11_OSS_DYNAMIC_OBJECTS).freeze
HOSTED_EVERYTHING_MODE_OBJECT_NAMES = (EVERYTHING_MODE_OBJECT_NAMES + RBAC_OBJECT_NAMES + CHEF_12_OBJECTS).freeze
-
#
# Create a new Config object which can produce a chef_fs and local_fs.
#
@@ -243,12 +242,12 @@ class Chef
# Print the given server path, relative to the current directory
def format_path(entry)
server_path = entry.path
- if base_path && server_path[0,base_path.length] == base_path
+ if base_path && server_path[0, base_path.length] == base_path
if server_path == base_path
return "."
- elsif server_path[base_path.length,1] == "/"
+ elsif server_path[base_path.length, 1] == "/"
return server_path[base_path.length + 1, server_path.length - base_path.length - 1]
- elsif base_path == "/" && server_path[0,1] == "/"
+ elsif base_path == "/" && server_path[0, 1] == "/"
return server_path[1, server_path.length - 1]
end
end
diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb
index 41c5dd13e2..b8d0b7cd4f 100644
--- a/lib/chef/chef_fs/data_handler/data_handler_base.rb
+++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb
@@ -28,10 +28,10 @@ class Chef
# Takes a name like blah.json and removes the .json from it.
#
def remove_dot_json(name)
- if name.length < 5 || name[-5,5] != ".json"
+ if name.length < 5 || name[-5, 5] != ".json"
raise "Invalid name #{path}: must end in .json"
end
- name[0,name.length-5]
+ name[0, name.length - 5]
end
#
@@ -154,11 +154,11 @@ class Chef
if object[key].size > 0
result << key
first = true
- object[key].each_pair do |k,v|
+ object[key].each_pair do |k, v|
if first
first = false
else
- result << " "*key.length
+ result << " " * key.length
end
result << " #{k.inspect} => #{v.inspect}\n"
end
diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb
index 74be64cd84..5beec6dfdd 100644
--- a/lib/chef/chef_fs/file_pattern.rb
+++ b/lib/chef/chef_fs/file_pattern.rb
@@ -74,13 +74,13 @@ class Chef
argument_is_absolute = Chef::ChefFS::PathUtils::is_absolute?(path)
return false if is_absolute != argument_is_absolute
- path = path[1,path.length-1] if argument_is_absolute
+ path = path[1, path.length - 1] if argument_is_absolute
path_parts = Chef::ChefFS::PathUtils::split(path)
# If the pattern is shorter than the path (or same size), children will be larger than the pattern, and will not match.
return false if regexp_parts.length <= path_parts.length && !has_double_star
# If the path doesn't match up to this point, children won't match either.
- return false if path_parts.zip(regexp_parts).any? { |part,regexp| !regexp.nil? && !regexp.match(part) }
+ return false if path_parts.zip(regexp_parts).any? { |part, regexp| !regexp.nil? && !regexp.match(part) }
# Otherwise, it's possible we could match: the path matches to this point, and the pattern is longer than the path.
# TODO There is one edge case where the double star comes after some characters like abc**def--we could check whether the next
# bit of path starts with abc in that case.
@@ -111,7 +111,7 @@ class Chef
#
# This method assumes +could_match_children?(path)+ is +true+.
def exact_child_name_under(path)
- path = path[1,path.length-1] if Chef::ChefFS::PathUtils::is_absolute?(path)
+ path = path[1, path.length - 1] if Chef::ChefFS::PathUtils::is_absolute?(path)
dirs_in_path = Chef::ChefFS::PathUtils::split(path).length
return nil if exact_parts.length <= dirs_in_path
return exact_parts[dirs_in_path]
@@ -151,7 +151,7 @@ class Chef
def match?(path)
argument_is_absolute = Chef::ChefFS::PathUtils::is_absolute?(path)
return false if is_absolute != argument_is_absolute
- path = path[1,path.length-1] if argument_is_absolute
+ path = path[1, path.length - 1] if argument_is_absolute
!!regexp.match(path)
end
@@ -275,15 +275,15 @@ class Chef
exact = nil
regexp << "."
else
- if part[0,1] == '\\' && part.length == 2
+ if part[0, 1] == '\\' && part.length == 2
# backslash escapes are only supported on Unix, and are handled here by leaving the escape on (it means the same thing in a regex)
- exact << part[1,1] if !exact.nil?
- if regexp_escape_characters.include?(part[1,1])
+ exact << part[1, 1] if !exact.nil?
+ if regexp_escape_characters.include?(part[1, 1])
regexp << part
else
- regexp << part[1,1]
+ regexp << part[1, 1]
end
- elsif part[0,1] == "[" && part.length > 1
+ elsif part[0, 1] == "[" && part.length > 1
# [...] happens only on Unix, and is handled here by *not* backslashing (it means the same thing in and out of regex)
exact = nil
regexp << part
diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb
index 6e25623a21..5865dd4b7c 100644
--- a/lib/chef/chef_fs/file_system.rb
+++ b/lib/chef/chef_fs/file_system.rb
@@ -95,9 +95,9 @@ class Chef
#
def self.resolve_path(entry, path)
return entry if path.length == 0
- return resolve_path(entry.root, path) if path[0,1] == "/" && entry.root != entry
- if path[0,1] == "/"
- path = path[1,path.length-1]
+ return resolve_path(entry.root, path) if path[0, 1] == "/" && entry.root != entry
+ if path[0, 1] == "/"
+ path = path[1, path.length - 1]
end
result = entry
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
index feb126f036..a6a062ab3c 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
@@ -58,7 +58,7 @@ class Chef
:files => { :recursive => true },
:resources => { :ruby_only => true, :recursive => true },
:providers => { :ruby_only => true, :recursive => true },
- :root_files => { },
+ :root_files => {},
}
def add_child(child)
@@ -99,7 +99,7 @@ class Chef
parts = segment_file[:path].split("/")
# Get or create the path to the file
container = self
- parts[0,parts.length-1].each do |part|
+ parts[0, parts.length - 1].each do |part|
old_container = container
container = old_container.children.select { |child| part == child.name }.first
if !container
@@ -108,7 +108,7 @@ class Chef
end
end
# Create the file itself
- container.add_child(CookbookFile.new(parts[parts.length-1], container, segment_file))
+ container.add_child(CookbookFile.new(parts[parts.length - 1], container, segment_file))
end
end
@children = @children.sort_by { |c| c.name }
diff --git a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
index 986a04ff4a..37b7af8b5e 100644
--- a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
@@ -37,7 +37,7 @@ class Chef
def write(contents)
desired_invites = minimize_value(Chef::JSONCompat.parse(contents, :create_additions => false))
- actual_invites = _read_json.inject({}) { |h,val| h[val["username"]] = val["id"]; h }
+ actual_invites = _read_json.inject({}) { |h, val| h[val["username"]] = val["id"]; h }
invites = actual_invites.keys
(desired_invites - invites).each do |invite|
begin
diff --git a/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb b/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
index 941c0268cc..d083383a0e 100644
--- a/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
@@ -10,7 +10,7 @@ class Chef
class PolicyRevisionEntry < RestListEntry
# /policies/foo-1.0.0.json -> /policies/foo/revisions/1.0.0
- def api_path(options={})
+ def api_path(options = {})
"#{parent.api_path}/#{policy_name}/revisions/#{revision_id}"
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
index 6791b0cd29..488e9c0ed0 100644
--- a/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
@@ -60,7 +60,6 @@ class Chef
# the server version directly, and can't ask the server for a list of the endpoints it supports.
#
-
#
# Does GET /<api_path>, assumes the result is of the format:
#
diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
index 5af91e3768..5b9252ba03 100644
--- a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
@@ -38,10 +38,10 @@ class Chef
end
def api_child_name
- if name.length < 5 || name[-5,5] != ".json"
+ if name.length < 5 || name[-5, 5] != ".json"
raise "Invalid name #{path}: must end in .json"
end
- name[0,name.length-5]
+ name[0, name.length - 5]
end
def api_path
diff --git a/lib/chef/chef_fs/file_system/memory/memory_file.rb b/lib/chef/chef_fs/file_system/memory/memory_file.rb
index 644273fa9f..7eabc8fcb1 100644
--- a/lib/chef/chef_fs/file_system/memory/memory_file.rb
+++ b/lib/chef/chef_fs/file_system/memory/memory_file.rb
@@ -9,6 +9,7 @@ class Chef
super(name, parent)
@value = value
end
+
def read
return @value
end
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
index 84f665066e..fa6ce9ba9e 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
@@ -59,7 +59,7 @@ class Chef
# Use the copy/diff algorithm to copy it down so we don't destroy
# chefignored data. This is terribly un-thread-safe.
- Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), from_fs, child, nil, {:purge => true})
+ Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), from_fs, child, nil, { :purge => true })
# Write out .uploaded-cookbook-version.json
cookbook_file_path = File.join(file_path, cookbook_name)
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
index 37bd6fa1ac..5f238888d5 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
@@ -60,7 +60,7 @@ class Chef
# [chef_config] - a hash of options that looks suspiciously like the ones
# stored in Chef::Config, containing at least these keys:
# :versioned_cookbooks:: whether to include versions in cookbook names
- def initialize(child_paths, root_paths=[], chef_config=Chef::Config)
+ def initialize(child_paths, root_paths = [], chef_config = Chef::Config)
super("", nil)
@child_paths = child_paths
@root_paths = root_paths
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
index f9a66240eb..5dc74d85da 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
@@ -29,7 +29,7 @@ class Chef
# We need the canonical cookbook name if we are using versioned cookbooks, but we don't
# want to spend a lot of time adding code to the main Chef libraries
canonical_name = canonical_cookbook_name(File.basename(file_path))
- raise "When versioned_cookbooks mode is on, cookbook #{file_path} must match format <cookbook_name>-x.y.z" unless canonical_name
+ raise "When versioned_cookbooks mode is on, cookbook #{file_path} must match format <cookbook_name>-x.y.z" unless canonical_name
# KLUDGE: We shouldn't have to use instance_variable_set
loader.instance_variable_set(:@cookbook_name, canonical_name)
loader.load_cookbooks
diff --git a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
index ac6c85db22..bee017f7a8 100644
--- a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
+++ b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
@@ -44,14 +44,14 @@ class Chef
# Except cookbooks and data bag dirs, all things must be json files
begin
Dir.entries(file_path).sort.
- map { |child_name| make_child_entry(child_name) }.
- select { |child| child && can_have_child?(child.name, child.dir?) }
+ map { |child_name| make_child_entry(child_name) }.
+ select { |child| child && can_have_child?(child.name, child.dir?) }
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
end
end
- def create_child(child_name, file_contents=nil)
+ def create_child(child_name, file_contents = nil)
child = make_child_entry(child_name)
if child.exists?
raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child)
@@ -93,7 +93,7 @@ class Chef
def read
begin
- File.open(file_path, "rb") {|f| f.read}
+ File.open(file_path, "rb") { |f| f.read }
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
end
diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb
index 90d4eddc07..399bf1c434 100644
--- a/lib/chef/chef_fs/knife.rb
+++ b/lib/chef/chef_fs/knife.rb
@@ -111,7 +111,7 @@ class Chef
end
# Use the original path because we can't be sure.
inferred_path = arg
- elsif arg[0,1] == "~"
+ elsif arg[0, 1] == "~"
# Let's be nice and fix it if possible - but warn the user.
ui.warn("A path relative to a user home directory has been provided: #{arg}")
ui.warn("Paths provided need to be rooted at the chef-repo being considered or be relative paths.")
diff --git a/lib/chef/chef_fs/parallelizer.rb b/lib/chef/chef_fs/parallelizer.rb
index 6590431d91..5d05f41e94 100644
--- a/lib/chef/chef_fs/parallelizer.rb
+++ b/lib/chef/chef_fs/parallelizer.rb
@@ -54,7 +54,7 @@ class Chef
def resize(to_threads, wait = true, timeout = nil)
if to_threads < num_threads
- threads_to_stop = @threads[to_threads..num_threads-1]
+ threads_to_stop = @threads[to_threads..num_threads - 1]
@threads = @threads.slice(0, to_threads)
threads_to_stop.each do |thread|
@stop_thread[thread] = true
diff --git a/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb b/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb
index 7321aa0664..6094fab493 100644
--- a/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb
@@ -23,7 +23,7 @@ class Chef
def flatten(value, levels, &block)
if levels != 0 && value.respond_to?(:each) && !value.is_a?(String)
value.each do |child|
- flatten(child, levels.nil? ? levels : levels-1, &block)
+ flatten(child, levels.nil? ? levels : levels - 1, &block)
end
else
block.call(value)
diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
index 60f283eabe..8df6a76e13 100644
--- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
@@ -92,7 +92,7 @@ class Chef
end
end
- def first(n=nil)
+ def first(n = nil)
if n
restricted_copy(@input_enumerable.first(n)).to_a
else
diff --git a/lib/chef/chef_fs/path_utils.rb b/lib/chef/chef_fs/path_utils.rb
index 66dbd4f13b..8ec5c3df78 100644
--- a/lib/chef/chef_fs/path_utils.rb
+++ b/lib/chef/chef_fs/path_utils.rb
@@ -64,6 +64,7 @@ class Chef
def self.is_absolute?(path)
!!(path =~ /^#{regexp_path_separator}/)
end
+
# Given a path which may only be partly real (i.e. /x/y/z when only /x exists,
# or /x/y/*/blah when /x/y/z/blah exists), call File.realpath on the biggest
# part that actually exists. The paths operated on here are not Chef-FS paths.
@@ -114,8 +115,8 @@ class Chef
return nil unless PathUtils.os_path_eq?(candidate_fragment, ancestor)
if ancestor.length == path.length
""
- elsif path[ancestor.length,1] =~ /#{PathUtils.regexp_path_separator}/
- path[ancestor.length+1..-1]
+ elsif path[ancestor.length, 1] =~ /#{PathUtils.regexp_path_separator}/
+ path[ancestor.length + 1..-1]
else
nil
end
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index d5bd7a1928..7d2dcf8057 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -78,6 +78,7 @@ class Chef
def node
run_status.node
end
+
def node=(value)
run_status.node = value
end
@@ -151,7 +152,7 @@ class Chef
# @option args [Array<String>] :specific_recipes A list of recipe file paths
# to load after the run list has been loaded.
#
- def initialize(json_attribs=nil, args={})
+ def initialize(json_attribs = nil, args = {})
@json_attribs = json_attribs || {}
@ohai = Ohai::System.new
@@ -397,10 +398,10 @@ class Chef
# it is fed non-UTF8 data.
#
# @api private
- def rest_clean(client_name=node_name, config=Chef::Config)
+ def rest_clean(client_name = node_name, config = Chef::Config)
@rest_clean ||=
Chef::ServerAPI.new(config[:chef_server_url], client_name: client_name,
- signing_key_filename: config[:client_key], validate_utf8: false)
+ signing_key_filename: config[:client_key], validate_utf8: false)
end
# Resource reporters send event information back to the chef server for
@@ -605,7 +606,7 @@ class Chef
#
# @api private
#
- def register(client_name=node_name, config=Chef::Config)
+ def register(client_name = node_name, config = Chef::Config)
if !config[:client_key]
events.skipping_registration(client_name, config)
Chef::Log.debug("Client key is unspecified - skipping registration")
@@ -620,7 +621,7 @@ class Chef
end
# We now have the client key, and should use it from now on.
@rest = Chef::ServerAPI.new(config[:chef_server_url], client_name: client_name,
- signing_key_filename: config[:client_key])
+ signing_key_filename: config[:client_key])
# force initialization of the rest_clean API object
rest_clean(client_name, config)
register_reporters
@@ -942,7 +943,7 @@ class Chef
# if it's an array, go through it and check each one, raise error at the last one if no files are found
cookbook_paths = Array(Chef::Config[:cookbook_path])
Chef::Log.debug "Loading from cookbook_path: #{cookbook_paths.map { |path| File.expand_path(path) }.join(', ')}"
- if cookbook_paths.all? {|path| empty_directory?(path) }
+ if cookbook_paths.all? { |path| empty_directory?(path) }
msg = "None of the cookbook paths set in Chef::Config[:cookbook_path], #{cookbook_paths.inspect}, contain any cookbooks"
Chef::Log.fatal(msg)
raise Chef::Exceptions::CookbookNotFound, msg
@@ -950,7 +951,6 @@ class Chef
else
Chef::Log.warn("Node #{node_name} has an empty run list.") if run_context.node.run_list.empty?
end
-
end
def has_admin_privileges?
diff --git a/lib/chef/constants.rb b/lib/chef/constants.rb
index b45bc12374..f32c3e6654 100644
--- a/lib/chef/constants.rb
+++ b/lib/chef/constants.rb
@@ -20,6 +20,7 @@ class Chef
def NOT_PASSED.to_s
"NOT_PASSED"
end
+
def NOT_PASSED.inspect
to_s
end
diff --git a/lib/chef/cookbook/chefignore.rb b/lib/chef/cookbook/chefignore.rb
index f0cbf12d4e..71ef53c9e5 100644
--- a/lib/chef/cookbook/chefignore.rb
+++ b/lib/chef/cookbook/chefignore.rb
@@ -40,7 +40,7 @@ class Chef
end
def ignored?(file_name)
- @ignores.any? {|glob| File.fnmatch?(glob, file_name)}
+ @ignores.any? { |glob| File.fnmatch?(glob, file_name) }
end
private
@@ -72,4 +72,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/cookbook/cookbook_collection.rb b/lib/chef/cookbook/cookbook_collection.rb
index a9de718902..81e7bb92b4 100644
--- a/lib/chef/cookbook/cookbook_collection.rb
+++ b/lib/chef/cookbook/cookbook_collection.rb
@@ -33,12 +33,12 @@ class Chef
# The input is a mapping of cookbook name to CookbookVersion objects. We
# simply extract them
- def initialize(cookbook_versions={})
+ def initialize(cookbook_versions = {})
super() do |hash, key|
raise Chef::Exceptions::CookbookNotFound, "Cookbook #{key} not found. " <<
"If you're loading #{key} from another cookbook, make sure you configure the dependency in your metadata"
end
- cookbook_versions.each{ |cookbook_name, cookbook_version| self[cookbook_name] = cookbook_version }
+ cookbook_versions.each { |cookbook_name, cookbook_version| self[cookbook_name] = cookbook_version }
end
# Validates that the cookbook metadata allows it to run on this instance.
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb
index 370a77ecaf..04be8c725c 100644
--- a/lib/chef/cookbook/cookbook_version_loader.rb
+++ b/lib/chef/cookbook/cookbook_version_loader.rb
@@ -32,7 +32,7 @@ class Chef
attr_reader :metadata_error
- def initialize(path, chefignore=nil)
+ def initialize(path, chefignore = nil)
@cookbook_path = File.expand_path( path ) # cookbook_path from which this was loaded
# We keep a list of all cookbook paths that have been merged in
@cookbook_paths = [ cookbook_path ]
diff --git a/lib/chef/cookbook/file_vendor.rb b/lib/chef/cookbook/file_vendor.rb
index 2501d4b8de..f849f79296 100644
--- a/lib/chef/cookbook/file_vendor.rb
+++ b/lib/chef/cookbook/file_vendor.rb
@@ -17,7 +17,6 @@
# limitations under the License.
#
-
class Chef
class Cookbook
# == Chef::Cookbook::FileVendor
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index 8050c4f892..7cc4be9f89 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -65,14 +65,14 @@ class Chef
:replacing, :attributes, :groupings, :recipes, :version,
:source_url, :issues_url, :privacy, :chef_versions, :ohai_versions ]
- VERSION_CONSTRAINTS = {:depends => DEPENDENCIES,
- :recommends => RECOMMENDATIONS,
- :suggests => SUGGESTIONS,
- :conflicts => CONFLICTING,
- :provides => PROVIDING,
- :replaces => REPLACING,
- :chef_version => CHEF_VERSIONS,
- :ohai_version => OHAI_VERSIONS }
+ VERSION_CONSTRAINTS = { :depends => DEPENDENCIES,
+ :recommends => RECOMMENDATIONS,
+ :suggests => SUGGESTIONS,
+ :conflicts => CONFLICTING,
+ :provides => PROVIDING,
+ :replaces => REPLACING,
+ :chef_version => CHEF_VERSIONS,
+ :ohai_version => OHAI_VERSIONS }
include Chef::Mixin::ParamsValidate
include Chef::Mixin::FromFile
@@ -105,7 +105,7 @@ class Chef
# === Returns
# metadata<Chef::Cookbook::Metadata>
def initialize
- @name = nil
+ @name = nil
@description = ""
@long_description = ""
@@ -173,7 +173,7 @@ class Chef
#
# === Returns
# maintainer<String>:: Returns the current maintainer.
- def maintainer(arg=nil)
+ def maintainer(arg = nil)
set_or_return(
:maintainer,
arg,
@@ -188,7 +188,7 @@ class Chef
#
# === Returns
# maintainer_email<String>:: Returns the current maintainer email.
- def maintainer_email(arg=nil)
+ def maintainer_email(arg = nil)
set_or_return(
:maintainer_email,
arg,
@@ -203,7 +203,7 @@ class Chef
#
# === Returns
# license<String>:: Returns the current license
- def license(arg=nil)
+ def license(arg = nil)
set_or_return(
:license,
arg,
@@ -218,7 +218,7 @@ class Chef
#
# === Returns
# description<String>:: Returns the description
- def description(arg=nil)
+ def description(arg = nil)
set_or_return(
:description,
arg,
@@ -233,7 +233,7 @@ class Chef
#
# === Returns
# long_description<String>:: Returns the long description
- def long_description(arg=nil)
+ def long_description(arg = nil)
set_or_return(
:long_description,
arg,
@@ -249,7 +249,7 @@ class Chef
#
# === Returns
# version<String>:: Returns the current version
- def version(arg=nil)
+ def version(arg = nil)
if arg
@version = Chef::Version.new(arg)
end
@@ -264,7 +264,7 @@ class Chef
#
# === Returns
# name<String>:: Returns the current cookbook name.
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(
:name,
arg,
@@ -321,7 +321,7 @@ class Chef
# === Returns
# versions<Array>:: Returns the list of versions for the platform
def recommends(cookbook, *version_args)
- version = new_args_format(:recommends, cookbook, version_args)
+ version = new_args_format(:recommends, cookbook, version_args)
constraint = validate_version_constraint(:recommends, cookbook, version)
@recommendations[cookbook] = constraint.to_s
@recommendations[cookbook]
@@ -622,11 +622,11 @@ class Chef
metadata = new()
VERSION_CONSTRAINTS.each do |dependency_type, hash_key|
if dependency_group = o[hash_key]
- dependency_group.each do |cb_name, constraints|
- if metadata.respond_to?(method_name)
- metadata.public_send(method_name, cb_name, *Array(constraints))
- end
- end
+ dependency_group.each do |cb_name, constraints|
+ if metadata.respond_to?(method_name)
+ metadata.public_send(method_name, cb_name, *Array(constraints))
+ end
+ end
end
end
true
@@ -644,7 +644,7 @@ class Chef
#
# === Returns
# source_url<String>:: Returns the current source URL.
- def source_url(arg=nil)
+ def source_url(arg = nil)
set_or_return(
:source_url,
arg,
@@ -659,7 +659,7 @@ class Chef
#
# === Returns
# issues_url<String>:: Returns the current issues URL.
- def issues_url(arg=nil)
+ def issues_url(arg = nil)
set_or_return(
:issues_url,
arg,
@@ -676,7 +676,7 @@ class Chef
# === Returns
# privacy<TrueClass,FalseClass>:: Whether this cookbook is private or not
#
- def privacy(arg=nil)
+ def privacy(arg = nil)
set_or_return(
:privacy,
arg,
@@ -733,14 +733,14 @@ class Chef
elsif version_constraints.size == 1
version_constraints.first
else
- msg=<<-OBSOLETED
+ msg = <<-OBSOLETED
The dependency specification syntax you are using is no longer valid. You may not
specify more than one version constraint for a particular cookbook.
Consult https://docs.chef.io/config_rb_metadata.html for the updated syntax.
-Called by: #{caller_name} '#{dep_name}', #{version_constraints.map {|vc| vc.inspect}.join(", ")}
+Called by: #{caller_name} '#{dep_name}', #{version_constraints.map { |vc| vc.inspect }.join(", ")}
Called from:
-#{caller[0...5].map {|line| " " + line}.join("\n")}
+#{caller[0...5].map { |line| " " + line }.join("\n")}
OBSOLETED
raise Exceptions::ObsoleteDependencySyntax, msg
end
@@ -751,7 +751,7 @@ OBSOLETED
rescue Chef::Exceptions::InvalidVersionConstraint => e
Log.debug(e)
- msg=<<-INVALID
+ msg = <<-INVALID
The version constraint syntax you are using is not valid. If you recently
upgraded to Chef 0.10.0, be aware that you no may longer use "<<" and ">>" for
'less than' and 'greater than'; use '<' and '>' instead.
@@ -759,7 +759,7 @@ Consult https://docs.chef.io/config_rb_metadata.html for more information.
Called by: #{caller_name} '#{dep_name}', '#{constraint_str}'
Called from:
-#{caller[0...5].map {|line| " " + line}.join("\n")}
+#{caller[0...5].map { |line| " " + line }.join("\n")}
INVALID
raise Exceptions::InvalidVersionConstraint, msg
end
@@ -773,7 +773,7 @@ INVALID
def validate_string_array(arry)
if arry.kind_of?(Array)
arry.each do |choice|
- validate( {:choice => choice}, {:choice => {:kind_of => String}} )
+ validate( { :choice => choice }, { :choice => { :kind_of => String } } )
end
end
end
@@ -783,28 +783,28 @@ INVALID
# Raise an exception if the members of the array do not match the defaults
# === Parameters
# opts<Hash>:: The options hash
- def validate_choice_array(opts)
- if opts[:choice].kind_of?(Array)
- case opts[:type]
- when "string"
- validator = [ String ]
- when "array"
- validator = [ Array ]
- when "hash"
- validator = [ Hash ]
- when "symbol"
- validator = [ Symbol ]
- when "boolean"
- validator = [ TrueClass, FalseClass ]
- when "numeric"
- validator = [ Numeric ]
- end
+ def validate_choice_array(opts)
+ if opts[:choice].kind_of?(Array)
+ case opts[:type]
+ when "string"
+ validator = [ String ]
+ when "array"
+ validator = [ Array ]
+ when "hash"
+ validator = [ Hash ]
+ when "symbol"
+ validator = [ Symbol ]
+ when "boolean"
+ validator = [ TrueClass, FalseClass ]
+ when "numeric"
+ validator = [ Numeric ]
+ end
- opts[:choice].each do |choice|
- validate( {:choice => choice}, {:choice => {:kind_of => validator}} )
- end
+ opts[:choice].each do |choice|
+ validate( { :choice => choice }, { :choice => { :kind_of => validator } } )
end
end
+ end
# For backwards compatibility, remap Boolean values to String
# true is mapped to "required"
diff --git a/lib/chef/cookbook/remote_file_vendor.rb b/lib/chef/cookbook/remote_file_vendor.rb
index d483c54f8f..9155162c4c 100644
--- a/lib/chef/cookbook/remote_file_vendor.rb
+++ b/lib/chef/cookbook/remote_file_vendor.rb
@@ -45,7 +45,7 @@ class Chef
end
raise "No such segment #{segment} in cookbook #{@cookbook_name}" unless @manifest[segment]
- found_manifest_record = @manifest[segment].find {|manifest_record| manifest_record[:path] == filename }
+ found_manifest_record = @manifest[segment].find { |manifest_record| manifest_record[:path] == filename }
raise "No such file #{filename} in #{@cookbook_name}" unless found_manifest_record
cache_filename = File.join("cookbooks", @cookbook_name, found_manifest_record["path"])
diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb
index 9955bae6bb..e8b90a45c3 100644
--- a/lib/chef/cookbook/synchronizer.rb
+++ b/lib/chef/cookbook/synchronizer.rb
@@ -141,7 +141,7 @@ class Chef
# === Returns
# true:: Always returns true
def sync_cookbooks
- Chef::Log.info("Loading cookbooks [#{cookbooks.map {|ckbk| ckbk.name + '@' + ckbk.version}.join(', ')}]")
+ Chef::Log.info("Loading cookbooks [#{cookbooks.map { |ckbk| ckbk.name + '@' + ckbk.version }.join(', ')}]")
Chef::Log.debug("Cookbooks detail: #{cookbooks.inspect}")
clear_obsoleted_cookbooks
@@ -176,7 +176,7 @@ class Chef
# Saves the full_path to the file of the cookbook to be updated
# in the manifest later
def save_full_file_path(file, full_path)
- @cookbook_full_file_paths[file.cookbook] ||= { }
+ @cookbook_full_file_paths[file.cookbook] ||= {}
@cookbook_full_file_paths[file.cookbook][file.segment] ||= [ ]
@cookbook_full_file_paths[file.cookbook][file.segment] << full_path
end
diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb
index d6849584c4..fd7835db96 100644
--- a/lib/chef/cookbook/syntax_check.rb
+++ b/lib/chef/cookbook/syntax_check.rb
@@ -43,7 +43,7 @@ class Chef
# Create a new PersistentSet. Values in the set are persisted by
# creating a file in the +cache_path+ directory.
- def initialize(cache_path=Chef::Config[:syntax_check_cache_path])
+ def initialize(cache_path = Chef::Config[:syntax_check_cache_path])
@cache_path = cache_path
@cache_path_created = false
end
@@ -82,7 +82,7 @@ class Chef
# Creates a new SyntaxCheck given the +cookbook_name+ and a +cookbook_path+.
# If no +cookbook_path+ is given, +Chef::Config.cookbook_path+ is used.
- def self.for_cookbook(cookbook_name, cookbook_path=nil)
+ def self.for_cookbook(cookbook_name, cookbook_path = nil)
cookbook_path ||= Chef::Config.cookbook_path
unless cookbook_path
raise ArgumentError, "Cannot find cookbook #{cookbook_name} unless Chef::Config.cookbook_path is set or an explicit cookbook path is given"
@@ -209,7 +209,7 @@ class Chef
# Debug a syntax error in a template.
def invalid_erb_file(erb_file, error_message)
- file_relative_path = erb_file[/^#{Regexp.escape(cookbook_path+File::Separator)}(.*)/, 1]
+ file_relative_path = erb_file[/^#{Regexp.escape(cookbook_path + File::Separator)}(.*)/, 1]
Chef::Log.fatal("Erb template #{file_relative_path} has a syntax error:")
error_message.each_line { |l| Chef::Log.fatal(l.chomp) }
nil
@@ -244,7 +244,7 @@ class Chef
# Debugs ruby syntax errors by printing the path to the file and any
# diagnostic info given in +error_message+
def invalid_ruby_file(ruby_file, error_message)
- file_relative_path = ruby_file[/^#{Regexp.escape(cookbook_path+File::Separator)}(.*)/, 1]
+ file_relative_path = ruby_file[/^#{Regexp.escape(cookbook_path + File::Separator)}(.*)/, 1]
Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error:")
error_message.each_line { |l| Chef::Log.fatal(l.chomp) }
false
diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb
index 27e0bc5aaa..9bab6f01ce 100644
--- a/lib/chef/cookbook_loader.rb
+++ b/lib/chef/cookbook_loader.rb
@@ -44,7 +44,7 @@ class Chef
@cookbooks_by_name = Mash.new
@loaded_cookbooks = {}
@metadata = Mash.new
- @cookbooks_paths = Hash.new {|h,k| h[k] = []} # for deprecation warnings
+ @cookbooks_paths = Hash.new { |h, k| h[k] = [] } # for deprecation warnings
@chefignores = {}
@repo_paths = repo_paths.map do |repo_path|
repo_path = File.expand_path(repo_path)
@@ -62,7 +62,7 @@ class Chef
def merged_cookbook_paths # for deprecation warnings
merged_cookbook_paths = {}
- @merged_cookbooks.each {|c| merged_cookbook_paths[c] = @cookbooks_paths[c]}
+ @merged_cookbooks.each { |c| merged_cookbook_paths[c] = @cookbooks_paths[c] }
merged_cookbook_paths
end
@@ -119,7 +119,7 @@ class Chef
alias :key? :has_key?
def each
- @cookbooks_by_name.keys.sort { |a,b| a.to_s <=> b.to_s }.each do |cname|
+ @cookbooks_by_name.keys.sort { |a, b| a.to_s <=> b.to_s }.each do |cname|
yield(cname, @cookbooks_by_name[cname])
end
end
diff --git a/lib/chef/cookbook_manifest.rb b/lib/chef/cookbook_manifest.rb
index f3df5c48aa..6e7458aa28 100644
--- a/lib/chef/cookbook_manifest.rb
+++ b/lib/chef/cookbook_manifest.rb
@@ -152,6 +152,7 @@ class Chef
def named_cookbook_url
"#{cookbook_url_path}/#{name}"
end
+
# Adds the `force=true` parameter to the upload URL. This allows
# the user to overwrite a frozen cookbook (a PUT against the
# normal #save_url raises a 409 Conflict in this case).
@@ -169,7 +170,7 @@ class Chef
COOKBOOK_SEGMENTS.each do |segment|
next unless @manifest.has_key?(segment)
- filenames = @manifest[segment].map{|manifest_record| manifest_record["name"]}
+ filenames = @manifest[segment].map { |manifest_record| manifest_record["name"] }
cookbook_version.replace_segment_filenames(segment, filenames)
end
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb
index 6e669f24ba..d6a270b033 100644
--- a/lib/chef/cookbook_site_streaming_uploader.rb
+++ b/lib/chef/cookbook_site_streaming_uploader.rb
@@ -114,14 +114,14 @@ class Chef
# TODO: tim: 2009-12-28: It'd be nice to remove this special case, and
# always hash the entire request body. In the file case it would just be
# expanded multipart text - the entire body of the POST.
- content_body = parts.inject("") { |result,part| result + part.read(0, part.size) }
+ content_body = parts.inject("") { |result, part| result + part.read(0, part.size) }
content_file.rewind if content_file # we consumed the file for the above operation, so rewind it.
signing_options = {
- :http_method=>http_verb,
- :path=>url.path,
- :user_id=>user_id,
- :timestamp=>timestamp}
+ :http_method => http_verb,
+ :path => url.path,
+ :user_id => user_id,
+ :timestamp => timestamp }
(content_file && signing_options[:file] = content_file) || (signing_options[:body] = (content_body || ""))
headers.merge!(Mixlib::Authentication::SignedHeaderAuth.signing_object(signing_options).sign(secret_key))
@@ -129,7 +129,7 @@ class Chef
content_file.rewind if content_file
# net/http doesn't like symbols for header keys, so we'll to_s each one just in case
- headers = DefaultHeaders.merge(Hash[*headers.map{ |k,v| [k.to_s, v] }.flatten])
+ headers = DefaultHeaders.merge(Hash[*headers.map { |k, v| [k.to_s, v] }.flatten])
req = case http_verb
when :put
@@ -201,7 +201,7 @@ class Chef
end
def size
- @parts.inject(0) {|size, part| size + part.size}
+ @parts.inject(0) { |size, part| size + part.size }
end
def read(how_much, dst_buf = nil)
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index a9f255df43..95c27799ec 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -37,7 +37,7 @@ class Chef
# in Chef::Config.
# * :concurrency An integer that decided how many threads will be used to
# perform concurrent uploads
- def initialize(cookbooks, opts={})
+ def initialize(cookbooks, opts = {})
@opts = opts
@cookbooks = Array(cookbooks)
@rest = opts[:rest] || Chef::ServerAPI.new(Chef::Config[:chef_server_url])
@@ -55,7 +55,7 @@ class Chef
checksum_files.merge!(cb.checksums)
end
- checksums = checksum_files.inject({}){|memo,elt| memo[elt.first]=nil ; memo}
+ checksums = checksum_files.inject({}) { |memo, elt| memo[elt.first] = nil ; memo }
new_sandbox = rest.post("sandboxes", { :checksums => checksums })
Chef::Log.info("Uploading files")
@@ -83,7 +83,7 @@ class Chef
# in eventual consistency)
retries = 0
begin
- rest.put(sandbox_url, {:is_completed => true})
+ rest.put(sandbox_url, { :is_completed => true })
rescue Net::HTTPServerException => e
if e.message =~ /^400/ && (retries += 1) <= 5
sleep 2
@@ -120,7 +120,7 @@ class Chef
# but we need the base64 encoding for the content-md5
# header
checksum64 = Base64.encode64([checksum].pack("H*")).strip
- file_contents = File.open(file, "rb") {|f| f.read}
+ file_contents = File.open(file, "rb") { |f| f.read }
# Custom headers. 'content-type' disables JSON serialization of the request body.
headers = { "content-type" => "application/x-binary", "content-md5" => checksum64, "accept" => "application/json" }
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index dc8a93b91e..9ebf705d79 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -300,7 +300,7 @@ class Chef
if segment == :files || segment == :templates
error_message = "Cookbook '#{name}' (#{version}) does not contain a file at any of these locations:\n"
error_locations = if filename.is_a?(Array)
- filename.map{|name| " #{File.join(segment.to_s, name)}"}
+ filename.map { |name| " #{File.join(segment.to_s, name)}" }
else
[
" #{segment}/#{node[:platform]}-#{node[:platform_version]}/#{filename}",
@@ -312,7 +312,7 @@ class Chef
error_message << error_locations.join("\n")
existing_files = segment_filenames(segment)
# Strip the root_dir prefix off all files for readability
- existing_files.map!{|path| path[root_dir.length+1..-1]} if root_dir
+ existing_files.map! { |path| path[root_dir.length + 1..-1] } if root_dir
# Show the files that the cookbook does have. If the user made a typo,
# hopefully they'll see it here.
unless existing_files.empty?
@@ -325,7 +325,7 @@ class Chef
end
end
- def preferred_filename_on_disk_location(node, segment, filename, current_filepath=nil)
+ def preferred_filename_on_disk_location(node, segment, filename, current_filepath = nil)
manifest_record = preferred_manifest_record(node, segment, filename)
if current_filepath && (manifest_record["checksum"] == self.class.checksum_cookbook_file(current_filepath))
nil
@@ -354,7 +354,7 @@ class Chef
# cookbook find them by filespecificity again. but it's the shortest
# path to "success" for now.
if manifest_record_path =~ /(#{Regexp.escape(segment.to_s)}\/[^\/]+\/#{Regexp.escape(dirname)})\/.+$/
- specificity_dirname = $1
+ specificity_dirname = $1
non_specific_path = manifest_record_path[/#{Regexp.escape(segment.to_s)}\/[^\/]+\/#{Regexp.escape(dirname)}\/(.+)$/, 1]
# Record the specificity_dirname only if it's in the list of
# valid preferences
@@ -369,7 +369,6 @@ class Chef
raise Chef::Exceptions::FileNotFound, "cookbook #{name} has no directory #{segment}/default/#{dirname}" unless best_pref
filenames_by_pref[best_pref]
-
end
# Determine the manifest records from the most specific directory
@@ -389,7 +388,7 @@ class Chef
# dirname argument as above, which is what
# preferences_for_path returns. It could be
# "files/ubuntu-9.10/dirname", for example.
- specificity_dirname = $1
+ specificity_dirname = $1
# Record the specificity_dirname only if it's in the list of
# valid preferences
@@ -449,7 +448,7 @@ class Chef
search_path
end
- relative_search_path.map {|relative_path| File.join(segment.to_s, relative_path)}
+ relative_search_path.map { |relative_path| File.join(segment.to_s, relative_path) }
else
if segment.to_sym == :root_files
[path]
@@ -501,7 +500,6 @@ class Chef
rendered_manifest
end
-
def to_hash
# TODO: this should become deprecated when the API for CookbookManifest becomes stable
cookbook_manifest.to_hash
@@ -512,7 +510,6 @@ class Chef
cookbook_manifest.to_json
end
-
def metadata_json_file
File.join(root_paths[0], "metadata.json")
end
@@ -554,7 +551,7 @@ class Chef
self
end
- def self.load(name, version="_latest")
+ def self.load(name, version = "_latest")
version = "_latest" if version == "latest"
from_hash(chef_server_rest.get("cookbooks/#{name}/#{version}"))
end
@@ -610,13 +607,13 @@ class Chef
preferences = preferences_for_path(node, segment, filename)
# in order of prefernce, look for the filename in the manifest
- preferences.find {|preferred_filename| manifest_records_by_path[preferred_filename] }
+ preferences.find { |preferred_filename| manifest_records_by_path[preferred_filename] }
end
# For each filename, produce a mapping of base filename (i.e. recipe name
# or attribute file) to on disk location
def filenames_by_name(filenames)
- filenames.select{|filename| filename =~ /\.rb$/}.inject({}){|memo, filename| memo[File.basename(filename, ".rb")] = filename ; memo }
+ filenames.select { |filename| filename =~ /\.rb$/ }.inject({}) { |memo, filename| memo[File.basename(filename, ".rb")] = filename ; memo }
end
def file_vendor
diff --git a/lib/chef/daemon.rb b/lib/chef/daemon.rb
index 2cf72d7764..242419890c 100644
--- a/lib/chef/daemon.rb
+++ b/lib/chef/daemon.rb
@@ -61,7 +61,7 @@ class Chef
# String::
# Location of the pid file for @name
def pid_file
- Chef::Config[:pid_file] or "/tmp/#{@name}.pid"
+ Chef::Config[:pid_file] or "/tmp/#{@name}.pid"
end
# Suck the pid out of pid_file
@@ -100,7 +100,7 @@ class Chef
# ==== Alternatives
# If group is left out, the user will be used (changing to user:user)
#
- def _change_privilege(user, group=user)
+ def _change_privilege(user, group = user)
uid, gid = Process.euid, Process.egid
begin
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb
index bb598d1fdb..d17dd8dc90 100644
--- a/lib/chef/data_bag.rb
+++ b/lib/chef/data_bag.rb
@@ -48,7 +48,7 @@ class Chef
@chef_server_rest = chef_server_rest
end
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(
:name,
arg,
@@ -90,7 +90,7 @@ class Chef
bag
end
- def self.list(inflate=false)
+ def self.list(inflate = false)
if Chef::Config[:solo]
paths = Array(Chef::Config[:data_bag_path])
names = []
@@ -99,9 +99,9 @@ class Chef
raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{path}' is invalid"
end
- names += Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(path), "*")).map{|f|File.basename(f)}.sort
+ names += Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(path), "*")).map { |f| File.basename(f) }.sort
end
- names.inject({}) {|h, n| h[n] = n; h}
+ names.inject({}) { |h, n| h[n] = n; h }
else
if inflate
# Can't search for all data bags like other objects, fall back to N+1 :(
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index 9c22d31bcd..facaf6815b 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -82,7 +82,7 @@ class Chef
@raw_data = new_data
end
- def data_bag(arg=nil)
+ def data_bag(arg = nil)
set_or_return(
:data_bag,
arg,
@@ -164,12 +164,12 @@ class Chef
end
end
- def destroy(data_bag=self.data_bag(), databag_item=name)
+ def destroy(data_bag = self.data_bag(), databag_item = name)
chef_server_rest.delete("data/#{data_bag}/#{databag_item}")
end
# Save this Data Bag Item via RESTful API
- def save(item_id=@raw_data["id"])
+ def save(item_id = @raw_data["id"])
r = chef_server_rest
begin
if Chef::Config[:why_run]
@@ -192,9 +192,9 @@ class Chef
def ==(other)
other.respond_to?(:to_hash) &&
- other.respond_to?(:data_bag) &&
- (other.to_hash == to_hash) &&
- (other.data_bag.to_s == data_bag.to_s)
+ other.respond_to?(:data_bag) &&
+ (other.to_hash == to_hash) &&
+ (other.data_bag.to_s == data_bag.to_s)
end
# As a string
@@ -207,7 +207,7 @@ class Chef
end
def pretty_print(pretty_printer)
- pretty_printer.pp({"data_bag_item('#{data_bag}', '#{id}')" => self.to_hash})
+ pretty_printer.pp({ "data_bag_item('#{data_bag}', '#{id}')" => self.to_hash })
end
def id
diff --git a/lib/chef/deprecation/provider/cookbook_file.rb b/lib/chef/deprecation/provider/cookbook_file.rb
index 166368df5a..d6e8a7566e 100644
--- a/lib/chef/deprecation/provider/cookbook_file.rb
+++ b/lib/chef/deprecation/provider/cookbook_file.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
class Chef
module Deprecation
module Provider
diff --git a/lib/chef/deprecation/provider/file.rb b/lib/chef/deprecation/provider/file.rb
index f788513b50..4db9101d8d 100644
--- a/lib/chef/deprecation/provider/file.rb
+++ b/lib/chef/deprecation/provider/file.rb
@@ -52,13 +52,13 @@ class Chef
suppress_resource_reporting = false
return [ "(diff output suppressed by config)" ] if Chef::Config[:diff_disabled]
- return [ "(no temp file with new content, diff output suppressed)" ] unless ::File.exists?(temp_path) # should never happen?
+ return [ "(no temp file with new content, diff output suppressed)" ] unless ::File.exists?(temp_path) # should never happen?
# solaris does not support diff -N, so create tempfile to diff against if we are creating a new file
target_path = if ::File.exists?(@current_resource.path)
@current_resource.path
else
- suppress_resource_reporting = true # suppress big diffs going to resource reporting service
+ suppress_resource_reporting = true # suppress big diffs going to resource reporting service
tempfile = Tempfile.new("chef-tempfile")
tempfile.path
end
@@ -119,13 +119,13 @@ class Chef
description << diff_current_from_content(@new_resource.content)
converge_by(description) do
backup @new_resource.path if ::File.exists?(@new_resource.path)
- ::File.open(@new_resource.path, "w") {|f| f.write @new_resource.content }
+ ::File.open(@new_resource.path, "w") { |f| f.write @new_resource.content }
Chef::Log.info("#{@new_resource} contents updated")
end
end
end
- def update_new_file_state(path=@new_resource.path)
+ def update_new_file_state(path = @new_resource.path)
if !::File.directory?(path)
@new_resource.checksum(checksum(path))
end
@@ -163,7 +163,7 @@ class Chef
end
end
- def backup(file=nil)
+ def backup(file = nil)
file ||= @new_resource.path
if @new_resource.backup != false && @new_resource.backup > 0 && ::File.exist?(file)
time = Time.now
@@ -181,7 +181,7 @@ class Chef
# Clean up after the number of backups
slice_number = @new_resource.backup
- backup_files = Dir[Chef::Util::PathHelper.escape_glob(prefix, ".#{@new_resource.path}") + ".chef-*"].sort { |a,b| b <=> a }
+ backup_files = Dir[Chef::Util::PathHelper.escape_glob(prefix, ".#{@new_resource.path}") + ".chef-*"].sort { |a, b| b <=> a }
if backup_files.length >= @new_resource.backup
remainder = backup_files.slice(slice_number..-1)
remainder.each do |backup_to_delete|
diff --git a/lib/chef/deprecation/provider/remote_directory.rb b/lib/chef/deprecation/provider/remote_directory.rb
index f6242a4557..4e28fdc3fa 100644
--- a/lib/chef/deprecation/provider/remote_directory.rb
+++ b/lib/chef/deprecation/provider/remote_directory.rb
@@ -43,7 +43,7 @@ class Chef
end
# Clean all the paths... this is required because of the join
- files.map {|f| Chef::Util::PathHelper.cleanpath(f)}
+ files.map { |f| Chef::Util::PathHelper.cleanpath(f) }
end
end
diff --git a/lib/chef/deprecation/provider/remote_file.rb b/lib/chef/deprecation/provider/remote_file.rb
index a73181e15c..9f115a2565 100644
--- a/lib/chef/deprecation/provider/remote_file.rb
+++ b/lib/chef/deprecation/provider/remote_file.rb
@@ -64,7 +64,7 @@ class Chef
end
def http_client_opts(source)
- opts={}
+ opts = {}
# CHEF-3140
# 1. If it's already compressed, trying to compress it more will
# probably be counter-productive.
diff --git a/lib/chef/dsl/chef_provisioning.rb b/lib/chef/dsl/chef_provisioning.rb
index d2b6aabb17..a91d297d02 100644
--- a/lib/chef/dsl/chef_provisioning.rb
+++ b/lib/chef/dsl/chef_provisioning.rb
@@ -37,7 +37,7 @@ class Chef
with_image_options
with_machine_options
}.each do |method_name|
- eval(<<-EOM, binding, __FILE__, __LINE__+1)
+ eval(<<-EOM, binding, __FILE__, __LINE__ + 1)
def #{method_name}(*args, &block)
Chef::DSL::ChefProvisioning.load_chef_provisioning
self.#{method_name}(*args, &block)
diff --git a/lib/chef/dsl/cheffish.rb b/lib/chef/dsl/cheffish.rb
index 3314ffd4d5..de052bbe5c 100644
--- a/lib/chef/dsl/cheffish.rb
+++ b/lib/chef/dsl/cheffish.rb
@@ -44,7 +44,7 @@ class Chef
with_chef_local_server
get_private_key
}.each do |method_name|
- eval(<<-EOM, binding, __FILE__, __LINE__+1)
+ eval(<<-EOM, binding, __FILE__, __LINE__ + 1)
def #{method_name}(*args, &block)
Chef::DSL::Cheffish.load_cheffish
self.#{method_name}(*args, &block)
diff --git a/lib/chef/dsl/data_query.rb b/lib/chef/dsl/data_query.rb
index 865d914d13..b966885724 100644
--- a/lib/chef/dsl/data_query.rb
+++ b/lib/chef/dsl/data_query.rb
@@ -55,7 +55,7 @@ class Chef
raise
end
- def data_bag_item(bag, item, secret=nil)
+ def data_bag_item(bag, item, secret = nil)
DataBag.validate_name!(bag.to_s)
DataBagItem.validate_id!(item)
@@ -73,7 +73,7 @@ class Chef
raise
end
end
-
+
item
rescue Exception
Log.error("Failed to load data bag item: #{bag.inspect} #{item.inspect}")
diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb
index 91fe62c263..2e7dc934dc 100644
--- a/lib/chef/dsl/declare_resource.rb
+++ b/lib/chef/dsl/declare_resource.rb
@@ -48,7 +48,7 @@ class Chef
# action :delete
# end
#
- def declare_resource(type, name, created_at=nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block)
+ def declare_resource(type, name, created_at = nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block)
created_at ||= caller[0]
if create_if_missing
@@ -86,7 +86,7 @@ class Chef
# action :delete
# end
#
- def build_resource(type, name, created_at=nil, run_context: self.run_context, &resource_attrs_block)
+ def build_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block)
created_at ||= caller[0]
Thread.exclusive do
require "chef/resource_builder" unless defined?(Chef::ResourceBuilder)
@@ -100,7 +100,7 @@ class Chef
run_context: run_context,
cookbook_name: cookbook_name,
recipe_name: recipe_name,
- enclosing_provider: self.is_a?(Chef::Provider) ? self : nil,
+ enclosing_provider: self.is_a?(Chef::Provider) ? self : nil,
).build(&resource_attrs_block)
end
end
diff --git a/lib/chef/dsl/definitions.rb b/lib/chef/dsl/definitions.rb
index 1358f67720..60b1cf6f61 100644
--- a/lib/chef/dsl/definitions.rb
+++ b/lib/chef/dsl/definitions.rb
@@ -9,7 +9,7 @@ class Chef
#
module Definitions
def self.add_definition(dsl_name)
- module_eval <<-EOM, __FILE__, __LINE__+1
+ module_eval <<-EOM, __FILE__, __LINE__ + 1
def #{dsl_name}(*args, &block)
evaluate_resource_definition(#{dsl_name.inspect}, *args, &block)
end
@@ -25,7 +25,6 @@ class Chef
#
# @api private
def evaluate_resource_definition(definition_name, *args, &block)
-
# This dupes the high level object, but we still need to dup the params
new_def = run_context.definitions[definition_name].dup
diff --git a/lib/chef/dsl/include_attribute.rb b/lib/chef/dsl/include_attribute.rb
index b1b9dc4dac..6d27fefc25 100644
--- a/lib/chef/dsl/include_attribute.rb
+++ b/lib/chef/dsl/include_attribute.rb
@@ -59,5 +59,3 @@ end
# **DEPRECATED**
# This used to be part of chef/mixin/language_include_attribute. Load the file to activate the deprecation code.
require "chef/mixin/language_include_attribute"
-
-
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb
index a3a978d418..276a03af63 100644
--- a/lib/chef/dsl/platform_introspection.rb
+++ b/lib/chef/dsl/platform_introspection.rb
@@ -45,7 +45,7 @@ class Chef
# :default => default_value
def initialize(platform_hash)
@values = {}
- platform_hash.each { |platforms, value| set(platforms, value)}
+ platform_hash.each { |platforms, value| set(platforms, value) }
end
def value_for_node(node)
@@ -110,7 +110,7 @@ class Chef
@values["default"] = value
else
assert_valid_platform_values!(platforms, value)
- Array(platforms).each { |platform| @values[platform.to_s] = normalize_keys(value)}
+ Array(platforms).each { |platform| @values[platform.to_s] = normalize_keys(value) }
value
end
end
@@ -134,8 +134,6 @@ class Chef
end
end
-
-
# Given a hash similar to the one we use for Platforms, select a value from the hash. Supports
# per platform defaults, along with a single base default. Arrays may be passed as hash keys and
# will be expanded.
@@ -168,8 +166,6 @@ class Chef
has_platform
end
-
-
# Implementation class for determining platform family dependent values
class PlatformFamilyDependentValue
@@ -193,7 +189,7 @@ class Chef
def initialize(platform_family_hash)
@values = {}
@values["default"] = nil
- platform_family_hash.each { |platform_families, value| set(platform_families, value)}
+ platform_family_hash.each { |platform_families, value| set(platform_families, value) }
end
def value_for_node(node)
@@ -221,7 +217,6 @@ class Chef
end
end
-
# Given a hash mapping platform families to values, select a value from the hash. Supports a single
# base default if platform family is not in the map. Arrays may be passed as hash keys and will be
# expanded
@@ -257,4 +252,3 @@ end
# **DEPRECATED**
# This used to be part of chef/mixin/language. Load the file to activate the deprecation code.
require "chef/mixin/language"
-
diff --git a/lib/chef/dsl/powershell.rb b/lib/chef/dsl/powershell.rb
index ff5fee93a5..1a900af6f6 100644
--- a/lib/chef/dsl/powershell.rb
+++ b/lib/chef/dsl/powershell.rb
@@ -21,7 +21,7 @@ require "chef/util/powershell/ps_credential"
class Chef
module DSL
module Powershell
- def ps_credential(username="placeholder", password)
+ def ps_credential(username = "placeholder", password)
Chef::Util::Powershell::PSCredential.new(username, password)
end
end
diff --git a/lib/chef/dsl/reboot_pending.rb b/lib/chef/dsl/reboot_pending.rb
index c3cf9a9a51..e8982d290e 100644
--- a/lib/chef/dsl/reboot_pending.rb
+++ b/lib/chef/dsl/reboot_pending.rb
@@ -29,7 +29,6 @@ class Chef
# Returns true if the system needs a reboot or is expected to reboot
# Note that we will silently miss any other platform-specific reboot notices besides Windows+Ubuntu.
def reboot_pending?
-
# don't break when used as a mixin in contexts without #node (e.g. specs).
if self.respond_to?(:node, true) && node.run_context.reboot_requested?
true
@@ -42,17 +41,17 @@ class Chef
# RebootRequired key contains Update IDs with a value of 1 if they require a reboot.
# The existence of RebootRequired alone is sufficient on my Windows 8.1 workstation in Windows Update
- registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') ||
+ registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') ||
# Vista + Server 2008 and newer may have reboots pending from CBS
- registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') ||
+ registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') ||
# The mere existence of the UpdateExeVolatile key should indicate a pending restart for certain updates
# http://support.microsoft.com/kb/832475
- Chef::Platform.windows_server_2003? &&
- (registry_key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile') &&
- !registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0].nil? &&
- [1,2,3].include?(registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0][:data]))
+ Chef::Platform.windows_server_2003? &&
+ (registry_key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile') &&
+ !registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0].nil? &&
+ [1, 2, 3].include?(registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0][:data]))
elsif platform?("ubuntu")
# This should work for Debian as well if update-notifier-common happens to be installed. We need an API for that.
File.exists?("/var/run/reboot-required")
diff --git a/lib/chef/dsl/registry_helper.rb b/lib/chef/dsl/registry_helper.rb
index 256b4eca1e..63da635ef1 100644
--- a/lib/chef/dsl/registry_helper.rb
+++ b/lib/chef/dsl/registry_helper.rb
@@ -33,22 +33,27 @@ class Chef
registry = Chef::Win32::Registry.new(run_context, architecture)
registry.key_exists?(key_path)
end
+
def registry_get_values(key_path, architecture = :machine)
registry = Chef::Win32::Registry.new(run_context, architecture)
registry.get_values(key_path)
end
+
def registry_has_subkeys?(key_path, architecture = :machine)
registry = Chef::Win32::Registry.new(run_context, architecture)
registry.has_subkeys?(key_path)
end
+
def registry_get_subkeys(key_path, architecture = :machine)
registry = Chef::Win32::Registry.new(run_context, architecture)
registry.get_subkeys(key_path)
end
+
def registry_value_exists?(key_path, value, architecture = :machine)
registry = Chef::Win32::Registry.new(run_context, architecture)
registry.value_exists?(key_path, value)
end
+
def registry_data_exists?(key_path, value, architecture = :machine)
registry = Chef::Win32::Registry.new(run_context, architecture)
registry.data_exists?(key_path, value)
@@ -56,4 +61,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/dsl/resources.rb b/lib/chef/dsl/resources.rb
index aba602da7e..7bbfeb2914 100644
--- a/lib/chef/dsl/resources.rb
+++ b/lib/chef/dsl/resources.rb
@@ -34,7 +34,7 @@ class Chef
def self.add_resource_dsl(dsl_name)
begin
- module_eval(<<-EOM, __FILE__, __LINE__+1)
+ module_eval(<<-EOM, __FILE__, __LINE__ + 1)
def #{dsl_name}(*args, &block)
Chef.log_deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1
declare_resource(#{dsl_name.inspect}, args[0], caller[0], &block)
@@ -48,8 +48,9 @@ class Chef
end
end
end
+
def self.remove_resource_dsl(dsl_name)
- remove_method(dsl_name)
+ remove_method(dsl_name)
rescue NameError
end
end
diff --git a/lib/chef/encrypted_data_bag_item.rb b/lib/chef/encrypted_data_bag_item.rb
index dc1c00cb27..e696199c63 100644
--- a/lib/chef/encrypted_data_bag_item.rb
+++ b/lib/chef/encrypted_data_bag_item.rb
@@ -125,7 +125,7 @@ class Chef::EncryptedDataBagItem
self.new(raw_hash, secret)
end
- def self.load_secret(path=nil)
+ def self.load_secret(path = nil)
path ||= Chef::Config[:encrypted_data_bag_secret]
if !path
raise ArgumentError, "No secret specified and no secret found at #{Chef::Config.platform_specific_path('/etc/chef/encrypted_data_bag_secret')}"
diff --git a/lib/chef/encrypted_data_bag_item/assertions.rb b/lib/chef/encrypted_data_bag_item/assertions.rb
index bbdcf7a721..8162a9aa54 100644
--- a/lib/chef/encrypted_data_bag_item/assertions.rb
+++ b/lib/chef/encrypted_data_bag_item/assertions.rb
@@ -30,7 +30,7 @@ class Chef::EncryptedDataBagItem
unless format_version.kind_of?(Integer) and format_version >= Chef::Config[:data_bag_decrypt_minimum_version]
raise UnacceptableEncryptedDataBagItemFormat,
"The encrypted data bag item has format version `#{format_version}', " +
- "but the config setting 'data_bag_decrypt_minimum_version' requires version `#{Chef::Config[:data_bag_decrypt_minimum_version]}'"
+ "but the config setting 'data_bag_decrypt_minimum_version' requires version `#{Chef::Config[:data_bag_decrypt_minimum_version]}'"
end
end
diff --git a/lib/chef/encrypted_data_bag_item/encryptor.rb b/lib/chef/encrypted_data_bag_item/encryptor.rb
index 83d5fa47ab..8d34033db6 100644
--- a/lib/chef/encrypted_data_bag_item/encryptor.rb
+++ b/lib/chef/encrypted_data_bag_item/encryptor.rb
@@ -35,7 +35,7 @@ class Chef::EncryptedDataBagItem
# for the desired encrypted data bag format version.
#
# +Chef::Config[:data_bag_encrypt_version]+ determines which version is used.
- def self.new(value, secret, iv=nil)
+ def self.new(value, secret, iv = nil)
format_version = Chef::Config[:data_bag_encrypt_version]
case format_version
when 1
@@ -65,7 +65,7 @@ class Chef::EncryptedDataBagItem
# * iv: The optional +iv+ parameter is intended for testing use only. When
# *not* supplied, Encryptor will use OpenSSL to generate a secure random
# IV, which is what you want.
- def initialize(plaintext_data, key, iv=nil)
+ def initialize(plaintext_data, key, iv = nil)
@plaintext_data = plaintext_data
@key = key
@iv = iv && Base64.decode64(iv)
@@ -162,7 +162,7 @@ class Chef::EncryptedDataBagItem
class Version3Encryptor < Version1Encryptor
include Chef::EncryptedDataBagItem::Assertions
- def initialize(plaintext_data, key, iv=nil)
+ def initialize(plaintext_data, key, iv = nil)
super
assert_aead_requirements_met!(algorithm)
@auth_tag = nil
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb
index 164901c107..aa6d756737 100644
--- a/lib/chef/environment.rb
+++ b/lib/chef/environment.rb
@@ -55,7 +55,7 @@ class Chef
Chef::ServerAPI.new(Chef::Config[:chef_server_url])
end
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(
:name,
arg,
@@ -63,7 +63,7 @@ class Chef
)
end
- def description(arg=nil)
+ def description(arg = nil)
set_or_return(
:description,
arg,
@@ -71,7 +71,7 @@ class Chef
)
end
- def default_attributes(arg=nil)
+ def default_attributes(arg = nil)
set_or_return(
:default_attributes,
arg,
@@ -83,7 +83,7 @@ class Chef
default_attributes(attrs)
end
- def override_attributes(arg=nil)
+ def override_attributes(arg = nil)
set_or_return(
:override_attributes,
arg,
@@ -95,7 +95,7 @@ class Chef
override_attributes(attrs)
end
- def cookbook_versions(arg=nil)
+ def cookbook_versions(arg = nil)
set_or_return(
:cookbook_versions,
arg,
@@ -111,7 +111,7 @@ class Chef
def cookbook(cookbook, version)
validate({
:version => version
- },{
+ }, {
:version => {
:callbacks => { "should be a valid version requirement" => lambda { |v| Chef::Environment.validate_cookbook_version(v) } }
}
@@ -231,7 +231,7 @@ class Chef
environment
end
- def self.list(inflate=false)
+ def self.list(inflate = false)
if inflate
response = Hash.new
Chef::Search::Query.new.search(:environment) do |e|
diff --git a/lib/chef/event_dispatch/base.rb b/lib/chef/event_dispatch/base.rb
index 585a3db174..a6a18718c2 100644
--- a/lib/chef/event_dispatch/base.rb
+++ b/lib/chef/event_dispatch/base.rb
@@ -298,7 +298,7 @@ class Chef
#
# Called before action is executed on a resource.
- def resource_action_start(resource, action, notification_type=nil, notifier=nil)
+ def resource_action_start(resource, action, notification_type = nil, notifier = nil)
end
# Called when a resource action has been skipped b/c of a conditional
@@ -381,7 +381,7 @@ class Chef
end
# Emit a message about something being deprecated.
- def deprecation(message, location=caller(2..2)[0])
+ def deprecation(message, location = caller(2..2)[0])
end
def run_list_expanded(run_list_expansion)
diff --git a/lib/chef/event_dispatch/dispatcher.rb b/lib/chef/event_dispatch/dispatcher.rb
index dae2c3f6b4..69419a393b 100644
--- a/lib/chef/event_dispatch/dispatcher.rb
+++ b/lib/chef/event_dispatch/dispatcher.rb
@@ -54,7 +54,7 @@ class Chef
end
# Special case deprecation, since it needs to know its caller
- def deprecation(message, location=caller(2..2)[0])
+ def deprecation(message, location = caller(2..2)[0])
call_subscribers(:deprecation, message, location)
end
end
diff --git a/lib/chef/event_dispatch/dsl.rb b/lib/chef/event_dispatch/dsl.rb
index d370c37fae..999d536fbe 100644
--- a/lib/chef/event_dispatch/dsl.rb
+++ b/lib/chef/event_dispatch/dsl.rb
@@ -55,6 +55,7 @@ class Chef
end
private
+
def validate!(event_type)
all_event_types = (Chef::EventDispatch::Base.instance_methods - Object.instance_methods)
raise Chef::Exceptions::InvalidEventType, "Invalid event type: #{event_type}" unless all_event_types.include?(event_type)
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index 6fe364a91b..6afcc9c51e 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -33,7 +33,7 @@ class Chef
def self.const_missing(const_name)
if const_name == :ShellCommandFailed
Chef::Log.warn("Chef::Exceptions::ShellCommandFailed is deprecated, use Mixlib::ShellOut::ShellCommandFailed")
- called_from = caller[0..3].inject("Called from:\n") {|msg, trace_line| msg << " #{trace_line}\n" }
+ called_from = caller[0..3].inject("Called from:\n") { |msg, trace_line| msg << " #{trace_line}\n" }
Chef::Log.warn(called_from)
Mixlib::ShellOut::ShellCommandFailed
else
@@ -250,7 +250,7 @@ class Chef
attr_reader :expansion
- def initialize(message_or_expansion=NULL)
+ def initialize(message_or_expansion = NULL)
@expansion = nil
case message_or_expansion
when NULL
@@ -449,7 +449,7 @@ This error is most often caused by network issues (proxies, etc) outside of chef
class RunFailedWrappingError < RuntimeError
attr_reader :wrapped_errors
def initialize(*errors)
- errors = errors.select {|e| !e.nil?}
+ errors = errors.select { |e| !e.nil? }
output = "Found #{errors.size} errors, they are stored in the backtrace"
@wrapped_errors = errors
super output
@@ -457,8 +457,8 @@ This error is most often caused by network issues (proxies, etc) outside of chef
def fill_backtrace
backtrace = []
- wrapped_errors.each_with_index do |e,i|
- backtrace << "#{i+1}) #{e.class} - #{e.message}"
+ wrapped_errors.each_with_index do |e, i|
+ backtrace << "#{i + 1}) #{e.class} - #{e.message}"
backtrace += e.backtrace if e.backtrace
backtrace << "" unless i == wrapped_errors.length - 1
end
diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb
index 9a90048ba6..cb8bf9bd11 100644
--- a/lib/chef/file_cache.rb
+++ b/lib/chef/file_cache.rb
@@ -39,7 +39,7 @@ class Chef
#
# === Returns
# true
- def store(path, contents, perm=0640)
+ def store(path, contents, perm = 0640)
validate(
{
:path => path,
@@ -102,7 +102,7 @@ class Chef
#
# === Raises
# Chef::Exceptions::FileNotFound:: If it cannot find the file in the cache
- def load(path, read=true)
+ def load(path, read = true)
validate(
{
:path => path
@@ -201,7 +201,7 @@ class Chef
#
# === Returns
# String:: The fully expanded path
- def create_cache_path(path, create_if_missing=true)
+ def create_cache_path(path, create_if_missing = true)
cache_dir = File.expand_path(File.join(file_cache_path, path))
if create_if_missing
create_path(cache_dir)
diff --git a/lib/chef/file_content_management/deploy.rb b/lib/chef/file_content_management/deploy.rb
index 67dcbfa424..1e3ae55c21 100644
--- a/lib/chef/file_content_management/deploy.rb
+++ b/lib/chef/file_content_management/deploy.rb
@@ -35,4 +35,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/file_content_management/deploy/mv_unix.rb b/lib/chef/file_content_management/deploy/mv_unix.rb
index 9c265e0a21..3805b3bef3 100644
--- a/lib/chef/file_content_management/deploy/mv_unix.rb
+++ b/lib/chef/file_content_management/deploy/mv_unix.rb
@@ -74,4 +74,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/file_content_management/deploy/mv_windows.rb b/lib/chef/file_content_management/deploy/mv_windows.rb
index b3ef021e76..0e6e6cd76f 100644
--- a/lib/chef/file_content_management/deploy/mv_windows.rb
+++ b/lib/chef/file_content_management/deploy/mv_windows.rb
@@ -96,10 +96,8 @@ class Chef
dst_so.owner = dst_sd.owner
dst_so.set_dacl(apply_dacl, dst_sd.dacl_inherits?) if dacl_present
dst_so.set_sacl(apply_sacl, dst_sd.sacl_inherits?) if sacl_present
-
end
end
end
end
end
-
diff --git a/lib/chef/file_content_management/tempfile.rb b/lib/chef/file_content_management/tempfile.rb
index 522a9fc43c..dbe8a30ab4 100644
--- a/lib/chef/file_content_management/tempfile.rb
+++ b/lib/chef/file_content_management/tempfile.rb
@@ -64,7 +64,7 @@ class Chef
#
def tempfile_basename
basename = ::File.basename(@new_resource.name)
- basename.insert 0, "." unless Chef::Platform.windows? # dotfile if we're not on windows
+ basename.insert 0, "." unless Chef::Platform.windows? # dotfile if we're not on windows
basename
end
diff --git a/lib/chef/formatters/base.rb b/lib/chef/formatters/base.rb
index 3a3e3336cc..b2a8c8099b 100644
--- a/lib/chef/formatters/base.rb
+++ b/lib/chef/formatters/base.rb
@@ -212,7 +212,7 @@ class Chef
file_load_failed(path, exception)
end
- def deprecation(message, location=caller(2..2)[0])
+ def deprecation(message, location = caller(2..2)[0])
Chef::Log.deprecation("#{message} at #{location}")
end
@@ -221,7 +221,6 @@ class Chef
end
end
-
# == NullFormatter
# Formatter that doesn't actually produce any output. You can use this to
# disable the use of output formatters.
diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb
index ab450cdeac..5462241049 100644
--- a/lib/chef/formatters/doc.rb
+++ b/lib/chef/formatters/doc.rb
@@ -240,7 +240,7 @@ class Chef
end
# Called before action is executed on a resource.
- def resource_action_start(resource, action, notification_type=nil, notifier=nil)
+ def resource_action_start(resource, action, notification_type = nil, notifier = nil)
if resource.cookbook_name && resource.recipe_name
resource_recipe = "#{resource.cookbook_name}::#{resource.recipe_name}"
else
@@ -282,7 +282,7 @@ class Chef
# Called when a resource has no converge actions, e.g., it was already correct.
def resource_up_to_date(resource, action)
- @up_to_date_resources+= 1
+ @up_to_date_resources += 1
puts " (up to date)", :stream => resource
unindent
end
@@ -293,7 +293,6 @@ class Chef
end
def output_record(line)
-
end
# Called when a change has been made to a resource. May be called multiple
@@ -369,7 +368,7 @@ class Chef
end
end
- def deprecation(message, location=caller(2..2)[0])
+ def deprecation(message, location = caller(2..2)[0])
if Chef::Config[:treat_deprecation_warnings_as_errors]
super
end
diff --git a/lib/chef/formatters/error_descriptor.rb b/lib/chef/formatters/error_descriptor.rb
index eba1f057d8..0f14e6e783 100644
--- a/lib/chef/formatters/error_descriptor.rb
+++ b/lib/chef/formatters/error_descriptor.rb
@@ -31,7 +31,7 @@ class Chef
end
def section(heading, text)
- @sections << {heading => (text or "")}
+ @sections << { heading => (text or "") }
end
def display(out)
diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
index 0ea313eb92..2415d0f4bb 100644
--- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb
+++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
@@ -26,18 +26,18 @@ class Chef
NETWORK_ERROR_CLASSES = [Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError]
def describe_network_errors(error_description)
- error_description.section("Networking Error:",<<-E)
+ error_description.section("Networking Error:", <<-E)
#{exception.message}
Your chef_server_url may be misconfigured, or the network could be down.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
E
end
def describe_eof_error(error_description)
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Received an EOF on transport socket. This almost always indicates a network
error external to chef-client. Some causes include:
@@ -74,18 +74,18 @@ broken virtual networking code.
def describe_401_error(error_description)
if clock_skew?
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
The request failed because your clock has drifted by more than 15 minutes.
Syncing your clock to an NTP Time source should resolve the issue.
E
else
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
node_name "#{username}"
client_key "#{api_key}"
@@ -97,10 +97,10 @@ E
end
def describe_400_error(error_description)
- error_description.section("Invalid Request Data:",<<-E)
+ error_description.section("Invalid Request Data:", <<-E)
The data in your request was invalid (HTTP 400).
E
- error_description.section("Server Response:",format_rest_error)
+ error_description.section("Server Response:", format_rest_error)
end
def describe_406_error(error_description, response)
@@ -110,7 +110,7 @@ E
min_server_version = version_header["min_version"]
max_server_version = version_header["max_version"]
- error_description.section("Incompatible server API version:",<<-E)
+ error_description.section("Incompatible server API version:", <<-E)
This version of the API that this Chef request specified is not supported by the Chef server you sent this request to.
The server supports a min API version of #{min_server_version} and a max API version of #{max_server_version}.
Chef just made a request with an API version of #{client_api_version}.
@@ -122,18 +122,17 @@ E
end
def describe_500_error(error_description)
- error_description.section("Unknown Server Error:",<<-E)
+ error_description.section("Unknown Server Error:", <<-E)
The server had a fatal error attempting to load the node data.
E
error_description.section("Server Response:", format_rest_error)
end
def describe_503_error(error_description)
- error_description.section("Server Unavailable","The Chef Server is temporarily unavailable")
+ error_description.section("Server Unavailable", "The Chef Server is temporarily unavailable")
error_description.section("Server Response:", format_rest_error)
end
-
# Fallback for unexpected/uncommon http errors
def describe_http_error(error_description)
error_description.section("Unexpected API Request Failure:", format_rest_error)
diff --git a/lib/chef/formatters/error_inspectors/compile_error_inspector.rb b/lib/chef/formatters/error_inspectors/compile_error_inspector.rb
index 589f98ddf2..d5ed69a83d 100644
--- a/lib/chef/formatters/error_inspectors/compile_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/compile_error_inspector.rb
@@ -40,7 +40,7 @@ class Chef
error_description.section(exception.class.name, exception.message)
if found_error_in_cookbooks?
- traceback = filtered_bt.map {|line| " #{line}"}.join("\n")
+ traceback = filtered_bt.map { |line| " #{line}" }.join("\n")
error_description.section("Cookbook Trace:", traceback)
error_description.section("Relevant File Content:", context)
end
@@ -107,22 +107,22 @@ class Chef
def culprit_backtrace_entry
@culprit_backtrace_entry ||= begin
- bt_entry = filtered_bt.first
- Chef::Log.debug("Backtrace entry for compile error: '#{bt_entry}'")
- bt_entry
+ bt_entry = filtered_bt.first
+ Chef::Log.debug("Backtrace entry for compile error: '#{bt_entry}'")
+ bt_entry
end
end
def culprit_line
@culprit_line ||= begin
- line_number = culprit_backtrace_entry[/^(?:.\:)?[^:]+:([\d]+)/,1].to_i
+ line_number = culprit_backtrace_entry[/^(?:.\:)?[^:]+:([\d]+)/, 1].to_i
Chef::Log.debug("Line number of compile error: '#{line_number}'")
line_number
end
end
def culprit_file
- @culprit_file ||= culprit_backtrace_entry[/^((?:.\:)?[^:]+):([\d]+)/,1]
+ @culprit_file ||= culprit_backtrace_entry[/^((?:.\:)?[^:]+):([\d]+)/, 1]
end
def filtered_bt
@@ -136,8 +136,8 @@ class Chef
def backtrace_lines_in_cookbooks
@backtrace_lines_in_cookbooks ||=
begin
- filters = Array(Chef::Config.cookbook_path).map {|p| /^#{Regexp.escape(p)}/i }
- r = exception.backtrace.select {|line| filters.any? {|filter| line =~ filter }}
+ filters = Array(Chef::Config.cookbook_path).map { |p| /^#{Regexp.escape(p)}/i }
+ r = exception.backtrace.select { |line| filters.any? { |filter| line =~ filter } }
Chef::Log.debug("Filtered backtrace of compile error: #{r.join(",")}")
r
end
diff --git a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
index b60b9d91d1..eb1aa629ff 100644
--- a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
@@ -42,7 +42,7 @@ class Chef
when *NETWORK_ERROR_CLASSES
describe_network_errors(error_description)
else
- error_description.section("Unexpected Error:","#{exception.class.name}: #{exception.message}")
+ error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}")
end
end
@@ -56,7 +56,7 @@ class Chef
# TODO: we're rescuing errors from Node.find_or_create
# * could be no write on nodes container
# * could be no read on the node
- error_description.section("Authorization Error",<<-E)
+ error_description.section("Authorization Error", <<-E)
This client is not authorized to read some of the information required to
access its cookbooks (HTTP 403).
@@ -128,7 +128,7 @@ EOM
end
def expanded_run_list_ul
- @expanded_run_list.map {|i| "* #{i}"}.join("\n")
+ @expanded_run_list.map { |i| "* #{i}" }.join("\n")
end
# In my tests, the error from the server is double JSON encoded, but we
@@ -162,7 +162,6 @@ EOM
maybe_json_string
end
-
end
end
end
diff --git a/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb b/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb
index 5ac39d7a83..3bd9b419fa 100644
--- a/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb
@@ -48,7 +48,7 @@ class Chef
when *NETWORK_ERROR_CLASSES
describe_network_errors(error_description)
else
- error_description.section("Unexpected Error:","#{exception.class.name}: #{exception.message}")
+ error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}")
end
end
diff --git a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
index b3196caddb..c52dad4c09 100644
--- a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
@@ -22,7 +22,6 @@ class Chef
module Formatters
module ErrorInspectors
-
# == APIErrorInspector
# Wraps exceptions caused by API calls to the server.
class NodeLoadErrorInspector
@@ -44,11 +43,11 @@ class Chef
when Net::HTTPServerException, Net::HTTPFatalError
humanize_http_exception(error_description)
when Chef::Exceptions::PrivateKeyMissing
- error_description.section("Private Key Not Found:",<<-E)
+ error_description.section("Private Key Not Found:", <<-E)
Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
client_key "#{api_key}"
E
when EOFError
@@ -56,7 +55,7 @@ E
when *NETWORK_ERROR_CLASSES
describe_network_errors(error_description)
else
- error_description.section("Unexpected Error:","#{exception.class.name}: #{exception.message}")
+ error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}")
end
end
@@ -70,12 +69,12 @@ E
# TODO: we're rescuing errors from Node.find_or_create
# * could be no write on nodes container
# * could be no read on the node
- error_description.section("Authorization Error",<<-E)
+ error_description.section("Authorization Error", <<-E)
Your client is not authorized to load the node data (HTTP 403).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Possible Causes:",<<-E)
+ error_description.section("Possible Causes:", <<-E)
* Your client (#{username}) may have misconfigured authorization permissions.
E
when Net::HTTPBadRequest
@@ -98,10 +97,10 @@ E
# one, e.g., PUT http://wrong.url/nodes/node-name becomes a GET after a
# redirect.
def describe_404_error(error_description)
- error_description.section("Resource Not Found:",<<-E)
+ error_description.section("Resource Not Found:", <<-E)
The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
E
end
diff --git a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
index 8c070742f7..c7c1454311 100644
--- a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
@@ -26,25 +26,25 @@ class Chef
when Net::HTTPServerException, Net::HTTPFatalError
humanize_http_exception(error_description)
when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError
- error_description.section("Network Error:",<<-E)
+ error_description.section("Network Error:", <<-E)
There was a network error connecting to the Chef Server:
#{exception.message}
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
If your chef_server_url is correct, your network could be down.
E
when Chef::Exceptions::PrivateKeyMissing
- error_description.section("Private Key Not Found:",<<-E)
+ error_description.section("Private Key Not Found:", <<-E)
Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
validation_key "#{api_key}"
E
when Chef::Exceptions::InvalidRedirect
- error_description.section("Invalid Redirect:",<<-E)
+ error_description.section("Invalid Redirect:", <<-E)
Change your server location in client.rb to the server's FQDN to avoid unwanted redirections.
E
when EOFError
@@ -59,18 +59,18 @@ E
case response
when Net::HTTPUnauthorized
if clock_skew?
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
The request failed because your clock has drifted by more than 15 minutes.
Syncing your clock to an NTP Time source should resolve the issue.
E
else
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
validation_client_name "#{username}"
validation_key "#{api_key}"
@@ -79,34 +79,34 @@ If these settings are correct, your validation_key may be invalid.
E
end
when Net::HTTPForbidden
- error_description.section("Authorization Error:",<<-E)
+ error_description.section("Authorization Error:", <<-E)
Your validation client is not authorized to create the client for this node (HTTP 403).
E
- error_description.section("Possible Causes:",<<-E)
+ error_description.section("Possible Causes:", <<-E)
* There may already be a client named "#{config[:node_name]}"
* Your validation client (#{username}) may have misconfigured authorization permissions.
E
when Net::HTTPBadRequest
- error_description.section("Invalid Request Data:",<<-E)
+ error_description.section("Invalid Request Data:", <<-E)
The data in your request was invalid (HTTP 400).
E
- error_description.section("Server Response:",format_rest_error)
+ error_description.section("Server Response:", format_rest_error)
when Net::HTTPNotFound
- error_description.section("Resource Not Found:",<<-E)
+ error_description.section("Resource Not Found:", <<-E)
The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
E
when Net::HTTPNotAcceptable
describe_406_error(error_description, response)
when Net::HTTPInternalServerError
- error_description.section("Unknown Server Error:",<<-E)
+ error_description.section("Unknown Server Error:", <<-E)
The server had a fatal error attempting to load the node data.
E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
- error_description.section("Server Unavailable","The Chef Server is temporarily unavailable")
+ error_description.section("Server Unavailable", "The Chef Server is temporarily unavailable")
error_description.section("Server Response:", format_rest_error)
else
error_description.section("Unexpected API Request Failure:", format_rest_error)
diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
index 73e2f0c4d3..f5936285be 100644
--- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
@@ -69,7 +69,6 @@ class Chef
relevant_lines = ["# In #{file}\n\n"]
-
current_line = line - 1
current_line = 0 if current_line < 0
nesting = 0
@@ -99,8 +98,8 @@ class Chef
end
def filtered_bt
- filters = Array(Chef::Config.cookbook_path).map {|p| /^#{Regexp.escape(p)}/ }
- exception.backtrace.select {|line| filters.any? {|filter| line =~ filter }}
+ filters = Array(Chef::Config.cookbook_path).map { |p| /^#{Regexp.escape(p)}/ }
+ exception.backtrace.select { |line| filters.any? { |filter| line =~ filter } }
end
private
@@ -112,15 +111,13 @@ class Chef
end
def parse_source
- resource.source_line[/^(([\w]:)?[^:]+):([\d]+)/,1]
+ resource.source_line[/^(([\w]:)?[^:]+):([\d]+)/, 1]
end
def parse_line(source)
- resource.source_line[/^#{Regexp.escape(source)}:([\d]+)/,1].to_i
+ resource.source_line[/^#{Regexp.escape(source)}:([\d]+)/, 1].to_i
end
-
-
end
end
end
diff --git a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
index 08fcdea609..e94b347378 100644
--- a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
@@ -36,7 +36,7 @@ class Chef
def add_explanation(error_description)
case exception
when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError
- error_description.section("Networking Error:",<<-E)
+ error_description.section("Networking Error:", <<-E)
#{exception.message}
Your chef_server_url may be misconfigured, or the network could be down.
@@ -48,13 +48,13 @@ E
when EOFError
describe_eof_error(error_description)
else
- error_description.section("Unexpected Error:","#{exception.class.name}: #{exception.message}")
+ error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}")
end
end
def describe_missing_role(error_description)
error_description.section("Missing Role(s) in Run List:", missing_roles_explained)
- original_run_list = node.run_list.map {|item| "* #{item}"}.join("\n")
+ original_run_list = node.run_list.map { |item| "* #{item}" }.join("\n")
error_description.section("Original Run List", original_run_list)
end
@@ -76,12 +76,12 @@ E
response = exception.response
case response
when Net::HTTPUnauthorized
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
node_name "#{username}"
client_key "#{api_key}"
@@ -92,23 +92,23 @@ E
# TODO: we're rescuing errors from Node.find_or_create
# * could be no write on nodes container
# * could be no read on the node
- error_description.section("Authorization Error",<<-E)
+ error_description.section("Authorization Error", <<-E)
Your client is not authorized to load one or more of your roles (HTTP 403).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Possible Causes:",<<-E)
+ error_description.section("Possible Causes:", <<-E)
* Your client (#{username}) may have misconfigured authorization permissions.
E
when Net::HTTPNotAcceptable
describe_406_error(error_description, response)
when Net::HTTPInternalServerError
- error_description.section("Unknown Server Error:",<<-E)
+ error_description.section("Unknown Server Error:", <<-E)
The server had a fatal error attempting to load a role.
E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
- error_description.section("Server Unavailable","The Chef Server is temporarily unavailable")
+ error_description.section("Server Unavailable", "The Chef Server is temporarily unavailable")
error_description.section("Server Response:", format_rest_error)
else
error_description.section("Unexpected API Request Failure:", format_rest_error)
diff --git a/lib/chef/formatters/minimal.rb b/lib/chef/formatters/minimal.rb
index 94fbfd3818..c8fc504eb0 100644
--- a/lib/chef/formatters/minimal.rb
+++ b/lib/chef/formatters/minimal.rb
@@ -4,7 +4,6 @@ class Chef
module Formatters
-
# == Formatters::Minimal
# Shows the progress of the chef run by printing single characters, and
# displays a summary of updates at the conclusion of the run. For events
@@ -20,11 +19,10 @@ class Chef
attr_reader :updated_resources
attr_reader :updates_by_resource
-
def initialize(out, err)
super
@updated_resources = []
- @updates_by_resource = Hash.new {|h, k| h[k] = []}
+ @updates_by_resource = Hash.new { |h, k| h[k] = [] }
end
# Called at the very start of a Chef Run
@@ -168,7 +166,7 @@ class Chef
end
# Called before action is executed on a resource.
- def resource_action_start(resource, action, notification_type=nil, notifier=nil)
+ def resource_action_start(resource, action, notification_type = nil, notifier = nil)
end
# Called when a resource fails, but will retry.
@@ -233,4 +231,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/guard_interpreter/default_guard_interpreter.rb b/lib/chef/guard_interpreter/default_guard_interpreter.rb
index c125d85ba3..449ca9a316 100644
--- a/lib/chef/guard_interpreter/default_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/default_guard_interpreter.rb
@@ -41,4 +41,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
index 7aa9950207..c21961479c 100644
--- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
@@ -42,9 +42,9 @@ class Chef
# We need to make sure we check for Script first because any resource
# that can get to here is an Execute resource.
if @resource.is_a? Chef::Resource::Script
- block_attributes = @command_opts.merge({:code => @command})
+ block_attributes = @command_opts.merge({ :code => @command })
else
- block_attributes = @command_opts.merge({:command => @command})
+ block_attributes = @command_opts.merge({ :command => @command })
end
# Handles cases like powershell_script where default
@@ -62,7 +62,7 @@ class Chef
protected
- def evaluate_action(action=nil, &block)
+ def evaluate_action(action = nil, &block)
@resource.instance_eval(&block)
run_action = action || @resource.action
@@ -71,7 +71,7 @@ class Chef
# Coerce to an array to be safe. This could happen with a legacy
# resource or something overriding the default_action code in a
# subclass.
- Array(run_action).each {|action_to_run| @resource.run_action(action_to_run) }
+ Array(run_action).each { |action_to_run| @resource.run_action(action_to_run) }
resource_updated = @resource.updated
rescue Mixlib::ShellOut::ShellCommandFailed
resource_updated = nil
diff --git a/lib/chef/handler/json_file.rb b/lib/chef/handler/json_file.rb
index 91bd6e1559..9ba3d70383 100644
--- a/lib/chef/handler/json_file.rb
+++ b/lib/chef/handler/json_file.rb
@@ -25,7 +25,7 @@ class Chef
attr_reader :config
- def initialize(config={})
+ def initialize(config = {})
@config = config
@config[:path] ||= "/var/chef/reports"
@config
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index e4a778611d..0060fb08c7 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -61,7 +61,6 @@ class Chef
end
-
def self.middlewares
@middlewares ||= []
end
@@ -81,7 +80,7 @@ class Chef
# all subsequent requests. For example, when initialized with a base url
# http://localhost:4000, a call to +get+ with 'nodes' will make an
# HTTP GET request to http://localhost:4000/nodes
- def initialize(url, options={})
+ def initialize(url, options = {})
@url = url
@default_headers = options[:headers] || {}
@sign_on_redirect = true
@@ -99,7 +98,7 @@ class Chef
#
# === Parameters
# path:: path part of the request URL
- def head(path, headers={})
+ def head(path, headers = {})
request(:HEAD, path, headers)
end
@@ -107,7 +106,7 @@ class Chef
#
# === Parameters
# path:: The path to GET
- def get(path, headers={})
+ def get(path, headers = {})
request(:GET, path, headers)
end
@@ -115,7 +114,7 @@ class Chef
#
# === Parameters
# path:: path part of the request URL
- def put(path, json, headers={})
+ def put(path, json, headers = {})
request(:PUT, path, headers, json)
end
@@ -123,7 +122,7 @@ class Chef
#
# === Parameters
# path:: path part of the request URL
- def post(path, json, headers={})
+ def post(path, json, headers = {})
request(:POST, path, headers, json)
end
@@ -131,13 +130,13 @@ class Chef
#
# === Parameters
# path:: path part of the request URL
- def delete(path, headers={})
+ def delete(path, headers = {})
request(:DELETE, path, headers)
end
# Makes an HTTP request to +path+ with the given +method+, +headers+, and
# +data+ (if applicable).
- def request(method, path, headers={}, data=false)
+ def request(method, path, headers = {}, data = false)
url = create_url(path)
method, url, headers, data = apply_request_middleware(method, url, headers, data)
@@ -160,7 +159,7 @@ class Chef
#
# If no block is given, the tempfile is returned, which means it's up to
# you to unlink the tempfile when you're done with it.
- def streaming_request(path, headers={}, &block)
+ def streaming_request(path, headers = {}, &block)
url = create_url(path)
response, rest_request, return_value = nil, nil, nil
tempfile = nil
@@ -196,7 +195,7 @@ class Chef
raise
end
- def http_client(base_url=nil)
+ def http_client(base_url = nil)
base_url ||= url
if chef_zero_uri?(base_url)
# PERFORMANCE CRITICAL: *MUST* lazy require here otherwise we load up webrick
@@ -272,7 +271,7 @@ class Chef
if block_given?
request, response = client.request(method, url, body, headers, &response_handler)
else
- request, response = client.request(method, url, body, headers) {|r| r.read_body }
+ request, response = client.request(method, url, body, headers) { |r| r.read_body }
return_value = response.read_body
end
@last_response = response
@@ -284,7 +283,7 @@ class Chef
elsif redirect_location = redirected_to(response)
if [:GET, :HEAD].include?(method)
follow_redirect do
- send_http_request(method, url+redirect_location, headers, body, &response_handler)
+ send_http_request(method, url + redirect_location, headers, body, &response_handler)
end
else
raise Exceptions::InvalidRedirect, "#{method} request was redirected from #{url} to #{redirect_location}. Only GET and HEAD support redirects."
@@ -295,7 +294,6 @@ class Chef
end
end
-
# Wraps an HTTP request with retry logic.
# === Arguments
# url:: URL of the request, used for error messages
@@ -308,7 +306,7 @@ class Chef
# handle HTTP 50X Error
if response.kind_of?(Net::HTTPServerError) && !Chef::Config.local_mode
if http_retry_count - http_attempts + 1 > 0
- sleep_time = 1 + (2 ** http_attempts) + rand(2 ** http_attempts)
+ sleep_time = 1 + (2**http_attempts) + rand(2**http_attempts)
Chef::Log.error("Server returned error #{response.code} for #{url}, retrying #{http_attempts}/#{http_retry_count} in #{sleep_time}s")
sleep(sleep_time)
redo
@@ -384,7 +382,7 @@ class Chef
response["location"]
end
- def build_headers(method, url, headers={}, json_body=false)
+ def build_headers(method, url, headers = {}, json_body = false)
headers = @default_headers.merge(headers)
headers["Content-Length"] = json_body.bytesize.to_s if json_body
headers.merge!(Chef::Config[:custom_http_headers]) if Chef::Config[:custom_http_headers]
@@ -412,7 +410,6 @@ class Chef
raise
end
-
public
############################################################################
diff --git a/lib/chef/http/auth_credentials.rb b/lib/chef/http/auth_credentials.rb
index 3db8b1bfe8..d5dbff3758 100644
--- a/lib/chef/http/auth_credentials.rb
+++ b/lib/chef/http/auth_credentials.rb
@@ -28,7 +28,7 @@ class Chef
class AuthCredentials
attr_reader :client_name, :key
- def initialize(client_name=nil, key=nil)
+ def initialize(client_name = nil, key = nil)
@client_name, @key = client_name, key
end
@@ -36,7 +36,7 @@ class Chef
!!key
end
- def signature_headers(request_params={})
+ def signature_headers(request_params = {})
raise ArgumentError, "Cannot sign the request without a client name, check that :node_name is assigned" if client_name.nil?
Chef::Log.debug("Signing the request as #{client_name}")
@@ -48,8 +48,8 @@ class Chef
host = request_params.delete(:host) || "localhost"
sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(request_params)
- signed = sign_obj.sign(key).merge({:host => host})
- signed.inject({}){|memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1];memo}
+ signed = sign_obj.sign(key).merge({ :host => host })
+ signed.inject({}) { |memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1];memo }
end
end
diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb
index d84f8dde55..970c19cd62 100644
--- a/lib/chef/http/authenticator.rb
+++ b/lib/chef/http/authenticator.rb
@@ -33,7 +33,7 @@ class Chef
attr_accessor :sign_request
- def initialize(opts={})
+ def initialize(opts = {})
@raw_key = nil
@sign_request = true
@signing_key_filename = opts[:signing_key_filename]
@@ -46,8 +46,8 @@ class Chef
end
end
- def handle_request(method, url, headers={}, data=false)
- headers.merge!({"X-Ops-Server-API-Version" => @api_version})
+ def handle_request(method, url, headers = {}, data = false)
+ headers.merge!({ "X-Ops-Server-API-Version" => @api_version })
headers.merge!(authentication_headers(method, url, data, headers)) if sign_requests?
[method, url, headers, data]
end
@@ -90,7 +90,7 @@ class Chef
raise Chef::Exceptions::InvalidPrivateKey, msg
end
- def authentication_headers(method, url, json_body=nil, headers=nil)
+ def authentication_headers(method, url, json_body = nil, headers = nil)
request_params = {
:http_method => method,
:path => url.path,
diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb
index 5f0415996f..9428858cdf 100644
--- a/lib/chef/http/basic_client.rb
+++ b/lib/chef/http/basic_client.rb
@@ -40,7 +40,7 @@ class Chef
# url:: An URI for the remote server.
# === Options:
# ssl_policy:: The SSL Policy to use, defaults to DefaultSSLPolicy
- def initialize(url, opts={})
+ def initialize(url, opts = {})
@url = url
@ssl_policy = opts[:ssl_policy] || DefaultSSLPolicy
@http_client = build_http_client
@@ -54,7 +54,7 @@ class Chef
@url.port
end
- def request(method, url, req_body, base_headers={})
+ def request(method, url, req_body, base_headers = {})
http_request = HTTPRequest.new(method, url, req_body, base_headers).http_request
Chef::Log.debug("Initiating #{method} to #{url}")
Chef::Log.debug("---- HTTP Request Header Data: ----")
@@ -105,12 +105,12 @@ class Chef
# here since we are really just trying to get the string built correctly.
if String === proxy && !proxy.strip.empty?
if proxy.match(/^.*:\/\//)
- proxy = URI.parse(proxy.strip)
+ proxy = URI.parse(proxy.strip)
else
- proxy = URI.parse("#{url.scheme}://#{proxy.strip}")
- end
+ proxy = URI.parse("#{url.scheme}://#{proxy.strip}")
+ end
end
-
+
no_proxy = Chef::Config[:no_proxy] || env["NO_PROXY"] || env["no_proxy"]
excludes = no_proxy.to_s.split(/\s*,\s*/).compact
excludes = excludes.map { |exclude| exclude =~ /:\d+$/ ? exclude : "#{exclude}:*" }
@@ -151,12 +151,12 @@ class Chef
def http_proxy_user(http_proxy)
http_proxy.user || Chef::Config["#{url.scheme}_proxy_user"] ||
- env["#{url.scheme.upcase}_PROXY_USER"] || env["#{url.scheme}_proxy_user"]
+ env["#{url.scheme.upcase}_PROXY_USER"] || env["#{url.scheme}_proxy_user"]
end
def http_proxy_pass(http_proxy)
http_proxy.password || Chef::Config["#{url.scheme}_proxy_pass"] ||
- env["#{url.scheme.upcase}_PROXY_PASS"] || env["#{url.scheme}_proxy_pass"]
+ env["#{url.scheme.upcase}_PROXY_PASS"] || env["#{url.scheme}_proxy_pass"]
end
def configure_ssl(http_client)
diff --git a/lib/chef/http/cookie_manager.rb b/lib/chef/http/cookie_manager.rb
index a99a8f1cd9..18824a8eff 100644
--- a/lib/chef/http/cookie_manager.rb
+++ b/lib/chef/http/cookie_manager.rb
@@ -27,11 +27,11 @@ class Chef
# it, so it's included with Chef::REST
class CookieManager
- def initialize(options={})
+ def initialize(options = {})
@cookies = CookieJar.instance
end
- def handle_request(method, url, headers={}, data=false)
+ def handle_request(method, url, headers = {}, data = false)
@host, @port = url.host, url.port
if @cookies.has_key?("#{@host}:#{@port}")
headers["Cookie"] = @cookies["#{@host}:#{@port}"]
diff --git a/lib/chef/http/decompressor.rb b/lib/chef/http/decompressor.rb
index c9b808861c..1bba4cc492 100644
--- a/lib/chef/http/decompressor.rb
+++ b/lib/chef/http/decompressor.rb
@@ -50,12 +50,12 @@ class Chef
DEFLATE = "deflate".freeze
IDENTITY = "identity".freeze
- def initialize(opts={})
+ def initialize(opts = {})
@disable_gzip = false
handle_options(opts)
end
- def handle_request(method, url, headers={}, data=false)
+ def handle_request(method, url, headers = {}, data = false)
headers[HTTPRequest::ACCEPT_ENCODING] = HTTPRequest::ENCODING_GZIP_DEFLATE unless gzip_disabled?
[method, url, headers, data]
end
@@ -114,7 +114,6 @@ class Chef
end
end
-
# gzip is disabled using the disable_gzip => true option in the
# constructor. When gzip is disabled, no 'Accept-Encoding' header will be
# set, and the response will not be decompressed, no matter what the
@@ -138,7 +137,6 @@ class Chef
end
end
-
end
end
end
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index 1590537f19..a1ef9b9ee2 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -72,7 +72,7 @@ class Chef
attr_reader :method, :url, :headers, :http_client, :http_request
- def initialize(method, url, req_body, base_headers={})
+ def initialize(method, url, req_body, base_headers = {})
@method, @url = method, url
@request_body = nil
build_headers(base_headers)
@@ -145,13 +145,12 @@ class Chef
# for the url scheme (80;443) - Fixes CHEF-5355
host_header = uri_safe_host.dup
host_header << ":#{port}" unless URI_SCHEME_DEFAULT_PORT[@url.scheme] == port.to_i
- @headers["Host"] = host_header unless @headers.keys.any? {|k| k.downcase.to_s == HOST_LOWER }
+ @headers["Host"] = host_header unless @headers.keys.any? { |k| k.downcase.to_s == HOST_LOWER }
@headers
end
-
- def configure_http_request(request_body=nil)
+ def configure_http_request(request_body = nil)
req_path = "#{path}"
req_path << "?#{query}" if query
diff --git a/lib/chef/http/json_input.rb b/lib/chef/http/json_input.rb
index 2fd1501b1d..eaee96d88a 100644
--- a/lib/chef/http/json_input.rb
+++ b/lib/chef/http/json_input.rb
@@ -27,11 +27,11 @@ class Chef
attr_accessor :opts
- def initialize(opts={})
+ def initialize(opts = {})
@opts = opts
end
- def handle_request(method, url, headers={}, data=false)
+ def handle_request(method, url, headers = {}, data = false)
if data && should_encode_as_json?(headers)
headers.delete_if { |key, _value| key.downcase == "content-type" }
headers["Content-Type"] = "application/json"
@@ -64,7 +64,7 @@ class Chef
# ruby/Net::HTTP don't enforce capitalized headers (it normalizes them
# for you before sending the request), so we have to account for all
# the variations we might find
- requested_content_type = headers.find {|k, v| k.downcase == "content-type" }
+ requested_content_type = headers.find { |k, v| k.downcase == "content-type" }
requested_content_type.nil? || requested_content_type.last.include?("json")
end
diff --git a/lib/chef/http/json_output.rb b/lib/chef/http/json_output.rb
index 6814fa1a55..6053c38a56 100644
--- a/lib/chef/http/json_output.rb
+++ b/lib/chef/http/json_output.rb
@@ -29,12 +29,12 @@ class Chef
attr_accessor :raw_output
attr_accessor :inflate_json_class
- def initialize(opts={})
+ def initialize(opts = {})
@raw_output = opts[:raw_output]
@inflate_json_class = opts[:inflate_json_class]
end
- def handle_request(method, url, headers={}, data=false)
+ def handle_request(method, url, headers = {}, data = false)
# Ideally this should always set Accept to application/json, but
# Chef::REST is sometimes used to make non-JSON requests, so it sets
# Accept to the desired value before middlewares get called.
diff --git a/lib/chef/http/json_to_model_output.rb b/lib/chef/http/json_to_model_output.rb
index 99878fe629..12ca1a90aa 100644
--- a/lib/chef/http/json_to_model_output.rb
+++ b/lib/chef/http/json_to_model_output.rb
@@ -25,7 +25,7 @@ class Chef
# possible, and converts it into an appropriate model object if it contains
# a `json_class` key.
class JSONToModelOutput < JSONOutput
- def initialize(opts={})
+ def initialize(opts = {})
opts[:inflate_json_class] = true if !opts.has_key?(:inflate_json_class)
super
end
diff --git a/lib/chef/http/remote_request_id.rb b/lib/chef/http/remote_request_id.rb
index ba6108e063..ef8a18a1e3 100644
--- a/lib/chef/http/remote_request_id.rb
+++ b/lib/chef/http/remote_request_id.rb
@@ -21,11 +21,11 @@ class Chef
class HTTP
class RemoteRequestID
- def initialize(opts={})
+ def initialize(opts = {})
end
- def handle_request(method, url, headers={}, data=false)
- headers.merge!({"X-REMOTE-REQUEST-ID" => Chef::RequestID.instance.request_id})
+ def handle_request(method, url, headers = {}, data = false)
+ headers.merge!({ "X-REMOTE-REQUEST-ID" => Chef::RequestID.instance.request_id })
[method, url, headers, data]
end
diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb
index ef2e8732cc..c8590903f6 100644
--- a/lib/chef/http/socketless_chef_zero_client.rb
+++ b/lib/chef/http/socketless_chef_zero_client.rb
@@ -133,7 +133,7 @@ class Chef
511 => "Network Authentication Required",
}
- STATUS_MESSAGE.values.each {|v| v.freeze }
+ STATUS_MESSAGE.values.each { |v| v.freeze }
STATUS_MESSAGE.freeze
def initialize(base_url)
@@ -195,12 +195,11 @@ class Chef
private
def headers_extracted_from_options
- options.reject {|name, _| KNOWN_OPTIONS.include?(name) }.map { |name, value|
+ options.reject { |name, _| KNOWN_OPTIONS.include?(name) }.map { |name, value|
[name.to_s.split("_").map { |segment| segment.capitalize }.join("-"), value]
}
end
-
end
end
diff --git a/lib/chef/http/validate_content_length.rb b/lib/chef/http/validate_content_length.rb
index c92360adfe..33b6d5a549 100644
--- a/lib/chef/http/validate_content_length.rb
+++ b/lib/chef/http/validate_content_length.rb
@@ -41,10 +41,10 @@ class Chef
end
end
- def initialize(opts={})
+ def initialize(opts = {})
end
- def handle_request(method, url, headers={}, data=false)
+ def handle_request(method, url, headers = {}, data = false)
[method, url, headers, data]
end
diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb
index 79b86a4a37..26d3751897 100644
--- a/lib/chef/json_compat.rb
+++ b/lib/chef/json_compat.rb
@@ -88,7 +88,7 @@ class Chef
mapped_hash
end
when Array
- json_obj.map {|e| map_to_rb_obj(e) }
+ json_obj.map { |e| map_to_rb_obj(e) }
else
json_obj
end
diff --git a/lib/chef/key.rb b/lib/chef/key.rb
index d848eb3738..ef29bd7288 100644
--- a/lib/chef/key.rb
+++ b/lib/chef/key.rb
@@ -75,23 +75,23 @@ class Chef
end
end
- def actor(arg=nil)
+ def actor(arg = nil)
set_or_return(:actor, arg,
:regex => /^[a-z0-9\-_]+$/)
end
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(:name, arg,
:kind_of => String)
end
- def public_key(arg=nil)
+ def public_key(arg = nil)
raise Chef::Exceptions::InvalidKeyAttribute, "you cannot set the public_key if create_key is true" if !arg.nil? && @create_key
set_or_return(:public_key, arg,
:kind_of => String)
end
- def private_key(arg=nil)
+ def private_key(arg = nil)
set_or_return(:private_key, arg,
:kind_of => String)
end
@@ -104,13 +104,13 @@ class Chef
@create_key = nil
end
- def create_key(arg=nil)
+ def create_key(arg = nil)
raise Chef::Exceptions::InvalidKeyAttribute, "you cannot set create_key to true if the public_key field exists" if arg == true && !@public_key.nil?
set_or_return(:create_key, arg,
:kind_of => [TrueClass, FalseClass])
end
- def expiration_date(arg=nil)
+ def expiration_date(arg = nil)
set_or_return(:expiration_date, arg,
:regex => /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|infinity)$/)
end
@@ -148,7 +148,7 @@ class Chef
end
end
- payload = {"name" => @name}
+ payload = { "name" => @name }
payload["public_key"] = @public_key unless @public_key.nil?
payload["create_key"] = @create_key if @create_key
payload["expiration_date"] = @expiration_date unless @expiration_date.nil?
@@ -165,7 +165,7 @@ class Chef
end
# set @name and pass put_name if you wish to update the name of an existing key put_name to @name
- def update(put_name=nil)
+ def update(put_name = nil)
if @name.nil? && put_name.nil?
raise Chef::Exceptions::MissingKeyAttribute, "the name field must be populated or you must pass a name to update when update is called"
end
@@ -227,33 +227,33 @@ class Chef
Chef::Key.from_json(json)
end
- def self.list_by_user(actor, inflate=false)
+ def self.list_by_user(actor, inflate = false)
keys = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys")
self.list(keys, actor, :load_by_user, inflate)
end
- def self.list_by_client(actor, inflate=false)
+ def self.list_by_client(actor, inflate = false)
keys = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys")
self.list(keys, actor, :load_by_client, inflate)
end
def self.load_by_user(actor, key_name)
response = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys/#{key_name}")
- Chef::Key.from_hash(response.merge({"user" => actor}))
+ Chef::Key.from_hash(response.merge({ "user" => actor }))
end
def self.load_by_client(actor, key_name)
response = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys/#{key_name}")
- Chef::Key.from_hash(response.merge({"client" => actor}))
+ Chef::Key.from_hash(response.merge({ "client" => actor }))
end
def self.generate_fingerprint(public_key)
- openssl_key_object = OpenSSL::PKey::RSA.new(public_key)
- data_string = OpenSSL::ASN1::Sequence([
- OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.n),
- OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.e),
- ])
- OpenSSL::Digest::SHA1.hexdigest(data_string.to_der).scan(/../).join(":")
+ openssl_key_object = OpenSSL::PKey::RSA.new(public_key)
+ data_string = OpenSSL::ASN1::Sequence([
+ OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.n),
+ OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.e),
+ ])
+ OpenSSL::Digest::SHA1.hexdigest(data_string.to_der).scan(/../).join(":")
end
private
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 56a23e0dde..164a2cdeda 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -72,7 +72,7 @@ class Chef
@ui ||= Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {})
end
- def self.msg(msg="")
+ def self.msg(msg = "")
ui.msg(msg)
end
@@ -195,7 +195,7 @@ class Chef
# args::: usually ARGV
# options::: A Mixlib::CLI option parser hash. These +options+ are how
# subcommands know about global knife CLI options
- def self.run(args, options={})
+ def self.run(args, options = {})
# Fallback debug logging. Normally the logger isn't configured until we
# read the config, but this means any logging that happens before the
# config file is read may be lost. If the KNIFE_DEBUG variable is set, we
@@ -250,7 +250,7 @@ class Chef
if category_commands = guess_category(args)
list_commands(category_commands)
- elsif missing_plugin = ( OFFICIAL_PLUGINS.find {|plugin| plugin == args[0]} )
+ elsif missing_plugin = ( OFFICIAL_PLUGINS.find { |plugin| plugin == args[0] } )
ui.info("The #{missing_plugin} commands were moved to plugins in Chef 0.10")
ui.info("You can install the plugin with `(sudo) gem install knife-#{missing_plugin}`")
ui.info("Use `chef gem install knife-#{missing_plugin}` instead if using ChefDK")
@@ -261,7 +261,7 @@ class Chef
exit 10
end
- def self.list_commands(preferred_category=nil)
+ def self.list_commands(preferred_category = nil)
category_desc = preferred_category ? preferred_category + " " : ""
msg "Available #{category_desc}subcommands: (for details, knife SUB-COMMAND --help)\n\n"
subcommand_loader.list_commands(preferred_category).sort.each do |category, commands|
@@ -285,7 +285,7 @@ class Chef
# Create a new instance of the current class configured for the given
# arguments and options
- def initialize(argv=[])
+ def initialize(argv = [])
super() # having to call super in initialize is the most annoying anti-pattern :(
@ui = Chef::Knife::UI.new(STDOUT, STDERR, STDIN, config)
@@ -510,7 +510,7 @@ class Chef
response.body
end
- def create_object(object, pretty_name=nil, &block)
+ def create_object(object, pretty_name = nil, &block)
output = edit_data(object)
if Kernel.block_given?
@@ -526,7 +526,7 @@ class Chef
output(output) if config[:print_after]
end
- def delete_object(klass, name, delete_name=nil, &block)
+ def delete_object(klass, name, delete_name = nil, &block)
confirm("Do you really want to delete #{name}")
if Kernel.block_given?
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index a1172aefc9..7982c0f927 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -250,7 +250,7 @@ class Chef
Chef::Config[:knife][:bootstrap_vault_item]
}
- def initialize(argv=[])
+ def initialize(argv = [])
super
@client_builder = Chef::Knife::Bootstrap::ClientBuilder.new(
chef_config: Chef::Config,
@@ -312,8 +312,8 @@ class Chef
bootstrap_files = []
bootstrap_files << File.join(File.dirname(__FILE__), "bootstrap/templates", "#{template}.erb")
bootstrap_files << File.join(Knife.chef_config_dir, "bootstrap", "#{template}.erb") if Chef::Knife.chef_config_dir
- Chef::Util::PathHelper.home(".chef", "bootstrap", "#{template}.erb") {|p| bootstrap_files << p}
- bootstrap_files << Gem.find_files(File.join("chef","knife","bootstrap","#{template}.erb"))
+ Chef::Util::PathHelper.home(".chef", "bootstrap", "#{template}.erb") { |p| bootstrap_files << p }
+ bootstrap_files << Gem.find_files(File.join("chef", "knife", "bootstrap", "#{template}.erb"))
bootstrap_files.flatten!
template_file = Array(bootstrap_files).find do |bootstrap_template|
@@ -367,8 +367,8 @@ class Chef
# chef-vault integration must use the new client-side hawtness, otherwise to use the
# new client-side hawtness, just delete your validation key.
- if chef_vault_handler.doing_chef_vault? ||
- (Chef::Config[:validation_key] && !File.exist?(File.expand_path(Chef::Config[:validation_key])))
+ if chef_vault_handler.doing_chef_vault? ||
+ (Chef::Config[:validation_key] && !File.exist?(File.expand_path(Chef::Config[:validation_key])))
unless config[:chef_node_name]
ui.error("You must pass a node name with -N when bootstrapping with user credentials")
@@ -449,7 +449,7 @@ class Chef
if config[:use_sudo]
sudo_prefix = config[:use_sudo_password] ? "echo '#{config[:ssh_password]}' | sudo -S " : "sudo "
- command = config[:preserve_home] ? "#{sudo_prefix} #{command}" : "#{sudo_prefix} -H #{command}"
+ command = config[:preserve_home] ? "#{sudo_prefix} #{command}" : "#{sudo_prefix} -H #{command}"
end
command
diff --git a/lib/chef/knife/bootstrap/chef_vault_handler.rb b/lib/chef/knife/bootstrap/chef_vault_handler.rb
index ca37cc5544..86eed6a8a6 100644
--- a/lib/chef/knife/bootstrap/chef_vault_handler.rb
+++ b/lib/chef/knife/bootstrap/chef_vault_handler.rb
@@ -136,7 +136,7 @@ class Chef
ChefVault::Item.load(vault, item)
end
- public :load_chef_bootstrap_vault_item # for stubbing
+ public :load_chef_bootstrap_vault_item # for stubbing
# Helper to very lazily require the chef-vault gem
def require_chef_vault!
diff --git a/lib/chef/knife/client_key_create.rb b/lib/chef/knife/client_key_create.rb
index 520798013e..68ad4d16d2 100644
--- a/lib/chef/knife/client_key_create.rb
+++ b/lib/chef/knife/client_key_create.rb
@@ -32,7 +32,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
diff --git a/lib/chef/knife/client_key_delete.rb b/lib/chef/knife/client_key_delete.rb
index 3e27148475..64eae2e27c 100644
--- a/lib/chef/knife/client_key_delete.rb
+++ b/lib/chef/knife/client_key_delete.rb
@@ -31,7 +31,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
diff --git a/lib/chef/knife/client_key_edit.rb b/lib/chef/knife/client_key_edit.rb
index 65657520bb..1dbd3c487b 100644
--- a/lib/chef/knife/client_key_edit.rb
+++ b/lib/chef/knife/client_key_edit.rb
@@ -34,7 +34,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
@@ -77,4 +77,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/client_key_list.rb b/lib/chef/knife/client_key_list.rb
index 01e0fe2b25..194ad42931 100644
--- a/lib/chef/knife/client_key_list.rb
+++ b/lib/chef/knife/client_key_list.rb
@@ -34,7 +34,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
diff --git a/lib/chef/knife/client_key_show.rb b/lib/chef/knife/client_key_show.rb
index 1611631a67..77f9e96c5a 100644
--- a/lib/chef/knife/client_key_show.rb
+++ b/lib/chef/knife/client_key_show.rb
@@ -31,7 +31,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb
index c48ecb7442..e62a9dd05c 100644
--- a/lib/chef/knife/configure.rb
+++ b/lib/chef/knife/configure.rb
@@ -97,7 +97,7 @@ EOH
user_create = Chef::Knife::UserCreate.new
user_create.name_args = [ new_client_name ]
user_create.config[:user_password] = config[:user_password] ||
- ui.ask("Please enter a password for the new user: ") {|q| q.echo = false}
+ ui.ask("Please enter a password for the new user: ") { |q| q.echo = false }
user_create.config[:admin] = true
user_create.config[:file] = new_client_key
user_create.config[:yes] = true
@@ -133,7 +133,7 @@ EOH
def ask_user_for_config
server_name = guess_servername
- @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "https://#{server_name}:443")
+ @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "https://#{server_name}:443")
if config[:initial]
@new_client_name = config[:node_name] || ask_question("Please enter a name for the new user: ", :default => Etc.getlogin)
@admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", :default => "admin")
diff --git a/lib/chef/knife/cookbook_bulk_delete.rb b/lib/chef/knife/cookbook_bulk_delete.rb
index 5ab97dc408..6c2ad5a53f 100644
--- a/lib/chef/knife/cookbook_bulk_delete.rb
+++ b/lib/chef/knife/cookbook_bulk_delete.rb
@@ -58,9 +58,8 @@ class Chef
ui.msg ""
end
-
cookbooks_names.each do |cookbook_name|
- versions = rest.get("cookbooks/#{cookbook_name}")[cookbook_name]["versions"].map {|v| v["version"]}.flatten
+ versions = rest.get("cookbooks/#{cookbook_name}")[cookbook_name]["versions"].map { |v| v["version"] }.flatten
versions.each do |version|
object = rest.delete("cookbooks/#{cookbook_name}/#{version}#{config[:purge] ? "?purge=true" : ""}")
ui.info("Deleted cookbook #{cookbook_name.ljust(25)} [#{version}]")
diff --git a/lib/chef/knife/cookbook_create.rb b/lib/chef/knife/cookbook_create.rb
index 2aeecc6e2a..1e19535fbf 100644
--- a/lib/chef/knife/cookbook_create.rb
+++ b/lib/chef/knife/cookbook_create.rb
@@ -182,11 +182,11 @@ EOH
def create_changelog(dir, cookbook_name)
msg("** Creating CHANGELOG for cookbook: #{cookbook_name}")
- unless File.exists?(File.join(dir,cookbook_name,"CHANGELOG.md"))
- open(File.join(dir, cookbook_name, "CHANGELOG.md"),"w") do |file|
+ unless File.exists?(File.join(dir, cookbook_name, "CHANGELOG.md"))
+ open(File.join(dir, cookbook_name, "CHANGELOG.md"), "w") do |file|
file.puts <<-EOH
#{cookbook_name} CHANGELOG
-#{'='*"#{cookbook_name} CHANGELOG".length}
+#{'=' * "#{cookbook_name} CHANGELOG".length}
This file is used to list changes made in each version of the #{cookbook_name} cookbook.
@@ -271,10 +271,10 @@ e.g.
== License and Authors
Authors: TODO: List authors
EOH
- when "md","mkd","txt"
+ when "md", "mkd", "txt"
file.puts <<-EOH
#{cookbook_name} Cookbook
-#{'='*"#{cookbook_name} Cookbook".length}
+#{'=' * "#{cookbook_name} Cookbook".length}
TODO: Enter the cookbook description here.
e.g.
@@ -345,7 +345,7 @@ EOH
else
file.puts <<-EOH
#{cookbook_name} Cookbook
-#{'='*"#{cookbook_name} Cookbook".length}
+#{'=' * "#{cookbook_name} Cookbook".length}
TODO: Enter the cookbook description here.
e.g.
diff --git a/lib/chef/knife/cookbook_delete.rb b/lib/chef/knife/cookbook_delete.rb
index e6a70d693c..b1bb88b388 100644
--- a/lib/chef/knife/cookbook_delete.rb
+++ b/lib/chef/knife/cookbook_delete.rb
@@ -86,7 +86,7 @@ class Chef
def available_versions
@available_versions ||= rest.get("cookbooks/#{@cookbook_name}").map do |name, url_and_version|
- url_and_version["versions"].map {|url_by_version| url_by_version["version"]}
+ url_and_version["versions"].map { |url_by_version| url_by_version["version"] }
end.flatten
rescue Net::HTTPServerException => e
if e.to_s =~ /^404/
diff --git a/lib/chef/knife/cookbook_download.rb b/lib/chef/knife/cookbook_download.rb
index 8c8f0cc677..741f444093 100644
--- a/lib/chef/knife/cookbook_download.rb
+++ b/lib/chef/knife/cookbook_download.rb
@@ -98,7 +98,6 @@ class Chef
end
def determine_version
-
if available_versions.nil?
nil
elsif available_versions.size == 1
diff --git a/lib/chef/knife/cookbook_show.rb b/lib/chef/knife/cookbook_show.rb
index 1a1ba36825..20013cea4b 100644
--- a/lib/chef/knife/cookbook_show.rb
+++ b/lib/chef/knife/cookbook_show.rb
@@ -96,7 +96,3 @@ class Chef
end
end
end
-
-
-
-
diff --git a/lib/chef/knife/cookbook_site_download.rb b/lib/chef/knife/cookbook_site_download.rb
index 541e60c977..7e4eda015f 100644
--- a/lib/chef/knife/cookbook_site_download.rb
+++ b/lib/chef/knife/cookbook_site_download.rb
@@ -57,6 +57,7 @@ class Chef
end
private
+
def cookbooks_api_url
"https://supermarket.chef.io/api/v1/cookbooks"
end
diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb
index 14be2d750f..9a79cd076a 100644
--- a/lib/chef/knife/cookbook_site_install.rb
+++ b/lib/chef/knife/cookbook_site_install.rb
@@ -142,7 +142,7 @@ class Chef
def extract_cookbook(upstream_file, version)
ui.info("Uncompressing #{@cookbook_name} version #{version}.")
# FIXME: Detect if we have the bad tar from git on Windows: https://github.com/opscode/chef/issues/1753
- extract_command="tar zxvf \"#{convert_path upstream_file}\""
+ extract_command = "tar zxvf \"#{convert_path upstream_file}\""
if Chef::Platform.windows?
extract_command << " --force-local"
end
diff --git a/lib/chef/knife/cookbook_site_list.rb b/lib/chef/knife/cookbook_site_list.rb
index 2c7c5d6df2..abe48bf340 100644
--- a/lib/chef/knife/cookbook_site_list.rb
+++ b/lib/chef/knife/cookbook_site_list.rb
@@ -33,14 +33,14 @@ class Chef
def run
if config[:with_uri]
cookbooks = Hash.new
- get_cookbook_list.each{ |k,v| cookbooks[k] = v["cookbook"] }
+ get_cookbook_list.each { |k, v| cookbooks[k] = v["cookbook"] }
ui.output(format_for_display(cookbooks))
else
ui.msg(ui.list(get_cookbook_list.keys.sort, :columns_down))
end
end
- def get_cookbook_list(items=10, start=0, cookbook_collection={})
+ def get_cookbook_list(items = 10, start = 0, cookbook_collection = {})
cookbooks_url = "https://supermarket.chef.io/api/v1/cookbooks?items=#{items}&start=#{start}"
cr = noauth_rest.get(cookbooks_url)
cr["items"].each do |cookbook|
@@ -56,7 +56,3 @@ class Chef
end
end
end
-
-
-
-
diff --git a/lib/chef/knife/cookbook_site_search.rb b/lib/chef/knife/cookbook_site_search.rb
index 2629761385..ba4b873efc 100644
--- a/lib/chef/knife/cookbook_site_search.rb
+++ b/lib/chef/knife/cookbook_site_search.rb
@@ -28,7 +28,7 @@ class Chef
output(search_cookbook(name_args[0]))
end
- def search_cookbook(query, items=10, start=0, cookbook_collection={})
+ def search_cookbook(query, items = 10, start = 0, cookbook_collection = {})
cookbooks_url = "https://supermarket.chef.io/api/v1/search?q=#{query}&items=#{items}&start=#{start}"
cr = noauth_rest.get(cookbooks_url)
cr["items"].each do |cookbook|
@@ -44,8 +44,3 @@ class Chef
end
end
end
-
-
-
-
-
diff --git a/lib/chef/knife/cookbook_site_share.rb b/lib/chef/knife/cookbook_site_share.rb
index fcb666dbae..fc5517cebc 100644
--- a/lib/chef/knife/cookbook_site_share.rb
+++ b/lib/chef/knife/cookbook_site_share.rb
@@ -103,7 +103,6 @@ class Chef
ui.error("Could not find cookbook #{cookbook_name} in your cookbook path.")
exit(1)
end
-
end
def get_category(cookbook_name)
@@ -125,7 +124,7 @@ class Chef
def do_upload(cookbook_filename, cookbook_category, user_id, user_secret_filename)
uri = "https://supermarket.chef.io/api/v1/cookbooks"
- category_string = Chef::JSONCompat.to_json({ "category"=>cookbook_category })
+ category_string = Chef::JSONCompat.to_json({ "category" => cookbook_category })
http_resp = Chef::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, {
:tarball => File.open(cookbook_filename),
diff --git a/lib/chef/knife/cookbook_site_show.rb b/lib/chef/knife/cookbook_site_show.rb
index 2956ca2879..a6a4c82c85 100644
--- a/lib/chef/knife/cookbook_site_show.rb
+++ b/lib/chef/knife/cookbook_site_show.rb
@@ -37,7 +37,7 @@ class Chef
end
end
- def get_cookbook_list(items=10, start=0, cookbook_collection={})
+ def get_cookbook_list(items = 10, start = 0, cookbook_collection = {})
cookbooks_url = "https://supermarket.chef.io/api/v1/cookbooks?items=#{items}&start=#{start}"
cr = noauth_rest.get(cookbooks_url)
cr["items"].each do |cookbook|
@@ -53,8 +53,3 @@ class Chef
end
end
end
-
-
-
-
-
diff --git a/lib/chef/knife/cookbook_test.rb b/lib/chef/knife/cookbook_test.rb
index f7931e321b..ee42facf5e 100644
--- a/lib/chef/knife/cookbook_test.rb
+++ b/lib/chef/knife/cookbook_test.rb
@@ -76,7 +76,6 @@ class Chef
end
end
-
def test_ruby(syntax_checker)
ui.info("Validating ruby files")
exit(1) unless syntax_checker.validate_ruby_files
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index 9cbd8f09d1..e16e21ae64 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -101,7 +101,7 @@ class Chef
# Get a list of cookbooks and their versions from the server
# to check for the existence of a cookbook's dependencies.
@server_side_cookbooks = Chef::CookbookVersion.list_all_versions
- justify_width = @server_side_cookbooks.map {|name| name.size}.max.to_i + 2
+ justify_width = @server_side_cookbooks.map { |name| name.size }.max.to_i + 2
if config[:all]
cookbook_repo.load_cookbooks
cookbooks_for_upload = []
@@ -145,7 +145,6 @@ class Chef
end
end
-
upload_failures += @name_args.length - @cookbooks_to_upload.length
if upload_failures == 0
@@ -259,7 +258,7 @@ WARNING
info[CHECKSUM].nil? || info[CHECKSUM] !~ MATCH_CHECKSUM
end
unless broken_files.empty?
- broken_filenames = Array(broken_files).map {|path, info| path}
+ broken_filenames = Array(broken_files).map { |path, info| path }
ui.error "The cookbook #{cookbook.name} has one or more broken files"
ui.error "This is probably caused by broken symlinks in the cookbook directory"
ui.error "The broken file(s) are: #{broken_filenames.join(' ')}"
@@ -275,7 +274,7 @@ WARNING
end
unless missing_dependencies.empty?
- missing_cookbook_names = missing_dependencies.map { |cookbook_name, version| "'#{cookbook_name}' version '#{version}'"}
+ missing_cookbook_names = missing_dependencies.map { |cookbook_name, version| "'#{cookbook_name}' version '#{version}'" }
ui.error "Cookbook #{cookbook.name} depends on cookbooks which are not currently"
ui.error "being uploaded and cannot be found on the server."
ui.error "The missing cookbook(s) are: #{missing_cookbook_names.join(', ')}"
@@ -287,7 +286,7 @@ WARNING
if @server_side_cookbooks[cookbook_name].nil?
false
else
- versions = @server_side_cookbooks[cookbook_name]["versions"].collect {|versions| versions["version"]}
+ versions = @server_side_cookbooks[cookbook_name]["versions"].collect { |versions| versions["version"] }
Log.debug "Versions of cookbook '#{cookbook_name}' returned by the server: #{versions.join(", ")}"
@server_side_cookbooks[cookbook_name]["versions"].each do |versions_hash|
if Chef::VersionConstraint.new(version).include?(versions_hash["version"])
diff --git a/lib/chef/knife/core/cookbook_scm_repo.rb b/lib/chef/knife/core/cookbook_scm_repo.rb
index 4779bb5405..e909066b02 100644
--- a/lib/chef/knife/core/cookbook_scm_repo.rb
+++ b/lib/chef/knife/core/cookbook_scm_repo.rb
@@ -31,7 +31,7 @@ class Chef
attr_reader :use_current_branch
attr_reader :ui
- def initialize(repo_path, ui, opts={})
+ def initialize(repo_path, ui, opts = {})
@repo_path = repo_path
@ui = ui
@default_branch = "master"
@@ -119,7 +119,7 @@ class Chef
end
def branch_exists?(branch_name)
- git("branch --no-color").stdout.lines.any? {|l| l =~ /\s#{Regexp.escape(branch_name)}(?:\s|$)/ }
+ git("branch --no-color").stdout.lines.any? { |l| l =~ /\s#{Regexp.escape(branch_name)}(?:\s|$)/ }
end
def get_current_branch()
@@ -157,4 +157,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb
index 2aabf4cf46..6802be29ef 100644
--- a/lib/chef/knife/core/gem_glob_loader.rb
+++ b/lib/chef/knife/core/gem_glob_loader.rb
@@ -50,7 +50,7 @@ class Chef
files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path("../../../knife", __FILE__)), "*.rb")]
subcommand_files = {}
files.each do |knife_file|
- rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/,1]
+ rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
subcommand_files[rel_path] = knife_file
end
subcommand_files
@@ -77,7 +77,7 @@ class Chef
private
- def find_files_latest_gems(glob, check_load_path=true)
+ def find_files_latest_gems(glob, check_load_path = true)
files = []
if check_load_path
@@ -103,7 +103,7 @@ class Chef
def latest_gem_specs
@latest_gem_specs ||= if Gem::Specification.respond_to? :latest_specs
- Gem::Specification.latest_specs(true) # find prerelease gems
+ Gem::Specification.latest_specs(true) # find prerelease gems
else
Gem.source_index.latest_specs(true)
end
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb
index 4ba9a15100..bbe0249b3d 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/lib/chef/knife/core/generic_presenter.rb
@@ -32,7 +32,7 @@ class Chef
option :attribute,
:short => "-a ATTR1 [-a ATTR2]",
:long => "--attribute ATTR1 [--attribute ATTR2] ",
- :proc => lambda {|val| @attrs_to_show << val},
+ :proc => lambda { |val| @attrs_to_show << val },
:description => "Show one or more attributes"
end
end
@@ -133,7 +133,7 @@ class Chef
end
def format_list_for_display(list)
- config[:with_uri] ? list : list.keys.sort { |a,b| a <=> b }
+ config[:with_uri] ? list : list.keys.sort { |a, b| a <=> b }
end
def format_for_display(data)
@@ -142,7 +142,7 @@ class Chef
elsif config[:id_only]
name_or_id_for(data)
elsif config[:environment] && data.respond_to?(:chef_environment)
- {"chef_environment" => data.chef_environment}
+ { "chef_environment" => data.chef_environment }
else
data
end
@@ -162,7 +162,7 @@ class Chef
else
raise ArgumentError, "format_data_subset_for_display requires attribute, run_list, or id_only config option to be set"
end
- {name_or_id_for(data) => subset }
+ { name_or_id_for(data) => subset }
end
def name_or_id_for(data)
@@ -173,7 +173,6 @@ class Chef
config[:attribute] || config[:run_list]
end
-
def extract_nested_value(data, nested_value_spec)
nested_value_spec.split(".").each do |attr|
if data.nil?
@@ -181,7 +180,7 @@ class Chef
# Must check :[] before attr because spec can include
# `keys` - want the key named `keys`, not a list of
# available keys.
- elsif data.respond_to?(:[]) && data.has_key?(attr)
+ elsif data.respond_to?(:[]) && data.has_key?(attr)
data = data[attr]
elsif data.respond_to?(attr.to_sym)
data = data.send(attr.to_sym)
@@ -207,10 +206,10 @@ class Chef
end
else
versions_by_cookbook = item.inject({}) do |collected, ( cookbook, versions )|
- collected[cookbook] = versions["versions"].map {|v| v["version"]}
+ collected[cookbook] = versions["versions"].map { |v| v["version"] }
collected
end
- key_length = versions_by_cookbook.empty? ? 0 : versions_by_cookbook.keys.map {|name| name.size }.max + 2
+ key_length = versions_by_cookbook.empty? ? 0 : versions_by_cookbook.keys.map { |name| name.size }.max + 2
versions_by_cookbook.sort.map do |cookbook, versions|
"#{cookbook.ljust(key_length)} #{versions.join(' ')}"
end
diff --git a/lib/chef/knife/core/hashed_command_loader.rb b/lib/chef/knife/core/hashed_command_loader.rb
index aecf738332..7b6c1c4c08 100644
--- a/lib/chef/knife/core/hashed_command_loader.rb
+++ b/lib/chef/knife/core/hashed_command_loader.rb
@@ -38,7 +38,7 @@ class Chef
find_longest_key(manifest[KEY]["plugins_by_category"], category_words, " ")
end
- def list_commands(pref_category=nil)
+ def list_commands(pref_category = nil)
if pref_category || manifest[KEY]["plugins_by_category"].key?(pref_category)
{ pref_category => manifest[KEY]["plugins_by_category"][pref_category] }
else
diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb
index a5837f268c..cdb664ec33 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/lib/chef/knife/core/node_presenter.rb
@@ -98,7 +98,7 @@ class Chef
# special case ec2 with their split horizon whatsis.
ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress]
- summarized=<<-SUMMARY
+ summarized = <<-SUMMARY
#{ui.color('Node Name:', :bold)} #{ui.color(node.name, :bold)}
SUMMARY
show_policy = !(node.policy_name.nil? && node.policy_group.nil?)
@@ -128,13 +128,13 @@ ROLES
#{key('Tags:')} #{node.tags.join(', ')}
SUMMARY
if config[:medium_output] || config[:long_output]
- summarized +=<<-MORE
+ summarized += <<-MORE
#{key('Attributes:')}
#{text_format(node.normal_attrs)}
MORE
end
if config[:long_output]
- summarized +=<<-MOST
+ summarized += <<-MOST
#{key('Default Attributes:')}
#{text_format(node.default_attrs)}
#{key('Override Attributes:')}
@@ -157,4 +157,3 @@ MOST
end
end
end
-
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index 13bcf5cab2..68c1acf4f1 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -93,7 +93,7 @@ class Chef
# the volume of output is adjusted accordingly. Uses colors if enabled
# in the ui object.
def summarize(list)
- summarized=""
+ summarized = ""
list.each do |data|
node = data
# special case ec2 with their split horizon whatsis.
@@ -130,7 +130,7 @@ class Chef
line_parts << platform
end
- summarized=summarized + line_parts.join(", ") + ".\n"
+ summarized = summarized + line_parts.join(", ") + ".\n"
end
summarized
end
diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb
index 2b8bbc929d..95ab219c80 100644
--- a/lib/chef/knife/core/subcommand_loader.rb
+++ b/lib/chef/knife/core/subcommand_loader.rb
@@ -96,7 +96,7 @@ class Chef
end
def force_load
- @loaded=false
+ @loaded = false
load_commands
end
@@ -128,7 +128,6 @@ class Chef
category_words, " ")
end
-
#
# This is shared between the custom_manifest_loader and the gem_glob_loader
#
@@ -137,7 +136,7 @@ class Chef
files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path("../../../knife", __FILE__)), "*.rb")]
subcommand_files = {}
files.each do |knife_file|
- rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/,1]
+ rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
subcommand_files[rel_path] = knife_file
end
subcommand_files
diff --git a/lib/chef/knife/core/text_formatter.rb b/lib/chef/knife/core/text_formatter.rb
index 006a6fc9cf..8775e2e76f 100644
--- a/lib/chef/knife/core/text_formatter.rb
+++ b/lib/chef/knife/core/text_formatter.rb
@@ -45,7 +45,7 @@ class Chef
buffer = ""
if data.respond_to?(:keys)
- justify_width = data.keys.map {|k| k.to_s.size }.max.to_i + 1
+ justify_width = data.keys.map { |k| k.to_s.size }.max.to_i + 1
data.sort.each do |key, value|
# key: ['value'] should be printed as key: value
if value.kind_of?(Array) && value.size == 1 && is_singleton(value[0])
@@ -68,7 +68,7 @@ class Chef
buffer << text_format(data[index])
# Separate items with newlines if it's an array of hashes or an
# array of arrays
- buffer << "\n" if !is_singleton(data[index]) && index != data.size-1
+ buffer << "\n" if !is_singleton(data[index]) && index != data.size - 1
end
else
buffer << "#{data}\n"
diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb
index f5002c8598..ee92127898 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/lib/chef/knife/core/ui.rb
@@ -137,7 +137,7 @@ class Chef
@presenter.interchange?
end
- def ask_question(question, opts={})
+ def ask_question(question, opts = {})
question = question + "[#{opts[:default]}] " if opts[:default]
if opts[:default] and config[:defaults]
@@ -163,7 +163,6 @@ class Chef
end
end
-
# Hash -> Hash
# Works the same as edit_data but
# returns a hash rather than a JSON string/Fully infated object
@@ -172,7 +171,7 @@ class Chef
Chef::JSONCompat.parse(raw)
end
- def edit_data(data, parse_output=true)
+ def edit_data(data, parse_output = true)
output = Chef::JSONCompat.to_json_pretty(data)
if (!config[:disable_editing])
Tempfile.open([ "knife-edit-", ".json" ]) do |tf|
@@ -226,7 +225,7 @@ class Chef
end
# See confirm method for argument information
- def confirm_without_exit(question, append_instructions=true, default_choice=nil)
+ def confirm_without_exit(question, append_instructions = true, default_choice = nil)
return true if config[:yes]
stdout.print question
@@ -264,7 +263,7 @@ class Chef
# append_instructions => Should print '? (Y/N)' as instructions
# default_choice => Set to true for 'Y', and false for 'N' as default answer
#
- def confirm(question, append_instructions=true, default_choice=nil)
+ def confirm(question, append_instructions = true, default_choice = nil)
unless confirm_without_exit(question, append_instructions, default_choice)
exit 3
end
diff --git a/lib/chef/knife/data_bag_delete.rb b/lib/chef/knife/data_bag_delete.rb
index a3cb008ec0..c1ea2013c8 100644
--- a/lib/chef/knife/data_bag_delete.rb
+++ b/lib/chef/knife/data_bag_delete.rb
@@ -47,5 +47,3 @@ class Chef
end
end
end
-
-
diff --git a/lib/chef/knife/data_bag_edit.rb b/lib/chef/knife/data_bag_edit.rb
index c9ce079a22..ba39207db1 100644
--- a/lib/chef/knife/data_bag_edit.rb
+++ b/lib/chef/knife/data_bag_edit.rb
@@ -72,6 +72,3 @@ class Chef
end
end
end
-
-
-
diff --git a/lib/chef/knife/data_bag_from_file.rb b/lib/chef/knife/data_bag_from_file.rb
index f2cbb1369b..e029ec4b22 100644
--- a/lib/chef/knife/data_bag_from_file.rb
+++ b/lib/chef/knife/data_bag_from_file.rb
@@ -60,6 +60,7 @@ class Chef
end
private
+
def data_bags_path
@data_bag_path ||= "data_bags"
end
diff --git a/lib/chef/knife/data_bag_list.rb b/lib/chef/knife/data_bag_list.rb
index a2b700f186..d507925ec8 100644
--- a/lib/chef/knife/data_bag_list.rb
+++ b/lib/chef/knife/data_bag_list.rb
@@ -40,7 +40,3 @@ class Chef
end
end
end
-
-
-
-
diff --git a/lib/chef/knife/delete.rb b/lib/chef/knife/delete.rb
index aeb4744873..d5d4a4c4bd 100644
--- a/lib/chef/knife/delete.rb
+++ b/lib/chef/knife/delete.rb
@@ -105,4 +105,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/deps.rb b/lib/chef/knife/deps.rb
index 0be83a8bf1..99a24e405b 100644
--- a/lib/chef/knife/deps.rb
+++ b/lib/chef/knife/deps.rb
@@ -61,12 +61,12 @@ class Chef
def print_dependencies_tree(entry, dependencies, printed = {}, depth = 0)
dependencies[entry.path] = get_dependencies(entry) if !dependencies[entry.path]
- output "#{' '*depth}#{format_path(entry)}"
+ output "#{' ' * depth}#{format_path(entry)}"
if !printed[entry.path] && (config[:recurse] || depth == 0)
printed[entry.path] = true
dependencies[entry.path].each do |child|
child_entry = Chef::ChefFS::FileSystem.resolve_path(@root, child)
- print_dependencies_tree(child_entry, dependencies, printed, depth+1)
+ print_dependencies_tree(child_entry, dependencies, printed, depth + 1)
end
end
end
@@ -96,7 +96,7 @@ class Chef
end
end
if role["env_run_lists"]
- role["env_run_lists"].each_pair do |env,run_list|
+ role["env_run_lists"].each_pair do |env, run_list|
dependencies_from_runlist(run_list).each do |dependency|
result << dependency if !result.include?(dependency)
end
diff --git a/lib/chef/knife/diff.rb b/lib/chef/knife/diff.rb
index 580e9e513f..d965490f0a 100644
--- a/lib/chef/knife/diff.rb
+++ b/lib/chef/knife/diff.rb
@@ -66,4 +66,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/download.rb b/lib/chef/knife/download.rb
index f2af0e0152..c609760509 100644
--- a/lib/chef/knife/download.rb
+++ b/lib/chef/knife/download.rb
@@ -66,4 +66,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/edit.rb b/lib/chef/knife/edit.rb
index 608ce82a8f..00358b2d09 100644
--- a/lib/chef/knife/edit.rb
+++ b/lib/chef/knife/edit.rb
@@ -70,4 +70,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/environment_compare.rb b/lib/chef/knife/environment_compare.rb
index 1a3389e2c8..8a2ef853d3 100644
--- a/lib/chef/knife/environment_compare.rb
+++ b/lib/chef/knife/environment_compare.rb
@@ -15,37 +15,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
+
require "chef/knife"
-
+
class Chef
class Knife
class EnvironmentCompare < Knife
-
+
deps do
require "chef/environment"
end
-
+
banner "knife environment compare [ENVIRONMENT..] (options)"
option :all,
:short => "-a",
:long => "--all",
:description => "Show all cookbooks",
- :boolean => true
+ :boolean => true
option :mismatch,
:short => "-m",
:long => "--mismatch",
:description => "Only show mismatching versions",
:boolean => true
-
+
def run
# Get the commandline environments or all if none are provided.
- environments = environment_list
+ environments = environment_list
# Get a list of all cookbooks that have constraints and their environment.
- constraints = constraint_list(environments)
+ constraints = constraint_list(environments)
# Get the total list of cookbooks that have constraints
cookbooks = cookbook_list(constraints)
@@ -55,7 +55,7 @@ class Chef
ui.error "Cannot find any environment cookbook constraints"
exit 1
end
-
+
# Get all cookbooks so we can compare them all
cookbooks = rest.get("/cookbooks?num_versions=1") if config[:all]
@@ -77,11 +77,11 @@ class Chef
else
environments = Chef::Environment.list
end
- end
+ end
def constraint_list(environments)
constraints = {}
- environments.each do |env,url|
+ environments.each do |env, url|
# Because you cannot modify the default environment I filter it out here.
unless env == "_default"
envdata = Chef::Environment.load(env)
@@ -91,22 +91,22 @@ class Chef
end
constraints
end
-
+
def cookbook_list(constraints)
result = {}
constraints.each { |env, cb| result.merge!(cb) }
result
- end
+ end
def matrix_output(cookbooks, constraints)
rows = [ "" ]
environments = []
- constraints.each { |e,v| environments << e.to_s }
+ constraints.each { |e, v| environments << e.to_s }
columns = environments.count + 1
environments.each { |env| rows << ui.color(env, :bold) }
- cookbooks.each do |c,v|
+ cookbooks.each do |c, v|
total = []
- environments.each { |n| total << constraints[n][c]}
+ environments.each { |n| total << constraints[n][c] }
if total.uniq.count == 1
next if config[:mismatch]
color = :white
@@ -116,7 +116,7 @@ class Chef
rows << ui.color(c, :bold)
environments.each do |e|
tag = constraints[e][c] || "latest"
- rows << ui.color(tag, color)
+ rows << ui.color(tag, color)
end
end
ui.list(rows, :uneven_columns_across, columns)
diff --git a/lib/chef/knife/environment_from_file.rb b/lib/chef/knife/environment_from_file.rb
index 4640632b32..5272c8934a 100644
--- a/lib/chef/knife/environment_from_file.rb
+++ b/lib/chef/knife/environment_from_file.rb
@@ -62,7 +62,6 @@ class Chef
ui.info("Updated Environment #{updated.name}")
end
-
def run
if config[:all] == true
load_all_environments
diff --git a/lib/chef/knife/help.rb b/lib/chef/knife/help.rb
index f4221f233a..e45b54eec8 100644
--- a/lib/chef/knife/help.rb
+++ b/lib/chef/knife/help.rb
@@ -43,8 +43,6 @@ MOAR_HELP
@query = name_args.join("-")
end
-
-
case @query
when "topics", "list"
print_help_topics
@@ -67,7 +65,7 @@ MOAR_HELP
def print_help_topics
ui.info "Available help topics are: "
- help_topics.collect {|t| t.gsub(/knife-/, "") }.sort.each do |topic|
+ help_topics.collect { |t| t.gsub(/knife-/, "") }.sort.each do |topic|
ui.msg " #{topic}"
end
end
diff --git a/lib/chef/knife/index_rebuild.rb b/lib/chef/knife/index_rebuild.rb
index c317d767b5..eb85b8d7be 100644
--- a/lib/chef/knife/index_rebuild.rb
+++ b/lib/chef/knife/index_rebuild.rb
@@ -40,7 +40,6 @@ class Chef
nag
output rest.post("/search/reindex", {})
end
-
end
def grab_api_info
diff --git a/lib/chef/knife/key_create.rb b/lib/chef/knife/key_create.rb
index 9288fd91e8..55c4f4ef36 100644
--- a/lib/chef/knife/key_create.rb
+++ b/lib/chef/knife/key_create.rb
@@ -40,7 +40,7 @@ class Chef
end
def public_key_or_key_name_error_msg
-<<EOS
+ <<EOS
You must pass either --public-key or --key-name, or both.
If you only pass --public-key, a key name will be generated from the fingerprint of your key.
If you only pass --key-name, a key pair will be generated by the server.
diff --git a/lib/chef/knife/key_edit.rb b/lib/chef/knife/key_edit.rb
index 8bc9ad21b8..cd54e61cb6 100644
--- a/lib/chef/knife/key_edit.rb
+++ b/lib/chef/knife/key_edit.rb
@@ -41,7 +41,7 @@ class Chef
end
def public_key_and_create_key_error_msg
-<<EOS
+ <<EOS
You passed both --public-key and --create-key. Only pass one, or the other, or neither.
Do not pass either if you do not want to change the public_key field of your key.
Pass --public-key if you want to update the public_key field of your key from a specific public key.
diff --git a/lib/chef/knife/key_list.rb b/lib/chef/knife/key_list.rb
index a6320b1603..9a820b7a50 100644
--- a/lib/chef/knife/key_list.rb
+++ b/lib/chef/knife/key_list.rb
@@ -40,7 +40,7 @@ class Chef
end
def expired_and_non_expired_msg
-<<EOS
+ <<EOS
You cannot pass both --only-expired and --only-non-expired.
Please pass one or none.
EOS
diff --git a/lib/chef/knife/node_bulk_delete.rb b/lib/chef/knife/node_bulk_delete.rb
index 8c0529db2c..2ca63da512 100644
--- a/lib/chef/knife/node_bulk_delete.rb
+++ b/lib/chef/knife/node_bulk_delete.rb
@@ -35,7 +35,6 @@ class Chef
exit 42
end
-
nodes_to_delete = {}
matcher = /#{name_args[0]}/
@@ -55,7 +54,6 @@ class Chef
ui.msg("")
ui.confirm("Are you sure you want to delete these nodes")
-
nodes_to_delete.sort.each do |name, node|
node.destroy
ui.msg("Deleted node #{name}")
@@ -66,7 +64,7 @@ class Chef
node_uris_by_name = Chef::Node.list
node_uris_by_name.keys.inject({}) do |nodes_by_name, name|
- nodes_by_name[name] = Chef::Node.new.tap {|n| n.name(name)}
+ nodes_by_name[name] = Chef::Node.new.tap { |n| n.name(name) }
nodes_by_name
end
end
@@ -74,7 +72,3 @@ class Chef
end
end
end
-
-
-
-
diff --git a/lib/chef/knife/node_create.rb b/lib/chef/knife/node_create.rb
index bcbb00e363..21d67f1355 100644
--- a/lib/chef/knife/node_create.rb
+++ b/lib/chef/knife/node_create.rb
@@ -45,6 +45,3 @@ class Chef
end
end
end
-
-
-
diff --git a/lib/chef/knife/node_delete.rb b/lib/chef/knife/node_delete.rb
index 10c728c60e..4dd7d764a1 100644
--- a/lib/chef/knife/node_delete.rb
+++ b/lib/chef/knife/node_delete.rb
@@ -44,4 +44,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/node_edit.rb b/lib/chef/knife/node_edit.rb
index a232ec5c4e..4632c0a5b4 100644
--- a/lib/chef/knife/node_edit.rb
+++ b/lib/chef/knife/node_edit.rb
@@ -68,5 +68,3 @@ class Chef
end
end
end
-
-
diff --git a/lib/chef/knife/node_environment_set.rb b/lib/chef/knife/node_environment_set.rb
index 30517df45e..ecba01be29 100644
--- a/lib/chef/knife/node_environment_set.rb
+++ b/lib/chef/knife/node_environment_set.rb
@@ -46,7 +46,7 @@ class Chef
config[:attribute] = "chef_environment"
- output(format_for_display(node))
+ output(format_for_display(node))
end
end
diff --git a/lib/chef/knife/node_from_file.rb b/lib/chef/knife/node_from_file.rb
index 661834e277..8e05e2798a 100644
--- a/lib/chef/knife/node_from_file.rb
+++ b/lib/chef/knife/node_from_file.rb
@@ -37,11 +37,11 @@ class Chef
def run
@name_args.each do |arg|
updated = loader.load_from("nodes", arg)
-
+
updated.save
-
+
output(format_for_display(updated)) if config[:print_after]
-
+
ui.info("Updated Node #{updated.name}!")
end
end
diff --git a/lib/chef/knife/node_list.rb b/lib/chef/knife/node_list.rb
index a726b2ded3..4885208136 100644
--- a/lib/chef/knife/node_list.rb
+++ b/lib/chef/knife/node_list.rb
@@ -42,5 +42,3 @@ class Chef
end
end
end
-
-
diff --git a/lib/chef/knife/node_run_list_add.rb b/lib/chef/knife/node_run_list_add.rb
index 2cb6d30b87..f8d40c8321 100644
--- a/lib/chef/knife/node_run_list_add.rb
+++ b/lib/chef/knife/node_run_list_add.rb
@@ -73,7 +73,7 @@ class Chef
private
- def add_to_run_list_after(node, entries, after=nil)
+ def add_to_run_list_after(node, entries, after = nil)
if after
nlist = []
node.run_list.each do |entry|
diff --git a/lib/chef/knife/node_show.rb b/lib/chef/knife/node_show.rb
index 14a7a35b21..c616b8ab72 100644
--- a/lib/chef/knife/node_show.rb
+++ b/lib/chef/knife/node_show.rb
@@ -64,4 +64,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/raw.rb b/lib/chef/knife/raw.rb
index 80fbf97dcc..56527a00f2 100644
--- a/lib/chef/knife/raw.rb
+++ b/lib/chef/knife/raw.rb
@@ -71,7 +71,7 @@ class Chef
begin
method = config[:method].to_sym
- headers = {"Content-Type" => "application/json"}
+ headers = { "Content-Type" => "application/json" }
if config[:proxy_auth]
headers["x-ops-request-source"] = "web"
diff --git a/lib/chef/knife/rehash.rb b/lib/chef/knife/rehash.rb
index 7c16260fed..3e7bab7e0f 100644
--- a/lib/chef/knife/rehash.rb
+++ b/lib/chef/knife/rehash.rb
@@ -21,7 +21,7 @@ require "chef/knife/core/subcommand_loader"
class Chef
class Knife
- class Rehash < Chef::Knife
+ class Rehash < Chef::Knife
banner "knife rehash"
def run
@@ -42,7 +42,7 @@ class Chef
output = if Chef::Knife::SubcommandLoader.plugin_manifest?
Chef::Knife::SubcommandLoader.plugin_manifest
else
- { Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY => {}}
+ { Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY => {} }
end
output[Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY]["plugins_paths"] = Chef::Knife.subcommand_files
output[Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY]["plugins_by_category"] = Chef::Knife.subcommands_by_category
diff --git a/lib/chef/knife/role_bulk_delete.rb b/lib/chef/knife/role_bulk_delete.rb
index 2ec0afb182..0726454da3 100644
--- a/lib/chef/knife/role_bulk_delete.rb
+++ b/lib/chef/knife/role_bulk_delete.rb
@@ -63,8 +63,3 @@ class Chef
end
end
end
-
-
-
-
-
diff --git a/lib/chef/knife/role_create.rb b/lib/chef/knife/role_create.rb
index 23bf0c372b..7e581f42d6 100644
--- a/lib/chef/knife/role_create.rb
+++ b/lib/chef/knife/role_create.rb
@@ -51,5 +51,3 @@ class Chef
end
end
end
-
-
diff --git a/lib/chef/knife/role_delete.rb b/lib/chef/knife/role_delete.rb
index 4162f5b9f4..5c10a05d85 100644
--- a/lib/chef/knife/role_delete.rb
+++ b/lib/chef/knife/role_delete.rb
@@ -44,4 +44,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/role_edit.rb b/lib/chef/knife/role_edit.rb
index 129d55cacd..d3697849ad 100644
--- a/lib/chef/knife/role_edit.rb
+++ b/lib/chef/knife/role_edit.rb
@@ -43,6 +43,3 @@ class Chef
end
end
end
-
-
-
diff --git a/lib/chef/knife/role_env_run_list_add.rb b/lib/chef/knife/role_env_run_list_add.rb
index 207484597e..61aec506a9 100644
--- a/lib/chef/knife/role_env_run_list_add.rb
+++ b/lib/chef/knife/role_env_run_list_add.rb
@@ -34,13 +34,13 @@ class Chef
:long => "--after ITEM",
:description => "Place the ENTRY in the run list after ITEM"
- def add_to_env_run_list(role, environment, entries, after=nil)
+ def add_to_env_run_list(role, environment, entries, after = nil)
if after
nlist = []
unless role.env_run_lists.key?(environment)
role.env_run_lists_add(environment => nlist)
end
- role.run_list_for(environment).each do |entry|
+ role.run_list_for(environment).each do |entry|
nlist << entry
if entry == after
entries.each { |e| nlist << e }
diff --git a/lib/chef/knife/role_env_run_list_remove.rb b/lib/chef/knife/role_env_run_list_remove.rb
index ae30d0a884..576e32e2a9 100644
--- a/lib/chef/knife/role_env_run_list_remove.rb
+++ b/lib/chef/knife/role_env_run_list_remove.rb
@@ -30,14 +30,14 @@ class Chef
banner "knife role env_run_list remove [ROLE] [ENVIRONMENT] [ENTRIES]"
def remove_from_env_run_list(role, environment, item_to_remove)
- nlist = []
- role.run_list_for(environment).each do |entry|
- nlist << entry unless entry == item_to_remove
- #unless entry == @name_args[2]
- # nlist << entry
- #end
- end
- role.env_run_lists_add(environment => nlist)
+ nlist = []
+ role.run_list_for(environment).each do |entry|
+ nlist << entry unless entry == item_to_remove
+ #unless entry == @name_args[2]
+ # nlist << entry
+ #end
+ end
+ role.env_run_lists_add(environment => nlist)
end
def run
diff --git a/lib/chef/knife/role_env_run_list_replace.rb b/lib/chef/knife/role_env_run_list_replace.rb
index ae0c7a63b5..e84e351c1e 100644
--- a/lib/chef/knife/role_env_run_list_replace.rb
+++ b/lib/chef/knife/role_env_run_list_replace.rb
@@ -31,7 +31,7 @@ class Chef
def replace_in_env_run_list(role, environment, old_entry, new_entry)
nlist = []
- role.run_list_for(environment).each do |entry|
+ role.run_list_for(environment).each do |entry|
if entry == old_entry
nlist << new_entry
else
diff --git a/lib/chef/knife/role_from_file.rb b/lib/chef/knife/role_from_file.rb
index 157c8b8889..e1f4737ab9 100644
--- a/lib/chef/knife/role_from_file.rb
+++ b/lib/chef/knife/role_from_file.rb
@@ -49,8 +49,3 @@ class Chef
end
end
end
-
-
-
-
-
diff --git a/lib/chef/knife/role_list.rb b/lib/chef/knife/role_list.rb
index 02a1bcb43e..1247478ef5 100644
--- a/lib/chef/knife/role_list.rb
+++ b/lib/chef/knife/role_list.rb
@@ -40,4 +40,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/role_run_list_add.rb b/lib/chef/knife/role_run_list_add.rb
index 3ce0439a7f..6aa92d37ba 100644
--- a/lib/chef/knife/role_run_list_add.rb
+++ b/lib/chef/knife/role_run_list_add.rb
@@ -34,13 +34,13 @@ class Chef
:long => "--after ITEM",
:description => "Place the ENTRY in the run list after ITEM"
- def add_to_env_run_list(role, environment, entries, after=nil)
+ def add_to_env_run_list(role, environment, entries, after = nil)
if after
nlist = []
unless role.env_run_lists.key?(environment)
role.env_run_lists_add(environment => nlist)
end
- role.run_list_for(environment).each do |entry|
+ role.run_list_for(environment).each do |entry|
nlist << entry
if entry == after
entries.each { |e| nlist << e }
diff --git a/lib/chef/knife/role_run_list_remove.rb b/lib/chef/knife/role_run_list_remove.rb
index f9f8e1dbb1..0dacfee051 100644
--- a/lib/chef/knife/role_run_list_remove.rb
+++ b/lib/chef/knife/role_run_list_remove.rb
@@ -30,14 +30,14 @@ class Chef
banner "knife role run_list remove [ROLE] [ENTRY]"
def remove_from_env_run_list(role, environment, item_to_remove)
- nlist = []
- role.run_list_for(environment).each do |entry|
- nlist << entry unless entry == item_to_remove
- #unless entry == @name_args[2]
- # nlist << entry
- #end
- end
- role.env_run_lists_add(environment => nlist)
+ nlist = []
+ role.run_list_for(environment).each do |entry|
+ nlist << entry unless entry == item_to_remove
+ #unless entry == @name_args[2]
+ # nlist << entry
+ #end
+ end
+ role.env_run_lists_add(environment => nlist)
end
def run
diff --git a/lib/chef/knife/role_run_list_replace.rb b/lib/chef/knife/role_run_list_replace.rb
index e12a77d487..3e7bc2d5ec 100644
--- a/lib/chef/knife/role_run_list_replace.rb
+++ b/lib/chef/knife/role_run_list_replace.rb
@@ -31,7 +31,7 @@ class Chef
def replace_in_env_run_list(role, environment, old_entry, new_entry)
nlist = []
- role.run_list_for(environment).each do |entry|
+ role.run_list_for(environment).each do |entry|
if entry == old_entry
nlist << new_entry
else
diff --git a/lib/chef/knife/role_show.rb b/lib/chef/knife/role_show.rb
index a3af0baf6a..99684768bb 100644
--- a/lib/chef/knife/role_show.rb
+++ b/lib/chef/knife/role_show.rb
@@ -31,7 +31,6 @@ class Chef
banner "knife role show ROLE (options)"
-
def run
@role_name = @name_args[0]
@@ -48,5 +47,3 @@ class Chef
end
end
end
-
-
diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb
index ecb323abe3..30a3db3cf2 100644
--- a/lib/chef/knife/search.rb
+++ b/lib/chef/knife/search.rb
@@ -106,7 +106,7 @@ class Chef
formatted_item = Hash.new
if item.is_a?(Hash)
# doing a little magic here to set the correct name
- formatted_item[item["__display_name"]] = item.reject{|k| k == "__display_name"}
+ formatted_item[item["__display_name"]] = item.reject { |k| k == "__display_name" }
else
formatted_item = format_for_display(item)
end
@@ -120,7 +120,7 @@ class Chef
end
if ui.interchange?
- output({:results => result_count, :rows => result_items})
+ output({ :results => result_count, :rows => result_items })
else
ui.log "#{result_count} items found"
ui.log("\n")
diff --git a/lib/chef/knife/serve.rb b/lib/chef/knife/serve.rb
index 3f97962eae..f74a5c1d1d 100644
--- a/lib/chef/knife/serve.rb
+++ b/lib/chef/knife/serve.rb
@@ -4,7 +4,7 @@ require "chef/local_mode"
class Chef
class Knife
class Serve < Knife
-
+
banner "knife serve (options)"
option :repo_mode,
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index fb36fb67f4..728ee671bc 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -165,7 +165,7 @@ class Chef
if @action_nodes.length == 0
ui.fatal("No nodes returned from search!")
else
- ui.fatal("#{@action_nodes.length} #{@action_nodes.length > 1 ? "nodes": "node"} found, " +
+ ui.fatal("#{@action_nodes.length} #{@action_nodes.length > 1 ? "nodes" : "node"} found, " +
"but does not have the required attribute to establish the connection. " +
"Try setting another attribute to open the connection using --attribute.")
end
@@ -209,7 +209,7 @@ class Chef
next if item.nil?
# next if we couldn't find the specified attribute in the
# returned node object
- host = extract_nested_value(item,get_ssh_attribute(item))
+ host = extract_nested_value(item, get_ssh_attribute(item))
next if host.nil?
ssh_port = item[:cloud].nil? ? nil : item[:cloud][:public_ssh_port]
srv = [host, ssh_port]
@@ -227,7 +227,7 @@ class Chef
# @param port [String] SSH port for this session.
# @param user [String] Optional username for this session.
# @return [Hash<Symbol, Object>]
- def session_options(host, port, user=nil)
+ def session_options(host, port, user = nil)
ssh_config = Net::SSH.configuration_for(host)
{}.tap do |opts|
# Chef::Config[:knife][:ssh_user] is parsed in #configure_user and written to config[:ssh_user]
@@ -297,7 +297,7 @@ class Chef
ui.msg(str)
end
- def ssh_command(command, subsession=nil)
+ def ssh_command(command, subsession = nil)
exit_status = 0
subsession ||= session
command = fixup_sudo(command)
@@ -425,7 +425,7 @@ class Chef
end.join(" \\; ")
end
- tmux_name = "'knife ssh #{@name_args[0].gsub(/:/,'=')}'"
+ tmux_name = "'knife ssh #{@name_args[0].gsub(/:/, '=')}'"
begin
server = session.servers_for.first
cmd = ["tmux new-session -d -s #{tmux_name}",
@@ -446,13 +446,13 @@ class Chef
end
Appscript.app("/Applications/Utilities/Terminal.app").windows.first.activate
- Appscript.app("System Events").application_processes["Terminal.app"].keystroke("n", :using=>:command_down)
+ Appscript.app("System Events").application_processes["Terminal.app"].keystroke("n", :using => :command_down)
term = Appscript.app("Terminal")
window = term.windows.first.get
(session.servers_for.size - 1).times do |i|
window.activate
- Appscript.app("System Events").application_processes["Terminal.app"].keystroke("t", :using=>:command_down)
+ Appscript.app("System Events").application_processes["Terminal.app"].keystroke("t", :using => :command_down)
end
session.servers_for.each_with_index do |server, tab_number|
diff --git a/lib/chef/knife/ssl_check.rb b/lib/chef/knife/ssl_check.rb
index 87cb82c8b1..6dac06b27b 100644
--- a/lib/chef/knife/ssl_check.rb
+++ b/lib/chef/knife/ssl_check.rb
@@ -206,7 +206,7 @@ ADVICE
def debug_invalid_host
noverify_socket.connect
subject = noverify_socket.peer_cert.subject
- cn_field_tuple = subject.to_a.find {|field| field[0] == "CN" }
+ cn_field_tuple = subject.to_a.find { |field| field[0] == "CN" }
cn = cn_field_tuple[1]
ui.error("You are attempting to connect to: '#{host}'")
@@ -253,6 +253,7 @@ ADVICE
end
private
+
def trusted_certificates
if configuration.trusted_certs_dir && Dir.exist?(configuration.trusted_certs_dir)
Dir.glob(File.join(configuration.trusted_certs_dir, "*.{crt,pem}"))
diff --git a/lib/chef/knife/ssl_fetch.rb b/lib/chef/knife/ssl_fetch.rb
index 3d9db57c07..f694a46ac6 100644
--- a/lib/chef/knife/ssl_fetch.rb
+++ b/lib/chef/knife/ssl_fetch.rb
@@ -87,10 +87,9 @@ class Chef
end
end
-
def cn_of(certificate)
subject = certificate.subject
- cn_field_tuple = subject.to_a.find {|field| field[0] == "CN" }
+ cn_field_tuple = subject.to_a.find { |field| field[0] == "CN" }
cn_field_tuple[1]
end
@@ -120,7 +119,7 @@ class Chef
cn = cn_of(cert)
filename = File.join(trusted_certs_dir, "#{normalize_cn(cn)}.crt")
ui.msg("Adding certificate for #{cn} in #{filename}")
- File.open(filename, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
+ File.open(filename, File::CREAT | File::TRUNC | File::RDWR, 0644) do |f|
f.print(cert.to_s)
end
end
@@ -153,7 +152,6 @@ TRUST_TRUST
exit 1
end
-
end
end
end
diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb
index 48e7a2a49d..7bf9abbd1b 100644
--- a/lib/chef/knife/status.rb
+++ b/lib/chef/knife/status.rb
@@ -61,10 +61,10 @@ class Chef
if config[:long_output]
opts = {}
else
- opts = {filter_result:
+ opts = { filter_result:
{ name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"],
- ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"],
- platform_version: ["platform_version"], chef_environment: ["chef_environment"]}}
+ ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"],
+ platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }
end
@query ||= ""
@@ -76,7 +76,7 @@ class Chef
time = Time.now.to_i
# AND NOT is not valid lucene syntax, so don't use append_to_query
@query << " " unless @query.empty?
- @query << "NOT ohai_time:[#{(time - 60*60)} TO #{time}]"
+ @query << "NOT ohai_time:[#{(time - 60 * 60)} TO #{time}]"
end
if config[:hide_by_mins]
@@ -84,7 +84,7 @@ class Chef
time = Time.now.to_i
# AND NOT is not valid lucene syntax, so don't use append_to_query
@query << " " unless @query.empty?
- @query << "NOT ohai_time:[#{(time - hidemins*60)} TO #{time}]"
+ @query << "NOT ohai_time:[#{(time - hidemins * 60)} TO #{time}]"
end
@query = @query.empty? ? "*:*" : @query
diff --git a/lib/chef/knife/upload.rb b/lib/chef/knife/upload.rb
index 90b9a1562b..d0bf89fa7f 100644
--- a/lib/chef/knife/upload.rb
+++ b/lib/chef/knife/upload.rb
@@ -68,4 +68,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/user_create.rb b/lib/chef/knife/user_create.rb
index 9613ec795d..5a9589aad8 100644
--- a/lib/chef/knife/user_create.rb
+++ b/lib/chef/knife/user_create.rb
@@ -69,7 +69,7 @@ class Chef
end
def osc_11_warning
-<<-EOF
+ <<-EOF
IF YOU ARE USING CHEF SERVER 12+, PLEASE FOLLOW THE INSTRUCTIONS UNDER knife user create --help.
You only passed a single argument to knife user create.
For backwards compatibility, when only a single argument is passed,
@@ -144,8 +144,6 @@ EOF
end
end
end
-
-
end
end
end
diff --git a/lib/chef/knife/user_delete.rb b/lib/chef/knife/user_delete.rb
index a6eb89bc17..ce4575ceab 100644
--- a/lib/chef/knife/user_delete.rb
+++ b/lib/chef/knife/user_delete.rb
@@ -30,7 +30,7 @@ class Chef
banner "knife user delete USER (options)"
def osc_11_warning
-<<-EOF
+ <<-EOF
The Chef Server you are using does not support the username field.
This means it is an Open Source 11 Server.
knife user delete for Open Source 11 Server is being deprecated.
@@ -89,7 +89,6 @@ EOF
else # proceed with EC / CS delete
delete_object(@user_name)
end
-
end
end
end
diff --git a/lib/chef/knife/user_edit.rb b/lib/chef/knife/user_edit.rb
index 5aa1c56796..9564a31b15 100644
--- a/lib/chef/knife/user_edit.rb
+++ b/lib/chef/knife/user_edit.rb
@@ -30,7 +30,7 @@ class Chef
banner "knife user edit USER (options)"
def osc_11_warning
-<<-EOF
+ <<-EOF
The Chef Server you are using does not support the username field.
This means it is an Open Source 11 Server.
knife user edit for Open Source 11 Server is being deprecated.
@@ -75,7 +75,6 @@ EOF
ui.msg("User unchanged, not saving.")
end
end
-
end
end
end
diff --git a/lib/chef/knife/user_key_create.rb b/lib/chef/knife/user_key_create.rb
index c5c983979d..95a98a2f4f 100644
--- a/lib/chef/knife/user_key_create.rb
+++ b/lib/chef/knife/user_key_create.rb
@@ -34,7 +34,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
diff --git a/lib/chef/knife/user_key_delete.rb b/lib/chef/knife/user_key_delete.rb
index 1dafc4879d..1c559f2ef0 100644
--- a/lib/chef/knife/user_key_delete.rb
+++ b/lib/chef/knife/user_key_delete.rb
@@ -31,7 +31,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
diff --git a/lib/chef/knife/user_key_edit.rb b/lib/chef/knife/user_key_edit.rb
index ce59876e39..561af8edd0 100644
--- a/lib/chef/knife/user_key_edit.rb
+++ b/lib/chef/knife/user_key_edit.rb
@@ -34,7 +34,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
@@ -77,4 +77,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/user_key_list.rb b/lib/chef/knife/user_key_list.rb
index 1d777bad18..799c069182 100644
--- a/lib/chef/knife/user_key_list.rb
+++ b/lib/chef/knife/user_key_list.rb
@@ -34,7 +34,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
diff --git a/lib/chef/knife/user_key_show.rb b/lib/chef/knife/user_key_show.rb
index 3887238b20..e09d5e04ed 100644
--- a/lib/chef/knife/user_key_show.rb
+++ b/lib/chef/knife/user_key_show.rb
@@ -31,7 +31,7 @@ class Chef
attr_reader :actor
- def initialize(argv=[])
+ def initialize(argv = [])
super(argv)
@service_object = nil
end
diff --git a/lib/chef/knife/user_reregister.rb b/lib/chef/knife/user_reregister.rb
index 3e093da6a5..8d2f2c1e73 100644
--- a/lib/chef/knife/user_reregister.rb
+++ b/lib/chef/knife/user_reregister.rb
@@ -30,7 +30,7 @@ class Chef
banner "knife user reregister USER (options)"
def osc_11_warning
-<<-EOF
+ <<-EOF
The Chef Server you are using does not support the username field.
This means it is an Open Source 11 Server.
knife user reregister for Open Source 11 Server is being deprecated.
@@ -83,7 +83,6 @@ EOF
ui.msg key
end
end
-
end
end
end
diff --git a/lib/chef/knife/user_show.rb b/lib/chef/knife/user_show.rb
index 0f70b86603..04251c0863 100644
--- a/lib/chef/knife/user_show.rb
+++ b/lib/chef/knife/user_show.rb
@@ -32,7 +32,7 @@ class Chef
banner "knife user show USER (options)"
def osc_11_warning
-<<-EOF
+ <<-EOF
The Chef Server you are using does not support the username field.
This means it is an Open Source 11 Server.
knife user show for Open Source 11 Server is being deprecated.
diff --git a/lib/chef/knife/xargs.rb b/lib/chef/knife/xargs.rb
index f16890cba5..10e15a4257 100644
--- a/lib/chef/knife/xargs.rb
+++ b/lib/chef/knife/xargs.rb
@@ -22,7 +22,7 @@ class Chef
:long => "--pattern [PATTERN]",
:short => "-p [PATTERN]",
:description => "Pattern on command line (if these are not specified, a list of patterns is expected on standard input). Multiple patterns may be passed in this way.",
- :arg_arity => [1,-1]
+ :arg_arity => [1, -1]
option :diff,
:long => "--[no-]diff",
@@ -264,4 +264,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/local_mode.rb b/lib/chef/local_mode.rb
index a1b0910156..5ce17e6fb3 100644
--- a/lib/chef/local_mode.rb
+++ b/lib/chef/local_mode.rb
@@ -107,7 +107,7 @@ class Chef
if port.is_a?(String)
parts = port.split(",")
if parts.size == 1
- a,b = parts[0].split("-",2)
+ a, b = parts[0].split("-", 2)
if b
a.to_i.upto(b.to_i)
else
diff --git a/lib/chef/log.rb b/lib/chef/log.rb
index 5b22b3c00e..8d4fed56aa 100644
--- a/lib/chef/log.rb
+++ b/lib/chef/log.rb
@@ -51,7 +51,7 @@ class Chef
caller(0..20).select { |c| !c.start_with?(chef_gem_path) }.first
end
- def self.deprecation(msg=nil, location=caller(2..2)[0], &block)
+ def self.deprecation(msg = nil, location = caller(2..2)[0], &block)
if msg
msg << " at #{Array(location).join("\n")}"
msg = msg.join("") if msg.respond_to?(:join)
diff --git a/lib/chef/log/syslog.rb b/lib/chef/log/syslog.rb
index 0fe3593fe5..58d6671095 100644
--- a/lib/chef/log/syslog.rb
+++ b/lib/chef/log/syslog.rb
@@ -32,7 +32,7 @@ class Chef
attr_accessor :sync, :formatter
- def initialize(program_name = "chef-client", facility = ::Syslog::LOG_DAEMON, logopts=nil)
+ def initialize(program_name = "chef-client", facility = ::Syslog::LOG_DAEMON, logopts = nil)
super
return if defined? ::Logger::Syslog::SYSLOG
::Logger::Syslog.const_set :SYSLOG, SYSLOG
@@ -43,4 +43,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/log/winevt.rb b/lib/chef/log/winevt.rb
index e5afb4ed3c..04e24e3913 100644
--- a/lib/chef/log/winevt.rb
+++ b/lib/chef/log/winevt.rb
@@ -42,7 +42,7 @@ class Chef
attr_accessor :sync, :formatter, :level
- def initialize(eventlog=nil)
+ def initialize(eventlog = nil)
@eventlog = eventlog || ::Win32::EventLog::open("Application")
end
diff --git a/lib/chef/mash.rb b/lib/chef/mash.rb
index e43ba6a0ae..3858ff09dd 100644
--- a/lib/chef/mash.rb
+++ b/lib/chef/mash.rb
@@ -71,7 +71,7 @@ class Mash < Hash
def initialize_copy(orig)
super
# Handle nested values
- each do |k,v|
+ each do |k, v|
if v.kind_of?(Mash) || v.is_a?(Array)
self[k] = v.dup
end
@@ -142,7 +142,7 @@ class Mash < Hash
#
# @return [Array] The values at each of the provided keys
def values_at(*indices)
- indices.collect {|key| self[convert_key(key)]}
+ indices.collect { |key| self[convert_key(key)] }
end
# @param hash<Hash> The hash to merge with the mash.
@@ -166,7 +166,7 @@ class Mash < Hash
# { :one => 1, :two => 2, :three => 3 }.except(:one)
# #=> { "two" => 2, "three" => 3 }
def except(*keys)
- super(*keys.map {|k| convert_key(k)})
+ super(*keys.map { |k| convert_key(k) })
end
# Used to provide the same interface as Hash.
@@ -195,6 +195,7 @@ class Mash < Hash
end
protected
+
# @param key<Object> The key to convert.
#
# @param [Object]
diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb
index 8e0b105274..257ed11221 100644
--- a/lib/chef/mixin/command.rb
+++ b/lib/chef/mixin/command.rb
@@ -75,7 +75,7 @@ class Chef
#
# === Returns
# Returns the exit status of args[:command]
- def run_command(args={})
+ def run_command(args = {})
status, stdout, stderr = run_command_and_return_stdout_stderr(args)
status
@@ -84,7 +84,7 @@ class Chef
# works same as above, except that it returns stdout and stderr
# requirement => platforms like solaris 9,10 has weird issues where
# even in command failure the exit code is zero, so we need to lookup stderr.
- def run_command_and_return_stdout_stderr(args={})
+ def run_command_and_return_stdout_stderr(args = {})
command_output = ""
args[:ignore_failure] ||= false
@@ -143,7 +143,7 @@ class Chef
return status, stdout_string, stderr_string
end
- def handle_command_failures(status, command_output, opts={})
+ def handle_command_failures(status, command_output, opts = {})
return if opts[:ignore_failure]
opts[:returns] ||= 0
return if Array(opts[:returns]).include?(status.exitstatus)
@@ -165,7 +165,7 @@ class Chef
#
# === Returns
# Returns the result of #run_command
- def run_command_with_systems_locale(args={})
+ def run_command_with_systems_locale(args = {})
args[:environment] ||= {}
args[:environment]["LC_ALL"] = ENV["LC_ALL"]
run_command args
diff --git a/lib/chef/mixin/command/unix.rb b/lib/chef/mixin/command/unix.rb
index 3d97b961aa..d930ee33e6 100644
--- a/lib/chef/mixin/command/unix.rb
+++ b/lib/chef/mixin/command/unix.rb
@@ -27,7 +27,7 @@ class Chef
# The original appears in external/open4.rb in its unmodified form.
#
# Thanks Ara!
- def popen4(cmd, args={}, &b)
+ def popen4(cmd, args = {}, &b)
# Ruby 1.8 suffers from intermittent segfaults believed to be due to GC while IO.select
# See CHEF-2916 / CHEF-1305
GC.disable
@@ -89,7 +89,7 @@ class Chef
Process.uid = args[:user]
end
- args[:environment].each do |key,value|
+ args[:environment].each do |key, value|
ENV[key] = value
end
@@ -116,7 +116,7 @@ class Chef
$VERBOSE = verbose
end
- [pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close}
+ [pw.first, pr.last, pe.last, ps.last].each { |fd| fd.close }
begin
e = Marshal.load ps.first
@@ -205,7 +205,7 @@ class Chef
results.last
end
ensure
- pi.each{|fd| fd.close unless fd.closed?}
+ pi.each { |fd| fd.close unless fd.closed? }
end
else
[cid, pw.last, pr.first, pe.first]
diff --git a/lib/chef/mixin/command/windows.rb b/lib/chef/mixin/command/windows.rb
index 5580aaec59..fd45ab0467 100644
--- a/lib/chef/mixin/command/windows.rb
+++ b/lib/chef/mixin/command/windows.rb
@@ -24,14 +24,13 @@ class Chef
module Mixin
module Command
module Windows
- def popen4(cmd, args={}, &b)
-
+ def popen4(cmd, args = {}, &b)
# By default, we are waiting before we yield the block.
args[:waitlast] ||= false
#XXX :user, :group, :environment support?
- Open3.popen3(cmd) do |stdin,stdout,stderr,cid|
+ Open3.popen3(cmd) do |stdin, stdout, stderr, cid|
if b
if args[:waitlast]
b[cid, stdin, stdout, stderr]
diff --git a/lib/chef/mixin/convert_to_class_name.rb b/lib/chef/mixin/convert_to_class_name.rb
index 5029474de9..d6bd8a4ea7 100644
--- a/lib/chef/mixin/convert_to_class_name.rb
+++ b/lib/chef/mixin/convert_to_class_name.rb
@@ -40,10 +40,10 @@ class Chef
rname
end
- def convert_to_snake_case(str, namespace=nil)
+ def convert_to_snake_case(str, namespace = nil)
str = str.dup
str.sub!(/^#{namespace}(\:\:)?/, "") if namespace
- str.gsub!(/[A-Z]/) {|s| "_" + s}
+ str.gsub!(/[A-Z]/) { |s| "_" + s }
str.downcase!
str.sub!(/^\_/, "")
str
@@ -51,8 +51,8 @@ class Chef
def normalize_snake_case_name(str)
str = str.dup
- str.gsub!(/[^A-Za-z0-9_]/,"_")
- str.gsub!(/^(_+)?/,"")
+ str.gsub!(/[^A-Za-z0-9_]/, "_")
+ str.gsub!(/^(_+)?/, "")
str
end
diff --git a/lib/chef/mixin/deprecation.rb b/lib/chef/mixin/deprecation.rb
index 04c40dcf29..0f059a215f 100644
--- a/lib/chef/mixin/deprecation.rb
+++ b/lib/chef/mixin/deprecation.rb
@@ -19,10 +19,9 @@
class Chef
module Mixin
-
- def self.deprecated_constants
- @deprecated_constants ||= {}
- end
+ def self.deprecated_constants
+ @deprecated_constants ||= {}
+ end
# Add a deprecated constant to the Chef::Mixin namespace.
# === Arguments
@@ -33,34 +32,34 @@ class Chef
# deprecate_constant(:RecipeDefinitionDSLCore, Chef::DSL::Recipe, <<-EOM)
# Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead.
# EOM
- def self.deprecate_constant(name, replacement, message)
- deprecated_constants[name] = {:replacement => replacement, :message => message}
- end
+ def self.deprecate_constant(name, replacement, message)
+ deprecated_constants[name] = { :replacement => replacement, :message => message }
+ end
# Const missing hook to look up deprecated constants defined with
# deprecate_constant. Emits a warning to the logger and returns the
# replacement constant. Will call super, most likely causing an exception
# for the missing constant, if +name+ is not found in the
# deprecated_constants collection.
- def self.const_missing(name)
- if new_const = deprecated_constants[name]
- Chef::Log.warn(new_const[:message])
- Chef::Log.warn("Called from: \n#{caller[0...3].map {|l| "\t#{l}"}.join("\n")}")
- new_const[:replacement]
- else
- super
- end
+ def self.const_missing(name)
+ if new_const = deprecated_constants[name]
+ Chef::Log.warn(new_const[:message])
+ Chef::Log.warn("Called from: \n#{caller[0...3].map { |l| "\t#{l}" }.join("\n")}")
+ new_const[:replacement]
+ else
+ super
end
+ end
module Deprecation
class DeprecatedObjectProxyBase
KEEPERS = %w{__id__ __send__ instance_eval == equal? initialize object_id}
- instance_methods.each { |method_name| undef_method(method_name) unless KEEPERS.include?(method_name.to_s)}
+ instance_methods.each { |method_name| undef_method(method_name) unless KEEPERS.include?(method_name.to_s) }
end
class DeprecatedInstanceVariable < DeprecatedObjectProxyBase
- def initialize(target, ivar_name, level=nil)
+ def initialize(target, ivar_name, level = nil)
@target, @ivar_name = target, ivar_name
@level ||= :warn
end
@@ -80,7 +79,7 @@ class Chef
called_from = called_from.flatten
log("Accessing #{@ivar_name} by the variable @#{@ivar_name} is deprecated. Support will be removed in a future release.")
log("Please update your cookbooks to use #{@ivar_name} in place of @#{@ivar_name}. Accessed from:")
- called_from.each {|l| log(l)}
+ called_from.each { |l| log(l) }
end
def log(msg)
@@ -91,7 +90,7 @@ class Chef
end
- def deprecated_ivar(obj, name, level=nil)
+ def deprecated_ivar(obj, name, level = nil)
DeprecatedInstanceVariable.new(obj, name, level)
end
@@ -100,22 +99,22 @@ class Chef
deprecated_attr_writer(name, alternative)
end
- def deprecated_attr_reader(name, alternative, level=:warn)
+ def deprecated_attr_reader(name, alternative, level = :warn)
define_method(name) do
Chef.log_deprecation("#{self.class}.#{name} is deprecated. Support will be removed in a future release.")
Chef.log_deprecation(alternative)
Chef.log_deprecation("Called from:")
- caller[0..3].each {|c| Chef.log_deprecation(c)}
+ caller[0..3].each { |c| Chef.log_deprecation(c) }
instance_variable_get("@#{name}")
end
end
- def deprecated_attr_writer(name, alternative, level=:warn)
+ def deprecated_attr_writer(name, alternative, level = :warn)
define_method("#{name}=") do |value|
Chef.log_deprecation("Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release.")
Chef.log_deprecation(alternative)
Chef.log_deprecation("Called from:")
- caller[0..3].each {|c| Chef.log_deprecation(c)}
+ caller[0..3].each { |c| Chef.log_deprecation(c) }
instance_variable_set("@#{name}", value)
end
end
diff --git a/lib/chef/mixin/descendants_tracker.rb b/lib/chef/mixin/descendants_tracker.rb
index e6c59d305e..b0f0ff2227 100644
--- a/lib/chef/mixin/descendants_tracker.rb
+++ b/lib/chef/mixin/descendants_tracker.rb
@@ -21,7 +21,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-
# This is lifted from rails activesupport (note the copyright above):
# https://github.com/rails/rails/blob/9f84e60ac9d7bf07d6ae1bc94f3941f5b8f1a228/activesupport/lib/active_support/descendants_tracker.rb
@@ -42,7 +41,7 @@ class Chef
end
def find_descendants_by_name(klass, name)
- descendants(klass).first {|c| c.name == name }
+ descendants(klass).first { |c| c.name == name }
end
# This is the only method that is not thread safe, but is only ever called
diff --git a/lib/chef/mixin/get_source_from_package.rb b/lib/chef/mixin/get_source_from_package.rb
index abab763436..555dd634f8 100644
--- a/lib/chef/mixin/get_source_from_package.rb
+++ b/lib/chef/mixin/get_source_from_package.rb
@@ -15,7 +15,6 @@
# limitations under the License.
#
-
#
# mixin to make this syntax work without specifying a source:
#
diff --git a/lib/chef/mixin/language_include_attribute.rb b/lib/chef/mixin/language_include_attribute.rb
index 39a04bb701..7cb66dc272 100644
--- a/lib/chef/mixin/language_include_attribute.rb
+++ b/lib/chef/mixin/language_include_attribute.rb
@@ -32,4 +32,3 @@ EOM
end
end
-
diff --git a/lib/chef/mixin/language_include_recipe.rb b/lib/chef/mixin/language_include_recipe.rb
index 9dd64673a1..97e384c7c4 100644
--- a/lib/chef/mixin/language_include_recipe.rb
+++ b/lib/chef/mixin/language_include_recipe.rb
@@ -29,4 +29,3 @@ EOM
end
end
-
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb
index a51b24df24..598c6c3c23 100644
--- a/lib/chef/mixin/params_validate.rb
+++ b/lib/chef/mixin/params_validate.rb
@@ -140,7 +140,7 @@ class Chef
end
# Raise an exception if the parameter is not found.
- def _pv_required(opts, key, is_required=true, explicitly_allows_nil=false)
+ def _pv_required(opts, key, is_required = true, explicitly_allows_nil = false)
if is_required
return true if opts.has_key?(key.to_s) && (explicitly_allows_nil || !opts[key.to_s].nil?)
return true if opts.has_key?(key.to_sym) && (explicitly_allows_nil || !opts[key.to_sym].nil?)
@@ -329,7 +329,7 @@ class Chef
# property :x, name_property: true
# ```
#
- def _pv_name_property(opts, key, is_name_property=true)
+ def _pv_name_property(opts, key, is_name_property = true)
if is_name_property
if opts[key].nil?
raise CannotValidateStaticallyError, "name_property cannot be evaluated without a resource." if self == Chef::Mixin::ParamsValidate
@@ -462,7 +462,6 @@ class Chef
# (which is the norm).
extend self
-
# Used by #set_or_return to avoid emitting a deprecation warning for
# "value nil" and to keep default stickiness working exactly the same
# @api private
@@ -476,7 +475,7 @@ class Chef
value
end
- def call(resource, value=NOT_PASSED)
+ def call(resource, value = NOT_PASSED)
# setting to nil does a get
if value.nil? && !explicitly_accepts_nil?(resource)
get(resource)
diff --git a/lib/chef/mixin/path_sanity.rb b/lib/chef/mixin/path_sanity.rb
index 6c1b26fabd..7078c585e0 100644
--- a/lib/chef/mixin/path_sanity.rb
+++ b/lib/chef/mixin/path_sanity.rb
@@ -20,7 +20,7 @@ class Chef
module Mixin
module PathSanity
- def enforce_path_sanity(env=ENV)
+ def enforce_path_sanity(env = ENV)
if Chef::Config[:enforce_path_sanity]
env["PATH"] = "" if env["PATH"].nil?
path_separator = Chef::Platform.windows? ? ";" : ":"
diff --git a/lib/chef/mixin/powershell_type_coercions.rb b/lib/chef/mixin/powershell_type_coercions.rb
index 60c04e85ae..381cbed637 100644
--- a/lib/chef/mixin/powershell_type_coercions.rb
+++ b/lib/chef/mixin/powershell_type_coercions.rb
@@ -23,14 +23,14 @@ class Chef
def type_coercions
@type_coercions ||= {
- Fixnum => { :type => lambda { |x| x.to_s }},
- Float => { :type => lambda { |x| x.to_s }},
- FalseClass => { :type => lambda { |x| "$false" }},
- TrueClass => { :type => lambda { |x| "$true" }},
- Hash => {:type => Proc.new { |x| translate_hash(x)}},
- Array => {:type => Proc.new { |x| translate_array(x)}},
- Chef::Node::ImmutableMash => {:type => Proc.new { |x| translate_hash(x)}},
- Chef::Node::ImmutableArray => {:type => Proc.new { |x| translate_array(x)}},
+ Fixnum => { :type => lambda { |x| x.to_s } },
+ Float => { :type => lambda { |x| x.to_s } },
+ FalseClass => { :type => lambda { |x| "$false" } },
+ TrueClass => { :type => lambda { |x| "$true" } },
+ Hash => { :type => Proc.new { |x| translate_hash(x) } },
+ Array => { :type => Proc.new { |x| translate_array(x) } },
+ Chef::Node::ImmutableMash => { :type => Proc.new { |x| translate_hash(x) } },
+ Chef::Node::ImmutableArray => { :type => Proc.new { |x| translate_array(x) } },
}
end
@@ -49,7 +49,7 @@ class Chef
private
def translate_hash(x)
- translated = x.inject([]) do |memo, (k,v)|
+ translated = x.inject([]) do |memo, (k, v)|
memo << "#{k}=#{translate_type(v)}"
end
"@{#{translated.join(';')}}"
diff --git a/lib/chef/mixin/properties.rb b/lib/chef/mixin/properties.rb
index af4e2c2c09..2e33d2d0e7 100644
--- a/lib/chef/mixin/properties.rb
+++ b/lib/chef/mixin/properties.rb
@@ -17,7 +17,7 @@ class Chef
#
# @return [Hash<Symbol,Property>] The list of property names and types.
#
- def properties(include_superclass=true)
+ def properties(include_superclass = true)
if include_superclass
result = {}
ancestors.reverse_each { |c| result.merge!(c.properties(false)) if c.respond_to?(:properties) }
@@ -92,10 +92,10 @@ class Chef
# @example With type and options
# property :x, String, default: 'hi'
#
- def property(name, type=NOT_PASSED, **options)
+ def property(name, type = NOT_PASSED, **options)
name = name.to_sym
- options.each { |k,v| options[k.to_sym] = v if k.is_a?(String) }
+ options.each { |k, v| options[k.to_sym] = v if k.is_a?(String) }
options[:instance_variable_name] = :"@#{name}" if !options.has_key?(:instance_variable_name)
options.merge!(name: name, declared_in: self)
@@ -200,7 +200,7 @@ class Chef
# If state_attrs *excludes* something which is currently desired state,
# mark it as desired_state: false.
- local_properties.each do |name,property|
+ local_properties.each do |name, property|
if property.desired_state? && !names.include?(name)
self.property name, desired_state: false
end
@@ -248,7 +248,7 @@ class Chef
# If identity_properties *excludes* something which is currently part of
# the identity, mark it as identity: false.
- properties.each do |name,property|
+ properties.each do |name, property|
if property.identity? && !names.include?(name)
self.property name, identity: false
diff --git a/lib/chef/mixin/provides.rb b/lib/chef/mixin/provides.rb
index 5885752752..34a078c010 100644
--- a/lib/chef/mixin/provides.rb
+++ b/lib/chef/mixin/provides.rb
@@ -7,7 +7,7 @@ class Chef
# TODO no longer needed, remove or deprecate?
include Chef::Mixin::DescendantsTracker
- def provides(short_name, opts={}, &block)
+ def provides(short_name, opts = {}, &block)
raise NotImplementedError, :provides
end
diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb
index d83d009638..af3e10126b 100644
--- a/lib/chef/mixin/securable.rb
+++ b/lib/chef/mixin/securable.rb
@@ -20,7 +20,7 @@ class Chef
module Mixin
module Securable
- def owner(arg=nil)
+ def owner(arg = nil)
set_or_return(
:owner,
arg,
@@ -30,7 +30,7 @@ class Chef
alias :user :owner
- def group(arg=nil)
+ def group(arg = nil)
set_or_return(
:group,
arg,
@@ -38,28 +38,27 @@ class Chef
)
end
- def mode(arg=nil)
+ def mode(arg = nil)
set_or_return(
:mode,
arg,
:callbacks => {
"not in valid numeric range" => lambda { |m|
if m.kind_of?(String)
- m =~ /^0/ || m="0#{m}"
+ m =~ /^0/ || m = "0#{m}"
end
# Windows does not support the sticky or setuid bits
if Chef::Platform.windows?
- Integer(m)<=0777 && Integer(m)>=0
+ Integer(m) <= 0777 && Integer(m) >= 0
else
- Integer(m)<=07777 && Integer(m)>=0
+ Integer(m) <= 07777 && Integer(m) >= 0
end
}
},
)
end
-
#==WindowsMacros
# Defines methods for adding attributes to a chef resource to describe
# Windows file security metadata.
@@ -108,10 +107,9 @@ class Chef
# * `:one_level_deep` (optional): Boolean
#
def rights_attribute(name)
-
# equivalent to something like:
# def rights(permissions=nil, principals=nil, args_hash=nil)
- define_method(name) do |permissions=nil, principals=nil, args_hash=nil|
+ define_method(name) do |permissions = nil, principals = nil, args_hash = nil|
rights = self.instance_variable_get("@#{name}".to_sym)
unless permissions.nil?
input = {
@@ -120,17 +118,17 @@ class Chef
}
input.merge!(args_hash) unless args_hash.nil?
- validations = {:permissions => { :required => true },
- :principals => { :required => true, :kind_of => [String, Array] },
- :applies_to_children => { :equal_to => [ true, false, :containers_only, :objects_only ]},
- :applies_to_self => { :kind_of => [ TrueClass, FalseClass ] },
- :one_level_deep => { :kind_of => [ TrueClass, FalseClass ] },
+ validations = { :permissions => { :required => true },
+ :principals => { :required => true, :kind_of => [String, Array] },
+ :applies_to_children => { :equal_to => [ true, false, :containers_only, :objects_only ] },
+ :applies_to_self => { :kind_of => [ TrueClass, FalseClass ] },
+ :one_level_deep => { :kind_of => [ TrueClass, FalseClass ] },
}
validate(input, validations)
[ permissions ].flatten.each do |permission|
if permission.is_a?(Integer)
- if permission < 0 || permission > 1<<32
+ if permission < 0 || permission > 1 << 32
raise ArgumentError, "permissions flags must be positive and <= 32 bits (#{permission})"
end
elsif !([:full_control, :modify, :read_execute, :read, :write].include?(permission.to_sym))
@@ -169,8 +167,7 @@ class Chef
# including class
module WindowsSecurableAttributes
-
- def inherits(arg=nil)
+ def inherits(arg = nil)
set_or_return(
:inherits,
arg,
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb
index be46f0cd2c..c423ccaa42 100644
--- a/lib/chef/mixin/template.rb
+++ b/lib/chef/mixin/template.rb
@@ -105,10 +105,9 @@ class Chef
def node
return @node if @node
raise "Could not find a value for node. If you are explicitly setting variables in a template, " +
- "include a node variable if you plan to use it."
+ "include a node variable if you plan to use it."
end
-
#
# Takes the name of the partial, plus a hash of options. Returns a
# string that contains the result of the evaluation of the partial.
@@ -177,7 +176,7 @@ class Chef
# this template.
if Chef::Platform.windows?
- output = output.gsub(/\r?\n/,"\r\n")
+ output = output.gsub(/\r?\n/, "\r\n")
end
output
@@ -225,7 +224,7 @@ class Chef
end
def line_number
- @line_number ||= $1.to_i if original_exception.backtrace.find {|line| line =~ /\(erubis\):(\d+)/ }
+ @line_number ||= $1.to_i if original_exception.backtrace.find { |line| line =~ /\(erubis\):(\d+)/ }
end
def source_location
@@ -246,7 +245,7 @@ class Chef
contextual_lines = lines[beginning_line, source_size]
output = []
contextual_lines.each_with_index do |line, index|
- line_number = (index+beginning_line+1).to_s.rjust(3)
+ line_number = (index + beginning_line + 1).to_s.rjust(3)
output << "#{line_number}: #{line}"
end
output.join("\n")
diff --git a/lib/chef/mixin/uris.rb b/lib/chef/mixin/uris.rb
index 5122177728..24e8a4f9ed 100644
--- a/lib/chef/mixin/uris.rb
+++ b/lib/chef/mixin/uris.rb
@@ -29,7 +29,6 @@ class Chef
!!(%r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ source)
end
-
def as_uri(source)
begin
URI.parse(source)
diff --git a/lib/chef/mixin/why_run.rb b/lib/chef/mixin/why_run.rb
index be9808b1fe..b2aa5949c0 100644
--- a/lib/chef/mixin/why_run.rb
+++ b/lib/chef/mixin/why_run.rb
@@ -222,7 +222,6 @@ class Chef
@assertion_failed
end
-
# Runs the assertion/assumption logic. Will raise an Exception of the
# type specified in #failure_message (or AssertionFailure by default)
# if the requirement is not met and Chef is not running in why run
@@ -247,7 +246,7 @@ class Chef
def initialize(resource, run_context)
@resource, @run_context = resource, run_context
- @assertions = Hash.new {|h,k| h[k] = [] }
+ @assertions = Hash.new { |h, k| h[k] = [] }
@blocked_actions = []
end
@@ -313,7 +312,7 @@ class Chef
def assert(*actions)
assertion = Assertion.new
yield assertion
- actions.each {|action| @assertions[action] << assertion }
+ actions.each { |action| @assertions[action] << assertion }
end
# Run the assertion and assumption logic.
diff --git a/lib/chef/mixin/windows_architecture_helper.rb b/lib/chef/mixin/windows_architecture_helper.rb
index edda6cf401..5f8d3e3729 100644
--- a/lib/chef/mixin/windows_architecture_helper.rb
+++ b/lib/chef/mixin/windows_architecture_helper.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "chef/exceptions"
require "chef/platform/query_helpers"
require "chef/win32/process" if Chef::Platform.windows?
diff --git a/lib/chef/mixin/windows_env_helper.rb b/lib/chef/mixin/windows_env_helper.rb
index e46b40b240..b2e08edc08 100644
--- a/lib/chef/mixin/windows_env_helper.rb
+++ b/lib/chef/mixin/windows_env_helper.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "chef/exceptions"
require "chef/mixin/wide_string"
require "chef/platform/query_helpers"
diff --git a/lib/chef/mixin/xml_escape.rb b/lib/chef/mixin/xml_escape.rb
index a278c81554..afb0d09c2d 100644
--- a/lib/chef/mixin/xml_escape.rb
+++ b/lib/chef/mixin/xml_escape.rb
@@ -95,7 +95,7 @@ class Chef
PREDEFINED = {
38 => "&amp;", # ampersand
60 => "&lt;", # left angle bracket
- 62 => "&gt;" # right angle bracket
+ 62 => "&gt;" # right angle bracket
}
# http://www.w3.org/TR/REC-xml/#charsets
@@ -104,9 +104,9 @@ class Chef
def xml_escape(unescaped_str)
begin
- unescaped_str.unpack("U*").map {|char| xml_escape_char!(char)}.join
+ unescaped_str.unpack("U*").map { |char| xml_escape_char!(char) }.join
rescue
- unescaped_str.unpack("C*").map {|char| xml_escape_char!(char)}.join
+ unescaped_str.unpack("C*").map { |char| xml_escape_char!(char) }.join
end
end
@@ -114,8 +114,8 @@ class Chef
def xml_escape_char!(char)
char = CP1252[char] || char
- char = 42 unless VALID.detect {|range| range.include? char}
- char = PREDEFINED[char] || (char<128 ? char.chr : "&##{char};")
+ char = 42 unless VALID.detect { |range| range.include? char }
+ char = PREDEFINED[char] || (char < 128 ? char.chr : "&##{char};")
end
end
diff --git a/lib/chef/mixins.rb b/lib/chef/mixins.rb
index 7ae7fe659e..b980e81287 100644
--- a/lib/chef/mixins.rb
+++ b/lib/chef/mixins.rb
@@ -11,4 +11,3 @@ require "chef/mixin/path_sanity"
require "chef/mixin/template"
require "chef/mixin/securable"
require "chef/mixin/xml_escape"
-
diff --git a/lib/chef/monkey_patches/net-ssh-multi.rb b/lib/chef/monkey_patches/net-ssh-multi.rb
index dd4da6865f..b0d05a0b27 100644
--- a/lib/chef/monkey_patches/net-ssh-multi.rb
+++ b/lib/chef/monkey_patches/net-ssh-multi.rb
@@ -47,14 +47,14 @@ if Net::SSH::Multi::Version::STRING == "1.1.0" || Net::SSH::Multi::Version::STRI
# Make sure that server returns false if the ssh connection
# has failed.
- def busy?(include_invisible=false)
+ def busy?(include_invisible = false)
!failed? && session && session.busy?(include_invisible)
end
end
class Session
- def next_session(server, force=false) #:nodoc:
+ def next_session(server, force = false) #:nodoc:
# don't retry a failed attempt
return nil if server.failed?
diff --git a/lib/chef/monkey_patches/net_http.rb b/lib/chef/monkey_patches/net_http.rb
index 6aad6029c3..c1cb87bffd 100644
--- a/lib/chef/monkey_patches/net_http.rb
+++ b/lib/chef/monkey_patches/net_http.rb
@@ -21,7 +21,7 @@ module Net
end
end
-if Net::HTTP.instance_methods.map {|m| m.to_s}.include?("proxy_uri")
+if Net::HTTP.instance_methods.map { |m| m.to_s }.include?("proxy_uri")
begin
# Ruby 2.0 changes the way proxy support is implemented in Net::HTTP.
# The implementation does not work correctly with IPv6 literals because it
diff --git a/lib/chef/monkey_patches/webrick-utils.rb b/lib/chef/monkey_patches/webrick-utils.rb
index f7f2cf6ad4..ff275a434d 100644
--- a/lib/chef/monkey_patches/webrick-utils.rb
+++ b/lib/chef/monkey_patches/webrick-utils.rb
@@ -11,7 +11,7 @@ module WEBrick
# create_listeners on Windows with Ruby > 2.0.0 does not
# raise an error if we're already listening on a port.
#
- def create_listeners(address, port, logger=nil)
+ def create_listeners(address, port, logger = nil)
#
# utils.rb -- Miscellaneous utilities
#
@@ -40,7 +40,7 @@ module WEBrick
sockets << sock
rescue => ex
logger.warn("TCPServer Error: #{ex}") if logger
- last_error = ex
+ last_error = ex
end
}
raise last_error if sockets.empty?
diff --git a/lib/chef/monkey_patches/win32/registry.rb b/lib/chef/monkey_patches/win32/registry.rb
index b8b3fb6fdd..a9333bdb99 100644
--- a/lib/chef/monkey_patches/win32/registry.rb
+++ b/lib/chef/monkey_patches/win32/registry.rb
@@ -53,7 +53,7 @@ module Win32
when REG_SZ, REG_EXPAND_SZ
data = data.to_s.encode(WCHAR) + WCHAR_NUL
when REG_MULTI_SZ
- data = data.to_a.map {|s| s.encode(WCHAR)}.join(WCHAR_NUL) << WCHAR_NUL << WCHAR_NUL
+ data = data.to_a.map { |s| s.encode(WCHAR) }.join(WCHAR_NUL) << WCHAR_NUL << WCHAR_NUL
when REG_BINARY
data = data.to_s
when REG_DWORD
diff --git a/lib/chef/monologger.rb b/lib/chef/monologger.rb
index e0ca5c5be6..77ca54d7eb 100644
--- a/lib/chef/monologger.rb
+++ b/lib/chef/monologger.rb
@@ -38,7 +38,6 @@ class MonoLogger < Logger
end
end
-
class LocklessLogDevice < LogDevice
def initialize(log = nil)
@@ -86,5 +85,4 @@ class MonoLogger < Logger
end
-
end
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index eeb59a119f..1f72c86a8b 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -108,13 +108,13 @@ class Chef
end
# Set the name of this Node, or return the current name.
- def name(arg=nil)
+ def name(arg = nil)
if arg != nil
validate(
- {:name => arg },
- {:name => { :kind_of => String,
- :cannot_be => :blank,
- :regex => /^[\-[:alnum:]_:.]+$/}
+ { :name => arg },
+ { :name => { :kind_of => String,
+ :cannot_be => :blank,
+ :regex => /^[\-[:alnum:]_:.]+$/ }
},)
@name = arg
else
@@ -122,7 +122,7 @@ class Chef
end
end
- def chef_environment(arg=nil)
+ def chef_environment(arg = nil)
set_or_return(
:chef_environment,
arg,
@@ -145,9 +145,9 @@ class Chef
#
# @param arg [String] the new policy_name value
# @return [String] the current policy_name, or the one you just set
- def policy_name(arg=NULL_ARG)
+ def policy_name(arg = NULL_ARG)
return @policy_name if arg.equal?(NULL_ARG)
- validate({policy_name: arg}, { policy_name: { kind_of: [ String, NilClass ], regex: /^[\-:.[:alnum:]_]+$/ } })
+ validate({ policy_name: arg }, { policy_name: { kind_of: [ String, NilClass ], regex: /^[\-:.[:alnum:]_]+$/ } })
@policy_name = arg
end
@@ -167,9 +167,9 @@ class Chef
#
# @param arg [String] the new policy_group value
# @return [String] the current policy_group, or the one you just set
- def policy_group(arg=NULL_ARG)
+ def policy_group(arg = NULL_ARG)
return @policy_group if arg.equal?(NULL_ARG)
- validate({policy_group: arg}, { policy_group: { kind_of: [ String, NilClass ], regex: /^[\-:.[:alnum:]_]+$/ } })
+ validate({ policy_group: arg }, { policy_group: { kind_of: [ String, NilClass ], regex: /^[\-:.[:alnum:]_]+$/ } })
@policy_group = arg
end
@@ -365,7 +365,7 @@ class Chef
normal_attrs_to_merge = consume_run_list(attrs)
normal_attrs_to_merge = consume_chef_environment(normal_attrs_to_merge)
Chef::Log.debug("Applying attributes from json file")
- self.normal_attrs = Chef::Mixin::DeepMerge.merge(normal_attrs,normal_attrs_to_merge)
+ self.normal_attrs = Chef::Mixin::DeepMerge.merge(normal_attrs, normal_attrs_to_merge)
self.tags # make sure they're defined
end
@@ -452,7 +452,7 @@ class Chef
# passed in, which came from roles.
def apply_expansion_attributes(expansion)
loaded_environment = if chef_environment == "_default"
- Chef::Environment.new.tap {|e| e.name("_default")}
+ Chef::Environment.new.tap { |e| e.name("_default") }
else
Chef::Environment.load(chef_environment)
end
@@ -561,17 +561,17 @@ class Chef
node
end
- def self.list_by_environment(environment, inflate=false)
+ def self.list_by_environment(environment, inflate = false)
if inflate
response = Hash.new
- Chef::Search::Query.new.search(:node, "chef_environment:#{environment}") {|n| response[n.name] = n unless n.nil?}
+ Chef::Search::Query.new.search(:node, "chef_environment:#{environment}") { |n| response[n.name] = n unless n.nil? }
response
else
Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("environments/#{environment}/nodes")
end
end
- def self.list(inflate=false)
+ def self.list(inflate = false)
if inflate
response = Hash.new
Chef::Search::Query.new.search(:node) do |n|
@@ -655,7 +655,7 @@ class Chef
def ==(other)
if other.kind_of?(self.class)
- self.name == other.name
+ self.name == other.name
else
false
end
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index 0ed4a9360a..13ce75455f 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -144,34 +144,34 @@ class Chef
end
# return the cookbook level default attribute component
- attr_reader :default
+ attr_reader :default
# return the role level default attribute component
- attr_reader :role_default
+ attr_reader :role_default
# return the environment level default attribute component
- attr_reader :env_default
+ attr_reader :env_default
# return the force_default level attribute component
- attr_reader :force_default
+ attr_reader :force_default
# return the "normal" level attribute component
- attr_reader :normal
+ attr_reader :normal
# return the cookbook level override attribute component
- attr_reader :override
+ attr_reader :override
# return the role level override attribute component
- attr_reader :role_override
+ attr_reader :role_override
# return the enviroment level override attribute component
- attr_reader :env_override
+ attr_reader :env_override
# return the force override level attribute component
- attr_reader :force_override
+ attr_reader :force_override
# return the automatic level attribute component
- attr_reader :automatic
+ attr_reader :automatic
# This is used to track the top level key as we descend through method chaining into
# a precedence level (e.g. node.default['foo']['bar']['baz']= results in 'foo' here). We
@@ -179,36 +179,36 @@ class Chef
# that we can invalidate the whole top-level deep merge cache for the top-level key. It is
# the responsibility of the accessor on the Chef::Node object to reset this to nil, and then
# the first VividMash#[] call can ||= and set this to the first key we encounter.
- attr_accessor :top_level_breadcrumb
+ attr_accessor :top_level_breadcrumb
# Cache of deep merged values by top-level key. This is a simple hash which has keys that are the
# top-level keys of the node object, and we save the computed deep-merge for that key here. There is
# no cache of subtrees.
- attr_accessor :deep_merge_cache
+ attr_accessor :deep_merge_cache
- def initialize(normal, default, override, automatic)
- @set_unless_present = false
+ def initialize(normal, default, override, automatic)
+ @set_unless_present = false
- @default = VividMash.new(self, default)
- @env_default = VividMash.new(self, {})
- @role_default = VividMash.new(self, {})
- @force_default = VividMash.new(self, {})
+ @default = VividMash.new(self, default)
+ @env_default = VividMash.new(self, {})
+ @role_default = VividMash.new(self, {})
+ @force_default = VividMash.new(self, {})
- @normal = VividMash.new(self, normal)
+ @normal = VividMash.new(self, normal)
- @override = VividMash.new(self, override)
- @role_override = VividMash.new(self, {})
- @env_override = VividMash.new(self, {})
- @force_override = VividMash.new(self, {})
+ @override = VividMash.new(self, override)
+ @role_override = VividMash.new(self, {})
+ @env_override = VividMash.new(self, {})
+ @force_override = VividMash.new(self, {})
- @automatic = VividMash.new(self, automatic)
+ @automatic = VividMash.new(self, automatic)
- @merged_attributes = nil
- @combined_override = nil
- @combined_default = nil
- @top_level_breadcrumb = nil
- @deep_merge_cache = {}
- end
+ @merged_attributes = nil
+ @combined_override = nil
+ @combined_default = nil
+ @top_level_breadcrumb = nil
+ @deep_merge_cache = {}
+ end
# Debug what's going on with an attribute. +args+ is a path spec to the
# attribute you're interested in. For example, to debug where the value
@@ -221,195 +221,195 @@ class Chef
# the component, such as role default, normal, etc. and value is the
# attribute value set at that precedence level. If there is no value at
# that precedence level, +value+ will be the symbol +:not_present+.
- def debug_value(*args)
- components = COMPONENTS.map do |component|
- ivar = instance_variable_get(component)
- value = args.inject(ivar) do |so_far, key|
- if so_far == :not_present
- :not_present
- elsif so_far.has_key?(key)
- so_far[key]
- else
- :not_present
- end
- end
- [component.to_s.sub(/^@/,""), value]
- end
- [["set_unless_enabled?", @set_unless_present]] + components
- end
+ def debug_value(*args)
+ components = COMPONENTS.map do |component|
+ ivar = instance_variable_get(component)
+ value = args.inject(ivar) do |so_far, key|
+ if so_far == :not_present
+ :not_present
+ elsif so_far.has_key?(key)
+ so_far[key]
+ else
+ :not_present
+ end
+ end
+ [component.to_s.sub(/^@/, ""), value]
+ end
+ [["set_unless_enabled?", @set_unless_present]] + components
+ end
# Enables or disables `||=`-like attribute setting. See, e.g., Node#set_unless
- def set_unless_value_present=(setting)
- @set_unless_present = setting
- end
+ def set_unless_value_present=(setting)
+ @set_unless_present = setting
+ end
# Invalidate a key in the deep_merge_cache. If called with nil, or no arg, this will invalidate
# the entire deep_merge cache. In the case of the user doing node.default['foo']['bar']['baz']=
# that eventually results in a call to reset_cache('foo') here. A node.default=hash_thing call
# must invalidate the entire cache and re-deep-merge the entire node object.
- def reset_cache(path = nil)
- if path.nil?
- @deep_merge_cache = {}
- else
- deep_merge_cache.delete(path.to_s)
- end
- end
+ def reset_cache(path = nil)
+ if path.nil?
+ @deep_merge_cache = {}
+ else
+ deep_merge_cache.delete(path.to_s)
+ end
+ end
- alias :reset :reset_cache
+ alias :reset :reset_cache
# Set the cookbook level default attribute component to +new_data+.
- def default=(new_data)
- reset
- @default = VividMash.new(self, new_data)
- end
+ def default=(new_data)
+ reset
+ @default = VividMash.new(self, new_data)
+ end
# Set the role level default attribute component to +new_data+
- def role_default=(new_data)
- reset
- @role_default = VividMash.new(self, new_data)
- end
+ def role_default=(new_data)
+ reset
+ @role_default = VividMash.new(self, new_data)
+ end
# Set the environment level default attribute component to +new_data+
- def env_default=(new_data)
- reset
- @env_default = VividMash.new(self, new_data)
- end
+ def env_default=(new_data)
+ reset
+ @env_default = VividMash.new(self, new_data)
+ end
# Set the force_default (+default!+) level attributes to +new_data+
- def force_default=(new_data)
- reset
- @force_default = VividMash.new(self, new_data)
- end
+ def force_default=(new_data)
+ reset
+ @force_default = VividMash.new(self, new_data)
+ end
# Set the normal level attribute component to +new_data+
- def normal=(new_data)
- reset
- @normal = VividMash.new(self, new_data)
- end
+ def normal=(new_data)
+ reset
+ @normal = VividMash.new(self, new_data)
+ end
# Set the cookbook level override attribute component to +new_data+
- def override=(new_data)
- reset
- @override = VividMash.new(self, new_data)
- end
+ def override=(new_data)
+ reset
+ @override = VividMash.new(self, new_data)
+ end
# Set the role level override attribute component to +new_data+
- def role_override=(new_data)
- reset
- @role_override = VividMash.new(self, new_data)
- end
+ def role_override=(new_data)
+ reset
+ @role_override = VividMash.new(self, new_data)
+ end
# Set the environment level override attribute component to +new_data+
- def env_override=(new_data)
- reset
- @env_override = VividMash.new(self, new_data)
- end
+ def env_override=(new_data)
+ reset
+ @env_override = VividMash.new(self, new_data)
+ end
- def force_override=(new_data)
- reset
- @force_override = VividMash.new(self, new_data)
- end
+ def force_override=(new_data)
+ reset
+ @force_override = VividMash.new(self, new_data)
+ end
- def automatic=(new_data)
- reset
- @automatic = VividMash.new(self, new_data)
- end
+ def automatic=(new_data)
+ reset
+ @automatic = VividMash.new(self, new_data)
+ end
#
# Deleting attributes
#
# clears attributes from all precedence levels
- def rm(*args)
- reset(args[0])
- # just easier to compute our retval, rather than collect+merge sub-retvals
- ret = args.inject(merged_attributes) do |attr, arg|
- if attr.nil? || !attr.respond_to?(:[])
- nil
- else
- begin
- attr[arg]
- rescue TypeError
- raise TypeError, "Wrong type in index of attribute (did you use a Hash index on an Array?)"
- end
- end
- end
- rm_default(*args)
- rm_normal(*args)
- rm_override(*args)
- ret
- end
+ def rm(*args)
+ reset(args[0])
+ # just easier to compute our retval, rather than collect+merge sub-retvals
+ ret = args.inject(merged_attributes) do |attr, arg|
+ if attr.nil? || !attr.respond_to?(:[])
+ nil
+ else
+ begin
+ attr[arg]
+ rescue TypeError
+ raise TypeError, "Wrong type in index of attribute (did you use a Hash index on an Array?)"
+ end
+ end
+ end
+ rm_default(*args)
+ rm_normal(*args)
+ rm_override(*args)
+ ret
+ end
# does <level>['foo']['bar'].delete('baz')
- def remove_from_precedence_level(level, *args, key)
- multimash = level.element(*args)
- multimash.nil? ? nil : multimash.delete(key)
- end
+ def remove_from_precedence_level(level, *args, key)
+ multimash = level.element(*args)
+ multimash.nil? ? nil : multimash.delete(key)
+ end
- private :remove_from_precedence_level
+ private :remove_from_precedence_level
# clears attributes from all default precedence levels
#
# equivalent to: force_default!['foo']['bar'].delete('baz')
- def rm_default(*args)
- reset(args[0])
- remove_from_precedence_level(force_default!(autovivify: false), *args)
- end
+ def rm_default(*args)
+ reset(args[0])
+ remove_from_precedence_level(force_default!(autovivify: false), *args)
+ end
# clears attributes from normal precedence
#
# equivalent to: normal!['foo']['bar'].delete('baz')
- def rm_normal(*args)
- reset(args[0])
- remove_from_precedence_level(normal!(autovivify: false), *args)
- end
+ def rm_normal(*args)
+ reset(args[0])
+ remove_from_precedence_level(normal!(autovivify: false), *args)
+ end
# clears attributes from all override precedence levels
#
# equivalent to: force_override!['foo']['bar'].delete('baz')
- def rm_override(*args)
- reset(args[0])
- remove_from_precedence_level(force_override!(autovivify: false), *args)
- end
+ def rm_override(*args)
+ reset(args[0])
+ remove_from_precedence_level(force_override!(autovivify: false), *args)
+ end
#
# Replacing attributes without merging
#
# sets default attributes without merging
- def default!(opts={})
- # FIXME: do not flush whole cache
- reset
- MultiMash.new(self, @default, [], opts)
- end
+ def default!(opts = {})
+ # FIXME: do not flush whole cache
+ reset
+ MultiMash.new(self, @default, [], opts)
+ end
# sets normal attributes without merging
- def normal!(opts={})
- # FIXME: do not flush whole cache
- reset
- MultiMash.new(self, @normal, [], opts)
- end
+ def normal!(opts = {})
+ # FIXME: do not flush whole cache
+ reset
+ MultiMash.new(self, @normal, [], opts)
+ end
# sets override attributes without merging
- def override!(opts={})
- # FIXME: do not flush whole cache
- reset
- MultiMash.new(self, @override, [], opts)
- end
+ def override!(opts = {})
+ # FIXME: do not flush whole cache
+ reset
+ MultiMash.new(self, @override, [], opts)
+ end
# clears from all default precedence levels and then sets force_default
- def force_default!(opts={})
- # FIXME: do not flush whole cache
- reset
- MultiMash.new(self, @force_default, [@default, @env_default, @role_default], opts)
- end
+ def force_default!(opts = {})
+ # FIXME: do not flush whole cache
+ reset
+ MultiMash.new(self, @force_default, [@default, @env_default, @role_default], opts)
+ end
# clears from all override precedence levels and then sets force_override
- def force_override!(opts={})
- # FIXME: do not flush whole cache
- reset
- MultiMash.new(self, @force_override, [@override, @env_override, @role_override], opts)
- end
+ def force_override!(opts = {})
+ # FIXME: do not flush whole cache
+ reset
+ MultiMash.new(self, @force_override, [@override, @env_override, @role_override], opts)
+ end
#
# Accessing merged attributes.
@@ -419,75 +419,75 @@ class Chef
# all of node['foo'] even if the user only requires node['foo']['bar']['baz'].
#
- def merged_attributes(*path)
- # immutablize(
- merge_all(path)
- # )
- end
-
- def combined_override(*path)
- immutablize(merge_overrides(path))
- end
-
- def combined_default(*path)
- immutablize(merge_defaults(path))
- end
-
- def [](key)
- if deep_merge_cache.has_key?(key.to_s)
- # return the cache of the deep merged values by top-level key
- deep_merge_cache[key.to_s]
- else
- # save all the work of computing node[key]
- deep_merge_cache[key.to_s] = merged_attributes(key)
- end
- end
-
- def []=(key, value)
- raise Exceptions::ImmutableAttributeModification
- end
-
- def has_key?(key)
- COMPONENTS.any? do |component_ivar|
- instance_variable_get(component_ivar).has_key?(key)
- end
- end
-
- alias :attribute? :has_key?
- alias :member? :has_key?
- alias :include? :has_key?
- alias :key? :has_key?
-
- alias :each_attribute :each
-
- def method_missing(symbol, *args)
- if args.empty?
- if key?(symbol)
- self[symbol]
- else
- raise NoMethodError, "Undefined method or attribute `#{symbol}' on `node'"
- end
- elsif symbol.to_s =~ /=$/
- key_to_set = symbol.to_s[/^(.+)=$/, 1]
- self[key_to_set] = (args.length == 1 ? args[0] : args)
- else
- raise NoMethodError, "Undefined node attribute or method `#{symbol}' on `node'"
- end
- end
-
- def to_s
- merged_attributes.to_s
- end
-
- def inspect
- "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map{|iv|
- "#{iv}=#{instance_variable_get(iv).inspect}"
- }.join(", ") << ">"
- end
-
- def set_unless?
- @set_unless_present
- end
+ def merged_attributes(*path)
+ # immutablize(
+ merge_all(path)
+ # )
+ end
+
+ def combined_override(*path)
+ immutablize(merge_overrides(path))
+ end
+
+ def combined_default(*path)
+ immutablize(merge_defaults(path))
+ end
+
+ def [](key)
+ if deep_merge_cache.has_key?(key.to_s)
+ # return the cache of the deep merged values by top-level key
+ deep_merge_cache[key.to_s]
+ else
+ # save all the work of computing node[key]
+ deep_merge_cache[key.to_s] = merged_attributes(key)
+ end
+ end
+
+ def []=(key, value)
+ raise Exceptions::ImmutableAttributeModification
+ end
+
+ def has_key?(key)
+ COMPONENTS.any? do |component_ivar|
+ instance_variable_get(component_ivar).has_key?(key)
+ end
+ end
+
+ alias :attribute? :has_key?
+ alias :member? :has_key?
+ alias :include? :has_key?
+ alias :key? :has_key?
+
+ alias :each_attribute :each
+
+ def method_missing(symbol, *args)
+ if args.empty?
+ if key?(symbol)
+ self[symbol]
+ else
+ raise NoMethodError, "Undefined method or attribute `#{symbol}' on `node'"
+ end
+ elsif symbol.to_s =~ /=$/
+ key_to_set = symbol.to_s[/^(.+)=$/, 1]
+ self[key_to_set] = (args.length == 1 ? args[0] : args)
+ else
+ raise NoMethodError, "Undefined node attribute or method `#{symbol}' on `node'"
+ end
+ end
+
+ def to_s
+ merged_attributes.to_s
+ end
+
+ def inspect
+ "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map{|iv|
+ "#{iv}=#{instance_variable_get(iv).inspect}"
+ }.join(", ") << ">"
+ end
+
+ def set_unless?
+ @set_unless_present
+ end
private
@@ -501,32 +501,32 @@ class Chef
# raise any TypeError if it attempts to apply a hash key to an Integer/String/TrueClass, and just returns
# nil in that case.
#
- def apply_path(component, path)
- path ||= []
- path.inject(component) do |val, path_arg|
- if val.respond_to?(:[])
- # Have an Array-like or Hash-like thing
- if !val.respond_to?(:has_key?)
- # Have an Array-like thing
- val[path_arg]
- elsif val.has_key?(path_arg)
- # Hash-like thing (must check has_key? first to protect against Autovivification)
- val[path_arg]
- else
- nil
- end
- else
- nil
- end
- end
- end
+ def apply_path(component, path)
+ path ||= []
+ path.inject(component) do |val, path_arg|
+ if val.respond_to?(:[])
+ # Have an Array-like or Hash-like thing
+ if !val.respond_to?(:has_key?)
+ # Have an Array-like thing
+ val[path_arg]
+ elsif val.has_key?(path_arg)
+ # Hash-like thing (must check has_key? first to protect against Autovivification)
+ val[path_arg]
+ else
+ nil
+ end
+ else
+ nil
+ end
+ end
+ end
# For elements like Fixnums, true, nil...
- def safe_dup(e)
- e.dup
- rescue TypeError
- e
- end
+ def safe_dup(e)
+ e.dup
+ rescue TypeError
+ e
+ end
# Deep merge all attribute levels using hash-only merging between different precidence
# levels (so override arrays completely replace arrays set at any default level).
@@ -535,24 +535,24 @@ class Chef
#
# @param path [Array] Array of args to method chain to descend into the node object
# @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
- def merge_all(path)
- components = [
- merge_defaults(path),
- apply_path(@normal, path),
- merge_overrides(path),
- apply_path(@automatic, path),
- ]
-
- components.map! do |component|
- safe_dup(component)
- end
+ def merge_all(path)
+ components = [
+ merge_defaults(path),
+ apply_path(@normal, path),
+ merge_overrides(path),
+ apply_path(@automatic, path),
+ ]
- return nil if components.compact.empty?
+ components.map! do |component|
+ safe_dup(component)
+ end
- components.inject(ImmutableMash.new({})) do |merged, component|
- Chef::Mixin::DeepMerge.hash_only_merge!(merged, component)
- end
- end
+ return nil if components.compact.empty?
+
+ components.inject(ImmutableMash.new({})) do |merged, component|
+ Chef::Mixin::DeepMerge.hash_only_merge!(merged, component)
+ end
+ end
# Deep merge the default attribute levels with array merging.
#
@@ -560,12 +560,12 @@ class Chef
#
# @param path [Array] Array of args to method chain to descend into the node object
# @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
- def merge_defaults(path)
- DEFAULT_COMPONENTS.inject(nil) do |merged, component_ivar|
- component_value = apply_path(instance_variable_get(component_ivar), path)
- Chef::Mixin::DeepMerge.deep_merge(component_value, merged)
- end
- end
+ def merge_defaults(path)
+ DEFAULT_COMPONENTS.inject(nil) do |merged, component_ivar|
+ component_value = apply_path(instance_variable_get(component_ivar), path)
+ Chef::Mixin::DeepMerge.deep_merge(component_value, merged)
+ end
+ end
# Deep merge the override attribute levels with array merging.
#
@@ -573,12 +573,12 @@ class Chef
#
# @param path [Array] Array of args to method chain to descend into the node object
# @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
- def merge_overrides(path)
- OVERRIDE_COMPONENTS.inject(nil) do |merged, component_ivar|
- component_value = apply_path(instance_variable_get(component_ivar), path)
- Chef::Mixin::DeepMerge.deep_merge(component_value, merged)
- end
- end
+ def merge_overrides(path)
+ OVERRIDE_COMPONENTS.inject(nil) do |merged, component_ivar|
+ component_value = apply_path(instance_variable_get(component_ivar), path)
+ Chef::Mixin::DeepMerge.deep_merge(component_value, merged)
+ end
+ end
end
diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb
index c52582a520..68f3a69756 100644
--- a/lib/chef/node/attribute_collections.rb
+++ b/lib/chef/node/attribute_collections.rb
@@ -82,7 +82,7 @@ class Chef
end
def dup
- Array.new(map {|e| safe_dup(e)})
+ Array.new(map { |e| safe_dup(e) })
end
end
@@ -130,7 +130,7 @@ class Chef
end
end
- def initialize(root, data={})
+ def initialize(root, data = {})
@root = root
super(data)
end
@@ -241,7 +241,7 @@ class Chef
# Initialize with an array of mashes. For the delete return value to work
# properly the mashes must come from the same attribute level (i.e. all
# override or all default, but not a mix of both).
- def initialize(root, primary_mash, mashes, opts={})
+ def initialize(root, primary_mash, mashes, opts = {})
@root = root
@primary_mash = primary_mash
@mashes = mashes
diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb
index c092c8cacc..b5fd86fa72 100644
--- a/lib/chef/node/immutable_collections.rb
+++ b/lib/chef/node/immutable_collections.rb
@@ -88,7 +88,7 @@ class Chef
end
def dup
- Array.new(map {|e| safe_dup(e)})
+ Array.new(map { |e| safe_dup(e) })
end
def to_a
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index 99e4e2dbf9..5eac63d380 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -49,7 +49,7 @@ class Chef
# our place in it (just before the first value with the same preference level).
insert_at = nil
map[key] ||= []
- map[key].each_with_index do |matcher,index|
+ map[key].each_with_index do |matcher, index|
cmp = compare_matchers(key, new_matcher, matcher)
insert_at ||= index if cmp && cmp <= 0
end
@@ -145,16 +145,16 @@ class Chef
value = node[attribute]
filter_values.empty? ||
- Array(filter_values).any? do |v|
- Chef::VersionConstraint::Platform.new(v).include?(value)
- end
+ Array(filter_values).any? do |v|
+ Chef::VersionConstraint::Platform.new(v).include?(value)
+ end
end
def filters_match?(node, filters)
matches_black_white_list?(node, filters, :os) &&
- matches_black_white_list?(node, filters, :platform_family) &&
- matches_black_white_list?(node, filters, :platform) &&
- matches_version_list?(node, filters, :platform_version)
+ matches_black_white_list?(node, filters, :platform_family) &&
+ matches_black_white_list?(node, filters, :platform) &&
+ matches_version_list?(node, filters, :platform_version)
end
def block_matches?(node, block)
diff --git a/lib/chef/null_logger.rb b/lib/chef/null_logger.rb
index aae503c9da..927cfc0c08 100644
--- a/lib/chef/null_logger.rb
+++ b/lib/chef/null_logger.rb
@@ -42,7 +42,7 @@ class Chef
def debug(message, &block)
end
- def add(severity, message=nil, progname=nil)
+ def add(severity, message = nil, progname = nil)
end
def <<(message)
diff --git a/lib/chef/org.rb b/lib/chef/org.rb
index ee4451fac0..a148e37aea 100644
--- a/lib/chef/org.rb
+++ b/lib/chef/org.rb
@@ -38,22 +38,22 @@ class Chef
@chef_rest ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root])
end
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(:name, arg,
:regex => /^[a-z0-9\-_]+$/)
end
- def full_name(arg=nil)
+ def full_name(arg = nil)
set_or_return(:full_name,
arg, :kind_of => String)
end
- def private_key(arg=nil)
+ def private_key(arg = nil)
set_or_return(:private_key,
arg, :kind_of => String)
end
- def guid(arg=nil)
+ def guid(arg = nil)
set_or_return(:guid,
arg, :kind_of => String)
end
@@ -73,13 +73,13 @@ class Chef
end
def create
- payload = {:name => self.name, :full_name => self.full_name}
+ payload = { :name => self.name, :full_name => self.full_name }
new_org = chef_rest.post("organizations", payload)
Chef::Org.from_hash(self.to_hash.merge(new_org))
end
def update
- payload = {:name => self.name, :full_name => self.full_name}
+ payload = { :name => self.name, :full_name => self.full_name }
new_org = chef_rest.put("organizations/#{name}", payload)
Chef::Org.from_hash(self.to_hash.merge(new_org))
end
@@ -101,7 +101,7 @@ class Chef
end
def associate_user(username)
- request_body = {:user => username}
+ request_body = { :user => username }
response = chef_rest.post "organizations/#{@name}/association_requests", request_body
association_id = response["uri"].split("/").last
chef_rest.put "users/#{username}/association_requests/#{association_id}", { :response => "accept" }
@@ -130,11 +130,11 @@ class Chef
end
def self.load(org_name)
- response = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("organizations/#{org_name}")
+ response = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("organizations/#{org_name}")
Chef::Org.from_hash(response)
end
- def self.list(inflate=false)
+ def self.list(inflate = false)
orgs = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("organizations")
if inflate
orgs.inject({}) do |org_map, (name, _url)|
diff --git a/lib/chef/platform/provider_mapping.rb b/lib/chef/platform/provider_mapping.rb
index 478ed55385..39d415e590 100644
--- a/lib/chef/platform/provider_mapping.rb
+++ b/lib/chef/platform/provider_mapping.rb
@@ -45,7 +45,7 @@ class Chef
end
if platforms.has_key?(name_sym)
- platform_versions = platforms[name_sym].select {|k, v| k != :default }
+ platform_versions = platforms[name_sym].select { |k, v| k != :default }
if platforms[name_sym].has_key?(:default)
provider_map.merge!(platforms[name_sym][:default])
end
@@ -89,7 +89,7 @@ class Chef
return platform, version
end
- def provider_for_resource(resource, action=:nothing)
+ def provider_for_resource(resource, action = :nothing)
node = resource.run_context && resource.run_context.node
raise ArgumentError, "Cannot find the provider for a resource with no run context set" unless node
provider = find_provider_for_node(node, resource).new(resource, resource.run_context)
@@ -183,31 +183,31 @@ class Chef
private
- def explicit_provider(platform, version, resource_type)
- resource_type.kind_of?(Chef::Resource) ? resource_type.provider : nil
- end
+ def explicit_provider(platform, version, resource_type)
+ resource_type.kind_of?(Chef::Resource) ? resource_type.provider : nil
+ end
- def platform_provider(platform, version, resource_type)
- pmap = Chef::Platform.find(platform, version)
- rtkey = resource_type.kind_of?(Chef::Resource) ? resource_type.resource_name.to_sym : resource_type
- pmap.has_key?(rtkey) ? pmap[rtkey] : nil
- end
+ def platform_provider(platform, version, resource_type)
+ pmap = Chef::Platform.find(platform, version)
+ rtkey = resource_type.kind_of?(Chef::Resource) ? resource_type.resource_name.to_sym : resource_type
+ pmap.has_key?(rtkey) ? pmap[rtkey] : nil
+ end
- include Chef::Mixin::ConvertToClassName
+ include Chef::Mixin::ConvertToClassName
- def resource_matching_provider(platform, version, resource_type)
- if resource_type.kind_of?(Chef::Resource)
- class_name = resource_type.class.name ? resource_type.class.name.split("::").last :
- convert_to_class_name(resource_type.resource_name.to_s)
+ def resource_matching_provider(platform, version, resource_type)
+ if resource_type.kind_of?(Chef::Resource)
+ class_name = resource_type.class.name ? resource_type.class.name.split("::").last :
+ convert_to_class_name(resource_type.resource_name.to_s)
- if Chef::Provider.const_defined?(class_name)
- Chef::Log.warn("Class Chef::Provider::#{class_name} does not declare 'provides #{convert_to_snake_case(class_name).to_sym.inspect}'.")
- Chef::Log.warn("This will no longer work in Chef 13: you must use 'provides' to use the resource's DSL.")
- return Chef::Provider.const_get(class_name)
- end
+ if Chef::Provider.const_defined?(class_name)
+ Chef::Log.warn("Class Chef::Provider::#{class_name} does not declare 'provides #{convert_to_snake_case(class_name).to_sym.inspect}'.")
+ Chef::Log.warn("This will no longer work in Chef 13: you must use 'provides' to use the resource's DSL.")
+ return Chef::Provider.const_get(class_name)
end
- nil
end
+ nil
+ end
end
end
diff --git a/lib/chef/platform/query_helpers.rb b/lib/chef/platform/query_helpers.rb
index 7a92fd3300..7d522072a3 100644
--- a/lib/chef/platform/query_helpers.rb
+++ b/lib/chef/platform/query_helpers.rb
@@ -99,7 +99,6 @@ class Chef
metadata = cmdlet.run!.return_value
metadata["RefreshMode"] == "Disabled"
end
-
def supported_powershell_version?(node, version_string)
return false unless node[:languages] && node[:languages][:powershell]
diff --git a/lib/chef/platform/rebooter.rb b/lib/chef/platform/rebooter.rb
index 622f35a5db..c678b60dd1 100644
--- a/lib/chef/platform/rebooter.rb
+++ b/lib/chef/platform/rebooter.rb
@@ -32,7 +32,7 @@ class Chef
cmd = if Chef::Platform.windows?
# should this do /f as well? do we then need a minimum delay to let apps quit?
- "shutdown /r /t #{reboot_info[:delay_mins]*60} /c \"#{reboot_info[:reason]}\""
+ "shutdown /r /t #{reboot_info[:delay_mins] * 60} /c \"#{reboot_info[:reason]}\""
else
# probably Linux-only.
"shutdown -r +#{reboot_info[:delay_mins]} \"#{reboot_info[:reason]}\""
diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb
index 13d710eefe..87b87d4c72 100644
--- a/lib/chef/platform/service_helpers.rb
+++ b/lib/chef/platform/service_helpers.rb
@@ -99,7 +99,7 @@ class Chef
def systemd_is_init?
::File.exist?(Chef.path_to("/proc/1/comm")) &&
- ::File.open(Chef.path_to("/proc/1/comm")).gets.chomp == "systemd"
+ ::File.open(Chef.path_to("/proc/1/comm")).gets.chomp == "systemd"
end
def has_systemd_service_unit?(svc_name)
diff --git a/lib/chef/policy_builder/dynamic.rb b/lib/chef/policy_builder/dynamic.rb
index c6c7deeee6..22438a1e0f 100644
--- a/lib/chef/policy_builder/dynamic.rb
+++ b/lib/chef/policy_builder/dynamic.rb
@@ -149,9 +149,9 @@ class Chef
# testing purposes; production code should call #load_node instead.
def select_implementation(node)
if policyfile_set_in_config? ||
- policyfile_attribs_in_node_json? ||
- node_has_policyfile_attrs?(node) ||
- policyfile_compat_mode_config?
+ policyfile_attribs_in_node_json? ||
+ node_has_policyfile_attrs?(node) ||
+ policyfile_compat_mode_config?
@implementation = Policyfile.new(node_name, ohai_data, json_attribs, override_runlist, events)
else
@implementation = ExpandNodeObject.new(node_name, ohai_data, json_attribs, override_runlist, events)
diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb
index f71036e4d1..b69ecfe6a8 100644
--- a/lib/chef/policy_builder/expand_node_object.rb
+++ b/lib/chef/policy_builder/expand_node_object.rb
@@ -68,7 +68,7 @@ class Chef
Chef.set_run_context(run_context)
end
- def setup_run_context(specific_recipes=nil)
+ def setup_run_context(specific_recipes = nil)
if Chef::Config[:solo]
Chef::Cookbook::FileVendor.fetch_from_disk(Chef::Config[:cookbook_path])
cl = Chef::CookbookLoader.new(Chef::Config[:cookbook_path])
@@ -198,7 +198,7 @@ class Chef
begin
events.cookbook_resolution_start(@expanded_run_list_with_versions)
cookbook_hash = api_service.post("environments/#{node.chef_environment}/cookbook_versions",
- {:run_list => @expanded_run_list_with_versions})
+ { :run_list => @expanded_run_list_with_versions })
cookbook_hash = cookbook_hash.inject({}) do |memo, (key, value)|
memo[key] = Chef::CookbookVersion.from_hash(value)
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb
index 1c0db91366..9a6e62bc5d 100644
--- a/lib/chef/policy_builder/policyfile.rb
+++ b/lib/chef/policy_builder/policyfile.rb
@@ -136,7 +136,6 @@ class Chef
Chef::Log.info("Run List is [#{run_list}]")
Chef::Log.info("Run List expands to [#{run_list_with_versions_for_display.join(', ')}]")
-
events.node_load_completed(node, run_list_with_versions_for_display, Chef::Config)
node
@@ -149,7 +148,7 @@ class Chef
# run.
#
# @return [Chef::RunContext]
- def setup_run_context(specific_recipes=nil)
+ def setup_run_context(specific_recipes = nil)
Chef::Cookbook::FileVendor.fetch_from_remote(http_api)
sync_cookbooks
cookbook_collection = Chef::CookbookCollection.new(cookbooks_to_sync)
@@ -258,7 +257,7 @@ class Chef
named_run_list or
raise ConfigurationError,
"Policy '#{retrieved_policy_name}' revision '#{revision_id}' does not have named_run_list '#{named_run_list_name}'" +
- "(available named_run_lists: [#{available_named_run_lists.join(', ')}])"
+ "(available named_run_lists: [#{available_named_run_lists.join(', ')}])"
else
policy["run_list"]
end
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index d7ef19ee3d..8198dd6700 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -87,12 +87,11 @@ class Chef
# is fully initialized.
#
def initialize(**options)
- options.each { |k,v| options[k.to_sym] = v; options.delete(k) if k.is_a?(String) }
+ options.each { |k, v| options[k.to_sym] = v; options.delete(k) if k.is_a?(String) }
@options = options
options[:name] = options[:name].to_sym if options[:name]
options[:instance_variable_name] = options[:instance_variable_name].to_sym if options[:instance_variable_name]
-
# Replace name_attribute with name_property
if options.has_key?(:name_attribute)
# If we have both name_attribute and name_property and they differ, raise an error
@@ -100,7 +99,7 @@ class Chef
raise ArgumentError, "Cannot specify both name_property and name_attribute together on property #{self}."
end
# replace name_property with name_attribute in place
- options = Hash[options.map { |k,v| k == :name_attribute ? [ :name_property, v ] : [ k,v ] }]
+ options = Hash[options.map { |k, v| k == :name_attribute ? [ :name_property, v ] : [ k, v ] }]
@options = options
end
@@ -233,8 +232,8 @@ class Chef
# @return [Hash<Symbol,Object>]
#
def validation_options
- @validation_options ||= options.reject { |k,v|
- [:declared_in,:name,:instance_variable_name,:desired_state,:identity,:default,:name_property,:coerce,:required].include?(k)
+ @validation_options ||= options.reject { |k, v|
+ [:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required].include?(k)
}
end
@@ -258,7 +257,7 @@ class Chef
# will be returned without running, validating or coercing. If it is a
# `get`, the non-lazy, coerced, validated value will always be returned.
#
- def call(resource, value=NOT_PASSED)
+ def call(resource, value = NOT_PASSED)
if value == NOT_PASSED
return get(resource)
end
@@ -342,7 +341,7 @@ class Chef
resource.enclosing_provider &&
resource.enclosing_provider.new_resource &&
resource.enclosing_provider.new_resource.respond_to?(name)
- Chef::Log.warn("#{Chef::Log.caller_location}: property #{name} is declared in both #{resource} and #{resource.enclosing_provider}. Use new_resource.#{name} instead. At #{Chef::Log.caller_location}")
+ Chef::Log.warn("#{Chef::Log.caller_location}: property #{name} is declared in both #{resource} and #{resource.enclosing_provider}. Use new_resource.#{name} instead. At #{Chef::Log.caller_location}")
end
if has_default?
@@ -489,7 +488,7 @@ class Chef
if modified_options.has_key?(:name_property) ||
modified_options.has_key?(:name_attribute) ||
modified_options.has_key?(:default)
- options = options.reject { |k,v| k == :name_attribute || k == :name_property || k == :default }
+ options = options.reject { |k, v| k == :name_attribute || k == :name_property || k == :default }
end
self.class.new(options.merge(modified_options))
end
@@ -506,7 +505,7 @@ class Chef
# We prefer this form because the property name won't show up in the
# stack trace if you use `define_method`.
- declared_in.class_eval <<-EOM, __FILE__, __LINE__+1
+ declared_in.class_eval <<-EOM, __FILE__, __LINE__ + 1
def #{name}(value=NOT_PASSED)
raise "Property #{name} of \#{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block_given?
self.class.properties[#{name.inspect}].call(self, value)
@@ -518,7 +517,7 @@ class Chef
EOM
rescue SyntaxError
# If the name is not a valid ruby name, we use define_method.
- declared_in.define_method(name) do |value=NOT_PASSED, &block|
+ declared_in.define_method(name) do |value = NOT_PASSED, &block|
raise "Property #{name} of #{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block
self.class.properties[name].call(self, value)
end
@@ -577,7 +576,7 @@ class Chef
# @api private
def explicitly_accepts_nil?(resource)
options.has_key?(:coerce) ||
- (options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false))
+ (options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false))
end
def get_value(resource)
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index eeef182f73..8bf6842f70 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -112,7 +112,7 @@ class Chef
run_context.events
end
- def run_action(action=nil)
+ def run_action(action = nil)
@action = action unless action.nil?
# TODO: it would be preferable to get the action to be executed in the
@@ -244,7 +244,7 @@ class Chef
true
end
- def self.provides(short_name, opts={}, &block)
+ def self.provides(short_name, opts = {}, &block)
Chef.provider_handler_map.set(short_name, self, opts, &block)
end
diff --git a/lib/chef/provider/apt_update.rb b/lib/chef/provider/apt_update.rb
index 00c3ad16bb..449b298804 100644
--- a/lib/chef/provider/apt_update.rb
+++ b/lib/chef/provider/apt_update.rb
@@ -51,6 +51,7 @@ class Chef
end
private
+
# Determines whether we need to run `apt-get update`
#
# @return [Boolean]
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index 01351603ca..36b67ab6a5 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -67,7 +67,7 @@ class Chef
if cron_found
@current_resource.time($2.to_sym)
@current_resource.command($3)
- cron_found=false
+ cron_found = false
end
when CRON_PATTERN
if cron_found
@@ -77,11 +77,11 @@ class Chef
@current_resource.month($4)
@current_resource.weekday($5)
@current_resource.command($6)
- cron_found=false
+ cron_found = false
end
next
else
- cron_found=false # We've got a Chef comment with no following crontab line
+ cron_found = false # We've got a Chef comment with no following crontab line
next
end
end
diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb
index d53cce1311..7274ab2e8f 100644
--- a/lib/chef/provider/deploy.rb
+++ b/lib/chef/provider/deploy.rb
@@ -56,7 +56,7 @@ class Chef
@shared_path = @new_resource.shared_path
end
- def sudo(command,&block)
+ def sudo(command, &block)
execute(command, &block)
end
@@ -93,7 +93,6 @@ class Chef
a.whyrun("Would assume callback file #{callback_file} included in release")
end
end
-
end
def action_deploy
@@ -175,7 +174,7 @@ class Chef
restart
end
- def callback(what, callback_code=nil)
+ def callback(what, callback_code = nil)
@collection = Chef::ResourceCollection.new
case callback_code
when Proc
@@ -201,7 +200,7 @@ class Chef
converge_by("execute migration command #{@new_resource.migration_command}") do
Chef::Log.info "#{@new_resource} migrating #{@new_resource.user} with environment #{env_info}"
- shell_out!(@new_resource.migration_command,run_options(:cwd=>release_path, :log_level => :info))
+ shell_out!(@new_resource.migration_command, run_options(:cwd => release_path, :log_level => :info))
end
end
end
@@ -221,7 +220,7 @@ class Chef
else
converge_by("restart app using command #{@new_resource.restart_command}") do
Chef::Log.info("#{@new_resource} restarting app")
- shell_out!(@new_resource.restart_command,run_options(:cwd=>@new_resource.current_path))
+ shell_out!(@new_resource.restart_command, run_options(:cwd => @new_resource.current_path))
end
end
end
@@ -391,7 +390,7 @@ class Chef
end
end
- def run_options(run_opts={})
+ def run_options(run_opts = {})
run_opts[:user] = @new_resource.user if @new_resource.user
run_opts[:group] = @new_resource.group if @new_resource.group
run_opts[:environment] = @new_resource.environment if @new_resource.environment
diff --git a/lib/chef/provider/deploy/revision.rb b/lib/chef/provider/deploy/revision.rb
index 0bd30ce762..9e2bb94f5b 100644
--- a/lib/chef/provider/deploy/revision.rb
+++ b/lib/chef/provider/deploy/revision.rb
@@ -56,11 +56,11 @@ class Chef
protected
def release_created(release)
- sorted_releases {|r| r.delete(release); r << release }
+ sorted_releases { |r| r.delete(release); r << release }
end
def release_deleted(release)
- sorted_releases { |r| r.delete(release)}
+ sorted_releases { |r| r.delete(release) }
end
def release_slug
diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb
index 1f6a8f0ef6..eac8a829bd 100644
--- a/lib/chef/provider/dsc_resource.rb
+++ b/lib/chef/provider/dsc_resource.rb
@@ -132,7 +132,7 @@ class Chef
create_reboot_resource if return_dsc_resource_result(result, "RebootRequired")
result.return_value
end
-
+
def add_dsc_verbose_log(result)
# We really want this information from the verbose stream,
# however in some versions of WMF, Invoke-DscResource is not correctly
@@ -148,7 +148,7 @@ class Chef
end
end
- def invoke_resource(method, output_format=:object)
+ def invoke_resource(method, output_format = :object)
properties = translate_type(@new_resource.properties)
switches = "-Method #{method} -Name #{@new_resource.resource}"\
" -Property #{properties} -Verbose"
@@ -160,7 +160,7 @@ class Chef
"Invoke-DscResource #{switches}",
output_format,
)
- cmdlet.run!({}, {:timeout => new_resource.timeout})
+ cmdlet.run!({}, { :timeout => new_resource.timeout })
end
def return_dsc_resource_result(result, property_name)
diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb
index b8686c4450..79769d9773 100644
--- a/lib/chef/provider/dsc_script.rb
+++ b/lib/chef/provider/dsc_script.rb
@@ -37,7 +37,7 @@ class Chef
},
:test => Proc.new { |config_manager, document, shellout_flags|
config_manager.test_configuration(document, shellout_flags)
- }}
+ } }
end
def action_run
@@ -138,7 +138,7 @@ class Chef
@dsc_resource.configuration_data_script
elsif @dsc_resource.configuration_data
configuration_data_path = "#{config_directory}/chef_dsc_config_data.psd1"
- ::File.open(configuration_data_path, "wt") do | script |
+ ::File.open(configuration_data_path, "wt") do |script|
script.write(@dsc_resource.configuration_data)
end
configuration_data_path
@@ -165,7 +165,7 @@ class Chef
if resource.changes_state?
# We ignore the last log message because it only contains the time it took, which looks weird
cleaned_messages = resource.change_log[0..-2].map { |c| c.sub(/^#{Regexp.escape(resource.name)}/, "").strip }
- "converge DSC resource #{resource.name} by #{cleaned_messages.find_all{ |c| c != ''}.join("\n")}"
+ "converge DSC resource #{resource.name} by #{cleaned_messages.find_all { |c| c != '' }.join("\n")}"
else
# This is needed because a dsc script can have resources that are both converged and not
"converge DSC resource #{resource.name} by doing nothing because it is already converged"
diff --git a/lib/chef/provider/env.rb b/lib/chef/provider/env.rb
index fda41aca39..5b252dd344 100644
--- a/lib/chef/provider/env.rb
+++ b/lib/chef/provider/env.rb
@@ -108,15 +108,15 @@ class Chef
not new_values.include?(item)
end.join(@new_resource.delim)
- if new_value.empty?
- return false #nothing left here, delete the key
- else
- old_value = @new_resource.value(new_value)
- create_env
- Chef::Log.debug("#{@new_resource} deleted #{old_value} element")
- @new_resource.updated_by_last_action(true)
- return true #we removed the element and updated; do not delete the key
- end
+ if new_value.empty?
+ return false #nothing left here, delete the key
+ else
+ old_value = @new_resource.value(new_value)
+ create_env
+ Chef::Log.debug("#{@new_resource} deleted #{old_value} element")
+ @new_resource.updated_by_last_action(true)
+ return true #we removed the element and updated; do not delete the key
+ end
end
end
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index fde60ba33f..45f0ad5488 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -40,9 +40,9 @@ class Chef
def define_resource_requirements
# @todo: this should change to raise in some appropriate major version bump.
- if creates && creates_relative? && !cwd
- Chef::Log.warn "Providing a relative path for the creates attribute without the cwd is deprecated and will be changed to fail in the future (CHEF-3819)"
- end
+ if creates && creates_relative? && !cwd
+ Chef::Log.warn "Providing a relative path for the creates attribute without the cwd is deprecated and will be changed to fail in the future (CHEF-3819)"
+ end
end
def timeout
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index 2be01889af..7f85085eeb 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -130,7 +130,7 @@ class Chef
if ::File.exist?(@new_resource.path)
requirements.assert(:delete) do |a|
a.assertion { ::File.writable?(@new_resource.path) }
- a.failure_message(Chef::Exceptions::InsufficientPermissions,"File #{@new_resource.path} exists but is not writable so it cannot be deleted")
+ a.failure_message(Chef::Exceptions::InsufficientPermissions, "File #{@new_resource.path} exists but is not writable so it cannot be deleted")
end
end
@@ -266,7 +266,7 @@ class Chef
else
[ Chef::Exceptions::FileTypeMismatch,
"File #{path} exists, but is a symlink to #{real_path} which is a #{file_type_string(real_path)}. " +
- "Disable manage_symlink_source and set force_unlink to remove it.",
+ "Disable manage_symlink_source and set force_unlink to remove it.",
"Assuming symlink #{path} or source file #{real_path} would have been fixed by a previous resource",
]
end
@@ -464,7 +464,7 @@ class Chef
def short_cksum(checksum)
return "none" if checksum.nil?
- checksum.slice(0,6)
+ checksum.slice(0, 6)
end
def load_resource_attributes_from_file(resource)
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index f197729367..f8a8dabb46 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -53,9 +53,9 @@ class Chef
a.assertion { !(@new_resource.revision =~ /^origin\//) }
a.failure_message Chef::Exceptions::InvalidRemoteGitReference,
"Deploying remote branches is not supported. " +
- "Specify the remote branch as a local branch for " +
- "the git repository you're deploying from " +
- "(ie: '#{@new_resource.revision.gsub('origin/', '')}' rather than '#{@new_resource.revision}')."
+ "Specify the remote branch as a local branch for " +
+ "the git repository you're deploying from " +
+ "(ie: '#{@new_resource.revision.gsub('origin/', '')}' rather than '#{@new_resource.revision}')."
end
requirements.assert(:all_actions) do |a|
@@ -65,8 +65,8 @@ class Chef
a.assertion { target_revision != nil }
a.failure_message Chef::Exceptions::UnresolvableGitReference,
"Unable to parse SHA reference for '#{@new_resource.revision}' in repository '#{@new_resource.repository}'. " +
- "Verify your (case-sensitive) repository URL and revision.\n" +
- "`git ls-remote '#{@new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}"
+ "Verify your (case-sensitive) repository URL and revision.\n" +
+ "`git ls-remote '#{@new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}"
end
end
@@ -86,7 +86,7 @@ class Chef
def action_export
action_checkout
converge_by("complete the export by removing #{@new_resource.destination}.git after checkout") do
- FileUtils.rm_rf(::File.join(@new_resource.destination,".git"))
+ FileUtils.rm_rf(::File.join(@new_resource.destination, ".git"))
end
end
@@ -113,14 +113,14 @@ class Chef
end
def target_dir_non_existent_or_empty?
- !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination).sort == [".",".."]
+ !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination).sort == [".", ".."]
end
def find_current_revision
Chef::Log.debug("#{@new_resource} finding current git revision")
if ::File.exist?(::File.join(cwd, ".git"))
# 128 is returned when we're not in a git repo. this is fine
- result = shell_out!("git rev-parse HEAD", :cwd => cwd, :returns => [0,128]).stdout.strip
+ result = shell_out!("git rev-parse HEAD", :cwd => cwd, :returns => [0, 128]).stdout.strip
end
sha_hash?(result) ? result : nil
end
@@ -189,10 +189,9 @@ class Chef
def setup_remote_tracking_branches(remote_name, remote_url)
converge_by("set up remote tracking branches for #{remote_url} at #{remote_name}") do
- Chef::Log.debug "#{@new_resource} configuring remote tracking branches for repository #{remote_url} "+
- "at remote #{remote_name}"
+ Chef::Log.debug "#{@new_resource} configuring remote tracking branches for repository #{remote_url} " + "at remote #{remote_name}"
check_remote_command = "git config --get remote.#{remote_name}.url"
- remote_status = shell_out!(check_remote_command, run_options(:cwd => @new_resource.destination, :returns => [0,1,2]))
+ remote_status = shell_out!(check_remote_command, run_options(:cwd => @new_resource.destination, :returns => [0, 1, 2]))
case remote_status.exitstatus
when 0, 2
# * Status 0 means that we already have a remote with this name, so we should update the url
@@ -200,7 +199,7 @@ class Chef
# * Status 2 means that we have multiple urls assigned to the same remote (not a good idea)
# which we can fix by replacing them all with our target url (hence the --replace-all option)
- if multiple_remotes?(remote_status) || !remote_matches?(remote_url,remote_status)
+ if multiple_remotes?(remote_status) || !remote_matches?(remote_url, remote_status)
update_remote_url_command = "git config --replace-all remote.#{remote_name}.url #{remote_url}"
shell_out!(update_remote_url_command, run_options(:cwd => @new_resource.destination))
end
@@ -259,7 +258,7 @@ class Chef
found.size == 1 ? found.first[0] : nil
end
- def find_revision(refs, revision, suffix="")
+ def find_revision(refs, revision, suffix = "")
found = refs_search(refs, rev_match_pattern("refs/tags/", revision) + suffix)
found = refs_search(refs, rev_match_pattern("refs/heads/", revision) + suffix) if found.empty?
found = refs_search(refs, revision + suffix) if found.empty?
@@ -293,7 +292,7 @@ class Chef
private
- def run_options(run_opts={})
+ def run_options(run_opts = {})
env = {}
if @new_resource.user
run_opts[:user] = @new_resource.user
@@ -314,7 +313,6 @@ class Chef
env.merge!(@new_resource.environment) if @new_resource.environment
run_opts[:environment] = env unless env.empty?
run_opts
-
end
def cwd
diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb
index 0c98730155..efcbef8014 100644
--- a/lib/chef/provider/group.rb
+++ b/lib/chef/provider/group.rb
@@ -86,7 +86,7 @@ class Chef
# <false>:: If a change is not required
def compare_group
@change_desc = [ ]
- if @new_resource.gid.to_s != @current_resource.gid.to_s
+ if @new_resource.gid.to_s != @current_resource.gid.to_s
@change_desc << "change gid #{@current_resource.gid} to #{@new_resource.gid}"
end
diff --git a/lib/chef/provider/group/aix.rb b/lib/chef/provider/group/aix.rb
index 196ce1345a..4a02d5ef8c 100644
--- a/lib/chef/provider/group/aix.rb
+++ b/lib/chef/provider/group/aix.rb
@@ -69,7 +69,7 @@ class Chef
def set_options
opts = ""
- { :gid => "id" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
+ { :gid => "id" }.sort { |a, b| a[0] <=> b[0] }.each do |field, option|
if @current_resource.send(field) != @new_resource.send(field)
if @new_resource.send(field)
Chef::Log.debug("#{@new_resource} setting #{field} to #{@new_resource.send(field)}")
diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb
index b433d57a03..08661f21b8 100644
--- a/lib/chef/provider/group/dscl.rb
+++ b/lib/chef/provider/group/dscl.rb
@@ -35,8 +35,8 @@ class Chef
def safe_dscl(*args)
result = dscl(*args)
return "" if ( args.first =~ /^delete/ ) && ( result[1].exitstatus != 0 )
- raise(Chef::Exceptions::Group,"dscl error: #{result.inspect}") unless result[1].exitstatus == 0
- raise(Chef::Exceptions::Group,"dscl error: #{result.inspect}") if result[2] =~ /No such key: /
+ raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") unless result[1].exitstatus == 0
+ raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") if result[2] =~ /No such key: /
return result[2]
end
@@ -69,7 +69,7 @@ class Chef
end
# get a free GID greater than 200
- def get_free_gid(search_limit=1000)
+ def get_free_gid(search_limit = 1000)
gid = nil; next_gid_guess = 200
groups_gids = safe_dscl("list /Groups gid")
while(next_gid_guess < search_limit + 200)
@@ -90,8 +90,8 @@ class Chef
end
def set_gid
- @new_resource.gid(get_free_gid) if [nil,""].include? @new_resource.gid
- raise(Chef::Exceptions::Group,"gid is already in use") if gid_used?(@new_resource.gid)
+ @new_resource.gid(get_free_gid) if [nil, ""].include? @new_resource.gid
+ raise(Chef::Exceptions::Group, "gid is already in use") if gid_used?(@new_resource.gid)
safe_dscl("create /Groups/#{@new_resource.group_name} PrimaryGroupID #{@new_resource.gid}")
end
diff --git a/lib/chef/provider/group/groupadd.rb b/lib/chef/provider/group/groupadd.rb
index 8f87054262..bc6b5d0208 100644
--- a/lib/chef/provider/group/groupadd.rb
+++ b/lib/chef/provider/group/groupadd.rb
@@ -113,7 +113,7 @@ class Chef
# <string>:: A string containing the option and then the quoted value
def set_options
opts = ""
- { :gid => "-g" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
+ { :gid => "-g" }.sort { |a, b| a[0] <=> b[0] }.each do |field, option|
if @current_resource.send(field) != @new_resource.send(field)
if @new_resource.send(field)
opts << " #{option} '#{@new_resource.send(field)}'"
diff --git a/lib/chef/provider/group/groupmod.rb b/lib/chef/provider/group/groupmod.rb
index 8169e50595..379d00e286 100644
--- a/lib/chef/provider/group/groupmod.rb
+++ b/lib/chef/provider/group/groupmod.rb
@@ -111,7 +111,7 @@ class Chef
#
# ==== Returns
# <string>:: A string containing the option and then the quoted value
- def set_options(overwrite_gid=false)
+ def set_options(overwrite_gid = false)
opts = ""
if overwrite_gid || @new_resource.gid && (@current_resource.gid != @new_resource.gid)
opts << " -g '#{@new_resource.gid}'"
diff --git a/lib/chef/provider/group/windows.rb b/lib/chef/provider/group/windows.rb
index 3c052cb92a..64b4587487 100644
--- a/lib/chef/provider/group/windows.rb
+++ b/lib/chef/provider/group/windows.rb
@@ -28,7 +28,7 @@ class Chef
provides :group, os: "windows"
- def initialize(new_resource,run_context)
+ def initialize(new_resource, run_context)
super
@net_group = Chef::Util::Windows::NetGroup.new(@new_resource.group_name)
end
diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb
index 9a261b8d79..b52368f472 100644
--- a/lib/chef/provider/http_request.rb
+++ b/lib/chef/provider/http_request.rb
@@ -109,13 +109,13 @@ class Chef
private
- def check_message(message)
- if message.kind_of?(Proc)
- message.call
- else
- message
- end
+ def check_message(message)
+ if message.kind_of?(Proc)
+ message.call
+ else
+ message
end
+ end
end
end
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 50b05304ff..d00d5cd155 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -67,7 +67,7 @@ class Chef
@status.stdout.each_line do |line|
if !line[0..9].strip.empty?
@int_name = line[0..9].strip
- @interfaces[@int_name] = {"hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp }
+ @interfaces[@int_name] = { "hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp }
else
@interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? ($1) : "nil") if line =~ /inet addr:/
@interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? ($1) : "nil") if line =~ /Bcast:/
@@ -193,6 +193,7 @@ class Chef
end
private
+
def add_command
command = "ifconfig #{@new_resource.device} #{@new_resource.target}"
command << " netmask #{@new_resource.mask}" if @new_resource.mask
diff --git a/lib/chef/provider/ifconfig/aix.rb b/lib/chef/provider/ifconfig/aix.rb
index 65c559a150..81164db304 100644
--- a/lib/chef/provider/ifconfig/aix.rb
+++ b/lib/chef/provider/ifconfig/aix.rb
@@ -67,6 +67,7 @@ class Chef
end
private
+
def add_command
# ifconfig changes are temporary, chdev persist across reboots.
raise Chef::Exceptions::Ifconfig, "interface metric attribute cannot be set for :add action" if @new_resource.metric
@@ -88,7 +89,7 @@ class Chef
def hex_to_dec_netmask(netmask)
# example '0xffff0000' -> '255.255.0.0'
dec = netmask[2..3].to_i(16).to_s(10)
- [4,6,8].each { |n| dec = dec + "." + netmask[n..n+1].to_i(16).to_s(10) }
+ [4, 6, 8].each { |n| dec = dec + "." + netmask[n..n + 1].to_i(16).to_s(10) }
dec
end
diff --git a/lib/chef/provider/ifconfig/debian.rb b/lib/chef/provider/ifconfig/debian.rb
index 4752f784ae..872b0db152 100644
--- a/lib/chef/provider/ifconfig/debian.rb
+++ b/lib/chef/provider/ifconfig/debian.rb
@@ -67,7 +67,7 @@ iface <%= @new_resource.device %> inet static
dir.run_action(:create)
new_resource.updated_by_last_action(true) if dir.updated_by_last_action?
# roll our own file_edit resource, this will not get reported until we have a file_edit resource
- interfaces_dot_d_for_regexp = INTERFACES_DOT_D_DIR.gsub(/\./, '\.') # escape dots for the regexp
+ interfaces_dot_d_for_regexp = INTERFACES_DOT_D_DIR.gsub(/\./, '\.') # escape dots for the regexp
regexp = %r{^\s*source\s+#{interfaces_dot_d_for_regexp}/\*\s*$}
unless ::File.exists?(INTERFACES_FILE) && regexp.match(IO.read(INTERFACES_FILE))
converge_by("modifying #{INTERFACES_FILE} to source #{INTERFACES_DOT_D_DIR}") do
diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb
index b8cffee695..116efccaef 100644
--- a/lib/chef/provider/link.rb
+++ b/lib/chef/provider/link.rb
@@ -75,7 +75,7 @@ class Chef
a.assertion do
if @current_resource.to
@current_resource.link_type == @new_resource.link_type and
- (@current_resource.link_type == :symbolic or @current_resource.to != "")
+ (@current_resource.link_type == :symbolic or @current_resource.to != "")
else
true
end
@@ -118,7 +118,7 @@ class Chef
end
if @new_resource.link_type == :symbolic
converge_by("create symlink at #{@new_resource.target_file} to #{@new_resource.to}") do
- file_class.symlink(canonicalize(@new_resource.to),@new_resource.target_file)
+ file_class.symlink(canonicalize(@new_resource.to), @new_resource.target_file)
Chef::Log.debug("#{@new_resource} created #{@new_resource.link_type} link from #{@new_resource.target_file} -> #{@new_resource.to}")
Chef::Log.info("#{@new_resource} created")
end
diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb
index f99dcc1fd3..d047b6913e 100644
--- a/lib/chef/provider/mdadm.rb
+++ b/lib/chef/provider/mdadm.rb
@@ -39,7 +39,7 @@ class Chef
Chef::Log.debug("#{@new_resource} checking for software raid device #{@current_resource.raid_device}")
device_not_found = 4
- mdadm = shell_out!("mdadm --detail --test #{@new_resource.raid_device}", :returns => [0,device_not_found])
+ mdadm = shell_out!("mdadm --detail --test #{@new_resource.raid_device}", :returns => [0, device_not_found])
exists = (mdadm.status == 0)
@current_resource.exists(exists)
end
diff --git a/lib/chef/provider/mount/aix.rb b/lib/chef/provider/mount/aix.rb
index 9df2e63bf4..12f0d67e6b 100644
--- a/lib/chef/provider/mount/aix.rb
+++ b/lib/chef/provider/mount/aix.rb
@@ -42,7 +42,7 @@ class Chef
# lsfs o/p = #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
# search only for current mount point
- shell_out("lsfs -c #{@new_resource.mount_point}").stdout.each_line do | line |
+ shell_out("lsfs -c #{@new_resource.mount_point}").stdout.each_line do |line|
case line
when /^#\s/
next
@@ -61,7 +61,7 @@ class Chef
Chef::Log.debug("Found mount #{device_fstab} to #{@new_resource.mount_point} in /etc/filesystems")
next
when /^#{Regexp.escape(@new_resource.mount_point)}/
- enabled=false
+ enabled = false
Chef::Log.debug("Found conflicting mount point #{@new_resource.mount_point} in /etc/filesystems")
end
end
@@ -167,7 +167,7 @@ class Chef
end
end
::File.open("/etc/filesystems", "w") do |fstab|
- contents.each { |line| fstab.puts line}
+ contents.each { |line| fstab.puts line }
end
else
Chef::Log.debug("#{@new_resource} is not enabled - nothing to do")
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index 0daacbf96d..f8b8684a1b 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -170,7 +170,7 @@ class Chef
found = false
::File.readlines("/etc/fstab").reverse_each do |line|
if !found && line =~ /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}\s/
- found = true
+ found = true
Chef::Log.debug("#{@new_resource} is removed from fstab")
next
else
@@ -179,7 +179,7 @@ class Chef
end
::File.open("/etc/fstab", "w") do |fstab|
- contents.reverse_each { |line| fstab.puts line}
+ contents.reverse_each { |line| fstab.puts line }
end
else
Chef::Log.debug("#{@new_resource} is not enabled - nothing to do")
@@ -237,13 +237,13 @@ class Chef
def device_mount_regex
if network_device?
# ignore trailing slash
- Regexp.escape(device_real)+"/?"
+ Regexp.escape(device_real) + "/?"
elsif ::File.symlink?(device_real)
# This regular expression tries to match device_real. If that does not match it will try to match the target of device_real.
# So given a symlink like this:
# /dev/mapper/vgroot-tmp.vol -> /dev/dm-9
# First it will try to match "/dev/mapper/vgroot-tmp.vol". If there is no match it will try matching for "/dev/dm-9".
- "(?:#{Regexp.escape(device_real)}|#{Regexp.escape(::File.expand_path(::File.readlink(device_real),::File.dirname(device_real)))})"
+ "(?:#{Regexp.escape(device_real)}|#{Regexp.escape(::File.expand_path(::File.readlink(device_real), ::File.dirname(device_real)))})"
else
Regexp.escape(device_real)
end
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index 4d2381b6d8..a5a7a327cb 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -236,7 +236,7 @@ class Chef
found = false
::File.readlines(VFSTAB).reverse_each do |line|
if !found && line =~ /^#{device_regex}\s+\S+\s+#{Regexp.escape(mount_point)}/
- found = true
+ found = true
Chef::Log.debug("#{new_resource} is removed from vfstab")
next
end
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index 2f5454ac15..e93d29bd1f 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -51,7 +51,7 @@ class Chef
@new_profile_identifier = @new_profile_hash["PayloadIdentifier"]
else
@new_profile_identifier = @new_resource.identifier ||
- @new_resource.profile_name
+ @new_resource.profile_name
end
if all_profiles.empty?
@@ -62,7 +62,6 @@ class Chef
end
end
@current_resource.profile(current_profile)
-
end
def define_resource_requirements
@@ -70,15 +69,15 @@ class Chef
if @new_profile_identifier
a.assertion {
!@new_profile_identifier.nil? and
- !@new_profile_identifier.end_with?(".mobileconfig") and
- /^\w+(?:\.\w+)+$/.match(@new_profile_identifier)
+ !@new_profile_identifier.end_with?(".mobileconfig") and
+ /^\w+(?:\.\w+)+$/.match(@new_profile_identifier)
}
a.failure_message RuntimeError, "when removing using the identifier attribute, it must match the profile identifier"
else
- new_profile_name = @new_resource.profile_name
+ new_profile_name = @new_resource.profile_name
a.assertion {
!new_profile_name.end_with?(".mobileconfig") and
- /^\w+(?:\.\w+)+$/.match(new_profile_name)
+ /^\w+(?:\.\w+)+$/.match(new_profile_name)
}
a.failure_message RuntimeError, "When removing by resource name, it must match the profile identifier "
end
@@ -206,7 +205,7 @@ class Chef
shellout_results.exitstatus
end
- def get_installed_profiles(update=nil)
+ def get_installed_profiles(update = nil)
if update
node.run_state[:config_profiles] = query_installed_profiles
else
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index a051a5fedd..ca9b526920 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -74,7 +74,7 @@ class Chef
# not, but as with the above comment, we don't yet enforce such a thing,
# so we'll just leave things as-is for now.
requirements.assert(:upgrade, :install) do |a|
- a.assertion { candidates_exist_for_all_uninstalled? || new_resource.source }
+ a.assertion { candidates_exist_for_all_uninstalled? || new_resource.source }
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}")
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
end
@@ -147,7 +147,7 @@ class Chef
def action_remove
if removing_package?
- description = @new_resource.version ? "version #{@new_resource.version} of " : ""
+ description = @new_resource.version ? "version #{@new_resource.version} of " : ""
converge_by("remove #{description}package #{@current_resource.package_name}") do
multipackage_api_adapter(@current_resource.package_name, @new_resource.version) do |name, version|
remove_package(name, version)
@@ -558,7 +558,7 @@ class Chef
# @param args [String] variable number of string arguments
# @return [String] nicely concatenated string or empty string
def a_to_s(*args)
- args.reject {|i| i.nil? || i == "" }.join(" ")
+ args.reject { |i| i.nil? || i == "" }.join(" ")
end
end
end
diff --git a/lib/chef/provider/package/aix.rb b/lib/chef/provider/package/aix.rb
index 732ca00b71..a1709c4af7 100644
--- a/lib/chef/provider/package/aix.rb
+++ b/lib/chef/provider/package/aix.rb
@@ -53,7 +53,7 @@ class Chef
if @package_source_found
Chef::Log.debug("#{@new_resource} checking pkg status")
ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
- ret.stdout.each_line do | line |
+ ret.stdout.each_line do |line|
case line
when /#{@new_resource.package_name}:/
fields = line.split(":")
@@ -66,7 +66,7 @@ class Chef
Chef::Log.debug("#{@new_resource} checking install state")
ret = shell_out_with_timeout("lslpp -lcq #{@current_resource.package_name}")
- ret.stdout.each_line do | line |
+ ret.stdout.each_line do |line|
case line
when /#{@current_resource.package_name}/
fields = line.split(":")
@@ -85,7 +85,7 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
- ret.stdout.each_line do | line |
+ ret.stdout.each_line do |line|
case line
when /\w:#{Regexp.escape(@new_resource.package_name)}:(.*)/
fields = line.split(":")
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb
index 0d320a3aad..14613b0218 100644
--- a/lib/chef/provider/package/chocolatey.rb
+++ b/lib/chef/provider/package/chocolatey.rb
@@ -63,7 +63,7 @@ EOS
# and not a package specific alternate source like other providers
# so we want to assert candidates exist for the alternate source
requirements.assert(:upgrade, :install) do |a|
- a.assertion { candidates_exist_for_all_uninstalled? }
+ a.assertion { candidates_exist_for_all_uninstalled? }
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}")
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
end
@@ -84,8 +84,8 @@ EOS
def install_package(names, versions)
name_versions_to_install = desired_name_versions.select { |n, v| lowercase_names(names).include?(n) }
- name_nil_versions = name_versions_to_install.select { |n,v| v.nil? }
- name_has_versions = name_versions_to_install.reject { |n,v| v.nil? }
+ name_nil_versions = name_versions_to_install.select { |n, v| v.nil? }
+ name_has_versions = name_versions_to_install.reject { |n, v| v.nil? }
# choco does not support installing multiple packages with version pins
name_has_versions.each do |name, version|
@@ -106,8 +106,8 @@ EOS
def upgrade_package(names, versions)
name_versions_to_install = desired_name_versions.select { |n, v| lowercase_names(names).include?(n) }
- name_nil_versions = name_versions_to_install.select { |n,v| v.nil? }
- name_has_versions = name_versions_to_install.reject { |n,v| v.nil? }
+ name_nil_versions = name_versions_to_install.select { |n, v| v.nil? }
+ name_has_versions = name_versions_to_install.reject { |n, v| v.nil? }
# choco does not support installing multiple packages with version pins
name_has_versions.each do |name, version|
@@ -220,7 +220,7 @@ EOS
# @param args [String] variable number of string arguments
# @return [String] nicely concatenated string or empty string
def args_to_string(*args)
- args.reject {|i| i.nil? || i == "" }.join(" ")
+ args.reject { |i| i.nil? || i == "" }.join(" ")
end
# Available packages in chocolatey as a Hash of names mapped to versions
diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb
index f57b779ffa..a5a80e14d6 100644
--- a/lib/chef/provider/package/dpkg.rb
+++ b/lib/chef/provider/package/dpkg.rb
@@ -145,14 +145,14 @@ class Chef
#
# @return [Boolean] True if all sources exist
def source_files_exist?
- resolved_source_array.all? {|s| s && ::File.exist?(s) }
+ resolved_source_array.all? { |s| s && ::File.exist?(s) }
end
# Helper to return all the nanes of the missing sources for error messages.
#
# @return [Array<String>] Array of missing sources
def missing_sources
- resolved_source_array.select {|s| s.nil? || !::File.exist?(s) }
+ resolved_source_array.select { |s| s.nil? || !::File.exist?(s) }
end
def current_package_name_array
@@ -187,14 +187,14 @@ class Chef
def name_candidate_version
@name_candidate_version ||=
begin
- Hash[name_pkginfo.map {|k, v| [k, v ? v.split("\t")[1].strip : nil] }]
+ Hash[name_pkginfo.map { |k, v| [k, v ? v.split("\t")[1].strip : nil] }]
end
end
def name_package_name
@name_package_name ||=
begin
- Hash[name_pkginfo.map {|k, v| [k, v ? v.split("\t")[0] : nil] }]
+ Hash[name_pkginfo.map { |k, v| [k, v ? v.split("\t")[0] : nil] }]
end
end
diff --git a/lib/chef/provider/package/easy_install.rb b/lib/chef/provider/package/easy_install.rb
index e4752cf3e7..a876258d04 100644
--- a/lib/chef/provider/package/easy_install.rb
+++ b/lib/chef/provider/package/easy_install.rb
@@ -32,10 +32,10 @@ class Chef
begin
# first check to see if we can import it
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{name}\"", :returns=>[0,1]).stderr
+ output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{name}\"", :returns => [0, 1]).stderr
if output.include? "ImportError"
# then check to see if its on the path
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout
+ output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns => [0, 1]).stdout
if output.downcase.include? "#{name.downcase}"
check = true
end
@@ -75,9 +75,9 @@ class Chef
output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{module_name}; print #{module_name}.__version__\"").stdout
package_version = output.strip
rescue
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout
+ output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns => [0, 1]).stdout
- output_array = output.gsub(/[\[\]]/,"").split(/\s*,\s*/)
+ output_array = output.gsub(/[\[\]]/, "").split(/\s*,\s*/)
package_path = ""
output_array.each do |entry|
@@ -103,12 +103,12 @@ class Chef
end
def candidate_version
- return @candidate_version if @candidate_version
+ return @candidate_version if @candidate_version
# do a dry run to get the latest version
- result = shell_out_with_timeout!("#{easy_install_binary_path} -n #{@new_resource.package_name}", :returns=>[0,1])
- @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3]
- @candidate_version
+ result = shell_out_with_timeout!("#{easy_install_binary_path} -n #{@new_resource.package_name}", :returns => [0, 1])
+ @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3]
+ @candidate_version
end
def install_package(name, version)
diff --git a/lib/chef/provider/package/freebsd/base.rb b/lib/chef/provider/package/freebsd/base.rb
index 81c27845ba..7104a71f70 100644
--- a/lib/chef/provider/package/freebsd/base.rb
+++ b/lib/chef/provider/package/freebsd/base.rb
@@ -57,8 +57,8 @@ class Chef
def makefile_variable_value(variable, dir = nil)
options = dir ? { :cwd => dir } : {}
- make_v = shell_out_with_timeout!("make -V #{variable}", options.merge!(:env => nil, :returns => [0,1]))
- make_v.exitstatus.zero? ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline.
+ make_v = shell_out_with_timeout!("make -V #{variable}", options.merge!(:env => nil, :returns => [0, 1]))
+ make_v.exitstatus.zero? ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline.
end
end
diff --git a/lib/chef/provider/package/freebsd/pkg.rb b/lib/chef/provider/package/freebsd/pkg.rb
index 339693a3d5..b42bd62c61 100644
--- a/lib/chef/provider/package/freebsd/pkg.rb
+++ b/lib/chef/provider/package/freebsd/pkg.rb
@@ -41,7 +41,7 @@ class Chef
Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
when /^\//
- shell_out_with_timeout!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , "LC_ALL"=>nil}).status
+ shell_out_with_timeout!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , "LC_ALL" => nil }).status
Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
else
@@ -72,7 +72,7 @@ class Chef
end
def current_installed_version
- pkg_info = shell_out_with_timeout!("pkg_info -E \"#{package_name}*\"", :env => nil, :returns => [0,1])
+ pkg_info = shell_out_with_timeout!("pkg_info -E \"#{package_name}*\"", :env => nil, :returns => [0, 1])
pkg_info.stdout[/^#{Regexp.escape(package_name)}-(.+)/, 1]
end
diff --git a/lib/chef/provider/package/freebsd/pkgng.rb b/lib/chef/provider/package/freebsd/pkgng.rb
index e3fa0ad571..de7bea6387 100644
--- a/lib/chef/provider/package/freebsd/pkgng.rb
+++ b/lib/chef/provider/package/freebsd/pkgng.rb
@@ -44,7 +44,7 @@ class Chef
end
def current_installed_version
- pkg_info = shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
+ pkg_info = shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0, 70])
pkg_info.stdout[/^Version +: (.+)$/, 1]
end
diff --git a/lib/chef/provider/package/freebsd/port.rb b/lib/chef/provider/package/freebsd/port.rb
index 39b7b00988..3eb3c5ab01 100644
--- a/lib/chef/provider/package/freebsd/port.rb
+++ b/lib/chef/provider/package/freebsd/port.rb
@@ -35,9 +35,9 @@ class Chef
def current_installed_version
pkg_info = if @new_resource.supports_pkgng?
- shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
+ shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0, 70])
else
- shell_out_with_timeout!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0,1])
+ shell_out_with_timeout!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0, 1])
end
pkg_info.stdout[/^#{Regexp.escape(@new_resource.package_name)}-(.+)/, 1]
end
diff --git a/lib/chef/provider/package/macports.rb b/lib/chef/provider/package/macports.rb
index c7ea71ac8c..b110207d8a 100644
--- a/lib/chef/provider/package/macports.rb
+++ b/lib/chef/provider/package/macports.rb
@@ -81,6 +81,7 @@ class Chef
end
private
+
def get_response_from_command(command)
output = nil
status = shell_out_with_timeout(command)
diff --git a/lib/chef/provider/package/openbsd.rb b/lib/chef/provider/package/openbsd.rb
index 3e209bcf99..2120b9aa48 100644
--- a/lib/chef/provider/package/openbsd.rb
+++ b/lib/chef/provider/package/openbsd.rb
@@ -72,7 +72,7 @@ class Chef
if parts = name.match(/^(.+?)--(.+)/) # use double-dash for stems with flavors, see man page for pkg_add
name = parts[1]
end
- shell_out_with_timeout!("pkg_add -r #{name}#{version_string(version)}", :env => {"PKG_PATH" => pkg_path}).status
+ shell_out_with_timeout!("pkg_add -r #{name}#{version_string(version)}", :env => { "PKG_PATH" => pkg_path }).status
Chef::Log.debug("#{new_resource.package_name} installed")
end
end
@@ -92,7 +92,7 @@ class Chef
else
name = new_resource.package_name
end
- pkg_info = shell_out_with_timeout!("pkg_info -e \"#{name}->0\"", :env => nil, :returns => [0,1])
+ pkg_info = shell_out_with_timeout!("pkg_info -e \"#{name}->0\"", :env => nil, :returns => [0, 1])
result = pkg_info.stdout[/^inst:#{Regexp.escape(name)}-(.+?)\s/, 1]
Chef::Log.debug("installed_version of '#{new_resource.package_name}' is '#{result}'")
result
@@ -101,7 +101,7 @@ class Chef
def candidate_version
@candidate_version ||= begin
results = []
- shell_out_with_timeout!("pkg_info -I \"#{new_resource.package_name}#{version_string(new_resource.version)}\"", :env => nil, :returns => [0,1]).stdout.each_line do |line|
+ shell_out_with_timeout!("pkg_info -I \"#{new_resource.package_name}#{version_string(new_resource.version)}\"", :env => nil, :returns => [0, 1]).stdout.each_line do |line|
if parts = new_resource.package_name.match(/^(.+?)--(.+)/)
results << line[/^#{Regexp.escape(parts[1])}-(.+?)\s/, 1]
else
diff --git a/lib/chef/provider/package/pacman.rb b/lib/chef/provider/package/pacman.rb
index ad7db25f49..22fa9c2307 100644
--- a/lib/chef/provider/package/pacman.rb
+++ b/lib/chef/provider/package/pacman.rb
@@ -52,14 +52,14 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
- repos = ["extra","core","community"]
+ repos = ["extra", "core", "community"]
if(::File.exists?("/etc/pacman.conf"))
pacman = ::File.read("/etc/pacman.conf")
repos = pacman.scan(/\[(.+)\]/).flatten
end
- package_repos = repos.map {|r| Regexp.escape(r) }.join("|")
+ package_repos = repos.map { |r| Regexp.escape(r) }.join("|")
status = shell_out_with_timeout("pacman -Sl")
status.stdout.each_line do |line|
@@ -80,7 +80,6 @@ class Chef
end
@candidate_version
-
end
def install_package(name, version)
diff --git a/lib/chef/provider/package/paludis.rb b/lib/chef/provider/package/paludis.rb
index 51437025e1..e1b2ea1cf4 100644
--- a/lib/chef/provider/package/paludis.rb
+++ b/lib/chef/provider/package/paludis.rb
@@ -59,7 +59,7 @@ class Chef
else
pkg = "#{@new_resource.package_name}"
end
- shell_out!("cave -L warning resolve -x#{expand_options(@new_resource.options)} \"#{pkg}\"",:timeout => @new_resource.timeout)
+ shell_out!("cave -L warning resolve -x#{expand_options(@new_resource.options)} \"#{pkg}\"", :timeout => @new_resource.timeout)
end
def upgrade_package(name, version)
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index 4d99d75ca2..688509889c 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -35,11 +35,11 @@ class Chef
@current_resource = Chef::Resource::Package.new(@new_resource.name)
@current_resource.package_name(@new_resource.package_name)
- category, pkg = %r{^#{PACKAGE_NAME_PATTERN}$}.match(@new_resource.package_name)[1,2]
+ category, pkg = %r{^#{PACKAGE_NAME_PATTERN}$}.match(@new_resource.package_name)[1, 2]
globsafe_category = category ? Chef::Util::PathHelper.escape_glob(category) : nil
globsafe_pkg = Chef::Util::PathHelper.escape_glob(pkg)
- possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map {|d| d.sub(%r{/var/db/pkg/}, "") }
+ possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map { |d| d.sub(%r{/var/db/pkg/}, "") }
versions = possibilities.map do |entry|
if(entry =~ %r{[^/]+/#{Regexp.escape(pkg)}\-(\d[\.\d]*((_(alpha|beta|pre|rc|p)\d*)*)?(-r\d+)?)})
[$&, $1]
@@ -47,8 +47,8 @@ class Chef
end.compact
if versions.size > 1
- atoms = versions.map {|v| v.first }.sort
- categories = atoms.map {|v| v.split("/")[0] }.uniq
+ atoms = versions.map { |v| v.first }.sort
+ categories = atoms.map { |v| v.split("/")[0] }.uniq
if !category && categories.size > 1
raise Chef::Exceptions::Package, "Multiple packages found for #{@new_resource.package_name}: #{atoms.join(" ")}. Specify a category."
end
@@ -103,7 +103,6 @@ class Chef
end
@candidate_version
-
end
def install_package(name, version)
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index b176114a15..7a2db6b32b 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -47,7 +47,7 @@ class Chef
# alternate value and overwrite it with the defaults.
Gem.configuration
- DEFAULT_UNINSTALLER_OPTS = {:ignore => true, :executables => true}
+ DEFAULT_UNINSTALLER_OPTS = { :ignore => true, :executables => true }
##
# The paths where rubygems should search for installed gems.
@@ -133,7 +133,7 @@ class Chef
def candidate_version_from_file(gem_dependency, source)
spec = spec_from_file(source)
if spec.satisfies_requirement?(gem_dependency)
- logger.debug {"#{@new_resource} found candidate gem version #{spec.version} from local gem package #{source}"}
+ logger.debug { "#{@new_resource} found candidate gem version #{spec.version} from local gem package #{source}" }
spec.version
else
# This is probably going to end badly...
@@ -189,7 +189,7 @@ class Chef
# === Options
# :sources rubygems servers to use
# Other options are passed to Gem::DependencyInstaller.new
- def install(gem_dependency, options={})
+ def install(gem_dependency, options = {})
with_gem_sources(*options.delete(:sources)) do
with_correct_verbosity do
dependency_installer(options).install(gem_dependency)
@@ -203,7 +203,7 @@ class Chef
# Otherwise, all versions are uninstalled.
# === Options
# Options are passed to Gem::Uninstaller.new
- def uninstall(gem_name, gem_version=nil, opts={})
+ def uninstall(gem_name, gem_version = nil, opts = {})
gem_version ? opts[:version] = gem_version : opts[:all] = true
with_correct_verbosity do
uninstaller(gem_name, opts).uninstall
@@ -218,11 +218,11 @@ class Chef
yield
end
- def dependency_installer(opts={})
+ def dependency_installer(opts = {})
Gem::DependencyInstaller.new(opts)
end
- def uninstaller(gem_name, opts={})
+ def uninstaller(gem_name, opts = {})
Gem::Uninstaller.new(gem_name, DEFAULT_UNINSTALLER_OPTS.merge(opts))
end
@@ -358,7 +358,7 @@ class Chef
include Chef::Mixin::GetSourceFromPackage
- def initialize(new_resource, run_context=nil)
+ def initialize(new_resource, run_context = nil)
super
@cleanup_gem_env = true
if new_resource.gem_binary
@@ -398,7 +398,7 @@ class Chef
Chef::Log.debug("#{@new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}")
# Omnibus installs to a static path because of linking on unix, find it.
true
- elsif RbConfig::CONFIG["bindir"].sub(/^[\w]:/, "") == "/opscode/chef/embedded/bin"
+ elsif RbConfig::CONFIG["bindir"].sub(/^[\w]:/, "") == "/opscode/chef/embedded/bin"
Chef::Log.debug("#{@new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}")
# windows, with the drive letter removed
true
@@ -436,7 +436,7 @@ class Chef
# is the current version
if !matching_installed_versions.empty?
gemspec = matching_installed_versions.last
- logger.debug { "#{@new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}"}
+ logger.debug { "#{@new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}" }
gemspec
# If no version matching the requirements exists, the latest installed
# version is the current version.
@@ -445,7 +445,7 @@ class Chef
logger.debug { "#{@new_resource} newest installed version of gem #{gemspec.name} is #{gemspec.version}" }
gemspec
else
- logger.debug { "#{@new_resource} no installed version found for #{gem_dependency}"}
+ logger.debug { "#{@new_resource} no installed version found for #{gem_dependency}" }
nil
end
end
@@ -519,7 +519,7 @@ class Chef
elsif @new_resource.gem_binary.nil?
@gem_env.install(@new_resource.source)
else
- install_via_gem_command(name,version)
+ install_via_gem_command(name, version)
end
true
end
@@ -538,9 +538,9 @@ class Chef
src = @new_resource.source && " --source=#{@new_resource.source} --source=https://rubygems.org"
end
if !version.nil? && version.length > 0
- shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env=>nil)
+ shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env => nil)
else
- shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env=>nil)
+ shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env => nil)
end
end
@@ -564,9 +564,9 @@ class Chef
def uninstall_via_gem_command(name, version)
if version
- shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env=>nil)
+ shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env => nil)
else
- shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :env=>nil)
+ shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :env => nil)
end
end
diff --git a/lib/chef/provider/package/smartos.rb b/lib/chef/provider/package/smartos.rb
index 5ef8ae2cbe..3f09bef212 100644
--- a/lib/chef/provider/package/smartos.rb
+++ b/lib/chef/provider/package/smartos.rb
@@ -43,7 +43,7 @@ class Chef
def check_package_state(name)
Chef::Log.debug("#{@new_resource} checking package #{name}")
version = nil
- info = shell_out_with_timeout!("/opt/local/sbin/pkg_info", "-E", "#{name}*", :env => nil, :returns => [0,1])
+ info = shell_out_with_timeout!("/opt/local/sbin/pkg_info", "-E", "#{name}*", :env => nil, :returns => [0, 1])
if info.stdout
version = info.stdout[/^#{@new_resource.package_name}-(.+)/, 1]
@@ -58,7 +58,7 @@ class Chef
return @candidate_version if @candidate_version
name = nil
version = nil
- pkg = shell_out_with_timeout!("/opt/local/bin/pkgin", "se", new_resource.package_name, :env => nil, :returns => [0,1])
+ pkg = shell_out_with_timeout!("/opt/local/bin/pkgin", "se", new_resource.package_name, :env => nil, :returns => [0, 1])
pkg.stdout.each_line do |line|
case line
when /^#{new_resource.package_name}/
diff --git a/lib/chef/provider/package/windows.rb b/lib/chef/provider/package/windows.rb
index c5aed43c9b..dc22de7ad5 100644
--- a/lib/chef/provider/package/windows.rb
+++ b/lib/chef/provider/package/windows.rb
@@ -79,7 +79,7 @@ class Chef
if new_resource.installer_type
new_resource.installer_type
elsif source_location.nil?
- inferred_registry_type
+ inferred_registry_type
else
basename = ::File.basename(source_location)
file_extension = basename.split(".").last.downcase
@@ -220,7 +220,7 @@ class Chef
r.backup(false)
if new_resource.remote_file_attributes
- new_resource.remote_file_attributes.each do |(k,v)|
+ new_resource.remote_file_attributes.each do |(k, v)|
r.send(k.to_sym, v)
end
end
diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb
index 62c3be1e25..ac771688e7 100644
--- a/lib/chef/provider/package/windows/msi.rb
+++ b/lib/chef/provider/package/windows/msi.rb
@@ -67,22 +67,22 @@ class Chef
def install_package
# We could use MsiConfigureProduct here, but we'll start off with msiexec
Chef::Log.debug("#{new_resource} installing MSI package '#{new_resource.source}'")
- shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", {:timeout => new_resource.timeout, :returns => new_resource.returns})
+ shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", { :timeout => new_resource.timeout, :returns => new_resource.returns })
end
def remove_package
# We could use MsiConfigureProduct here, but we'll start off with msiexec
if !new_resource.source.nil? && ::File.exist?(new_resource.source)
Chef::Log.debug("#{new_resource} removing MSI package '#{new_resource.source}'")
- shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", {:timeout => new_resource.timeout, :returns => new_resource.returns})
+ shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", { :timeout => new_resource.timeout, :returns => new_resource.returns })
else
uninstall_version = new_resource.version || installed_version
uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) }
.map { |version| version.uninstall_string }.uniq.each do |uninstall_string|
- Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'")
- uninstall_string += expand_options(new_resource.options)
- uninstall_string += " /Q" unless uninstall_string =~ / \/Q\b/
- shell_out!(uninstall_string, {:timeout => new_resource.timeout, :returns => new_resource.returns})
+ Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'")
+ uninstall_string += expand_options(new_resource.options)
+ uninstall_string += " /Q" unless uninstall_string =~ / \/Q\b/
+ shell_out!(uninstall_string, { :timeout => new_resource.timeout, :returns => new_resource.returns })
end
end
end
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index a0629842f2..aeecf3869e 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -63,7 +63,7 @@ class Chef
end
end
- version = evr[lead,tail]
+ version = evr[lead, tail]
if version.empty?
version = nil
end
@@ -159,12 +159,12 @@ class Chef
end
# copy the segment but not the unmatched character that x_seg_pos will
# refer to
- x_comp = x[x_pos,x_seg_pos - x_pos]
+ x_comp = x[x_pos, x_seg_pos - x_pos]
while (y_seg_pos <= y_pos_max) and isdigit(y[y_seg_pos])
y_seg_pos += 1
end
- y_comp = y[y_pos,y_seg_pos - y_pos]
+ y_comp = y[y_pos, y_seg_pos - y_pos]
else
# we are comparing strings
x_seg_is_num = false
@@ -172,12 +172,12 @@ class Chef
while (x_seg_pos <= x_pos_max) and isalpha(x[x_seg_pos])
x_seg_pos += 1
end
- x_comp = x[x_pos,x_seg_pos - x_pos]
+ x_comp = x[x_pos, x_seg_pos - x_pos]
while (y_seg_pos <= y_pos_max) and isalpha(y[y_seg_pos])
y_seg_pos += 1
end
- y_comp = y[y_pos,y_seg_pos - y_pos]
+ y_comp = y[y_pos, y_seg_pos - y_pos]
end
# if y_seg_pos didn't advance in the above loop it means the segments are
@@ -240,7 +240,7 @@ class Chef
@r = args[2]
else
raise ArgumentError, "Expecting either 'epoch-version-release' or 'epoch, " +
- "version, release'"
+ "version, release'"
end
end
attr_reader :e, :v, :r
@@ -286,7 +286,7 @@ class Chef
# 2:1.2-1 == 2:1.2
# 2:1.2-1 == 2:
#
- def compare_versions(y, partial=false)
+ def compare_versions(y, partial = false)
x = self
# compare epoch
@@ -344,12 +344,12 @@ class Chef
e = args[1].to_i
v = args[2]
r = args[3]
- @version = RPMVersion.new(e,v,r)
+ @version = RPMVersion.new(e, v, r)
@a = args[4]
@provides = args[5]
else
raise ArgumentError, "Expecting either 'name, epoch-version-release, arch, provides' " +
- "or 'name, epoch, version, release, arch, provides'"
+ "or 'name, epoch, version, release, arch, provides'"
end
# We always have one, ourselves!
@@ -429,11 +429,11 @@ class Chef
e = args[1].to_i
v = args[2]
r = args[3]
- @version = RPMVersion.new(e,v,r)
+ @version = RPMVersion.new(e, v, r)
@flag = args[4] || :==
else
raise ArgumentError, "Expecting either 'name, epoch-version-release, flag' or " +
- "'name, epoch, version, release, flag'"
+ "'name, epoch, version, release, flag'"
end
end
attr_reader :name, :version, :flag
@@ -690,15 +690,15 @@ class Chef
when :installed
reset_installed
# fast
- opts=" --installed"
+ opts = " --installed"
when :all
reset
# medium
- opts=" --options --installed-provides"
+ opts = " --options --installed-provides"
when :provides
reset
# slow!
- opts=" --options --all-provides"
+ opts = " --options --all-provides"
else
raise ArgumentError, "Unexpected value in next_refresh: #{@next_refresh}"
end
@@ -870,7 +870,7 @@ class Chef
end
# Check if a package-version.arch is available to install
- def version_available?(package_name, desired_version, arch=nil)
+ def version_available?(package_name, desired_version, arch = nil)
version(package_name, arch, true, false) do |v|
return true if desired_version == v
end
@@ -879,7 +879,7 @@ class Chef
end
# Return the source repository for a package-version.arch
- def package_repository(package_name, desired_version, arch=nil)
+ def package_repository(package_name, desired_version, arch = nil)
package(package_name, arch, true, false) do |pkg|
return pkg.repoid if desired_version == pkg.version.to_s
end
@@ -888,13 +888,13 @@ class Chef
end
# Return the latest available version for a package.arch
- def available_version(package_name, arch=nil)
+ def available_version(package_name, arch = nil)
version(package_name, arch, true, false)
end
alias :candidate_version :available_version
# Return the currently installed version for a package.arch
- def installed_version(package_name, arch=nil)
+ def installed_version(package_name, arch = nil)
version(package_name, arch, false, true)
end
@@ -922,7 +922,7 @@ class Chef
private
- def version(package_name, arch=nil, is_available=false, is_installed=false)
+ def version(package_name, arch = nil, is_available = false, is_installed = false)
package(package_name, arch, is_available, is_installed) do |pkg|
if block_given?
yield pkg.version.to_s
@@ -939,7 +939,7 @@ class Chef
end
end
- def package(package_name, arch=nil, is_available=false, is_installed=false)
+ def package(package_name, arch = nil, is_available = false, is_installed = false)
refresh
packages = @rpmdb[package_name]
if packages
@@ -1049,7 +1049,7 @@ class Chef
def yum_command(command)
command = "#{yum_binary} #{command}"
Chef::Log.debug("#{@new_resource}: yum command: \"#{command}\"")
- status = shell_out_with_timeout(command, {:timeout => Chef::Config[:yum_timeout]})
+ status = shell_out_with_timeout(command, { :timeout => Chef::Config[:yum_timeout] })
# This is fun: rpm can encounter errors in the %post/%postun scripts which aren't
# considered fatal - meaning the rpm is still successfully installed. These issue
@@ -1066,7 +1066,7 @@ class Chef
if l =~ %r{^error: %(post|postun)\(.*\) scriptlet failed, exit status \d+$}
Chef::Log.warn("#{@new_resource} caught non-fatal scriptlet issue: \"#{l}\". Can't trust yum exit status " +
"so running install again to verify.")
- status = shell_out_with_timeout(command, {:timeout => Chef::Config[:yum_timeout]})
+ status = shell_out_with_timeout(command, { :timeout => Chef::Config[:yum_timeout] })
break
end
end
@@ -1126,7 +1126,6 @@ class Chef
end
end
-
@current_resource = Chef::Resource::Package.new(@new_resource.name)
@current_resource.package_name(@new_resource.package_name)
@@ -1225,7 +1224,7 @@ class Chef
else
# we bail like yum when the package is older
raise Chef::Exceptions::Package, "Installed package #{n}-#{current_version_array[idx]} is newer " +
- "than candidate package #{n}-#{v}"
+ "than candidate package #{n}-#{v}"
end
end
end
@@ -1258,7 +1257,7 @@ class Chef
yum_command("-d0 -e0 -y#{expand_options(@new_resource.options)} #{method} #{pkg_string}")
else
raise Chef::Exceptions::Package, "Version #{version} of #{name} not found. Did you specify both version " +
- "and release? (version-release, e.g. 1.84-10.fc6)"
+ "and release? (version-release, e.g. 1.84-10.fc6)"
end
end
@@ -1359,7 +1358,7 @@ class Chef
# matching them up with an actual package so the standard resource handling can apply.
#
# There is currently no support for filename matching.
- def parse_dependency(name,version)
+ def parse_dependency(name, version)
# Transform the package_name into a requirement
# If we are passed a version or a version constraint we have to assume it's a requirement first. If it can't be
@@ -1412,7 +1411,7 @@ class Chef
new_package_version = nil
end
- [new_package_name,new_package_version]
+ [new_package_name, new_package_version]
end
end
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index 5d42772a48..2441b46013 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -42,10 +42,10 @@ class Chef
candidate_version = $1
Chef::Log.debug("#{new_resource} version #{$1}")
when /^Installed: Yes$/
- is_installed=true
+ is_installed = true
Chef::Log.debug("#{new_resource} is installed")
when /^Status: out-of-date \(version (.+) installed\)$/
- current_version=$1
+ current_version = $1
Chef::Log.debug("#{new_resource} out of date version #{$1}")
end
end
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index 77aaa080a9..6365f6a171 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -79,7 +79,7 @@ class Chef
def validate_script_syntax!
interpreter_arguments = default_interpreter_flags.join(" ")
- Tempfile.open(["chef_powershell_script-user-code", ".ps1"]) do | user_script_file |
+ Tempfile.open(["chef_powershell_script-user-code", ".ps1"]) do |user_script_file|
# Wrap the user's code in a PowerShell script block so that
# it isn't executed. However, syntactically invalid script
# in that block will still trigger a syntax error which is
@@ -110,7 +110,7 @@ EOH
# means a non-zero return and thus a syntactically invalid script.
with_os_architecture(node, architecture: new_resource.architecture) do
- shell_out!(validation_command, {returns: [0]})
+ shell_out!(validation_command, { returns: [0] })
end
end
end
@@ -146,7 +146,7 @@ EOH
# executed, otherwise 0 or 1 based on whether $? is set to true
# (success, where we return 0) or false (where we return 1).
def wrapper_script
-<<-EOH
+ <<-EOH
# Chef Client wrapper for powershell_script resources
# LASTEXITCODE can be uninitialized -- make it explictly 0
diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb
index 3d3d2a01a4..2e00fd08e1 100644
--- a/lib/chef/provider/registry_key.rb
+++ b/lib/chef/provider/registry_key.rb
@@ -72,22 +72,22 @@ class Chef
def define_resource_requirements
requirements.assert(:create, :create_if_missing, :delete, :delete_key) do |a|
- a.assertion{ registry.hive_exists?(@new_resource.key) }
+ a.assertion { registry.hive_exists?(@new_resource.key) }
a.failure_message(Chef::Exceptions::Win32RegHiveMissing, "Hive #{@new_resource.key.split("\\").shift} does not exist")
end
requirements.assert(:create) do |a|
- a.assertion{ registry.key_exists?(@new_resource.key) }
+ a.assertion { registry.key_exists?(@new_resource.key) }
a.whyrun("Key #{@new_resource.key} does not exist. Unless it would have been created before, attempt to modify its values would fail.")
end
requirements.assert(:create, :create_if_missing) do |a|
#If keys missing in the path and recursive == false
- a.assertion{ !registry.keys_missing?(@current_resource.key) || @new_resource.recursive }
+ a.assertion { !registry.keys_missing?(@current_resource.key) || @new_resource.recursive }
a.failure_message(Chef::Exceptions::Win32RegNoRecursive, "Intermediate keys missing but recursive is set to false")
a.whyrun("Intermediate keys in #{@new_resource.key} go not exist. Unless they would have been created earlier, attempt to modify them would fail.")
end
requirements.assert(:delete_key) do |a|
#If key to be deleted has subkeys but recurssive == false
- a.assertion{ !registry.key_exists?(@new_resource.key) || !registry.has_subkeys?(@new_resource.key) || @new_resource.recursive }
+ a.assertion { !registry.key_exists?(@new_resource.key) || !registry.has_subkeys?(@new_resource.key) || @new_resource.recursive }
a.failure_message(Chef::Exceptions::Win32RegNoRecursive, "#{@new_resource.key} has subkeys but recursive is set to false.")
a.whyrun("#{@current_resource.key} has subkeys, but recursive is set to false. attempt to delete would fails unless subkeys were deleted prior to this action.")
end
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
index 7479ef9e85..b592b13ccf 100644
--- a/lib/chef/provider/remote_directory.rb
+++ b/lib/chef/provider/remote_directory.rb
@@ -106,7 +106,7 @@ class Chef
if purge
Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob(path), "**", "*"), ::File::FNM_DOTMATCH).sort!.reverse!.each do |file|
# skip '.' and '..'
- next if [".",".."].include?(Pathname.new(file).basename().to_s)
+ next if [".", ".."].include?(Pathname.new(file).basename().to_s)
# Clean the path. This is required because of the ::File.join
file = Chef::Util::PathHelper.cleanpath(file)
@@ -251,7 +251,7 @@ class Chef
# Windows will handle inheritance.
if dir == path
rights.each do |r|
- r = r.dup # do not update the new_resource
+ r = r.dup # do not update the new_resource
permissions = r.delete(:permissions)
principals = r.delete(:principals)
res.rights(permissions, principals, r)
diff --git a/lib/chef/provider/remote_file/cache_control_data.rb b/lib/chef/provider/remote_file/cache_control_data.rb
index b100ebf4a0..7aa059f4cb 100644
--- a/lib/chef/provider/remote_file/cache_control_data.rb
+++ b/lib/chef/provider/remote_file/cache_control_data.rb
@@ -177,10 +177,9 @@ class Chef
def sanitized_cache_file_basename
uri_sha2 = Chef::Digester.instance.generate_checksum(StringIO.new(uri))
- cache_file_basename(uri_sha2[0,32])
+ cache_file_basename(uri_sha2[0, 32])
end
-
def sanitized_cache_file_basename_md5
# Old way of creating the file basename
uri_md5 = Chef::Digester.instance.generate_md5_checksum(StringIO.new(uri))
diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb
index 0e44f06ca7..6fa574e777 100644
--- a/lib/chef/provider/remote_file/http.rb
+++ b/lib/chef/provider/remote_file/http.rb
@@ -95,7 +95,7 @@ class Chef
end
def http_client_opts
- opts={}
+ opts = {}
# CHEF-3140
# 1. If it's already compressed, trying to compress it more will
# probably be counter-productive.
diff --git a/lib/chef/provider/remote_file/local_file.rb b/lib/chef/provider/remote_file/local_file.rb
index b02d575999..613db02337 100644
--- a/lib/chef/provider/remote_file/local_file.rb
+++ b/lib/chef/provider/remote_file/local_file.rb
@@ -35,7 +35,7 @@ class Chef
# CHEF-4472: Remove the leading slash from windows paths that we receive from a file:// URI
def fix_windows_path(path)
- path.gsub(/^\/([a-zA-Z]:)/,'\1')
+ path.gsub(/^\/([a-zA-Z]:)/, '\1')
end
def source_path
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index d325c65d2a..3dd0e33cd1 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -22,208 +22,208 @@ require "chef/provider"
require "ipaddr"
class Chef::Provider::Route < Chef::Provider
- include Chef::Mixin::Command
-
- provides :route
-
- attr_accessor :is_running
-
- MASK = {"0.0.0.0" => "0",
- "128.0.0.0" => "1",
- "192.0.0.0" => "2",
- "224.0.0.0" => "3",
- "240.0.0.0" => "4",
- "248.0.0.0" => "5",
- "252.0.0.0" => "6",
- "254.0.0.0" => "7",
- "255.0.0.0" => "8",
- "255.128.0.0" => "9",
- "255.192.0.0" => "10",
- "255.224.0.0" => "11",
- "255.240.0.0" => "12",
- "255.248.0.0" => "13",
- "255.252.0.0" => "14",
- "255.254.0.0" => "15",
- "255.255.0.0" => "16",
- "255.255.128.0" => "17",
- "255.255.192.0" => "18",
- "255.255.224.0" => "19",
- "255.255.240.0" => "20",
- "255.255.248.0" => "21",
- "255.255.252.0" => "22",
- "255.255.254.0" => "23",
- "255.255.255.0" => "24",
- "255.255.255.128" => "25",
- "255.255.255.192" => "26",
- "255.255.255.224" => "27",
- "255.255.255.240" => "28",
- "255.255.255.248" => "29",
- "255.255.255.252" => "30",
- "255.255.255.254" => "31",
- "255.255.255.255" => "32" }
-
- def hex2ip(hex_data)
- # Cleanup hex data
- hex_ip = hex_data.to_s.downcase.gsub(/[^0-9a-f]/, "")
-
- # Check hex data format (IP is a 32bit integer, so should be 8 chars long)
- return nil if hex_ip.length != hex_data.length || hex_ip.length != 8
-
- # Extract octets from hex data
- octets = hex_ip.scan(/../).reverse.collect { |octet| [octet].pack("H2").unpack("C").first }
-
- # Validate IP
- ip = octets.join(".")
- begin
- IPAddr.new(ip, Socket::AF_INET).to_s
- rescue ArgumentError
- Chef::Log.debug("Invalid IP address data: hex=#{hex_ip}, ip=#{ip}")
- return nil
- end
- end
-
- def whyrun_supported?
- true
+ include Chef::Mixin::Command
+
+ provides :route
+
+ attr_accessor :is_running
+
+ MASK = { "0.0.0.0" => "0",
+ "128.0.0.0" => "1",
+ "192.0.0.0" => "2",
+ "224.0.0.0" => "3",
+ "240.0.0.0" => "4",
+ "248.0.0.0" => "5",
+ "252.0.0.0" => "6",
+ "254.0.0.0" => "7",
+ "255.0.0.0" => "8",
+ "255.128.0.0" => "9",
+ "255.192.0.0" => "10",
+ "255.224.0.0" => "11",
+ "255.240.0.0" => "12",
+ "255.248.0.0" => "13",
+ "255.252.0.0" => "14",
+ "255.254.0.0" => "15",
+ "255.255.0.0" => "16",
+ "255.255.128.0" => "17",
+ "255.255.192.0" => "18",
+ "255.255.224.0" => "19",
+ "255.255.240.0" => "20",
+ "255.255.248.0" => "21",
+ "255.255.252.0" => "22",
+ "255.255.254.0" => "23",
+ "255.255.255.0" => "24",
+ "255.255.255.128" => "25",
+ "255.255.255.192" => "26",
+ "255.255.255.224" => "27",
+ "255.255.255.240" => "28",
+ "255.255.255.248" => "29",
+ "255.255.255.252" => "30",
+ "255.255.255.254" => "31",
+ "255.255.255.255" => "32" }
+
+ def hex2ip(hex_data)
+ # Cleanup hex data
+ hex_ip = hex_data.to_s.downcase.gsub(/[^0-9a-f]/, "")
+
+ # Check hex data format (IP is a 32bit integer, so should be 8 chars long)
+ return nil if hex_ip.length != hex_data.length || hex_ip.length != 8
+
+ # Extract octets from hex data
+ octets = hex_ip.scan(/../).reverse.collect { |octet| [octet].pack("H2").unpack("C").first }
+
+ # Validate IP
+ ip = octets.join(".")
+ begin
+ IPAddr.new(ip, Socket::AF_INET).to_s
+ rescue ArgumentError
+ Chef::Log.debug("Invalid IP address data: hex=#{hex_ip}, ip=#{ip}")
+ return nil
end
+ end
- def load_current_resource
- self.is_running = false
+ def whyrun_supported?
+ true
+ end
- # cidr or quad dot mask
- if @new_resource.netmask
- new_ip = IPAddr.new("#{@new_resource.target}/#{@new_resource.netmask}")
- else
- new_ip = IPAddr.new(@new_resource.target)
- end
-
- # For linux, we use /proc/net/route file to read proc table info
- if node[:os] == "linux"
- route_file = ::File.open("/proc/net/route", "r")
-
- # Read all routes
- while (line = route_file.gets)
- # Get all the fields for a route
- iface,destination,gateway,flags,refcnt,use,metric,mask,mtu,window,irtt = line.split
-
- # Convert hex-encoded values to quad-dotted notation (e.g. 0064A8C0 => 192.168.100.0)
- destination = hex2ip(destination)
- gateway = hex2ip(gateway)
- mask = hex2ip(mask)
-
- # Skip formatting lines (header, etc)
- next unless destination && gateway && mask
- Chef::Log.debug("#{@new_resource} system has route: dest=#{destination} mask=#{mask} gw=#{gateway}")
-
- # check if what were trying to configure is already there
- # use an ipaddr object with ip/mask this way we can have
- # a new resource be in cidr format (i don't feel like
- # expanding bitmask by hand.
- #
- running_ip = IPAddr.new("#{destination}/#{mask}")
- Chef::Log.debug("#{@new_resource} new ip: #{new_ip.inspect} running ip: #{running_ip.inspect}")
- self.is_running = true if running_ip == new_ip && gateway == @new_resource.gateway
- end
+ def load_current_resource
+ self.is_running = false
- route_file.close
- end
+ # cidr or quad dot mask
+ if @new_resource.netmask
+ new_ip = IPAddr.new("#{@new_resource.target}/#{@new_resource.netmask}")
+ else
+ new_ip = IPAddr.new(@new_resource.target)
end
- def action_add
- # check to see if load_current_resource found the route
- if is_running
- Chef::Log.debug("#{@new_resource} route already active - nothing to do")
- else
- command = generate_command(:add)
- converge_by ("run #{ command } to add route") do
- run_command( :command => command )
- Chef::Log.info("#{@new_resource} added")
- end
+ # For linux, we use /proc/net/route file to read proc table info
+ if node[:os] == "linux"
+ route_file = ::File.open("/proc/net/route", "r")
+
+ # Read all routes
+ while (line = route_file.gets)
+ # Get all the fields for a route
+ iface, destination, gateway, flags, refcnt, use, metric, mask, mtu, window, irtt = line.split
+
+ # Convert hex-encoded values to quad-dotted notation (e.g. 0064A8C0 => 192.168.100.0)
+ destination = hex2ip(destination)
+ gateway = hex2ip(gateway)
+ mask = hex2ip(mask)
+
+ # Skip formatting lines (header, etc)
+ next unless destination && gateway && mask
+ Chef::Log.debug("#{@new_resource} system has route: dest=#{destination} mask=#{mask} gw=#{gateway}")
+
+ # check if what were trying to configure is already there
+ # use an ipaddr object with ip/mask this way we can have
+ # a new resource be in cidr format (i don't feel like
+ # expanding bitmask by hand.
+ #
+ running_ip = IPAddr.new("#{destination}/#{mask}")
+ Chef::Log.debug("#{@new_resource} new ip: #{new_ip.inspect} running ip: #{running_ip.inspect}")
+ self.is_running = true if running_ip == new_ip && gateway == @new_resource.gateway
end
- #for now we always write the file (ugly but its what it is)
- generate_config
+ route_file.close
end
-
- def action_delete
- if is_running
- command = generate_command(:delete)
- converge_by ("run #{ command } to delete route ") do
- run_command( :command => command )
- Chef::Log.info("#{@new_resource} removed")
- end
- else
- Chef::Log.debug("#{@new_resource} route does not exist - nothing to do")
+ end
+
+ def action_add
+ # check to see if load_current_resource found the route
+ if is_running
+ Chef::Log.debug("#{@new_resource} route already active - nothing to do")
+ else
+ command = generate_command(:add)
+ converge_by ("run #{ command } to add route") do
+ run_command( :command => command )
+ Chef::Log.info("#{@new_resource} added")
end
+ end
+
+ #for now we always write the file (ugly but its what it is)
+ generate_config
+ end
- #for now we always write the file (ugly but its what it is)
- generate_config
+ def action_delete
+ if is_running
+ command = generate_command(:delete)
+ converge_by ("run #{ command } to delete route ") do
+ run_command( :command => command )
+ Chef::Log.info("#{@new_resource} removed")
+ end
+ else
+ Chef::Log.debug("#{@new_resource} route does not exist - nothing to do")
end
- def generate_config
- conf = Hash.new
- case node[:platform]
- when "centos", "redhat", "fedora"
- # walk the collection
- run_context.resource_collection.each do |resource|
- if resource.is_a? Chef::Resource::Route
- # default to eth0
- if resource.device
- dev = resource.device
- else
- dev = "eth0"
- end
-
- conf[dev] = String.new if conf[dev].nil?
- case @action
- when :add
- conf[dev] << config_file_contents(:add, :target => resource.target, :netmask => resource.netmask, :gateway => resource.gateway)
- when :delete
- # need to do this for the case when the last route on an int
- # is removed
- conf[dev] << config_file_contents(:delete)
- end
+ #for now we always write the file (ugly but its what it is)
+ generate_config
+ end
+
+ def generate_config
+ conf = Hash.new
+ case node[:platform]
+ when "centos", "redhat", "fedora"
+ # walk the collection
+ run_context.resource_collection.each do |resource|
+ if resource.is_a? Chef::Resource::Route
+ # default to eth0
+ if resource.device
+ dev = resource.device
+ else
+ dev = "eth0"
end
- end
- conf.each do |k, v|
- network_file_name = "/etc/sysconfig/network-scripts/route-#{k}"
- converge_by ("write route route.#{k}\n#{conf[k]} to #{ network_file_name }") do
- network_file = ::File.new(network_file_name, "w")
- network_file.puts(conf[k])
- Chef::Log.debug("#{@new_resource} writing route.#{k}\n#{conf[k]}")
- network_file.close
+
+ conf[dev] = String.new if conf[dev].nil?
+ case @action
+ when :add
+ conf[dev] << config_file_contents(:add, :target => resource.target, :netmask => resource.netmask, :gateway => resource.gateway)
+ when :delete
+ # need to do this for the case when the last route on an int
+ # is removed
+ conf[dev] << config_file_contents(:delete)
end
end
end
- end
-
- def generate_command(action)
- common_route_items = ""
- common_route_items << "/#{MASK[@new_resource.netmask.to_s]}" if @new_resource.netmask
- common_route_items << " via #{@new_resource.gateway} " if @new_resource.gateway
-
- case action
- when :add
- command = "ip route replace #{@new_resource.target}"
- command << common_route_items
- command << " dev #{@new_resource.device} " if @new_resource.device
- when :delete
- command = "ip route delete #{@new_resource.target}"
- command << common_route_items
+ conf.each do |k, v|
+ network_file_name = "/etc/sysconfig/network-scripts/route-#{k}"
+ converge_by ("write route route.#{k}\n#{conf[k]} to #{ network_file_name }") do
+ network_file = ::File.new(network_file_name, "w")
+ network_file.puts(conf[k])
+ Chef::Log.debug("#{@new_resource} writing route.#{k}\n#{conf[k]}")
+ network_file.close
+ end
end
-
- return command
+ end
+ end
+
+ def generate_command(action)
+ common_route_items = ""
+ common_route_items << "/#{MASK[@new_resource.netmask.to_s]}" if @new_resource.netmask
+ common_route_items << " via #{@new_resource.gateway} " if @new_resource.gateway
+
+ case action
+ when :add
+ command = "ip route replace #{@new_resource.target}"
+ command << common_route_items
+ command << " dev #{@new_resource.device} " if @new_resource.device
+ when :delete
+ command = "ip route delete #{@new_resource.target}"
+ command << common_route_items
end
- def config_file_contents(action, options={})
- content = ""
- case action
- when :add
- content << "#{options[:target]}"
- content << "/#{options[:netmask]}" if options[:netmask]
- content << " via #{options[:gateway]}" if options[:gateway]
- content << "\n"
- end
-
- return content
+ return command
+ end
+
+ def config_file_contents(action, options = {})
+ content = ""
+ case action
+ when :add
+ content << "#{options[:target]}"
+ content << "/#{options[:netmask]}" if options[:netmask]
+ content << " via #{options[:gateway]}" if options[:gateway]
+ content << "\n"
end
+
+ return content
+ end
end
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index 95ff28e368..390330aed2 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -62,13 +62,13 @@ class Chef
end
def define_resource_requirements
- requirements.assert(:reload) do |a|
- a.assertion { supports[:reload] || @new_resource.reload_command }
- a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} does not support :reload"
- # if a service is not declared to support reload, that won't
- # typically change during the course of a run - so no whyrun
- # alternative here.
- end
+ requirements.assert(:reload) do |a|
+ a.assertion { supports[:reload] || @new_resource.reload_command }
+ a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} does not support :reload"
+ # if a service is not declared to support reload, that won't
+ # typically change during the course of a run - so no whyrun
+ # alternative here.
+ end
end
def action_enable
diff --git a/lib/chef/provider/service/aix.rb b/lib/chef/provider/service/aix.rb
index 6f0eba7737..201f9ff5f9 100644
--- a/lib/chef/provider/service/aix.rb
+++ b/lib/chef/provider/service/aix.rb
@@ -90,6 +90,7 @@ class Chef
end
protected
+
def determine_current_status!
Chef::Log.debug "#{@new_resource} using lssrc to check the status"
begin
@@ -126,4 +127,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb
index c6483c3f59..6b451d649a 100644
--- a/lib/chef/provider/service/aixinit.rb
+++ b/lib/chef/provider/service/aixinit.rb
@@ -57,14 +57,14 @@ class Chef
end
def enable_service
- Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f)}
+ Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
if @new_resource.priority.is_a? Integer
create_symlink(2, "S", @new_resource.priority)
elsif @new_resource.priority.is_a? Hash
- @new_resource.priority.each do |level,o|
- create_symlink(level,(o[0] == :start ? "S" : "K"),o[1])
+ @new_resource.priority.each do |level, o|
+ create_symlink(level, (o[0] == :start ? "S" : "K"), o[1])
end
else
create_symlink(2, "S", "")
@@ -75,9 +75,9 @@ class Chef
Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
if @new_resource.priority.is_a? Integer
- create_symlink(2, "K",100 - @new_resource.priority)
+ create_symlink(2, "K", 100 - @new_resource.priority)
elsif @new_resource.priority.is_a? Hash
- @new_resource.priority.each do |level,o|
+ @new_resource.priority.each do |level, o|
create_symlink(level, "K", 100 - o[1]) if o[0] == :stop
end
else
diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb
index 66504390e8..9c66fb4098 100644
--- a/lib/chef/provider/service/arch.rb
+++ b/lib/chef/provider/service/arch.rb
@@ -32,8 +32,8 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
end
def load_current_resource
- raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf")
- raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
+ raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf")
+ raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
super
@current_resource.enabled(daemons.include?(@current_resource.service_name))
@@ -50,7 +50,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
def daemons
entries = []
if ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
- entries += $1.gsub(/\\?[\r\n]/, " ").gsub(/# *[^ ]+/," ").split(" ") if $1.length > 0
+ entries += $1.gsub(/\\?[\r\n]/, " ").gsub(/# *[^ ]+/, " ").split(" ") if $1.length > 0
end
yield(entries) if block_given?
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index e67f5ca95d..6550c85b2a 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -55,18 +55,18 @@ class Chef
requirements.assert(:all_actions) do |a|
a.assertion { @priority_success }
- a.failure_message Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{current_resource.service_name} failed - #{@rcd_status.inspect}"
+ a.failure_message Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{current_resource.service_name} failed - #{@rcd_status.inspect}"
# This can happen if the service is not yet installed,so we'll fake it.
a.whyrun ["Unable to determine priority of service, assuming service would have been correctly installed earlier in the run.",
"Assigning temporary priorities to continue.",
"If this service is not properly installed prior to this point, this will fail."] do
- temp_priorities = {"6"=>[:stop, "20"],
- "0"=>[:stop, "20"],
- "1"=>[:stop, "20"],
- "2"=>[:start, "20"],
- "3"=>[:start, "20"],
- "4"=>[:start, "20"],
- "5"=>[:start, "20"]}
+ temp_priorities = { "6" => [:stop, "20"],
+ "0" => [:stop, "20"],
+ "1" => [:stop, "20"],
+ "2" => [:start, "20"],
+ "3" => [:start, "20"],
+ "4" => [:start, "20"],
+ "5" => [:start, "20"] }
current_resource.priority(temp_priorities)
end
end
@@ -148,7 +148,6 @@ class Chef
shell_out!("/usr/sbin/update-rc.d -f #{new_resource.service_name} remove")
shell_out!("/usr/sbin/update-rc.d #{new_resource.service_name} defaults")
end
-
end
def disable_service
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb
index fc0743d5e4..7e475fc878 100644
--- a/lib/chef/provider/service/freebsd.rb
+++ b/lib/chef/provider/service/freebsd.rb
@@ -51,7 +51,7 @@ class Chef
Chef::Log.debug("#{current_resource} found at #{init_command}")
@status_load_success = true
- determine_current_status! # see Chef::Provider::Service::Simple
+ determine_current_status! # see Chef::Provider::Service::Simple
determine_enabled_status!
current_resource
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 4206f29aef..63485903c3 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -83,7 +83,7 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion {::File.exists?(@plist.to_s) }
+ a.assertion { ::File.exists?(@plist.to_s) }
a.failure_message Chef::Exceptions::Service,
"Could not find plist for #{@new_resource}"
end
diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb
index 4fc10cff5c..c31df25e68 100644
--- a/lib/chef/provider/service/openbsd.rb
+++ b/lib/chef/provider/service/openbsd.rb
@@ -117,7 +117,7 @@ class Chef
old_list = rc_conf_local.match(/^pkg_scripts="(.*)"/)
old_list = old_list ? old_list[1].split(" ") : []
new_list = old_list - [new_resource.service_name]
- update_rcl rc_conf_local.sub(/^pkg_scripts="(.*)"/, pkg_scripts="#{new_list.join(' ')}")
+ update_rcl rc_conf_local.sub(/^pkg_scripts="(.*)"/, pkg_scripts = "#{new_list.join(' ')}")
end
end
end
diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb
index 58c8d4d30a..a76622ee8f 100644
--- a/lib/chef/provider/service/redhat.rb
+++ b/lib/chef/provider/service/redhat.rb
@@ -75,7 +75,7 @@ class Chef
super
if ::File.exists?("/sbin/chkconfig")
- chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0,1])
+ chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0, 1])
unless run_levels.nil? or run_levels.empty?
all_levels_match = true
chkconfig.stdout.split(/\s+/)[1..-1].each do |level|
diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb
index b954a118dd..d76779a74b 100644
--- a/lib/chef/provider/service/simple.rb
+++ b/lib/chef/provider/service/simple.rb
@@ -66,7 +66,7 @@ class Chef
end
requirements.assert(:restart) do |a|
- a.assertion { @new_resource.restart_command || ( @new_resource.start_command && @new_resource.stop_command ) }
+ a.assertion { @new_resource.restart_command || ( @new_resource.start_command && @new_resource.stop_command ) }
a.failure_message Chef::Exceptions::Service, "#{self} requires a restart_command or both start_command and stop_command be set in order to perform a restart"
end
@@ -109,6 +109,7 @@ class Chef
end
protected
+
def determine_current_status!
if @new_resource.status_command
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb
index b302441a60..0787392094 100644
--- a/lib/chef/provider/service/solaris.rb
+++ b/lib/chef/provider/service/solaris.rb
@@ -28,7 +28,7 @@ class Chef
provides :service, os: "solaris2"
- def initialize(new_resource, run_context=nil)
+ def initialize(new_resource, run_context = nil)
super
@init_command = "/usr/sbin/svcadm"
@status_command = "/bin/svcs"
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 2aacdf3915..edd41dba7e 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -89,7 +89,7 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion { @config_file_found }
+ a.assertion { @config_file_found }
# no failure here, just document the assumptions made.
a.whyrun "Could not find #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}. Assuming service is disabled."
end
@@ -130,7 +130,7 @@ class Chef
# Get enabled/disabled state by reading job configuration file
if ::File.exists?("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
Chef::Log.debug("#{@new_resource} found #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
- ::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}","r") do |file|
+ ::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}", "r") do |file|
while line = file.gets
case line
when /^start on/
diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb
index 8c7c76df3f..2705aa5c02 100644
--- a/lib/chef/provider/service/windows.rb
+++ b/lib/chef/provider/service/windows.rb
@@ -45,7 +45,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
START_PENDING = "start pending"
STOP_PENDING = "stop pending"
- TIMEOUT = 60
+ TIMEOUT = 60
SERVICE_RIGHT = "SeServiceLogonRight"
@@ -75,7 +75,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
service_name: @new_resource.service_name,
service_start_name: @new_resource.run_as_user,
password: @new_resource.run_as_password,
- }.reject { |k,v| v.nil? || v.length == 0 }
+ }.reject { |k, v| v.nil? || v.length == 0 }
Win32::Service.configure(new_config)
Chef::Log.info "#{@new_resource} configured with #{new_config.inspect}"
@@ -238,6 +238,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
end
private
+
def grant_service_logon(username)
begin
Chef::ReservedNames::Win32::Security.add_account_right(canonicalize_username(username), SERVICE_RIGHT)
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index e8c25c1740..45002de244 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -48,7 +48,7 @@ class Chef
end
def define_resource_requirements
- requirements.assert(:all_actions) do |a|
+ requirements.assert(:all_actions) do |a|
# Make sure the parent dir exists, or else fail.
# for why run, print a message explaining the potential error.
parent_directory = ::File.dirname(@new_resource.destination)
@@ -115,7 +115,7 @@ class Chef
def export_command
args = ["--force"]
args << @new_resource.svn_arguments << verbose << authentication <<
- "-r#{revision_int}" << @new_resource.repository << @new_resource.destination
+ "-r#{revision_int}" << @new_resource.repository << @new_resource.destination
c = scm :export, *args
Chef::Log.info "#{@new_resource} exported #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
c
@@ -130,7 +130,7 @@ class Chef
@new_resource.revision
else
command = scm(:info, @new_resource.repository, @new_resource.svn_info_args, authentication, "-r#{@new_resource.revision}")
- svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0,1])).stdout
+ svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout
extract_revision_info(svn_info)
end
@@ -142,7 +142,7 @@ class Chef
def find_current_revision
return nil unless ::File.exist?(::File.join(@new_resource.destination, ".svn"))
command = scm(:info)
- svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0,1])).stdout
+ svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout
extract_revision_info(svn_info)
end
@@ -151,7 +151,7 @@ class Chef
(!@current_resource.revision.nil?) && (revision_int.strip.to_i == @current_resource.revision.strip.to_i)
end
- def run_options(run_opts={})
+ def run_options(run_opts = {})
run_opts[:user] = @new_resource.user if @new_resource.user
run_opts[:group] = @new_resource.group if @new_resource.group
run_opts[:timeout] = @new_resource.timeout if @new_resource.timeout
@@ -201,7 +201,7 @@ class Chef
end
def target_dir_non_existent_or_empty?
- !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination).sort == [".",".."]
+ !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination).sort == [".", ".."]
end
def svn_binary
diff --git a/lib/chef/provider/template_finder.rb b/lib/chef/provider/template_finder.rb
index ede6103885..67342a86ea 100644
--- a/lib/chef/provider/template_finder.rb
+++ b/lib/chef/provider/template_finder.rb
@@ -41,6 +41,7 @@ class Chef
end
protected
+
def template_source_name(name, options)
if options[:source]
options[:source]
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb
index 3b8fe61171..85bd674d8d 100644
--- a/lib/chef/provider/user.rb
+++ b/lib/chef/provider/user.rb
@@ -98,7 +98,7 @@ class Chef
a.assertion { @shadow_lib_ok }
a.failure_message Chef::Exceptions::MissingLibrary, "You must have ruby-shadow installed for password support!"
a.whyrun "ruby-shadow is not installed. Attempts to set user password will cause failure. Assuming that this gem will have been previously installed." +
- "Note that user update converge may report false-positive on the basis of mismatched password. "
+ "Note that user update converge may report false-positive on the basis of mismatched password. "
end
requirements.assert(:modify, :lock, :unlock) do |a|
a.assertion { @user_exists }
@@ -125,7 +125,6 @@ class Chef
end
def action_create
-
if !@user_exists
converge_by("create user #{@new_resource.username}") do
create_user
diff --git a/lib/chef/provider/user/aix.rb b/lib/chef/provider/user/aix.rb
index 019fe88a04..42798a5f62 100644
--- a/lib/chef/provider/user/aix.rb
+++ b/lib/chef/provider/user/aix.rb
@@ -48,7 +48,7 @@ class Chef
end
raise Chef::Exceptions::User, "Cannot determine if #{@new_resource} is locked!" if lock_info.stdout.empty?
- status = /\S+\s+account_locked=(\S+)/.match(lock_info.stdout)
+ status = /\S+\s+account_locked=(\S+)/.match(lock_info.stdout)
if status && status[1] == "true"
@locked = true
else
@@ -67,6 +67,7 @@ class Chef
end
private
+
def add_password
if @current_resource.password != @new_resource.password && @new_resource.password
Chef::Log.debug("#{@new_resource.username} setting password to #{@new_resource.password}")
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 995d3bf30b..e81a01c764 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -109,7 +109,6 @@ in 'password', with the associated 'salt' and 'iterations'.")
Mac OS X version 10.7. Please specify a SALTED-SHA512 shadow hash in 'password' attribute to set the \
user password using shadow hash.")
end
-
end
def load_current_resource
@@ -145,7 +144,7 @@ user password using shadow hash.")
# Convert the salt from Base64 encoding to hex before consuming them
current_resource.salt(shadow_hash["SALTED-SHA512-PBKDF2"]["salt"].string.unpack("H*").first)
else
- raise(Chef::Exceptions::User,"Unknown shadow_hash format: #{shadow_hash.keys.join(' ')}")
+ raise(Chef::Exceptions::User, "Unknown shadow_hash format: #{shadow_hash.keys.join(' ')}")
end
end
@@ -226,7 +225,7 @@ user password using shadow hash.")
# Find the next available uid on the system. starting with 200 if `system` is set,
# 500 otherwise.
#
- def get_free_uid(search_limit=1000)
+ def get_free_uid(search_limit = 1000)
uid = nil
base_uid = new_resource.system ? 200 : 500
next_uid_guess = base_uid
@@ -308,7 +307,7 @@ user password using shadow hash.")
def validate_home_dir_specification!
unless new_resource.home =~ /^\//
- raise(Chef::Exceptions::InvalidHomeDirectory,"invalid path spec for User: '#{new_resource.username}', home directory: '#{new_resource.home}'")
+ raise(Chef::Exceptions::InvalidHomeDirectory, "invalid path spec for User: '#{new_resource.username}', home directory: '#{new_resource.home}'")
end
end
@@ -322,9 +321,9 @@ user password using shadow hash.")
def ditto_home
skel = "/System/Library/User Template/English.lproj"
- raise(Chef::Exceptions::User,"can't find skel at: #{skel}") unless ::File.exists?(skel)
+ raise(Chef::Exceptions::User, "can't find skel at: #{skel}") unless ::File.exists?(skel)
shell_out! "ditto '#{skel}' '#{new_resource.home}'"
- ::FileUtils.chown_R(new_resource.username,new_resource.gid.to_s,new_resource.home)
+ ::FileUtils.chown_R(new_resource.username, new_resource.gid.to_s, new_resource.home)
end
def move_home
@@ -332,10 +331,10 @@ user password using shadow hash.")
src = current_resource.home
FileUtils.mkdir_p(new_resource.home)
- files = ::Dir.glob("#{Chef::Util::PathHelper.escape_glob(src)}/*", ::File::FNM_DOTMATCH) - ["#{src}/.","#{src}/.."]
- ::FileUtils.mv(files,new_resource.home, :force => true)
+ files = ::Dir.glob("#{Chef::Util::PathHelper.escape_glob(src)}/*", ::File::FNM_DOTMATCH) - ["#{src}/.", "#{src}/.."]
+ ::FileUtils.mv(files, new_resource.home, :force => true)
::FileUtils.rmdir(src)
- ::FileUtils.chown_R(new_resource.username,new_resource.gid.to_s,new_resource.home)
+ ::FileUtils.chown_R(new_resource.username, new_resource.gid.to_s, new_resource.home)
end
#
@@ -384,7 +383,7 @@ user password using shadow hash.")
# Prepares the password shadow info based on the platform version.
#
def prepare_password_shadow_info
- shadow_info = { }
+ shadow_info = {}
entropy = nil
salt = nil
iterations = nil
@@ -420,7 +419,7 @@ user password using shadow hash.")
)
end
- pbkdf_info = { }
+ pbkdf_info = {}
pbkdf_info["entropy"] = StringIO.new
pbkdf_info["entropy"].string = entropy
pbkdf_info["salt"] = StringIO.new
@@ -465,7 +464,7 @@ user password using shadow hash.")
# Unlocks the user
#
def unlock_user
- auth_string = authentication_authority.gsub(/AuthenticationAuthority: /,"").gsub(/;DisabledUser;/,"").strip
+ auth_string = authentication_authority.gsub(/AuthenticationAuthority: /, "").gsub(/;DisabledUser;/, "").strip
run_dscl("create /Users/#{new_resource.username} AuthenticationAuthority '#{auth_string}'")
end
@@ -655,16 +654,16 @@ user password using shadow hash.")
def run_dscl(*args)
result = shell_out("dscl . -#{args.join(' ')}")
return "" if ( args.first =~ /^delete/ ) && ( result.exitstatus != 0 )
- raise(Chef::Exceptions::DsclCommandFailed,"dscl error: #{result.inspect}") unless result.exitstatus == 0
- raise(Chef::Exceptions::DsclCommandFailed,"dscl error: #{result.inspect}") if result.stdout =~ /No such key: /
+ raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") unless result.exitstatus == 0
+ raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if result.stdout =~ /No such key: /
result.stdout
end
def run_plutil(*args)
result = shell_out("plutil -#{args.join(' ')}")
- raise(Chef::Exceptions::PlistUtilCommandFailed,"plutil error: #{result.inspect}") unless result.exitstatus == 0
+ raise(Chef::Exceptions::PlistUtilCommandFailed, "plutil error: #{result.inspect}") unless result.exitstatus == 0
if result.stdout.encoding == Encoding::ASCII_8BIT
- result.stdout.encode("utf-8", "binary", :undef => :replace, :invalid => :replace, :replace => "?")
+ result.stdout.encode("utf-8", "binary", :undef => :replace, :invalid => :replace, :replace => "?")
else
result.stdout
end
@@ -675,7 +674,7 @@ user password using shadow hash.")
end
def convert_to_binary(string)
- string.unpack("a2"*(string.size/2)).collect { |i| i.hex.chr }.join
+ string.unpack("a2" * (string.size / 2)).collect { |i| i.hex.chr }.join
end
def salted_sha512?(string)
@@ -684,7 +683,7 @@ user password using shadow hash.")
def salted_sha512_password_match?
# Salt is included in the first 4 bytes of shadow data
- salt = current_resource.password.slice(0,8)
+ salt = current_resource.password.slice(0, 8)
shadow = OpenSSL::Digest::SHA512.hexdigest(convert_to_binary(salt) + new_resource.password)
current_resource.password == salt + shadow
end
diff --git a/lib/chef/provider/user/pw.rb b/lib/chef/provider/user/pw.rb
index 8bb234700e..949a21790b 100644
--- a/lib/chef/provider/user/pw.rb
+++ b/lib/chef/provider/user/pw.rb
@@ -77,7 +77,7 @@ class Chef
"uid" => "-u",
"shell" => "-s",
}
- field_list.sort{ |a,b| a[0] <=> b[0] }.each do |field, option|
+ field_list.sort { |a, b| a[0] <=> b[0] }.each do |field, option|
field_symbol = field.to_sym
if @current_resource.send(field_symbol) != @new_resource.send(field_symbol)
if @new_resource.send(field_symbol)
diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb
index 4779dedd94..aabd4b5f68 100644
--- a/lib/chef/provider/user/useradd.rb
+++ b/lib/chef/provider/user/useradd.rb
@@ -55,7 +55,7 @@ class Chef
def check_lock
# we can get an exit code of 1 even when it's successful on
# rhel/centos (redhat bug 578534). See additional error checks below.
- passwd_s = shell_out!("passwd", "-S", new_resource.username, :returns => [0,1])
+ passwd_s = shell_out!("passwd", "-S", new_resource.username, :returns => [0, 1])
if whyrun_mode? && passwd_s.stdout.empty? && passwd_s.stderr.match(/does not exist/)
# if we're in whyrun mode and the user is not yet created we assume it would be
return false
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb
index 0a7505ddc3..9545b1fd59 100644
--- a/lib/chef/provider/user/windows.rb
+++ b/lib/chef/provider/user/windows.rb
@@ -29,7 +29,7 @@ class Chef
provides :user, os: "windows"
- def initialize(new_resource,run_context)
+ def initialize(new_resource, run_context)
super
@net_user = Chef::Util::Windows::NetUser.new(@new_resource.username)
end
@@ -37,7 +37,7 @@ class Chef
def load_current_resource
if @new_resource.gid
Chef::Log.warn("The 'gid' attribute is not implemented by the Windows platform. Please use the 'group' resource to assign a user to a group.")
- end
+ end
@current_resource = Chef::Resource::User.new(@new_resource.name)
@current_resource.username(@new_resource.username)
@@ -98,7 +98,7 @@ class Chef
end
def set_options
- opts = {:name => @new_resource.username}
+ opts = { :name => @new_resource.username }
field_list = {
"comment" => "full_name",
@@ -108,7 +108,7 @@ class Chef
"password" => "password",
}
- field_list.sort{ |a,b| a[0] <=> b[0] }.each do |field, option|
+ field_list.sort { |a, b| a[0] <=> b[0] }.each do |field, option|
field_symbol = field.to_sym
if @current_resource.send(field_symbol) != @new_resource.send(field_symbol)
if @new_resource.send(field_symbol)
diff --git a/lib/chef/provider/windows_script.rb b/lib/chef/provider/windows_script.rb
index e500e16c8b..2de127addf 100644
--- a/lib/chef/provider/windows_script.rb
+++ b/lib/chef/provider/windows_script.rb
@@ -29,7 +29,7 @@ class Chef
include Chef::Mixin::WindowsArchitectureHelper
- def initialize( new_resource, run_context, script_extension="")
+ def initialize( new_resource, run_context, script_extension = "")
super( new_resource, run_context )
@script_extension = script_extension
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index 20032e5b6a..3a91781b2e 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -17,7 +17,6 @@
# limitations under the License.
#
-
require "chef/dsl/recipe"
require "chef/dsl/data_query"
require "chef/dsl/platform_introspection"
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 1791e4143e..032effe4db 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -132,7 +132,7 @@ class Chef
# used for notifications to this resource).
# @param run_context The context of the Chef run. Corresponds to #run_context.
#
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
name(name) unless name.nil?
@run_context = run_context
@noop = nil
@@ -167,7 +167,7 @@ class Chef
# @param arg [Array[Symbol], Symbol] A list of actions (e.g. `:create`)
# @return [Array[Symbol]] the list of actions.
#
- def action(arg=nil)
+ def action(arg = nil)
if arg
arg = Array(arg).map(&:to_sym)
arg.each do |action|
@@ -240,7 +240,7 @@ class Chef
# notifies :create, bar
# end
#
- def notifies(action, resource_spec, timing=:delayed)
+ def notifies(action, resource_spec, timing = :delayed)
# when using old-style resources(:template => "/foo.txt") style, you
# could end up with multiple resources.
validate_resource_spec!(resource_spec)
@@ -327,7 +327,7 @@ class Chef
# subscribes :create, [ bar, baz ]
# end
#
- def subscribes(action, resources, timing=:delayed)
+ def subscribes(action, resources, timing = :delayed)
resources = [resources].flatten
resources.each do |resource|
if resource.is_a?(String)
@@ -364,7 +364,7 @@ class Chef
# @param opts [Hash] Options control the execution of the command
# @param block [Proc] A ruby block to run. Ignored if a command is given.
#
- def only_if(command=nil, opts={}, &block)
+ def only_if(command = nil, opts = {}, &block)
if command || block_given?
@only_if << Conditional.only_if(self, command, opts, &block)
end
@@ -394,7 +394,7 @@ class Chef
# @param opts [Hash] Options control the execution of the command
# @param block [Proc] A ruby block to run. Ignored if a command is given.
#
- def not_if(command=nil, opts={}, &block)
+ def not_if(command = nil, opts = {}, &block)
if command || block_given?
@not_if << Conditional.not_if(self, command, opts, &block)
end
@@ -411,7 +411,7 @@ class Chef
# @param arg [Integer] The number of retries.
# @return [Integer] The number of retries.
#
- def retries(arg=nil)
+ def retries(arg = nil)
set_or_return(:retries, arg, kind_of: Integer)
end
attr_writer :retries
@@ -422,7 +422,7 @@ class Chef
# @param arg [Integer] The number of seconds to wait between retries.
# @return [Integer] The number of seconds to wait between retries.
#
- def retry_delay(arg=nil)
+ def retry_delay(arg = nil)
set_or_return(:retry_delay, arg, kind_of: Integer)
end
attr_writer :retry_delay
@@ -434,7 +434,7 @@ class Chef
# @param arg [Boolean] Whether this resource is sensitive or not.
# @return [Boolean] Whether this resource is sensitive or not.
#
- def sensitive(arg=nil)
+ def sensitive(arg = nil)
set_or_return(:sensitive, arg, :kind_of => [ TrueClass, FalseClass ])
end
attr_writer :sensitive
@@ -468,7 +468,7 @@ class Chef
# symbol/name.
# @return [Class, Symbol, String] The Guard interpreter resource.
#
- def guard_interpreter(arg=nil)
+ def guard_interpreter(arg = nil)
if arg.nil?
@guard_interpreter || @default_guard_interpreter
else
@@ -535,7 +535,7 @@ class Chef
# @param arg [Boolean] Whether to ignore failures.
# @return Whether this resource will ignore failures.
#
- def ignore_failure(arg=nil)
+ def ignore_failure(arg = nil)
set_or_return(:ignore_failure, arg, kind_of: [ TrueClass, FalseClass ])
end
attr_writer :ignore_failure
@@ -567,7 +567,7 @@ class Chef
#
# @raise Any error that occurs during the actual action.
#
- def run_action(action, notification_type=nil, notifying_resource=nil)
+ def run_action(action, notification_type = nil, notifying_resource = nil)
# reset state in case of multiple actions on the same resource.
@elapsed_time = 0
start_time = Time.now
@@ -647,7 +647,7 @@ class Chef
ivars.each do |ivar|
if (value = instance_variable_get(ivar)) && !(value.respond_to?(:empty?) && value.empty?)
value_string = value.respond_to?(:to_text) ? value.to_text : value.inspect
- text << " #{ivar.to_s.sub(/^@/,'')} #{value_string}\n"
+ text << " #{ivar.to_s.sub(/^@/, '')} #{value_string}\n"
end
end
[@not_if, @only_if].flatten.each do |conditional|
@@ -692,7 +692,7 @@ class Chef
end
safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
safe_ivars.each do |iv|
- key = iv.to_s.sub(/^@/,"").to_sym
+ key = iv.to_s.sub(/^@/, "").to_sym
next if result.has_key?(key)
result[key] = instance_variable_get(iv)
end
@@ -701,7 +701,7 @@ class Chef
def self.json_create(o)
resource = self.new(o["instance_vars"]["@name"])
- o["instance_vars"].each do |k,v|
+ o["instance_vars"].each do |k, v|
resource.instance_variable_set("@#{k}".to_sym, v)
end
resource
@@ -730,7 +730,7 @@ class Chef
#
# @see Chef::Resource.action_class
#
- def provider(arg=nil)
+ def provider(arg = nil)
klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
lookup_provider_constant(arg)
else
@@ -739,6 +739,7 @@ class Chef
set_or_return(:provider, klass, kind_of: [ Class ]) ||
self.class.action_class
end
+
def provider=(arg)
provider(arg)
end
@@ -791,7 +792,7 @@ class Chef
# @raise [ArgumentError] If no arguments are passed and the resource has
# more than one identity property.
#
- def self.identity_property(name=nil)
+ def self.identity_property(name = nil)
result = identity_properties(*Array(name))
if result.size > 1
raise Chef::Exceptions::MultipleIdentityError, "identity_property cannot be called on an object with more than one identity property (#{result.map { |r| r.name }.join(", ")})."
@@ -813,7 +814,7 @@ class Chef
# @raise [ArgumentError] If no arguments are passed and the resource has
# more than one identity property.
#
- def self.identity_attr(name=nil)
+ def self.identity_attr(name = nil)
property = identity_property(name)
return nil if !property
property.name
@@ -842,7 +843,7 @@ class Chef
# have.
#
attr_accessor :allowed_actions
- def allowed_actions(value=NOT_PASSED)
+ def allowed_actions(value = NOT_PASSED)
if value != NOT_PASSED
self.allowed_actions = value
end
@@ -900,7 +901,7 @@ class Chef
def updated=(true_or_false)
Chef::Log.warn("Chef::Resource#updated=(true|false) is deprecated. Please call #updated_by_last_action(true|false) instead.")
Chef::Log.warn("Called from:")
- caller[0..3].each {|line| Chef::Log.warn(line)}
+ caller[0..3].each { |line| Chef::Log.warn(line) }
updated_by_last_action(true_or_false)
@updated = true_or_false
end
@@ -927,13 +928,14 @@ class Chef
# this resource. Default: {}
# @return Hash{Symbol=>Boolean} An array of things this resource supports.
#
- def supports(args={})
+ def supports(args = {})
if args.any?
@supports = args
else
@supports
end
end
+
def supports=(args)
supports(args)
end
@@ -977,7 +979,7 @@ class Chef
#
# @return [Symbol] The name of this resource type (e.g. `:execute`).
#
- def self.resource_name(name=NOT_PASSED)
+ def self.resource_name(name = NOT_PASSED)
# Setter
if name != NOT_PASSED
remove_canonical_dsl
@@ -996,6 +998,7 @@ class Chef
end
@resource_name
end
+
def self.resource_name=(name)
resource_name(name)
end
@@ -1029,7 +1032,7 @@ class Chef
#
# @deprecated Use `provides` on the provider, or `provider` on the resource, instead.
#
- def self.provider_base(arg=nil)
+ def self.provider_base(arg = nil)
if arg
Chef.log_deprecation("Resource.provider_base is deprecated and will be removed in Chef 13. Use provides on the provider, or provider on the resource, instead.")
end
@@ -1052,6 +1055,7 @@ class Chef
end
@allowed_actions |= actions.flatten
end
+
def self.allowed_actions=(value)
@allowed_actions = value.uniq
end
@@ -1069,7 +1073,7 @@ class Chef
#
# @return [Array<Symbol>] The default actions for the resource.
#
- def self.default_action(action_name=NOT_PASSED)
+ def self.default_action(action_name = NOT_PASSED)
unless action_name.equal?(NOT_PASSED)
@default_action = Array(action_name).map(&:to_sym)
self.allowed_actions |= @default_action
@@ -1083,6 +1087,7 @@ class Chef
[:nothing]
end
end
+
def self.default_action=(action_name)
default_action action_name
end
@@ -1313,6 +1318,7 @@ class Chef
def self.sorted_descendants
@@sorted_descendants ||= descendants.sort_by { |x| x.to_s }
end
+
def self.inherited(child)
super
@@sorted_descendants = nil
@@ -1324,7 +1330,6 @@ class Chef
end
end
-
# If an unknown method is invoked, determine whether the enclosing Provider's
# lexical scope can fulfill the request. E.g. This happens when the Resource's
# block invokes new_resource.
@@ -1444,7 +1449,7 @@ class Chef
end
# ??? TODO Seems unused. Delete?
- def noop(tf=nil)
+ def noop(tf = nil)
if !tf.nil?
raise ArgumentError, "noop must be true or false!" unless tf == true || tf == false
@noop = tf
@@ -1540,7 +1545,6 @@ class Chef
Chef::Resource.const_set(class_name, resource_class)
deprecated_constants[class_name.to_sym] = resource_class
end
-
end
def self.deprecated_constants
@@ -1548,7 +1552,7 @@ class Chef
end
# @api private
- def lookup_provider_constant(name, action=:nothing)
+ def lookup_provider_constant(name, action = :nothing)
begin
self.class.provider_base.const_get(convert_to_class_name(name.to_s))
rescue NameError => e
diff --git a/lib/chef/resource/action_class.rb b/lib/chef/resource/action_class.rb
index 275680ee2d..3d9f2f3e7c 100644
--- a/lib/chef/resource/action_class.rb
+++ b/lib/chef/resource/action_class.rb
@@ -36,7 +36,7 @@ class Chef
# We clear desired state in the copy, because it is supposed to be actual state.
# We keep identity properties and non-desired-state, which are assumed to be
# "control" values like `recurse: true`
- current_resource.class.properties.each do |name,property|
+ current_resource.class.properties.each do |name, property|
if property.desired_state? && !property.identity? && !property.name_property?
property.reset(current_resource)
end
diff --git a/lib/chef/resource/bash.rb b/lib/chef/resource/bash.rb
index 4abaf629cf..1238eedc42 100644
--- a/lib/chef/resource/bash.rb
+++ b/lib/chef/resource/bash.rb
@@ -23,7 +23,7 @@ class Chef
class Resource
class Bash < Chef::Resource::Script
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@interpreter = "bash"
end
diff --git a/lib/chef/resource/batch.rb b/lib/chef/resource/batch.rb
index e6eed983f0..10e96839fb 100644
--- a/lib/chef/resource/batch.rb
+++ b/lib/chef/resource/batch.rb
@@ -24,7 +24,7 @@ class Chef
provides :batch, os: "windows"
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super(name, run_context, nil, "cmd.exe")
end
diff --git a/lib/chef/resource/breakpoint.rb b/lib/chef/resource/breakpoint.rb
index 040acc40a3..a5eed0da94 100644
--- a/lib/chef/resource/breakpoint.rb
+++ b/lib/chef/resource/breakpoint.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "chef/resource"
class Chef
@@ -24,7 +23,7 @@ class Chef
class Breakpoint < Chef::Resource
default_action :break
- def initialize(action="break", *args)
+ def initialize(action = "break", *args)
super(caller.first, *args)
end
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb
index d2f8f98aff..e08bacc625 100644
--- a/lib/chef/resource/chef_gem.rb
+++ b/lib/chef/resource/chef_gem.rb
@@ -25,7 +25,7 @@ class Chef
resource_name :chef_gem
property :gem_binary, default: "#{RbConfig::CONFIG['bindir']}/gem",
- callbacks: {
+ callbacks: {
"The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { |v| v == "#{RbConfig::CONFIG['bindir']}/gem" }
}
property :compile_time, [ true, false, nil ], default: lazy { Chef::Config[:chef_gem_compile_time] }, desired_state: false
diff --git a/lib/chef/resource/chocolatey_package.rb b/lib/chef/resource/chocolatey_package.rb
index 4b4a537e7f..805d3a3121 100644
--- a/lib/chef/resource/chocolatey_package.rb
+++ b/lib/chef/resource/chocolatey_package.rb
@@ -26,7 +26,7 @@ class Chef
allowed_actions :install, :upgrade, :remove, :uninstall, :purge, :reconfig
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@resource_name = :chocolatey_package
end
diff --git a/lib/chef/resource/conditional.rb b/lib/chef/resource/conditional.rb
index 12fd55d572..cdb9f13c45 100644
--- a/lib/chef/resource/conditional.rb
+++ b/lib/chef/resource/conditional.rb
@@ -30,11 +30,11 @@ class Chef
private :new
end
- def self.not_if(parent_resource, command=nil, command_opts={}, &block)
+ def self.not_if(parent_resource, command = nil, command_opts = {}, &block)
new(:not_if, parent_resource, command, command_opts, &block)
end
- def self.only_if(parent_resource, command=nil, command_opts={}, &block)
+ def self.only_if(parent_resource, command = nil, command_opts = {}, &block)
new(:only_if, parent_resource, command, command_opts, &block)
end
@@ -43,7 +43,7 @@ class Chef
attr_reader :command_opts
attr_reader :block
- def initialize(positivity, parent_resource, command=nil, command_opts={}, &block)
+ def initialize(positivity, parent_resource, command = nil, command_opts = {}, &block)
@positivity = positivity
@command, @command_opts = command, command_opts
@block = block
@@ -55,7 +55,7 @@ class Chef
def configure
case @command
- when String,Array
+ when String, Array
@guard_interpreter = Chef::GuardInterpreter.for_resource(@parent_resource, @command, @command_opts)
@block = nil
when nil
diff --git a/lib/chef/resource/cookbook_file.rb b/lib/chef/resource/cookbook_file.rb
index 6f1da0aa01..785cf693be 100644
--- a/lib/chef/resource/cookbook_file.rb
+++ b/lib/chef/resource/cookbook_file.rb
@@ -29,18 +29,18 @@ class Chef
default_action :create
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@provider = Chef::Provider::CookbookFile
@source = ::File.basename(name)
@cookbook = nil
end
- def source(source_filename=nil)
+ def source(source_filename = nil)
set_or_return(:source, source_filename, :kind_of => [ String, Array ])
end
- def cookbook(cookbook_name=nil)
+ def cookbook(cookbook_name = nil)
set_or_return(:cookbook, cookbook_name, :kind_of => String)
end
diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb
index e105cc94d8..26711fde16 100644
--- a/lib/chef/resource/cron.rb
+++ b/lib/chef/resource/cron.rb
@@ -30,7 +30,7 @@ class Chef
default_action :create
allowed_actions :create, :delete
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@minute = "*"
@hour = "*"
@@ -47,7 +47,7 @@ class Chef
@environment = {}
end
- def minute(arg=nil)
+ def minute(arg = nil)
if arg.is_a?(Integer)
converted_arg = arg.to_s
else
@@ -64,7 +64,7 @@ class Chef
)
end
- def hour(arg=nil)
+ def hour(arg = nil)
if arg.is_a?(Integer)
converted_arg = arg.to_s
else
@@ -81,7 +81,7 @@ class Chef
)
end
- def day(arg=nil)
+ def day(arg = nil)
if arg.is_a?(Integer)
converted_arg = arg.to_s
else
@@ -98,7 +98,7 @@ class Chef
)
end
- def month(arg=nil)
+ def month(arg = nil)
if arg.is_a?(Integer)
converted_arg = arg.to_s
else
@@ -115,7 +115,7 @@ class Chef
)
end
- def weekday(arg=nil)
+ def weekday(arg = nil)
if arg.is_a?(Integer)
converted_arg = arg.to_s
else
@@ -123,11 +123,11 @@ class Chef
end
begin
error_message = "You provided '#{arg}' as a weekday, acceptable values are "
- error_message << Provider::Cron::WEEKDAY_SYMBOLS.map {|sym| ":#{sym}"}.join(", ")
+ error_message << Provider::Cron::WEEKDAY_SYMBOLS.map { |sym| ":#{sym}" }.join(", ")
error_message << " and a string in crontab format"
if (arg.is_a?(Symbol) && !Provider::Cron::WEEKDAY_SYMBOLS.include?(arg)) ||
- (!arg.is_a?(Symbol) && integerize(arg) > 7) ||
- (!arg.is_a?(Symbol) && integerize(arg) < 0)
+ (!arg.is_a?(Symbol) && integerize(arg) > 7) ||
+ (!arg.is_a?(Symbol) && integerize(arg) < 0)
raise RangeError, error_message
end
rescue ArgumentError
@@ -139,7 +139,7 @@ class Chef
)
end
- def time(arg=nil)
+ def time(arg = nil)
set_or_return(
:time,
arg,
@@ -147,7 +147,7 @@ class Chef
)
end
- def mailto(arg=nil)
+ def mailto(arg = nil)
set_or_return(
:mailto,
arg,
@@ -155,7 +155,7 @@ class Chef
)
end
- def path(arg=nil)
+ def path(arg = nil)
set_or_return(
:path,
arg,
@@ -163,7 +163,7 @@ class Chef
)
end
- def home(arg=nil)
+ def home(arg = nil)
set_or_return(
:home,
arg,
@@ -171,7 +171,7 @@ class Chef
)
end
- def shell(arg=nil)
+ def shell(arg = nil)
set_or_return(
:shell,
arg,
@@ -179,7 +179,7 @@ class Chef
)
end
- def command(arg=nil)
+ def command(arg = nil)
set_or_return(
:command,
arg,
@@ -187,7 +187,7 @@ class Chef
)
end
- def user(arg=nil)
+ def user(arg = nil)
set_or_return(
:user,
arg,
@@ -195,7 +195,7 @@ class Chef
)
end
- def environment(arg=nil)
+ def environment(arg = nil)
set_or_return(
:environment,
arg,
diff --git a/lib/chef/resource/csh.rb b/lib/chef/resource/csh.rb
index b4bae13399..4e7c22b660 100644
--- a/lib/chef/resource/csh.rb
+++ b/lib/chef/resource/csh.rb
@@ -23,7 +23,7 @@ class Chef
class Resource
class Csh < Chef::Resource::Script
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@interpreter = "csh"
end
diff --git a/lib/chef/resource/deploy.rb b/lib/chef/resource/deploy.rb
index 797e2a664a..df301dd024 100644
--- a/lib/chef/resource/deploy.rb
+++ b/lib/chef/resource/deploy.rb
@@ -59,7 +59,7 @@ class Chef
default_action :deploy
allowed_actions :force_deploy, :deploy, :rollback
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@deploy_to = name
@environment = nil
@@ -67,8 +67,8 @@ class Chef
@copy_exclude = []
@purge_before_symlink = %w{log tmp/pids public/system}
@create_dirs_before_symlink = %w{tmp public config}
- @symlink_before_migrate = {"config/database.yml" => "config/database.yml"}
- @symlinks = {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}
+ @symlink_before_migrate = { "config/database.yml" => "config/database.yml" }
+ @symlinks = { "system" => "public/system", "pids" => "tmp/pids", "log" => "log" }
@revision = "HEAD"
@migrate = false
@rollback_on_error = false
@@ -99,7 +99,7 @@ class Chef
@current_path ||= @deploy_to + "/current"
end
- def depth(arg=@shallow_clone ? 5 : nil)
+ def depth(arg = @shallow_clone ? 5 : nil)
set_or_return(
:depth,
arg,
@@ -108,7 +108,7 @@ class Chef
end
# note: deploy_to is your application "meta-root."
- def deploy_to(arg=nil)
+ def deploy_to(arg = nil)
set_or_return(
:deploy_to,
arg,
@@ -116,7 +116,7 @@ class Chef
)
end
- def repo(arg=nil)
+ def repo(arg = nil)
set_or_return(
:repo,
arg,
@@ -125,7 +125,7 @@ class Chef
end
alias :repository :repo
- def remote(arg=nil)
+ def remote(arg = nil)
set_or_return(
:remote,
arg,
@@ -133,7 +133,7 @@ class Chef
)
end
- def role(arg=nil)
+ def role(arg = nil)
set_or_return(
:role,
arg,
@@ -141,7 +141,7 @@ class Chef
)
end
- def restart_command(arg=nil, &block)
+ def restart_command(arg = nil, &block)
arg ||= block
set_or_return(
:restart_command,
@@ -151,7 +151,7 @@ class Chef
end
alias :restart :restart_command
- def migrate(arg=nil)
+ def migrate(arg = nil)
set_or_return(
:migrate,
arg,
@@ -159,7 +159,7 @@ class Chef
)
end
- def migration_command(arg=nil)
+ def migration_command(arg = nil)
set_or_return(
:migration_command,
arg,
@@ -167,7 +167,7 @@ class Chef
)
end
- def rollback_on_error(arg=nil)
+ def rollback_on_error(arg = nil)
set_or_return(
:rollback_on_error,
arg,
@@ -175,7 +175,7 @@ class Chef
)
end
- def user(arg=nil)
+ def user(arg = nil)
set_or_return(
:user,
arg,
@@ -183,7 +183,7 @@ class Chef
)
end
- def group(arg=nil)
+ def group(arg = nil)
set_or_return(
:group,
arg,
@@ -191,7 +191,7 @@ class Chef
)
end
- def enable_submodules(arg=nil)
+ def enable_submodules(arg = nil)
set_or_return(
:enable_submodules,
arg,
@@ -199,7 +199,7 @@ class Chef
)
end
- def shallow_clone(arg=nil)
+ def shallow_clone(arg = nil)
set_or_return(
:shallow_clone,
arg,
@@ -207,7 +207,7 @@ class Chef
)
end
- def repository_cache(arg=nil)
+ def repository_cache(arg = nil)
set_or_return(
:repository_cache,
arg,
@@ -215,7 +215,7 @@ class Chef
)
end
- def copy_exclude(arg=nil)
+ def copy_exclude(arg = nil)
set_or_return(
:copy_exclude,
arg,
@@ -223,7 +223,7 @@ class Chef
)
end
- def revision(arg=nil)
+ def revision(arg = nil)
set_or_return(
:revision,
arg,
@@ -232,7 +232,7 @@ class Chef
end
alias :branch :revision
- def git_ssh_wrapper(arg=nil)
+ def git_ssh_wrapper(arg = nil)
set_or_return(
:git_ssh_wrapper,
arg,
@@ -241,7 +241,7 @@ class Chef
end
alias :ssh_wrapper :git_ssh_wrapper
- def svn_username(arg=nil)
+ def svn_username(arg = nil)
set_or_return(
:svn_username,
arg,
@@ -249,7 +249,7 @@ class Chef
)
end
- def svn_password(arg=nil)
+ def svn_password(arg = nil)
set_or_return(
:svn_password,
arg,
@@ -257,7 +257,7 @@ class Chef
)
end
- def svn_arguments(arg=nil)
+ def svn_arguments(arg = nil)
set_or_return(
:svn_arguments,
arg,
@@ -265,14 +265,14 @@ class Chef
)
end
- def svn_info_args(arg=nil)
+ def svn_info_args(arg = nil)
set_or_return(
:svn_arguments,
arg,
:kind_of => [ String ])
end
- def scm_provider(arg=nil)
+ def scm_provider(arg = nil)
klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
lookup_provider_constant(arg)
else
@@ -291,7 +291,7 @@ class Chef
Chef::Provider::Deploy
end
- def svn_force_export(arg=nil)
+ def svn_force_export(arg = nil)
set_or_return(
:svn_force_export,
arg,
@@ -299,11 +299,11 @@ class Chef
)
end
- def environment(arg=nil)
+ def environment(arg = nil)
if arg.is_a?(String)
Chef::Log.debug "Setting RAILS_ENV, RACK_ENV, and MERB_ENV to `#{arg}'"
Chef::Log.warn "[DEPRECATED] please modify your deploy recipe or attributes to set the environment using a hash"
- arg = {"RAILS_ENV"=>arg,"MERB_ENV"=>arg,"RACK_ENV"=>arg}
+ arg = { "RAILS_ENV" => arg, "MERB_ENV" => arg, "RACK_ENV" => arg }
end
set_or_return(
:environment,
@@ -313,7 +313,7 @@ class Chef
end
# The number of old release directories to keep around after cleanup
- def keep_releases(arg=nil)
+ def keep_releases(arg = nil)
[set_or_return(
:keep_releases,
arg,
@@ -324,7 +324,7 @@ class Chef
# SCM clone/checkout before symlinking. Use this to get rid of files and
# directories you want to be shared between releases.
# Default: ["log", "tmp/pids", "public/system"]
- def purge_before_symlink(arg=nil)
+ def purge_before_symlink(arg = nil)
set_or_return(
:purge_before_symlink,
arg,
@@ -340,7 +340,7 @@ class Chef
# then specify tmp here so that the tmp directory will exist when you
# symlink the pids directory in to the current release.
# Default: ["tmp", "public", "config"]
- def create_dirs_before_symlink(arg=nil)
+ def create_dirs_before_symlink(arg = nil)
set_or_return(
:create_dirs_before_symlink,
arg,
@@ -354,7 +354,7 @@ class Chef
# $shared/pids that you would like to symlink as $current_release/tmp/pids
# you specify it as "pids" => "tmp/pids"
# Default {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}
- def symlinks(arg=nil)
+ def symlinks(arg = nil)
set_or_return(
:symlinks,
arg,
@@ -369,7 +369,7 @@ class Chef
# For a rails/merb app, this is used to link in a known good database.yml
# (with the production db password) before running migrate.
# Default {"config/database.yml" => "config/database.yml"}
- def symlink_before_migrate(arg=nil)
+ def symlink_before_migrate(arg = nil)
set_or_return(
:symlink_before_migrate,
arg,
@@ -378,30 +378,30 @@ class Chef
end
# Callback fires before migration is run.
- def before_migrate(arg=nil, &block)
+ def before_migrate(arg = nil, &block)
arg ||= block
set_or_return(:before_migrate, arg, :kind_of => [Proc, String])
end
# Callback fires before symlinking
- def before_symlink(arg=nil, &block)
+ def before_symlink(arg = nil, &block)
arg ||= block
set_or_return(:before_symlink, arg, :kind_of => [Proc, String])
end
# Callback fires before restart
- def before_restart(arg=nil, &block)
+ def before_restart(arg = nil, &block)
arg ||= block
set_or_return(:before_restart, arg, :kind_of => [Proc, String])
end
# Callback fires after restart
- def after_restart(arg=nil, &block)
+ def after_restart(arg = nil, &block)
arg ||= block
set_or_return(:after_restart, arg, :kind_of => [Proc, String])
end
- def additional_remotes(arg=nil)
+ def additional_remotes(arg = nil)
set_or_return(
:additional_remotes,
arg,
@@ -409,7 +409,7 @@ class Chef
)
end
- def enable_checkout(arg=nil)
+ def enable_checkout(arg = nil)
set_or_return(
:enable_checkout,
arg,
@@ -417,7 +417,7 @@ class Chef
)
end
- def checkout_branch(arg=nil)
+ def checkout_branch(arg = nil)
set_or_return(
:checkout_branch,
arg,
@@ -430,7 +430,7 @@ class Chef
# timeout for SCM operations. The deploy resource must therefore support
# a timeout method, but the timeout it describes is for SCM operations,
# not the overall deployment. This is potentially confusing.
- def timeout(arg=nil)
+ def timeout(arg = nil)
set_or_return(
:timeout,
arg,
diff --git a/lib/chef/resource/directory.rb b/lib/chef/resource/directory.rb
index 1f0c4cdb51..07c29b48a6 100644
--- a/lib/chef/resource/directory.rb
+++ b/lib/chef/resource/directory.rb
@@ -35,13 +35,13 @@ class Chef
default_action :create
allowed_actions :create, :delete
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@path = name
@recursive = false
end
- def recursive(arg=nil)
+ def recursive(arg = nil)
set_or_return(
:recursive,
arg,
@@ -49,7 +49,7 @@ class Chef
)
end
- def path(arg=nil)
+ def path(arg = nil)
set_or_return(
:path,
arg,
diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb
index d1777e77d9..4a55ce1d70 100644
--- a/lib/chef/resource/dsc_resource.rb
+++ b/lib/chef/resource/dsc_resource.rb
@@ -52,7 +52,7 @@ class Chef
@reboot_action = :nothing
end
- def resource(value=nil)
+ def resource(value = nil)
if value
@resource = value
else
@@ -60,7 +60,7 @@ class Chef
end
end
- def module_name(value=nil)
+ def module_name(value = nil)
if value
@module_name = value
else
@@ -68,7 +68,7 @@ class Chef
end
end
- def property(property_name, value=nil)
+ def property(property_name, value = nil)
if not property_name.is_a?(Symbol)
raise TypeError, "A property name of type Symbol must be specified, '#{property_name}' of type #{property_name.class} was given"
end
@@ -91,7 +91,7 @@ class Chef
# If the set method of the DSC resource indicate that a reboot
# is necessary, reboot_action provides the mechanism for a reboot to
# be requested.
- def reboot_action(value=nil)
+ def reboot_action(value = nil)
if value
@reboot_action = value
else
@@ -99,13 +99,14 @@ class Chef
end
end
- def timeout(arg=nil)
+ def timeout(arg = nil)
set_or_return(
:timeout,
arg,
:kind_of => [ Integer ],
)
end
+
private
def value_of(value)
diff --git a/lib/chef/resource/dsc_script.rb b/lib/chef/resource/dsc_script.rb
index 633a98c456..a8eeeb1d4f 100644
--- a/lib/chef/resource/dsc_script.rb
+++ b/lib/chef/resource/dsc_script.rb
@@ -28,12 +28,12 @@ class Chef
default_action :run
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@imports = {}
end
- def code(arg=nil)
+ def code(arg = nil)
if arg && command
raise ArgumentError, "Only one of 'code' and 'command' attributes may be specified"
end
@@ -47,7 +47,7 @@ class Chef
)
end
- def configuration_name(arg=nil)
+ def configuration_name(arg = nil)
if arg && code
raise ArgumentError, "Attribute `configuration_name` may not be set if `code` is set"
end
@@ -58,7 +58,7 @@ class Chef
)
end
- def command(arg=nil)
+ def command(arg = nil)
if arg && code
raise ArgumentError, "The 'code' and 'command' attributes may not be used together"
end
@@ -69,7 +69,7 @@ class Chef
)
end
- def configuration_data(arg=nil)
+ def configuration_data(arg = nil)
if arg && configuration_data_script
raise ArgumentError, "The 'configuration_data' and 'configuration_data_script' attributes may not be used together"
end
@@ -80,7 +80,7 @@ class Chef
)
end
- def configuration_data_script(arg=nil)
+ def configuration_data_script(arg = nil)
if arg && configuration_data
raise ArgumentError, "The 'configuration_data' and 'configuration_data_script' attributes may not be used together"
end
@@ -91,7 +91,7 @@ class Chef
)
end
- def imports(module_name=nil, *args)
+ def imports(module_name = nil, *args)
if module_name
@imports[module_name] ||= []
if args.length == 0
@@ -104,7 +104,7 @@ class Chef
end
end
- def flags(arg=nil)
+ def flags(arg = nil)
set_or_return(
:flags,
arg,
@@ -112,7 +112,7 @@ class Chef
)
end
- def cwd(arg=nil)
+ def cwd(arg = nil)
set_or_return(
:cwd,
arg,
@@ -120,7 +120,7 @@ class Chef
)
end
- def environment(arg=nil)
+ def environment(arg = nil)
set_or_return(
:environment,
arg,
@@ -128,7 +128,7 @@ class Chef
)
end
- def timeout(arg=nil)
+ def timeout(arg = nil)
set_or_return(
:timeout,
arg,
diff --git a/lib/chef/resource/env.rb b/lib/chef/resource/env.rb
index a6caa3299a..a483b69ee5 100644
--- a/lib/chef/resource/env.rb
+++ b/lib/chef/resource/env.rb
@@ -30,14 +30,14 @@ class Chef
default_action :create
allowed_actions :create, :delete, :modify
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@key_name = name
@value = nil
@delim = nil
end
- def key_name(arg=nil)
+ def key_name(arg = nil)
set_or_return(
:key_name,
arg,
@@ -45,7 +45,7 @@ class Chef
)
end
- def value(arg=nil)
+ def value(arg = nil)
set_or_return(
:value,
arg,
@@ -53,7 +53,7 @@ class Chef
)
end
- def delim(arg=nil)
+ def delim(arg = nil)
set_or_return(
:delim,
arg,
diff --git a/lib/chef/resource/erl_call.rb b/lib/chef/resource/erl_call.rb
index 607bcc0fae..5b5273d31d 100644
--- a/lib/chef/resource/erl_call.rb
+++ b/lib/chef/resource/erl_call.rb
@@ -30,7 +30,7 @@ class Chef
default_action :run
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@code = "q()." # your erlang code goes here
@@ -40,7 +40,7 @@ class Chef
@node_name = "chef@localhost" # the erlang node hostname
end
- def code(arg=nil)
+ def code(arg = nil)
set_or_return(
:code,
arg,
@@ -48,7 +48,7 @@ class Chef
)
end
- def cookie(arg=nil)
+ def cookie(arg = nil)
set_or_return(
:cookie,
arg,
@@ -56,7 +56,7 @@ class Chef
)
end
- def distributed(arg=nil)
+ def distributed(arg = nil)
set_or_return(
:distributed,
arg,
@@ -64,7 +64,7 @@ class Chef
)
end
- def name_type(arg=nil)
+ def name_type(arg = nil)
set_or_return(
:name_type,
arg,
@@ -72,7 +72,7 @@ class Chef
)
end
- def node_name(arg=nil)
+ def node_name(arg = nil)
set_or_return(
:node_name,
arg,
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index 167720f09f..b30cc245bd 100644
--- a/lib/chef/resource/execute.rb
+++ b/lib/chef/resource/execute.rb
@@ -34,7 +34,7 @@ class Chef
default_action :run
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@command = name
@backup = 5
@@ -52,7 +52,7 @@ class Chef
@live_stream = false
end
- def umask(arg=nil)
+ def umask(arg = nil)
set_or_return(
:umask,
arg,
@@ -60,7 +60,7 @@ class Chef
)
end
- def command(arg=nil)
+ def command(arg = nil)
set_or_return(
:command,
arg,
@@ -68,7 +68,7 @@ class Chef
)
end
- def creates(arg=nil)
+ def creates(arg = nil)
set_or_return(
:creates,
arg,
@@ -76,7 +76,7 @@ class Chef
)
end
- def cwd(arg=nil)
+ def cwd(arg = nil)
set_or_return(
:cwd,
arg,
@@ -84,7 +84,7 @@ class Chef
)
end
- def environment(arg=nil)
+ def environment(arg = nil)
set_or_return(
:environment,
arg,
@@ -94,7 +94,7 @@ class Chef
alias :env :environment
- def group(arg=nil)
+ def group(arg = nil)
set_or_return(
:group,
arg,
@@ -102,14 +102,14 @@ class Chef
)
end
- def live_stream(arg=nil)
+ def live_stream(arg = nil)
set_or_return(
:live_stream,
arg,
:kind_of => [ TrueClass, FalseClass ])
end
- def path(arg=nil)
+ def path(arg = nil)
Chef::Log.warn "The 'path' attribute of 'execute' is not used by any provider in Chef 11 or Chef 12. Use 'environment' attribute to configure 'PATH'. This attribute will be removed in Chef 13."
set_or_return(
@@ -119,7 +119,7 @@ class Chef
)
end
- def returns(arg=nil)
+ def returns(arg = nil)
set_or_return(
:returns,
arg,
@@ -127,7 +127,7 @@ class Chef
)
end
- def timeout(arg=nil)
+ def timeout(arg = nil)
set_or_return(
:timeout,
arg,
@@ -135,7 +135,7 @@ class Chef
)
end
- def user(arg=nil)
+ def user(arg = nil)
set_or_return(
:user,
arg,
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
index f2606f72f0..ac6dc5fbdb 100644
--- a/lib/chef/resource/file.rb
+++ b/lib/chef/resource/file.rb
@@ -58,7 +58,7 @@ class Chef
property :manage_symlink_source, [ true, false ], desired_state: false
property :verifications, Array, default: lazy { [] }
- def verify(command=nil, opts={}, &block)
+ def verify(command = nil, opts = {}, &block)
if ! (command.nil? || [String, Symbol].include?(command.class))
raise ArgumentError, "verify requires either a string, symbol, or a block"
end
diff --git a/lib/chef/resource/file/verification.rb b/lib/chef/resource/file/verification.rb
index 1c00797668..e11035d33f 100644
--- a/lib/chef/resource/file/verification.rb
+++ b/lib/chef/resource/file/verification.rb
@@ -73,7 +73,7 @@ class Chef
end
def self.lookup(name)
- c = descendants.find {|d| d.provides?(name) }
+ c = descendants.find { |d| d.provides?(name) }
if c.nil?
raise Chef::Exceptions::VerificationNotFound.new "No file verification for #{name} found."
end
@@ -86,7 +86,7 @@ class Chef
@parent_resource = parent_resource
end
- def verify(path, opts={})
+ def verify(path, opts = {})
Chef::Log.debug("Running verification[#{self}] on #{path}")
if @block
verify_block(path, opts)
@@ -112,7 +112,7 @@ class Chef
"%{file} is deprecated in verify command and will not be "\
"supported in Chef 13. Please use %{path} instead."
) if @command.include?("%{file}")
- command = @command % {:file => path, :path => path}
+ command = @command % { :file => path, :path => path }
interpreter = Chef::GuardInterpreter.for_resource(@parent_resource, command, @command_opts)
interpreter.evaluate
end
diff --git a/lib/chef/resource/git.rb b/lib/chef/resource/git.rb
index 44d4c9b684..0d3b1438bf 100644
--- a/lib/chef/resource/git.rb
+++ b/lib/chef/resource/git.rb
@@ -22,12 +22,12 @@ class Chef
class Resource
class Git < Chef::Resource::Scm
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@additional_remotes = Hash[]
end
- def additional_remotes(arg=nil)
+ def additional_remotes(arg = nil)
set_or_return(
:additional_remotes,
arg,
diff --git a/lib/chef/resource/group.rb b/lib/chef/resource/group.rb
index 6a53e0de22..50a70b9e5f 100644
--- a/lib/chef/resource/group.rb
+++ b/lib/chef/resource/group.rb
@@ -28,7 +28,7 @@ class Chef
allowed_actions :create, :remove, :modify, :manage
default_action :create
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@group_name = name
@gid = nil
@@ -38,7 +38,7 @@ class Chef
@non_unique = false
end
- def group_name(arg=nil)
+ def group_name(arg = nil)
set_or_return(
:group_name,
arg,
@@ -46,7 +46,7 @@ class Chef
)
end
- def gid(arg=nil)
+ def gid(arg = nil)
set_or_return(
:gid,
arg,
@@ -54,7 +54,7 @@ class Chef
)
end
- def members(arg=nil)
+ def members(arg = nil)
converted_members = arg.is_a?(String) ? [].push(arg) : arg
set_or_return(
:members,
@@ -65,7 +65,7 @@ class Chef
alias_method :users, :members
- def excluded_members(arg=nil)
+ def excluded_members(arg = nil)
converted_members = arg.is_a?(String) ? [].push(arg) : arg
set_or_return(
:excluded_members,
@@ -74,8 +74,7 @@ class Chef
)
end
-
- def append(arg=nil)
+ def append(arg = nil)
set_or_return(
:append,
arg,
@@ -83,7 +82,7 @@ class Chef
)
end
- def system(arg=nil)
+ def system(arg = nil)
set_or_return(
:system,
arg,
@@ -91,7 +90,7 @@ class Chef
)
end
- def non_unique(arg=nil)
+ def non_unique(arg = nil)
set_or_return(
:non_unique,
arg,
diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb
index a8299a9064..be69e2f1df 100644
--- a/lib/chef/resource/http_request.rb
+++ b/lib/chef/resource/http_request.rb
@@ -29,14 +29,14 @@ class Chef
default_action :get
allowed_actions :get, :put, :post, :delete, :head, :options
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@message = name
@url = nil
@headers = {}
end
- def url(args=nil)
+ def url(args = nil)
set_or_return(
:url,
args,
@@ -44,7 +44,7 @@ class Chef
)
end
- def message(args=nil, &block)
+ def message(args = nil, &block)
args = block if block_given?
set_or_return(
:message,
@@ -53,7 +53,7 @@ class Chef
)
end
- def headers(args=nil)
+ def headers(args = nil)
set_or_return(
:headers,
args,
diff --git a/lib/chef/resource/ifconfig.rb b/lib/chef/resource/ifconfig.rb
index c751595380..94362b1c73 100644
--- a/lib/chef/resource/ifconfig.rb
+++ b/lib/chef/resource/ifconfig.rb
@@ -30,7 +30,7 @@ class Chef
default_action :add
allowed_actions :add, :delete, :enable, :disable
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@target = name
@hwaddr = nil
@@ -46,7 +46,7 @@ class Chef
@onparent = nil
end
- def target(arg=nil)
+ def target(arg = nil)
set_or_return(
:target,
arg,
@@ -54,7 +54,7 @@ class Chef
)
end
- def device(arg=nil)
+ def device(arg = nil)
set_or_return(
:device,
arg,
@@ -62,7 +62,7 @@ class Chef
)
end
- def hwaddr(arg=nil)
+ def hwaddr(arg = nil)
set_or_return(
:hwaddr,
arg,
@@ -70,7 +70,7 @@ class Chef
)
end
- def inet_addr(arg=nil)
+ def inet_addr(arg = nil)
set_or_return(
:inet_addr,
arg,
@@ -78,7 +78,7 @@ class Chef
)
end
- def bcast(arg=nil)
+ def bcast(arg = nil)
set_or_return(
:bcast,
arg,
@@ -86,7 +86,7 @@ class Chef
)
end
- def mask(arg=nil)
+ def mask(arg = nil)
set_or_return(
:mask,
arg,
@@ -94,7 +94,7 @@ class Chef
)
end
- def mtu(arg=nil)
+ def mtu(arg = nil)
set_or_return(
:mtu,
arg,
@@ -102,7 +102,7 @@ class Chef
)
end
- def metric(arg=nil)
+ def metric(arg = nil)
set_or_return(
:metric,
arg,
@@ -110,7 +110,7 @@ class Chef
)
end
- def onboot(arg=nil)
+ def onboot(arg = nil)
set_or_return(
:onboot,
arg,
@@ -118,7 +118,7 @@ class Chef
)
end
- def network(arg=nil)
+ def network(arg = nil)
set_or_return(
:network,
arg,
@@ -126,7 +126,7 @@ class Chef
)
end
- def bootproto(arg=nil)
+ def bootproto(arg = nil)
set_or_return(
:bootproto,
arg,
@@ -134,7 +134,7 @@ class Chef
)
end
- def onparent(arg=nil)
+ def onparent(arg = nil)
set_or_return(
:onparent,
arg,
diff --git a/lib/chef/resource/ksh.rb b/lib/chef/resource/ksh.rb
index 3e54b5e836..3097156329 100644
--- a/lib/chef/resource/ksh.rb
+++ b/lib/chef/resource/ksh.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class Ksh < Chef::Resource::Script
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@interpreter = "ksh"
end
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
index c2d5aa102c..a85e9eb058 100644
--- a/lib/chef/resource/link.rb
+++ b/lib/chef/resource/link.rb
@@ -32,7 +32,7 @@ class Chef
default_action :create
allowed_actions :create, :delete
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
verify_links_supported!
super
@to = nil
@@ -40,7 +40,7 @@ class Chef
@target_file = name
end
- def to(arg=nil)
+ def to(arg = nil)
set_or_return(
:to,
arg,
@@ -48,7 +48,7 @@ class Chef
)
end
- def target_file(arg=nil)
+ def target_file(arg = nil)
set_or_return(
:target_file,
arg,
@@ -56,7 +56,7 @@ class Chef
)
end
- def link_type(arg=nil)
+ def link_type(arg = nil)
real_arg = arg.kind_of?(String) ? arg.to_sym : arg
set_or_return(
:link_type,
@@ -65,7 +65,7 @@ class Chef
)
end
- def group(arg=nil)
+ def group(arg = nil)
set_or_return(
:group,
arg,
@@ -73,7 +73,7 @@ class Chef
)
end
- def owner(arg=nil)
+ def owner(arg = nil)
set_or_return(
:owner,
arg,
@@ -87,6 +87,7 @@ class Chef
end
private
+
def verify_links_supported!
# On certain versions of windows links are not supported. Make
# sure we are not on such a platform.
diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb
index 49f821b3f2..a9b288a210 100644
--- a/lib/chef/resource/log.rb
+++ b/lib/chef/resource/log.rb
@@ -48,13 +48,13 @@ class Chef
# name<String>:: Message to log
# collection<Array>:: Collection of included recipes
# node<Chef::Node>:: Node where resource will be used
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@level = :info
@message = name
end
- def message(arg=nil)
+ def message(arg = nil)
set_or_return(
:message,
arg,
@@ -63,7 +63,7 @@ class Chef
end
# <Symbol> Log level, one of :debug, :info, :warn, :error or :fatal
- def level(arg=nil)
+ def level(arg = nil)
set_or_return(
:level,
arg,
diff --git a/lib/chef/resource/macosx_service.rb b/lib/chef/resource/macosx_service.rb
index ad51287253..c2d05e5991 100644
--- a/lib/chef/resource/macosx_service.rb
+++ b/lib/chef/resource/macosx_service.rb
@@ -29,7 +29,7 @@ class Chef
state_attrs :enabled, :running
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@plist = nil
@session_type = nil
@@ -37,7 +37,7 @@ class Chef
# This will enable user to pass a plist in the case
# that the filename and label for the service dont match
- def plist(arg=nil)
+ def plist(arg = nil)
set_or_return(
:plist,
arg,
@@ -45,7 +45,7 @@ class Chef
)
end
- def session_type(arg=nil)
+ def session_type(arg = nil)
set_or_return(
:session_type,
arg,
diff --git a/lib/chef/resource/mdadm.rb b/lib/chef/resource/mdadm.rb
index 235cd86210..efdd448101 100644
--- a/lib/chef/resource/mdadm.rb
+++ b/lib/chef/resource/mdadm.rb
@@ -30,7 +30,7 @@ class Chef
default_action :create
allowed_actions :create, :assemble, :stop
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@chunk = 16
@@ -42,7 +42,7 @@ class Chef
@raid_device = name
end
- def chunk(arg=nil)
+ def chunk(arg = nil)
set_or_return(
:chunk,
arg,
@@ -50,7 +50,7 @@ class Chef
)
end
- def devices(arg=nil)
+ def devices(arg = nil)
set_or_return(
:devices,
arg,
@@ -58,7 +58,7 @@ class Chef
)
end
- def exists(arg=nil)
+ def exists(arg = nil)
set_or_return(
:exists,
arg,
@@ -66,7 +66,7 @@ class Chef
)
end
- def level(arg=nil)
+ def level(arg = nil)
set_or_return(
:level,
arg,
@@ -74,7 +74,7 @@ class Chef
)
end
- def metadata(arg=nil)
+ def metadata(arg = nil)
set_or_return(
:metadata,
arg,
@@ -82,7 +82,7 @@ class Chef
)
end
- def bitmap(arg=nil)
+ def bitmap(arg = nil)
set_or_return(
:bitmap,
arg,
@@ -90,7 +90,7 @@ class Chef
)
end
- def raid_device(arg=nil)
+ def raid_device(arg = nil)
set_or_return(
:raid_device,
arg,
@@ -98,7 +98,6 @@ class Chef
)
end
-
end
end
end
diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb
index 9d0c0291f8..7bbff57f50 100644
--- a/lib/chef/resource/mount.rb
+++ b/lib/chef/resource/mount.rb
@@ -30,7 +30,7 @@ class Chef
default_action :mount
allowed_actions :mount, :umount, :remount, :enable, :disable
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@mount_point = name
@device = nil
@@ -48,7 +48,7 @@ class Chef
@domain = nil
end
- def mount_point(arg=nil)
+ def mount_point(arg = nil)
set_or_return(
:mount_point,
arg,
@@ -56,7 +56,7 @@ class Chef
)
end
- def device(arg=nil)
+ def device(arg = nil)
set_or_return(
:device,
arg,
@@ -64,7 +64,7 @@ class Chef
)
end
- def device_type(arg=nil)
+ def device_type(arg = nil)
real_arg = arg.kind_of?(String) ? arg.to_sym : arg
valid_devices = if RUBY_PLATFORM =~ /solaris/i
[ :device ]
@@ -78,7 +78,7 @@ class Chef
)
end
- def fsck_device(arg=nil)
+ def fsck_device(arg = nil)
set_or_return(
:fsck_device,
arg,
@@ -86,7 +86,7 @@ class Chef
)
end
- def fstype(arg=nil)
+ def fstype(arg = nil)
set_or_return(
:fstype,
arg,
@@ -94,7 +94,7 @@ class Chef
)
end
- def options(arg=nil)
+ def options(arg = nil)
ret = set_or_return(
:options,
arg,
@@ -108,7 +108,7 @@ class Chef
end
end
- def dump(arg=nil)
+ def dump(arg = nil)
set_or_return(
:dump,
arg,
@@ -116,7 +116,7 @@ class Chef
)
end
- def pass(arg=nil)
+ def pass(arg = nil)
set_or_return(
:pass,
arg,
@@ -124,7 +124,7 @@ class Chef
)
end
- def mounted(arg=nil)
+ def mounted(arg = nil)
set_or_return(
:mounted,
arg,
@@ -132,7 +132,7 @@ class Chef
)
end
- def enabled(arg=nil)
+ def enabled(arg = nil)
set_or_return(
:enabled,
arg,
@@ -140,7 +140,7 @@ class Chef
)
end
- def supports(args={})
+ def supports(args = {})
if args.is_a? Array
args.each { |arg| @supports[arg] = true }
elsif args.any?
@@ -150,7 +150,7 @@ class Chef
end
end
- def username(arg=nil)
+ def username(arg = nil)
set_or_return(
:username,
arg,
@@ -158,7 +158,7 @@ class Chef
)
end
- def password(arg=nil)
+ def password(arg = nil)
set_or_return(
:password,
arg,
@@ -166,7 +166,7 @@ class Chef
)
end
- def domain(arg=nil)
+ def domain(arg = nil)
set_or_return(
:domain,
arg,
diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb
index b36cf32880..5211e2f3bc 100644
--- a/lib/chef/resource/ohai.rb
+++ b/lib/chef/resource/ohai.rb
@@ -27,13 +27,13 @@ class Chef
default_action :reload
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@name = name
@plugin = nil
end
- def plugin(arg=nil)
+ def plugin(arg = nil)
set_or_return(
:plugin,
arg,
@@ -41,7 +41,7 @@ class Chef
)
end
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(
:name,
arg,
diff --git a/lib/chef/resource/osx_profile.rb b/lib/chef/resource/osx_profile.rb
index aa01fa2ac0..920d09a83a 100644
--- a/lib/chef/resource/osx_profile.rb
+++ b/lib/chef/resource/osx_profile.rb
@@ -29,7 +29,7 @@ class Chef
default_action :install
allowed_actions :install, :remove
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@profile_name = name
@profile = nil
@@ -37,7 +37,7 @@ class Chef
@path = nil
end
- def profile_name(arg=nil)
+ def profile_name(arg = nil)
set_or_return(
:profile_name,
arg,
@@ -45,7 +45,7 @@ class Chef
)
end
- def profile(arg=nil)
+ def profile(arg = nil)
set_or_return(
:profile,
arg,
@@ -53,7 +53,7 @@ class Chef
)
end
- def identifier(arg=nil)
+ def identifier(arg = nil)
set_or_return(
:identifier,
arg,
@@ -61,7 +61,7 @@ class Chef
)
end
- def path(arg=nil)
+ def path(arg = nil)
set_or_return(
:path,
arg,
diff --git a/lib/chef/resource/perl.rb b/lib/chef/resource/perl.rb
index 783751aca4..60af0e92da 100644
--- a/lib/chef/resource/perl.rb
+++ b/lib/chef/resource/perl.rb
@@ -22,7 +22,7 @@ require "chef/provider/script"
class Chef
class Resource
class Perl < Chef::Resource::Script
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@interpreter = "perl"
end
diff --git a/lib/chef/resource/portage_package.rb b/lib/chef/resource/portage_package.rb
index 9814ccda56..ad66c7b42b 100644
--- a/lib/chef/resource/portage_package.rb
+++ b/lib/chef/resource/portage_package.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class PortagePackage < Chef::Resource::Package
resource_name :portage_package
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@provider = Chef::Provider::Package::Portage
end
diff --git a/lib/chef/resource/powershell_script.rb b/lib/chef/resource/powershell_script.rb
index 891438eb01..e66db9fa55 100644
--- a/lib/chef/resource/powershell_script.rb
+++ b/lib/chef/resource/powershell_script.rb
@@ -22,12 +22,12 @@ class Chef
class PowershellScript < Chef::Resource::WindowsScript
provides :powershell_script, os: "windows"
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super(name, run_context, nil, "powershell.exe")
@convert_boolean_return = false
end
- def convert_boolean_return(arg=nil)
+ def convert_boolean_return(arg = nil)
set_or_return(
:convert_boolean_return,
arg,
@@ -43,7 +43,7 @@ class Chef
# guard context and recipe resource context will have the
# same behavior.
def self.get_default_attributes(opts)
- {:convert_boolean_return => true}
+ { :convert_boolean_return => true }
end
end
end
diff --git a/lib/chef/resource/python.rb b/lib/chef/resource/python.rb
index d2a7a4fc14..bcad3d090b 100644
--- a/lib/chef/resource/python.rb
+++ b/lib/chef/resource/python.rb
@@ -21,7 +21,7 @@ require "chef/provider/script"
class Chef
class Resource
class Python < Chef::Resource::Script
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@interpreter = "python"
end
diff --git a/lib/chef/resource/reboot.rb b/lib/chef/resource/reboot.rb
index 2941294ff8..24d6e74157 100644
--- a/lib/chef/resource/reboot.rb
+++ b/lib/chef/resource/reboot.rb
@@ -26,7 +26,7 @@ class Chef
class Reboot < Chef::Resource
allowed_actions :request_reboot, :reboot_now, :cancel
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@provider = Chef::Provider::Reboot
@@ -36,11 +36,11 @@ class Chef
# no default action.
end
- def reason(arg=nil)
+ def reason(arg = nil)
set_or_return(:reason, arg, :kind_of => String)
end
- def delay_mins(arg=nil)
+ def delay_mins(arg = nil)
set_or_return(:delay_mins, arg, :kind_of => Fixnum)
end
end
diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb
index eaa9a00de5..135e63d959 100644
--- a/lib/chef/resource/registry_key.rb
+++ b/lib/chef/resource/registry_key.rb
@@ -59,7 +59,7 @@ class Chef
# See lib/chef/resource_reporter.rb for more information.
attr_reader :unscrubbed_values
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@architecture = :machine
@recursive = false
@@ -67,7 +67,7 @@ class Chef
@values, @unscrubbed_values = [], []
end
- def key(arg=nil)
+ def key(arg = nil)
set_or_return(
:key,
arg,
@@ -75,7 +75,7 @@ class Chef
)
end
- def values(arg=nil)
+ def values(arg = nil)
if not arg.nil?
if arg.is_a?(Hash)
@values = [ arg ]
@@ -90,7 +90,7 @@ class Chef
raise ArgumentError, "Missing type key in RegistryKey values hash" unless v.has_key?(:type)
raise ArgumentError, "Missing data key in RegistryKey values hash" unless v.has_key?(:data)
v.each_key do |key|
- raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless [:name,:type,:data].include?(key)
+ raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless [:name, :type, :data].include?(key)
end
raise ArgumentError, "Type of name => #{v[:name]} should be string" unless v[:name].is_a?(String)
raise ArgumentError, "Type of type => #{v[:type]} should be symbol" unless v[:type].is_a?(Symbol)
@@ -101,7 +101,7 @@ class Chef
end
end
- def recursive(arg=nil)
+ def recursive(arg = nil)
set_or_return(
:recursive,
arg,
@@ -109,7 +109,7 @@ class Chef
)
end
- def architecture(arg=nil)
+ def architecture(arg = nil)
set_or_return(
:architecture,
arg,
diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb
index b7fbcaf3b3..600ee5138e 100644
--- a/lib/chef/resource/remote_directory.rb
+++ b/lib/chef/resource/remote_directory.rb
@@ -33,7 +33,7 @@ class Chef
default_action :create
allowed_actions :create, :create_if_missing, :delete
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@path = name
@source = ::File.basename(name)
@@ -53,8 +53,7 @@ class Chef
rights_attribute(:files_rights)
end
-
- def source(args=nil)
+ def source(args = nil)
set_or_return(
:source,
args,
@@ -62,7 +61,7 @@ class Chef
)
end
- def files_backup(arg=nil)
+ def files_backup(arg = nil)
set_or_return(
:files_backup,
arg,
@@ -70,7 +69,7 @@ class Chef
)
end
- def purge(arg=nil)
+ def purge(arg = nil)
set_or_return(
:purge,
arg,
@@ -78,7 +77,7 @@ class Chef
)
end
- def files_group(arg=nil)
+ def files_group(arg = nil)
set_or_return(
:files_group,
arg,
@@ -86,7 +85,7 @@ class Chef
)
end
- def files_mode(arg=nil)
+ def files_mode(arg = nil)
set_or_return(
:files_mode,
arg,
@@ -94,7 +93,7 @@ class Chef
)
end
- def files_owner(arg=nil)
+ def files_owner(arg = nil)
set_or_return(
:files_owner,
arg,
@@ -102,7 +101,7 @@ class Chef
)
end
- def overwrite(arg=nil)
+ def overwrite(arg = nil)
set_or_return(
:overwrite,
arg,
@@ -110,7 +109,7 @@ class Chef
)
end
- def cookbook(args=nil)
+ def cookbook(args = nil)
set_or_return(
:cookbook,
args,
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index 5fce1ee89a..36f1c614d1 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -28,7 +28,7 @@ class Chef
class RemoteFile < Chef::Resource::File
include Chef::Mixin::Securable
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@source = []
@use_etag = true
@@ -52,7 +52,7 @@ class Chef
arg,
{ :callbacks => {
:validate_source => method(:validate_source)
- }})
+ } })
if ret.is_a? String
Array(ret)
else
@@ -65,14 +65,14 @@ class Chef
nil
elsif args[0].is_a?(Chef::DelayedEvaluator) && args.count == 1
args[0]
- elsif args.any? {|a| a.is_a?(Chef::DelayedEvaluator)} && args.count > 1
+ elsif args.any? { |a| a.is_a?(Chef::DelayedEvaluator) } && args.count > 1
raise Exceptions::InvalidRemoteFileURI, "Only 1 source argument allowed when using a lazy evaluator"
else
Array(args).flatten
end
end
- def checksum(args=nil)
+ def checksum(args = nil)
set_or_return(
:checksum,
args,
@@ -88,7 +88,7 @@ class Chef
use_last_modified(true_or_false)
end
- def use_etag(args=nil)
+ def use_etag(args = nil)
set_or_return(
:use_etag,
args,
@@ -98,7 +98,7 @@ class Chef
alias :use_etags :use_etag
- def use_last_modified(args=nil)
+ def use_last_modified(args = nil)
set_or_return(
:use_last_modified,
args,
@@ -106,7 +106,7 @@ class Chef
)
end
- def ftp_active_mode(args=nil)
+ def ftp_active_mode(args = nil)
set_or_return(
:ftp_active_mode,
args,
@@ -114,7 +114,7 @@ class Chef
)
end
- def headers(args=nil)
+ def headers(args = nil)
set_or_return(
:headers,
args,
diff --git a/lib/chef/resource/route.rb b/lib/chef/resource/route.rb
index b817ed33e0..bbfbada674 100644
--- a/lib/chef/resource/route.rb
+++ b/lib/chef/resource/route.rb
@@ -29,7 +29,7 @@ class Chef
default_action :add
allowed_actions :add, :delete
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@target = name
@netmask = nil
@@ -44,7 +44,7 @@ class Chef
@domain = nil
end
- def networking(arg=nil)
+ def networking(arg = nil)
set_or_return(
:networking,
arg,
@@ -52,7 +52,7 @@ class Chef
)
end
- def networking_ipv6(arg=nil)
+ def networking_ipv6(arg = nil)
set_or_return(
:networking_ipv6,
arg,
@@ -60,7 +60,7 @@ class Chef
)
end
- def hostname(arg=nil)
+ def hostname(arg = nil)
set_or_return(
:hostname,
arg,
@@ -68,7 +68,7 @@ class Chef
)
end
- def domainname(arg=nil)
+ def domainname(arg = nil)
set_or_return(
:domainname,
arg,
@@ -76,7 +76,7 @@ class Chef
)
end
- def domain(arg=nil)
+ def domain(arg = nil)
set_or_return(
:domain,
arg,
@@ -84,7 +84,7 @@ class Chef
)
end
- def target(arg=nil)
+ def target(arg = nil)
set_or_return(
:target,
arg,
@@ -92,7 +92,7 @@ class Chef
)
end
- def netmask(arg=nil)
+ def netmask(arg = nil)
set_or_return(
:netmask,
arg,
@@ -100,7 +100,7 @@ class Chef
)
end
- def gateway(arg=nil)
+ def gateway(arg = nil)
set_or_return(
:gateway,
arg,
@@ -108,7 +108,7 @@ class Chef
)
end
- def metric(arg=nil)
+ def metric(arg = nil)
set_or_return(
:metric,
arg,
@@ -116,7 +116,7 @@ class Chef
)
end
- def device(arg=nil)
+ def device(arg = nil)
set_or_return(
:device,
arg,
@@ -124,7 +124,7 @@ class Chef
)
end
- def route_type(arg=nil)
+ def route_type(arg = nil)
real_arg = arg.kind_of?(String) ? arg.to_sym : arg
set_or_return(
:route_type,
diff --git a/lib/chef/resource/ruby.rb b/lib/chef/resource/ruby.rb
index 0a7bec90a2..91805a1db6 100644
--- a/lib/chef/resource/ruby.rb
+++ b/lib/chef/resource/ruby.rb
@@ -22,7 +22,7 @@ require "chef/provider/script"
class Chef
class Resource
class Ruby < Chef::Resource::Script
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@interpreter = "ruby"
end
diff --git a/lib/chef/resource/ruby_block.rb b/lib/chef/resource/ruby_block.rb
index 48f297e6ec..7bb433b330 100644
--- a/lib/chef/resource/ruby_block.rb
+++ b/lib/chef/resource/ruby_block.rb
@@ -28,7 +28,7 @@ class Chef
identity_attr :block_name
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@block_name = name
end
@@ -41,7 +41,7 @@ class Chef
end
end
- def block_name(arg=nil)
+ def block_name(arg = nil)
set_or_return(
:block_name,
arg,
diff --git a/lib/chef/resource/scm.rb b/lib/chef/resource/scm.rb
index 9f5c66378b..4ba31cd31b 100644
--- a/lib/chef/resource/scm.rb
+++ b/lib/chef/resource/scm.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "chef/resource"
class Chef
@@ -29,7 +28,7 @@ class Chef
default_action :sync
allowed_actions :checkout, :export, :sync, :diff, :log
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@destination = name
@enable_submodules = false
@@ -42,7 +41,7 @@ class Chef
@environment = nil
end
- def destination(arg=nil)
+ def destination(arg = nil)
set_or_return(
:destination,
arg,
@@ -50,7 +49,7 @@ class Chef
)
end
- def repository(arg=nil)
+ def repository(arg = nil)
set_or_return(
:repository,
arg,
@@ -58,7 +57,7 @@ class Chef
)
end
- def revision(arg=nil)
+ def revision(arg = nil)
set_or_return(
:revision,
arg,
@@ -66,7 +65,7 @@ class Chef
)
end
- def user(arg=nil)
+ def user(arg = nil)
set_or_return(
:user,
arg,
@@ -74,7 +73,7 @@ class Chef
)
end
- def group(arg=nil)
+ def group(arg = nil)
set_or_return(
:group,
arg,
@@ -82,7 +81,7 @@ class Chef
)
end
- def svn_username(arg=nil)
+ def svn_username(arg = nil)
set_or_return(
:svn_username,
arg,
@@ -90,7 +89,7 @@ class Chef
)
end
- def svn_password(arg=nil)
+ def svn_password(arg = nil)
set_or_return(
:svn_password,
arg,
@@ -98,7 +97,7 @@ class Chef
)
end
- def svn_arguments(arg=nil)
+ def svn_arguments(arg = nil)
@svn_arguments, arg = nil, nil if arg == false
set_or_return(
:svn_arguments,
@@ -107,7 +106,7 @@ class Chef
)
end
- def svn_info_args(arg=nil)
+ def svn_info_args(arg = nil)
@svn_info_args, arg = nil, nil if arg == false
set_or_return(
:svn_info_args,
@@ -116,7 +115,7 @@ class Chef
end
# Capistrano and git-deploy use ``shallow clone''
- def depth(arg=nil)
+ def depth(arg = nil)
set_or_return(
:depth,
arg,
@@ -124,7 +123,7 @@ class Chef
)
end
- def enable_submodules(arg=nil)
+ def enable_submodules(arg = nil)
set_or_return(
:enable_submodules,
arg,
@@ -132,7 +131,7 @@ class Chef
)
end
- def enable_checkout(arg=nil)
+ def enable_checkout(arg = nil)
set_or_return(
:enable_checkout,
arg,
@@ -140,7 +139,7 @@ class Chef
)
end
- def remote(arg=nil)
+ def remote(arg = nil)
set_or_return(
:remote,
arg,
@@ -148,7 +147,7 @@ class Chef
)
end
- def ssh_wrapper(arg=nil)
+ def ssh_wrapper(arg = nil)
set_or_return(
:ssh_wrapper,
arg,
@@ -156,7 +155,7 @@ class Chef
)
end
- def timeout(arg=nil)
+ def timeout(arg = nil)
set_or_return(
:timeout,
arg,
@@ -164,7 +163,7 @@ class Chef
)
end
- def checkout_branch(arg=nil)
+ def checkout_branch(arg = nil)
set_or_return(
:checkout_branch,
arg,
@@ -172,7 +171,7 @@ class Chef
)
end
- def environment(arg=nil)
+ def environment(arg = nil)
set_or_return(
:environment,
arg,
diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb
index c7748a7eb8..d80effbf67 100644
--- a/lib/chef/resource/script.rb
+++ b/lib/chef/resource/script.rb
@@ -26,7 +26,7 @@ class Chef
# Chef-13: go back to using :name as the identity attr
identity_attr :command
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
# Chef-13: the command variable should be initialized to nil
@command = name
@@ -36,7 +36,7 @@ class Chef
@default_guard_interpreter = :default
end
- def command(arg=nil)
+ def command(arg = nil)
unless arg.nil?
# Chef-13: change this to raise if the user is trying to set a value here
Chef::Log.warn "Specifying command attribute on a script resource is a coding error, use the 'code' attribute, or the execute resource"
@@ -45,7 +45,7 @@ class Chef
super
end
- def code(arg=nil)
+ def code(arg = nil)
set_or_return(
:code,
arg,
@@ -53,7 +53,7 @@ class Chef
)
end
- def interpreter(arg=nil)
+ def interpreter(arg = nil)
set_or_return(
:interpreter,
arg,
@@ -61,7 +61,7 @@ class Chef
)
end
- def flags(arg=nil)
+ def flags(arg = nil)
set_or_return(
:flags,
arg,
diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb
index 504fdac104..5288e1b2be 100644
--- a/lib/chef/resource/service.rb
+++ b/lib/chef/resource/service.rb
@@ -29,7 +29,7 @@ class Chef
default_action :nothing
allowed_actions :enable, :disable, :start, :stop, :restart, :reload
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@service_name = name
@enabled = nil
@@ -48,7 +48,7 @@ class Chef
@supports = { :restart => nil, :reload => nil, :status => nil }
end
- def service_name(arg=nil)
+ def service_name(arg = nil)
set_or_return(
:service_name,
arg,
@@ -57,7 +57,7 @@ class Chef
end
# regex for match against ps -ef when !supports[:has_status] && status == nil
- def pattern(arg=nil)
+ def pattern(arg = nil)
set_or_return(
:pattern,
arg,
@@ -66,7 +66,7 @@ class Chef
end
# command to call to start service
- def start_command(arg=nil)
+ def start_command(arg = nil)
set_or_return(
:start_command,
arg,
@@ -75,7 +75,7 @@ class Chef
end
# command to call to stop service
- def stop_command(arg=nil)
+ def stop_command(arg = nil)
set_or_return(
:stop_command,
arg,
@@ -84,7 +84,7 @@ class Chef
end
# command to call to get status of service
- def status_command(arg=nil)
+ def status_command(arg = nil)
set_or_return(
:status_command,
arg,
@@ -93,7 +93,7 @@ class Chef
end
# command to call to restart service
- def restart_command(arg=nil)
+ def restart_command(arg = nil)
set_or_return(
:restart_command,
arg,
@@ -101,7 +101,7 @@ class Chef
)
end
- def reload_command(arg=nil)
+ def reload_command(arg = nil)
set_or_return(
:reload_command,
arg,
@@ -114,7 +114,7 @@ class Chef
# non-standard configurations setting this value will save having to
# specify overrides for the start_command, stop_command and
# restart_command attributes.
- def init_command(arg=nil)
+ def init_command(arg = nil)
set_or_return(
:init_command,
arg,
@@ -123,7 +123,7 @@ class Chef
end
# if the service is enabled or not
- def enabled(arg=nil)
+ def enabled(arg = nil)
set_or_return(
:enabled,
arg,
@@ -132,7 +132,7 @@ class Chef
end
# if the service is running or not
- def running(arg=nil)
+ def running(arg = nil)
set_or_return(
:running,
arg,
@@ -150,7 +150,7 @@ class Chef
# runlevel 2, stopped in 3 with priority 55 and no symlinks or
# similar for other runlevels
#
- def priority(arg=nil)
+ def priority(arg = nil)
set_or_return(
:priority,
arg,
@@ -159,7 +159,7 @@ class Chef
end
# timeout only applies to the windows service manager
- def timeout(arg=nil)
+ def timeout(arg = nil)
set_or_return(
:timeout,
arg,
@@ -167,7 +167,7 @@ class Chef
)
end
- def parameters(arg=nil)
+ def parameters(arg = nil)
set_or_return(
:parameters,
arg,
@@ -175,14 +175,14 @@ class Chef
)
end
- def run_levels(arg=nil)
+ def run_levels(arg = nil)
set_or_return(
:run_levels,
arg,
:kind_of => [ Array ] )
end
- def supports(args={})
+ def supports(args = {})
if args.is_a? Array
args.each { |arg| @supports[arg] = true }
elsif args.any?
diff --git a/lib/chef/resource/subversion.rb b/lib/chef/resource/subversion.rb
index c391fdfd0f..9966614eeb 100644
--- a/lib/chef/resource/subversion.rb
+++ b/lib/chef/resource/subversion.rb
@@ -24,7 +24,7 @@ class Chef
class Subversion < Chef::Resource::Scm
allowed_actions :force_export
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@svn_arguments = "--no-auth-cache"
@svn_info_args = "--no-auth-cache"
@@ -36,7 +36,7 @@ class Chef
"#{self} (#{defined_at}) had an error: #{e.class.name}: #{svn_password ? e.message.gsub(svn_password, "[hidden_password]") : e.message}"
end
- def svn_binary(arg=nil)
+ def svn_binary(arg = nil)
set_or_return(:svn_binary, arg, :kind_of => [String])
end
end
diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb
index 9a1a69120d..1570af2812 100644
--- a/lib/chef/resource/template.rb
+++ b/lib/chef/resource/template.rb
@@ -30,7 +30,7 @@ class Chef
attr_reader :inline_helper_blocks
attr_reader :inline_helper_modules
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@source = "#{::File.basename(name)}.erb"
@cookbook = nil
@@ -41,7 +41,7 @@ class Chef
@helper_modules = []
end
- def source(file=nil)
+ def source(file = nil)
set_or_return(
:source,
file,
@@ -49,7 +49,7 @@ class Chef
)
end
- def variables(args=nil)
+ def variables(args = nil)
set_or_return(
:variables,
args,
@@ -57,7 +57,7 @@ class Chef
)
end
- def cookbook(args=nil)
+ def cookbook(args = nil)
set_or_return(
:cookbook,
args,
@@ -65,7 +65,7 @@ class Chef
)
end
- def local(args=nil)
+ def local(args = nil)
set_or_return(
:local,
args,
@@ -160,7 +160,7 @@ class Chef
# And in the template resource:
# helpers(MyTemplateHelper)
# The template code in the above example will work unmodified.
- def helpers(module_name=nil,&block)
+ def helpers(module_name = nil, &block)
if block_given? and !module_name.nil?
raise Exceptions::ValidationFailed,
"Passing both a module and block to #helpers is not supported. Call #helpers multiple times instead"
@@ -171,8 +171,8 @@ class Chef
elsif module_name.nil?
raise Exceptions::ValidationFailed,
"#helpers requires either a module name or inline module code as a block.\n" +
- "e.g.: helpers do; helper_code; end;\n" +
- "OR: helpers(MyHelpersModule)"
+ "e.g.: helpers do; helper_code; end;\n" +
+ "OR: helpers(MyHelpersModule)"
else
raise Exceptions::ValidationFailed,
"Argument to #helpers must be a module. You gave #{module_name.inspect} (#{module_name.class})"
diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb
index 4f11975d50..5aa94ae49e 100644
--- a/lib/chef/resource/user.rb
+++ b/lib/chef/resource/user.rb
@@ -28,7 +28,7 @@ class Chef
default_action :create
allowed_actions :create, :remove, :modify, :manage, :lock, :unlock
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@username = name
@comment = nil
@@ -49,7 +49,7 @@ class Chef
@salt = nil
end
- def username(arg=nil)
+ def username(arg = nil)
set_or_return(
:username,
arg,
@@ -57,7 +57,7 @@ class Chef
)
end
- def comment(arg=nil)
+ def comment(arg = nil)
set_or_return(
:comment,
arg,
@@ -65,7 +65,7 @@ class Chef
)
end
- def uid(arg=nil)
+ def uid(arg = nil)
set_or_return(
:uid,
arg,
@@ -73,7 +73,7 @@ class Chef
)
end
- def gid(arg=nil)
+ def gid(arg = nil)
set_or_return(
:gid,
arg,
@@ -83,7 +83,7 @@ class Chef
alias_method :group, :gid
- def home(arg=nil)
+ def home(arg = nil)
set_or_return(
:home,
arg,
@@ -91,7 +91,7 @@ class Chef
)
end
- def shell(arg=nil)
+ def shell(arg = nil)
set_or_return(
:shell,
arg,
@@ -99,7 +99,7 @@ class Chef
)
end
- def password(arg=nil)
+ def password(arg = nil)
set_or_return(
:password,
arg,
@@ -107,7 +107,7 @@ class Chef
)
end
- def salt(arg=nil)
+ def salt(arg = nil)
set_or_return(
:salt,
arg,
@@ -115,7 +115,7 @@ class Chef
)
end
- def iterations(arg=nil)
+ def iterations(arg = nil)
set_or_return(
:iterations,
arg,
@@ -123,7 +123,7 @@ class Chef
)
end
- def system(arg=nil)
+ def system(arg = nil)
set_or_return(
:system,
arg,
@@ -131,7 +131,7 @@ class Chef
)
end
- def manage_home(arg=nil)
+ def manage_home(arg = nil)
set_or_return(
:manage_home,
arg,
@@ -139,7 +139,7 @@ class Chef
)
end
- def force(arg=nil)
+ def force(arg = nil)
set_or_return(
:force,
arg,
@@ -147,7 +147,7 @@ class Chef
)
end
- def non_unique(arg=nil)
+ def non_unique(arg = nil)
set_or_return(
:non_unique,
arg,
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb
index c718708e79..0e8dd39672 100644
--- a/lib/chef/resource/windows_package.rb
+++ b/lib/chef/resource/windows_package.rb
@@ -32,7 +32,7 @@ class Chef
allowed_actions :install, :remove
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@source ||= source(@package_name) if @package_name.downcase.end_with?(".msi")
end
diff --git a/lib/chef/resource/windows_script.rb b/lib/chef/resource/windows_script.rb
index 13905fc4ba..44f1d8d652 100644
--- a/lib/chef/resource/windows_script.rb
+++ b/lib/chef/resource/windows_script.rb
@@ -40,7 +40,7 @@ class Chef
public
- def architecture(arg=nil)
+ def architecture(arg = nil)
assert_architecture_compatible!(arg) if ! arg.nil?
result = set_or_return(
:architecture,
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index ab49abc2c3..635edbb389 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -34,14 +34,14 @@ class Chef
state_attrs :enabled, :running
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@startup_type = :automatic
@run_as_user = ""
@run_as_password = ""
end
- def startup_type(arg=nil)
+ def startup_type(arg = nil)
# Set-Service arguments are automatic and manual
# Win32::Service returns 'auto start' or 'demand start' respectively, which the provider currently uses
set_or_return(
@@ -51,7 +51,7 @@ class Chef
)
end
- def run_as_user(arg=nil)
+ def run_as_user(arg = nil)
set_or_return(
:run_as_user,
arg,
@@ -59,7 +59,7 @@ class Chef
)
end
- def run_as_password(arg=nil)
+ def run_as_password(arg = nil)
set_or_return(
:run_as_password,
arg,
diff --git a/lib/chef/resource_collection.rb b/lib/chef/resource_collection.rb
index 369aacd29e..293a99991e 100644
--- a/lib/chef/resource_collection.rb
+++ b/lib/chef/resource_collection.rb
@@ -45,7 +45,7 @@ class Chef
# @param instance_name [String] If known, the recource name as used in the recipe, IE `vim` in `package 'vim'`
# This method is meant to be the 1 insert method necessary in the future. It should support all known use cases
# for writing into the ResourceCollection.
- def insert(resource, opts={})
+ def insert(resource, opts = {})
resource_type ||= opts[:resource_type] # Would rather use Ruby 2.x syntax, but oh well
instance_name ||= opts[:instance_name]
resource_list.insert(resource)
@@ -78,8 +78,8 @@ class Chef
# Read-only methods are simple to delegate - doing that below
resource_list_methods = Enumerable.instance_methods +
- [:iterator, :all_resources, :[], :each, :execute_each_resource, :each_index, :empty?] -
- [:find] # find needs to run on the set
+ [:iterator, :all_resources, :[], :each, :execute_each_resource, :each_index, :empty?] -
+ [:find] # find needs to run on the set
resource_set_methods = [:lookup, :find, :resources, :keys, :validate_lookup_spec!]
def_delegators :resource_list, *resource_list_methods
diff --git a/lib/chef/resource_collection/resource_collection_serialization.rb b/lib/chef/resource_collection/resource_collection_serialization.rb
index b654644cd9..0e76296a4a 100644
--- a/lib/chef/resource_collection/resource_collection_serialization.rb
+++ b/lib/chef/resource_collection/resource_collection_serialization.rb
@@ -41,7 +41,7 @@ class Chef
module ClassMethods
def json_create(o)
collection = self.new()
- o["instance_vars"].each do |k,v|
+ o["instance_vars"].each do |k, v|
collection.instance_variable_set(k.to_sym, v)
end
collection
diff --git a/lib/chef/resource_collection/resource_set.rb b/lib/chef/resource_collection/resource_set.rb
index 7bc980b6db..2a653356dc 100644
--- a/lib/chef/resource_collection/resource_set.rb
+++ b/lib/chef/resource_collection/resource_set.rb
@@ -40,7 +40,7 @@ class Chef
@resources_by_key.keys
end
- def insert_as(resource, resource_type=nil, instance_name=nil)
+ def insert_as(resource, resource_type = nil, instance_name = nil)
is_chef_resource!(resource)
resource_type ||= resource.resource_name
instance_name ||= resource.name
@@ -124,7 +124,7 @@ class Chef
else
raise Chef::Exceptions::InvalidResourceSpecification,
"The object `#{query_object.inspect}' is not valid for resource collection lookup. " +
- "Use a String like `resource_type[resource_name]' or a Chef::Resource object"
+ "Use a String like `resource_type[resource_name]' or a Chef::Resource object"
end
end
diff --git a/lib/chef/resource_collection/stepable_iterator.rb b/lib/chef/resource_collection/stepable_iterator.rb
index c744ce7943..d1165764ca 100644
--- a/lib/chef/resource_collection/stepable_iterator.rb
+++ b/lib/chef/resource_collection/stepable_iterator.rb
@@ -27,7 +27,7 @@ class Chef
attr_accessor :collection
attr_reader :position
- def initialize(collection=[])
+ def initialize(collection = [])
@position = 0
@paused = false
@collection = collection
@@ -72,11 +72,11 @@ class Chef
@position = 0
end
- def skip_back(skips=1)
+ def skip_back(skips = 1)
@position -= skips
end
- def skip_forward(skips=1)
+ def skip_forward(skips = 1)
@position += skips
end
diff --git a/lib/chef/resource_definition.rb b/lib/chef/resource_definition.rb
index f6fe77a1fd..aa114af46c 100644
--- a/lib/chef/resource_definition.rb
+++ b/lib/chef/resource_definition.rb
@@ -27,14 +27,14 @@ class Chef
attr_accessor :name, :params, :recipe, :node
- def initialize(node=nil)
+ def initialize(node = nil)
@name = nil
@params = Hash.new
@recipe = nil
@node = node
end
- def define(resource_name, prototype_params=nil, &block)
+ def define(resource_name, prototype_params = nil, &block)
unless resource_name.kind_of?(Symbol)
raise ArgumentError, "You must use a symbol when defining a new resource!"
end
diff --git a/lib/chef/resource_definition_list.rb b/lib/chef/resource_definition_list.rb
index ca3f46c4ea..22751249e4 100644
--- a/lib/chef/resource_definition_list.rb
+++ b/lib/chef/resource_definition_list.rb
@@ -29,7 +29,7 @@ class Chef
@defines = Hash.new
end
- def define(resource_name, prototype_params=nil, &block)
+ def define(resource_name, prototype_params = nil, &block)
@defines[resource_name] = ResourceDefinition.new
@defines[resource_name].define(resource_name, prototype_params, &block)
true
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index 19964c24cf..4135483441 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -121,8 +121,8 @@ class Chef
if reporting_enabled?
begin
resource_history_url = "reports/nodes/#{node_name}/runs"
- server_response = @rest_client.post(resource_history_url, {:action => :start, :run_id => run_id,
- :start_time => start_time.to_s}, headers)
+ server_response = @rest_client.post(resource_history_url, { :action => :start, :run_id => run_id,
+ :start_time => start_time.to_s }, headers)
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
handle_error_starting_run(e, resource_history_url)
end
@@ -232,7 +232,7 @@ class Chef
Chef::Log.debug("Sending compressed run data...")
# Since we're posting compressed data we can not directly call post which expects JSON
begin
- @rest_client.raw_request(:POST, resource_history_url, headers({"Content-Encoding" => "gzip"}), compressed_data)
+ @rest_client.raw_request(:POST, resource_history_url, headers({ "Content-Encoding" => "gzip" }), compressed_data)
rescue StandardError => e
if e.respond_to? :response
Chef::FileCache.store("failed-reporting-data.json", Chef::JSONCompat.to_json_pretty(run_data), 0640)
@@ -247,7 +247,7 @@ class Chef
end
def headers(additional_headers = {})
- options = {"X-Ops-Reporting-Protocol-Version" => PROTOCOL_VERSION}
+ options = { "X-Ops-Reporting-Protocol-Version" => PROTOCOL_VERSION }
options.merge(additional_headers)
end
@@ -282,7 +282,7 @@ class Chef
exception_data["class"] = exception.inspect
exception_data["message"] = exception.message
exception_data["backtrace"] = Chef::JSONCompat.to_json(exception.backtrace)
- exception_data["description"] = @error_descriptions
+ exception_data["description"] = @error_descriptions
run_data["data"]["exception"] = exception_data
end
run_data
@@ -319,7 +319,7 @@ class Chef
def encode_gzip(data)
"".tap do |out|
- Zlib::GzipWriter.wrap(StringIO.new(out)){|gz| gz << data }
+ Zlib::GzipWriter.wrap(StringIO.new(out)) { |gz| gz << data }
end
end
diff --git a/lib/chef/resource_resolver.rb b/lib/chef/resource_resolver.rb
index d8fb7f6599..769272d637 100644
--- a/lib/chef/resource_resolver.rb
+++ b/lib/chef/resource_resolver.rb
@@ -47,7 +47,6 @@ class Chef
new(node, resource_name, canonical: canonical).list
end
-
include Chef::Mixin::ConvertToClassName
# @api private
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb
index bf444ffe23..a3c5c66b8a 100644
--- a/lib/chef/rest.rb
+++ b/lib/chef/rest.rb
@@ -57,8 +57,7 @@ class Chef
# all subsequent requests. For example, when initialized with a base url
# http://localhost:4000, a call to +get_rest+ with 'nodes' will make an
# HTTP GET request to http://localhost:4000/nodes
- def initialize(url, client_name=Chef::Config[:node_name], signing_key_filename=Chef::Config[:client_key], options={})
-
+ def initialize(url, client_name = Chef::Config[:node_name], signing_key_filename = Chef::Config[:client_key], options = {})
Chef.log_deprecation("Chef::REST is deprecated. Please use Chef::ServerAPI, or investigate Ridley or ChefAPI.")
signing_key_filename = nil if chef_zero_uri?(url)
@@ -84,7 +83,6 @@ class Chef
# because the order of middlewares is reversed when handling
# responses.
@middlewares << ValidateContentLength.new(options)
-
end
def signing_key_filename
@@ -115,7 +113,7 @@ class Chef
# path:: The path to GET
# raw:: Whether you want the raw body returned, or JSON inflated. Defaults
# to JSON inflated.
- def get(path, raw=false, headers={})
+ def get(path, raw = false, headers = {})
if raw
streaming_request(path, headers)
else
@@ -136,8 +134,8 @@ class Chef
# If you rename the tempfile, it will not be deleted.
# Beware that if the server streams infinite content, this method will
# stream it until you run out of disk space.
- def fetch(path, headers={})
- streaming_request(create_url(path), headers) {|tmp_file| yield tmp_file }
+ def fetch(path, headers = {})
+ streaming_request(create_url(path), headers) { |tmp_file| yield tmp_file }
end
alias :api_request :request
@@ -203,7 +201,7 @@ class Chef
@decompressor.decompress_body(body)
end
- def authentication_headers(method, url, json_body=nil)
+ def authentication_headers(method, url, json_body = nil)
authenticator.authentication_headers(method, url, json_body)
end
diff --git a/lib/chef/role.rb b/lib/chef/role.rb
index 22a4c9f01d..a5a33c28cf 100644
--- a/lib/chef/role.rb
+++ b/lib/chef/role.rb
@@ -41,7 +41,7 @@ class Chef
@description = ""
@default_attributes = Mash.new
@override_attributes = Mash.new
- @env_run_lists = {"_default" => Chef::RunList.new}
+ @env_run_lists = { "_default" => Chef::RunList.new }
@chef_server_rest = chef_server_rest
end
@@ -53,7 +53,7 @@ class Chef
Chef::ServerAPI.new(Chef::Config[:chef_server_url])
end
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(
:name,
arg,
@@ -61,7 +61,7 @@ class Chef
)
end
- def description(arg=nil)
+ def description(arg = nil)
set_or_return(
:description,
arg,
@@ -92,7 +92,7 @@ class Chef
end
# Per environment run lists
- def env_run_lists(env_run_lists=nil)
+ def env_run_lists(env_run_lists = nil)
if (!env_run_lists.nil?)
unless env_run_lists.key?("_default")
msg = "_default key is required in env_run_lists.\n"
@@ -100,24 +100,23 @@ class Chef
raise Chef::Exceptions::InvalidEnvironmentRunListSpecification, msg
end
@env_run_lists.clear
- env_run_lists.each { |k,v| @env_run_lists[k] = Chef::RunList.new(*Array(v))}
+ env_run_lists.each { |k, v| @env_run_lists[k] = Chef::RunList.new(*Array(v)) }
end
@env_run_lists
end
alias :env_run_list :env_run_lists
- def env_run_lists_add(env_run_lists=nil)
+ def env_run_lists_add(env_run_lists = nil)
if (!env_run_lists.nil?)
- env_run_lists.each { |k,v| @env_run_lists[k] = Chef::RunList.new(*Array(v))}
+ env_run_lists.each { |k, v| @env_run_lists[k] = Chef::RunList.new(*Array(v)) }
end
@env_run_lists
end
alias :env_run_list_add :env_run_lists_add
-
- def default_attributes(arg=nil)
+ def default_attributes(arg = nil)
set_or_return(
:default_attributes,
arg,
@@ -125,7 +124,7 @@ class Chef
)
end
- def override_attributes(arg=nil)
+ def override_attributes(arg = nil)
set_or_return(
:override_attributes,
arg,
@@ -184,7 +183,7 @@ class Chef
# _default run_list is in 'run_list' for newer clients, and
# 'recipes' for older clients.
- env_run_list_hash = {"_default" => (o.has_key?("run_list") ? o["run_list"] : o["recipes"])}
+ env_run_list_hash = { "_default" => (o.has_key?("run_list") ? o["run_list"] : o["recipes"]) }
# Clients before 0.10 do not include env_run_lists, so only
# merge if it's there.
@@ -197,7 +196,7 @@ class Chef
end
# Get the list of all roles from the API.
- def self.list(inflate=false)
+ def self.list(inflate = false)
if inflate
response = Hash.new
Chef::Search::Query.new.search(:role) do |n|
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index 8b3f120deb..ecb16c190d 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -173,9 +173,9 @@ class Chef
def initialize_child_state
@audits = {}
@resource_collection = Chef::ResourceCollection.new
- @before_notification_collection = Hash.new {|h,k| h[k] = []}
- @immediate_notification_collection = Hash.new {|h,k| h[k] = []}
- @delayed_notification_collection = Hash.new {|h,k| h[k] = []}
+ @before_notification_collection = Hash.new { |h, k| h[k] = [] }
+ @immediate_notification_collection = Hash.new { |h, k| h[k] = [] }
+ @delayed_notification_collection = Hash.new { |h, k| h[k] = [] }
end
#
@@ -322,7 +322,6 @@ including it from in that cookbook's metadata.
ERROR_MESSAGE
end
-
if loaded_fully_qualified_recipe?(cookbook_name, recipe_short_name)
Chef::Log.debug("I am not loading #{recipe_name}, because I have already seen it.")
false
@@ -592,7 +591,6 @@ ERROR_MESSAGE
end
prepend Deprecated
-
#
# A child run context. Delegates all root context calls to its parent.
#
diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb
index 57aa59881a..e8311a18a6 100644
--- a/lib/chef/run_context/cookbook_compiler.rb
+++ b/lib/chef/run_context/cookbook_compiler.rb
@@ -165,7 +165,7 @@ class Chef
def load_attributes_from_cookbook(cookbook_name)
list_of_attr_files = files_in_cookbook_by_segment(cookbook_name, :attributes).dup
- if default_file = list_of_attr_files.find {|path| File.basename(path) == "default.rb" }
+ if default_file = list_of_attr_files.find { |path| File.basename(path) == "default.rb" }
list_of_attr_files.delete(default_file)
load_attribute_file(cookbook_name.to_s, default_file)
end
@@ -224,7 +224,6 @@ class Chef
raise
end
-
def load_resource_definitions_from_cookbook(cookbook_name)
files_in_cookbook_by_segment(cookbook_name, :definitions).each do |filename|
begin
@@ -258,7 +257,6 @@ class Chef
ordered_cookbooks << cookbook
end
-
def count_files_by_segment(segment)
cookbook_collection.inject(0) do |count, cookbook_by_name|
count + cookbook_by_name[1].segment_filenames(segment).size
@@ -275,7 +273,7 @@ class Chef
# +cookbook_name+ in lexical sort order.
def each_cookbook_dep(cookbook_name, &block)
cookbook = cookbook_collection[cookbook_name]
- cookbook.metadata.dependencies.keys.sort.map{|x| x.to_sym}.each(&block)
+ cookbook.metadata.dependencies.keys.sort.map { |x| x.to_sym }.each(&block)
end
# Given a +recipe_name+, finds the file associated with the recipe.
@@ -285,7 +283,6 @@ class Chef
cookbook.recipe_filenames_by_name[recipe_short_name]
end
-
end
end
diff --git a/lib/chef/run_list.rb b/lib/chef/run_list.rb
index 8b586f4077..b9ec9259ca 100644
--- a/lib/chef/run_list.rb
+++ b/lib/chef/run_list.rb
@@ -47,13 +47,13 @@ class Chef
end
def role_names
- @run_list_items.inject([]){|memo, run_list_item| memo << run_list_item.name if run_list_item.role? ; memo}
+ @run_list_items.inject([]) { |memo, run_list_item| memo << run_list_item.name if run_list_item.role? ; memo }
end
alias :roles :role_names
def recipe_names
- @run_list_items.inject([]){|memo, run_list_item| memo << run_list_item.name if run_list_item.recipe? ; memo}
+ @run_list_items.inject([]) { |memo, run_list_item| memo << run_list_item.name if run_list_item.recipe? ; memo }
end
alias :recipes :recipe_names
@@ -130,7 +130,7 @@ class Chef
end
def remove(item)
- @run_list_items.delete_if{|i| i == item}
+ @run_list_items.delete_if { |i| i == item }
self
end
alias :delete :remove
@@ -138,7 +138,7 @@ class Chef
# Expands this run_list: recursively expand roles into their included
# recipes.
# Returns a RunListExpansion object.
- def expand(environment, data_source="server", expansion_opts={})
+ def expand(environment, data_source = "server", expansion_opts = {})
expansion = expansion_for_data_source(environment, data_source, expansion_opts)
expansion.expand
expansion
@@ -153,7 +153,7 @@ class Chef
item.kind_of?(RunListItem) ? item : parse_entry(item)
end
- def expansion_for_data_source(environment, data_source, opts={})
+ def expansion_for_data_source(environment, data_source, opts = {})
case data_source.to_s
when "disk"
RunListExpansionFromDisk.new(environment, @run_list_items)
diff --git a/lib/chef/run_list/run_list_expansion.rb b/lib/chef/run_list/run_list_expansion.rb
index bac748096d..b895b53523 100644
--- a/lib/chef/run_list/run_list_expansion.rb
+++ b/lib/chef/run_list/run_list_expansion.rb
@@ -62,7 +62,7 @@ class Chef
attr_reader :all_missing_roles
attr_reader :role_errors
- def initialize(environment, run_list_items, source=nil)
+ def initialize(environment, run_list_items, source = nil)
@environment = environment
@missing_roles_with_including_role = Array.new
@@ -75,8 +75,8 @@ class Chef
@recipes = Chef::RunList::VersionedRecipeList.new
@applied_roles = {}
- @run_list_trace = Hash.new {|h, key| h[key] = [] }
- @better_run_list_trace = Hash.new {|h, key| h[key] = [] }
+ @run_list_trace = Hash.new { |h, key| h[key] = [] }
+ @better_run_list_trace = Hash.new { |h, key| h[key] = [] }
@all_missing_roles = {}
@role_errors = {}
end
@@ -140,7 +140,7 @@ class Chef
end
def errors
- @missing_roles_with_including_role.map {|item| item.first }
+ @missing_roles_with_including_role.map { |item| item.first }
end
def to_json(*a)
@@ -148,8 +148,8 @@ class Chef
end
def to_hash
- seen_items = {:recipe => {}, :role => {}}
- {:id => @environment, :run_list => convert_run_list_trace("top level", seen_items)}
+ seen_items = { :recipe => {}, :role => {} }
+ { :id => @environment, :run_list => convert_run_list_trace("top level", seen_items) }
end
private
@@ -160,11 +160,10 @@ class Chef
@applied_roles[role_name] = true
end
- def expand_run_list_items(items, included_by="top level")
-
+ def expand_run_list_items(items, included_by = "top level")
if entry = items.shift
@run_list_trace[included_by.to_s] << entry.to_s
- @better_run_list_trace[included_by.to_s] << entry
+ @better_run_list_trace[included_by.to_s] << entry
case entry.type
when :recipe
@@ -186,19 +185,18 @@ class Chef
seen_items[item.type][item.name] = true
case item.type
when :recipe
- {:type => "recipe", :name => item.name, :version => item.version, :skipped => !!skipped}
+ { :type => "recipe", :name => item.name, :version => item.version, :skipped => !!skipped }
when :role
error = @role_errors[item.name]
missing = @all_missing_roles[item.name]
- {:type => :role, :name => item.name, :children => (missing || error || skipped) ? [] : convert_run_list_trace(item.to_s, seen_items),
- :missing => missing, :error => error, :skipped => skipped}
+ { :type => :role, :name => item.name, :children => (missing || error || skipped) ? [] : convert_run_list_trace(item.to_s, seen_items),
+ :missing => missing, :error => error, :skipped => skipped }
end
end
end
end
-
# Expand a run list from disk. Suitable for chef-solo
class RunListExpansionFromDisk < RunListExpansion
@@ -234,5 +232,3 @@ class Chef
end
end
-
-
diff --git a/lib/chef/run_list/run_list_item.rb b/lib/chef/run_list/run_list_item.rb
index 3e689eddef..15e11b206e 100644
--- a/lib/chef/run_list/run_list_item.rb
+++ b/lib/chef/run_list/run_list_item.rb
@@ -25,7 +25,6 @@ class Chef
attr_reader :name, :type, :version
-
def initialize(item)
@version = nil
case item
@@ -89,7 +88,7 @@ class Chef
end
def assert_hash_is_valid_run_list_item!(item)
- unless (item.key?("type")|| item.key?(:type)) && (item.key?("name") || item.key?(:name))
+ unless (item.key?("type") || item.key?(:type)) && (item.key?("name") || item.key?(:name))
raise ArgumentError, "Initializing a #{self.class} from a hash requires that it have a 'type' and 'name' key"
end
end
diff --git a/lib/chef/run_list/versioned_recipe_list.rb b/lib/chef/run_list/versioned_recipe_list.rb
index 49622b8c43..7845568aaa 100644
--- a/lib/chef/run_list/versioned_recipe_list.rb
+++ b/lib/chef/run_list/versioned_recipe_list.rb
@@ -29,7 +29,7 @@ class Chef
@versions = Hash.new
end
- def add_recipe(name, version=nil)
+ def add_recipe(name, version = nil)
if version && @versions.has_key?(name)
unless Chef::Version.new(@versions[name]) == Chef::Version.new(version)
raise Chef::Exceptions::CookbookVersionConflict, "Run list requires #{name} at versions #{@versions[name]} and #{version}"
@@ -40,7 +40,7 @@ class Chef
end
def with_versions
- self.map {|recipe_name| {:name => recipe_name, :version => @versions[recipe_name]}}
+ self.map { |recipe_name| { :name => recipe_name, :version => @versions[recipe_name] } }
end
# Return an Array of Hashes, each of the form:
diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb
index c4e2751391..be83494048 100644
--- a/lib/chef/run_lock.rb
+++ b/lib/chef/run_lock.rb
@@ -132,7 +132,7 @@ class Chef
def create_lock
# ensure the runlock_file path exists
create_path(File.dirname(runlock_file))
- @runlock = File.open(runlock_file,"a+")
+ @runlock = File.open(runlock_file, "a+")
end
# @api private solely for race condition tests
@@ -148,7 +148,7 @@ class Chef
end
# Flock will return 0 if it can acquire the lock otherwise it
# will return false
- if runlock.flock(File::LOCK_NB|File::LOCK_EX) == 0
+ if runlock.flock(File::LOCK_NB | File::LOCK_EX) == 0
true
else
false
diff --git a/lib/chef/run_status.rb b/lib/chef/run_status.rb
index 58a6a43e3c..c3b7945bc9 100644
--- a/lib/chef/run_status.rb
+++ b/lib/chef/run_status.rb
@@ -113,7 +113,7 @@ class Chef::RunStatus
:updated_resources => updated_resources,
:exception => formatted_exception,
:backtrace => backtrace,
- :run_id => run_id}
+ :run_id => run_id }
end
# Returns a string of the format "ExceptionClass: message" or +nil+ if no
diff --git a/lib/chef/runner.rb b/lib/chef/runner.rb
index a8cda86a6b..ce128203f2 100644
--- a/lib/chef/runner.rb
+++ b/lib/chef/runner.rb
@@ -45,8 +45,7 @@ class Chef
# Determine the appropriate provider for the given resource, then
# execute it.
- def run_action(resource, action, notification_type=nil, notifying_resource=nil)
-
+ def run_action(resource, action, notification_type = nil, notifying_resource = nil)
# If there are any before notifications, why-run the resource
# and notify anyone who needs notifying
# TODO cheffish has a bug where it passes itself instead of the run_context to us, so doesn't have before_notifications. Fix there, update dependency requirement, and remove this if statement.
@@ -103,7 +102,7 @@ class Chef
# Execute each resource.
run_context.resource_collection.execute_each_resource do |resource|
- Array(resource.action).each {|action| run_action(resource, action)}
+ Array(resource.action).each { |action| run_action(resource, action) }
end
rescue Exception => e
@@ -117,7 +116,7 @@ class Chef
private
# Run all our :delayed actions
- def run_delayed_notifications(error=nil)
+ def run_delayed_notifications(error = nil)
collected_failures = Exceptions::MultipleFailures.new
collected_failures.client_run_failure(error) unless error.nil?
delayed_actions.each do |notification|
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index 6041cafcf8..8a205160fa 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -29,7 +29,7 @@ class Chef
attr_accessor :rest
attr_reader :config
- def initialize(url=nil, config:Chef::Config)
+ def initialize(url = nil, config:Chef::Config)
@config = config
@url = url
end
@@ -40,7 +40,7 @@ class Chef
# Backwards compatability for cookbooks.
# This can be removed in Chef > 12.
- def partial_search(type, query="*:*", *args, &block)
+ def partial_search(type, query = "*:*", *args, &block)
Chef::Log.warn(<<-WARNDEP)
DEPRECATED: The 'partial_search' API is deprecated and will be removed in
future releases. Please use 'search' with a :filter_result argument to get
@@ -80,7 +80,7 @@ WARNDEP
# an example of the returned json may be:
# {"ip_address":"127.0.0.1", "ruby_version": "1.9.3"}
#
- def search(type, query="*:*", *args, &block)
+ def search(type, query = "*:*", *args, &block)
validate_type(type)
args_h = hashify_args(*args)
@@ -116,8 +116,8 @@ WARNDEP
def validate_type(t)
unless t.kind_of?(String) || t.kind_of?(Symbol)
msg = "Invalid search object type #{t.inspect} (#{t.class}), must be a String or Symbol." +
- "Usage: search(:node, QUERY[, OPTIONAL_ARGS])" +
- " `knife search environment QUERY (options)`"
+ "Usage: search(:node, QUERY[, OPTIONAL_ARGS])" +
+ " `knife search environment QUERY (options)`"
raise Chef::Exceptions::InvalidSearchQuery, msg
end
end
diff --git a/lib/chef/server_api.rb b/lib/chef/server_api.rb
index 3bfceacdd7..cad8586ac8 100644
--- a/lib/chef/server_api.rb
+++ b/lib/chef/server_api.rb
@@ -57,7 +57,7 @@ class Chef
# Makes an HTTP request to +path+ with the given +method+, +headers+, and
# +data+ (if applicable). Does not apply any middleware, besides that
# needed for Authentication.
- def raw_request(method, path, headers={}, data=false)
+ def raw_request(method, path, headers = {}, data = false)
url = create_url(path)
method, url, headers, data = Chef::HTTP::Authenticator.new(options).handle_request(method, url, headers, data)
method, url, headers, data = Chef::HTTP::RemoteRequestID.new(options).handle_request(method, url, headers, data)
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index c877c1cbf3..72081b18df 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -64,7 +64,6 @@ module Shell
init(irb.context.main)
-
irb_conf[:IRB_RC].call(irb.context) if irb_conf[:IRB_RC]
irb_conf[:MAIN_CONTEXT] = irb.context
@@ -186,7 +185,7 @@ module Shell
class Options
include Mixlib::CLI
- def self.footer(text=nil)
+ def self.footer(text = nil)
@footer = text if text
@footer
end
@@ -232,7 +231,7 @@ FOOTER
:long => "--solo",
:description => "chef-solo session",
:boolean => true,
- :proc => proc {Chef::Config[:solo] = true}
+ :proc => proc { Chef::Config[:solo] = true }
option :client,
:short => "-z",
@@ -257,14 +256,14 @@ FOOTER
:long => "--version",
:description => "Show chef version",
:boolean => true,
- :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
+ :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
:exit => 0
option :override_runlist,
:short => "-o RunlistItem,RunlistItem...",
:long => "--override-runlist RunlistItem,RunlistItem...",
:description => "Replace current run list with specified items",
- :proc => lambda { |items| items.split(",").map { |item| Chef::RunList::RunListItem.new(item) }}
+ :proc => lambda { |items| items.split(",").map { |item| Chef::RunList::RunListItem.new(item) } }
def self.print_help
instance = new
diff --git a/lib/chef/shell/ext.rb b/lib/chef/shell/ext.rb
index 902de4ec04..83863b16f7 100644
--- a/lib/chef/shell/ext.rb
+++ b/lib/chef/shell/ext.rb
@@ -40,7 +40,7 @@ module Shell
# so these methods need to be defined at the latest possible time.
unless jobs.respond_to?(:select_session_by_context)
def jobs.select_session_by_context(&block)
- @jobs.select { |job| block.call(job[1].context.main)}
+ @jobs.select { |job| block.call(job[1].context.main) }
end
end
@@ -125,7 +125,7 @@ module Shell
@explain = explain_text
end
- def subcommands(subcommand_help={})
+ def subcommands(subcommand_help = {})
@subcommand_help = subcommand_help
end
@@ -197,7 +197,7 @@ module Shell
prints a detailed explanation of the command if available, or the
description if no explanation is available.
E
- def help(commmand=nil)
+ def help(commmand = nil)
if commmand
explain_command(commmand)
else
@@ -209,10 +209,10 @@ module Shell
desc "prints information about chef"
def version
- puts "This is the chef-shell.\n" +
- " Chef Version: #{::Chef::VERSION}\n" +
- " http://www.chef.io/\n" +
- " http://docs.chef.io/"
+ puts "This is the chef-shell.\n" +
+ " Chef Version: #{::Chef::VERSION}\n" +
+ " http://www.chef.io/\n" +
+ " http://docs.chef.io/"
:ucanhaz_automation
end
alias :shell :version
@@ -240,9 +240,9 @@ module Shell
desc "returns an object to control a paused chef run"
subcommands :resume => "resume the chef run",
- :step => "run only the next resource",
- :skip_back => "move back in the run list",
- :skip_forward => "move forward in the run list"
+ :step => "run only the next resource",
+ :skip_back => "move back in the run list",
+ :skip_forward => "move forward in the run list"
def chef_run
Shell.session.resource_collection.iterator
end
@@ -295,7 +295,7 @@ module Shell
end
desc "pretty print the node's attributes"
- def ohai(key=nil)
+ def ohai(key = nil)
pp(key ? node.attribute[key] : node.attribute)
end
end
@@ -394,17 +394,17 @@ module Shell
This will strip the admin privileges from any client named after borat.
E
subcommands :all => "list all api clients",
- :show => "load an api client by name",
- :search => "search for API clients",
- :transform => "edit all api clients via a code block and save them"
+ :show => "load an api client by name",
+ :search => "search for API clients",
+ :transform => "edit all api clients via a code block and save them"
def clients
@clients ||= Shell::ModelWrapper.new(Chef::ApiClient, :client)
end
desc "Find and edit cookbooks"
subcommands :all => "list all cookbooks",
- :show => "load a cookbook by name",
- :transform => "edit all cookbooks via a code block and save them"
+ :show => "load a cookbook by name",
+ :transform => "edit all cookbooks via a code block and save them"
def cookbooks
@cookbooks ||= Shell::ModelWrapper.new(Chef::CookbookVersion)
end
@@ -456,9 +456,9 @@ module Shell
This will assign the attribute to every node with a FQDN matching the regex.
E
subcommands :all => "list all nodes",
- :show => "load a node by name",
- :search => "search for nodes",
- :transform => "edit all nodes via a code block and save them"
+ :show => "load a node by name",
+ :search => "search for nodes",
+ :transform => "edit all nodes via a code block and save them"
def nodes
@nodes ||= Shell::ModelWrapper.new(Chef::Node)
end
@@ -478,9 +478,9 @@ module Shell
See the help for +nodes+ for more information about the subcommands.
E
subcommands :all => "list all roles",
- :show => "load a role by name",
- :search => "search for roles",
- :transform => "edit all roles via a code block and save them"
+ :show => "load a role by name",
+ :search => "search for roles",
+ :transform => "edit all roles via a code block and save them"
def roles
@roles ||= Shell::ModelWrapper.new(Chef::Role)
end
@@ -504,9 +504,9 @@ module Shell
E
subcommands :all => "list all items in the data bag",
- :show => "load a data bag item by id",
- :search => "search for items in the data bag",
- :transform => "edit all items via a code block and save them"
+ :show => "load a data bag item by id",
+ :search => "search for items in the data bag",
+ :transform => "edit all items via a code block and save them"
def databags(databag_name)
@named_databags_wrappers ||= {}
@named_databags_wrappers[databag_name] ||= Shell::NamedDataBagWrapper.new(databag_name)
@@ -527,9 +527,9 @@ module Shell
See the help for +nodes+ for more information about the subcommands.
E
subcommands :all => "list all environments",
- :show => "load an environment by name",
- :search => "search for environments",
- :transform => "edit all environments via a code block and save them"
+ :show => "load an environment by name",
+ :search => "search for environments",
+ :transform => "edit all environments via a code block and save them"
def environments
@environments ||= Shell::ModelWrapper.new(Chef::Environment)
end
diff --git a/lib/chef/shell/model_wrapper.rb b/lib/chef/shell/model_wrapper.rb
index f9f9874401..403f9479cf 100644
--- a/lib/chef/shell/model_wrapper.rb
+++ b/lib/chef/shell/model_wrapper.rb
@@ -26,7 +26,7 @@ module Shell
attr_reader :model_symbol
- def initialize(model_class, symbol=nil)
+ def initialize(model_class, symbol = nil)
@model_class = model_class
@model_symbol = symbol || convert_to_snake_case(model_class.name, "Chef").to_sym
end
@@ -79,8 +79,8 @@ module Shell
# paper over inconsistencies in the model classes APIs, and return the objects
# the user wanted instead of the URI=>object stuff
def list_objects
- objects = @model_class.method(:list).arity == 0? @model_class.list : @model_class.list(true)
- objects.map { |obj| Array(obj).find {|o| o.kind_of?(@model_class)} }
+ objects = @model_class.method(:list).arity == 0 ? @model_class.list : @model_class.list(true)
+ objects.map { |obj| Array(obj).find { |o| o.kind_of?(@model_class) } }
end
def format_query(query)
@@ -98,7 +98,6 @@ module Shell
@model_symbol = @databag_name = databag_name
end
-
alias :list :all
def show(item)
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index 431f9a8121..6d8b6f14ae 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -33,7 +33,7 @@ module Shell
class ShellSession
include Singleton
- def self.session_type(type=nil)
+ def self.session_type(type = nil)
@session_type = type if type
@session_type
end
@@ -244,7 +244,7 @@ module Shell
Chef::Log.debug("Building node object for #{@node_name}")
@node = Chef::Node.find_or_create(node_name)
ohai_data = @ohai.data.merge(@node.automatic_attrs)
- @node.consume_external_attrs(ohai_data,nil)
+ @node.consume_external_attrs(ohai_data, nil)
@run_list_expansion = @node.expand!("server")
@expanded_run_list_with_versions = @run_list_expansion.recipes.with_version_constraints_strings
Chef::Log.info("Run List is [#{@node.run_list}]")
@@ -254,7 +254,7 @@ module Shell
def register
@rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url], :client_name => Chef::Config[:node_name],
- :signing_key_filename => Chef::Config[:client_key])
+ :signing_key_filename => Chef::Config[:client_key])
end
end
diff --git a/lib/chef/shell_out.rb b/lib/chef/shell_out.rb
index bf6018df52..54ff718e8e 100644
--- a/lib/chef/shell_out.rb
+++ b/lib/chef/shell_out.rb
@@ -5,7 +5,7 @@ class Chef
def initialize(*args)
Chef::Log.warn("Chef::ShellOut is deprecated, please use Mixlib::ShellOut")
- called_from = caller[0..3].inject("Called from:\n") {|msg, trace_line| msg << " #{trace_line}\n" }
+ called_from = caller[0..3].inject("Called from:\n") { |msg, trace_line| msg << " #{trace_line}\n" }
Chef::Log.warn(called_from)
super
end
diff --git a/lib/chef/tasks/chef_repo.rake b/lib/chef/tasks/chef_repo.rake
index 5d5d6640b9..543bd8d864 100644
--- a/lib/chef/tasks/chef_repo.rake
+++ b/lib/chef/tasks/chef_repo.rake
@@ -176,7 +176,6 @@ def deprecation_notice
NOTICE: Chef Repository Rake Tasks Are Deprecated
*************************************************
}
-
end
def deprecated_cookbook_upload
diff --git a/lib/chef/user.rb b/lib/chef/user.rb
index 7791b56cb5..a6fc21646d 100644
--- a/lib/chef/user.rb
+++ b/lib/chef/user.rb
@@ -49,30 +49,30 @@ class Chef
end
def chef_rest_v0
- @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"})
+ @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" })
end
- def name(arg=nil)
+ def name(arg = nil)
set_or_return(:name, arg,
:regex => /^[a-z0-9\-_]+$/)
end
- def admin(arg=nil)
+ def admin(arg = nil)
set_or_return(:admin,
arg, :kind_of => [TrueClass, FalseClass])
end
- def public_key(arg=nil)
+ def public_key(arg = nil)
set_or_return(:public_key,
arg, :kind_of => String)
end
- def private_key(arg=nil)
+ def private_key(arg = nil)
set_or_return(:private_key,
arg, :kind_of => String)
end
- def password(arg=nil)
+ def password(arg = nil)
set_or_return(:password,
arg, :kind_of => String)
end
@@ -97,21 +97,21 @@ class Chef
end
def create
- payload = {:name => self.name, :admin => self.admin, :password => self.password }
+ payload = { :name => self.name, :admin => self.admin, :password => self.password }
payload[:public_key] = public_key if public_key
new_user = chef_rest_v0.post("users", payload)
Chef::User.from_hash(self.to_hash.merge(new_user))
end
- def update(new_key=false)
- payload = {:name => name, :admin => admin}
+ def update(new_key = false)
+ payload = { :name => name, :admin => admin }
payload[:private_key] = new_key if new_key
payload[:password] = password if password
updated_user = chef_rest_v0.put("users/#{name}", payload)
Chef::User.from_hash(self.to_hash.merge(updated_user))
end
- def save(new_key=false)
+ def save(new_key = false)
begin
create
rescue Net::HTTPServerException => e
@@ -159,8 +159,8 @@ class Chef
Chef::User.from_json(json)
end
- def self.list(inflate=false)
- response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"}).get("users")
+ def self.list(inflate = false)
+ response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }).get("users")
users = if response.is_a?(Array)
transform_ohc_list_response(response) # OHC/OPC
else
@@ -177,7 +177,7 @@ class Chef
end
def self.load(name)
- response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"}).get("users/#{name}")
+ response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }).get("users/#{name}")
Chef::User.from_hash(response)
end
diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb
index ba0253d50e..3b7dc330df 100644
--- a/lib/chef/user_v1.rb
+++ b/lib/chef/user_v1.rb
@@ -39,7 +39,7 @@ class Chef
include Chef::Mixin::ParamsValidate
include Chef::Mixin::ApiVersionRequestHandling
- SUPPORTED_API_VERSIONS = [0,1]
+ SUPPORTED_API_VERSIONS = [0, 1]
def initialize
@username = nil
@@ -55,59 +55,59 @@ class Chef
end
def chef_root_rest_v0
- @chef_root_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], {:api_version => "0"})
+ @chef_root_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { :api_version => "0" })
end
def chef_root_rest_v1
- @chef_root_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], {:api_version => "1"})
+ @chef_root_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { :api_version => "1" })
end
- def username(arg=nil)
+ def username(arg = nil)
set_or_return(:username, arg,
:regex => /^[a-z0-9\-_]+$/)
end
- def display_name(arg=nil)
+ def display_name(arg = nil)
set_or_return(:display_name,
arg, :kind_of => String)
end
- def first_name(arg=nil)
+ def first_name(arg = nil)
set_or_return(:first_name,
arg, :kind_of => String)
end
- def middle_name(arg=nil)
+ def middle_name(arg = nil)
set_or_return(:middle_name,
arg, :kind_of => String)
end
- def last_name(arg=nil)
+ def last_name(arg = nil)
set_or_return(:last_name,
arg, :kind_of => String)
end
- def email(arg=nil)
+ def email(arg = nil)
set_or_return(:email,
arg, :kind_of => String)
end
- def create_key(arg=nil)
+ def create_key(arg = nil)
set_or_return(:create_key, arg,
:kind_of => [TrueClass, FalseClass])
end
- def public_key(arg=nil)
+ def public_key(arg = nil)
set_or_return(:public_key,
arg, :kind_of => String)
end
- def private_key(arg=nil)
+ def private_key(arg = nil)
set_or_return(:private_key,
arg, :kind_of => String)
end
- def password(arg=nil)
+ def password(arg = nil)
set_or_return(:password,
arg, :kind_of => String)
end
@@ -183,9 +183,9 @@ class Chef
Chef::UserV1.from_hash(self.to_hash.merge(new_user))
end
- def update(new_key=false)
+ def update(new_key = false)
begin
- payload = {:username => username}
+ payload = { :username => username }
payload[:display_name] = display_name unless display_name.nil?
payload[:first_name] = first_name unless first_name.nil?
payload[:middle_name] = middle_name unless middle_name.nil?
@@ -216,7 +216,7 @@ class Chef
Chef::UserV1.from_hash(self.to_hash.merge(updated_user))
end
- def save(new_key=false)
+ def save(new_key = false)
begin
create
rescue Net::HTTPServerException => e
@@ -231,7 +231,7 @@ class Chef
# Note: remove after API v0 no longer supported by client (and knife command).
def reregister
begin
- payload = self.to_hash.merge({"private_key" => true})
+ payload = self.to_hash.merge({ "private_key" => true })
reregistered_self = chef_root_rest_v0.put("users/#{username}", payload)
private_key(reregistered_self["private_key"])
# only V0 supported for reregister
@@ -281,7 +281,7 @@ class Chef
Chef::UserV1.from_json(json)
end
- def self.list(inflate=false)
+ def self.list(inflate = false)
response = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("users")
users = if response.is_a?(Array)
# EC 11 / CS 12 V0, V1
diff --git a/lib/chef/util/backup.rb b/lib/chef/util/backup.rb
index e9b4ed2fe3..8bf2b3f25b 100644
--- a/lib/chef/util/backup.rb
+++ b/lib/chef/util/backup.rb
@@ -83,11 +83,11 @@ class Chef
fn = Regexp.escape(::File.basename(path))
Dir.entries(::File.dirname(backup_path)).select do |f|
!!(f =~ /\A#{fn}.chef-[0-9.]*\B/)
- end.map {|f| ::File.join(::File.dirname(backup_path), f)}
+ end.map { |f| ::File.join(::File.dirname(backup_path), f) }
end
def sorted_backup_files
- unsorted_backup_files.sort { |a,b| b <=> a }
+ unsorted_backup_files.sort { |a, b| b <=> a }
end
end
end
diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb
index bec9c69ff7..af9a71b246 100644
--- a/lib/chef/util/dsc/configuration_generator.rb
+++ b/lib/chef/util/dsc/configuration_generator.rb
@@ -70,7 +70,7 @@ class Chef::Util::DSC
def get_merged_configuration_flags!(configuration_flags, configuration_name)
merged_configuration_flags = { :outputpath => configuration_document_directory(configuration_name) }
if configuration_flags
- configuration_flags.map do | switch, value |
+ configuration_flags.map do |switch, value|
if merged_configuration_flags.key?(switch.to_s.downcase.to_sym)
raise ArgumentError, "The `flags` attribute for the dsc_script resource contained a command line switch :#{switch} that is disallowed."
end
@@ -114,7 +114,7 @@ Configuration '#{configuration_name}'
def write_document_generation_script(code, configuration_name, imports)
script_path = "#{@config_directory}/chef_dsc_config.ps1"
- ::File.open(script_path, "wt") do | script |
+ ::File.open(script_path, "wt") do |script|
script.write(configuration_code(code, configuration_name, imports))
end
script_path
@@ -122,7 +122,7 @@ Configuration '#{configuration_name}'
def find_configuration_document(configuration_name)
document_directory = configuration_document_directory(configuration_name)
- document_file_name = ::Dir.entries(document_directory).find { | path | path =~ /.*.mof/ }
+ document_file_name = ::Dir.entries(document_directory).find { |path| path =~ /.*.mof/ }
::File.join(document_directory, document_file_name) if document_file_name
end
@@ -131,7 +131,7 @@ Configuration '#{configuration_name}'
end
def get_configuration_document(document_path)
- ::File.open(document_path, "rb") do | file |
+ ::File.open(document_path, "rb") do |file|
file.read
end
end
diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb
index 8f62a27c8a..2e81b363e0 100644
--- a/lib/chef/util/dsc/lcm_output_parser.rb
+++ b/lib/chef/util/dsc/lcm_output_parser.rb
@@ -73,7 +73,7 @@ class Chef
if current_resource[:name]
resources.push(current_resource)
end
- current_resource = {:name => info}
+ current_resource = { :name => info }
else
Chef::Log.debug("Ignoring op_action #{op_action}: Read line #{line}")
end
@@ -108,8 +108,8 @@ class Chef
# If the line looks like
# What If: [machinename]: LCM: [op_action op_type] message
# extract op_action, op_type, and message
- operation, info = match.captures
- op_action, op_type = operation.strip.split(" ").map {|m| m.downcase.to_sym}
+ operation, info = match.captures
+ op_action, op_type = operation.strip.split(" ").map { |m| m.downcase.to_sym }
else
op_action = op_type = :info
if match = line.match(/^.*?:.*?: \s+(.*)/)
diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb
index 6db8f40eae..3b4eaa92a9 100644
--- a/lib/chef/util/dsc/local_configuration_manager.rb
+++ b/lib/chef/util/dsc/local_configuration_manager.rb
@@ -111,7 +111,7 @@ EOH
def save_configuration_document(configuration_document)
::FileUtils.mkdir_p(@configuration_path)
- ::File.open(configuration_document_path, "wb") do | file |
+ ::File.open(configuration_document_path, "wb") do |file|
file.write(configuration_document)
end
end
@@ -121,7 +121,7 @@ EOH
end
def configuration_document_path
- File.join(@configuration_path,"..mof")
+ File.join(@configuration_path, "..mof")
end
def clear_execution_time
diff --git a/lib/chef/util/dsc/resource_info.rb b/lib/chef/util/dsc/resource_info.rb
index 4a32451721..d6dfcff59a 100644
--- a/lib/chef/util/dsc/resource_info.rb
+++ b/lib/chef/util/dsc/resource_info.rb
@@ -2,25 +2,25 @@
class Chef
class Util
class DSC
- class ResourceInfo
- # The name is the text following [Start Set]
- attr_reader :name
+ class ResourceInfo
+ # The name is the text following [Start Set]
+ attr_reader :name
- # A list of all log messages between [Start Set] and [End Set].
- # Each line is an element in the list.
- attr_reader :change_log
+ # A list of all log messages between [Start Set] and [End Set].
+ # Each line is an element in the list.
+ attr_reader :change_log
- def initialize(name, sets, change_log)
- @name = name
- @sets = sets
- @change_log = change_log || []
- end
+ def initialize(name, sets, change_log)
+ @name = name
+ @sets = sets
+ @change_log = change_log || []
+ end
- # Does this resource change the state of the system?
- def changes_state?
- @sets
- end
+ # Does this resource change the state of the system?
+ def changes_state?
+ @sets
end
+ end
end
end
end
diff --git a/lib/chef/util/dsc/resource_store.rb b/lib/chef/util/dsc/resource_store.rb
index df8cfa84ed..bb3480d105 100644
--- a/lib/chef/util/dsc/resource_store.rb
+++ b/lib/chef/util/dsc/resource_store.rb
@@ -21,90 +21,89 @@ require "chef/util/powershell/cmdlet_result"
require "chef/exceptions"
class Chef
-class Util
-class DSC
- class ResourceStore
+ class Util
+ class DSC
+ class ResourceStore
- def self.instance
- @@instance ||= ResourceStore.new.tap do |store|
- store.send(:populate_cache)
- end
- end
+ def self.instance
+ @@instance ||= ResourceStore.new.tap do |store|
+ store.send(:populate_cache)
+ end
+ end
- def resources
- @resources ||= []
- end
+ def resources
+ @resources ||= []
+ end
- def find(name, module_name=nil)
- found = find_resources(name, module_name, resources)
+ def find(name, module_name = nil)
+ found = find_resources(name, module_name, resources)
- # We don't have it, query for the resource...it might
- # have been added since we last queried
- if found.length == 0
- rs = query_resource(name)
- add_resources(rs)
- found = find_resources(name, module_name, rs)
- end
+ # We don't have it, query for the resource...it might
+ # have been added since we last queried
+ if found.length == 0
+ rs = query_resource(name)
+ add_resources(rs)
+ found = find_resources(name, module_name, rs)
+ end
- found
- end
-
- private
+ found
+ end
- def add_resource(new_r)
- count = resources.count do |r|
- r["ResourceType"].casecmp(new_r["ResourceType"]) == 0
- end
- if count == 0
- resources << new_r
- end
- end
+ private
- def add_resources(rs)
- rs.each do |r|
- add_resource(r)
- end
- end
+ def add_resource(new_r)
+ count = resources.count do |r|
+ r["ResourceType"].casecmp(new_r["ResourceType"]) == 0
+ end
+ if count == 0
+ resources << new_r
+ end
+ end
- def populate_cache
- @resources = query_resources
- end
+ def add_resources(rs)
+ rs.each do |r|
+ add_resource(r)
+ end
+ end
- def find_resources(name, module_name, rs)
- found = rs.find_all do |r|
- name_matches = r["Name"].casecmp(name) == 0
- if name_matches
- module_name == nil || (r["Module"] and r["Module"]["Name"].casecmp(module_name) == 0)
- else
- false
+ def populate_cache
+ @resources = query_resources
end
- end
- end
+ def find_resources(name, module_name, rs)
+ found = rs.find_all do |r|
+ name_matches = r["Name"].casecmp(name) == 0
+ if name_matches
+ module_name == nil || (r["Module"] and r["Module"]["Name"].casecmp(module_name) == 0)
+ else
+ false
+ end
+ end
+ end
- # Returns a list of dsc resources
- def query_resources
- cmdlet = Chef::Util::Powershell::Cmdlet.new(nil, "get-dscresource",
- :object)
- result = cmdlet.run
- result.return_value
- end
+ # Returns a list of dsc resources
+ def query_resources
+ cmdlet = Chef::Util::Powershell::Cmdlet.new(nil, "get-dscresource",
+ :object)
+ result = cmdlet.run
+ result.return_value
+ end
- # Returns a list of dsc resources matching the provided name
- def query_resource(resource_name)
- cmdlet = Chef::Util::Powershell::Cmdlet.new(nil, "get-dscresource #{resource_name}",
- :object)
- result = cmdlet.run
- ret_val = result.return_value
- if ret_val.nil?
- []
- elsif ret_val.is_a? Array
- ret_val
- else
- [ret_val]
+ # Returns a list of dsc resources matching the provided name
+ def query_resource(resource_name)
+ cmdlet = Chef::Util::Powershell::Cmdlet.new(nil, "get-dscresource #{resource_name}",
+ :object)
+ result = cmdlet.run
+ ret_val = result.return_value
+ if ret_val.nil?
+ []
+ elsif ret_val.is_a? Array
+ ret_val
+ else
+ [ret_val]
+ end
+ end
end
end
end
end
-end
-end
diff --git a/lib/chef/util/editor.rb b/lib/chef/util/editor.rb
index 4073a0be70..fa4f0ec12e 100644
--- a/lib/chef/util/editor.rb
+++ b/lib/chef/util/editor.rb
@@ -89,4 +89,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb
index d9b53f6c7c..6ab380c071 100644
--- a/lib/chef/util/powershell/cmdlet.rb
+++ b/lib/chef/util/powershell/cmdlet.rb
@@ -21,150 +21,150 @@ require "chef/mixin/windows_architecture_helper"
require "chef/util/powershell/cmdlet_result"
class Chef
-class Util
-class Powershell
- class Cmdlet
- def initialize(node, cmdlet, output_format=nil, output_format_options={})
- @output_format = output_format
- @node = node
-
- case output_format
- when nil
- @json_format = false
- when :json
- @json_format = true
- when :text
- @json_format = false
- when :object
- @json_format = true
- else
- raise ArgumentError, "Invalid output format #{output_format} specified"
- end
-
- @cmdlet = cmdlet
- @output_format_options = output_format_options
- end
-
- attr_reader :output_format
+ class Util
+ class Powershell
+ class Cmdlet
+ def initialize(node, cmdlet, output_format = nil, output_format_options = {})
+ @output_format = output_format
+ @node = node
+
+ case output_format
+ when nil
+ @json_format = false
+ when :json
+ @json_format = true
+ when :text
+ @json_format = false
+ when :object
+ @json_format = true
+ else
+ raise ArgumentError, "Invalid output format #{output_format} specified"
+ end
- def run(switches={}, execution_options={}, *arguments)
- streams = { :json => CmdletStream.new("json"),
- :verbose => CmdletStream.new("verbose"),
- }
+ @cmdlet = cmdlet
+ @output_format_options = output_format_options
+ end
- arguments_string = arguments.join(" ")
+ attr_reader :output_format
- switches_string = command_switches_string(switches)
+ def run(switches = {}, execution_options = {}, *arguments)
+ streams = { :json => CmdletStream.new("json"),
+ :verbose => CmdletStream.new("verbose"),
+ }
- json_depth = 5
+ arguments_string = arguments.join(" ")
- if @json_format && @output_format_options.has_key?(:depth)
- json_depth = @output_format_options[:depth]
- end
+ switches_string = command_switches_string(switches)
- json_command = @json_format ? " | convertto-json -compress -depth #{json_depth} "\
- "> #{streams[:json].path}" : ""
- redirections = "4> '#{streams[:verbose].path}'"
- command_string = "powershell.exe -executionpolicy bypass -noprofile -noninteractive "\
- "-command \"trap [Exception] {write-error -exception "\
- "($_.Exception.Message);exit 1};#{@cmdlet} #{switches_string} "\
- "#{arguments_string} #{redirections}"\
- "#{json_command}\";if ( ! $? ) { exit 1 }"
+ json_depth = 5
- augmented_options = {:returns => [0], :live_stream => false}.merge(execution_options)
- command = Mixlib::ShellOut.new(command_string, augmented_options)
+ if @json_format && @output_format_options.has_key?(:depth)
+ json_depth = @output_format_options[:depth]
+ end
- status = nil
+ json_command = @json_format ? " | convertto-json -compress -depth #{json_depth} "\
+ "> #{streams[:json].path}" : ""
+ redirections = "4> '#{streams[:verbose].path}'"
+ command_string = "powershell.exe -executionpolicy bypass -noprofile -noninteractive "\
+ "-command \"trap [Exception] {write-error -exception "\
+ "($_.Exception.Message);exit 1};#{@cmdlet} #{switches_string} "\
+ "#{arguments_string} #{redirections}"\
+ "#{json_command}\";if ( ! $? ) { exit 1 }"
- with_os_architecture(@node) do
- status = command.run_command
- end
+ augmented_options = { :returns => [0], :live_stream => false }.merge(execution_options)
+ command = Mixlib::ShellOut.new(command_string, augmented_options)
- CmdletResult.new(status, streams, @output_format)
- end
+ status = nil
- def run!(switches={}, execution_options={}, *arguments)
- result = run(switches, execution_options, arguments)
+ with_os_architecture(@node) do
+ status = command.run_command
+ end
- if ! result.succeeded?
- raise Chef::Exceptions::PowershellCmdletException, "Powershell Cmdlet failed: #{result.stderr}"
- end
+ CmdletResult.new(status, streams, @output_format)
+ end
- result
- end
+ def run!(switches = {}, execution_options = {}, *arguments)
+ result = run(switches, execution_options, arguments)
- protected
+ if ! result.succeeded?
+ raise Chef::Exceptions::PowershellCmdletException, "Powershell Cmdlet failed: #{result.stderr}"
+ end
- include Chef::Mixin::WindowsArchitectureHelper
+ result
+ end
- def validate_switch_name!(switch_parameter_name)
- if !!(switch_parameter_name =~ /\A[A-Za-z]+[_a-zA-Z0-9]*\Z/) == false
- raise ArgumentError, "`#{switch_parameter_name}` is not a valid PowerShell cmdlet switch parameter name"
- end
- end
+ protected
- def escape_parameter_value(parameter_value)
- parameter_value.gsub(/(`|'|"|#)/,'`\1')
- end
+ include Chef::Mixin::WindowsArchitectureHelper
- def escape_string_parameter_value(parameter_value)
- "'#{escape_parameter_value(parameter_value)}'"
- end
+ def validate_switch_name!(switch_parameter_name)
+ if !!(switch_parameter_name =~ /\A[A-Za-z]+[_a-zA-Z0-9]*\Z/) == false
+ raise ArgumentError, "`#{switch_parameter_name}` is not a valid PowerShell cmdlet switch parameter name"
+ end
+ end
- def command_switches_string(switches)
- command_switches = switches.map do | switch_name, switch_value |
- if switch_name.class != Symbol
- raise ArgumentError, "Invalid type `#{switch_name} `for PowerShell switch '#{switch_name}'. The switch must be specified as a Symbol'"
+ def escape_parameter_value(parameter_value)
+ parameter_value.gsub(/(`|'|"|#)/, '`\1')
end
- validate_switch_name!(switch_name)
-
- switch_argument = ""
- switch_present = true
-
- case switch_value
- when Numeric
- switch_argument = switch_value.to_s
- when Float
- switch_argument = switch_value.to_s
- when FalseClass
- switch_present = false
- when TrueClass
- when String
- switch_argument = escape_string_parameter_value(switch_value)
- else
- raise ArgumentError, "Invalid argument type `#{switch_value.class}` specified for PowerShell switch `:#{switch_name}`. Arguments to PowerShell must be of type `String`, `Numeric`, `Float`, `FalseClass`, or `TrueClass`"
+ def escape_string_parameter_value(parameter_value)
+ "'#{escape_parameter_value(parameter_value)}'"
end
- switch_present ? ["-#{switch_name.to_s.downcase}", switch_argument].join(" ").strip : ""
- end
+ def command_switches_string(switches)
+ command_switches = switches.map do |switch_name, switch_value|
+ if switch_name.class != Symbol
+ raise ArgumentError, "Invalid type `#{switch_name} `for PowerShell switch '#{switch_name}'. The switch must be specified as a Symbol'"
+ end
+
+ validate_switch_name!(switch_name)
+
+ switch_argument = ""
+ switch_present = true
+
+ case switch_value
+ when Numeric
+ switch_argument = switch_value.to_s
+ when Float
+ switch_argument = switch_value.to_s
+ when FalseClass
+ switch_present = false
+ when TrueClass
+ when String
+ switch_argument = escape_string_parameter_value(switch_value)
+ else
+ raise ArgumentError, "Invalid argument type `#{switch_value.class}` specified for PowerShell switch `:#{switch_name}`. Arguments to PowerShell must be of type `String`, `Numeric`, `Float`, `FalseClass`, or `TrueClass`"
+ end
+
+ switch_present ? ["-#{switch_name.to_s.downcase}", switch_argument].join(" ").strip : ""
+ end
- command_switches.join(" ")
- end
+ command_switches.join(" ")
+ end
- class CmdletStream
- def initialize(name)
- @filename = Dir::Tmpname.create(name) {}
- ObjectSpace.define_finalizer(self, self.class.destroy(@filename))
- end
+ class CmdletStream
+ def initialize(name)
+ @filename = Dir::Tmpname.create(name) {}
+ ObjectSpace.define_finalizer(self, self.class.destroy(@filename))
+ end
- def path
- @filename
- end
+ def path
+ @filename
+ end
- def read
- if File.exist? @filename
- File.open(@filename, "rb:bom|UTF-16LE") do |f|
- f.read.encode("UTF-8")
+ def read
+ if File.exist? @filename
+ File.open(@filename, "rb:bom|UTF-16LE") do |f|
+ f.read.encode("UTF-8")
+ end
+ end
end
- end
- end
- def self.destroy(name)
- proc { File.delete(name) if File.exists? name }
+ def self.destroy(name)
+ proc { File.delete(name) if File.exists? name }
+ end
+ end
end
end
end
end
-end
-end
diff --git a/lib/chef/util/powershell/cmdlet_result.rb b/lib/chef/util/powershell/cmdlet_result.rb
index 4f97658a58..82aef4da40 100644
--- a/lib/chef/util/powershell/cmdlet_result.rb
+++ b/lib/chef/util/powershell/cmdlet_result.rb
@@ -19,43 +19,43 @@
require "chef/json_compat"
class Chef
-class Util
-class Powershell
- class CmdletResult
- attr_reader :output_format
-
- def initialize(status, streams, output_format)
- @status = status
- @output_format = output_format
- @streams = streams
- end
+ class Util
+ class Powershell
+ class CmdletResult
+ attr_reader :output_format
- def stdout
- @status.stdout
- end
-
- def stderr
- @status.stderr
- end
+ def initialize(status, streams, output_format)
+ @status = status
+ @output_format = output_format
+ @streams = streams
+ end
- def stream(name)
- @streams[name].read
- end
+ def stdout
+ @status.stdout
+ end
- def return_value
- if output_format == :object
- Chef::JSONCompat.parse(stream(:json))
- elsif output_format == :json
- stream(:json)
- else
- @status.stdout
- end
- end
+ def stderr
+ @status.stderr
+ end
- def succeeded?
- @succeeded = @status.status.exitstatus == 0
+ def stream(name)
+ @streams[name].read
+ end
+
+ def return_value
+ if output_format == :object
+ Chef::JSONCompat.parse(stream(:json))
+ elsif output_format == :json
+ stream(:json)
+ else
+ @status.stdout
+ end
+ end
+
+ def succeeded?
+ @succeeded = @status.status.exitstatus == 0
+ end
+ end
end
end
end
-end
-end
diff --git a/lib/chef/util/selinux.rb b/lib/chef/util/selinux.rb
index 46b4dfce36..1aac7eeeca 100644
--- a/lib/chef/util/selinux.rb
+++ b/lib/chef/util/selinux.rb
@@ -71,7 +71,7 @@ class Chef
def check_selinux_enabled?
if selinuxenabled_path
- cmd = shell_out!(selinuxenabled_path, :returns => [0,1])
+ cmd = shell_out!(selinuxenabled_path, :returns => [0, 1])
case cmd.exitstatus
when 1
return false
diff --git a/lib/chef/util/windows/net_group.rb b/lib/chef/util/windows/net_group.rb
index cfb06ed1f1..6dd6e39f2b 100644
--- a/lib/chef/util/windows/net_group.rb
+++ b/lib/chef/util/windows/net_group.rb
@@ -72,7 +72,6 @@ class Chef::Util::Windows::NetGroup
rescue Chef::Exceptions::Win32APIError => e
raise ArgumentError, e
end
-
end
def local_delete
diff --git a/lib/chef/util/windows/net_use.rb b/lib/chef/util/windows/net_use.rb
index 89b17a9687..b9c3ecc783 100644
--- a/lib/chef/util/windows/net_use.rb
+++ b/lib/chef/util/windows/net_use.rb
@@ -29,7 +29,7 @@ class Chef::Util::Windows::NetUse < Chef::Util::Windows
end
def to_ui2_struct(use_info)
- use_info.inject({}) do |memo, (k,v)|
+ use_info.inject({}) do |memo, (k, v)|
memo["ui2_#{k}".to_sym] = v
memo
end
@@ -52,7 +52,7 @@ class Chef::Util::Windows::NetUse < Chef::Util::Windows
end
def from_use_info_struct(ui2_hash)
- ui2_hash.inject({}) do |memo, (k,v)|
+ ui2_hash.inject({}) do |memo, (k, v)|
memo[k.to_s.sub("ui2_", "").to_sym] = v
memo
end
diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb
index 3c28ce6e22..f2edeacf17 100644
--- a/lib/chef/util/windows/net_user.rb
+++ b/lib/chef/util/windows/net_user.rb
@@ -26,6 +26,7 @@ require "chef/win32/security"
class Chef::Util::Windows::NetUser < Chef::Util::Windows
private
+
NetUser = Chef::ReservedNames::Win32::NetUser
Security = Chef::ReservedNames::Win32::Security
@@ -62,7 +63,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
}
def transform_usri3(args)
- args.inject({}) do |memo, (k,v)|
+ args.inject({}) do |memo, (k, v)|
memo[USER_INFO_3_TRANSFORM[k]] = v
memo
end
@@ -70,7 +71,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def usri3_to_hash(usri3)
t = USER_INFO_3_TRANSFORM.invert
- usri3.inject({}) do |memo, (k,v)|
+ usri3.inject({}) do |memo, (k, v)|
memo[t[k]] = v
memo
end
@@ -128,7 +129,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def update(args)
user_modify do |user|
- args.each do |key,val|
+ args.each do |key, val|
user[key] = val
end
end
diff --git a/lib/chef/version/platform.rb b/lib/chef/version/platform.rb
index 426d3d9834..07b1a17b11 100644
--- a/lib/chef/version/platform.rb
+++ b/lib/chef/version/platform.rb
@@ -22,7 +22,7 @@ class Chef
protected
- def parse(str="")
+ def parse(str = "")
@major, @minor, @patch =
case str.to_s
when /^(\d+)\.(\d+)\.(\d+)$/
@@ -31,7 +31,7 @@ class Chef
[ $1.to_i, $2.to_i, 0 ]
when /^(\d+)$/
[ $1.to_i, 0, 0 ]
- when /^(\d+).(\d+)-[a-z]+\d?(-p(\d+))?$/i # Match FreeBSD
+ when /^(\d+).(\d+)-[a-z]+\d?(-p(\d+))?$/i # Match FreeBSD
[ $1.to_i, $2.to_i, ($4 ? $4.to_i : 0)]
else
msg = "'#{str}' does not match 'x.y.z', 'x.y' or 'x'"
diff --git a/lib/chef/version_class.rb b/lib/chef/version_class.rb
index b27a9cc421..35a9f3282f 100644
--- a/lib/chef/version_class.rb
+++ b/lib/chef/version_class.rb
@@ -20,7 +20,7 @@ class Chef
include Comparable
attr_reader :major, :minor, :patch
- def initialize(str="")
+ def initialize(str = "")
parse(str)
end
@@ -53,7 +53,7 @@ class Chef
protected
- def parse(str="")
+ def parse(str = "")
@major, @minor, @patch =
case str.to_s
when /^(\d+)\.(\d+)\.(\d+)$/
diff --git a/lib/chef/version_constraint.rb b/lib/chef/version_constraint.rb
index 25f5bd1a47..d4fa5df775 100644
--- a/lib/chef/version_constraint.rb
+++ b/lib/chef/version_constraint.rb
@@ -26,7 +26,7 @@ class Chef
attr_reader :op, :version
- def initialize(constraint_spec=DEFAULT_CONSTRAINT)
+ def initialize(constraint_spec = DEFAULT_CONSTRAINT)
case constraint_spec
when nil
parse(DEFAULT_CONSTRAINT)
@@ -46,7 +46,7 @@ class Chef
else
self.class::VERSION_CLASS.new(v.to_s)
end
- do_op(version)
+ do_op(version)
end
def inspect
@@ -78,7 +78,7 @@ class Chef
other_version.minor == @version.minor &&
other_version.patch >= @version.patch)
end
- else # should never happen
+ else # should never happen
raise "bad op #{@op}"
end
end
diff --git a/lib/chef/whitelist.rb b/lib/chef/whitelist.rb
index ca4be38d7f..58d0bd70c6 100644
--- a/lib/chef/whitelist.rb
+++ b/lib/chef/whitelist.rb
@@ -27,7 +27,7 @@ class Chef
# },
# ["network/interfaces/eth0", ["filesystem", "/dev/disk"]])
# will capture the eth0 and /dev/disk subtrees.
- def self.filter(data, whitelist=nil)
+ def self.filter(data, whitelist = nil)
return data if whitelist.nil?
new_data = {}
diff --git a/lib/chef/win32/api.rb b/lib/chef/win32/api.rb
index e7cd3b5bd0..ad65b087cc 100644
--- a/lib/chef/win32/api.rb
+++ b/lib/chef/win32/api.rb
@@ -239,7 +239,7 @@ class Chef
# In WinNT.h: host.typedef wchar_t WCHAR;
#WINAPI: K, # Calling convention for system functions. WinDef.h: define WINAPI __stdcall
host.typedef :ushort, :WORD # 16-bit unsigned integer. The range is 0 through 65535 decimal.
- host.typedef :uint, :WPARAM # Message parameter. WinDef.h as follows: host.typedef UINT_PTR WPARAM;
+ host.typedef :uint, :WPARAM # Message parameter. WinDef.h as follows: host.typedef UINT_PTR WPARAM;
end
module Macros
diff --git a/lib/chef/win32/api/crypto.rb b/lib/chef/win32/api/crypto.rb
index a2c44dcb42..0abb908622 100644
--- a/lib/chef/win32/api/crypto.rb
+++ b/lib/chef/win32/api/crypto.rb
@@ -35,9 +35,9 @@ class Chef
CRYPTPROTECT_AUDIT = 0x10
class CRYPT_INTEGER_BLOB < FFI::Struct
- layout :cbData, :DWORD, # Count, in bytes, of data
+ layout :cbData, :DWORD, # Count, in bytes, of data
:pbData, :pointer # Pointer to data buffer
- def initialize(str=nil)
+ def initialize(str = nil)
super(nil)
if str
self[:pbData] = FFI::MemoryPointer.from_string(str)
@@ -48,7 +48,7 @@ class Chef
end
safe_attach_function :CryptProtectData, [
- :PDATA_BLOB,
+ :PDATA_BLOB,
:LPCWSTR,
:PDATA_BLOB,
:pointer,
diff --git a/lib/chef/win32/api/error.rb b/lib/chef/win32/api/error.rb
index 0b10fc6e3d..aa80f89743 100644
--- a/lib/chef/win32/api/error.rb
+++ b/lib/chef/win32/api/error.rb
@@ -178,7 +178,7 @@ class Chef
ERROR_LOCK_FAILED = 167
ERROR_BUSY = 170
ERROR_CANCEL_VIOLATION = 173
- ERROR_ATOMIC_LOCKS_NOT_SUPPORTED= 174
+ ERROR_ATOMIC_LOCKS_NOT_SUPPORTED = 174
ERROR_INVALID_SEGMENT_NUMBER = 180
ERROR_INVALID_CALLGATE = 181
@@ -446,7 +446,7 @@ class Chef
ERROR_DOWNGRADE_DETECTED = 1265
ERROR_MACHINE_LOCKED = 1271
ERROR_CALLBACK_SUPPLIED_INVALID_DATA = 1273
- ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED= 1274
+ ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED = 1274
ERROR_DRIVER_BLOCKED = 1275
ERROR_INVALID_IMPORT_OF_NON_DLL = 1276
ERROR_NOT_ALL_ASSIGNED = 1300
@@ -750,7 +750,7 @@ class Chef
ERROR_NETLOGON_NOT_STARTED = 1792
ERROR_ACCOUNT_EXPIRED = 1793
ERROR_REDIRECTOR_HAS_OPEN_HANDLES = 1794
- ERROR_PRINTER_DRIVER_ALREADY_INSTALLED= 1795
+ ERROR_PRINTER_DRIVER_ALREADY_INSTALLED = 1795
ERROR_UNKNOWN_PORT = 1796
ERROR_UNKNOWN_PRINTER_DRIVER = 1797
ERROR_UNKNOWN_PRINTPROCESSOR = 1798
@@ -824,9 +824,9 @@ class Chef
ERROR_CONTEXT_EXPIRED = 1931
ERROR_PER_USER_TRUST_QUOTA_EXCEEDED = 1932
ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED = 1933
- ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED= 1934
- ERROR_AUTHENTICATION_FIREWALL_FAILED = 1935
- ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED= 1936
+ ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED = 1934
+ ERROR_AUTHENTICATION_FIREWALL_FAILED = 1935
+ ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED = 1936
ERROR_INVALID_PIXEL_FORMAT = 2000
ERROR_BAD_DRIVER = 2001
ERROR_INVALID_WINDOW_STYLE = 2002
diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb
index 992c595e9a..52ac4868c7 100644
--- a/lib/chef/win32/api/file.rb
+++ b/lib/chef/win32/api/file.rb
@@ -163,7 +163,7 @@ class Chef
(device_type << 16) | (access << 14) | (function << 2) | method
end
- FSCTL_GET_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
+ FSCTL_GET_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
# Reparse point tags
IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
@@ -176,7 +176,7 @@ class Chef
IO_REPARSE_TAG_SYMLINK = 0xA000000C
IO_REPARSE_TAG_DFSR = 0x80000012
- MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16*1024
+ MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
###############################################
# Win32 API Bindings
@@ -238,7 +238,7 @@ typedef struct _WIN32_FIND_DATA {
:n_file_size_low, :DWORD,
:dw_reserved_0, :DWORD,
:dw_reserved_1, :DWORD,
- :c_file_name, [:BYTE, MAX_PATH*2],
+ :c_file_name, [:BYTE, MAX_PATH * 2],
:c_alternate_file_name, [:BYTE, 14]
end
@@ -307,11 +307,12 @@ typedef struct _REPARSE_DATA_BUFFER {
def substitute_name
string_pointer = FFI::Pointer.new(pointer.address) + offset_of(:PathBuffer) + self[:SubstituteNameOffset]
- string_pointer.read_wstring(self[:SubstituteNameLength]/2)
+ string_pointer.read_wstring(self[:SubstituteNameLength] / 2)
end
+
def print_name
string_pointer = FFI::Pointer.new(pointer.address) + offset_of(:PathBuffer) + self[:PrintNameOffset]
- string_pointer.read_wstring(self[:PrintNameLength]/2)
+ string_pointer.read_wstring(self[:PrintNameLength] / 2)
end
end
class REPARSE_DATA_BUFFER_MOUNT_POINT < FFI::Struct
@@ -323,11 +324,12 @@ typedef struct _REPARSE_DATA_BUFFER {
def substitute_name
string_pointer = FFI::Pointer.new(pointer.address) + offset_of(:PathBuffer) + self[:SubstituteNameOffset]
- string_pointer.read_wstring(self[:SubstituteNameLength]/2)
+ string_pointer.read_wstring(self[:SubstituteNameLength] / 2)
end
+
def print_name
string_pointer = FFI::Pointer.new(pointer.address) + offset_of(:PathBuffer) + self[:PrintNameOffset]
- string_pointer.read_wstring(self[:PrintNameLength]/2)
+ string_pointer.read_wstring(self[:PrintNameLength] / 2)
end
end
class REPARSE_DATA_BUFFER_GENERIC < FFI::Struct
@@ -458,7 +460,6 @@ BOOL WINAPI DeviceIoControl(
=end
safe_attach_function :DeviceIoControl, [:HANDLE, :DWORD, :LPVOID, :DWORD, :LPVOID, :DWORD, :LPDWORD, :pointer], :BOOL
-
#BOOL WINAPI DeleteVolumeMountPoint(
#_In_ LPCTSTR lpszVolumeMountPoint
#);
@@ -606,7 +607,7 @@ BOOL WINAPI VerQueryValue(
if file_size == 0
Chef::ReservedNames::Win32::Error.raise!
end
-
+
version_info = FFI::MemoryPointer.new(file_size)
unless GetFileVersionInfoW(file_name, 0, file_size, version_info)
Chef::ReservedNames::Win32::Error.raise!
diff --git a/lib/chef/win32/api/installer.rb b/lib/chef/win32/api/installer.rb
index e1be747245..caf7b23f59 100644
--- a/lib/chef/win32/api/installer.rb
+++ b/lib/chef/win32/api/installer.rb
@@ -32,7 +32,6 @@ class Chef
# Win32 API Constants
###############################################
-
###############################################
# Win32 API Bindings
###############################################
@@ -94,7 +93,7 @@ UINT MsiCloseHandle(
msg << Chef::ReservedNames::Win32::Error.format_message(status)
raise Chef::Exceptions::Package, msg
end
-
+
buffer_length = FFI::Buffer.new(:long).write_long(buffer_length.read_long + 1)
buffer = 0.chr * buffer_length.read_long
@@ -114,18 +113,18 @@ UINT MsiCloseHandle(
# Opens a Microsoft Installer (MSI) file from an absolute path and returns a pointer to a handle
# Remember to close the handle with msi_close_handle()
def open_package(package_path)
- # MsiOpenPackage expects a perfect absolute Windows path to the MSI
+ # MsiOpenPackage expects a perfect absolute Windows path to the MSI
raise ArgumentError, "Provided path '#{package_path}' must be an absolute path" unless Pathname.new(package_path).absolute?
pkg_ptr = FFI::MemoryPointer.new(:pointer, 4)
status = msi_open_package(package_path, 1, pkg_ptr)
case status
- when 0
+ when 0
# success
else
raise Chef::Exceptions::Package, "msi_open_package: unexpected status #{status}: #{Chef::ReservedNames::Win32::Error.format_message(status)}"
end
- return pkg_ptr
+ return pkg_ptr
end
# All installed product_codes should have a VersionString
@@ -133,11 +132,11 @@ UINT MsiCloseHandle(
def get_installed_version(product_code)
version = 0.chr
version_length = FFI::Buffer.new(:long).write_long(0)
-
+
status = msi_get_product_info(product_code, "VersionString", version, version_length)
-
+
return nil if status == 1605 # ERROR_UNKNOWN_PRODUCT (0x645)
-
+
# We expect error ERROR_MORE_DATA (234) here because we passed a buffer length of 0
if status != 234
msg = "msi_get_product_info: product code '#{product_code}' returned unknown error #{status} when retrieving VersionString: "
@@ -149,9 +148,9 @@ UINT MsiCloseHandle(
version_length = FFI::Buffer.new(:long).write_long(version_length.read_long + 1)
version = 0.chr * version_length.read_long
-
+
status = msi_get_product_info(product_code, "VersionString", version, version_length)
-
+
if status != 0
msg = "msi_get_product_info: product code '#{product_code}' returned unknown error #{status} when retrieving VersionString: "
msg << Chef::ReservedNames::Win32::Error.format_message(status)
diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb
index fdbe55579f..bec00f638a 100644
--- a/lib/chef/win32/api/net.rb
+++ b/lib/chef/win32/api/net.rb
@@ -90,7 +90,6 @@ class Chef
end
end
-
class USER_INFO_3 < FFI::Struct
include StructHelpers
layout :usri3_name, :LPWSTR,
@@ -159,7 +158,6 @@ class Chef
:ui2_domainname, :LMSTR
end
-
#NET_API_STATUS NetLocalGroupAdd(
#_In_ LPCWSTR servername,
#_In_ DWORD level,
diff --git a/lib/chef/win32/api/registry.rb b/lib/chef/win32/api/registry.rb
index 8f394ad12a..dec25118a3 100644
--- a/lib/chef/win32/api/registry.rb
+++ b/lib/chef/win32/api/registry.rb
@@ -48,4 +48,4 @@ class Chef
end
end
end
-end \ No newline at end of file
+end
diff --git a/lib/chef/win32/api/security.rb b/lib/chef/win32/api/security.rb
index 61c65971be..44968372b5 100644
--- a/lib/chef/win32/api/security.rb
+++ b/lib/chef/win32/api/security.rb
@@ -136,20 +136,10 @@ class Chef
SYNCHRONIZE |
0x1FF
FILE_GENERIC_READ = STANDARD_RIGHTS_READ |
- FILE_READ_DATA |
- FILE_READ_ATTRIBUTES |
- FILE_READ_EA |
- SYNCHRONIZE
- FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE |
- FILE_WRITE_DATA |
- FILE_WRITE_ATTRIBUTES |
- FILE_WRITE_EA |
- FILE_APPEND_DATA |
- SYNCHRONIZE
- FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE |
- FILE_READ_ATTRIBUTES |
- FILE_EXECUTE |
- SYNCHRONIZE
+ FILE_READ_DATA | FILE_READ_ATTRIBUTES |
+ FILE_READ_EA | SYNCHRONIZE
+ FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE
+ FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE
# Access Token Rights (for OpenProcessToken)
# Access Rights for Access-Token Objects (used in OpenProcessToken)
TOKEN_ASSIGN_PRIMARY = 0x0001
@@ -173,9 +163,7 @@ class Chef
SE_PRIVILEGE_REMOVED = 0X00000004
SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000
SE_PRIVILEGE_VALID_ATTRIBUTES = SE_PRIVILEGE_ENABLED_BY_DEFAULT |
- SE_PRIVILEGE_ENABLED |
- SE_PRIVILEGE_REMOVED |
- SE_PRIVILEGE_USED_FOR_ACCESS
+ SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_REMOVED | SE_PRIVILEGE_USED_FOR_ACCESS
# Minimum size of a SECURITY_DESCRIPTOR. TODO: this is probably platform dependent.
# Make it work on 64 bit.
@@ -315,7 +303,6 @@ class Chef
:SecurityDelegation,
]
-
# SECURITY_DESCRIPTOR is an opaque structure whose contents can vary. Pass the
# pointer around and free it with LocalFree.
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa379561(v=vs.85).aspx
@@ -384,7 +371,7 @@ class Chef
:Privileges, LUID_AND_ATTRIBUTES
def self.size_with_privileges(num_privileges)
- offset_of(:Privileges) + LUID_AND_ATTRIBUTES.size*num_privileges
+ offset_of(:Privileges) + LUID_AND_ATTRIBUTES.size * num_privileges
end
def size_with_privileges
@@ -431,7 +418,7 @@ class Chef
safe_attach_function :GetAce, [ :pointer, :DWORD, :pointer ], :BOOL
safe_attach_function :GetFileSecurityW, [:LPCWSTR, :DWORD, :pointer, :DWORD, :pointer], :BOOL
safe_attach_function :GetLengthSid, [ :pointer ], :DWORD
- safe_attach_function :GetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer ], :DWORD
+ safe_attach_function :GetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer ], :DWORD
safe_attach_function :GetSecurityDescriptorControl, [ :pointer, :PWORD, :LPDWORD], :BOOL
safe_attach_function :GetSecurityDescriptorDacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL
safe_attach_function :GetSecurityDescriptorGroup, [ :pointer, :pointer, :LPBOOL], :BOOL
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb
index a0aa34d481..19b17b7d7c 100644
--- a/lib/chef/win32/file.rb
+++ b/lib/chef/win32/file.rb
@@ -125,8 +125,8 @@ class Chef
if size == 0
Chef::ReservedNames::Win32::Error.raise!
end
- result = FFI::MemoryPointer.new :char, (size+1)*2
- if GetShortPathNameW(path, result, size+1) == 0
+ result = FFI::MemoryPointer.new :char, (size + 1) * 2
+ if GetShortPathNameW(path, result, size + 1) == 0
Chef::ReservedNames::Win32::Error.raise!
end
result.read_wstring(size)
@@ -139,8 +139,8 @@ class Chef
if size == 0
Chef::ReservedNames::Win32::Error.raise!
end
- result = FFI::MemoryPointer.new :char, (size+1)*2
- if GetLongPathNameW(path, result, size+1) == 0
+ result = FFI::MemoryPointer.new :char, (size + 1) * 2
+ if GetLongPathNameW(path, result, size + 1) == 0
Chef::ReservedNames::Win32::Error.raise!
end
result.read_wstring(size)
@@ -199,7 +199,7 @@ class Chef
def self.get_volume_name_for_volume_mount_point(mount_point)
buffer = FFI::MemoryPointer.new(2, 128)
- unless GetVolumeNameForVolumeMountPointW(wstring(mount_point), buffer, buffer.size/buffer.type_size)
+ unless GetVolumeNameForVolumeMountPointW(wstring(mount_point), buffer, buffer.size / buffer.type_size)
Chef::ReservedNames::Win32::Error.raise!
end
buffer.read_wstring
diff --git a/lib/chef/win32/file/info.rb b/lib/chef/win32/file/info.rb
index 010bf80079..55873f8a0b 100644
--- a/lib/chef/win32/file/info.rb
+++ b/lib/chef/win32/file/info.rb
@@ -93,7 +93,6 @@ class Chef
file_time_struct[:dw_high_date_time]))
end
-
end
end
end
diff --git a/lib/chef/win32/file/version_info.rb b/lib/chef/win32/file/version_info.rb
index 37cfd944e6..fa04096cf1 100644
--- a/lib/chef/win32/file/version_info.rb
+++ b/lib/chef/win32/file/version_info.rb
@@ -75,7 +75,7 @@ class Chef
end
def to_hex(integer)
- integer.to_s(16).rjust(4,"0")
+ integer.to_s(16).rjust(4, "0")
end
def get_version_info_string(string_key)
diff --git a/lib/chef/win32/net.rb b/lib/chef/win32/net.rb
index 4ee278aa28..0454b17d49 100644
--- a/lib/chef/win32/net.rb
+++ b/lib/chef/win32/net.rb
@@ -40,7 +40,7 @@ class Chef
usri3_priv: 0,
usri3_home_dir: nil,
usri3_comment: nil,
- usri3_flags: UF_SCRIPT|UF_DONT_EXPIRE_PASSWD|UF_NORMAL_ACCOUNT,
+ usri3_flags: UF_SCRIPT | UF_DONT_EXPIRE_PASSWD | UF_NORMAL_ACCOUNT,
usri3_script_path: nil,
usri3_auth_flags: 0,
usri3_full_name: nil,
@@ -63,7 +63,7 @@ class Chef
usri3_profile: nil,
usri3_home_dir_drive: nil,
usri3_password_expired: 0,
- }.each do |(k,v)|
+ }.each do |(k, v)|
s.set(k, v)
end
end
@@ -254,7 +254,7 @@ class Chef
end
end
- def self.net_use_del(server_name, use_name, force=:use_noforce)
+ def self.net_use_del(server_name, use_name, force = :use_noforce)
server_name = wstring(server_name)
use_name = wstring(use_name)
force_const = case force
@@ -296,8 +296,8 @@ class Chef
buf = USE_INFO_2.new
- ui2_hash.each do |(k,v)|
- buf.set(k,v)
+ ui2_hash.each do |(k, v)|
+ buf.set(k, v)
end
rc = NetUseAdd(server_name, 2, buf, nil)
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index 4113e5eb2b..5f8d23b452 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -42,7 +42,7 @@ class Chef
attr_accessor :run_context
attr_accessor :architecture
- def initialize(run_context=nil, user_architecture=:machine)
+ def initialize(run_context = nil, user_architecture = :machine)
@run_context = run_context
self.architecture = user_architecture
end
@@ -56,7 +56,7 @@ class Chef
hive, key = get_hive_and_key(key_path)
key_exists!(key_path)
values = hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- reg.map { |name, type, data| {:name=>name, :type=>get_name_from_type(type), :data=>data} }
+ reg.map { |name, type, data| { :name => name, :type => get_name_from_type(type), :data => data } }
end
end
@@ -175,7 +175,7 @@ class Chef
key_exists!(key_path)
hive, key = get_hive_and_key(key_path)
hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- reg.each_key{ |key| return true }
+ reg.each_key { |key| return true }
end
return false
end
@@ -185,7 +185,7 @@ class Chef
key_exists!(key_path)
hive, key = get_hive_and_key(key_path)
hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- reg.each_key{ |current_key| subkeys << current_key }
+ reg.each_key { |current_key| subkeys << current_key }
end
return subkeys
end
@@ -200,7 +200,7 @@ class Chef
key_exists!(key_path)
hive, key = get_hive_and_key(key_path)
hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- return true if reg.any? {|val| safely_downcase(val) == safely_downcase(value[:name]) }
+ return true if reg.any? { |val| safely_downcase(val) == safely_downcase(value[:name]) }
end
return false
end
@@ -211,8 +211,8 @@ class Chef
hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
reg.each do |val_name, val_type, val_data|
if safely_downcase(val_name) == safely_downcase(value[:name]) &&
- val_type == get_type_from_name(value[:type]) &&
- val_data == value[:data]
+ val_type == get_type_from_name(value[:type]) &&
+ val_data == value[:data]
return true
end
end
@@ -273,7 +273,6 @@ class Chef
private
-
def safely_downcase(val)
if val.is_a? String
return val.downcase
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb
index 13b4604469..7fc3215786 100644
--- a/lib/chef/win32/security.rb
+++ b/lib/chef/win32/security.rb
@@ -235,7 +235,6 @@ class Chef
SecurityDescriptor.new(security_descriptor_ptr)
end
-
def self.get_named_security_info(path, type = :SE_FILE_OBJECT, info = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION)
security_descriptor = FFI::MemoryPointer.new :pointer
hr = GetNamedSecurityInfoW(path.to_wstring, type, info, nil, nil, nil, nil, security_descriptor)
@@ -385,7 +384,7 @@ class Chef
end
sid = FFI::MemoryPointer.new :char, sid_size.read_long
- referenced_domain_name = FFI::MemoryPointer.new :char, (referenced_domain_name_size.read_long*2)
+ referenced_domain_name = FFI::MemoryPointer.new :char, (referenced_domain_name_size.read_long * 2)
use = FFI::Buffer.new(:long).write_long(0)
unless LookupAccountNameW(system_name, name.to_wstring, sid, sid_size, referenced_domain_name, referenced_domain_name_size, use)
Chef::ReservedNames::Win32::Error.raise!
@@ -406,8 +405,8 @@ class Chef
Chef::ReservedNames::Win32::Error.raise!
end
- name = FFI::MemoryPointer.new :char, (name_size.read_long*2)
- referenced_domain_name = FFI::MemoryPointer.new :char, (referenced_domain_name_size.read_long*2)
+ name = FFI::MemoryPointer.new :char, (name_size.read_long * 2)
+ referenced_domain_name = FFI::MemoryPointer.new :char, (referenced_domain_name_size.read_long * 2)
use = FFI::Buffer.new(:long).write_long(0)
unless LookupAccountSidW(system_name, sid, name, name_size, referenced_domain_name, referenced_domain_name_size, use)
Chef::ReservedNames::Win32::Error.raise!
@@ -425,7 +424,7 @@ class Chef
Chef::ReservedNames::Win32::Error.raise!
end
- name = FFI::MemoryPointer.new :char, (name_size.read_long*2)
+ name = FFI::MemoryPointer.new :char, (name_size.read_long * 2)
unless LookupPrivilegeNameW(system_name, luid, name, name_size)
Chef::ReservedNames::Win32::Error.raise!
end
@@ -443,7 +442,7 @@ class Chef
Chef::ReservedNames::Win32::Error.raise!
end
- display_name = FFI::MemoryPointer.new :char, (display_name_size.read_long*2)
+ display_name = FFI::MemoryPointer.new :char, (display_name_size.read_long * 2)
unless LookupPrivilegeDisplayNameW(system_name, name.to_wstring, display_name, display_name_size, language_id)
Chef::ReservedNames::Win32::Error.raise!
end
diff --git a/lib/chef/win32/security/acl.rb b/lib/chef/win32/security/acl.rb
index 86c6e05bd2..8a04987e44 100644
--- a/lib/chef/win32/security/acl.rb
+++ b/lib/chef/win32/security/acl.rb
@@ -34,7 +34,7 @@ class Chef
end
def self.create(aces)
- aces_size = aces.inject(0) { |sum,ace| sum + ace.size }
+ aces_size = aces.inject(0) { |sum, ace| sum + ace.size }
acl_size = align_dword(Chef::ReservedNames::Win32::API::Security::ACLStruct.size + aces_size) # What the heck is 94???
acl = Chef::ReservedNames::Win32::Security.initialize_acl(acl_size)
aces.each { |ace| Chef::ReservedNames::Win32::Security.add_ace(acl, ace) }
@@ -45,7 +45,7 @@ class Chef
def ==(other)
return false if length != other.length
- 0.upto(length-1) do |i|
+ 0.upto(length - 1) do |i|
return false if self[i] != other[i]
end
return true
@@ -64,7 +64,7 @@ class Chef
end
def each
- 0.upto(length-1) { |i| yield self[i] }
+ 0.upto(length - 1) { |i| yield self[i] }
end
def insert(index, *aces)
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index 0219aa6eb1..4d2d252dd3 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -80,111 +80,147 @@ class Chef
def self.Null
SID.from_string_sid("S-1-0")
end
+
def self.Nobody
SID.from_string_sid("S-1-0-0")
end
+
def self.World
SID.from_string_sid("S-1-1")
end
+
def self.Everyone
SID.from_string_sid("S-1-1-0")
end
+
def self.Local
SID.from_string_sid("S-1-2")
end
+
def self.Creator
SID.from_string_sid("S-1-3")
end
+
def self.CreatorOwner
SID.from_string_sid("S-1-3-0")
end
+
def self.CreatorGroup
SID.from_string_sid("S-1-3-1")
end
+
def self.CreatorOwnerServer
SID.from_string_sid("S-1-3-2")
end
+
def self.CreatorGroupServer
SID.from_string_sid("S-1-3-3")
end
+
def self.NonUnique
SID.from_string_sid("S-1-4")
end
+
def self.Nt
SID.from_string_sid("S-1-5")
end
+
def self.Dialup
SID.from_string_sid("S-1-5-1")
end
+
def self.Network
SID.from_string_sid("S-1-5-2")
end
+
def self.Batch
SID.from_string_sid("S-1-5-3")
end
+
def self.Interactive
SID.from_string_sid("S-1-5-4")
end
+
def self.Service
SID.from_string_sid("S-1-5-6")
end
+
def self.Anonymous
SID.from_string_sid("S-1-5-7")
end
+
def self.Proxy
SID.from_string_sid("S-1-5-8")
end
+
def self.EnterpriseDomainControllers
SID.from_string_sid("S-1-5-9")
end
+
def self.PrincipalSelf
SID.from_string_sid("S-1-5-10")
end
+
def self.AuthenticatedUsers
SID.from_string_sid("S-1-5-11")
end
+
def self.RestrictedCode
SID.from_string_sid("S-1-5-12")
end
+
def self.TerminalServerUsers
SID.from_string_sid("S-1-5-13")
end
+
def self.LocalSystem
SID.from_string_sid("S-1-5-18")
end
+
def self.NtLocal
SID.from_string_sid("S-1-5-19")
end
+
def self.NtNetwork
SID.from_string_sid("S-1-5-20")
end
+
def self.BuiltinAdministrators
SID.from_string_sid("S-1-5-32-544")
end
+
def self.BuiltinUsers
SID.from_string_sid("S-1-5-32-545")
end
+
def self.Guests
SID.from_string_sid("S-1-5-32-546")
end
+
def self.PowerUsers
SID.from_string_sid("S-1-5-32-547")
end
+
def self.AccountOperators
SID.from_string_sid("S-1-5-32-548")
end
+
def self.ServerOperators
SID.from_string_sid("S-1-5-32-549")
end
+
def self.PrintOperators
SID.from_string_sid("S-1-5-32-550")
end
+
def self.BackupOperators
SID.from_string_sid("S-1-5-32-551")
end
+
def self.Replicators
SID.from_string_sid("S-1-5-32-552")
end
+
def self.Administrators
SID.from_string_sid("S-1-5-32-544")
end
@@ -192,9 +228,11 @@ class Chef
def self.None
SID.from_account("#{::ENV['COMPUTERNAME']}\\None")
end
+
def self.Administrator
SID.from_account("#{::ENV['COMPUTERNAME']}\\#{SID.admin_account_name}")
end
+
def self.Guest
SID.from_account("#{::ENV['COMPUTERNAME']}\\Guest")
end
diff --git a/lib/chef/win32/unicode.rb b/lib/chef/win32/unicode.rb
index a7509115c0..b0fcf6492d 100644
--- a/lib/chef/win32/unicode.rb
+++ b/lib/chef/win32/unicode.rb
@@ -40,13 +40,13 @@ module FFI
last_char = nil
while last_char != "\000\000" do
length += 1
- last_char = self.get_bytes(0,length * 2)[-2..-1]
+ last_char = self.get_bytes(0, length * 2)[-2..-1]
end
num_wchars = length
end
- wide_to_utf8(self.get_bytes(0, num_wchars*2))
+ wide_to_utf8(self.get_bytes(0, num_wchars * 2))
end
end
end
diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb
index abd9916b3a..a18211b8c6 100644
--- a/lib/chef/win32/version.rb
+++ b/lib/chef/win32/version.rb
@@ -48,21 +48,21 @@ class Chef
private_class_method :method_name_from_marketing_name
WIN_VERSIONS = {
- "Windows 10" => {:major => 10, :minor => 0, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2016" => {:major => 10, :minor => 0, :callable => lambda {|product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows 8.1" => {:major => 6, :minor => 3, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2012 R2" => {:major => 6, :minor => 3, :callable => lambda {|product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows 8" => {:major => 6, :minor => 2, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2012" => {:major => 6, :minor => 2, :callable => lambda{ |product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows 7" => {:major => 6, :minor => 1, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2008 R2" => {:major => 6, :minor => 1, :callable => lambda{ |product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows Server 2008" => {:major => 6, :minor => 0, :callable => lambda{ |product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows Vista" => {:major => 6, :minor => 0, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2003 R2" => {:major => 5, :minor => 2, :callable => lambda{ |product_type, suite_mask| get_system_metrics(SM_SERVERR2) != 0 }},
- "Windows Home Server" => {:major => 5, :minor => 2, :callable => lambda{ |product_type, suite_mask| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER }},
- "Windows Server 2003" => {:major => 5, :minor => 2, :callable => lambda{ |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 }},
- "Windows XP" => {:major => 5, :minor => 1},
- "Windows 2000" => {:major => 5, :minor => 0},
+ "Windows 10" => { :major => 10, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2016" => { :major => 10, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 8.1" => { :major => 6, :minor => 3, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2012 R2" => { :major => 6, :minor => 3, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 8" => { :major => 6, :minor => 2, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2012" => { :major => 6, :minor => 2, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 7" => { :major => 6, :minor => 1, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2008 R2" => { :major => 6, :minor => 1, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows Server 2008" => { :major => 6, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows Vista" => { :major => 6, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2003 R2" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) != 0 } },
+ "Windows Home Server" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } },
+ "Windows Server 2003" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 } },
+ "Windows XP" => { :major => 5, :minor => 1 },
+ "Windows 2000" => { :major => 5, :minor => 0 },
}
def initialize
@@ -88,12 +88,12 @@ class Chef
marketing_names = Array.new
# General Windows checks
- WIN_VERSIONS.each do |k,v|
+ WIN_VERSIONS.each do |k, v|
method_name = method_name_from_marketing_name(k)
define_method(method_name) do
(@major_version == v[:major]) &&
- (@minor_version == v[:minor]) &&
- (v[:callable] ? v[:callable].call(@product_type, @suite_mask) : true)
+ (@minor_version == v[:minor]) &&
+ (v[:callable] ? v[:callable].call(@product_type, @suite_mask) : true)
end
marketing_names << [k, method_name]
end
@@ -129,7 +129,7 @@ class Chef
# The operating system version is a string in the following form
# that can be split into components based on the '.' delimiter:
# MajorVersionNumber.MinorVersionNumber.BuildNumber
- os_version.split(".").collect { | version_string | version_string.to_i }
+ os_version.split(".").collect { |version_string| version_string.to_i }
end
def get_version_ex