summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autotest/rspec.rb2
-rw-r--r--autotest/watcher.rb130
-rw-r--r--ext/extlookup.rb26
-rwxr-xr-xext/nagios/check_puppet.rb49
-rwxr-xr-xext/puppetlisten/puppetrun.rb2
-rw-r--r--ext/puppetstoredconfigclean.rb5
-rw-r--r--ext/regexp_nodes/regexp_nodes.rb10
-rwxr-xr-xinstall.rb495
-rw-r--r--lib/puppet.rb3
-rw-r--r--lib/puppet/application.rb8
-rw-r--r--lib/puppet/application/agent.rb11
-rw-r--r--lib/puppet/application/describe.rb3
-rw-r--r--lib/puppet/application/doc.rb7
-rw-r--r--lib/puppet/application/kick.rb5
-rw-r--r--lib/puppet/application/master.rb2
-rw-r--r--lib/puppet/configurer.rb3
-rw-r--r--lib/puppet/defaults.rb189
-rw-r--r--lib/puppet/error.rb8
-rwxr-xr-xlib/puppet/external/base64.rb2
-rw-r--r--lib/puppet/external/event-loop/better-definers.rb16
-rw-r--r--lib/puppet/external/event-loop/event-loop.rb4
-rw-r--r--lib/puppet/external/event-loop/signal-system.rb4
-rwxr-xr-xlib/puppet/external/nagios/base.rb34
-rw-r--r--lib/puppet/external/nagios/parser.rb1087
-rw-r--r--lib/puppet/external/pson/common.rb675
-rw-r--r--lib/puppet/external/pson/pure.rb124
-rw-r--r--lib/puppet/external/pson/pure/generator.rb840
-rw-r--r--lib/puppet/external/pson/pure/parser.rb501
-rw-r--r--lib/puppet/external/pson/version.rb12
-rw-r--r--lib/puppet/file_serving/base.rb2
-rw-r--r--lib/puppet/file_serving/configuration/parser.rb19
-rw-r--r--lib/puppet/file_serving/metadata.rb23
-rw-r--r--lib/puppet/file_serving/mount/file.rb5
-rw-r--r--lib/puppet/indirector.rb6
-rw-r--r--lib/puppet/indirector/indirection.rb2
-rw-r--r--lib/puppet/indirector/ldap.rb2
-rw-r--r--lib/puppet/indirector/node/ldap.rb58
-rw-r--r--lib/puppet/indirector/report/processor.rb3
-rw-r--r--lib/puppet/indirector/ssl_file.rb2
-rw-r--r--lib/puppet/indirector/yaml.rb2
-rw-r--r--lib/puppet/metatype/manager.rb22
-rw-r--r--lib/puppet/network/authconfig.rb7
-rw-r--r--lib/puppet/network/authorization.rb12
-rwxr-xr-xlib/puppet/network/authstore.rb4
-rw-r--r--lib/puppet/network/client.rb18
-rw-r--r--lib/puppet/network/formats.rb4
-rw-r--r--lib/puppet/network/handler.rb5
-rw-r--r--lib/puppet/network/handler/ca.rb10
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb62
-rwxr-xr-xlib/puppet/network/handler/report.rb3
-rw-r--r--lib/puppet/network/http/handler.rb4
-rw-r--r--lib/puppet/network/http/mongrel.rb2
-rw-r--r--lib/puppet/network/http/webrick.rb2
-rw-r--r--lib/puppet/network/http_pool.rb2
-rw-r--r--lib/puppet/network/http_server/webrick.rb3
-rw-r--r--lib/puppet/network/rest_authconfig.rb5
-rw-r--r--lib/puppet/network/rest_authorization.rb2
-rw-r--r--lib/puppet/network/server.rb2
-rw-r--r--lib/puppet/network/xmlrpc/client.rb5
-rw-r--r--lib/puppet/network/xmlrpc/webrick_servlet.rb10
-rw-r--r--lib/puppet/node.rb4
-rw-r--r--lib/puppet/node/environment.rb2
-rw-r--r--lib/puppet/parameter.rb16
-rw-r--r--lib/puppet/parser/ast.rb10
-rw-r--r--lib/puppet/parser/ast/branch.rb2
-rw-r--r--lib/puppet/parser/ast/caseopt.rb4
-rw-r--r--lib/puppet/parser/ast/collection.rb10
-rw-r--r--lib/puppet/parser/ast/function.rb6
-rw-r--r--lib/puppet/parser/ast/ifstatement.rb2
-rw-r--r--lib/puppet/parser/ast/resource.rb10
-rw-r--r--lib/puppet/parser/ast/resource_override.rb5
-rw-r--r--lib/puppet/parser/ast/resourceparam.rb5
-rw-r--r--lib/puppet/parser/collector.rb10
-rw-r--r--lib/puppet/parser/compiler.rb7
-rw-r--r--lib/puppet/parser/functions.rb15
-rw-r--r--lib/puppet/parser/functions/file.rb8
-rw-r--r--lib/puppet/parser/functions/fqdn_rand.rb2
-rw-r--r--lib/puppet/parser/functions/inline_template.rb3
-rw-r--r--lib/puppet/parser/functions/regsubst.rb49
-rw-r--r--lib/puppet/parser/functions/require.rb29
-rw-r--r--lib/puppet/parser/functions/sha1.rb3
-rw-r--r--lib/puppet/parser/functions/split.rb26
-rw-r--r--lib/puppet/parser/functions/sprintf.rb7
-rw-r--r--lib/puppet/parser/functions/template.rb7
-rw-r--r--lib/puppet/parser/functions/versioncmp.rb5
-rw-r--r--lib/puppet/parser/grammar.ra420
-rw-r--r--lib/puppet/parser/lexer.rb158
-rw-r--r--lib/puppet/parser/resource.rb21
-rw-r--r--lib/puppet/parser/resource/param.rb2
-rw-r--r--lib/puppet/parser/scope.rb5
-rw-r--r--lib/puppet/parser/type_loader.rb24
-rw-r--r--lib/puppet/property.rb7
-rw-r--r--lib/puppet/property/ensure.rb9
-rw-r--r--lib/puppet/property/keyvalue.rb4
-rw-r--r--lib/puppet/property/list.rb4
-rw-r--r--lib/puppet/provider.rb11
-rw-r--r--lib/puppet/provider/augeas/augeas.rb22
-rwxr-xr-xlib/puppet/provider/cron/crontab.rb5
-rw-r--r--lib/puppet/provider/file/posix.rb4
-rw-r--r--lib/puppet/provider/file/win32.rb2
-rw-r--r--lib/puppet/provider/host/parsed.rb5
-rw-r--r--lib/puppet/provider/macauthorization/macauthorization.rb19
-rwxr-xr-xlib/puppet/provider/mailalias/aliases.rb15
-rw-r--r--lib/puppet/provider/mcx/mcxcontent.rb27
-rwxr-xr-xlib/puppet/provider/mount/parsed.rb8
-rw-r--r--lib/puppet/provider/nameservice.rb22
-rw-r--r--lib/puppet/provider/nameservice/directoryservice.rb84
-rw-r--r--lib/puppet/provider/package/aix.rb2
-rw-r--r--lib/puppet/provider/package/appdmg.rb14
-rwxr-xr-xlib/puppet/provider/package/apple.rb5
-rwxr-xr-xlib/puppet/provider/package/apt.rb2
-rw-r--r--lib/puppet/provider/package/aptrpm.rb12
-rwxr-xr-xlib/puppet/provider/package/dpkg.rb13
-rwxr-xr-xlib/puppet/provider/package/fink.rb2
-rwxr-xr-xlib/puppet/provider/package/freebsd.rb4
-rwxr-xr-xlib/puppet/provider/package/gem.rb6
-rw-r--r--lib/puppet/provider/package/hpux.rb4
-rw-r--r--lib/puppet/provider/package/nim.rb2
-rwxr-xr-xlib/puppet/provider/package/openbsd.rb12
-rw-r--r--lib/puppet/provider/package/pkg.rb14
-rw-r--r--lib/puppet/provider/package/pkgdmg.rb17
-rwxr-xr-xlib/puppet/provider/package/ports.rb6
-rw-r--r--lib/puppet/provider/package/portupgrade.rb474
-rwxr-xr-xlib/puppet/provider/package/rpm.rb12
-rwxr-xr-xlib/puppet/provider/package/sun.rb4
-rw-r--r--lib/puppet/provider/package/up2date.rb2
-rw-r--r--lib/puppet/provider/package/urpmi.rb12
-rwxr-xr-xlib/puppet/provider/package/yum.rb54
-rwxr-xr-xlib/puppet/provider/parsedfile.rb6
-rw-r--r--lib/puppet/provider/selboolean/getsetsebool.rb16
-rw-r--r--lib/puppet/provider/selmodule/semodule.rb18
-rwxr-xr-xlib/puppet/provider/service/base.rb13
-rw-r--r--lib/puppet/provider/service/daemontools.rb8
-rwxr-xr-xlib/puppet/provider/service/debian.rb4
-rw-r--r--lib/puppet/provider/service/freebsd.rb258
-rw-r--r--lib/puppet/provider/service/gentoo.rb6
-rwxr-xr-xlib/puppet/provider/service/init.rb5
-rw-r--r--lib/puppet/provider/service/launchd.rb50
-rwxr-xr-xlib/puppet/provider/service/redhat.rb6
-rw-r--r--lib/puppet/provider/service/runit.rb36
-rwxr-xr-xlib/puppet/provider/service/smf.rb5
-rwxr-xr-xlib/puppet/provider/service/src.rb8
-rw-r--r--lib/puppet/provider/ssh_authorized_key/parsed.rb5
-rwxr-xr-xlib/puppet/provider/sshkey/parsed.rb5
-rw-r--r--lib/puppet/provider/user/user_role_add.rb3
-rw-r--r--lib/puppet/rails.rb12
-rw-r--r--lib/puppet/rails/database/schema.rb8
-rw-r--r--lib/puppet/rails/fact_value.rb2
-rw-r--r--lib/puppet/rails/host.rb7
-rw-r--r--lib/puppet/rails/resource_tag.rb2
-rw-r--r--lib/puppet/rails/source_file.rb2
-rw-r--r--lib/puppet/reference/metaparameter.rb20
-rw-r--r--lib/puppet/reference/type.rb73
-rw-r--r--lib/puppet/relationship.rb2
-rw-r--r--lib/puppet/reports/rrdgraph.rb12
-rw-r--r--lib/puppet/reports/store.rb8
-rw-r--r--lib/puppet/reports/tagmail.rb18
-rw-r--r--lib/puppet/resource.rb32
-rw-r--r--lib/puppet/resource/catalog.rb15
-rw-r--r--lib/puppet/resource/type.rb2
-rw-r--r--lib/puppet/run.rb3
-rw-r--r--lib/puppet/simple_graph.rb60
-rwxr-xr-xlib/puppet/sslcertificates.rb7
-rw-r--r--lib/puppet/sslcertificates/ca.rb19
-rw-r--r--lib/puppet/sslcertificates/certificate.rb35
-rw-r--r--lib/puppet/sslcertificates/support.rb6
-rw-r--r--lib/puppet/transaction.rb2
-rw-r--r--lib/puppet/transaction/event.rb4
-rw-r--r--lib/puppet/transaction/resource_harness.rb2
-rw-r--r--lib/puppet/transportable.rb28
-rw-r--r--lib/puppet/type.rb132
-rw-r--r--lib/puppet/type/augeas.rb70
-rw-r--r--lib/puppet/type/computer.rb20
-rwxr-xr-xlib/puppet/type/cron.rb24
-rwxr-xr-xlib/puppet/type/exec.rb17
-rw-r--r--lib/puppet/type/file.rb19
-rwxr-xr-xlib/puppet/type/file/content.rb3
-rwxr-xr-xlib/puppet/type/file/ensure.rb11
-rwxr-xr-xlib/puppet/type/file/mode.rb35
-rwxr-xr-xlib/puppet/type/file/owner.rb5
-rw-r--r--lib/puppet/type/file/selcontext.rb4
-rwxr-xr-xlib/puppet/type/file/source.rb2
-rwxr-xr-xlib/puppet/type/filebucket.rb11
-rwxr-xr-xlib/puppet/type/host.rb22
-rw-r--r--lib/puppet/type/macauthorization.rb14
-rwxr-xr-xlib/puppet/type/maillist.rb4
-rw-r--r--lib/puppet/type/mcx.rb6
-rwxr-xr-xlib/puppet/type/mount.rb13
-rw-r--r--lib/puppet/type/package.rb8
-rwxr-xr-xlib/puppet/type/port.rb6
-rw-r--r--lib/puppet/type/resources.rb22
-rwxr-xr-xlib/puppet/type/schedule.rb19
-rw-r--r--lib/puppet/type/ssh_authorized_key.rb4
-rwxr-xr-xlib/puppet/type/sshkey.rb6
-rwxr-xr-xlib/puppet/type/tidy.rb12
-rwxr-xr-xlib/puppet/type/user.rb4
-rw-r--r--lib/puppet/type/yumrepo.rb57
-rw-r--r--lib/puppet/type/zone.rb26
-rwxr-xr-xlib/puppet/type/zpool.rb8
-rw-r--r--lib/puppet/util.rb25
-rw-r--r--lib/puppet/util/autoload.rb2
-rw-r--r--lib/puppet/util/backups.rb6
-rw-r--r--lib/puppet/util/classgen.rb4
-rw-r--r--lib/puppet/util/command_line.rb5
-rw-r--r--lib/puppet/util/diff.rb9
-rw-r--r--lib/puppet/util/docs.rb2
-rw-r--r--lib/puppet/util/errors.rb3
-rw-r--r--lib/puppet/util/fileparsing.rb4
-rwxr-xr-xlib/puppet/util/filetype.rb13
-rw-r--r--lib/puppet/util/inifile.rb3
-rw-r--r--lib/puppet/util/ldap/connection.rb12
-rw-r--r--lib/puppet/util/log.rb7
-rw-r--r--lib/puppet/util/log/destination.rb2
-rw-r--r--lib/puppet/util/log/destinations.rb14
-rw-r--r--lib/puppet/util/log_paths.rb2
-rw-r--r--lib/puppet/util/metric.rb2
-rw-r--r--lib/puppet/util/monkey_patches.rb2
-rw-r--r--lib/puppet/util/provider_features.rb2
-rw-r--r--lib/puppet/util/pson.rb2
-rw-r--r--lib/puppet/util/rdoc.rb17
-rw-r--r--lib/puppet/util/rdoc/generators/puppet_generator.rb31
-rw-r--r--lib/puppet/util/reference.rb4
-rw-r--r--lib/puppet/util/selinux.rb4
-rw-r--r--lib/puppet/util/settings.rb26
-rw-r--r--lib/puppet/util/settings/boolean_setting.rb9
-rw-r--r--lib/puppet/util/settings/file_setting.rb7
-rw-r--r--lib/puppet/util/settings/setting.rb6
-rw-r--r--lib/puppet/util/storage.rb11
-rw-r--r--lib/puppet/util/subclass_loader.rb9
-rw-r--r--lib/puppet/util/suidmanager.rb11
-rw-r--r--lib/puppet/util/zaml.rb88
-rwxr-xr-xspec/integration/defaults_spec.rb10
-rw-r--r--spec/integration/indirector/report/rest_spec.rb5
-rwxr-xr-xspec/integration/transaction_spec.rb55
-rwxr-xr-xspec/integration/type/file_spec.rb25
-rw-r--r--spec/spec_helper.rb6
-rwxr-xr-xspec/unit/application/resource_spec.rb4
-rwxr-xr-xspec/unit/file_bucket/dipper_spec.rb20
-rwxr-xr-xspec/unit/file_serving/metadata_spec.rb10
-rwxr-xr-xspec/unit/indirector/file_bucket_file/file_spec.rb2
-rwxr-xr-xspec/unit/indirector/indirection_spec.rb8
-rwxr-xr-xspec/unit/indirector/node/active_record_spec.rb2
-rwxr-xr-xspec/unit/indirector/report/rest_spec.rb6
-rwxr-xr-xspec/unit/indirector/yaml_spec.rb52
-rw-r--r--spec/unit/network/authstore_spec.rb284
-rwxr-xr-xspec/unit/network/format_handler_spec.rb2
-rwxr-xr-xspec/unit/network/formats_spec.rb2
-rw-r--r--spec/unit/network/handler/fileserver_spec.rb14
-rwxr-xr-xspec/unit/network/rest_authconfig_spec.rb4
-rwxr-xr-xspec/unit/network/server_spec.rb12
-rwxr-xr-xspec/unit/node/environment_spec.rb2
-rwxr-xr-xspec/unit/node/facts_spec.rb2
-rw-r--r--spec/unit/other/selinux_spec.rb15
-rwxr-xr-xspec/unit/parser/ast/casestatement_spec.rb8
-rwxr-xr-xspec/unit/parser/ast/comparison_operator_spec.rb18
-rwxr-xr-xspec/unit/parser/ast/vardef_spec.rb6
-rw-r--r--spec/unit/parser/ast_spec.rb6
-rwxr-xr-xspec/unit/parser/functions/defined_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/regsubst_spec.rb134
-rwxr-xr-xspec/unit/parser/functions/shellquote_spec.rb51
-rwxr-xr-xspec/unit/parser/functions/split_spec.rb24
-rwxr-xr-xspec/unit/parser/functions/sprintf_spec.rb5
-rwxr-xr-xspec/unit/parser/lexer_spec.rb8
-rwxr-xr-xspec/unit/parser/parser_spec.rb48
-rwxr-xr-xspec/unit/parser/resource_spec.rb2
-rwxr-xr-xspec/unit/parser/scope_spec.rb15
-rwxr-xr-xspec/unit/parser/templatewrapper_spec.rb14
-rw-r--r--spec/unit/property/list_spec.rb2
-rwxr-xr-xspec/unit/provider/mount/parsed_spec.rb4
-rwxr-xr-xspec/unit/provider/package/apt_spec.rb2
-rwxr-xr-xspec/unit/provider/package/dpkg_spec.rb6
-rw-r--r--spec/unit/provider/package/hpux_spec.rb2
-rwxr-xr-xspec/unit/provider/package/nim_spec.rb2
-rw-r--r--spec/unit/provider/package/pkg_spec.rb26
-rwxr-xr-xspec/unit/provider/package/pkgdmg_spec.rb10
-rw-r--r--spec/unit/provider/package/zypper_spec.rb8
-rwxr-xr-xspec/unit/provider/selmodule_spec.rb2
-rwxr-xr-xspec/unit/provider/service/daemontools_spec.rb2
-rwxr-xr-xspec/unit/provider/service/debian_spec.rb10
-rwxr-xr-xspec/unit/provider/service/init_spec.rb16
-rwxr-xr-xspec/unit/provider/service/launchd_spec.rb14
-rwxr-xr-xspec/unit/provider/service/redhat_spec.rb12
-rwxr-xr-xspec/unit/provider/service/runit_spec.rb2
-rwxr-xr-xspec/unit/provider/service/src_spec.rb6
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed_spec.rb34
-rwxr-xr-xspec/unit/provider/sshkey/parsed_spec.rb12
-rw-r--r--spec/unit/provider/user/user_role_add_spec.rb24
-rwxr-xr-xspec/unit/rails_spec.rb6
-rwxr-xr-xspec/unit/run_spec.rb5
-rwxr-xr-xspec/unit/ssl/certificate_authority/interface_spec.rb2
-rwxr-xr-xspec/unit/transaction/report_spec.rb6
-rwxr-xr-xspec/unit/transaction_spec.rb2
-rwxr-xr-xspec/unit/type/computer_spec.rb5
-rwxr-xr-xspec/unit/type/exec_spec.rb4
-rwxr-xr-xspec/unit/type/file/content_spec.rb4
-rwxr-xr-xspec/unit/type/file/group_spec.rb2
-rwxr-xr-xspec/unit/type/file/owner_spec.rb4
-rwxr-xr-xspec/unit/type/file_spec.rb9
-rwxr-xr-xspec/unit/type/macauthorization_spec.rb4
-rwxr-xr-xspec/unit/type/maillist_spec.rb2
-rwxr-xr-xspec/unit/type/mount_spec.rb8
-rw-r--r--spec/unit/type/resources_spec.rb118
-rwxr-xr-xspec/unit/type/schedule_spec.rb4
-rwxr-xr-xspec/unit/type/ssh_authorized_key_spec.rb22
-rwxr-xr-xspec/unit/type/zone_spec.rb15
-rw-r--r--spec/unit/util/cache_accumulator_spec.rb18
-rwxr-xr-xspec/unit/util/file_locking_spec.rb6
-rwxr-xr-xspec/unit/util/log_spec.rb4
-rwxr-xr-xspec/unit/util/selinux_spec.rb18
-rwxr-xr-xspec/unit/util/settings/file_setting_spec.rb2
-rwxr-xr-xspec/unit/util/settings_spec.rb2
-rw-r--r--spec/unit/util/user_attr_spec.rb2
-rw-r--r--spec/unit/util/zaml_spec.rb4
-rwxr-xr-xtest/certmgr/ca.rb4
-rwxr-xr-xtest/certmgr/certmgr.rb15
-rwxr-xr-xtest/certmgr/inventory.rb18
-rwxr-xr-xtest/certmgr/support.rb11
-rwxr-xr-xtest/language/ast.rb5
-rwxr-xr-xtest/language/functions.rb71
-rwxr-xr-xtest/language/parser.rb9
-rwxr-xr-xtest/language/scope.rb105
-rwxr-xr-xtest/language/snippets.rb26
-rwxr-xr-xtest/language/transportable.rb5
-rwxr-xr-xtest/lib/puppettest.rb41
-rw-r--r--test/lib/puppettest/fakes.rb3
-rw-r--r--test/lib/puppettest/filetesting.rb25
-rw-r--r--test/lib/puppettest/parsertesting.rb144
-rw-r--r--test/lib/puppettest/railstesting.rb7
-rw-r--r--test/lib/puppettest/resourcetesting.rb10
-rw-r--r--test/lib/puppettest/servertest.rb7
-rw-r--r--test/lib/puppettest/support/utils.rb2
-rwxr-xr-xtest/network/authconfig.rb20
-rwxr-xr-xtest/network/authorization.rb8
-rwxr-xr-xtest/network/authstore.rb130
-rwxr-xr-xtest/network/client/ca.rb6
-rwxr-xr-xtest/network/handler/ca.rb5
-rwxr-xr-xtest/network/handler/fileserver.rb256
-rwxr-xr-xtest/network/rights.rb5
-rwxr-xr-xtest/network/server/webrick.rb20
-rwxr-xr-xtest/network/xmlrpc/processor.rb3
-rwxr-xr-xtest/network/xmlrpc/server.rb3
-rwxr-xr-xtest/network/xmlrpc/webrick_servlet.rb5
-rwxr-xr-xtest/other/relationships.rb18
-rwxr-xr-xtest/other/report.rb8
-rwxr-xr-xtest/other/transactions.rb33
-rwxr-xr-xtest/puppet/defaults.rb3
-rwxr-xr-xtest/puppet/tc_suidmanager.rb21
-rwxr-xr-xtest/rails/railsparameter.rb18
-rwxr-xr-xtest/ral/manager/attributes.rb27
-rwxr-xr-xtest/ral/manager/provider.rb3
-rwxr-xr-xtest/ral/manager/type.rb81
-rwxr-xr-xtest/ral/providers/cron/crontab.rb60
-rwxr-xr-xtest/ral/providers/group.rb3
-rwxr-xr-xtest/ral/providers/host/parsed.rb17
-rwxr-xr-xtest/ral/providers/mailalias/aliases.rb2
-rwxr-xr-xtest/ral/providers/package.rb9
-rwxr-xr-xtest/ral/providers/package/aptitude.rb78
-rwxr-xr-xtest/ral/providers/package/aptrpm.rb76
-rwxr-xr-xtest/ral/providers/parsedfile.rb58
-rwxr-xr-xtest/ral/providers/provider.rb106
-rwxr-xr-xtest/ral/providers/service/base.rb10
-rwxr-xr-xtest/ral/providers/sshkey/parsed.rb7
-rwxr-xr-xtest/ral/providers/user.rb68
-rwxr-xr-xtest/ral/providers/user/useradd.rb65
-rwxr-xr-xtest/ral/type/cron.rb73
-rwxr-xr-xtest/ral/type/exec.rb206
-rwxr-xr-xtest/ral/type/file.rb130
-rwxr-xr-xtest/ral/type/file/target.rb75
-rwxr-xr-xtest/ral/type/fileignoresource.rb61
-rwxr-xr-xtest/ral/type/filesources.rb48
-rwxr-xr-xtest/ral/type/host.rb12
-rwxr-xr-xtest/ral/type/port.rb2
-rwxr-xr-xtest/ral/type/sshkey.rb7
-rwxr-xr-xtest/ral/type/user.rb17
-rwxr-xr-xtest/ral/type/yumrepo.rb9
-rwxr-xr-xtest/ral/type/zone.rb85
-rwxr-xr-xtest/util/classgen.rb39
-rwxr-xr-xtest/util/fileparsing.rb164
-rwxr-xr-xtest/util/inifile.rb43
-rwxr-xr-xtest/util/log.rb27
-rwxr-xr-xtest/util/package.rb3
-rwxr-xr-xtest/util/settings.rb146
-rwxr-xr-xtest/util/storage.rb5
-rwxr-xr-xtest/util/subclass_loader.rb11
-rwxr-xr-xtest/util/utiltest.rb59
385 files changed, 6801 insertions, 5642 deletions
diff --git a/autotest/rspec.rb b/autotest/rspec.rb
index 707429d2e..bf3d2d939 100644
--- a/autotest/rspec.rb
+++ b/autotest/rspec.rb
@@ -50,7 +50,7 @@ class Autotest::Rspec < Autotest
# ~/.autotest to provide a different spec command then the default
# paths provided.
def spec_command(separator=File::ALT_SEPARATOR)
- unless defined? @spec_command then
+ unless defined?(@spec_command) then
@spec_command = spec_commands.find { |cmd| File.exists? cmd }
raise RspecCommandError, "No spec command could be found!" unless @spec_command
diff --git a/autotest/watcher.rb b/autotest/watcher.rb
index 61baf49d0..028d3fe7d 100644
--- a/autotest/watcher.rb
+++ b/autotest/watcher.rb
@@ -2,75 +2,75 @@ ENV["WATCHR"] = "1"
ENV['AUTOTEST'] = 'true'
def run_comp(cmd)
- puts cmd
- results = []
- old_sync = $stdout.sync
- $stdout.sync = true
- line = []
- begin
- open("| #{cmd}", "r") do |f|
- until f.eof? do
- c = f.getc
- putc c
- line << c
- if c == ?\n then
- results << if RUBY_VERSION >= "1.9" then
- line.join
+ puts cmd
+ results = []
+ old_sync = $stdout.sync
+ $stdout.sync = true
+ line = []
+ begin
+ open("| #{cmd}", "r") do |f|
+ until f.eof? do
+ c = f.getc
+ putc c
+ line << c
+ if c == ?\n then
+ results << if RUBY_VERSION >= "1.9" then
+ line.join
else
- line.pack "c*"
- end
- line.clear
- end
+ line.pack "c*"
+ end
+ line.clear
+ end
+ end
end
- end
ensure
- $stdout.sync = old_sync
+ $stdout.sync = old_sync
end
results.join
end
def clear
- #system("clear")
+ #system("clear")
end
def growl(message, status)
- # Strip the color codes
- message.gsub!(/\[\d+m/, '')
-
- growlnotify = `which growlnotify`.chomp
- return if growlnotify.empty?
- title = "Watchr Test Results"
- image = status == :pass ? "autotest/images/pass.png" : "autotest/images/fail.png"
- options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
- system %(#{growlnotify} #{options} &)
+ # Strip the color codes
+ message.gsub!(/\[\d+m/, '')
+
+ growlnotify = `which growlnotify`.chomp
+ return if growlnotify.empty?
+ title = "Watchr Test Results"
+ image = status == :pass ? "autotest/images/pass.png" : "autotest/images/fail.png"
+ options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
+ system %(#{growlnotify} #{options} &)
end
def file2specs(file)
- %w{spec/unit spec/integration}.collect { |d|
- file.sub('lib/puppet', d)
+ %w{spec/unit spec/integration}.collect { |d|
+ file.sub('lib/puppet', d)
}.find_all { |f|
- File.exist?(f)
+ File.exist?(f)
}
end
def file2test(file)
- result = file.sub('lib/puppet', 'test')
- return nil unless File.exist?(result)
- result
+ result = file.sub('lib/puppet', 'test')
+ return nil unless File.exist?(result)
+ result
end
def run_spec(command)
- clear
- result = run_comp(command).split("\n").last
- status = result.include?('0 failures') ? :pass : :fail
- growl result, status
+ clear
+ result = run_comp(command).split("\n").last
+ status = result.include?('0 failures') ? :pass : :fail
+ growl result, status
end
def run_test(command)
- clear
- result = run_comp(command).split("\n").last
- status = result.include?('0 failures, 0 errors') ? :pass : :fail
- growl result.split("\n").last rescue nil
+ clear
+ result = run_comp(command).split("\n").last
+ status = result.include?('0 failures, 0 errors') ? :pass : :fail
+ growl result.split("\n").last rescue nil
end
def run_test_file(file)
@@ -85,16 +85,16 @@ def run_spec_files(files)
end
def run_all_tests
- run_test("rake unit")
+ run_test("rake unit")
end
def run_all_specs
- run_test("rake spec")
+ run_test("rake spec")
end
def run_suite
- run_all_tests
- run_all_specs
+ run_all_tests
+ run_all_specs
end
watch('spec/spec_helper.rb') { run_all_specs }
@@ -108,31 +108,31 @@ watch(%r%^lib/puppet/(.*)\.rb$%) { |md|
watch(%r!^spec/lib/spec.*!) { |md| run_all_specs }
watch(%r!^spec/lib/monkey_patches/.*!) { |md| run_all_specs }
watch(%r{test/.+\.rb}) { |md|
- if md[0] =~ /\/lib\//
- run_all_tests
- else
- run_test_file(md[0])
- end
+ if md[0] =~ /\/lib\//
+ run_all_tests
+ else
+ run_test_file(md[0])
+ end
}
# Ctrl-\
Signal.trap 'QUIT' do
- puts " --- Running all tests ---\n\n"
- run_suite
+ puts " --- Running all tests ---\n\n"
+ run_suite
end
@interrupted = false
# Ctrl-C
Signal.trap 'INT' do
- if @interrupted then
- @wants_to_quit = true
- abort("\n")
- else
- puts "Interrupt a second time to quit; wait for rerun of tests"
- @interrupted = true
- Kernel.sleep 1.5
- # raise Interrupt, nil # let the run loop catch it
- run_suite
- end
+ if @interrupted then
+ @wants_to_quit = true
+ abort("\n")
+ else
+ puts "Interrupt a second time to quit; wait for rerun of tests"
+ @interrupted = true
+ Kernel.sleep 1.5
+ # raise Interrupt, nil # let the run loop catch it
+ run_suite
+ end
end
diff --git a/ext/extlookup.rb b/ext/extlookup.rb
index b0978ef12..b9ebc43c8 100644
--- a/ext/extlookup.rb
+++ b/ext/extlookup.rb
@@ -1,10 +1,10 @@
-# Puppet External Data Sources
+# Puppet External Data Sources
#
# This is a parser function to read data from external files, this version
# uses CSV files but the concept can easily be adjust for databases, yaml
# or any other queryable data source.
#
-# The object of this is to make it obvious when it's being used, rather than
+# The object of this is to make it obvious when it's being used, rather than
# magically loading data in when an module is loaded I prefer to look at the code
# and see statements like:
#
@@ -34,7 +34,7 @@
#
# Now create the following data files in /etc/puppet/manifests/extdata
#
-# domain_myclient.com.csv:
+# domain_myclient.com.csv:
# snmp_contact,John Doe <john@myclient.com>
# root_contact,support@%{domain}
# client_trusted_ips,192.168.1.130,192.168.10.0/24
@@ -48,7 +48,7 @@
#
# $snmp_contact = extlookup("snmp_contact")
#
-# The obove code shows some other features, you can use any fact or variable that
+# The obove code shows some other features, you can use any fact or variable that
# is in scope by simply using %{varname} in your data files, you can return arrays
# by just having multiple values in the csv after the initial variable name.
#
@@ -57,8 +57,8 @@
# in empty values etc. You can however specify a default value:
#
# $ntp_servers = extlookup("ntp_servers", "1.${country}.pool.ntp.org")
-#
-# In this case it will default to "1.${country}.pool.ntp.org" if nothing is defined in
+#
+# In this case it will default to "1.${country}.pool.ntp.org" if nothing is defined in
# any data file.
#
# You can also specify an additional data file to search first before any others at use
@@ -78,7 +78,7 @@
#
# For further help contact Volcane on #puppet
require 'csv'
-
+
module Puppet::Parser::Functions
newfunction(:extlookup, :type => :rvalue) do |args|
key = args[0]
@@ -110,12 +110,12 @@ module Puppet::Parser::Functions
extlookup_precedence << prec
end
-
+
datafiles = Array.new
# if we got a custom data file, put it first in the array of search files
- if datafile != ""
+ if datafile != ""
if File.exists?(extlookup_datadir + "/#{datafile}.csv")
datafiles << extlookup_datadir + "/#{datafile}.csv"
end
@@ -135,14 +135,14 @@ module Puppet::Parser::Functions
result = CSV.read(file).find_all do |r|
r[0] == key
end
-
+
# return just the single result if theres just one,
# else take all the fields in the csv and build an array
if result.length > 0
if result[0].length == 2
val = result[0][1].to_s
-
+
# parse %{}'s in the CSV into local variables using lookupvar()
while val =~ /%\{(.+?)\}/
val.gsub!(/%\{#{$1}\}/, lookupvar($1))
@@ -152,7 +152,7 @@ module Puppet::Parser::Functions
elsif result[0].length > 1
length = result[0].length
cells = result[0][1,length]
-
+
# Individual cells in a CSV result are a weird data type and throws
# puppets yaml parsing, so just map it all to plain old strings
desired = cells.map do |c|
@@ -172,7 +172,7 @@ module Puppet::Parser::Functions
# don't accidently return nil's and such rather throw a parse error
if desired == "_ExtUNSET_" && default == "_ExtUNSET_"
raise Puppet::ParseError, "No match found for '#{key}' in any data file during extlookup()"
- else
+ else
desired = default if desired == "_ExtUNSET_"
end
diff --git a/ext/nagios/check_puppet.rb b/ext/nagios/check_puppet.rb
index c569566ad..5d448b6fc 100755
--- a/ext/nagios/check_puppet.rb
+++ b/ext/nagios/check_puppet.rb
@@ -20,26 +20,35 @@ class CheckPuppet
o.set_summary_indent(' ')
o.banner = "Usage: #{script_name} [OPTIONS]"
o.define_head "The check_puppet Nagios plug-in checks that specified " +
- "Puppet process is running and the state file is no " +
- "older than specified interval."
- o.separator ""
- o.separator "Mandatory arguments to long options are mandatory for " +
- "short options too."
-
- o.on("-s", "--statefile=statefile", String, "The state file",
- "Default: #{OPTIONS[:statefile]}") { |OPTIONS[:statefile]| }
- o.on("-p", "--process=processname", String, "The process to check",
- "Default: #{OPTIONS[:process]}") { |OPTIONS[:process]| }
- o.on("-i", "--interval=value", Integer,
- "Default: #{OPTIONS[:interval]} minutes") { |OPTIONS[:interval]| }
-
- o.separator ""
- o.on_tail("-h", "--help", "Show this help message.") do
- puts o
- exit
- end
-
- o.parse!(ARGV)
+ "Puppet process is running and the state file is no " +
+ "older than specified interval."
+ o.separator ""
+ o.separator "Mandatory arguments to long options are mandatory for " +
+ "short options too."
+
+
+ o.on(
+ "-s", "--statefile=statefile", String, "The state file",
+
+ "Default: #{OPTIONS[:statefile]}") { |OPTIONS[:statefile]| }
+
+ o.on(
+ "-p", "--process=processname", String, "The process to check",
+
+ "Default: #{OPTIONS[:process]}") { |OPTIONS[:process]| }
+
+ o.on(
+ "-i", "--interval=value", Integer,
+
+ "Default: #{OPTIONS[:interval]} minutes") { |OPTIONS[:interval]| }
+
+ o.separator ""
+ o.on_tail("-h", "--help", "Show this help message.") do
+ puts o
+ exit
+ end
+
+ o.parse!(ARGV)
end
def check_proc
diff --git a/ext/puppetlisten/puppetrun.rb b/ext/puppetlisten/puppetrun.rb
index 600ab1038..192016c8d 100755
--- a/ext/puppetlisten/puppetrun.rb
+++ b/ext/puppetlisten/puppetrun.rb
@@ -31,7 +31,7 @@ s = TCPSocket.new(host, port)
ssl = OpenSSL::SSL::SSLSocket.new(s, ctx)
ssl.connect # start SSL session
ssl.sync_close = true # if true the underlying socket will be
- # closed in SSLSocket#close. (default: false)
+# closed in SSLSocket#close. (default: false)
while (line = ssl.gets)
puts line
end
diff --git a/ext/puppetstoredconfigclean.rb b/ext/puppetstoredconfigclean.rb
index 1b4aabd0f..6f4aa7230 100644
--- a/ext/puppetstoredconfigclean.rb
+++ b/ext/puppetstoredconfigclean.rb
@@ -17,10 +17,13 @@ def printusage(error_code)
exit(error_code)
end
-opts = GetoptLong.new(
+
+ opts = GetoptLong.new(
+
[ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ],
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
[ "--usage", "-u", GetoptLong::NO_ARGUMENT ],
+
[ "--version", "-v", GetoptLong::NO_ARGUMENT ]
)
diff --git a/ext/regexp_nodes/regexp_nodes.rb b/ext/regexp_nodes/regexp_nodes.rb
index a9e7ed6a9..377b13053 100644
--- a/ext/regexp_nodes/regexp_nodes.rb
+++ b/ext/regexp_nodes/regexp_nodes.rb
@@ -96,9 +96,9 @@ class ExternalNode
def to_yaml
classes = self.classes.to_a
if self.parameters.empty? # otherwise to_yaml prints "parameters: {}"
- parameters = nil
+ parameters = nil
else
- parameters = self.parameters
+ parameters = self.parameters
end
({ 'classes' => classes, 'parameters' => parameters}).to_yaml
end
@@ -164,7 +164,7 @@ class ExternalNode
next if File.basename(filepath) =~ /^\./ # skip over dotfiles
next unless File.directory?(filepath) and
- File.readable?(filepath) # skip over non-directories
+ File.readable?(filepath) # skip over non-directories
$LOG.debug "Considering contents of #{filepath}"
@@ -175,8 +175,8 @@ class ExternalNode
File.readable?(secondlevel)
$LOG.debug("Attempting to match [#{@hostname}] in [#{secondlevel}]")
if matched_in_patternfile?(secondlevel, @hostname)
- @parameters[ parametername.to_s ] = patternfile.to_s
- $LOG.debug("Set @parameters[#{parametername.to_s}] = #{patternfile.to_s}")
+ @parameters[ parametername.to_s ] = patternfile.to_s
+ $LOG.debug("Set @parameters[#{parametername.to_s}] = #{patternfile.to_s}")
end # if
end # Dir.foreach #{filepath}
end # Dir.foreach #{fullpath}
diff --git a/install.rb b/install.rb
index eb17ec3a3..54a714674 100755
--- a/install.rb
+++ b/install.rb
@@ -36,11 +36,11 @@ require 'rbconfig'
require 'find'
require 'fileutils'
begin
- require 'ftools' # apparently on some system ftools doesn't get loaded
- $haveftools = true
+ require 'ftools' # apparently on some system ftools doesn't get loaded
+ $haveftools = true
rescue LoadError
- puts "ftools not found. Using FileUtils instead.."
- $haveftools = false
+ puts "ftools not found. Using FileUtils instead.."
+ $haveftools = false
end
require 'optparse'
require 'ostruct'
@@ -55,10 +55,10 @@ end
begin
if $haverdoc
- rst2man = %x{which rst2man.py}
- $haveman = true
+ rst2man = %x{which rst2man.py}
+ $haveman = true
else
- $haveman = false
+ $haveman = false
end
rescue
puts "Missing rst2man; skipping man page creation"
@@ -88,45 +88,45 @@ libs = glob(%w{lib/**/*.rb lib/**/*.py})
tests = glob(%w{test/**/*.rb})
def do_bins(bins, target, strip = 's?bin/')
- bins.each do |bf|
- obf = bf.gsub(/#{strip}/, '')
- install_binfile(bf, obf, target)
- end
+ bins.each do |bf|
+ obf = bf.gsub(/#{strip}/, '')
+ install_binfile(bf, obf, target)
+ end
end
def do_libs(libs, strip = 'lib/')
- libs.each do |lf|
- olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
- op = File.dirname(olf)
- if $haveftools
- File.makedirs(op, true)
- File.chmod(0755, op)
- File.install(lf, olf, 0644, true)
- else
- FileUtils.makedirs(op, {:mode => 0755, :verbose => true})
- FileUtils.chmod(0755, op)
- FileUtils.install(lf, olf, {:mode => 0644, :verbose => true})
+ libs.each do |lf|
+ olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
+ op = File.dirname(olf)
+ if $haveftools
+ File.makedirs(op, true)
+ File.chmod(0755, op)
+ File.install(lf, olf, 0644, true)
+ else
+ FileUtils.makedirs(op, {:mode => 0755, :verbose => true})
+ FileUtils.chmod(0755, op)
+ FileUtils.install(lf, olf, {:mode => 0644, :verbose => true})
+ end
end
- end
end
def do_man(man, strip = 'man/')
- man.each do |mf|
- omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
- om = File.dirname(omf)
- if $haveftools
- File.makedirs(om, true)
- File.chmod(0755, om)
- File.install(mf, omf, 0644, true)
- else
- FileUtils.makedirs(om, {:mode => 0755, :verbose => true})
- FileUtils.chmod(0755, om)
- FileUtils.install(mf, omf, {:mode => 0644, :verbose => true})
+ man.each do |mf|
+ omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
+ om = File.dirname(omf)
+ if $haveftools
+ File.makedirs(om, true)
+ File.chmod(0755, om)
+ File.install(mf, omf, 0644, true)
+ else
+ FileUtils.makedirs(om, {:mode => 0755, :verbose => true})
+ FileUtils.chmod(0755, om)
+ FileUtils.install(mf, omf, {:mode => 0644, :verbose => true})
+ end
+ gzip = %x{which gzip}
+ gzip.chomp!
+ %x{#{gzip} -f #{omf}}
end
- gzip = %x{which gzip}
- gzip.chomp!
- %x{#{gzip} -f #{omf}}
- end
end
# Verify that all of the prereqs are installed
@@ -135,13 +135,13 @@ def check_prereqs
begin
require pre
if pre == "facter"
- # to_f isn't quite exact for strings like "1.5.1" but is good
- # enough for this purpose.
- facter_version = Facter.version.to_f
- if facter_version < MIN_FACTER_VERSION
- puts "Facter version: %s; minimum required: %s; cannot install" % [facter_version, MIN_FACTER_VERSION]
- exit -1
- end
+ # to_f isn't quite exact for strings like "1.5.1" but is good
+ # enough for this purpose.
+ facter_version = Facter.version.to_f
+ if facter_version < MIN_FACTER_VERSION
+ puts "Facter version: %s; minimum required: %s; cannot install" % [facter_version, MIN_FACTER_VERSION]
+ exit -1
+ end
end
rescue LoadError
puts "Could not load %s; cannot install" % pre
@@ -154,169 +154,169 @@ end
# Prepare the file installation.
#
def prepare_installation
- # Only try to do docs if we're sure they have rdoc
- if $haverdoc
- InstallOptions.rdoc = true
- if RUBY_PLATFORM == "i386-mswin32"
+ # Only try to do docs if we're sure they have rdoc
+ if $haverdoc
+ InstallOptions.rdoc = true
+ if RUBY_PLATFORM == "i386-mswin32"
+ InstallOptions.ri = false
+ else
+ InstallOptions.ri = true
+ end
+ else
+ InstallOptions.rdoc = false
InstallOptions.ri = false
- else
- InstallOptions.ri = true
- end
- else
- InstallOptions.rdoc = false
- InstallOptions.ri = false
- end
-
-
- if $haveman
- InstallOptions.man = true
- if RUBY_PLATFORM == "i386-mswin32"
- InstallOptions.man = false
- end
- else
- InstallOptions.man = false
- end
-
- InstallOptions.tests = true
-
- if $haveman
- InstallOptions.man = true
- if RUBY_PLATFORM == "i386-mswin32"
- InstallOptions.man = false
- end
- else
- InstallOptions.man = false
- end
-
- ARGV.options do |opts|
- opts.banner = "Usage: #{File.basename($0)} [options]"
- opts.separator ""
- opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
- InstallOptions.rdoc = onrdoc
- end
- opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
- InstallOptions.ri = onri
- end
- opts.on('--[no-]man', 'Prevents the creation of man pages.', 'Default on.') do |onman|
- InstallOptions.man = onman
- end
- opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
- InstallOptions.tests = ontest
end
- opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
- InstallOptions.destdir = destdir
+
+
+ if $haveman
+ InstallOptions.man = true
+ if RUBY_PLATFORM == "i386-mswin32"
+ InstallOptions.man = false
+ end
+ else
+ InstallOptions.man = false
end
- opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir|
- InstallOptions.bindir = bindir
+
+ InstallOptions.tests = true
+
+ if $haveman
+ InstallOptions.man = true
+ if RUBY_PLATFORM == "i386-mswin32"
+ InstallOptions.man = false
+ end
+ else
+ InstallOptions.man = false
end
- opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir|
- InstallOptions.sbindir = sbindir
+
+ ARGV.options do |opts|
+ opts.banner = "Usage: #{File.basename($0)} [options]"
+ opts.separator ""
+ opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
+ InstallOptions.rdoc = onrdoc
+ end
+ opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
+ InstallOptions.ri = onri
+ end
+ opts.on('--[no-]man', 'Prevents the creation of man pages.', 'Default on.') do |onman|
+ InstallOptions.man = onman
+ end
+ opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
+ InstallOptions.tests = ontest
+ end
+ opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
+ InstallOptions.destdir = destdir
+ end
+ opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir|
+ InstallOptions.bindir = bindir
+ end
+ opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir|
+ InstallOptions.sbindir = sbindir
+ end
+ opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir|
+ InstallOptions.sitelibdir = sitelibdir
+ end
+ opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir|
+ InstallOptions.mandir = mandir
+ end
+ opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
+ InstallOptions.rdoc = false
+ InstallOptions.ri = false
+ InstallOptions.tests = false
+ end
+ opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
+ InstallOptions.rdoc = true
+ InstallOptions.man = true
+ InstallOptions.ri = true
+ InstallOptions.tests = true
+ end
+ opts.separator("")
+ opts.on_tail('--help', "Shows this help text.") do
+ $stderr.puts opts
+ exit
+ end
+
+ opts.parse!
end
- opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir|
- InstallOptions.sitelibdir = sitelibdir
+
+ tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."]
+
+ version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
+ libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
+
+ # Mac OS X 10.5 and higher declare bindir and sbindir as
+ # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
+ # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin
+ # which is not generally where people expect executables to be installed
+ # These settings are appropriate defaults for all OS X versions.
+ if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/
+ Config::CONFIG['bindir'] = "/usr/bin"
+ Config::CONFIG['sbindir'] = "/usr/sbin"
end
- opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir|
- InstallOptions.mandir = mandir
+
+ if not InstallOptions.bindir.nil?
+ bindir = InstallOptions.bindir
+ else
+ bindir = Config::CONFIG['bindir']
end
- opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
- InstallOptions.rdoc = false
- InstallOptions.ri = false
- InstallOptions.tests = false
+
+ if not InstallOptions.sbindir.nil?
+ sbindir = InstallOptions.sbindir
+ else
+ sbindir = Config::CONFIG['sbindir']
end
- opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
- InstallOptions.rdoc = true
- InstallOptions.man = true
- InstallOptions.ri = true
- InstallOptions.tests = true
+
+ if not InstallOptions.sitelibdir.nil?
+ sitelibdir = InstallOptions.sitelibdir
+ else
+ sitelibdir = Config::CONFIG["sitelibdir"]
+ if sitelibdir.nil?
+ sitelibdir = $:.find { |x| x =~ /site_ruby/ }
+ if sitelibdir.nil?
+ sitelibdir = File.join(libdir, "site_ruby")
+ elsif sitelibdir !~ Regexp.quote(version)
+ sitelibdir = File.join(sitelibdir, version)
+ end
+ end
end
- opts.separator("")
- opts.on_tail('--help', "Shows this help text.") do
- $stderr.puts opts
- exit
+
+ if not InstallOptions.mandir.nil?
+ mandir = InstallOptions.mandir
+ else
+ mandir = Config::CONFIG['mandir']
end
- opts.parse!
- end
-
- tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."]
-
- version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
- libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
-
- # Mac OS X 10.5 and higher declare bindir and sbindir as
- # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
- # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin
- # which is not generally where people expect executables to be installed
- # These settings are appropriate defaults for all OS X versions.
- if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/
- Config::CONFIG['bindir'] = "/usr/bin"
- Config::CONFIG['sbindir'] = "/usr/sbin"
- end
-
- if not InstallOptions.bindir.nil?
- bindir = InstallOptions.bindir
- else
- bindir = Config::CONFIG['bindir']
- end
-
- if not InstallOptions.sbindir.nil?
- sbindir = InstallOptions.sbindir
- else
- sbindir = Config::CONFIG['sbindir']
- end
-
- if not InstallOptions.sitelibdir.nil?
- sitelibdir = InstallOptions.sitelibdir
- else
- sitelibdir = Config::CONFIG["sitelibdir"]
- if sitelibdir.nil?
- sitelibdir = $:.find { |x| x =~ /site_ruby/ }
- if sitelibdir.nil?
- sitelibdir = File.join(libdir, "site_ruby")
- elsif sitelibdir !~ Regexp.quote(version)
- sitelibdir = File.join(sitelibdir, version)
- end
+ # To be deprecated once people move over to using --destdir option
+ if (destdir = ENV['DESTDIR'])
+ bindir = "#{destdir}#{bindir}"
+ sbindir = "#{destdir}#{sbindir}"
+ mandir = "#{destdir}#{mandir}"
+ sitelibdir = "#{destdir}#{sitelibdir}"
+
+ FileUtils.makedirs(bindir)
+ FileUtils.makedirs(sbindir)
+ FileUtils.makedirs(mandir)
+ FileUtils.makedirs(sitelibdir)
+ # This is the new way forward
+ elsif (destdir = InstallOptions.destdir)
+ bindir = "#{destdir}#{bindir}"
+ sbindir = "#{destdir}#{sbindir}"
+ mandir = "#{destdir}#{mandir}"
+ sitelibdir = "#{destdir}#{sitelibdir}"
+
+ FileUtils.makedirs(bindir)
+ FileUtils.makedirs(sbindir)
+ FileUtils.makedirs(mandir)
+ FileUtils.makedirs(sitelibdir)
end
- end
-
- if not InstallOptions.mandir.nil?
- mandir = InstallOptions.mandir
- else
- mandir = Config::CONFIG['mandir']
- end
-
- # To be deprecated once people move over to using --destdir option
- if (destdir = ENV['DESTDIR'])
- bindir = "#{destdir}#{bindir}"
- sbindir = "#{destdir}#{sbindir}"
- mandir = "#{destdir}#{mandir}"
- sitelibdir = "#{destdir}#{sitelibdir}"
-
- FileUtils.makedirs(bindir)
- FileUtils.makedirs(sbindir)
- FileUtils.makedirs(mandir)
- FileUtils.makedirs(sitelibdir)
- # This is the new way forward
- elsif (destdir = InstallOptions.destdir)
- bindir = "#{destdir}#{bindir}"
- sbindir = "#{destdir}#{sbindir}"
- mandir = "#{destdir}#{mandir}"
- sitelibdir = "#{destdir}#{sitelibdir}"
-
- FileUtils.makedirs(bindir)
- FileUtils.makedirs(sbindir)
- FileUtils.makedirs(mandir)
- FileUtils.makedirs(sitelibdir)
- end
-
- tmpdirs << bindir
-
- InstallOptions.tmp_dirs = tmpdirs.compact
- InstallOptions.site_dir = sitelibdir
- InstallOptions.bin_dir = bindir
- InstallOptions.sbin_dir = sbindir
- InstallOptions.lib_dir = libdir
- InstallOptions.man_dir = mandir
+
+ tmpdirs << bindir
+
+ InstallOptions.tmp_dirs = tmpdirs.compact
+ InstallOptions.site_dir = sitelibdir
+ InstallOptions.bin_dir = bindir
+ InstallOptions.sbin_dir = sbindir
+ InstallOptions.lib_dir = libdir
+ InstallOptions.man_dir = mandir
end
##
@@ -326,8 +326,7 @@ def build_rdoc(files)
return unless $haverdoc
begin
r = RDoc::RDoc.new
- r.document(["--main", "README", "--title",
- "Puppet -- Site Configuration Management", "--line-numbers"] + files)
+ r.document(["--main", "README", "--title", "Puppet -- Site Configuration Management", "--line-numbers"] + files)
rescue RDoc::RDocError => e
$stderr.puts e.message
rescue Exception => e
@@ -361,17 +360,17 @@ def build_man(bins, sbins)
File.unlink("./puppet.conf.rst")
# Create binary man pages
- binary = bins + sbins
+ binary = bins + sbins
binary.each do |bin|
- b = bin.gsub( /(bin|sbin)\//, "")
- %x{#{bin} --help > ./#{b}.rst}
- %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8}
- File.unlink("./#{b}.rst")
+ b = bin.gsub( /(bin|sbin)\//, "")
+ %x{#{bin} --help > ./#{b}.rst}
+ %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8}
+ File.unlink("./#{b}.rst")
end
-
+
rescue SystemCallError
- $stderr.puts "Couldn't build man pages: " + $!
- $stderr.puts "Continuing with install..."
+ $stderr.puts "Couldn't build man pages: " + $!
+ $stderr.puts "Continuing with install..."
end
end
@@ -402,57 +401,57 @@ end
# (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
# windows, we add an '.rb' extension and let file associations do their stuff.
def install_binfile(from, op_file, target)
- tmp_dir = nil
- InstallOptions.tmp_dirs.each do |t|
- if File.directory?(t) and File.writable?(t)
- tmp_dir = t
- break
+ tmp_dir = nil
+ InstallOptions.tmp_dirs.each do |t|
+ if File.directory?(t) and File.writable?(t)
+ tmp_dir = t
+ break
+ end
end
- end
-
- fail "Cannot find a temporary directory" unless tmp_dir
- tmp_file = File.join(tmp_dir, '_tmp')
- ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
-
- File.open(from) do |ip|
- File.open(tmp_file, "w") do |op|
- ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
- op.puts "#!#{ruby}"
- contents = ip.readlines
- if contents[0] =~ /^#!/
- contents.shift
- end
- op.write contents.join()
+
+ fail "Cannot find a temporary directory" unless tmp_dir
+ tmp_file = File.join(tmp_dir, '_tmp')
+ ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+
+ File.open(from) do |ip|
+ File.open(tmp_file, "w") do |op|
+ ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+ op.puts "#!#{ruby}"
+ contents = ip.readlines
+ if contents[0] =~ /^#!/
+ contents.shift
+ end
+ op.write contents.join()
+ end
end
- end
- if Config::CONFIG["target_os"] =~ /win/io and Config::CONFIG["target_os"] !~ /darwin/io
- installed_wrapper = false
+ if Config::CONFIG["target_os"] =~ /win/io and Config::CONFIG["target_os"] !~ /darwin/io
+ installed_wrapper = false
- if File.exists?("#{from}.bat")
- FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
- installed_wrapper = true
- end
+ if File.exists?("#{from}.bat")
+ FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
+ installed_wrapper = true
+ end
- if File.exists?("#{from}.cmd")
- FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
- installed_wrapper = true
- end
+ if File.exists?("#{from}.cmd")
+ FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
+ installed_wrapper = true
+ end
- if not installed_wrapper
- tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
- cwn = File.join(Config::CONFIG['bindir'], op_file)
- cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
+ if not installed_wrapper
+ tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
+ cwn = File.join(Config::CONFIG['bindir'], op_file)
+ cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
- File.open(tmp_file2, "wb") { |cw| cw.puts cwv }
- FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
+ File.open(tmp_file2, "wb") { |cw| cw.puts cwv }
+ FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
- File.unlink(tmp_file2)
- installed_wrapper = true
+ File.unlink(tmp_file2)
+ installed_wrapper = true
+ end
end
- end
- FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
- File.unlink(tmp_file)
+ FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
+ File.unlink(tmp_file)
end
CMD_WRAPPER = <<-EOS
diff --git a/lib/puppet.rb b/lib/puppet.rb
index fbf5ccf73..d09c81801 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -138,8 +138,7 @@ module Puppet
elsif FileTest.directory?(File.join(path))
next
else FileTest.exist?(File.join(path))
- raise Puppet::Error, "Cannot create %s: basedir %s is a file" %
- [dir, File.join(path)]
+ raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)]
end
}
return true
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index abd930949..3409d3615 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -11,7 +11,7 @@ require 'optparse'
#
# For legacy compatibility,
# Puppet::Application[:example].run
-# is equivalent to
+# is equivalent to
# Puppet::Application::Example.new.run
#
#
@@ -182,7 +182,7 @@ class Application
end
def should_parse_config?
- if ! defined? @parse_config
+ if ! defined?(@parse_config)
@parse_config = true
end
return @parse_config
@@ -259,7 +259,7 @@ class Application
end
def option_parser
- return @option_parser if defined? @option_parser
+ return @option_parser if defined?(@option_parser)
@option_parser = OptionParser.new(self.class.banner)
@@ -280,7 +280,7 @@ class Application
$puppet_application_mode = @run_mode
$puppet_application_name = name
-
+
if Puppet.respond_to? :settings
# This is to reduce the amount of confusion in rspec
# because it might have loaded defaults.rb before the globals were set
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index a754ed399..ab47abc38 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -100,9 +100,9 @@ class Puppet::Application::Agent < Puppet::Application
def fingerprint
unless cert = host.certificate || host.certificate_request
- $stderr.puts "Fingerprint asked but no certificate nor certificate request have yet been issued"
- exit(1)
- return
+ $stderr.puts "Fingerprint asked but no certificate nor certificate request have yet been issued"
+ exit(1)
+ return
end
unless fingerprint = cert.fingerprint(options[:digest])
raise ArgumentError, "Could not get fingerprint for digest '#{options[:digest]}'"
@@ -183,8 +183,7 @@ class Puppet::Application::Agent < Puppet::Application
def setup_listen
unless FileTest.exists?(Puppet[:authconfig])
- Puppet.err "Will not start without authorization file %s" %
- Puppet[:authconfig]
+ Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig]
exit(14)
end
@@ -235,7 +234,7 @@ class Puppet::Application::Agent < Puppet::Application
Puppet.settings.use :main, :agent, :ssl
# We need to specify a ca location for all of the SSL-related i
- # indirected classes to work; in fingerprint mode we just need
+ # indirected classes to work; in fingerprint mode we just need
# access to the local files and we don't need a ca.
Puppet::SSL::Host.ca_location = options[:fingerprint] ? :none : :remote
diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb
index 4da64b3bb..f9c5260ec 100644
--- a/lib/puppet/application/describe.rb
+++ b/lib/puppet/application/describe.rb
@@ -160,8 +160,7 @@ class TypeDoc
a.to_s <=> b.to_s
}.each { |prov|
puts "\n- **%s**" % prov
- puts @format.wrap(type.provider(prov).doc,
- :indent => 4, :scrub => true)
+ puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true)
}
end
diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb
index a28cac21b..ae4c871cd 100644
--- a/lib/puppet/application/doc.rb
+++ b/lib/puppet/application/doc.rb
@@ -70,7 +70,10 @@ class Puppet::Application::Doc < Puppet::Application
end
files += command_line.args
Puppet.info "scanning: %s" % files.inspect
- Puppet.settings.setdefaults("puppetdoc",
+
+ Puppet.settings.setdefaults(
+ "puppetdoc",
+
"document_all" => [false, "Document all resources"]
)
Puppet.settings[:document_all] = options[:all] || false
@@ -160,7 +163,7 @@ class Puppet::Application::Doc < Puppet::Application
if options[:mode] == :pdf
Puppet::Util::Reference.pdf(text)
- else
+ else
puts text
end
diff --git a/lib/puppet/application/kick.rb b/lib/puppet/application/kick.rb
index 5792edebd..8c168b3ba 100644
--- a/lib/puppet/application/kick.rb
+++ b/lib/puppet/application/kick.rb
@@ -82,8 +82,7 @@ class Puppet::Application::Kick < Puppet::Application
end
print "%s finished with exit code %s\n" % [host, $?.exitstatus]
else
- $stderr.puts "Could not find host for PID %s with status %s" %
- [pid, $?.exitstatus]
+ $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus]
end
rescue Errno::ECHILD
# There are no children left, so just exit unless there are still
@@ -144,7 +143,7 @@ class Puppet::Application::Kick < Puppet::Application
exit(12)
end
end
-
+
def initialize(*args)
super
@hosts = []
diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb
index 484ec08ca..a8ed27c42 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -54,7 +54,7 @@ class Puppet::Application::Master < Puppet::Application
raise ArgumentError, "Cannot render compiled catalogs without pson support" unless Puppet.features.pson?
begin
unless catalog = Puppet::Resource::Catalog.find(options[:node])
- raise "Could not compile catalog for %s" % options[:node]
+ raise "Could not compile catalog for %s" % options[:node]
end
jj catalog.to_resource
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index 9e1fa0929..dc2b99cfe 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -62,8 +62,7 @@ class Puppet::Configurer
::File.unlink(Puppet[:statefile])
retry
rescue => detail
- raise Puppet::Error.new("Cannot remove %s: %s" %
- [Puppet[:statefile], detail])
+ raise Puppet::Error.new("Cannot remove %s: %s" % [Puppet[:statefile], detail])
end
end
end
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 6ded3c0fe..9637a63e0 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -56,7 +56,7 @@ module Puppet
],
:onetime => [false,
"Run the configuration once, rather than as a long-running
- daemon. This is useful for interactively running puppetd."
+ daemon. This is useful for interactively running puppetd."
],
:path => {:default => "none",
:desc => "The shell search path. Defaults to whatever is inherited
@@ -82,7 +82,7 @@ module Puppet
is in Ruby's search path",
:call_on_define => true, # Call our hook with the default value, so we always get the libdir set.
:hook => proc do |value|
- if defined? @oldlibdir and $:.include?(@oldlibdir)
+ if defined?(@oldlibdir) and $:.include?(@oldlibdir)
$:.delete(@oldlibdir)
end
@oldlibdir = value
@@ -99,8 +99,7 @@ module Puppet
],
:environment => {:default => "production", :desc => "The environment Puppet is running in. For clients
(e.g., ``puppet agent``) this determines the environment itself, which
- is used to find modules and much more. For servers (i.e.,
- ``puppet master``) this provides the default environment for nodes
+ is used to find modules and much more. For servers (i.e., ``puppet master``) this provides the default environment for nodes
we know nothing about."
},
:diff_args => ["-u", "Which arguments to pass to the diff command when printing differences between files."],
@@ -128,8 +127,7 @@ module Puppet
:http_proxy_host => ["none",
"The HTTP proxy host to use for outgoing connections. Note: You
may need to use a FQDN for the server hostname when using a proxy."],
- :http_proxy_port => [3128,
- "The HTTP proxy port to use for outgoing connections"],
+ :http_proxy_port => [3128, "The HTTP proxy port to use for outgoing connections"],
:filetimeout => [ 15,
"The minimum time to wait (in seconds) between checking for updates in
configuration files. This timeout determines how quickly Puppet checks whether
@@ -158,7 +156,7 @@ module Puppet
If true, then storeconfigs performance will be higher and still allow exported/collected
resources, but other usage external to Puppet might not work",
:hook => proc do |value|
- Puppet.settings[:storeconfigs] = true if value
+ Puppet.settings[:storeconfigs] = true if value
end
},
:config_version => ["", "How to determine the configuration version. By default, it will be the
@@ -186,7 +184,10 @@ module Puppet
fqdn = hostname
end
- Puppet.setdefaults(:main,
+
+ Puppet.setdefaults(
+ :main,
+
# We have to downcase the fqdn, because the current ssl stuff (as oppsed to in master) doesn't have good facilities for
# manipulating naming.
:certname => {:default => fqdn.downcase, :desc => "The name to use when handling certificates. Defaults
@@ -268,7 +269,9 @@ module Puppet
to all clients. If enabled, CA chaining will almost definitely not work."]
)
- setdefaults(:ca,
+
+ setdefaults(
+ :ca,
:ca_name => ["$certname", "The name to use the Certificate Authority certificate."],
:cadir => { :default => "$ssldir/ca",
:owner => "service",
@@ -297,6 +300,7 @@ module Puppet
:owner => "service",
:group => "service",
:mode => 0664,
+
:desc => "The certificate revocation list (CRL) for the CA. Will be used if present but otherwise ignored.",
:hook => proc do |value|
if value == 'false'
@@ -340,13 +344,13 @@ module Puppet
never autosigns any key request), and the path to a file, which
uses that configuration file to determine which keys to sign."},
:ca_days => ["", "How long a certificate should be valid.
- This parameter is deprecated, use ca_ttl instead"],
+ This parameter is deprecated, use ca_ttl instead"],
:ca_ttl => ["5y", "The default TTL for new certificates; valid values
- must be an integer, optionally followed by one of the units
- 'y' (years of 365 days), 'd' (days), 'h' (hours), or
- 's' (seconds). The unit defaults to seconds. If this parameter
- is set, ca_days is ignored. Examples are '3600' (one hour)
- and '1825d', which is the same as '5y' (5 years) "],
+ must be an integer, optionally followed by one of the units
+ 'y' (years of 365 days), 'd' (days), 'h' (hours), or
+ 's' (seconds). The unit defaults to seconds. If this parameter
+ is set, ca_days is ignored. Examples are '3600' (one hour)
+ and '1825d', which is the same as '5y' (5 years) "],
:ca_md => ["md5", "The type of hash used in certificates."],
:req_bits => [2048, "The bit length of the certificates."],
:keylength => [1024, "The bit length of keys."],
@@ -360,7 +364,9 @@ module Puppet
)
# Define the config default.
- setdefaults(Puppet.settings[:name],
+
+ setdefaults(
+ Puppet.settings[:name],
:config => ["$confdir/puppet.conf",
"The configuration file for #{Puppet[:name]}."],
:pidfile => ["$rundir/$name.pid", "The pid file"],
@@ -370,6 +376,7 @@ module Puppet
options are webrick and mongrel. If you use mongrel, you will need
a proxy in front of the process or processes, since Mongrel cannot
speak SSL.",
+
:call_on_define => true, # Call our hook with the default value, so we always get the correct bind address set.
:hook => proc { |value| value == "webrick" ? Puppet.settings[:bindaddress] = "0.0.0.0" : Puppet.settings[:bindaddress] = "127.0.0.1" if Puppet.settings[:bindaddress] == "" }
}
@@ -378,10 +385,8 @@ module Puppet
setdefaults(:master,
:user => ["puppet", "The user puppet master should run as."],
:group => ["puppet", "The group puppet master should run as."],
- :manifestdir => ["$confdir/manifests",
- "Where puppet master looks for its manifests."],
- :manifest => ["$manifestdir/site.pp",
- "The entry-point manifest for puppet master."],
+ :manifestdir => ["$confdir/manifests", "Where puppet master looks for its manifests."],
+ :manifest => ["$manifestdir/site.pp", "The entry-point manifest for puppet master."],
:code => ["", "Code to parse directly. This is essentially only used
by ``puppet``, and should only be set if you're writing your own Puppet
executable"],
@@ -402,11 +407,11 @@ module Puppet
:masterport => [8140, "Which port puppet master listens on."],
:parseonly => [false, "Just check the syntax of the manifests."],
:node_name => ["cert", "How the puppetmaster determines the client's identity
- and sets the 'hostname', 'fqdn' and 'domain' facts for use in the manifest,
- in particular for determining which 'node' statement applies to the client.
- Possible values are 'cert' (use the subject's CN in the client's
- certificate) and 'facter' (use the hostname that the client
- reported in its facts)"],
+ and sets the 'hostname', 'fqdn' and 'domain' facts for use in the manifest,
+ in particular for determining which 'node' statement applies to the client.
+ Possible values are 'cert' (use the subject's CN in the client's
+ certificate) and 'facter' (use the hostname that the client
+ reported in its facts)"],
:bucketdir => {
:default => "$vardir/bucket",
:mode => 0750,
@@ -421,7 +426,7 @@ module Puppet
],
:ca => [true, "Wether the master should function as a certificate authority."],
:modulepath => {:default => "$confdir/modules:/usr/share/puppet/modules",
- :desc => "The search path for modules as a colon-separated list of
+ :desc => "The search path for modules as a colon-separated list of
directories.", :type => :setting }, # We don't want this to be considered a file, since it's multiple files.
:ssl_client_header => ["HTTP_X_CLIENT_DN", "The header containing an authenticated
client's SSL DN. Only used with Mongrel. This header must be set by the proxy
@@ -442,8 +447,7 @@ module Puppet
in puppet/reports/name.rb, and multiple report names should be
comma-separated (whitespace is okay)."
],
- :fileserverconfig => ["$confdir/fileserver.conf",
- "Where the fileserver configuration is stored."],
+ :fileserverconfig => ["$confdir/fileserver.conf", "Where the fileserver configuration is stored."],
:rrddir => {:default => "$vardir/rrd",
:owner => "service",
:group => "service",
@@ -471,10 +475,8 @@ module Puppet
this file reflects the state discovered through interacting
with clients."
},
- :clientyamldir => {:default => "$vardir/client_yaml", :mode => "750",
- :desc => "The directory in which client-side YAML data is stored."},
- :client_datadir => {:default => "$vardir/client_data", :mode => "750",
- :desc => "The directory in which serialized data is stored on the client."},
+ :clientyamldir => {:default => "$vardir/client_yaml", :mode => "750", :desc => "The directory in which client-side YAML data is stored."},
+ :client_datadir => {:default => "$vardir/client_data", :mode => "750", :desc => "The directory in which serialized data is stored on the client."},
:classfile => { :default => "$statedir/classes.txt",
:owner => "root",
:mode => 0644,
@@ -487,8 +489,7 @@ module Puppet
:mode => 0640,
:desc => "The log file for puppet agent. This is generally not used."
},
- :server => ["puppet",
- "The server to which server puppet agent should connect"],
+ :server => ["puppet", "The server to which server puppet agent should connect"],
:ignoreschedules => [false,
"Boolean; whether puppet agent should ignore schedules. This is useful
for initial puppet agent runs."],
@@ -508,8 +509,8 @@ module Puppet
:catalog_format => {
:default => "",
:desc => "(Deprecated for 'preferred_serialization_format') What format to
- use to dump the catalog. Only supports 'marshal' and 'yaml'. Only
- matters on the client, since it asks the server for a specific format.",
+ use to dump the catalog. Only supports 'marshal' and 'yaml'. Only
+ matters on the client, since it asks the server for a specific format.",
:hook => proc { |value|
if value
Puppet.warning "Setting 'catalog_format' is deprecated; use 'preferred_serialization_format' instead."
@@ -522,8 +523,7 @@ module Puppet
instances will be serialized using this method, since not all classes
can be guaranteed to support this format, but it will be used for all
classes that support it."],
- :puppetdlockfile => [ "$statedir/puppetdlock",
- "A lock file to temporarily stop puppet agent from doing anything."],
+ :puppetdlockfile => [ "$statedir/puppetdlock", "A lock file to temporarily stop puppet agent from doing anything."],
:usecacheonfailure => [true,
"Whether to use the cached configuration when the remote
configuration will not compile. This option is useful for testing
@@ -540,8 +540,7 @@ module Puppet
fact be stale even if the timestamps are up to date - if the facts
change or if the server changes."
],
- :downcasefacts => [false,
- "Whether facts should be made all lowercase when sent to the server."],
+ :downcasefacts => [false, "Whether facts should be made all lowercase when sent to the server."],
:dynamicfacts => ["memorysize,memoryfree,swapsize,swapfree",
"Facts that are dynamic; these facts will be ignored when deciding whether
changed facts should result in a recompile. Multiple facts should be
@@ -567,16 +566,16 @@ module Puppet
:call_on_define => false,
:desc => "(Deprecated for 'report_server') The server to which to send transaction reports.",
:hook => proc do |value|
- if value
- Puppet.settings[:report_server] = value
- end
+ if value
+ Puppet.settings[:report_server] = value
+ end
end
},
:report_server => ["$server",
- "The server to which to send transaction reports."
+ "The server to which to send transaction reports."
],
:report_port => ["$masterport",
- "The port to communicate with the report_server."
+ "The port to communicate with the report_server."
],
:report => [false,
"Whether to send reports after every transaction."
@@ -588,31 +587,35 @@ module Puppet
:http_compression => [false, "Allow http compression in REST communication with the master.
This setting might improve performance for agent -> master communications over slow WANs.
Your puppetmaster needs to support compression (usually by activating some settings in a reverse-proxy
- in front of the puppetmaster, which rules out webrick).
+ in front of the puppetmaster, which rules out webrick).
It is harmless to activate this settings if your master doesn't support
compression, but if it supports it, this setting might reduce performance on high-speed LANs."]
)
# Plugin information.
- setdefaults(:main,
+
+ setdefaults(
+ :main,
:plugindest => ["$libdir",
"Where Puppet should store plugins that it pulls down from the central
server."],
:pluginsource => ["puppet://$server/plugins",
"From where to retrieve plugins. The standard Puppet ``file`` type
- is used for retrieval, so anything that is a valid file source can
- be used here."],
- :pluginsync => [false,
- "Whether plugins should be synced with the central server."],
- :pluginsignore => [".svn CVS .git",
- "What files to ignore when pulling down plugins."]
+ is used for retrieval, so anything that is a valid file source can
+ be used here."],
+ :pluginsync => [false, "Whether plugins should be synced with the central server."],
+
+ :pluginsignore => [".svn CVS .git", "What files to ignore when pulling down plugins."]
)
# Central fact information.
- setdefaults(:main,
+
+ setdefaults(
+ :main,
:factpath => {:default => "$vardir/lib/facter/${File::PATH_SEPARATOR}$vardir/facts",
:desc => "Where Puppet should look for facts. Multiple directories should
be colon-separated, like normal PATH variables.",
+
:call_on_define => true, # Call our hook with the default value, so we always get the value added to facter.
:type => :setting, # Don't consider it a file, because it could be multiple colon-separated files
:hook => proc { |value| Facter.search(value) if Facter.respond_to?(:search) }},
@@ -621,35 +624,34 @@ module Puppet
server."],
:factsource => ["puppet://$server/facts/",
"From where to retrieve facts. The standard Puppet ``file`` type
- is used for retrieval, so anything that is a valid file source can
- be used here."],
- :factsync => [false,
- "Whether facts should be synced with the central server."],
- :factsignore => [".svn CVS",
- "What files to ignore when pulling down facts."],
+ is used for retrieval, so anything that is a valid file source can
+ be used here."],
+ :factsync => [false, "Whether facts should be synced with the central server."],
+ :factsignore => [".svn CVS", "What files to ignore when pulling down facts."],
:reportdir => {:default => "$vardir/reports",
- :mode => 0750,
- :owner => "service",
- :group => "service",
- :desc => "The directory in which to store reports
- received from the client. Each client gets a separate
- subdirectory."},
+ :mode => 0750,
+ :owner => "service",
+ :group => "service",
+ :desc => "The directory in which to store reports
+ received from the client. Each client gets a separate
+ subdirectory."},
:reporturl => ["http://localhost:3000/reports",
"The URL used by the http reports processor to send reports"]
- )
-
- setdefaults(:tagmail,
- :tagmap => ["$confdir/tagmail.conf",
- "The mapping between reporting tags and email addresses."],
- :sendmail => [%x{which sendmail 2>/dev/null}.chomp,
- "Where to find the sendmail binary with which to send email."],
- :reportfrom => ["report@" + [Facter["hostname"].value, Facter["domain"].value].join("."),
- "The 'from' email address for the reports."],
- :smtpserver => ["none",
- "The server through which to send email reports."]
)
- setdefaults(:rails,
+
+ setdefaults(
+ :tagmail,
+ :tagmap => ["$confdir/tagmail.conf", "The mapping between reporting tags and email addresses."],
+ :sendmail => [%x{which sendmail 2>/dev/null}.chomp, "Where to find the sendmail binary with which to send email."],
+
+ :reportfrom => ["report@" + [Facter["hostname"].value, Facter["domain"].value].join("."), "The 'from' email address for the reports."],
+ :smtpserver => ["none", "The server through which to send email reports."]
+ )
+
+
+ setdefaults(
+ :rails,
:dblocation => { :default => "$statedir/clientconfigs.sqlite3",
:mode => 0660,
:owner => "service",
@@ -679,16 +681,22 @@ module Puppet
:group => "service",
:desc => "Where Rails-specific logs are sent"
},
+
:rails_loglevel => ["info", "The log level for Rails connections. The value must be
a valid log level within Rails. Production environments normally use ``info``
and other environments normally use ``debug``."]
)
- setdefaults(:couchdb,
+
+ setdefaults(
+ :couchdb,
+
:couchdb_url => ["http://127.0.0.1:5984/puppet", "The url where the puppet couchdb database will be created"]
)
- setdefaults(:transaction,
+
+ setdefaults(
+ :transaction,
:tags => ["", "Tags to use to find resources. If this is set, then
only resources tagged with the specified tags will be applied.
Values must be comma-separated."],
@@ -696,12 +704,16 @@ module Puppet
being evaluated. This allows you to interactively see exactly
what is being done."],
:summarize => [false,
+
"Whether to print a transaction summary."
]
)
- setdefaults(:main,
+
+ setdefaults(
+ :main,
:external_nodes => ["none",
+
"An external command that can produce node information. The output
must be a YAML dump of a hash, and that hash must have one or both of
``classes`` and ``parameters``, where ``classes`` is an array and
@@ -711,7 +723,9 @@ module Puppet
This command makes it straightforward to store your node mapping
information in other data sources like databases."])
- setdefaults(:ldap,
+
+ setdefaults(
+ :ldap,
:ldapnodes => [false,
"Whether to search for node configurations in LDAP. See
http://projects.puppetlabs.com/projects/puppet/wiki/LDAP_Nodes for more information."],
@@ -727,6 +741,7 @@ module Puppet
"The LDAP server. Only used if ``ldapnodes`` is enabled."],
:ldapport => [389,
"The LDAP port. Only used if ``ldapnodes`` is enabled."],
+
:ldapstring => ["(&(objectclass=puppetClient)(cn=%s))",
"The search string used to find an LDAP node."],
:ldapclassattrs => ["puppetclass",
@@ -746,8 +761,7 @@ module Puppet
:ldapuser => ["",
"The user to use to connect to LDAP. Must be specified as a
full DN."],
- :ldappassword => ["",
- "The password to use to connect to LDAP."],
+ :ldappassword => ["", "The password to use to connect to LDAP."],
:ldapbase => ["",
"The search base for LDAP searches. It's impossible to provide
a meaningful default here, although the LDAP libraries might
@@ -774,11 +788,14 @@ module Puppet
)
# This doesn't actually work right now.
- setdefaults(:parser,
+
+ setdefaults(
+ :parser,
+
:lexical => [false, "Whether to use lexical scoping (vs. dynamic)."],
:templatedir => ["$vardir/templates",
"Where Puppet looks for template files. Can be a list of colon-seperated
- directories."
+ directories."
]
)
end
diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb
index 971b31116..66c4f19a6 100644
--- a/lib/puppet/error.rb
+++ b/lib/puppet/error.rb
@@ -6,7 +6,7 @@ module Puppet # :nodoc:
attr_accessor :line, :file
def backtrace
- if defined? @backtrace
+ if defined?(@backtrace)
return @backtrace
else
return super
@@ -23,11 +23,9 @@ module Puppet # :nodoc:
def to_s
str = nil
if self.file and self.line
- str = "%s at %s:%s" %
- [@message.to_s, @file, @line]
+ str = "%s at %s:%s" % [@message.to_s, @file, @line]
elsif self.line
- str = "%s at line %s" %
- [@message.to_s, @line]
+ str = "%s at line %s" % [@message.to_s, @line]
elsif self.file
str = "%s in %s" % [@message.to_s, self.file]
else
diff --git a/lib/puppet/external/base64.rb b/lib/puppet/external/base64.rb
index 4030ad358..1005c8f2f 100755
--- a/lib/puppet/external/base64.rb
+++ b/lib/puppet/external/base64.rb
@@ -6,7 +6,7 @@
require 'base64'
-unless defined? Base64
+unless defined?(Base64)
class Base64
def Base64.encode64(*args)
Object.method(:encode64).call(*args)
diff --git a/lib/puppet/external/event-loop/better-definers.rb b/lib/puppet/external/event-loop/better-definers.rb
index 5d6175fe9..c600fc208 100644
--- a/lib/puppet/external/event-loop/better-definers.rb
+++ b/lib/puppet/external/event-loop/better-definers.rb
@@ -69,7 +69,7 @@ class Module
new_aliases.kind_of? Array or new_aliases = [new_aliases]
for new_alias in new_aliases do
class_eval %{def #{new_alias}(*args, &block)
- #{existing_name}(*args, &block) end}
+ #{existing_name}(*args, &block) end}
end
end
end
@@ -94,7 +94,7 @@ class Module
end
def writer_defined? (name)
- method_defined? name.to_sym.writer
+ method_defined?(name.to_sym.writer)
end
# If you pass a predicate symbol :foo? to this method, it'll first
@@ -110,7 +110,7 @@ class Module
end
if name.predicate?
class_eval %{def #{name.imperative}
- self.#{name.writer} true end}
+ self.#{name.writer} true end}
end
end
end
@@ -130,7 +130,7 @@ class Module
def define_opposite_readers (name_pairs)
name_pairs.collect! { |k, v| [k.to_sym, v.to_sym] }
for opposite_name, name in name_pairs do
- define_reader(name) unless method_defined? name
+ define_reader(name) unless method_defined?(name)
class_eval %{def #{opposite_name} ; not #{name} end}
end
end
@@ -138,11 +138,11 @@ class Module
def define_opposite_writers (name_pairs)
name_pairs.collect! { |k, v| [k.to_sym, v.to_sym] }
for opposite_name, name in name_pairs do
- define_writer(name) unless writer_defined? name
+ define_writer(name) unless writer_defined?(name)
class_eval %{def #{opposite_name.writer} x
- self.#{name.writer} !x end}
+ self.#{name.writer} !x end}
class_eval %{def #{opposite_name.imperative}
- self.#{name.writer} false end}
+ self.#{name.writer} false end}
end
end
@@ -167,7 +167,7 @@ class Module
define_opposite_writer(opposite_name => name)
end
- public :define_method
+ public :define_method
def define_methods (*names, &body)
names.each { |name| define_method(name, &body) }
diff --git a/lib/puppet/external/event-loop/event-loop.rb b/lib/puppet/external/event-loop/event-loop.rb
index 75febab80..06fa34607 100644
--- a/lib/puppet/external/event-loop/event-loop.rb
+++ b/lib/puppet/external/event-loop/event-loop.rb
@@ -118,7 +118,7 @@ class EventLoop
end
end
- private
+ private
def select (timeout)
@wakeup_time = timeout ? Time.now + timeout : nil
@@ -130,7 +130,7 @@ class EventLoop
@timers.each { |x| x.sound_alarm if x.ready? }
end
- public
+ public
def quit ; stopped! ; wake_up ; self end
diff --git a/lib/puppet/external/event-loop/signal-system.rb b/lib/puppet/external/event-loop/signal-system.rb
index 07feb9bf0..8d97c4359 100644
--- a/lib/puppet/external/event-loop/signal-system.rb
+++ b/lib/puppet/external/event-loop/signal-system.rb
@@ -35,7 +35,7 @@ module SignalEmitterModule
def define_signal (name, slot=:before, &body)
# Can't use `define_method' and take a block pre-1.9.
class_eval %{ def on_#{name} &block
- add_signal_handler(:#{name}, &block) end }
+ add_signal_handler(:#{name}, &block) end }
define_signal_handler(name, :before, &lambda {|*a|})
define_signal_handler(name, :after, &lambda {|*a|})
define_signal_handler(name, slot, &body) if block_given?
@@ -160,7 +160,7 @@ module SignalObserver
names.each { |x| __ignore_signal_1(subject, x) }
end
- private
+ private
def __ignore_signal_1(subject, name)
@observed_signals[subject][name].each do |handler|
diff --git a/lib/puppet/external/nagios/base.rb b/lib/puppet/external/nagios/base.rb
index 69c2c6aab..1b49459a4 100755
--- a/lib/puppet/external/nagios/base.rb
+++ b/lib/puppet/external/nagios/base.rb
@@ -63,7 +63,7 @@ class Nagios::Base
# Return a mapping (or nil) for a param
def self.mapping(name)
name = name.intern if name.is_a? String
- if defined? @map
+ if defined?(@map)
@map[name]
else
nil
@@ -72,7 +72,7 @@ class Nagios::Base
# Return the namevar for the canonical name.
def self.namevar
- if defined? @namevar
+ if defined?(@namevar)
return @namevar
else
if parameter?(:name)
@@ -157,7 +157,7 @@ class Nagios::Base
# Whether a given parameter is suppressed.
def self.suppress?(name)
- defined? @suppress and @suppress.include?(name)
+ defined?(@suppress) and @suppress.include?(name)
end
# Return our name as the string.
@@ -197,7 +197,7 @@ class Nagios::Base
self[param] = value
}
if @namevar == :_naginator_name
- self['_naginator_name'] = self['name']
+ self['_naginator_name'] = self['name']
end
end
@@ -241,7 +241,7 @@ class Nagios::Base
end
def parammap(param)
- unless defined? @map
+ unless defined?(@map)
map = {
self.namevar => "cn"
}
@@ -257,7 +257,7 @@ class Nagios::Base
end
def parent
- unless defined? self.class.attached
+ unless defined?(self.class.attached)
puts "Duh, you called parent on an unattached class"
return
end
@@ -346,9 +346,9 @@ class Nagios::Base
end
newtype :hostgroup do
- setparameters :hostgroup_name, :alias, :members, :hostgroup_members, :notes,
- :notes_url, :action_url,
- :register, :use
+ setparameters :hostgroup_name, :alias, :members, :hostgroup_members, :notes,
+ :notes_url, :action_url,
+ :register, :use
end
newtype :service do
@@ -434,14 +434,14 @@ class Nagios::Base
end
newtype :hostdependency do
- auxiliary = true
- setparameters :dependent_host_name, :dependent_hostgroup_name, :host_name,
- :hostgroup_name, :inherits_parent, :execution_failure_criteria,
- :notification_failure_criteria, :dependency_period,
- :register, :use,
- :_naginator_name
-
- setnamevar :_naginator_name
+ auxiliary = true
+ setparameters :dependent_host_name, :dependent_hostgroup_name, :host_name,
+ :hostgroup_name, :inherits_parent, :execution_failure_criteria,
+ :notification_failure_criteria, :dependency_period,
+ :register, :use,
+ :_naginator_name
+
+ setnamevar :_naginator_name
end
newtype :hostescalation do
diff --git a/lib/puppet/external/nagios/parser.rb b/lib/puppet/external/nagios/parser.rb
index 498b0884e..deea9f3bc 100644
--- a/lib/puppet/external/nagios/parser.rb
+++ b/lib/puppet/external/nagios/parser.rb
@@ -25,433 +25,432 @@ self.class.module_eval <<'..end racc/parser.rb modeval..id5256434e8a', 'racc/par
#
unless defined?(NotImplementedError)
- NotImplementedError = NotImplementError
+ NotImplementedError = NotImplementError
end
module Racc
- class ParseError < StandardError; end
+ class ParseError < StandardError; end
end
unless defined?(::ParseError)
- ParseError = Racc::ParseError
+ ParseError = Racc::ParseError
end
module Racc
- unless defined?(Racc_No_Extentions)
- Racc_No_Extentions = false
- end
-
- class Parser
-
- Racc_Runtime_Version = '1.4.5'
- Racc_Runtime_Revision = '$Revision: 1.7 $'.split[1]
-
- Racc_Runtime_Core_Version_R = '1.4.5'
- Racc_Runtime_Core_Revision_R = '$Revision: 1.7 $'.split[1]
- begin
- require 'racc/cparse'
- # Racc_Runtime_Core_Version_C = (defined in extention)
- Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
- unless new.respond_to?(:_racc_do_parse_c, true)
- raise LoadError, 'old cparse.so'
- end
- if Racc_No_Extentions
- raise LoadError, 'selecting ruby version of racc runtime core'
- end
-
- Racc_Main_Parsing_Routine = :_racc_do_parse_c
- Racc_YY_Parse_Method = :_racc_yyparse_c
- Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C
- Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C
- Racc_Runtime_Type = 'c'
- rescue LoadError
- Racc_Main_Parsing_Routine = :_racc_do_parse_rb
- Racc_YY_Parse_Method = :_racc_yyparse_rb
- Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
- Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
- Racc_Runtime_Type = 'ruby'
+ unless defined?(Racc_No_Extentions)
+ Racc_No_Extentions = false
end
- def Parser.racc_runtime_type
- Racc_Runtime_Type
- end
+ class Parser
- private
-
- def _racc_setup
- @yydebug = false unless self.class::Racc_debug_parser
- @yydebug = false unless defined?(@yydebug)
- if @yydebug
- @racc_debug_out = $stderr unless defined?(@racc_debug_out)
- @racc_debug_out ||= $stderr
- end
- arg = self.class::Racc_arg
- arg[13] = true if arg.size < 14
- arg
- end
+ Racc_Runtime_Version = '1.4.5'
+ Racc_Runtime_Revision = '$Revision: 1.7 $'.split[1]
- def _racc_init_sysvars
- @racc_state = [0]
- @racc_tstack = []
- @racc_vstack = []
+ Racc_Runtime_Core_Version_R = '1.4.5'
+ Racc_Runtime_Core_Revision_R = '$Revision: 1.7 $'.split[1]
+ begin
+ require 'racc/cparse'
+ # Racc_Runtime_Core_Version_C = (defined in extention)
+ Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
+ unless new.respond_to?(:_racc_do_parse_c, true)
+ raise LoadError, 'old cparse.so'
+ end
+ if Racc_No_Extentions
+ raise LoadError, 'selecting ruby version of racc runtime core'
+ end
- @racc_t = nil
- @racc_val = nil
+ Racc_Main_Parsing_Routine = :_racc_do_parse_c
+ Racc_YY_Parse_Method = :_racc_yyparse_c
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C
+ Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C
+ Racc_Runtime_Type = 'c'
+ rescue LoadError
+ Racc_Main_Parsing_Routine = :_racc_do_parse_rb
+ Racc_YY_Parse_Method = :_racc_yyparse_rb
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
+ Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
+ Racc_Runtime_Type = 'ruby'
+ end
- @racc_read_next = true
+ def Parser.racc_runtime_type
+ Racc_Runtime_Type
+ end
- @racc_user_yyerror = false
- @racc_error_status = 0
- end
+ private
- ###
- ### do_parse
- ###
+ def _racc_setup
+ @yydebug = false unless self.class::Racc_debug_parser
+ @yydebug = false unless defined?(@yydebug)
+ if @yydebug
+ @racc_debug_out = $stderr unless defined?(@racc_debug_out)
+ @racc_debug_out ||= $stderr
+ end
+ arg = self.class::Racc_arg
+ arg[13] = true if arg.size < 14
+ arg
+ end
- def do_parse
- __send__(Racc_Main_Parsing_Routine, _racc_setup(), false)
- end
+ def _racc_init_sysvars
+ @racc_state = [0]
+ @racc_tstack = []
+ @racc_vstack = []
- def next_token
- raise NotImplementedError, "#{self.class}\#next_token is not defined"
- end
+ @racc_t = nil
+ @racc_val = nil
+
+ @racc_read_next = true
+
+ @racc_user_yyerror = false
+ @racc_error_status = 0
+ end
+
+ ###
+ ### do_parse
+ ###
+
+ def do_parse
+ __send__(Racc_Main_Parsing_Routine, _racc_setup(), false)
+ end
- def _racc_do_parse_rb(arg, in_debug)
- action_table, action_check, action_default, action_pointer,
- goto_table, goto_check, goto_default, goto_pointer,
- nt_base, reduce_table, token_table, shift_n,
- reduce_n, use_result, * = arg
-
- _racc_init_sysvars
- tok = act = i = nil
- nerr = 0
-
- catch(:racc_end_parse) {
- while true
- if i = action_pointer[@racc_state[-1]]
- if @racc_read_next
- if @racc_t != 0 # not EOF
- tok, @racc_val = next_token()
- unless tok # EOF
- @racc_t = 0
+ def next_token
+ raise NotImplementedError, "#{self.class}\#next_token is not defined"
+ end
+
+ def _racc_do_parse_rb(arg, in_debug)
+ action_table, action_check, action_default, action_pointer,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, token_table, shift_n,
+ reduce_n, use_result, * = arg
+
+ _racc_init_sysvars
+ tok = act = i = nil
+ nerr = 0
+
+ catch(:racc_end_parse) {
+ while true
+ if i = action_pointer[@racc_state[-1]]
+ if @racc_read_next
+ if @racc_t != 0 # not EOF
+ tok, @racc_val = next_token()
+ unless tok # EOF
+ @racc_t = 0
+ else
+ @racc_t = (token_table[tok] or 1) # error token
+ end
+ racc_read_token(@racc_t, tok, @racc_val) if @yydebug
+ @racc_read_next = false
+ end
+ end
+ i += @racc_t
+ unless i >= 0 and
+ act = action_table[i] and
+ action_check[i] == @racc_state[-1]
+ act = action_default[@racc_state[-1]]
+ end
else
- @racc_t = (token_table[tok] or 1) # error token
+ act = action_default[@racc_state[-1]]
+ end
+ while act = _racc_evalact(act, arg)
+ ;
end
- racc_read_token(@racc_t, tok, @racc_val) if @yydebug
- @racc_read_next = false
- end
- end
- i += @racc_t
- unless i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
end
- else
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
- end
- }
- end
+ }
+ end
- ###
- ### yyparse
- ###
+ ###
+ ### yyparse
+ ###
- def yyparse(recv, mid)
- __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
- end
+ def yyparse(recv, mid)
+ __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
+ end
- def _racc_yyparse_rb(recv, mid, arg, c_debug)
- action_table, action_check, action_default, action_pointer,
- goto_table, goto_check, goto_default, goto_pointer,
- nt_base, reduce_table, token_table, shift_n,
- reduce_n, use_result, * = arg
-
- _racc_init_sysvars
- tok = nil
- act = nil
- i = nil
- nerr = 0
-
- catch(:racc_end_parse) {
- until i = action_pointer[@racc_state[-1]]
- while act = _racc_evalact(action_default[@racc_state[-1]], arg)
- ;
- end
- end
- recv.__send__(mid) do |tok, val|
- unless tok
- @racc_t = 0
- else
- @racc_t = (token_table[tok] or 1) # error token
- end
- @racc_val = val
- @racc_read_next = false
-
- i += @racc_t
- unless i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
-
- while not (i = action_pointer[@racc_state[-1]]) or
- not @racc_read_next or
- @racc_t == 0 # $
- unless i and i += @racc_t and
- i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
+ def _racc_yyparse_rb(recv, mid, arg, c_debug)
+ action_table, action_check, action_default, action_pointer,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, token_table, shift_n,
+ reduce_n, use_result, * = arg
+
+ _racc_init_sysvars
+ tok = nil
+ act = nil
+ i = nil
+ nerr = 0
+
+ catch(:racc_end_parse) {
+ until i = action_pointer[@racc_state[-1]]
+ while act = _racc_evalact(action_default[@racc_state[-1]], arg)
+ ;
+ end
end
- while act = _racc_evalact(act, arg)
- ;
+ recv.__send__(mid) do |tok, val|
+ unless tok
+ @racc_t = 0
+ else
+ @racc_t = (token_table[tok] or 1) # error token
+ end
+ @racc_val = val
+ @racc_read_next = false
+
+ i += @racc_t
+ unless i >= 0 and
+ act = action_table[i] and
+ action_check[i] == @racc_state[-1]
+ act = action_default[@racc_state[-1]]
+ end
+ while act = _racc_evalact(act, arg)
+ ;
+ end
+
+ while not (i = action_pointer[@racc_state[-1]]) or
+ not @racc_read_next or
+ @racc_t == 0 # $
+ unless i and i += @racc_t and
+ i >= 0 and
+ act = action_table[i] and
+ action_check[i] == @racc_state[-1]
+ act = action_default[@racc_state[-1]]
+ end
+ while act = _racc_evalact(act, arg)
+ ;
+ end
+ end
end
- end
+ }
end
- }
- end
-
- ###
- ### common
- ###
- def _racc_evalact(act, arg)
- action_table, action_check, action_default, action_pointer,
- goto_table, goto_check, goto_default, goto_pointer,
- nt_base, reduce_table, token_table, shift_n,
- reduce_n, use_result, * = arg
- nerr = 0 # tmp
+ ###
+ ### common
+ ###
+
+ def _racc_evalact(act, arg)
+ action_table, action_check, action_default, action_pointer,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, token_table, shift_n,
+ reduce_n, use_result, * = arg
+ nerr = 0 # tmp
+
+ if act > 0 and act < shift_n
+ #
+ # shift
+ #
+ if @racc_error_status > 0
+ @racc_error_status -= 1 unless @racc_t == 1 # error token
+ end
+ @racc_vstack.push @racc_val
+ @racc_state.push act
+ @racc_read_next = true
+ if @yydebug
+ @racc_tstack.push @racc_t
+ racc_shift @racc_t, @racc_tstack, @racc_vstack
+ end
- if act > 0 and act < shift_n
- #
- # shift
- #
- if @racc_error_status > 0
- @racc_error_status -= 1 unless @racc_t == 1 # error token
- end
- @racc_vstack.push @racc_val
- @racc_state.push act
- @racc_read_next = true
- if @yydebug
- @racc_tstack.push @racc_t
- racc_shift @racc_t, @racc_tstack, @racc_vstack
- end
+ elsif act < 0 and act > -reduce_n
+ #
+ # reduce
+ #
+ code = catch(:racc_jump) {
+ @racc_state.push _racc_do_reduce(arg, act)
+ false
+ }
+ if code
+ case code
+ when 1 # yyerror
+ @racc_user_yyerror = true # user_yyerror
+ return -reduce_n
+ when 2 # yyaccept
+ return shift_n
+ else
+ raise '[Racc Bug] unknown jump code'
+ end
+ end
- elsif act < 0 and act > -reduce_n
- #
- # reduce
- #
- code = catch(:racc_jump) {
- @racc_state.push _racc_do_reduce(arg, act)
- false
- }
- if code
- case code
- when 1 # yyerror
- @racc_user_yyerror = true # user_yyerror
- return -reduce_n
- when 2 # yyaccept
- return shift_n
- else
- raise '[Racc Bug] unknown jump code'
- end
- end
-
- elsif act == shift_n
- #
- # accept
- #
- racc_accept if @yydebug
- throw :racc_end_parse, @racc_vstack[0]
+ elsif act == shift_n
+ #
+ # accept
+ #
+ racc_accept if @yydebug
+ throw :racc_end_parse, @racc_vstack[0]
+
+ elsif act == -reduce_n
+ #
+ # error
+ #
+ case @racc_error_status
+ when 0
+ unless arg[21] # user_yyerror
+ nerr += 1
+ on_error @racc_t, @racc_val, @racc_vstack
+ end
+ when 3
+ if @racc_t == 0 # is $
+ throw :racc_end_parse, nil
+ end
+ @racc_read_next = true
+ end
+ @racc_user_yyerror = false
+ @racc_error_status = 3
+ while true
+ if i = action_pointer[@racc_state[-1]]
+ i += 1 # error token
+ if i >= 0 and
+ (act = action_table[i]) and
+ action_check[i] == @racc_state[-1]
+ break
+ end
+ end
+ throw :racc_end_parse, nil if @racc_state.size <= 1
+ @racc_state.pop
+ @racc_vstack.pop
+ if @yydebug
+ @racc_tstack.pop
+ racc_e_pop @racc_state, @racc_tstack, @racc_vstack
+ end
+ end
+ return act
- elsif act == -reduce_n
- #
- # error
- #
- case @racc_error_status
- when 0
- unless arg[21] # user_yyerror
- nerr += 1
- on_error @racc_t, @racc_val, @racc_vstack
- end
- when 3
- if @racc_t == 0 # is $
- throw :racc_end_parse, nil
- end
- @racc_read_next = true
- end
- @racc_user_yyerror = false
- @racc_error_status = 3
- while true
- if i = action_pointer[@racc_state[-1]]
- i += 1 # error token
- if i >= 0 and
- (act = action_table[i]) and
- action_check[i] == @racc_state[-1]
- break
+ else
+ raise "[Racc Bug] unknown action #{act.inspect}"
end
- end
- throw :racc_end_parse, nil if @racc_state.size <= 1
- @racc_state.pop
- @racc_vstack.pop
- if @yydebug
- @racc_tstack.pop
- racc_e_pop @racc_state, @racc_tstack, @racc_vstack
- end
+
+ racc_next_state(@racc_state[-1], @racc_state) if @yydebug
+
+ nil
end
- return act
- else
- raise "[Racc Bug] unknown action #{act.inspect}"
- end
+ def _racc_do_reduce(arg, act)
+ action_table, action_check, action_default, action_pointer,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, token_table, shift_n,
+ reduce_n, use_result, * = arg
+ state = @racc_state
+ vstack = @racc_vstack
+ tstack = @racc_tstack
+
+ i = act * -3
+ len = reduce_table[i]
+ reduce_to = reduce_table[i+1]
+ method_id = reduce_table[i+2]
+ void_array = []
+
+ tmp_t = tstack[-len, len] if @yydebug
+ tmp_v = vstack[-len, len]
+ tstack[-len, len] = void_array if @yydebug
+ vstack[-len, len] = void_array
+ state[-len, len] = void_array
+
+ # tstack must be updated AFTER method call
+ if use_result
+ vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
+ else
+ vstack.push __send__(method_id, tmp_v, vstack)
+ end
+ tstack.push reduce_to
+
+ racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
- racc_next_state(@racc_state[-1], @racc_state) if @yydebug
+ k1 = reduce_to - nt_base
+ if i = goto_pointer[k1]
+ i += state[-1]
+ if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
+ return curstate
+ end
+ end
+ goto_default[k1]
+ end
- nil
- end
+ def on_error(t, val, vstack)
+ raise ParseError, sprintf("\nparse error on value %s (%s)", val.inspect, token_to_str(t) || '?')
+ end
- def _racc_do_reduce(arg, act)
- action_table, action_check, action_default, action_pointer,
- goto_table, goto_check, goto_default, goto_pointer,
- nt_base, reduce_table, token_table, shift_n,
- reduce_n, use_result, * = arg
- state = @racc_state
- vstack = @racc_vstack
- tstack = @racc_tstack
-
- i = act * -3
- len = reduce_table[i]
- reduce_to = reduce_table[i+1]
- method_id = reduce_table[i+2]
- void_array = []
-
- tmp_t = tstack[-len, len] if @yydebug
- tmp_v = vstack[-len, len]
- tstack[-len, len] = void_array if @yydebug
- vstack[-len, len] = void_array
- state[-len, len] = void_array
-
- # tstack must be updated AFTER method call
- if use_result
- vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
- else
- vstack.push __send__(method_id, tmp_v, vstack)
- end
- tstack.push reduce_to
-
- racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
-
- k1 = reduce_to - nt_base
- if i = goto_pointer[k1]
- i += state[-1]
- if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
- return curstate
- end
- end
- goto_default[k1]
- end
+ def yyerror
+ throw :racc_jump, 1
+ end
- def on_error(t, val, vstack)
- raise ParseError, sprintf("\nparse error on value %s (%s)",
- val.inspect, token_to_str(t) || '?')
- end
+ def yyaccept
+ throw :racc_jump, 2
+ end
- def yyerror
- throw :racc_jump, 1
- end
+ def yyerrok
+ @racc_error_status = 0
+ end
- def yyaccept
- throw :racc_jump, 2
- end
+ #
+ # for debugging output
+ #
- def yyerrok
- @racc_error_status = 0
- end
+ def racc_read_token(t, tok, val)
+ @racc_debug_out.print 'read '
+ @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
+ @racc_debug_out.puts val.inspect
+ @racc_debug_out.puts
+ end
- #
- # for debugging output
- #
+ def racc_shift(tok, tstack, vstack)
+ @racc_debug_out.puts "shift #{racc_token2str tok}"
+ racc_print_stacks tstack, vstack
+ @racc_debug_out.puts
+ end
- def racc_read_token(t, tok, val)
- @racc_debug_out.print 'read '
- @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
- @racc_debug_out.puts val.inspect
- @racc_debug_out.puts
- end
+ def racc_reduce(toks, sim, tstack, vstack)
+ out = @racc_debug_out
+ out.print 'reduce '
+ if toks.empty?
+ out.print ' <none>'
+ else
+ toks.each {|t| out.print ' ', racc_token2str(t) }
+ end
+ out.puts " --> #{racc_token2str(sim)}"
- def racc_shift(tok, tstack, vstack)
- @racc_debug_out.puts "shift #{racc_token2str tok}"
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
+ racc_print_stacks tstack, vstack
+ @racc_debug_out.puts
+ end
- def racc_reduce(toks, sim, tstack, vstack)
- out = @racc_debug_out
- out.print 'reduce '
- if toks.empty?
- out.print ' <none>'
- else
- toks.each {|t| out.print ' ', racc_token2str(t) }
- end
- out.puts " --> #{racc_token2str(sim)}"
-
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
+ def racc_accept
+ @racc_debug_out.puts 'accept'
+ @racc_debug_out.puts
+ end
- def racc_accept
- @racc_debug_out.puts 'accept'
- @racc_debug_out.puts
- end
+ def racc_e_pop(state, tstack, vstack)
+ @racc_debug_out.puts 'error recovering mode: pop token'
+ racc_print_states state
+ racc_print_stacks tstack, vstack
+ @racc_debug_out.puts
+ end
- def racc_e_pop(state, tstack, vstack)
- @racc_debug_out.puts 'error recovering mode: pop token'
- racc_print_states state
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
+ def racc_next_state(curstate, state)
+ @racc_debug_out.puts "goto #{curstate}"
+ racc_print_states state
+ @racc_debug_out.puts
+ end
- def racc_next_state(curstate, state)
- @racc_debug_out.puts "goto #{curstate}"
- racc_print_states state
- @racc_debug_out.puts
- end
+ def racc_print_stacks(t, v)
+ out = @racc_debug_out
+ out.print ' ['
+ t.each_index do |i|
+ out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
+ end
+ out.puts ' ]'
+ end
- def racc_print_stacks(t, v)
- out = @racc_debug_out
- out.print ' ['
- t.each_index do |i|
- out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
- end
- out.puts ' ]'
- end
+ def racc_print_states(s)
+ out = @racc_debug_out
+ out.print ' ['
+ s.each {|st| out.print ' ', st }
+ out.puts ' ]'
+ end
- def racc_print_states(s)
- out = @racc_debug_out
- out.print ' ['
- s.each {|st| out.print ' ', st }
- out.puts ' ]'
- end
+ def racc_token2str(tok)
+ self.class::Racc_token_to_s_table[tok] or
+ raise "[Racc Bug] can't convert token #{tok} to string"
+ end
- def racc_token2str(tok)
- self.class::Racc_token_to_s_table[tok] or
- raise "[Racc Bug] can't convert token #{tok} to string"
- end
+ def token_to_str(t)
+ self.class::Racc_token_to_s_table[t]
+ end
- def token_to_str(t)
- self.class::Racc_token_to_s_table[t]
end
- end
-
end
..end racc/parser.rb modeval..id5256434e8a
end
@@ -460,68 +459,68 @@ end
module Nagios
- class Parser < Racc::Parser
+ class Parser < Racc::Parser
module_eval <<'..end grammar.ry modeval..idcb2ea30b34', 'grammar.ry', 57
class ::Nagios::Parser::SyntaxError < RuntimeError; end
def parse(src)
- @src = src
+ @src = src
- # state variables
- @invar = false
- @inobject = false
- @done = false
+ # state variables
+ @invar = false
+ @inobject = false
+ @done = false
- @line = 0
- @yydebug = true
+ @line = 0
+ @yydebug = true
do_parse
end
# The lexer. Very simple.
def token
- @src.sub!(/\A\n/,'')
- if $&
- @line += 1
- return [ :RETURN, "\n" ]
- end
-
- if @done
- return nil
- end
- yytext = String.new
-
-
- # remove comments from this line
- @src.sub!(/\A[ \t]*;.*\n/,"\n")
- if $&
- return [:INLINECOMMENT, ""]
- end
-
- @src.sub!(/\A#.*\n/,"\n")
- if $&
- return [:COMMENT, ""]
- end
-
- @src.sub!(/#.*/,'')
-
- if @src.length == 0
- @done = true
- return [false, '$']
- end
-
- if @invar
- @src.sub!(/\A[ \t]+/,'')
- @src.sub!(/\A([^;\n]+)(\n|;)/,'\2')
- if $1
- yytext += $1
- end
- @invar = false
- return [:VALUE, yytext]
- else
- @src.sub!(/\A[\t ]*(\S+)([\t ]*|$)/,'')
+ @src.sub!(/\A\n/,'')
+ if $&
+ @line += 1
+ return [ :RETURN, "\n" ]
+ end
+
+ if @done
+ return nil
+ end
+ yytext = String.new
+
+
+ # remove comments from this line
+ @src.sub!(/\A[ \t]*;.*\n/,"\n")
+ if $&
+ return [:INLINECOMMENT, ""]
+ end
+
+ @src.sub!(/\A#.*\n/,"\n")
+ if $&
+ return [:COMMENT, ""]
+ end
+
+ @src.sub!(/#.*/,'')
+
+ if @src.length == 0
+ @done = true
+ return [false, '$']
+ end
+
+ if @invar
+ @src.sub!(/\A[ \t]+/,'')
+ @src.sub!(/\A([^;\n]+)(\n|;)/,'\2')
+ if $1
+ yytext += $1
+ end
+ @invar = false
+ return [:VALUE, yytext]
+ else
+ @src.sub!(/\A[\t ]*(\S+)([\t ]*|$)/,'')
if $1
yytext = $1
case yytext
@@ -561,11 +560,11 @@ def token
end
end
end
- end
+ end
end
def next_token
- token
+ token
end
def yydebug
@@ -577,109 +576,105 @@ def yywrap
end
def on_error(token, value, vstack )
- msg = ""
- unless value.nil?
- msg = "line #{@line}: syntax error at '#{value}'"
- else
- msg = "line #{@line}: syntax error at '#{token}'"
- end
- unless @src.size > 0
- msg = "line #{@line}: Unexpected end of file"
- end
- if token == '$end'.intern
- puts "okay, this is silly"
- else
- raise ::Nagios::Parser::SyntaxError, msg
- end
+ msg = ""
+ unless value.nil?
+ msg = "line #{@line}: syntax error at '#{value}'"
+ else
+ msg = "line #{@line}: syntax error at '#{token}'"
+ end
+ unless @src.size > 0
+ msg = "line #{@line}: Unexpected end of file"
+ end
+ if token == '$end'.intern
+ puts "okay, this is silly"
+ else
+ raise ::Nagios::Parser::SyntaxError, msg
+ end
end
..end grammar.ry modeval..idcb2ea30b34
##### racc 1.4.5 generates ###
racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 13, :_reduce_1,
- 2, 13, :_reduce_2,
- 1, 14, :_reduce_3,
- 1, 14, :_reduce_4,
- 1, 14, :_reduce_none,
- 2, 16, :_reduce_6,
- 6, 15, :_reduce_7,
- 1, 17, :_reduce_none,
- 2, 17, :_reduce_9,
- 4, 18, :_reduce_10,
- 1, 20, :_reduce_none,
- 2, 20, :_reduce_none,
- 0, 19, :_reduce_none,
- 1, 19, :_reduce_none ]
+ 0, 0, :racc_error,
+ 1, 13, :_reduce_1,
+ 2, 13, :_reduce_2,
+ 1, 14, :_reduce_3,
+ 1, 14, :_reduce_4,
+ 1, 14, :_reduce_none,
+ 2, 16, :_reduce_6,
+ 6, 15, :_reduce_7,
+ 1, 17, :_reduce_none,
+ 2, 17, :_reduce_9,
+ 4, 18, :_reduce_10,
+ 1, 20, :_reduce_none,
+ 2, 20, :_reduce_none,
+ 0, 19, :_reduce_none,
+ 1, 19, :_reduce_none ]
racc_reduce_n = 15
racc_shift_n = 26
racc_action_table = [
- 9, 15, 1, 20, 1, 14, 12, 13, 11, 6,
- 7, 6, 7, 15, 18, 8, 21, 23, 25 ]
+ 9, 15, 1, 20, 1, 14, 12, 13, 11, 6,
+ 7, 6, 7, 15, 18, 8, 21, 23, 25 ]
racc_action_check = [
- 2, 16, 2, 16, 0, 12, 8, 9, 7, 2,
- 2, 0, 0, 14, 15, 1, 18, 22, 24 ]
+ 2, 16, 2, 16, 0, 12, 8, 9, 7, 2,
+ 2, 0, 0, 14, 15, 1, 18, 22, 24 ]
racc_action_pointer = [
- 2, 12, 0, nil, nil, nil, nil, -1, 0, 7,
- nil, nil, -4, nil, 8, 6, -4, nil, 5, nil,
- nil, nil, 8, nil, 9, nil ]
+ 2, 12, 0, nil, nil, nil, nil, -1, 0, 7,
+ nil, nil, -4, nil, 8, 6, -4, nil, 5, nil,
+ nil, nil, 8, nil, 9, nil ]
racc_action_default = [
- -15, -15, -15, -1, -3, -5, -4, -15, -15, -15,
+ -15, -15, -15, -1, -3, -5, -4, -15, -15, -15,
-2, -6, -15, 26, -15, -15, -15, -8, -13, -9,
-7, -14, -15, -11, -10, -12 ]
-racc_goto_table = [
- 17, 3, 19, 10, 2, 16, 22, 24 ]
+racc_goto_table = [ 17, 3, 19, 10, 2, 16, 22, 24 ]
-racc_goto_check = [
- 6, 2, 6, 2, 1, 5, 7, 8 ]
+racc_goto_check = [ 6, 2, 6, 2, 1, 5, 7, 8 ]
-racc_goto_pointer = [
- nil, 4, 1, nil, nil, -9, -14, -12, -15 ]
+racc_goto_pointer = [ nil, 4, 1, nil, nil, -9, -14, -12, -15 ]
-racc_goto_default = [
- nil, nil, nil, 4, 5, nil, nil, nil, nil ]
+racc_goto_default = [ nil, nil, nil, 4, 5, nil, nil, nil, nil ]
racc_token_table = {
- false => 0,
- Object.new => 1,
- :DEFINE => 2,
- :NAME => 3,
- :STRING => 4,
- :PARAM => 5,
- :LCURLY => 6,
- :RCURLY => 7,
- :VALUE => 8,
- :RETURN => 9,
- :COMMENT => 10,
- :INLINECOMMENT => 11 }
+ false => 0,
+ Object.new => 1,
+ :DEFINE => 2,
+ :NAME => 3,
+ :STRING => 4,
+ :PARAM => 5,
+ :LCURLY => 6,
+ :RCURLY => 7,
+ :VALUE => 8,
+ :RETURN => 9,
+ :COMMENT => 10,
+ :INLINECOMMENT => 11 }
racc_use_result_var = true
racc_nt_base = 12
Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
+ racc_action_table,
+ racc_action_check,
+ racc_action_default,
+ racc_action_pointer,
+ racc_goto_table,
+ racc_goto_check,
+ racc_goto_default,
+ racc_goto_pointer,
+ racc_nt_base,
+ racc_reduce_table,
+ racc_token_table,
+ racc_shift_n,
+ racc_reduce_n,
+ racc_use_result_var ]
Racc_token_to_s_table = [
'$end',
@@ -708,91 +703,91 @@ Racc_debug_parser = false
##### racc system variables end #####
- # reduce 0 omitted
+# reduce 0 omitted
module_eval <<'.,.,', 'grammar.ry', 6
- def _reduce_1( val, _values, result )
- return val[0] if val[0]
- result
- end
+ def _reduce_1( val, _values, result )
+return val[0] if val[0]
+ result
+end
.,.,
module_eval <<'.,.,', 'grammar.ry', 18
- def _reduce_2( val, _values, result )
- if val[1].nil?
- result = val[0]
- else
- if val[0].nil?
- result = val[1]
- else
- result = [ val[0], val[1] ].flatten
- end
- end
- result
- end
+ def _reduce_2( val, _values, result )
+ if val[1].nil?
+ result = val[0]
+ else
+ if val[0].nil?
+ result = val[1]
+ else
+ result = [ val[0], val[1] ].flatten
+ end
+ end
+ result
+ end
.,.,
module_eval <<'.,.,', 'grammar.ry', 20
- def _reduce_3( val, _values, result )
- result = [val[0]]
- result
- end
+ def _reduce_3( val, _values, result )
+result = [val[0]]
+ result
+end
.,.,
module_eval <<'.,.,', 'grammar.ry', 21
- def _reduce_4( val, _values, result )
- result = nil
- result
- end
+ def _reduce_4( val, _values, result )
+result = nil
+ result
+end
.,.,
- # reduce 5 omitted
+# reduce 5 omitted
module_eval <<'.,.,', 'grammar.ry', 25
- def _reduce_6( val, _values, result )
- result = nil
- result
- end
+ def _reduce_6( val, _values, result )
+result = nil
+ result
+end
.,.,
module_eval <<'.,.,', 'grammar.ry', 31
- def _reduce_7( val, _values, result )
- result = Nagios::Base.create(val[1],val[4])
- result
- end
+ def _reduce_7( val, _values, result )
+ result = Nagios::Base.create(val[1],val[4])
+ result
+ end
.,.,
- # reduce 8 omitted
+# reduce 8 omitted
module_eval <<'.,.,', 'grammar.ry', 40
- def _reduce_9( val, _values, result )
- val[1].each {|p,v|
- val[0][p] = v
- }
- result = val[0]
- result
- end
+ def _reduce_9( val, _values, result )
+ val[1].each {|p,v|
+ val[0][p] = v
+ }
+ result = val[0]
+ result
+ end
.,.,
module_eval <<'.,.,', 'grammar.ry', 42
- def _reduce_10( val, _values, result )
- result = {val[0],val[1]}
- result
- end
+ def _reduce_10( val, _values, result )
+result = {val[0],val[1]}
+ result
+end
.,.,
- # reduce 11 omitted
+# reduce 11 omitted
- # reduce 12 omitted
+# reduce 12 omitted
- # reduce 13 omitted
+# reduce 13 omitted
- # reduce 14 omitted
+# reduce 14 omitted
- def _reduce_none( val, _values, result )
- result
- end
+def _reduce_none( val, _values, result )
+ result
+end
- end # class Parser
+ end # class Parser
end # module Nagios
diff --git a/lib/puppet/external/pson/common.rb b/lib/puppet/external/pson/common.rb
index 87bce988b..17da5ad11 100644
--- a/lib/puppet/external/pson/common.rb
+++ b/lib/puppet/external/pson/common.rb
@@ -1,367 +1,370 @@
require 'puppet/external/pson/version'
module PSON
- class << self
- # If _object_ is string-like parse the string and return the parsed result
- # as a Ruby data structure. Otherwise generate a PSON text from the Ruby
- # data structure object and return it.
- #
- # The _opts_ argument is passed through to generate/parse respectively, see
- # generate and parse for their documentation.
- def [](object, opts = {})
- if object.respond_to? :to_str
- PSON.parse(object.to_str, opts => {})
- else
- PSON.generate(object, opts => {})
- end
- end
+ class << self
+ # If _object_ is string-like parse the string and return the parsed result
+ # as a Ruby data structure. Otherwise generate a PSON text from the Ruby
+ # data structure object and return it.
+ #
+ # The _opts_ argument is passed through to generate/parse respectively, see
+ # generate and parse for their documentation.
+ def [](object, opts = {})
+ if object.respond_to? :to_str
+ PSON.parse(object.to_str, opts => {})
+ else
+ PSON.generate(object, opts => {})
+ end
+ end
- # Returns the PSON parser class, that is used by PSON. This might be either
- # PSON::Ext::Parser or PSON::Pure::Parser.
- attr_reader :parser
+ # Returns the PSON parser class, that is used by PSON. This might be either
+ # PSON::Ext::Parser or PSON::Pure::Parser.
+ attr_reader :parser
- # Set the PSON parser class _parser_ to be used by PSON.
- def parser=(parser) # :nodoc:
- @parser = parser
- remove_const :Parser if const_defined? :Parser
- const_set :Parser, parser
- end
+ # Set the PSON parser class _parser_ to be used by PSON.
+ def parser=(parser) # :nodoc:
+ @parser = parser
+ remove_const :Parser if const_defined? :Parser
+ const_set :Parser, parser
+ end
+
+ def registered_document_types
+ @registered_document_types ||= {}
+ end
+
+ # Register a class-constant for deserializaion.
+ def register_document_type(name,klass)
+ registered_document_types[name.to_s] = klass
+ end
+
+ # Return the constant located at _path_.
+ # Anything may be registered as a path by calling register_path, above.
+ # Otherwise, the format of _path_ has to be either ::A::B::C or A::B::C.
+ # In either of these cases A has to be defined in Object (e.g. the path
+ # must be an absolute namespace path. If the constant doesn't exist at
+ # the given path, an ArgumentError is raised.
+ def deep_const_get(path) # :nodoc:
+ path = path.to_s
+ registered_document_types[path] || path.split(/::/).inject(Object) do |p, c|
+ case
+ when c.empty? then p
+ when p.const_defined?(c) then p.const_get(c)
+ else raise ArgumentError, "can't find const for unregistered document type #{path}"
+ end
+ end
+ end
+
+ # Set the module _generator_ to be used by PSON.
+ def generator=(generator) # :nodoc:
+ @generator = generator
+ generator_methods = generator::GeneratorMethods
+ for const in generator_methods.constants
+ klass = deep_const_get(const)
+ modul = generator_methods.const_get(const)
+ klass.class_eval do
+ instance_methods(false).each do |m|
+ m.to_s == 'to_pson' and remove_method m
+ end
+ include modul
+ end
+ end
+ self.state = generator::State
+ const_set :State, self.state
+ end
+
+ # Returns the PSON generator modul, that is used by PSON. This might be
+ # either PSON::Ext::Generator or PSON::Pure::Generator.
+ attr_reader :generator
- def registered_document_types
- @registered_document_types ||= {}
+ # Returns the PSON generator state class, that is used by PSON. This might
+ # be either PSON::Ext::Generator::State or PSON::Pure::Generator::State.
+ attr_accessor :state
+
+ # This is create identifier, that is used to decide, if the _pson_create_
+ # hook of a class should be called. It defaults to 'document_type'.
+ attr_accessor :create_id
end
+ self.create_id = 'document_type'
+
+ NaN = (-1.0) ** 0.5
+
+ Infinity = 1.0/0
+
+ MinusInfinity = -Infinity
+
+ # The base exception for PSON errors.
+ class PSONError < StandardError; end
+
+ # This exception is raised, if a parser error occurs.
+ class ParserError < PSONError; end
+
+ # This exception is raised, if the nesting of parsed datastructures is too
+ # deep.
+ class NestingError < ParserError; end
+
+ # This exception is raised, if a generator or unparser error occurs.
+ class GeneratorError < PSONError; end
+ # For backwards compatibility
+ UnparserError = GeneratorError
- # Register a class-constant for deserializaion.
- def register_document_type(name,klass)
- registered_document_types[name.to_s] = klass
+ # If a circular data structure is encountered while unparsing
+ # this exception is raised.
+ class CircularDatastructure < GeneratorError; end
+
+ # This exception is raised, if the required unicode support is missing on the
+ # system. Usually this means, that the iconv library is not installed.
+ class MissingUnicodeSupport < PSONError; end
+
+ module_function
+
+ # Parse the PSON string _source_ into a Ruby data structure and return it.
+ #
+ # _opts_ can have the following
+ # keys:
+ # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ # structures. Disable depth checking with :max_nesting => false, it defaults
+ # to 19.
+ # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
+ # defiance of RFC 4627 to be parsed by the Parser. This option defaults
+ # to false.
+ # * *create_additions*: If set to false, the Parser doesn't create
+ # additions even if a matchin class and create_id was found. This option
+ # defaults to true.
+ def parse(source, opts = {})
+ PSON.parser.new(source, opts).parse
end
- # Return the constant located at _path_.
- # Anything may be registered as a path by calling register_path, above.
- # Otherwise, the format of _path_ has to be either ::A::B::C or A::B::C.
- # In either of these cases A has to be defined in Object (e.g. the path
- # must be an absolute namespace path. If the constant doesn't exist at
- # the given path, an ArgumentError is raised.
- def deep_const_get(path) # :nodoc:
- path = path.to_s
- registered_document_types[path] || path.split(/::/).inject(Object) do |p, c|
- case
- when c.empty? then p
- when p.const_defined?(c) then p.const_get(c)
- else raise ArgumentError, "can't find const for unregistered document type #{path}"
- end
- end
+ # Parse the PSON string _source_ into a Ruby data structure and return it.
+ # The bang version of the parse method, defaults to the more dangerous values
+ # for the _opts_ hash, so be sure only to parse trusted _source_ strings.
+ #
+ # _opts_ can have the following keys:
+ # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ # structures. Enable depth checking with :max_nesting => anInteger. The parse!
+ # methods defaults to not doing max depth checking: This can be dangerous,
+ # if someone wants to fill up your stack.
+ # * *allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in
+ # defiance of RFC 4627 to be parsed by the Parser. This option defaults
+ # to true.
+ # * *create_additions*: If set to false, the Parser doesn't create
+ # additions even if a matchin class and create_id was found. This option
+ # defaults to true.
+ def parse!(source, opts = {})
+ opts = {
+ :max_nesting => false,
+ :allow_nan => true
+ }.update(opts)
+ PSON.parser.new(source, opts).parse
end
- # Set the module _generator_ to be used by PSON.
- def generator=(generator) # :nodoc:
- @generator = generator
- generator_methods = generator::GeneratorMethods
- for const in generator_methods.constants
- klass = deep_const_get(const)
- modul = generator_methods.const_get(const)
- klass.class_eval do
- instance_methods(false).each do |m|
- m.to_s == 'to_pson' and remove_method m
- end
- include modul
+ # Unparse the Ruby data structure _obj_ into a single line PSON string and
+ # return it. _state_ is
+ # * a PSON::State object,
+ # * or a Hash like object (responding to to_hash),
+ # * an object convertible into a hash by a to_h method,
+ # that is used as or to configure a State object.
+ #
+ # It defaults to a state object, that creates the shortest possible PSON text
+ # in one line, checks for circular data structures and doesn't allow NaN,
+ # Infinity, and -Infinity.
+ #
+ # A _state_ hash can have the following keys:
+ # * *indent*: a string used to indent levels (default: ''),
+ # * *space*: a string that is put after, a : or , delimiter (default: ''),
+ # * *space_before*: a string that is put before a : pair delimiter (default: ''),
+ # * *object_nl*: a string that is put at the end of a PSON object (default: ''),
+ # * *array_nl*: a string that is put at the end of a PSON array (default: ''),
+ # * *check_circular*: true if checking for circular data structures
+ # should be done (the default), false otherwise.
+ # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
+ # generated, otherwise an exception is thrown, if these values are
+ # encountered. This options defaults to false.
+ # * *max_nesting*: The maximum depth of nesting allowed in the data
+ # structures from which PSON is to be generated. Disable depth checking
+ # with :max_nesting => false, it defaults to 19.
+ #
+ # See also the fast_generate for the fastest creation method with the least
+ # amount of sanity checks, and the pretty_generate method for some
+ # defaults for a pretty output.
+ def generate(obj, state = nil)
+ if state
+ state = State.from_state(state)
+ else
+ state = State.new
end
- end
- self.state = generator::State
- const_set :State, self.state
+ obj.to_pson(state)
end
- # Returns the PSON generator modul, that is used by PSON. This might be
- # either PSON::Ext::Generator or PSON::Pure::Generator.
- attr_reader :generator
-
- # Returns the PSON generator state class, that is used by PSON. This might
- # be either PSON::Ext::Generator::State or PSON::Pure::Generator::State.
- attr_accessor :state
-
- # This is create identifier, that is used to decide, if the _pson_create_
- # hook of a class should be called. It defaults to 'document_type'.
- attr_accessor :create_id
- end
- self.create_id = 'document_type'
-
- NaN = (-1.0) ** 0.5
-
- Infinity = 1.0/0
-
- MinusInfinity = -Infinity
-
- # The base exception for PSON errors.
- class PSONError < StandardError; end
-
- # This exception is raised, if a parser error occurs.
- class ParserError < PSONError; end
-
- # This exception is raised, if the nesting of parsed datastructures is too
- # deep.
- class NestingError < ParserError; end
-
- # This exception is raised, if a generator or unparser error occurs.
- class GeneratorError < PSONError; end
- # For backwards compatibility
- UnparserError = GeneratorError
-
- # If a circular data structure is encountered while unparsing
- # this exception is raised.
- class CircularDatastructure < GeneratorError; end
-
- # This exception is raised, if the required unicode support is missing on the
- # system. Usually this means, that the iconv library is not installed.
- class MissingUnicodeSupport < PSONError; end
-
- module_function
-
- # Parse the PSON string _source_ into a Ruby data structure and return it.
- #
- # _opts_ can have the following
- # keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Disable depth checking with :max_nesting => false, it defaults
- # to 19.
- # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to false.
- # * *create_additions*: If set to false, the Parser doesn't create
- # additions even if a matchin class and create_id was found. This option
- # defaults to true.
- def parse(source, opts = {})
- PSON.parser.new(source, opts).parse
- end
-
- # Parse the PSON string _source_ into a Ruby data structure and return it.
- # The bang version of the parse method, defaults to the more dangerous values
- # for the _opts_ hash, so be sure only to parse trusted _source_ strings.
- #
- # _opts_ can have the following keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Enable depth checking with :max_nesting => anInteger. The parse!
- # methods defaults to not doing max depth checking: This can be dangerous,
- # if someone wants to fill up your stack.
- # * *allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to true.
- # * *create_additions*: If set to false, the Parser doesn't create
- # additions even if a matchin class and create_id was found. This option
- # defaults to true.
- def parse!(source, opts = {})
- opts = {
- :max_nesting => false,
- :allow_nan => true
- }.update(opts)
- PSON.parser.new(source, opts).parse
- end
-
- # Unparse the Ruby data structure _obj_ into a single line PSON string and
- # return it. _state_ is
- # * a PSON::State object,
- # * or a Hash like object (responding to to_hash),
- # * an object convertible into a hash by a to_h method,
- # that is used as or to configure a State object.
- #
- # It defaults to a state object, that creates the shortest possible PSON text
- # in one line, checks for circular data structures and doesn't allow NaN,
- # Infinity, and -Infinity.
- #
- # A _state_ hash can have the following keys:
- # * *indent*: a string used to indent levels (default: ''),
- # * *space*: a string that is put after, a : or , delimiter (default: ''),
- # * *space_before*: a string that is put before a : pair delimiter (default: ''),
- # * *object_nl*: a string that is put at the end of a PSON object (default: ''),
- # * *array_nl*: a string that is put at the end of a PSON array (default: ''),
- # * *check_circular*: true if checking for circular data structures
- # should be done (the default), false otherwise.
- # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
- # generated, otherwise an exception is thrown, if these values are
- # encountered. This options defaults to false.
- # * *max_nesting*: The maximum depth of nesting allowed in the data
- # structures from which PSON is to be generated. Disable depth checking
- # with :max_nesting => false, it defaults to 19.
- #
- # See also the fast_generate for the fastest creation method with the least
- # amount of sanity checks, and the pretty_generate method for some
- # defaults for a pretty output.
- def generate(obj, state = nil)
- if state
- state = State.from_state(state)
- else
- state = State.new
- end
- obj.to_pson(state)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and
- # later delete them.
- alias unparse generate
- module_function :unparse
- # :startdoc:
-
- # Unparse the Ruby data structure _obj_ into a single line PSON string and
- # return it. This method disables the checks for circles in Ruby objects, and
- # also generates NaN, Infinity, and, -Infinity float values.
- #
- # *WARNING*: Be careful not to pass any Ruby data structures with circles as
- # _obj_ argument, because this will cause PSON to go into an infinite loop.
- def fast_generate(obj)
- obj.to_pson(nil)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
- alias fast_unparse fast_generate
- module_function :fast_unparse
- # :startdoc:
-
- # Unparse the Ruby data structure _obj_ into a PSON string and return it. The
- # returned string is a prettier form of the string returned by #unparse.
- #
- # The _opts_ argument can be used to configure the generator, see the
- # generate method for a more detailed explanation.
- def pretty_generate(obj, opts = nil)
- state = PSON.state.new(
- :indent => ' ',
- :space => ' ',
- :object_nl => "\n",
- :array_nl => "\n",
- :check_circular => true
- )
- if opts
- if opts.respond_to? :to_hash
- opts = opts.to_hash
- elsif opts.respond_to? :to_h
- opts = opts.to_h
- else
- raise TypeError, "can't convert #{opts.class} into Hash"
- end
- state.configure(opts)
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and
+ # later delete them.
+ alias unparse generate
+ module_function :unparse
+ # :startdoc:
+
+ # Unparse the Ruby data structure _obj_ into a single line PSON string and
+ # return it. This method disables the checks for circles in Ruby objects, and
+ # also generates NaN, Infinity, and, -Infinity float values.
+ #
+ # *WARNING*: Be careful not to pass any Ruby data structures with circles as
+ # _obj_ argument, because this will cause PSON to go into an infinite loop.
+ def fast_generate(obj)
+ obj.to_pson(nil)
end
- obj.to_pson(state)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
- alias pretty_unparse pretty_generate
- module_function :pretty_unparse
- # :startdoc:
-
- # Load a ruby data structure from a PSON _source_ and return it. A source can
- # either be a string-like object, an IO like object, or an object responding
- # to the read method. If _proc_ was given, it will be called with any nested
- # Ruby object as an argument recursively in depth first order.
- #
- # This method is part of the implementation of the load/dump interface of
- # Marshal and YAML.
- def load(source, proc = nil)
- if source.respond_to? :to_str
- source = source.to_str
- elsif source.respond_to? :to_io
- source = source.to_io.read
- else
- source = source.read
+
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
+ alias fast_unparse fast_generate
+ module_function :fast_unparse
+ # :startdoc:
+
+ # Unparse the Ruby data structure _obj_ into a PSON string and return it. The
+ # returned string is a prettier form of the string returned by #unparse.
+ #
+ # The _opts_ argument can be used to configure the generator, see the
+ # generate method for a more detailed explanation.
+ def pretty_generate(obj, opts = nil)
+
+ state = PSON.state.new(
+
+ :indent => ' ',
+ :space => ' ',
+ :object_nl => "\n",
+ :array_nl => "\n",
+
+ :check_circular => true
+ )
+ if opts
+ if opts.respond_to? :to_hash
+ opts = opts.to_hash
+ elsif opts.respond_to? :to_h
+ opts = opts.to_h
+ else
+ raise TypeError, "can't convert #{opts.class} into Hash"
+ end
+ state.configure(opts)
+ end
+ obj.to_pson(state)
end
- result = parse(source, :max_nesting => false, :allow_nan => true)
- recurse_proc(result, &proc) if proc
- result
- end
-
- def recurse_proc(result, &proc)
- case result
- when Array
- result.each { |x| recurse_proc x, &proc }
- proc.call result
- when Hash
- result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc }
- proc.call result
- else
- proc.call result
+
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
+ alias pretty_unparse pretty_generate
+ module_function :pretty_unparse
+ # :startdoc:
+
+ # Load a ruby data structure from a PSON _source_ and return it. A source can
+ # either be a string-like object, an IO like object, or an object responding
+ # to the read method. If _proc_ was given, it will be called with any nested
+ # Ruby object as an argument recursively in depth first order.
+ #
+ # This method is part of the implementation of the load/dump interface of
+ # Marshal and YAML.
+ def load(source, proc = nil)
+ if source.respond_to? :to_str
+ source = source.to_str
+ elsif source.respond_to? :to_io
+ source = source.to_io.read
+ else
+ source = source.read
+ end
+ result = parse(source, :max_nesting => false, :allow_nan => true)
+ recurse_proc(result, &proc) if proc
+ result
end
- end
- private :recurse_proc
- module_function :recurse_proc
-
- alias restore load
- module_function :restore
-
- # Dumps _obj_ as a PSON string, i.e. calls generate on the object and returns
- # the result.
- #
- # If anIO (an IO like object or an object that responds to the write method)
- # was given, the resulting PSON is written to it.
- #
- # If the number of nested arrays or objects exceeds _limit_ an ArgumentError
- # exception is raised. This argument is similar (but not exactly the
- # same!) to the _limit_ argument in Marshal.dump.
- #
- # This method is part of the implementation of the load/dump interface of
- # Marshal and YAML.
- def dump(obj, anIO = nil, limit = nil)
- if anIO and limit.nil?
- anIO = anIO.to_io if anIO.respond_to?(:to_io)
- unless anIO.respond_to?(:write)
- limit = anIO
- anIO = nil
- end
+
+ def recurse_proc(result, &proc)
+ case result
+ when Array
+ result.each { |x| recurse_proc x, &proc }
+ proc.call result
+ when Hash
+ result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc }
+ proc.call result
+ else
+ proc.call result
+ end
end
- limit ||= 0
- result = generate(obj, :allow_nan => true, :max_nesting => limit)
- if anIO
- anIO.write result
- anIO
- else
- result
+ private :recurse_proc
+ module_function :recurse_proc
+
+ alias restore load
+ module_function :restore
+
+ # Dumps _obj_ as a PSON string, i.e. calls generate on the object and returns
+ # the result.
+ #
+ # If anIO (an IO like object or an object that responds to the write method)
+ # was given, the resulting PSON is written to it.
+ #
+ # If the number of nested arrays or objects exceeds _limit_ an ArgumentError
+ # exception is raised. This argument is similar (but not exactly the
+ # same!) to the _limit_ argument in Marshal.dump.
+ #
+ # This method is part of the implementation of the load/dump interface of
+ # Marshal and YAML.
+ def dump(obj, anIO = nil, limit = nil)
+ if anIO and limit.nil?
+ anIO = anIO.to_io if anIO.respond_to?(:to_io)
+ unless anIO.respond_to?(:write)
+ limit = anIO
+ anIO = nil
+ end
+ end
+ limit ||= 0
+ result = generate(obj, :allow_nan => true, :max_nesting => limit)
+ if anIO
+ anIO.write result
+ anIO
+ else
+ result
+ end
+ rescue PSON::NestingError
+ raise ArgumentError, "exceed depth limit"
end
- rescue PSON::NestingError
- raise ArgumentError, "exceed depth limit"
- end
end
module ::Kernel
- private
+ private
- # Outputs _objs_ to STDOUT as PSON strings in the shortest form, that is in
- # one line.
- def j(*objs)
- objs.each do |obj|
- puts PSON::generate(obj, :allow_nan => true, :max_nesting => false)
+ # Outputs _objs_ to STDOUT as PSON strings in the shortest form, that is in
+ # one line.
+ def j(*objs)
+ objs.each do |obj|
+ puts PSON::generate(obj, :allow_nan => true, :max_nesting => false)
+ end
+ nil
end
- nil
- end
-
- # Ouputs _objs_ to STDOUT as PSON strings in a pretty format, with
- # indentation and over many lines.
- def jj(*objs)
- objs.each do |obj|
- puts PSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
+
+ # Ouputs _objs_ to STDOUT as PSON strings in a pretty format, with
+ # indentation and over many lines.
+ def jj(*objs)
+ objs.each do |obj|
+ puts PSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
+ end
+ nil
end
- nil
- end
-
- # If _object_ is string-like parse the string and return the parsed result as
- # a Ruby data structure. Otherwise generate a PSON text from the Ruby data
- # structure object and return it.
- #
- # The _opts_ argument is passed through to generate/parse respectively, see
- # generate and parse for their documentation.
- def PSON(object, opts = {})
- if object.respond_to? :to_str
- PSON.parse(object.to_str, opts)
- else
- PSON.generate(object, opts)
+
+ # If _object_ is string-like parse the string and return the parsed result as
+ # a Ruby data structure. Otherwise generate a PSON text from the Ruby data
+ # structure object and return it.
+ #
+ # The _opts_ argument is passed through to generate/parse respectively, see
+ # generate and parse for their documentation.
+ def PSON(object, opts = {})
+ if object.respond_to? :to_str
+ PSON.parse(object.to_str, opts)
+ else
+ PSON.generate(object, opts)
+ end
end
- end
end
class ::Class
- # Returns true, if this class can be used to create an instance
- # from a serialised PSON string. The class has to implement a class
- # method _pson_create_ that expects a hash as first parameter, which includes
- # the required data.
- def pson_creatable?
- respond_to?(:pson_create)
- end
+ # Returns true, if this class can be used to create an instance
+ # from a serialised PSON string. The class has to implement a class
+ # method _pson_create_ that expects a hash as first parameter, which includes
+ # the required data.
+ def pson_creatable?
+ respond_to?(:pson_create)
+ end
end
diff --git a/lib/puppet/external/pson/pure.rb b/lib/puppet/external/pson/pure.rb
index 53d1ea2a7..dffd06d92 100644
--- a/lib/puppet/external/pson/pure.rb
+++ b/lib/puppet/external/pson/pure.rb
@@ -3,75 +3,75 @@ require 'puppet/external/pson/pure/parser'
require 'puppet/external/pson/pure/generator'
module PSON
- begin
- require 'iconv'
- # An iconv instance to convert from UTF8 to UTF16 Big Endian.
- UTF16toUTF8 = Iconv.new('utf-8', 'utf-16be') # :nodoc:
- # An iconv instance to convert from UTF16 Big Endian to UTF8.
- UTF8toUTF16 = Iconv.new('utf-16be', 'utf-8') # :nodoc:
- UTF8toUTF16.iconv('no bom')
- rescue LoadError
- # We actually don't care
- Puppet.warning "iconv couldn't be loaded, which is required for UTF-8/UTF-16 conversions"
- rescue Errno::EINVAL, Iconv::InvalidEncoding
- # Iconv doesn't support big endian utf-16. Let's try to hack this manually
- # into the converters.
begin
- old_verbose, $VERBSOSE = $VERBOSE, nil
- # An iconv instance to convert from UTF8 to UTF16 Big Endian.
- UTF16toUTF8 = Iconv.new('utf-8', 'utf-16') # :nodoc:
- # An iconv instance to convert from UTF16 Big Endian to UTF8.
- UTF8toUTF16 = Iconv.new('utf-16', 'utf-8') # :nodoc:
- UTF8toUTF16.iconv('no bom')
- if UTF8toUTF16.iconv("\xe2\x82\xac") == "\xac\x20"
- swapper = Class.new do
- def initialize(iconv) # :nodoc:
- @iconv = iconv
- end
+ require 'iconv'
+ # An iconv instance to convert from UTF8 to UTF16 Big Endian.
+ UTF16toUTF8 = Iconv.new('utf-8', 'utf-16be') # :nodoc:
+ # An iconv instance to convert from UTF16 Big Endian to UTF8.
+ UTF8toUTF16 = Iconv.new('utf-16be', 'utf-8') # :nodoc:
+ UTF8toUTF16.iconv('no bom')
+ rescue LoadError
+ # We actually don't care
+ Puppet.warning "iconv couldn't be loaded, which is required for UTF-8/UTF-16 conversions"
+ rescue Errno::EINVAL, Iconv::InvalidEncoding
+ # Iconv doesn't support big endian utf-16. Let's try to hack this manually
+ # into the converters.
+ begin
+ old_verbose, $VERBSOSE = $VERBOSE, nil
+ # An iconv instance to convert from UTF8 to UTF16 Big Endian.
+ UTF16toUTF8 = Iconv.new('utf-8', 'utf-16') # :nodoc:
+ # An iconv instance to convert from UTF16 Big Endian to UTF8.
+ UTF8toUTF16 = Iconv.new('utf-16', 'utf-8') # :nodoc:
+ UTF8toUTF16.iconv('no bom')
+ if UTF8toUTF16.iconv("\xe2\x82\xac") == "\xac\x20"
+ swapper = Class.new do
+ def initialize(iconv) # :nodoc:
+ @iconv = iconv
+ end
- def iconv(string) # :nodoc:
- result = @iconv.iconv(string)
- PSON.swap!(result)
- end
- end
- UTF8toUTF16 = swapper.new(UTF8toUTF16) # :nodoc:
- end
- if UTF16toUTF8.iconv("\xac\x20") == "\xe2\x82\xac"
- swapper = Class.new do
- def initialize(iconv) # :nodoc:
- @iconv = iconv
- end
+ def iconv(string) # :nodoc:
+ result = @iconv.iconv(string)
+ PSON.swap!(result)
+ end
+ end
+ UTF8toUTF16 = swapper.new(UTF8toUTF16) # :nodoc:
+ end
+ if UTF16toUTF8.iconv("\xac\x20") == "\xe2\x82\xac"
+ swapper = Class.new do
+ def initialize(iconv) # :nodoc:
+ @iconv = iconv
+ end
- def iconv(string) # :nodoc:
- string = PSON.swap!(string.dup)
- @iconv.iconv(string)
- end
+ def iconv(string) # :nodoc:
+ string = PSON.swap!(string.dup)
+ @iconv.iconv(string)
+ end
+ end
+ UTF16toUTF8 = swapper.new(UTF16toUTF8) # :nodoc:
+ end
+ rescue Errno::EINVAL, Iconv::InvalidEncoding
+ Puppet.warning "iconv doesn't seem to support UTF-8/UTF-16 conversions"
+ ensure
+ $VERBOSE = old_verbose
end
- UTF16toUTF8 = swapper.new(UTF16toUTF8) # :nodoc:
- end
- rescue Errno::EINVAL, Iconv::InvalidEncoding
- Puppet.warning "iconv doesn't seem to support UTF-8/UTF-16 conversions"
- ensure
- $VERBOSE = old_verbose
end
- end
- # Swap consecutive bytes of _string_ in place.
- def self.swap!(string) # :nodoc:
- 0.upto(string.size / 2) do |i|
- break unless string[2 * i + 1]
- string[2 * i], string[2 * i + 1] = string[2 * i + 1], string[2 * i]
+ # Swap consecutive bytes of _string_ in place.
+ def self.swap!(string) # :nodoc:
+ 0.upto(string.size / 2) do |i|
+ break unless string[2 * i + 1]
+ string[2 * i], string[2 * i + 1] = string[2 * i + 1], string[2 * i]
+ end
+ string
end
- string
- end
- # This module holds all the modules/classes that implement PSON's
- # functionality in pure ruby.
- module Pure
- $DEBUG and warn "Using pure library for PSON."
- PSON.parser = Parser
- PSON.generator = Generator
- end
+ # This module holds all the modules/classes that implement PSON's
+ # functionality in pure ruby.
+ module Pure
+ $DEBUG and warn "Using pure library for PSON."
+ PSON.parser = Parser
+ PSON.generator = Generator
+ end
- PSON_LOADED = true
+ PSON_LOADED = true
end
diff --git a/lib/puppet/external/pson/pure/generator.rb b/lib/puppet/external/pson/pure/generator.rb
index b2a7ddeb5..44aa526c7 100644
--- a/lib/puppet/external/pson/pure/generator.rb
+++ b/lib/puppet/external/pson/pure/generator.rb
@@ -1,429 +1,429 @@
module PSON
- MAP = {
- "\x0" => '\u0000',
- "\x1" => '\u0001',
- "\x2" => '\u0002',
- "\x3" => '\u0003',
- "\x4" => '\u0004',
- "\x5" => '\u0005',
- "\x6" => '\u0006',
- "\x7" => '\u0007',
- "\b" => '\b',
- "\t" => '\t',
- "\n" => '\n',
- "\xb" => '\u000b',
- "\f" => '\f',
- "\r" => '\r',
- "\xe" => '\u000e',
- "\xf" => '\u000f',
- "\x10" => '\u0010',
- "\x11" => '\u0011',
- "\x12" => '\u0012',
- "\x13" => '\u0013',
- "\x14" => '\u0014',
- "\x15" => '\u0015',
- "\x16" => '\u0016',
- "\x17" => '\u0017',
- "\x18" => '\u0018',
- "\x19" => '\u0019',
- "\x1a" => '\u001a',
- "\x1b" => '\u001b',
- "\x1c" => '\u001c',
- "\x1d" => '\u001d',
- "\x1e" => '\u001e',
- "\x1f" => '\u001f',
- '"' => '\"',
- '\\' => '\\\\',
- } # :nodoc:
-
- # Convert a UTF8 encoded Ruby string _string_ to a PSON string, encoded with
- # UTF16 big endian characters as \u????, and return it.
- if String.method_defined?(:force_encoding)
- def utf8_to_pson(string) # :nodoc:
- string = string.dup
- string << '' # XXX workaround: avoid buffer sharing
- string.force_encoding(Encoding::ASCII_8BIT)
- string.gsub!(/["\\\x0-\x1f]/) { MAP[$&] }
- string.gsub!(/(
- (?:
- [\xc2-\xdf][\x80-\xbf] |
- [\xe0-\xef][\x80-\xbf]{2} |
- [\xf0-\xf4][\x80-\xbf]{3}
- )+ |
- [\x80-\xc1\xf5-\xff] # invalid
- )/nx) { |c|
- c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
- s = PSON::UTF8toUTF16.iconv(c).unpack('H*')[0]
- s.gsub!(/.{4}/n, '\\\\u\&')
- }
- string.force_encoding(Encoding::UTF_8)
- string
- rescue Iconv::Failure => e
- raise GeneratorError, "Caught #{e.class}: #{e}"
- end
- else
- def utf8_to_pson(string) # :nodoc:
- string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] }
- string.gsub!(/(
- (?:
- [\xc2-\xdf][\x80-\xbf] |
- [\xe0-\xef][\x80-\xbf]{2} |
- [\xf0-\xf4][\x80-\xbf]{3}
- )+ |
- [\x80-\xc1\xf5-\xff] # invalid
- )/nx) { |c|
- c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
- s = PSON::UTF8toUTF16.iconv(c).unpack('H*')[0]
- s.gsub!(/.{4}/n, '\\\\u\&')
- }
- string
- rescue Iconv::Failure => e
- raise GeneratorError, "Caught #{e.class}: #{e}"
- end
- end
- module_function :utf8_to_pson
-
- module Pure
- module Generator
- # This class is used to create State instances, that are use to hold data
- # while generating a PSON text from a a Ruby data structure.
- class State
- # Creates a State object from _opts_, which ought to be Hash to create
- # a new State instance configured by _opts_, something else to create
- # an unconfigured instance. If _opts_ is a State object, it is just
- # returned.
- def self.from_state(opts)
- case opts
- when self
- opts
- when Hash
- new(opts)
- else
- new
- end
- end
-
- # Instantiates a new State object, configured by _opts_.
- #
- # _opts_ can have the following keys:
- #
- # * *indent*: a string used to indent levels (default: ''),
- # * *space*: a string that is put after, a : or , delimiter (default: ''),
- # * *space_before*: a string that is put before a : pair delimiter (default: ''),
- # * *object_nl*: a string that is put at the end of a PSON object (default: ''),
- # * *array_nl*: a string that is put at the end of a PSON array (default: ''),
- # * *check_circular*: true if checking for circular data structures
- # should be done (the default), false otherwise.
- # * *check_circular*: true if checking for circular data structures
- # should be done, false (the default) otherwise.
- # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
- # generated, otherwise an exception is thrown, if these values are
- # encountered. This options defaults to false.
- def initialize(opts = {})
- @seen = {}
- @indent = ''
- @space = ''
- @space_before = ''
- @object_nl = ''
- @array_nl = ''
- @check_circular = true
- @allow_nan = false
- configure opts
- end
-
- # This string is used to indent levels in the PSON text.
- attr_accessor :indent
-
- # This string is used to insert a space between the tokens in a PSON
- # string.
- attr_accessor :space
-
- # This string is used to insert a space before the ':' in PSON objects.
- attr_accessor :space_before
-
- # This string is put at the end of a line that holds a PSON object (or
- # Hash).
- attr_accessor :object_nl
-
- # This string is put at the end of a line that holds a PSON array.
- attr_accessor :array_nl
-
- # This integer returns the maximum level of data structure nesting in
- # the generated PSON, max_nesting = 0 if no maximum is checked.
- attr_accessor :max_nesting
-
- def check_max_nesting(depth) # :nodoc:
- return if @max_nesting.zero?
- current_nesting = depth + 1
- current_nesting > @max_nesting and
- raise NestingError, "nesting of #{current_nesting} is too deep"
- end
-
- # Returns true, if circular data structures should be checked,
- # otherwise returns false.
- def check_circular?
- @check_circular
- end
-
- # Returns true if NaN, Infinity, and -Infinity should be considered as
- # valid PSON and output.
- def allow_nan?
- @allow_nan
- end
-
- # Returns _true_, if _object_ was already seen during this generating
- # run.
- def seen?(object)
- @seen.key?(object.__id__)
- end
-
- # Remember _object_, to find out if it was already encountered (if a
- # cyclic data structure is if a cyclic data structure is rendered).
- def remember(object)
- @seen[object.__id__] = true
- end
-
- # Forget _object_ for this generating run.
- def forget(object)
- @seen.delete object.__id__
- end
-
- # Configure this State instance with the Hash _opts_, and return
- # itself.
- def configure(opts)
- @indent = opts[:indent] if opts.key?(:indent)
- @space = opts[:space] if opts.key?(:space)
- @space_before = opts[:space_before] if opts.key?(:space_before)
- @object_nl = opts[:object_nl] if opts.key?(:object_nl)
- @array_nl = opts[:array_nl] if opts.key?(:array_nl)
- @check_circular = !!opts[:check_circular] if opts.key?(:check_circular)
- @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
- if !opts.key?(:max_nesting) # defaults to 19
- @max_nesting = 19
- elsif opts[:max_nesting]
- @max_nesting = opts[:max_nesting]
- else
- @max_nesting = 0
- end
- self
- end
-
- # Returns the configuration instance variables as a hash, that can be
- # passed to the configure method.
- def to_h
- result = {}
- for iv in %w[indent space space_before object_nl array_nl check_circular allow_nan max_nesting]
- result[iv.intern] = instance_variable_get("@#{iv}")
- end
- result
- end
- end
-
- module GeneratorMethods
- module Object
- # Converts this object to a string (calling #to_s), converts
- # it to a PSON string, and returns the result. This is a fallback, if no
- # special method #to_pson was defined for some object.
- def to_pson(*) to_s.to_pson end
+ MAP = {
+ "\x0" => '\u0000',
+ "\x1" => '\u0001',
+ "\x2" => '\u0002',
+ "\x3" => '\u0003',
+ "\x4" => '\u0004',
+ "\x5" => '\u0005',
+ "\x6" => '\u0006',
+ "\x7" => '\u0007',
+ "\b" => '\b',
+ "\t" => '\t',
+ "\n" => '\n',
+ "\xb" => '\u000b',
+ "\f" => '\f',
+ "\r" => '\r',
+ "\xe" => '\u000e',
+ "\xf" => '\u000f',
+ "\x10" => '\u0010',
+ "\x11" => '\u0011',
+ "\x12" => '\u0012',
+ "\x13" => '\u0013',
+ "\x14" => '\u0014',
+ "\x15" => '\u0015',
+ "\x16" => '\u0016',
+ "\x17" => '\u0017',
+ "\x18" => '\u0018',
+ "\x19" => '\u0019',
+ "\x1a" => '\u001a',
+ "\x1b" => '\u001b',
+ "\x1c" => '\u001c',
+ "\x1d" => '\u001d',
+ "\x1e" => '\u001e',
+ "\x1f" => '\u001f',
+ '"' => '\"',
+ '\\' => '\\\\',
+ } # :nodoc:
+
+ # Convert a UTF8 encoded Ruby string _string_ to a PSON string, encoded with
+ # UTF16 big endian characters as \u????, and return it.
+ if String.method_defined?(:force_encoding)
+ def utf8_to_pson(string) # :nodoc:
+ string = string.dup
+ string << '' # XXX workaround: avoid buffer sharing
+ string.force_encoding(Encoding::ASCII_8BIT)
+ string.gsub!(/["\\\x0-\x1f]/) { MAP[$&] }
+ string.gsub!(/(
+ (?:
+ [\xc2-\xdf][\x80-\xbf] |
+ [\xe0-\xef][\x80-\xbf]{2} |
+ [\xf0-\xf4][\x80-\xbf]{3}
+ )+ |
+ [\x80-\xc1\xf5-\xff] # invalid
+ )/nx) { |c|
+ c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
+ s = PSON::UTF8toUTF16.iconv(c).unpack('H*')[0]
+ s.gsub!(/.{4}/n, '\\\\u\&')
+ }
+ string.force_encoding(Encoding::UTF_8)
+ string
+ rescue Iconv::Failure => e
+ raise GeneratorError, "Caught #{e.class}: #{e}"
end
-
- module Hash
- # Returns a PSON string containing a PSON object, that is unparsed from
- # this Hash instance.
- # _state_ is a PSON::State object, that can also be used to configure the
- # produced PSON string output further.
- # _depth_ is used to find out nesting depth, to indent accordingly.
- def to_pson(state = nil, depth = 0, *)
- if state
- state = PSON.state.from_state(state)
- state.check_max_nesting(depth)
- pson_check_circular(state) { pson_transform(state, depth) }
- else
- pson_transform(state, depth)
- end
- end
-
- private
-
- def pson_check_circular(state)
- if state and state.check_circular?
- state.seen?(self) and raise PSON::CircularDatastructure,
- "circular data structures not supported!"
- state.remember self
- end
- yield
- ensure
- state and state.forget self
- end
-
- def pson_shift(state, depth)
- state and not state.object_nl.empty? or return ''
- state.indent * depth
- end
-
- def pson_transform(state, depth)
- delim = ','
- if state
- delim << state.object_nl
- result = '{'
- result << state.object_nl
- result << map { |key,value|
- s = pson_shift(state, depth + 1)
- s << key.to_s.to_pson(state, depth + 1)
- s << state.space_before
- s << ':'
- s << state.space
- s << value.to_pson(state, depth + 1)
- }.join(delim)
- result << state.object_nl
- result << pson_shift(state, depth)
- result << '}'
- else
- result = '{'
- result << map { |key,value|
- key.to_s.to_pson << ':' << value.to_pson
- }.join(delim)
- result << '}'
- end
- result
- end
- end
-
- module Array
- # Returns a PSON string containing a PSON array, that is unparsed from
- # this Array instance.
- # _state_ is a PSON::State object, that can also be used to configure the
- # produced PSON string output further.
- # _depth_ is used to find out nesting depth, to indent accordingly.
- def to_pson(state = nil, depth = 0, *)
- if state
- state = PSON.state.from_state(state)
- state.check_max_nesting(depth)
- pson_check_circular(state) { pson_transform(state, depth) }
- else
- pson_transform(state, depth)
- end
- end
-
- private
-
- def pson_check_circular(state)
- if state and state.check_circular?
- state.seen?(self) and raise PSON::CircularDatastructure,
- "circular data structures not supported!"
- state.remember self
- end
- yield
- ensure
- state and state.forget self
- end
-
- def pson_shift(state, depth)
- state and not state.array_nl.empty? or return ''
- state.indent * depth
- end
-
- def pson_transform(state, depth)
- delim = ','
- if state
- delim << state.array_nl
- result = '['
- result << state.array_nl
- result << map { |value|
- pson_shift(state, depth + 1) << value.to_pson(state, depth + 1)
- }.join(delim)
- result << state.array_nl
- result << pson_shift(state, depth)
- result << ']'
- else
- '[' << map { |value| value.to_pson }.join(delim) << ']'
- end
- end
- end
-
- module Integer
- # Returns a PSON string representation for this Integer number.
- def to_pson(*) to_s end
+ else
+ def utf8_to_pson(string) # :nodoc:
+ string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] }
+ string.gsub!(/(
+ (?:
+ [\xc2-\xdf][\x80-\xbf] |
+ [\xe0-\xef][\x80-\xbf]{2} |
+ [\xf0-\xf4][\x80-\xbf]{3}
+ )+ |
+ [\x80-\xc1\xf5-\xff] # invalid
+ )/nx) { |c|
+ c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
+ s = PSON::UTF8toUTF16.iconv(c).unpack('H*')[0]
+ s.gsub!(/.{4}/n, '\\\\u\&')
+ }
+ string
+ rescue Iconv::Failure => e
+ raise GeneratorError, "Caught #{e.class}: #{e}"
end
-
- module Float
- # Returns a PSON string representation for this Float number.
- def to_pson(state = nil, *)
- case
- when infinite?
- if !state || state.allow_nan?
- to_s
- else
- raise GeneratorError, "#{self} not allowed in PSON"
- end
- when nan?
- if !state || state.allow_nan?
- to_s
- else
- raise GeneratorError, "#{self} not allowed in PSON"
- end
- else
- to_s
+ end
+ module_function :utf8_to_pson
+
+ module Pure
+ module Generator
+ # This class is used to create State instances, that are use to hold data
+ # while generating a PSON text from a a Ruby data structure.
+ class State
+ # Creates a State object from _opts_, which ought to be Hash to create
+ # a new State instance configured by _opts_, something else to create
+ # an unconfigured instance. If _opts_ is a State object, it is just
+ # returned.
+ def self.from_state(opts)
+ case opts
+ when self
+ opts
+ when Hash
+ new(opts)
+ else
+ new
+ end
+ end
+
+ # Instantiates a new State object, configured by _opts_.
+ #
+ # _opts_ can have the following keys:
+ #
+ # * *indent*: a string used to indent levels (default: ''),
+ # * *space*: a string that is put after, a : or , delimiter (default: ''),
+ # * *space_before*: a string that is put before a : pair delimiter (default: ''),
+ # * *object_nl*: a string that is put at the end of a PSON object (default: ''),
+ # * *array_nl*: a string that is put at the end of a PSON array (default: ''),
+ # * *check_circular*: true if checking for circular data structures
+ # should be done (the default), false otherwise.
+ # * *check_circular*: true if checking for circular data structures
+ # should be done, false (the default) otherwise.
+ # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
+ # generated, otherwise an exception is thrown, if these values are
+ # encountered. This options defaults to false.
+ def initialize(opts = {})
+ @seen = {}
+ @indent = ''
+ @space = ''
+ @space_before = ''
+ @object_nl = ''
+ @array_nl = ''
+ @check_circular = true
+ @allow_nan = false
+ configure opts
+ end
+
+ # This string is used to indent levels in the PSON text.
+ attr_accessor :indent
+
+ # This string is used to insert a space between the tokens in a PSON
+ # string.
+ attr_accessor :space
+
+ # This string is used to insert a space before the ':' in PSON objects.
+ attr_accessor :space_before
+
+ # This string is put at the end of a line that holds a PSON object (or
+ # Hash).
+ attr_accessor :object_nl
+
+ # This string is put at the end of a line that holds a PSON array.
+ attr_accessor :array_nl
+
+ # This integer returns the maximum level of data structure nesting in
+ # the generated PSON, max_nesting = 0 if no maximum is checked.
+ attr_accessor :max_nesting
+
+ def check_max_nesting(depth) # :nodoc:
+ return if @max_nesting.zero?
+ current_nesting = depth + 1
+ current_nesting > @max_nesting and
+ raise NestingError, "nesting of #{current_nesting} is too deep"
+ end
+
+ # Returns true, if circular data structures should be checked,
+ # otherwise returns false.
+ def check_circular?
+ @check_circular
+ end
+
+ # Returns true if NaN, Infinity, and -Infinity should be considered as
+ # valid PSON and output.
+ def allow_nan?
+ @allow_nan
+ end
+
+ # Returns _true_, if _object_ was already seen during this generating
+ # run.
+ def seen?(object)
+ @seen.key?(object.__id__)
+ end
+
+ # Remember _object_, to find out if it was already encountered (if a
+ # cyclic data structure is if a cyclic data structure is rendered).
+ def remember(object)
+ @seen[object.__id__] = true
+ end
+
+ # Forget _object_ for this generating run.
+ def forget(object)
+ @seen.delete object.__id__
+ end
+
+ # Configure this State instance with the Hash _opts_, and return
+ # itself.
+ def configure(opts)
+ @indent = opts[:indent] if opts.key?(:indent)
+ @space = opts[:space] if opts.key?(:space)
+ @space_before = opts[:space_before] if opts.key?(:space_before)
+ @object_nl = opts[:object_nl] if opts.key?(:object_nl)
+ @array_nl = opts[:array_nl] if opts.key?(:array_nl)
+ @check_circular = !!opts[:check_circular] if opts.key?(:check_circular)
+ @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
+ if !opts.key?(:max_nesting) # defaults to 19
+ @max_nesting = 19
+ elsif opts[:max_nesting]
+ @max_nesting = opts[:max_nesting]
+ else
+ @max_nesting = 0
+ end
+ self
+ end
+
+ # Returns the configuration instance variables as a hash, that can be
+ # passed to the configure method.
+ def to_h
+ result = {}
+ for iv in %w[indent space space_before object_nl array_nl check_circular allow_nan max_nesting]
+ result[iv.intern] = instance_variable_get("@#{iv}")
+ end
+ result
+ end
end
- end
- end
- module String
- # This string should be encoded with UTF-8 A call to this method
- # returns a PSON string encoded with UTF16 big endian characters as
- # \u????.
- def to_pson(*)
- '"' << PSON.utf8_to_pson(self) << '"'
- end
-
- # Module that holds the extinding methods if, the String module is
- # included.
- module Extend
- # Raw Strings are PSON Objects (the raw bytes are stored in an array for the
- # key "raw"). The Ruby String can be created by this module method.
- def pson_create(o)
- o['raw'].pack('C*')
+ module GeneratorMethods
+ module Object
+ # Converts this object to a string (calling #to_s), converts
+ # it to a PSON string, and returns the result. This is a fallback, if no
+ # special method #to_pson was defined for some object.
+ def to_pson(*) to_s.to_pson end
+ end
+
+ module Hash
+ # Returns a PSON string containing a PSON object, that is unparsed from
+ # this Hash instance.
+ # _state_ is a PSON::State object, that can also be used to configure the
+ # produced PSON string output further.
+ # _depth_ is used to find out nesting depth, to indent accordingly.
+ def to_pson(state = nil, depth = 0, *)
+ if state
+ state = PSON.state.from_state(state)
+ state.check_max_nesting(depth)
+ pson_check_circular(state) { pson_transform(state, depth) }
+ else
+ pson_transform(state, depth)
+ end
+ end
+
+ private
+
+ def pson_check_circular(state)
+ if state and state.check_circular?
+ state.seen?(self) and raise PSON::CircularDatastructure,
+ "circular data structures not supported!"
+ state.remember self
+ end
+ yield
+ ensure
+ state and state.forget self
+ end
+
+ def pson_shift(state, depth)
+ state and not state.object_nl.empty? or return ''
+ state.indent * depth
+ end
+
+ def pson_transform(state, depth)
+ delim = ','
+ if state
+ delim << state.object_nl
+ result = '{'
+ result << state.object_nl
+ result << map { |key,value|
+ s = pson_shift(state, depth + 1)
+ s << key.to_s.to_pson(state, depth + 1)
+ s << state.space_before
+ s << ':'
+ s << state.space
+ s << value.to_pson(state, depth + 1)
+ }.join(delim)
+ result << state.object_nl
+ result << pson_shift(state, depth)
+ result << '}'
+ else
+ result = '{'
+ result << map { |key,value|
+ key.to_s.to_pson << ':' << value.to_pson
+ }.join(delim)
+ result << '}'
+ end
+ result
+ end
+ end
+
+ module Array
+ # Returns a PSON string containing a PSON array, that is unparsed from
+ # this Array instance.
+ # _state_ is a PSON::State object, that can also be used to configure the
+ # produced PSON string output further.
+ # _depth_ is used to find out nesting depth, to indent accordingly.
+ def to_pson(state = nil, depth = 0, *)
+ if state
+ state = PSON.state.from_state(state)
+ state.check_max_nesting(depth)
+ pson_check_circular(state) { pson_transform(state, depth) }
+ else
+ pson_transform(state, depth)
+ end
+ end
+
+ private
+
+ def pson_check_circular(state)
+ if state and state.check_circular?
+ state.seen?(self) and raise PSON::CircularDatastructure,
+ "circular data structures not supported!"
+ state.remember self
+ end
+ yield
+ ensure
+ state and state.forget self
+ end
+
+ def pson_shift(state, depth)
+ state and not state.array_nl.empty? or return ''
+ state.indent * depth
+ end
+
+ def pson_transform(state, depth)
+ delim = ','
+ if state
+ delim << state.array_nl
+ result = '['
+ result << state.array_nl
+ result << map { |value|
+ pson_shift(state, depth + 1) << value.to_pson(state, depth + 1)
+ }.join(delim)
+ result << state.array_nl
+ result << pson_shift(state, depth)
+ result << ']'
+ else
+ '[' << map { |value| value.to_pson }.join(delim) << ']'
+ end
+ end
+ end
+
+ module Integer
+ # Returns a PSON string representation for this Integer number.
+ def to_pson(*) to_s end
+ end
+
+ module Float
+ # Returns a PSON string representation for this Float number.
+ def to_pson(state = nil, *)
+ case
+ when infinite?
+ if !state || state.allow_nan?
+ to_s
+ else
+ raise GeneratorError, "#{self} not allowed in PSON"
+ end
+ when nan?
+ if !state || state.allow_nan?
+ to_s
+ else
+ raise GeneratorError, "#{self} not allowed in PSON"
+ end
+ else
+ to_s
+ end
+ end
+ end
+
+ module String
+ # This string should be encoded with UTF-8 A call to this method
+ # returns a PSON string encoded with UTF16 big endian characters as
+ # \u????.
+ def to_pson(*)
+ '"' << PSON.utf8_to_pson(self) << '"'
+ end
+
+ # Module that holds the extinding methods if, the String module is
+ # included.
+ module Extend
+ # Raw Strings are PSON Objects (the raw bytes are stored in an array for the
+ # key "raw"). The Ruby String can be created by this module method.
+ def pson_create(o)
+ o['raw'].pack('C*')
+ end
+ end
+
+ # Extends _modul_ with the String::Extend module.
+ def self.included(modul)
+ modul.extend Extend
+ end
+
+ # This method creates a raw object hash, that can be nested into
+ # other data structures and will be unparsed as a raw string. This
+ # method should be used, if you want to convert raw strings to PSON
+ # instead of UTF-8 strings, e. g. binary data.
+ def to_pson_raw_object
+ {
+ PSON.create_id => self.class.name,
+ 'raw' => self.unpack('C*'),
+ }
+ end
+
+ # This method creates a PSON text from the result of
+ # a call to to_pson_raw_object of this String.
+ def to_pson_raw(*args)
+ to_pson_raw_object.to_pson(*args)
+ end
+ end
+
+ module TrueClass
+ # Returns a PSON string for true: 'true'.
+ def to_pson(*) 'true' end
+ end
+
+ module FalseClass
+ # Returns a PSON string for false: 'false'.
+ def to_pson(*) 'false' end
+ end
+
+ module NilClass
+ # Returns a PSON string for nil: 'null'.
+ def to_pson(*) 'null' end
+ end
end
- end
-
- # Extends _modul_ with the String::Extend module.
- def self.included(modul)
- modul.extend Extend
- end
-
- # This method creates a raw object hash, that can be nested into
- # other data structures and will be unparsed as a raw string. This
- # method should be used, if you want to convert raw strings to PSON
- # instead of UTF-8 strings, e. g. binary data.
- def to_pson_raw_object
- {
- PSON.create_id => self.class.name,
- 'raw' => self.unpack('C*'),
- }
- end
-
- # This method creates a PSON text from the result of
- # a call to to_pson_raw_object of this String.
- def to_pson_raw(*args)
- to_pson_raw_object.to_pson(*args)
- end
- end
-
- module TrueClass
- # Returns a PSON string for true: 'true'.
- def to_pson(*) 'true' end
- end
-
- module FalseClass
- # Returns a PSON string for false: 'false'.
- def to_pson(*) 'false' end
- end
-
- module NilClass
- # Returns a PSON string for nil: 'null'.
- def to_pson(*) 'null' end
end
- end
end
- end
end
diff --git a/lib/puppet/external/pson/pure/parser.rb b/lib/puppet/external/pson/pure/parser.rb
index 56c27f762..ef14d4009 100644
--- a/lib/puppet/external/pson/pure/parser.rb
+++ b/lib/puppet/external/pson/pure/parser.rb
@@ -1,269 +1,272 @@
require 'strscan'
module PSON
- module Pure
- # This class implements the PSON parser that is used to parse a PSON string
- # into a Ruby data structure.
- class Parser < StringScanner
- STRING = /" ((?:[^\x0-\x1f"\\] |
- # escaped special characters:
- \\["\\\/bfnrt] |
- \\u[0-9a-fA-F]{4} |
- # match all but escaped special characters:
- \\[\x20-\x21\x23-\x2e\x30-\x5b\x5d-\x61\x63-\x65\x67-\x6d\x6f-\x71\x73\x75-\xff])*)
- "/nx
- INTEGER = /(-?0|-?[1-9]\d*)/
- FLOAT = /(-?
- (?:0|[1-9]\d*)
- (?:
- \.\d+(?i:e[+-]?\d+) |
- \.\d+ |
- (?i:e[+-]?\d+)
- )
- )/x
- NAN = /NaN/
- INFINITY = /Infinity/
- MINUS_INFINITY = /-Infinity/
- OBJECT_OPEN = /\{/
- OBJECT_CLOSE = /\}/
- ARRAY_OPEN = /\[/
- ARRAY_CLOSE = /\]/
- PAIR_DELIMITER = /:/
- COLLECTION_DELIMITER = /,/
- TRUE = /true/
- FALSE = /false/
- NULL = /null/
- IGNORE = %r(
- (?:
- //[^\n\r]*[\n\r]| # line comments
- /\* # c-style comments
- (?:
- [^*/]| # normal chars
- /[^*]| # slashes that do not start a nested comment
- \*[^/]| # asterisks that do not end this comment
- /(?=\*/) # single slash before this comment's end
- )*
- \*/ # the End of this comment
- |[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
- )+
- )mx
+ module Pure
+ # This class implements the PSON parser that is used to parse a PSON string
+ # into a Ruby data structure.
+ class Parser < StringScanner
+ STRING = /" ((?:[^\x0-\x1f"\\] |
+ # escaped special characters:
+ \\["\\\/bfnrt] |
+ \\u[0-9a-fA-F]{4} |
+ # match all but escaped special characters:
+ \\[\x20-\x21\x23-\x2e\x30-\x5b\x5d-\x61\x63-\x65\x67-\x6d\x6f-\x71\x73\x75-\xff])*)
+ "/nx
+ INTEGER = /(-?0|-?[1-9]\d*)/
+ FLOAT = /(-?
+ (?:0|[1-9]\d*)
+ (?:
+ \.\d+(?i:e[+-]?\d+) |
+ \.\d+ |
+ (?i:e[+-]?\d+)
+ )
+ )/x
+ NAN = /NaN/
+ INFINITY = /Infinity/
+ MINUS_INFINITY = /-Infinity/
+ OBJECT_OPEN = /\{/
+ OBJECT_CLOSE = /\}/
+ ARRAY_OPEN = /\[/
+ ARRAY_CLOSE = /\]/
+ PAIR_DELIMITER = /:/
+ COLLECTION_DELIMITER = /,/
+ TRUE = /true/
+ FALSE = /false/
+ NULL = /null/
+ IGNORE = %r(
+ (?:
+ //[^\n\r]*[\n\r]| # line comments
+ /\* # c-style comments
+ (?:
+ [^*/]| # normal chars
+ /[^*]| # slashes that do not start a nested comment
+ \*[^/]| # asterisks that do not end this comment
+ /(?=\*/) # single slash before this comment's end
+ )*
+ \*/ # the End of this comment
+ |[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
+ )+
+ )mx
- UNPARSED = Object.new
+ UNPARSED = Object.new
- # Creates a new PSON::Pure::Parser instance for the string _source_.
- #
- # It will be configured by the _opts_ hash. _opts_ can have the following
- # keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Disable depth checking with :max_nesting => false|nil|0,
- # it defaults to 19.
- # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to false.
- # * *create_additions*: If set to false, the Parser doesn't create
- # additions even if a matchin class and create_id was found. This option
- # defaults to true.
- # * *object_class*: Defaults to Hash
- # * *array_class*: Defaults to Array
- def initialize(source, opts = {})
- super
- if !opts.key?(:max_nesting) # defaults to 19
- @max_nesting = 19
- elsif opts[:max_nesting]
- @max_nesting = opts[:max_nesting]
- else
- @max_nesting = 0
- end
- @allow_nan = !!opts[:allow_nan]
- ca = true
- ca = opts[:create_additions] if opts.key?(:create_additions)
- @create_id = ca ? PSON.create_id : nil
- @object_class = opts[:object_class] || Hash
- @array_class = opts[:array_class] || Array
- end
+ # Creates a new PSON::Pure::Parser instance for the string _source_.
+ #
+ # It will be configured by the _opts_ hash. _opts_ can have the following
+ # keys:
+ # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ # structures. Disable depth checking with :max_nesting => false|nil|0,
+ # it defaults to 19.
+ # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
+ # defiance of RFC 4627 to be parsed by the Parser. This option defaults
+ # to false.
+ # * *create_additions*: If set to false, the Parser doesn't create
+ # additions even if a matchin class and create_id was found. This option
+ # defaults to true.
+ # * *object_class*: Defaults to Hash
+ # * *array_class*: Defaults to Array
+ def initialize(source, opts = {})
+ super
+ if !opts.key?(:max_nesting) # defaults to 19
+ @max_nesting = 19
+ elsif opts[:max_nesting]
+ @max_nesting = opts[:max_nesting]
+ else
+ @max_nesting = 0
+ end
+ @allow_nan = !!opts[:allow_nan]
+ ca = true
+ ca = opts[:create_additions] if opts.key?(:create_additions)
+ @create_id = ca ? PSON.create_id : nil
+ @object_class = opts[:object_class] || Hash
+ @array_class = opts[:array_class] || Array
+ end
- alias source string
+ alias source string
- # Parses the current PSON string _source_ and returns the complete data
- # structure as a result.
- def parse
- reset
- obj = nil
- until eos?
- case
- when scan(OBJECT_OPEN)
- obj and raise ParserError, "source '#{peek(20)}' not in PSON!"
- @current_nesting = 1
- obj = parse_object
- when scan(ARRAY_OPEN)
- obj and raise ParserError, "source '#{peek(20)}' not in PSON!"
- @current_nesting = 1
- obj = parse_array
- when skip(IGNORE)
- ;
- else
- raise ParserError, "source '#{peek(20)}' not in PSON!"
- end
- end
- obj or raise ParserError, "source did not contain any PSON!"
- obj
- end
+ # Parses the current PSON string _source_ and returns the complete data
+ # structure as a result.
+ def parse
+ reset
+ obj = nil
+ until eos?
+ case
+ when scan(OBJECT_OPEN)
+ obj and raise ParserError, "source '#{peek(20)}' not in PSON!"
+ @current_nesting = 1
+ obj = parse_object
+ when scan(ARRAY_OPEN)
+ obj and raise ParserError, "source '#{peek(20)}' not in PSON!"
+ @current_nesting = 1
+ obj = parse_array
+ when skip(IGNORE)
+ ;
+ else
+ raise ParserError, "source '#{peek(20)}' not in PSON!"
+ end
+ end
+ obj or raise ParserError, "source did not contain any PSON!"
+ obj
+ end
- private
+ private
- # Unescape characters in strings.
- UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
- UNESCAPE_MAP.update({
- ?" => '"',
- ?\\ => '\\',
- ?/ => '/',
- ?b => "\b",
- ?f => "\f",
- ?n => "\n",
- ?r => "\r",
- ?t => "\t",
- ?u => nil,
- })
+ # Unescape characters in strings.
+ UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
- def parse_string
- if scan(STRING)
- return '' if self[1].empty?
- string = self[1].gsub(%r{(?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff])}n) do |c|
- if u = UNESCAPE_MAP[$&[1]]
- u
- else # \uXXXX
- bytes = ''
- i = 0
- while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
- bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
- i += 1
- end
- PSON::UTF16toUTF8.iconv(bytes)
- end
- end
- if string.respond_to?(:force_encoding)
- string.force_encoding(Encoding::UTF_8)
- end
- string
- else
- UNPARSED
- end
- rescue Iconv::Failure => e
- raise GeneratorError, "Caught #{e.class}: #{e}"
- end
+ UNESCAPE_MAP.update(
+ {
+ ?" => '"',
+ ?\\ => '\\',
+ ?/ => '/',
+ ?b => "\b",
+ ?f => "\f",
+ ?n => "\n",
+ ?r => "\r",
+ ?t => "\t",
+ ?u => nil,
- def parse_value
- case
- when scan(FLOAT)
- Float(self[1])
- when scan(INTEGER)
- Integer(self[1])
- when scan(TRUE)
- true
- when scan(FALSE)
- false
- when scan(NULL)
- nil
- when (string = parse_string) != UNPARSED
- string
- when scan(ARRAY_OPEN)
- @current_nesting += 1
- ary = parse_array
- @current_nesting -= 1
- ary
- when scan(OBJECT_OPEN)
- @current_nesting += 1
- obj = parse_object
- @current_nesting -= 1
- obj
- when @allow_nan && scan(NAN)
- NaN
- when @allow_nan && scan(INFINITY)
- Infinity
- when @allow_nan && scan(MINUS_INFINITY)
- MinusInfinity
- else
- UNPARSED
- end
- end
+ })
- def parse_array
- raise NestingError, "nesting of #@current_nesting is too deep" if
- @max_nesting.nonzero? && @current_nesting > @max_nesting
- result = @array_class.new
- delim = false
- until eos?
- case
- when (value = parse_value) != UNPARSED
- delim = false
- result << value
- skip(IGNORE)
- if scan(COLLECTION_DELIMITER)
- delim = true
- elsif match?(ARRAY_CLOSE)
- ;
- else
- raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!"
- end
- when scan(ARRAY_CLOSE)
- if delim
- raise ParserError, "expected next element in array at '#{peek(20)}'!"
+ def parse_string
+ if scan(STRING)
+ return '' if self[1].empty?
+ string = self[1].gsub(%r{(?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff])}n) do |c|
+ if u = UNESCAPE_MAP[$&[1]]
+ u
+ else # \uXXXX
+ bytes = ''
+ i = 0
+ while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
+ bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
+ i += 1
+ end
+ PSON::UTF16toUTF8.iconv(bytes)
+ end
+ end
+ if string.respond_to?(:force_encoding)
+ string.force_encoding(Encoding::UTF_8)
+ end
+ string
+ else
+ UNPARSED
+ end
+ rescue Iconv::Failure => e
+ raise GeneratorError, "Caught #{e.class}: #{e}"
end
- break
- when skip(IGNORE)
- ;
- else
- raise ParserError, "unexpected token in array at '#{peek(20)}'!"
- end
- end
- result
- end
- def parse_object
- raise NestingError, "nesting of #@current_nesting is too deep" if
- @max_nesting.nonzero? && @current_nesting > @max_nesting
- result = @object_class.new
- delim = false
- until eos?
- case
- when (string = parse_string) != UNPARSED
- skip(IGNORE)
- unless scan(PAIR_DELIMITER)
- raise ParserError, "expected ':' in object at '#{peek(20)}'!"
+ def parse_value
+ case
+ when scan(FLOAT)
+ Float(self[1])
+ when scan(INTEGER)
+ Integer(self[1])
+ when scan(TRUE)
+ true
+ when scan(FALSE)
+ false
+ when scan(NULL)
+ nil
+ when (string = parse_string) != UNPARSED
+ string
+ when scan(ARRAY_OPEN)
+ @current_nesting += 1
+ ary = parse_array
+ @current_nesting -= 1
+ ary
+ when scan(OBJECT_OPEN)
+ @current_nesting += 1
+ obj = parse_object
+ @current_nesting -= 1
+ obj
+ when @allow_nan && scan(NAN)
+ NaN
+ when @allow_nan && scan(INFINITY)
+ Infinity
+ when @allow_nan && scan(MINUS_INFINITY)
+ MinusInfinity
+ else
+ UNPARSED
+ end
end
- skip(IGNORE)
- unless (value = parse_value).equal? UNPARSED
- result[string] = value
- delim = false
- skip(IGNORE)
- if scan(COLLECTION_DELIMITER)
- delim = true
- elsif match?(OBJECT_CLOSE)
- ;
- else
- raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!"
- end
- else
- raise ParserError, "expected value in object at '#{peek(20)}'!"
- end
- when scan(OBJECT_CLOSE)
- if delim
- raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!"
+
+ def parse_array
+ raise NestingError, "nesting of #@current_nesting is too deep" if
+ @max_nesting.nonzero? && @current_nesting > @max_nesting
+ result = @array_class.new
+ delim = false
+ until eos?
+ case
+ when (value = parse_value) != UNPARSED
+ delim = false
+ result << value
+ skip(IGNORE)
+ if scan(COLLECTION_DELIMITER)
+ delim = true
+ elsif match?(ARRAY_CLOSE)
+ ;
+ else
+ raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!"
+ end
+ when scan(ARRAY_CLOSE)
+ if delim
+ raise ParserError, "expected next element in array at '#{peek(20)}'!"
+ end
+ break
+ when skip(IGNORE)
+ ;
+ else
+ raise ParserError, "unexpected token in array at '#{peek(20)}'!"
+ end
+ end
+ result
end
- if @create_id and klassname = result[@create_id]
- klass = PSON.deep_const_get klassname
- break unless klass and klass.pson_creatable?
- result = klass.pson_create(result)
+
+ def parse_object
+ raise NestingError, "nesting of #@current_nesting is too deep" if
+ @max_nesting.nonzero? && @current_nesting > @max_nesting
+ result = @object_class.new
+ delim = false
+ until eos?
+ case
+ when (string = parse_string) != UNPARSED
+ skip(IGNORE)
+ unless scan(PAIR_DELIMITER)
+ raise ParserError, "expected ':' in object at '#{peek(20)}'!"
+ end
+ skip(IGNORE)
+ unless (value = parse_value).equal? UNPARSED
+ result[string] = value
+ delim = false
+ skip(IGNORE)
+ if scan(COLLECTION_DELIMITER)
+ delim = true
+ elsif match?(OBJECT_CLOSE)
+ ;
+ else
+ raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!"
+ end
+ else
+ raise ParserError, "expected value in object at '#{peek(20)}'!"
+ end
+ when scan(OBJECT_CLOSE)
+ if delim
+ raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!"
+ end
+ if @create_id and klassname = result[@create_id]
+ klass = PSON.deep_const_get klassname
+ break unless klass and klass.pson_creatable?
+ result = klass.pson_create(result)
+ end
+ break
+ when skip(IGNORE)
+ ;
+ else
+ raise ParserError, "unexpected token in object at '#{peek(20)}'!"
+ end
+ end
+ result
end
- break
- when skip(IGNORE)
- ;
- else
- raise ParserError, "unexpected token in object at '#{peek(20)}'!"
- end
end
- result
- end
end
- end
end
diff --git a/lib/puppet/external/pson/version.rb b/lib/puppet/external/pson/version.rb
index a5a8e4702..0bcfa4ad8 100644
--- a/lib/puppet/external/pson/version.rb
+++ b/lib/puppet/external/pson/version.rb
@@ -1,8 +1,8 @@
module PSON
- # PSON version
- VERSION = '1.1.9'
- VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
- VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
- VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
- VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
+ # PSON version
+ VERSION = '1.1.9'
+ VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
end
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb
index a7ab9b66e..3543df8d7 100644
--- a/lib/puppet/file_serving/base.rb
+++ b/lib/puppet/file_serving/base.rb
@@ -86,7 +86,7 @@ class Puppet::FileServing::Base
'metadata' => {
'api_version' => 1
}
- }
+ }
end
end
diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb
index eef2d7852..d8bf30477 100644
--- a/lib/puppet/file_serving/configuration/parser.rb
+++ b/lib/puppet/file_serving/configuration/parser.rb
@@ -36,12 +36,10 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile
when "deny"
deny(mount, value)
else
- raise ArgumentError.new("Invalid argument '%s'" % var,
- @count, file)
+ raise ArgumentError.new("Invalid argument '%s'" % var, @count, file)
end
else
- raise ArgumentError.new("Invalid line '%s'" % line.chomp,
- @count, file)
+ raise ArgumentError.new("Invalid line '%s'" % line.chomp, @count, file)
end
}
}
@@ -61,7 +59,10 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile
mount.info "allowing %s access" % val
mount.allow(val)
rescue AuthStoreError => detail
- raise ArgumentError.new(detail.to_s,
+
+ raise ArgumentError.new(
+ detail.to_s,
+
@count, file)
end
}
@@ -75,7 +76,10 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile
mount.info "denying %s access" % val
mount.deny(val)
rescue AuthStoreError => detail
- raise ArgumentError.new(detail.to_s,
+
+ raise ArgumentError.new(
+ detail.to_s,
+
@count, file)
end
}
@@ -84,8 +88,7 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile
# Create a new mount.
def newmount(name)
if @mounts.include?(name)
- raise ArgumentError, "%s is already mounted at %s" %
- [@mounts[name], name], @count, file
+ raise ArgumentError, "%s is already mounted at %s" % [@mounts[name], name], @count, file
end
case name
when "modules"
diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb
index 6790c1a78..848a5f963 100644
--- a/lib/puppet/file_serving/metadata.rb
+++ b/lib/puppet/file_serving/metadata.rb
@@ -87,29 +87,32 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
def to_pson_data_hash
{
'document_type' => 'FileMetadata',
- 'data' => super['data'].update({
- 'owner' => owner,
- 'group' => group,
- 'mode' => mode,
- 'checksum' => {
- 'type' => checksum_type,
- 'value' => checksum
+
+ 'data' => super['data'].update(
+ {
+ 'owner' => owner,
+ 'group' => group,
+ 'mode' => mode,
+ 'checksum' => {
+ 'type' => checksum_type,
+ 'value' => checksum
},
'type' => ftype,
'destination' => destination,
+
}),
'metadata' => {
'api_version' => 1
}
- }
+ }
end
def to_pson(*args)
- to_pson_data_hash.to_pson(*args)
+ to_pson_data_hash.to_pson(*args)
end
def self.from_pson(data)
- new(data.delete('path'), data)
+ new(data.delete('path'), data)
end
end
diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb
index e1eaf6052..8a619e962 100644
--- a/lib/puppet/file_serving/mount/file.rb
+++ b/lib/puppet/file_serving/mount/file.rb
@@ -96,8 +96,7 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount
if node
map = clientmap(node)
else
- Puppet.notice "No client; expanding '%s' with local host" %
- path
+ Puppet.notice "No client; expanding '%s' with local host" % path
# Else, use the local information
map = localmap()
end
@@ -114,7 +113,7 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount
# Do we have any patterns in our path, yo?
def expandable?
- if defined? @expandable
+ if defined?(@expandable)
@expandable
else
false
diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb
index 91c759331..4f56b2fc4 100644
--- a/lib/puppet/indirector.rb
+++ b/lib/puppet/indirector.rb
@@ -31,7 +31,7 @@ module Puppet::Indirector
@indirection
end
- module ClassMethods
+ module ClassMethods
attr_reader :indirection
def cache_class=(klass)
@@ -41,12 +41,12 @@ module Puppet::Indirector
def terminus_class=(klass)
indirection.terminus_class = klass
end
-
+
# Expire any cached instance.
def expire(*args)
indirection.expire(*args)
end
-
+
def find(*args)
indirection.find(*args)
end
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 06aa19077..85890f24c 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -79,7 +79,7 @@ class Puppet::Indirector::Indirection
def doc
text = ""
- if defined? @doc and @doc
+ if defined?(@doc) and @doc
text += scrub(@doc) + "\n\n"
end
diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb
index ab3c7ef54..390fe6793 100644
--- a/lib/puppet/indirector/ldap.rb
+++ b/lib/puppet/indirector/ldap.rb
@@ -61,7 +61,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
# Create an ldap connection.
def connection
- unless defined? @connection and @connection
+ unless defined?(@connection) and @connection
unless Puppet.features.ldap?
raise Puppet::Error, "Could not set up LDAP Connection: Missing ruby/ldap libraries"
end
diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb
index c9c922b5b..2d58df68a 100644
--- a/lib/puppet/indirector/node/ldap.rb
+++ b/lib/puppet/indirector/node/ldap.rb
@@ -21,28 +21,28 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
# with our error handling.
def name2hash(name,name_env,node_type)
info = nil
- ldapsearch(search_filter(name)) {
- |entry| info = entry2hash(entry)
- if info[:environment]
- if name_env == info[:environment]
- return info
- else
+ ldapsearch(search_filter(name)) {
+ |entry| info = entry2hash(entry)
+ if info[:environment]
+ if name_env == info[:environment]
+ return info
+ else
info = nil
- end
- else
- info_env = "production"
- if name_env == info[:environment]
+ end
+ else
+ info_env = "production"
+ if name_env == info[:environment]
return info
- else
+ else
info = nil
- end
- end
- }
+ end
+ end
+ }
if node_type == 'parent'
- raise Puppet::Error.new("Could not find node '%s' with environment '%s'" % [name,name_env])
+ raise Puppet::Error.new("Could not find node '%s' with environment '%s'" % [name,name_env])
end
- info = name2hash('default',name_env,'parent')
+ info = name2hash('default',name_env,'parent')
return info
end
@@ -58,15 +58,15 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
names.each do |name|
facts = Puppet::Node::Facts.find(name)
if facts.values["environment"]
- name_env = facts.values["environment"]
+ name_env = facts.values["environment"]
else
- name_env = "production"
+ name_env = "production"
end
info = name2hash(name,name_env,'child')
next if info == nil
if info
- break if node = info2node(request.key, info)
+ break if node = info2node(request.key, info)
end
end
@@ -205,26 +205,26 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
def find_and_merge_parent(parent, information)
if information[:environment]
- name_env = information[:environment]
+ name_env = information[:environment]
else
- name_env = 'production'
+ name_env = 'production'
end
parent_info = name2hash(parent,name_env,'parent')
if parent_info
- information[:classes] += parent_info[:classes]
- parent_info[:parameters].each do |param, value|
+ information[:classes] += parent_info[:classes]
+ parent_info[:parameters].each do |param, value|
# Specifically test for whether it's set, so false values are handled
# correctly.
information[:parameters][param] = value unless information[:parameters].include?(param)
- end
+ end
- information[:environment] ||= parent_info[:environment]
- parent_info[:parent]
+ information[:environment] ||= parent_info[:environment]
+ parent_info[:parent]
else
- raise Puppet::Error.new("Could not find parent node '%s'" % parent)
- nil
- end
+ raise Puppet::Error.new("Could not find parent node '%s'" % parent)
+ nil
+ end
end
diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb
index 9daf14641..1ff2e0e84 100644
--- a/lib/puppet/indirector/report/processor.rb
+++ b/lib/puppet/indirector/report/processor.rb
@@ -34,8 +34,7 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code
if Puppet[:trace]
puts detail.backtrace
end
- Puppet.err "Report %s failed: %s" %
- [name, detail]
+ Puppet.err "Report %s failed: %s" % [name, detail]
end
else
Puppet.warning "No report named '%s'" % name
diff --git a/lib/puppet/indirector/ssl_file.rb b/lib/puppet/indirector/ssl_file.rb
index fc1e65d22..67202699d 100644
--- a/lib/puppet/indirector/ssl_file.rb
+++ b/lib/puppet/indirector/ssl_file.rb
@@ -91,7 +91,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
def save(request)
path = path(request.key)
dir = File.dirname(path)
-
+
raise Puppet::Error.new("Cannot save %s; parent directory %s does not exist" % [request.key, dir]) unless FileTest.directory?(dir)
raise Puppet::Error.new("Cannot save %s; parent directory %s is not writable" % [request.key, dir]) unless FileTest.writable?(dir)
diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb
index 39d4751fc..2ff267f06 100644
--- a/lib/puppet/indirector/yaml.rb
+++ b/lib/puppet/indirector/yaml.rb
@@ -55,7 +55,7 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
# Do a glob on the yaml directory, loading each file found
def search(request)
- Dir.glob(File.join(base, self.class.indirection_name.to_s, request.key)).collect { |f| YAML.load_file(f) }
+ Dir.glob(File.join(base, self.class.indirection_name.to_s, request.key)).collect { |f| YAML.load_file(f) }
end
private
diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb
index f7910e3a9..590562633 100644
--- a/lib/puppet/metatype/manager.rb
+++ b/lib/puppet/metatype/manager.rb
@@ -60,8 +60,11 @@ module Manager
end
# Then create the class.
- klass = genclass(name,
+
+ klass = genclass(
+ name,
:parent => (parent || Puppet::Type),
+
:overwrite => true,
:hash => @types,
:attributes => options,
@@ -85,7 +88,10 @@ module Manager
end
# Now set up autoload any providers that might exist for this type.
- klass.providerloader = Puppet::Util::Autoload.new(klass,
+
+ klass.providerloader = Puppet::Util::Autoload.new(
+ klass,
+
"puppet/provider/#{klass.name.to_s}"
)
@@ -98,7 +104,10 @@ module Manager
# Remove an existing defined type. Largely used for testing.
def rmtype(name)
# Then create the class.
- klass = rmclass(name,
+
+ klass = rmclass(
+ name,
+
:hash => @types
)
@@ -128,8 +137,11 @@ module Manager
# Create a loader for Puppet types.
def typeloader
- unless defined? @typeloader
- @typeloader = Puppet::Util::Autoload.new(self,
+ unless defined?(@typeloader)
+
+ @typeloader = Puppet::Util::Autoload.new(
+ self,
+
"puppet/type", :wrap => false
)
end
diff --git a/lib/puppet/network/authconfig.rb b/lib/puppet/network/authconfig.rb
index bf037fbcc..3ee4df306 100644
--- a/lib/puppet/network/authconfig.rb
+++ b/lib/puppet/network/authconfig.rb
@@ -6,7 +6,7 @@ module Puppet
class Network::AuthConfig < Puppet::Util::LoadedFile
def self.main
- unless defined? @main
+ unless defined?(@main)
@main = self.new()
end
@main
@@ -105,7 +105,7 @@ module Puppet
count += 1
next
when /^(?:(\[[\w.]+\])|(path)\s+((?:~\s+)?[^ ]+))\s*$/ # "namespace" or "namespace.method" or "path /path" or "path ~ regex"
- name = $1
+ name = $1
if $2 == "path"
name = $3
end
@@ -123,8 +123,7 @@ module Puppet
Puppet.err "Configuration error: Cannot read %s; cannot serve" % @file
#raise Puppet::Error, "Cannot read %s" % @config
rescue Errno::ENOENT => detail
- Puppet.err "Configuration error: '%s' does not exit; cannot serve" %
- @file
+ Puppet.err "Configuration error: '%s' does not exit; cannot serve" % @file
#raise Puppet::Error, "%s does not exit" % @config
#rescue FileServerError => detail
# Puppet.err "FileServer error: %s" % detail
diff --git a/lib/puppet/network/authorization.rb b/lib/puppet/network/authorization.rb
index eb7690db4..d65aeeb6a 100644
--- a/lib/puppet/network/authorization.rb
+++ b/lib/puppet/network/authorization.rb
@@ -10,7 +10,7 @@ module Puppet::Network
# Create our config object if necessary. This works even if
# there's no configuration file.
def authconfig
- unless defined? @authconfig
+ unless defined?(@authconfig)
@authconfig = Puppet::Network::AuthConfig.main()
end
@@ -20,9 +20,7 @@ module Puppet::Network
# Verify that our client has access. We allow untrusted access to
# puppetca methods but no others.
def authorized?(request)
- msg = "%s client %s access to %s" %
- [request.authenticated? ? "authenticated" : "unauthenticated",
- request, request.call]
+ msg = "%s client %s access to %s" % [request.authenticated? ? "authenticated" : "unauthenticated", request, request.call]
if request.authenticated?
if authconfig.exists?
@@ -57,8 +55,7 @@ module Puppet::Network
if handler_loaded?(request.handler)
return true
else
- Puppet.warning "Client %s requested unavailable functionality %s" %
- [request, request.handler]
+ Puppet.warning "Client %s requested unavailable functionality %s" % [request, request.handler]
return false
end
end
@@ -72,8 +69,7 @@ module Puppet::Network
end
unless authorized?(request)
raise InvalidClientRequest.new(
- "Host %s not authorized to call %s" %
- [request, request.call]
+ "Host %s not authorized to call %s" % [request, request.call]
)
end
end
diff --git a/lib/puppet/network/authstore.rb b/lib/puppet/network/authstore.rb
index a7029a0a0..eb3400dd9 100755
--- a/lib/puppet/network/authstore.rb
+++ b/lib/puppet/network/authstore.rb
@@ -127,7 +127,7 @@ module Puppet
# Sort the declarations most specific first.
def <=>(other)
- compare(exact?, other.exact?) ||
+ compare(exact?, other.exact?) ||
compare(ip?, other.ip?) ||
((length != other.length) && (other.length <=> length)) ||
compare(deny?, other.deny?) ||
@@ -230,7 +230,7 @@ module Puppet
@name,@exact,@length,@pattern = *case value
when /^(?:#{IP})\/(\d+)$/ # 12.34.56.78/24, a001:b002::efff/120, c444:1000:2000::9:192.168.0.1/112
[:ip,:inexact,$1.to_i,IPAddr.new(value)]
- when /^(#{IP})$/ # 10.20.30.40,
+ when /^(#{IP})$/ # 10.20.30.40,
[:ip,:exact,nil,IPAddr.new(value)]
when /^(#{Octet}\.){1,3}\*$/ # an ip address with a '*' at the end
segments = value.split(".")[0..-2]
diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb
index 429e2563f..f53dd3a79 100644
--- a/lib/puppet/network/client.rb
+++ b/lib/puppet/network/client.rb
@@ -14,7 +14,7 @@ require 'net/http'
# us to never use ssl. Yay.
class Net::HTTP
def use_ssl?
- if defined? @use_ssl
+ if defined?(@use_ssl)
@use_ssl
else
false
@@ -50,7 +50,7 @@ class Puppet::Network::Client
# Determine what clients look for when being passed an object for local
# client/server stuff. E.g., you could call Client::CA.new(:CA => ca).
def self.drivername
- unless defined? @drivername
+ unless defined?(@drivername)
@drivername = self.name
end
@drivername
@@ -58,7 +58,7 @@ class Puppet::Network::Client
# Figure out the handler for our client.
def self.handler
- unless defined? @handler
+ unless defined?(@handler)
@handler = Puppet::Network::Handler.handler(self.name)
end
@handler
@@ -66,7 +66,7 @@ class Puppet::Network::Client
# The class that handles xmlrpc interaction for us.
def self.xmlrpc_client
- unless defined? @xmlrpc_client
+ unless defined?(@xmlrpc_client)
@xmlrpc_client = Puppet::Network::XMLRPCClient.handler_class(self.handler)
end
@xmlrpc_client
@@ -112,7 +112,7 @@ class Puppet::Network::Client
# Are we a local client?
def local?
- if defined? @local and @local
+ if defined?(@local) and @local
true
else
false
@@ -140,8 +140,7 @@ class Puppet::Network::Client
end
def run
- raise Puppet::DevError, "Client type %s did not override run" %
- self.class
+ raise Puppet::DevError, "Client type %s did not override run" % self.class
end
def scheduled?
@@ -168,9 +167,12 @@ class Puppet::Network::Client
# timer events here.
def start
# Create our timer. Puppet will handle observing it and such.
- timer = Puppet.newtimer(
+
+ timer = Puppet.newtimer(
+
:interval => Puppet[:runinterval],
:tolerance => 1,
+
:start? => true
) do
begin
diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb
index eec632d72..dfdb4cc67 100644
--- a/lib/puppet/network/formats.rb
+++ b/lib/puppet/network/formats.rb
@@ -65,13 +65,13 @@ Puppet::Network::FormatHandler.create(:b64_zlib_yaml, :mime => "text/b64_zlib_ya
end
def encode(text)
- requiring_zlib do
+ requiring_zlib do
Base64.encode64(Zlib::Deflate.deflate(text, Zlib::BEST_COMPRESSION))
end
end
def decode(yaml)
- requiring_zlib do
+ requiring_zlib do
YAML.load(Zlib::Inflate.inflate(Base64.decode64(yaml)))
end
end
diff --git a/lib/puppet/network/handler.rb b/lib/puppet/network/handler.rb
index f6a658662..95e3101f2 100644
--- a/lib/puppet/network/handler.rb
+++ b/lib/puppet/network/handler.rb
@@ -19,11 +19,10 @@ module Puppet::Network
# Return the xmlrpc interface.
def self.interface
- if defined? @interface
+ if defined?(@interface)
return @interface
else
- raise Puppet::DevError, "Handler %s has no defined interface" %
- self
+ raise Puppet::DevError, "Handler %s has no defined interface" % self
end
end
diff --git a/lib/puppet/network/handler/ca.rb b/lib/puppet/network/handler/ca.rb
index de7a976c8..20d971007 100644
--- a/lib/puppet/network/handler/ca.rb
+++ b/lib/puppet/network/handler/ca.rb
@@ -19,7 +19,7 @@ class Puppet::Network::Handler
}
def autosign
- if defined? @autosign
+ if defined?(@autosign)
@autosign
else
Puppet[:autosign]
@@ -35,12 +35,11 @@ class Puppet::Network::Handler
# we only otherwise know how to handle files
unless autosign =~ /^\//
- raise Puppet::Error, "Invalid autosign value %s" %
- autosign.inspect
+ raise Puppet::Error, "Invalid autosign value %s" % autosign.inspect
end
unless FileTest.exists?(autosign)
- unless defined? @@warnedonautosign
+ unless defined?(@@warnedonautosign)
@@warnedonautosign = true
Puppet.info "Autosign is enabled but %s is missing" % autosign
end
@@ -124,8 +123,7 @@ class Puppet::Network::Handler
if @ca.getclientcsr(hostname)
Puppet.info "Not replacing existing request from %s" % hostname
else
- Puppet.notice "Host %s has a waiting certificate request" %
- hostname
+ Puppet.notice "Host %s has a waiting certificate request" % hostname
@ca.storeclientcsr(csr)
end
return ["", ""]
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 84af5ac55..a48d05d91 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -107,8 +107,7 @@ class Puppet::Network::Handler
if hash.include?(:Mount)
@passedconfig = true
unless hash[:Mount].is_a?(Hash)
- raise Puppet::DevError, "Invalid mount hash %s" %
- hash[:Mount].inspect
+ raise Puppet::DevError, "Invalid mount hash %s" % hash[:Mount].inspect
end
hash[:Mount].each { |dir, name|
@@ -159,8 +158,7 @@ class Puppet::Network::Handler
def mount(path, name)
if @mounts.include?(name)
if @mounts[name] != path
- raise FileServerError, "%s is already mounted at %s" %
- [@mounts[name].path, name]
+ raise FileServerError, "%s is already mounted at %s" % [@mounts[name].path, name]
else
# it's already mounted; no problem
return
@@ -219,8 +217,7 @@ class Puppet::Network::Handler
clientip = nil
end
unless mount.allowed?(client, clientip)
- mount.warning "%s cannot access %s" %
- [client, file]
+ mount.warning "%s cannot access %s" % [client, file]
raise Puppet::AuthorizationError, "Cannot access %s" % mount
end
end
@@ -283,8 +280,7 @@ class Puppet::Network::Handler
when /\[([-\w]+)\]/
name = $1
if newmounts.include?(name)
- raise FileServerError, "%s is already mounted as %s in %s" %
- [newmounts[name], name, @configuration.file]
+ raise FileServerError, "%s is already mounted as %s in %s" % [newmounts[name], name, @configuration.file]
end
mount = Mount.new(name)
newmounts[name] = mount
@@ -299,8 +295,7 @@ class Puppet::Network::Handler
begin
mount.path = value
rescue FileServerError => detail
- Puppet.err "Removing mount %s: %s" %
- [mount.name, detail]
+ Puppet.err "Removing mount %s: %s" % [mount.name, detail]
newmounts.delete(mount.name)
end
end
@@ -311,7 +306,10 @@ class Puppet::Network::Handler
mount.allow(val)
rescue AuthStoreError => detail
puts detail.backtrace if Puppet[:trace]
- raise FileServerError.new(detail.to_s,
+
+ raise FileServerError.new(
+ detail.to_s,
+
count, @configuration.file)
end
}
@@ -321,17 +319,18 @@ class Puppet::Network::Handler
mount.info "denying %s access" % val
mount.deny(val)
rescue AuthStoreError => detail
- raise FileServerError.new(detail.to_s,
+
+ raise FileServerError.new(
+ detail.to_s,
+
count, @configuration.file)
end
}
else
- raise FileServerError.new("Invalid argument '%s'" % var,
- count, @configuration.file)
+ raise FileServerError.new("Invalid argument '%s'" % var, count, @configuration.file)
end
else
- raise FileServerError.new("Invalid line '%s'" % line.chomp,
- count, @configuration.file)
+ raise FileServerError.new("Invalid line '%s'" % line.chomp, count, @configuration.file)
end
count += 1
}
@@ -340,8 +339,7 @@ class Puppet::Network::Handler
Puppet.err "FileServer error: Cannot read %s; cannot serve" % @configuration
#raise Puppet::Error, "Cannot read %s" % @configuration
rescue Errno::ENOENT => detail
- Puppet.err "FileServer error: '%s' does not exist; cannot serve" %
- @configuration
+ Puppet.err "FileServer error: '%s' does not exist; cannot serve" % @configuration
end
unless newmounts[MODULES]
@@ -368,9 +366,12 @@ class Puppet::Network::Handler
# object...
mount = PluginMount.new(PLUGINS)
# Yes, you're allowed to hate me for this.
- mount.instance_variable_set(:@declarations,
- newmounts[PLUGINS].instance_variable_get(:@declarations)
- )
+
+ mount.instance_variable_set(
+ :@declarations,
+
+ newmounts[PLUGINS].instance_variable_get(:@declarations)
+ )
newmounts[PLUGINS] = mount
end
@@ -379,8 +380,7 @@ class Puppet::Network::Handler
# pointing to the specific problem.
newmounts.each { |name, mount|
unless mount.valid?
- raise FileServerError, "Invalid mount %s" %
- name
+ raise FileServerError, "Invalid mount %s" % name
end
}
@mounts = newmounts
@@ -448,8 +448,7 @@ class Puppet::Network::Handler
if client
map = clientmap(client)
else
- Puppet.notice "No client; expanding '%s' with local host" %
- path
+ Puppet.notice "No client; expanding '%s' with local host" % path
# Else, use the local information
map = localmap()
end
@@ -465,7 +464,7 @@ class Puppet::Network::Handler
# Do we have any patterns in our path, yo?
def expandable?
- if defined? @expandable
+ if defined?(@expandable)
@expandable
else
false
@@ -515,8 +514,11 @@ class Puppet::Network::Handler
# the effort.
obj[:audit] = CHECKPARAMS
else
+
obj = Puppet::Type.type(:file).new(
+
:name => file_path(path, client),
+
:audit => CHECKPARAMS
)
@files[file_path(path, client)] = obj
@@ -542,11 +544,11 @@ class Puppet::Network::Handler
# Cache this manufactured map, since if it's used it's likely
# to get used a lot.
def localmap
- unless defined? @@localmap
+ unless defined?(@@localmap)
@@localmap = {
"h" => Facter.value("hostname"),
"H" => [Facter.value("hostname"),
- Facter.value("domain")].join("."),
+ Facter.value("domain")].join("."),
"d" => Facter.value("domain")
}
end
@@ -710,7 +712,7 @@ class Puppet::Network::Handler
end
def path_exists?(relpath, client = nil)
- !valid_modules(client).find { |mod| mod.plugin(relpath) }.nil?
+ !valid_modules(client).find { |mod| mod.plugin(relpath) }.nil?
end
def valid?
@@ -749,7 +751,7 @@ class Puppet::Network::Handler
end
def add_to_filetree(f, filetree)
- first, rest = f.split(File::SEPARATOR, 2)
+ first, rest = f.split(File::SEPARATOR, 2)
end
end
end
diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb
index 8cfd8d83d..960b65f73 100755
--- a/lib/puppet/network/handler/report.rb
+++ b/lib/puppet/network/handler/report.rb
@@ -68,8 +68,7 @@ class Puppet::Network::Handler
if Puppet[:trace]
puts detail.backtrace
end
- Puppet.err "Report %s failed: %s" %
- [name, detail]
+ Puppet.err "Report %s failed: %s" % [name, detail]
end
else
Puppet.warning "No report named '%s'" % name
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb
index ab853665c..a76fefdcc 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -22,7 +22,7 @@ module Puppet::Network::HTTP::Handler
raise NotImplementedError
end
- # Which format to use when serializing our response or interpreting the request.
+ # Which format to use when serializing our response or interpreting the request.
# IF the client provided a Content-Type use this, otherwise use the Accept header
# and just pick the first value.
def format_to_use(request)
@@ -155,7 +155,7 @@ module Puppet::Network::HTTP::Handler
return result[:ip]
end
- private
+ private
def return_yaml_response(response, body)
set_content_type(response, Puppet::Network::FormatHandler.format("yaml"))
diff --git a/lib/puppet/network/http/mongrel.rb b/lib/puppet/network/http/mongrel.rb
index 6c39bb37f..8181600e3 100644
--- a/lib/puppet/network/http/mongrel.rb
+++ b/lib/puppet/network/http/mongrel.rb
@@ -33,7 +33,7 @@ class Puppet::Network::HTTP::Mongrel
@listening
end
- private
+ private
def setup_handlers
# Register our REST support at /
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index c0b736d44..effe92434 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -117,7 +117,7 @@ class Puppet::Network::HTTP::WEBrick
results
end
- private
+ private
def setup_handlers
# Set up the new-style protocols.
diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb
index 244f18b0d..980d3de13 100644
--- a/lib/puppet/network/http_pool.rb
+++ b/lib/puppet/network/http_pool.rb
@@ -62,7 +62,7 @@ module Puppet::Network::HttpPool
http.verify_callback = self.method(:ssl_verify_callback).to_proc
end
end
-
+
def self.ssl_verify_callback(peer_ok, x509_store_ctx)
if not peer_ok
Puppet.debug "OpenSSL: Error(#{x509_store_ctx.error}): #{x509_store_ctx.error_string}"
diff --git a/lib/puppet/network/http_server/webrick.rb b/lib/puppet/network/http_server/webrick.rb
index e71d4ba14..fa7ce4872 100644
--- a/lib/puppet/network/http_server/webrick.rb
+++ b/lib/puppet/network/http_server/webrick.rb
@@ -108,8 +108,7 @@ module Puppet
# have a global state
# mount has to be called after the server is initialized
- servlet = Puppet::Network::XMLRPC::WEBrickServlet.new(
- handler_instances)
+ servlet = Puppet::Network::XMLRPC::WEBrickServlet.new( handler_instances)
self.mount("/RPC2", servlet)
end
diff --git a/lib/puppet/network/rest_authconfig.rb b/lib/puppet/network/rest_authconfig.rb
index 7c0ef9cf3..13ad8dbb4 100644
--- a/lib/puppet/network/rest_authconfig.rb
+++ b/lib/puppet/network/rest_authconfig.rb
@@ -35,7 +35,10 @@ module Puppet
# we're splitting the request in part because
# fail_on_deny could as well be called in the XMLRPC context
# with a ClientRequest.
- @rights.fail_on_deny(build_uri(request),
+
+ @rights.fail_on_deny(
+ build_uri(request),
+
:node => request.node,
:ip => request.ip,
:method => request.method,
diff --git a/lib/puppet/network/rest_authorization.rb b/lib/puppet/network/rest_authorization.rb
index 5dd4fb5e6..0cf4472f1 100644
--- a/lib/puppet/network/rest_authorization.rb
+++ b/lib/puppet/network/rest_authorization.rb
@@ -9,7 +9,7 @@ module Puppet::Network
# Create our config object if necessary. If there's no configuration file
# we install our defaults
def authconfig
- unless defined? @authconfig
+ unless defined?(@authconfig)
@authconfig = Puppet::Network::RestAuthConfig.main
end
diff --git a/lib/puppet/network/server.rb b/lib/puppet/network/server.rb
index 01a55df36..2c899cf15 100644
--- a/lib/puppet/network/server.rb
+++ b/lib/puppet/network/server.rb
@@ -151,7 +151,7 @@ class Puppet::Network::Server
remove_pidfile
end
- private
+ private
def http_server
@http_server ||= http_server_class.new
diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb
index f12d279d4..c5efe985d 100644
--- a/lib/puppet/network/xmlrpc/client.rb
+++ b/lib/puppet/network/xmlrpc/client.rb
@@ -174,12 +174,15 @@ module Puppet::Network
hash[:HTTPProxyPort] = nil
end
- super(
+
+ super(
+
hash[:Server],
hash[:Path],
hash[:Port],
hash[:HTTPProxyHost],
hash[:HTTPProxyPort],
+
nil, # user
nil, # password
true, # use_ssl
diff --git a/lib/puppet/network/xmlrpc/webrick_servlet.rb b/lib/puppet/network/xmlrpc/webrick_servlet.rb
index ec64c1c60..a03db01d1 100644
--- a/lib/puppet/network/xmlrpc/webrick_servlet.rb
+++ b/lib/puppet/network/xmlrpc/webrick_servlet.rb
@@ -10,7 +10,7 @@ module Puppet::Network::XMLRPC
# This is a hackish way to avoid an auth message every time we have a
# normal operation
def self.log(msg)
- unless defined? @logs
+ unless defined?(@logs)
@logs = {}
end
if @logs.include?(msg)
@@ -84,8 +84,11 @@ module Puppet::Network::XMLRPC
client = peer[2]
clientip = peer[3]
else
- raise ::XMLRPC::FaultException.new(
+
+ raise ::XMLRPC::FaultException.new(
+
ERR_UNCAUGHT_EXCEPTION,
+
"Could not retrieve client information"
)
end
@@ -103,8 +106,7 @@ module Puppet::Network::XMLRPC
Puppet.warning "Could not retrieve server name from cert"
else
unless client == nameary[1]
- Puppet.debug "Overriding %s with cert name %s" %
- [client, nameary[1]]
+ Puppet.debug "Overriding %s with cert name %s" % [client, nameary[1]]
client = nameary[1]
end
valid = true
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index 5115e7fb1..0d9783b5a 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -94,9 +94,9 @@ class Puppet::Node
# First, get the fqdn
unless fqdn = parameters["fqdn"]
if parameters["hostname"] and parameters["domain"]
- fqdn = parameters["hostname"] + "." + parameters["domain"]
+ fqdn = parameters["hostname"] + "." + parameters["domain"]
else
- Puppet.warning "Host is missing hostname and/or domain: %s" % name
+ Puppet.warning "Host is missing hostname and/or domain: %s" % name
end
end
diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb
index 81f8f2cfe..8d4b20611 100644
--- a/lib/puppet/node/environment.rb
+++ b/lib/puppet/node/environment.rb
@@ -128,5 +128,5 @@ class Puppet::Node::Environment
end
end
- @root = new(:'*root*')
+ @root = new(:'*root*')
end
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index 3c208527f..4197c8c4a 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -40,7 +40,7 @@ class Puppet::Parameter
def doc
@doc ||= ""
- unless defined? @addeddocvals
+ unless defined?(@addeddocvals)
@doc += value_collection.doc
if f = self.required_features
@@ -92,7 +92,7 @@ class Puppet::Parameter
# Is this parameter the namevar? Defaults to false.
def isnamevar?
- if defined? @isnamevar
+ if defined?(@isnamevar)
return @isnamevar
else
return false
@@ -111,7 +111,7 @@ class Puppet::Parameter
# Is this parameter required? Defaults to false.
def required?
- if defined? @required
+ if defined?(@required)
return @required
else
return false
@@ -174,11 +174,11 @@ class Puppet::Parameter
error = type.new(args.join(" "))
- if defined? @resource and @resource and @resource.line
+ if defined?(@resource) and @resource and @resource.line
error.line = @resource.line
end
- if defined? @resource and @resource and @resource.file
+ if defined?(@resource) and @resource and @resource.file
error.file = @resource.file
end
@@ -217,7 +217,7 @@ class Puppet::Parameter
# for testing whether we should actually do anything
def noop
- unless defined? @noop
+ unless defined?(@noop)
@noop = false
end
tmp = @noop || self.resource.noop || Puppet[:noop] || false
@@ -228,7 +228,7 @@ class Puppet::Parameter
# return the full path to us, for logging and rollback; not currently
# used
def pathbuilder
- if defined? @resource and @resource
+ if defined?(@resource) and @resource
return [@resource.pathbuilder, self.name]
else
return [self.name]
@@ -303,7 +303,7 @@ class Puppet::Parameter
# The properties need to return tags so that logs correctly collect them.
def tags
- unless defined? @tags
+ unless defined?(@tags)
@tags = []
# This might not be true in testing
if @resource.respond_to? :tags
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb
index 5a8f7be41..f407c78d6 100644
--- a/lib/puppet/parser/ast.rb
+++ b/lib/puppet/parser/ast.rb
@@ -26,15 +26,15 @@ class Puppet::Parser::AST
# allow our subclass to specify they want documentation
class << self
- attr_accessor :use_docs
- def associates_doc
- self.use_docs = true
- end
+ attr_accessor :use_docs
+ def associates_doc
+ self.use_docs = true
+ end
end
# Does this ast object set something? If so, it gets evaluated first.
def self.settor?
- if defined? @settor
+ if defined?(@settor)
@settor
else
false
diff --git a/lib/puppet/parser/ast/branch.rb b/lib/puppet/parser/ast/branch.rb
index dcd09baa3..0c481ffe6 100644
--- a/lib/puppet/parser/ast/branch.rb
+++ b/lib/puppet/parser/ast/branch.rb
@@ -23,7 +23,7 @@ class Puppet::Parser::AST
super(arghash)
# Create the hash, if it was not set at initialization time.
- unless defined? @children
+ unless defined?(@children)
@children = []
end
diff --git a/lib/puppet/parser/ast/caseopt.rb b/lib/puppet/parser/ast/caseopt.rb
index 47f32e2ee..51a82c5c0 100644
--- a/lib/puppet/parser/ast/caseopt.rb
+++ b/lib/puppet/parser/ast/caseopt.rb
@@ -16,7 +16,7 @@ class Puppet::Parser::AST
# Are we the default option?
def default?
# Cache the @default value.
- if defined? @default
+ if defined?(@default)
return @default
end
@@ -33,7 +33,7 @@ class Puppet::Parser::AST
end
end
- unless defined? @default
+ unless defined?(@default)
@default = false
end
diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb
index f3690c146..44f3b330c 100644
--- a/lib/puppet/parser/ast/collection.rb
+++ b/lib/puppet/parser/ast/collection.rb
@@ -30,11 +30,14 @@ class Collection < AST::Branch
param.safeevaluate(scope)
end
- newcoll.add_override(
+
+ newcoll.add_override(
+
:parameters => params,
:file => @file,
:line => @line,
:source => scope.source,
+
:scope => scope
)
end
@@ -47,9 +50,12 @@ class Collection < AST::Branch
if override.is_a?(AST::ASTArray)
@override = override
else
- @override = AST::ASTArray.new(
+
+ @override = AST::ASTArray.new(
+
:line => override.line,
:file => override.file,
+
:children => [override]
)
end
diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb
index 0984ed8ce..98204b14a 100644
--- a/lib/puppet/parser/ast/function.rb
+++ b/lib/puppet/parser/ast/function.rb
@@ -21,14 +21,12 @@ class Puppet::Parser::AST
case @ftype
when :rvalue
unless Puppet::Parser::Functions.rvalue?(@name)
- raise Puppet::ParseError, "Function '%s' does not return a value" %
- @name
+ raise Puppet::ParseError, "Function '%s' does not return a value" % @name
end
when :statement
if Puppet::Parser::Functions.rvalue?(@name)
raise Puppet::ParseError,
- "Function '%s' must be the value of a statement" %
- @name
+ "Function '%s' must be the value of a statement" % @name
end
else
raise Puppet::DevError, "Invalid function type %s" % @ftype.inspect
diff --git a/lib/puppet/parser/ast/ifstatement.rb b/lib/puppet/parser/ast/ifstatement.rb
index d84445bbd..36da50c7a 100644
--- a/lib/puppet/parser/ast/ifstatement.rb
+++ b/lib/puppet/parser/ast/ifstatement.rb
@@ -24,7 +24,7 @@ class Puppet::Parser::AST
if Puppet::Parser::Scope.true?(value)
return @statements.safeevaluate(scope)
else
- if defined? @else
+ if defined?(@else)
return @else.safeevaluate(scope)
else
return nil
diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb
index 5488724c8..5aa11129a 100644
--- a/lib/puppet/parser/ast/resource.rb
+++ b/lib/puppet/parser/ast/resource.rb
@@ -37,7 +37,9 @@ class Resource < AST::ResourceReference
# many times.
resource_titles.flatten.collect { |resource_title|
exceptwrap :type => Puppet::ParseError do
- resource = Puppet::Parser::Resource.new(type, resource_title,
+
+ resource = Puppet::Parser::Resource.new(
+ type, resource_title,
:parameters => paramobjects,
:file => self.file,
:line => self.line,
@@ -45,6 +47,7 @@ class Resource < AST::ResourceReference
:virtual => virt,
:source => scope.source,
:scope => scope,
+
:strict => true
)
@@ -62,9 +65,12 @@ class Resource < AST::ResourceReference
if params.is_a?(AST::ASTArray)
@parameters = params
else
- @parameters = AST::ASTArray.new(
+
+ @parameters = AST::ASTArray.new(
+
:line => params.line,
:file => params.file,
+
:children => [params]
)
end
diff --git a/lib/puppet/parser/ast/resource_override.rb b/lib/puppet/parser/ast/resource_override.rb
index 93ddf4dbe..f667ed23a 100644
--- a/lib/puppet/parser/ast/resource_override.rb
+++ b/lib/puppet/parser/ast/resource_override.rb
@@ -36,11 +36,14 @@ class Puppet::Parser::AST
resource = [resource] unless resource.is_a?(Array)
resource = resource.collect do |r|
- res = Puppet::Parser::Resource.new(r.type, r.title,
+
+ res = Puppet::Parser::Resource.new(
+ r.type, r.title,
:parameters => params,
:file => file,
:line => line,
:source => scope.source,
+
:scope => scope
)
diff --git a/lib/puppet/parser/ast/resourceparam.rb b/lib/puppet/parser/ast/resourceparam.rb
index e6d9df17f..bf0a2258b 100644
--- a/lib/puppet/parser/ast/resourceparam.rb
+++ b/lib/puppet/parser/ast/resourceparam.rb
@@ -11,9 +11,12 @@ class Puppet::Parser::AST
# Return the parameter and the value.
def evaluate(scope)
- return Puppet::Parser::Resource::Param.new(
+
+ return Puppet::Parser::Resource::Param.new(
+
:name => @param,
:value => @value.safeevaluate(scope),
+
:source => scope.source, :line => self.line, :file => self.file,
:add => self.add
)
diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb
index 9126cb2f8..9283d06ae 100644
--- a/lib/puppet/parser/collector.rb
+++ b/lib/puppet/parser/collector.rb
@@ -41,11 +41,14 @@ class Puppet::Parser::Collector
# overrided those resources
objects.each do |res|
unless @collected.include?(res.ref)
- newres = Puppet::Parser::Resource.new(res.type, res.title,
+
+ newres = Puppet::Parser::Resource.new(
+ res.type, res.title,
:parameters => overrides[:parameters],
:file => overrides[:file],
:line => overrides[:line],
:source => overrides[:source],
+
:scope => overrides[:scope]
)
@@ -111,7 +114,7 @@ class Puppet::Parser::Collector
# We used to eagerly include param_names/values but the way
# the search filter is built ruined those efforts and we
# were eagerly loading only the searched parameter and not
- # the other ones.
+ # the other ones.
query = {}
case search
when /puppet_tags/
@@ -151,8 +154,7 @@ class Puppet::Parser::Collector
end
end
- scope.debug("Collected %s %s resource%s in %.2f seconds" %
- [count, @type, count == 1 ? "" : "s", time])
+ scope.debug("Collected %s %s resource%s in %.2f seconds" % [count, @type, count == 1 ? "" : "s", time])
return resources
end
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb
index 0a9d0804f..e64ec4ba3 100644
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -121,7 +121,7 @@ class Puppet::Parser::Compiler
# Return the node's environment.
def environment
- unless defined? @environment
+ unless defined?(@environment)
if node.environment and node.environment != ""
@environment = node.environment
else
@@ -189,7 +189,7 @@ class Puppet::Parser::Compiler
end
# Create a new scope, with either a specified parent scope or
- # using the top scope.
+ # using the top scope.
def newscope(parent, options = {})
parent ||= topscope
options[:compiler] = self
@@ -355,8 +355,7 @@ class Puppet::Parser::Compiler
end
unless remaining.empty?
- raise Puppet::ParseError, "Failed to realize virtual resources %s" %
- remaining.join(', ')
+ raise Puppet::ParseError, "Failed to realize virtual resources %s" % remaining.join(', ')
end
end
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index 201121cb9..a99e8dc95 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -15,9 +15,12 @@ module Puppet::Parser::Functions
end
def self.autoloader
- unless defined? @autoloader
- @autoloader = Puppet::Util::Autoload.new(self,
+ unless defined?(@autoloader)
+
+ @autoloader = Puppet::Util::Autoload.new(
+ self,
"puppet/parser/functions",
+
:wrap => false
)
end
@@ -28,8 +31,8 @@ module Puppet::Parser::Functions
Environment = Puppet::Node::Environment
def self.environment_module(env = nil)
- @modules.synchronize {
- @modules[ env || Environment.current || Environment.root ] ||= Module.new
+ @modules.synchronize {
+ @modules[ env || Environment.current || Environment.root ] ||= Module.new
}
end
@@ -104,8 +107,8 @@ module Puppet::Parser::Functions
end
def self.functions(env = nil)
- @functions.synchronize {
- @functions[ env || Environment.current || Environment.root ]
+ @functions.synchronize {
+ @functions[ env || Environment.current || Environment.root ]
}
end
diff --git a/lib/puppet/parser/functions/file.rb b/lib/puppet/parser/functions/file.rb
index 47b3f96e0..f78823d3a 100644
--- a/lib/puppet/parser/functions/file.rb
+++ b/lib/puppet/parser/functions/file.rb
@@ -1,5 +1,8 @@
# Returns the contents of a file
-Puppet::Parser::Functions::newfunction(:file, :type => :rvalue,
+
+ Puppet::Parser::Functions::newfunction(
+ :file, :type => :rvalue,
+
:doc => "Return the contents of a file. Multiple files
can be passed, and the first file that exists will be read in.") do |vals|
ret = nil
@@ -15,7 +18,6 @@ Puppet::Parser::Functions::newfunction(:file, :type => :rvalue,
if ret
ret
else
- raise Puppet::ParseError, "Could not find any files from %s" %
- vals.join(", ")
+ raise Puppet::ParseError, "Could not find any files from %s" % vals.join(", ")
end
end
diff --git a/lib/puppet/parser/functions/fqdn_rand.rb b/lib/puppet/parser/functions/fqdn_rand.rb
index 9297539e3..27af2d7ca 100644
--- a/lib/puppet/parser/functions/fqdn_rand.rb
+++ b/lib/puppet/parser/functions/fqdn_rand.rb
@@ -1,6 +1,6 @@
Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc =>
"Generates random numbers based on the node's fqdn. The first argument
- sets the range. Additional (optional) arguments may be used to further
+ sets the range. Additional (optional) arguments may be used to further
distinguish the seed.") do |args|
require 'md5'
max = args.shift
diff --git a/lib/puppet/parser/functions/inline_template.rb b/lib/puppet/parser/functions/inline_template.rb
index b9547cac7..fde8006b4 100644
--- a/lib/puppet/parser/functions/inline_template.rb
+++ b/lib/puppet/parser/functions/inline_template.rb
@@ -14,8 +14,7 @@ Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :doc
wrapper.result(string)
rescue => detail
raise Puppet::ParseError,
- "Failed to parse inline template: %s" %
- [detail]
+ "Failed to parse inline template: %s" % [detail]
end
end.join("")
end
diff --git a/lib/puppet/parser/functions/regsubst.rb b/lib/puppet/parser/functions/regsubst.rb
index d02680862..c47c1654e 100644
--- a/lib/puppet/parser/functions/regsubst.rb
+++ b/lib/puppet/parser/functions/regsubst.rb
@@ -1,7 +1,10 @@
module Puppet::Parser::Functions
- newfunction(:regsubst, :type => :rvalue,
- :doc => "
- Perform regexp replacement on a string or array of strings.
+
+ newfunction(
+ :regsubst, :type => :rvalue,
+
+ :doc => "
+ Perform regexp replacement on a string or array of strings.
- **Parameters** (in order):
@@ -20,10 +23,10 @@ module Puppet::Parser::Functions
:lang: Optional. How to handle multibyte characters. A single-character string with the following values:
- - **N** None
- - **E** EUC
- - **S** SJIS
- - **U** UTF-8
+ - **N** None
+ - **E** EUC
+ - **S** SJIS
+ - **U** UTF-8
- **Examples**
@@ -37,8 +40,11 @@ Put angle brackets around each octet in the node's IP address::
") \
do |args|
unless args.length.between?(3, 5)
- raise(Puppet::ParseError,
- "regsubst(): got #{args.length} arguments, expected 3 to 5")
+
+ raise(
+ Puppet::ParseError,
+
+ "regsubst(): got #{args.length} arguments, expected 3 to 5")
end
target, regexp, replacement, flags, lang = args
reflags = 0
@@ -48,8 +54,11 @@ Put angle brackets around each octet in the node's IP address::
elsif flags.respond_to?(:split)
flags = flags.split('')
else
- raise(Puppet::ParseError,
- "regsubst(): bad flags parameter #{flags.class}:`#{flags}'")
+
+ raise(
+ Puppet::ParseError,
+
+ "regsubst(): bad flags parameter #{flags.class}:`#{flags}'")
end
flags.each do |f|
case f
@@ -63,22 +72,28 @@ Put angle brackets around each octet in the node's IP address::
begin
re = Regexp.compile(regexp, reflags, lang)
rescue RegexpError, TypeError
- raise(Puppet::ParseError,
- "regsubst(): Bad regular expression `#{regexp}'")
+
+ raise(
+ Puppet::ParseError,
+
+ "regsubst(): Bad regular expression `#{regexp}'")
end
if target.respond_to?(operation)
# String parameter -> string result
result = target.send(operation, re, replacement)
elsif target.respond_to?(:collect) and
- target.respond_to?(:all?) and
- target.all? { |e| e.respond_to?(operation) }
+ target.respond_to?(:all?) and
+ target.all? { |e| e.respond_to?(operation) }
# Array parameter -> array result
result = target.collect { |e|
e.send(operation, re, replacement)
}
else
- raise(Puppet::ParseError,
- "regsubst(): bad target #{target.class}:`#{target}'")
+
+ raise(
+ Puppet::ParseError,
+
+ "regsubst(): bad target #{target.class}:`#{target}'")
end
return result
end
diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/parser/functions/require.rb
index a46999f05..45b89c77a 100644
--- a/lib/puppet/parser/functions/require.rb
+++ b/lib/puppet/parser/functions/require.rb
@@ -1,5 +1,8 @@
# Requires the specified classes
-Puppet::Parser::Functions::newfunction(:require,
+
+ Puppet::Parser::Functions::newfunction(
+ :require,
+
:doc =>"Evaluate one or more classes, adding the required class as a dependency.
The relationship metaparameters work well for specifying relationships
@@ -9,18 +12,18 @@ relationships between classes. This function is a superset of the
class depends on the required class.
Warning: using require in place of include can lead to unwanted dependency cycles.
- For instance the following manifest, with 'require' instead of 'include'
- would produce a nasty dependence cycle, because notify imposes a before
- between File[/foo] and Service[foo]::
-
- class myservice {
- service { foo: ensure => running }
- }
-
- class otherstuff {
- include myservice
- file { '/foo': notify => Service[foo] }
- }
+ For instance the following manifest, with 'require' instead of 'include'
+ would produce a nasty dependence cycle, because notify imposes a before
+ between File[/foo] and Service[foo]::
+
+ class myservice {
+ service { foo: ensure => running }
+ }
+
+ class otherstuff {
+ include myservice
+ file { '/foo': notify => Service[foo] }
+ }
Note that this function only works with clients 0.25 and later, and it will
fail if used with earlier clients.
diff --git a/lib/puppet/parser/functions/sha1.rb b/lib/puppet/parser/functions/sha1.rb
index 09386a604..432825ee9 100644
--- a/lib/puppet/parser/functions/sha1.rb
+++ b/lib/puppet/parser/functions/sha1.rb
@@ -1,5 +1,4 @@
-Puppet::Parser::Functions::newfunction(:sha1, :type => :rvalue,
- :doc => "Returns a SHA1 hash value from a provided string.") do |args|
+Puppet::Parser::Functions::newfunction(:sha1, :type => :rvalue, :doc => "Returns a SHA1 hash value from a provided string.") do |args|
require 'sha1'
Digest::SHA1.hexdigest(args[0])
diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb
index 36dba7e68..405a5bc9a 100644
--- a/lib/puppet/parser/functions/split.rb
+++ b/lib/puppet/parser/functions/split.rb
@@ -1,14 +1,17 @@
module Puppet::Parser::Functions
- newfunction(:split, :type => :rvalue,
- :doc => "\
+
+ newfunction(
+ :split, :type => :rvalue,
+
+ :doc => "\
Split a string variable into an array using the specified split regexp.
- Usage::
+ Usage::
- $string = 'v1.v2:v3.v4'
- $array_var1 = split($string, ':')
- $array_var2 = split($string, '[.]')
- $array_var3 = split($string, '[.:]')
+ $string = 'v1.v2:v3.v4'
+ $array_var1 = split($string, ':')
+ $array_var2 = split($string, '[.]')
+ $array_var3 = split($string, '[.:]')
$array_var1 now holds the result ['v1.v2', 'v3.v4'],
while $array_var2 holds ['v1', 'v2:v3', 'v4'], and
@@ -19,11 +22,10 @@ a regexp meta-character (.), and that needs protection. A simple
way to do that for a single character is to enclose it in square
brackets.") do |args|
- if args.length != 2
- raise Puppet::ParseError, ("split(): wrong number of arguments" +
- " (#{args.length}; must be 2)")
- end
+ if args.length != 2
+ raise Puppet::ParseError, ("split(): wrong number of arguments" + " (#{args.length}; must be 2)")
+ end
- return args[0].split(Regexp.compile(args[1]))
+ return args[0].split(Regexp.compile(args[1]))
end
end
diff --git a/lib/puppet/parser/functions/sprintf.rb b/lib/puppet/parser/functions/sprintf.rb
index d84b1866a..4a53a9736 100644
--- a/lib/puppet/parser/functions/sprintf.rb
+++ b/lib/puppet/parser/functions/sprintf.rb
@@ -1,8 +1,11 @@
module Puppet::Parser::Functions
- newfunction(:sprintf, :type => :rvalue,
+
+ newfunction(
+ :sprintf, :type => :rvalue,
+
:doc => "Perform printf-style formatting of text.
- The first parameter is format string describing how the rest of the parameters should be formatted. See the documentation for the ``Kernel::sprintf()`` function in Ruby for all the details.") do |args|
+ The first parameter is format string describing how the rest of the parameters should be formatted. See the documentation for the ``Kernel::sprintf()`` function in Ruby for all the details.") do |args|
if args.length < 1
raise Puppet::ParseError, 'sprintf() needs at least one argument'
end
diff --git a/lib/puppet/parser/functions/template.rb b/lib/puppet/parser/functions/template.rb
index 34524e388..35c54c66a 100644
--- a/lib/puppet/parser/functions/template.rb
+++ b/lib/puppet/parser/functions/template.rb
@@ -1,7 +1,7 @@
Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc =>
"Evaluate a template and return its value. See `the templating docs
- <http://docs.puppetlabs.com/guides/templating.html>`_ for more information.
- Note that if multiple templates are specified, their output is all
+ <http://docs.puppetlabs.com/guides/templating.html>`_ for more information.
+ Note that if multiple templates are specified, their output is all
concatenated and returned as the output of the function.") do |vals|
require 'erb'
@@ -16,8 +16,7 @@ Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc =>
wrapper.result
rescue => detail
raise Puppet::ParseError,
- "Failed to parse template %s: %s" %
- [file, detail]
+ "Failed to parse template %s: %s" % [file, detail]
end
end.join("")
end
diff --git a/lib/puppet/parser/functions/versioncmp.rb b/lib/puppet/parser/functions/versioncmp.rb
index 9435655a7..b8d39af96 100644
--- a/lib/puppet/parser/functions/versioncmp.rb
+++ b/lib/puppet/parser/functions/versioncmp.rb
@@ -1,6 +1,9 @@
require 'puppet/util/package'
-Puppet::Parser::Functions::newfunction(:versioncmp, :type => :rvalue,
+
+ Puppet::Parser::Functions::newfunction(
+ :versioncmp, :type => :rvalue,
+
:doc => "Compares two versions
Prototype::
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index a6e64a38f..c08b1a31a 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -44,11 +44,11 @@ program: statements {
result = nil
end
}
- | nil
+ | nil
statements: statement
- | statements statement {
- if val[0] and val[1]
+ | statements statement {
+ if val[0] and val[1]
if val[0].instance_of?(AST::ASTArray)
val[0].push(val[1])
result = val[0]
@@ -63,25 +63,25 @@ statements: statement
# The main list of valid statements
statement: resource
- | virtualresource
- | collection
- | assignment
- | casestatement
- | ifstatement_begin
- | import
- | fstatement
- | definition
- | hostclass
- | nodedef
- | resourceoverride
- | append
- | relationship
+ | virtualresource
+ | collection
+ | assignment
+ | casestatement
+ | ifstatement_begin
+ | import
+ | fstatement
+ | definition
+ | hostclass
+ | nodedef
+ | resourceoverride
+ | append
+ | relationship
relationship: relationship_side edge relationship_side {
result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context)
}
- | relationship edge relationship_side {
- result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context)
+ | relationship edge relationship_side {
+ result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context)
}
relationship_side: resource | resourceref | collection
@@ -96,7 +96,7 @@ fstatement: NAME LPAREN funcvalues RPAREN {
:arguments => args,
:ftype => :statement
}
- | NAME LPAREN funcvalues COMMA RPAREN {
+| NAME LPAREN funcvalues COMMA RPAREN {
args = aryfy(val[2])
result = ast AST::Function,
:name => val[0][:value],
@@ -110,9 +110,9 @@ fstatement: NAME LPAREN funcvalues RPAREN {
:arguments => AST::ASTArray.new({}),
:ftype => :statement
}
- | NAME funcvalues {
- args = aryfy(val[1])
- result = ast AST::Function,
+ | NAME funcvalues {
+ args = aryfy(val[1])
+ result = ast AST::Function,
:name => val[0][:value],
:line => val[0][:line],
:arguments => args,
@@ -120,14 +120,14 @@ fstatement: NAME LPAREN funcvalues RPAREN {
}
funcvalues: namestring
- | resourceref
- | funcvalues COMMA namestring {
- result = aryfy(val[0], val[2])
- result.line = @lexer.line
- result.file = @lexer.file
-}
- | funcvalues COMMA resourceref {
- unless val[0].is_a?(AST::ASTArray)
+ | resourceref
+ | funcvalues COMMA namestring {
+ result = aryfy(val[0], val[2])
+ result.line = @lexer.line
+ result.file = @lexer.file
+}
+ | funcvalues COMMA resourceref {
+ unless val[0].is_a?(AST::ASTArray)
val[0] = aryfy(val[0])
end
@@ -139,16 +139,16 @@ funcvalues: namestring
# This is *almost* an rvalue, but I couldn't get a full
# rvalue to work without scads of shift/reduce conflicts.
namestring: name
- | variable
- | type
- | boolean
- | funcrvalue
- | selector
- | quotedtext
- | hasharrayaccesses
- | CLASSNAME {
- result = ast AST::Name, :value => val[0][:value]
- }
+ | variable
+ | type
+ | boolean
+ | funcrvalue
+ | selector
+ | quotedtext
+ | hasharrayaccesses
+ | CLASSNAME {
+ result = ast AST::Name, :value => val[0][:value]
+ }
resource: classname LBRACE resourceinstances endsemi RBRACE {
@lexer.commentpop
@@ -165,9 +165,12 @@ resource: classname LBRACE resourceinstances endsemi RBRACE {
end
# now, i need to somehow differentiate between those things with
# arrays in their names, and normal things
- result.push ast(AST::Resource,
+
+ result.push ast(
+ AST::Resource,
:type => val[0],
:title => instance[0],
+
:parameters => instance[1])
}
} | classname LBRACE params endcomma RBRACE {
@@ -238,8 +241,8 @@ collection: classref collectrhand LBRACE anyparams endcomma RBRACE {
args[:override] = val[3]
result = ast AST::Collection, args
}
- | classref collectrhand {
- if val[0] =~ /^[a-z]/
+ | classref collectrhand {
+ if val[0] =~ /^[a-z]/
Puppet.warning addcontext("Collection names must now be capitalized")
end
type = val[0].downcase
@@ -267,8 +270,8 @@ collectrhand: LCOLLECT collstatements RCOLLECT {
result = :virtual
end
}
- | LLCOLLECT collstatements RRCOLLECT {
- if val[1]
+ | LLCOLLECT collstatements RRCOLLECT {
+ if val[1]
result = val[1]
result.form = :exported
else
@@ -279,41 +282,41 @@ collectrhand: LCOLLECT collstatements RCOLLECT {
# A mini-language for handling collection comparisons. This is organized
# to avoid the need for precedence indications.
collstatements: nil
- | collstatement
- | collstatements colljoin collstatement {
- result = ast AST::CollExpr, :test1 => val[0], :oper => val[1], :test2 => val[2]
+ | collstatement
+ | collstatements colljoin collstatement {
+ result = ast AST::CollExpr, :test1 => val[0], :oper => val[1], :test2 => val[2]
}
collstatement: collexpr
- | LPAREN collstatements RPAREN {
- result = val[1]
- result.parens = true
+ | LPAREN collstatements RPAREN {
+ result = val[1]
+ result.parens = true
}
colljoin: AND { result=val[0][:value] }
- | OR { result=val[0][:value] }
+ | OR { result=val[0][:value] }
collexpr: colllval ISEQUAL simplervalue {
result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2]
#result = ast AST::CollExpr
#result.push *val
}
- | colllval NOTEQUAL simplervalue {
- result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2]
- #result = ast AST::CollExpr
- #result.push *val
+ | colllval NOTEQUAL simplervalue {
+ result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2]
+ #result = ast AST::CollExpr
+ #result.push *val
}
colllval: variable
- | name
+ | name
resourceinst: resourcename COLON params endcomma {
result = ast AST::ResourceInstance, :children => [val[0],val[2]]
}
resourceinstances: resourceinst
- | resourceinstances SEMIC resourceinst {
- if val[0].instance_of?(AST::ResourceInstance)
+ | resourceinstances SEMIC resourceinst {
+ if val[0].instance_of?(AST::ResourceInstance)
result = ast AST::ASTArray, :children => [val[0],val[2]]
else
val[0].push val[2]
@@ -322,7 +325,7 @@ resourceinstances: resourceinst
}
endsemi: # nothing
- | SEMIC
+ | SEMIC
undef: UNDEF {
result = ast AST::Undef, :value => :undef
@@ -337,12 +340,12 @@ type: CLASSREF {
}
resourcename: quotedtext
- | name
- | type
- | selector
- | variable
- | array
- | hasharrayaccesses
+ | name
+ | type
+ | selector
+ | variable
+ | array
+ | hasharrayaccesses
assignment: VARIABLE EQUALS expression {
if val[0][:value] =~ /::/
@@ -352,8 +355,8 @@ assignment: VARIABLE EQUALS expression {
variable = ast AST::Name, :value => val[0][:value], :line => val[0][:line]
result = ast AST::VarDef, :name => variable, :value => val[2], :line => val[0][:line]
}
- | hasharrayaccess EQUALS expression {
- result = ast AST::VarDef, :name => val[0], :value => val[2]
+ | hasharrayaccess EQUALS expression {
+ result = ast AST::VarDef, :name => val[0], :value => val[2]
}
append: VARIABLE APPENDS expression {
@@ -365,9 +368,9 @@ params: # nothing
{
result = ast AST::ASTArray
}
- | param { result = val[0] }
- | params COMMA param {
- if val[0].instance_of?(AST::ASTArray)
+ | param { result = val[0] }
+ | params COMMA param {
+ if val[0].instance_of?(AST::ASTArray)
val[0].push(val[2])
result = val[0]
else
@@ -381,19 +384,19 @@ param: NAME FARROW rvalue {
addparam: NAME PARROW rvalue {
result = ast AST::ResourceParam, :param => val[0][:value], :line => val[0][:line], :value => val[2],
- :add => true
+ :add => true
}
anyparam: param
- | addparam
+ | addparam
anyparams: # nothing
{
result = ast AST::ASTArray
}
- | anyparam { result = val[0] }
- | anyparams COMMA anyparam {
- if val[0].instance_of?(AST::ASTArray)
+ | anyparam { result = val[0] }
+ | anyparams COMMA anyparam {
+ if val[0].instance_of?(AST::ASTArray)
val[0].push(val[2])
result = val[0]
else
@@ -402,8 +405,8 @@ anyparams: # nothing
}
rvalues: rvalue
- | rvalues comma rvalue {
- if val[0].instance_of?(AST::ASTArray)
+ | rvalues comma rvalue {
+ if val[0].instance_of?(AST::ASTArray)
result = val[0].push(val[2])
else
result = ast AST::ASTArray, :children => [val[0],val[2]]
@@ -411,24 +414,24 @@ rvalues: rvalue
}
simplervalue: quotedtext
- | name
- | type
- | boolean
- | selector
- | variable
+ | name
+ | type
+ | boolean
+ | selector
+ | variable
rvalue: quotedtext
- | name
- | type
- | boolean
- | selector
- | variable
- | array
- | hash
- | hasharrayaccesses
- | resourceref
- | funcrvalue
- | undef
+ | name
+ | type
+ | boolean
+ | selector
+ | variable
+ | array
+ | hash
+ | hasharrayaccesses
+ | resourceref
+ | funcrvalue
+ | undef
# We currently require arguments in these functions.
funcrvalue: NAME LPAREN funcvalues RPAREN {
@@ -444,13 +447,13 @@ funcrvalue: NAME LPAREN funcvalues RPAREN {
:ftype => :rvalue
}
-quotedtext: STRING { result = ast AST::String, :value => val[0][:value], :line => val[0][:line] }
- | DQPRE dqrval { result = ast AST::Concat, :value => [ast(AST::String,val[0])]+val[1], :line => val[0][:line] }
+quotedtext: STRING { result = ast AST::String, :value => val[0][:value], :line => val[0][:line] }
+ | DQPRE dqrval { result = ast AST::Concat, :value => [ast(AST::String,val[0])]+val[1], :line => val[0][:line] }
dqrval: expression dqtail { result = [val[0]] + val[1] }
dqtail: DQPOST { result = [ast(AST::String,val[0])] }
- | DQMID dqrval { result = [ast(AST::String,val[0])] + val[1] }
+ | DQMID dqrval { result = [ast(AST::String,val[0])] + val[1] }
boolean: BOOLEAN {
result = ast AST::Boolean, :value => val[0][:value], :line => val[0][:line]
@@ -480,11 +483,11 @@ ifstatement: expression LBRACE statements RBRACE else {
result = ast AST::IfStatement, args
}
- | expression LBRACE RBRACE else {
- @lexer.commentpop
- args = {
- :test => val[0],
- :statements => ast(AST::Nop)
+ | expression LBRACE RBRACE else {
+ @lexer.commentpop
+ args = {
+ :test => val[0],
+ :statements => ast(AST::Nop)
}
if val[3]
@@ -495,16 +498,16 @@ ifstatement: expression LBRACE statements RBRACE else {
}
else: # nothing
- | ELSIF ifstatement {
- result = ast AST::Else, :statements => val[1]
+ | ELSIF ifstatement {
+ result = ast AST::Else, :statements => val[1]
}
- | ELSE LBRACE statements RBRACE {
- @lexer.commentpop
- result = ast AST::Else, :statements => val[2]
+ | ELSE LBRACE statements RBRACE {
+ @lexer.commentpop
+ result = ast AST::Else, :statements => val[2]
}
- | ELSE LBRACE RBRACE {
- @lexer.commentpop
- result = ast AST::Else, :statements => ast(AST::Nop)
+ | ELSE LBRACE RBRACE {
+ @lexer.commentpop
+ result = ast AST::Else, :statements => ast(AST::Nop)
}
# Unlike yacc/bison, it seems racc
@@ -520,65 +523,65 @@ else: # nothing
# per operator :-(
expression: rvalue
- | expression IN rvalue {
- result = ast AST::InOperator, :lval => val[0], :rval => val[2]
+ | expression IN rvalue {
+ result = ast AST::InOperator, :lval => val[0], :rval => val[2]
}
- | expression MATCH regex {
- result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression MATCH regex {
+ result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression NOMATCH regex {
- result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression NOMATCH regex {
+ result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression PLUS expression {
- result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression PLUS expression {
+ result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression MINUS expression {
- result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression MINUS expression {
+ result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression DIV expression {
- result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression DIV expression {
+ result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression TIMES expression {
- result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression TIMES expression {
+ result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression LSHIFT expression {
- result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression LSHIFT expression {
+ result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression RSHIFT expression {
- result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression RSHIFT expression {
+ result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | MINUS expression =UMINUS {
- result = ast AST::Minus, :value => val[1]
+ | MINUS expression =UMINUS {
+ result = ast AST::Minus, :value => val[1]
}
- | expression NOTEQUAL expression {
- result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression NOTEQUAL expression {
+ result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression ISEQUAL expression {
- result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression ISEQUAL expression {
+ result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression GREATERTHAN expression {
- result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression GREATERTHAN expression {
+ result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression GREATEREQUAL expression {
- result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression GREATEREQUAL expression {
+ result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression LESSTHAN expression {
- result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression LESSTHAN expression {
+ result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression LESSEQUAL expression {
- result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression LESSEQUAL expression {
+ result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | NOT expression {
- result = ast AST::Not, :value => val[1]
+ | NOT expression {
+ result = ast AST::Not, :value => val[1]
}
- | expression AND expression {
- result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression AND expression {
+ result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | expression OR expression {
- result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
+ | expression OR expression {
+ result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2]
}
- | LPAREN expression RPAREN {
- result = val[1]
+ | LPAREN expression RPAREN {
+ result = val[1]
}
casestatement: CASE rvalue LBRACE caseopts RBRACE {
@@ -591,8 +594,8 @@ casestatement: CASE rvalue LBRACE caseopts RBRACE {
}
caseopts: caseopt
- | caseopts caseopt {
- if val[0].instance_of?(AST::ASTArray)
+ | caseopts caseopt {
+ if val[0].instance_of?(AST::ASTArray)
val[0].push val[1]
result = val[0]
else
@@ -605,15 +608,18 @@ caseopt: casevalues COLON LBRACE statements RBRACE {
result = ast AST::CaseOpt, :value => val[0], :statements => val[3]
} | casevalues COLON LBRACE RBRACE {
@lexer.commentpop
- result = ast(AST::CaseOpt,
+
+ result = ast(
+ AST::CaseOpt,
:value => val[0],
+
:statements => ast(AST::ASTArray)
)
}
casevalues: selectlhand
- | casevalues COMMA selectlhand {
- if val[0].instance_of?(AST::ASTArray)
+ | casevalues COMMA selectlhand {
+ if val[0].instance_of?(AST::ASTArray)
val[0].push(val[2])
result = val[0]
else
@@ -626,14 +632,14 @@ selector: selectlhand QMARK svalues {
}
svalues: selectval
- | LBRACE sintvalues endcomma RBRACE {
- @lexer.commentpop
- result = val[1]
+ | LBRACE sintvalues endcomma RBRACE {
+ @lexer.commentpop
+ result = val[1]
}
sintvalues: selectval
- | sintvalues comma selectval {
- if val[0].instance_of?(AST::ASTArray)
+ | sintvalues comma selectval {
+ if val[0].instance_of?(AST::ASTArray)
val[0].push(val[2])
result = val[0]
else
@@ -646,21 +652,21 @@ selectval: selectlhand FARROW rvalue {
}
selectlhand: name
- | type
- | quotedtext
- | variable
- | funcrvalue
- | boolean
- | undef
- | DEFAULT {
- result = ast AST::Default, :value => val[0][:value], :line => val[0][:line]
+ | type
+ | quotedtext
+ | variable
+ | funcrvalue
+ | boolean
+ | undef
+ | DEFAULT {
+ result = ast AST::Default, :value => val[0][:value], :line => val[0][:line]
}
- | regex
+ | regex
# These are only used for importing, and we don't interpolate there.
string: STRING { result = [val[0][:value]] }
strings: string
- | strings COMMA string { result = val[0] += val[2] }
+ | strings COMMA string { result = val[0] += val[2] }
import: IMPORT strings {
val[1].each do |file|
@@ -714,16 +720,16 @@ nodedef: NODE hostnames nodeparent LBRACE statements RBRACE {
classref: CLASSREF { result = val[0][:value] }
classname: NAME { result = val[0][:value] }
- | CLASSNAME { result = val[0][:value] }
- | CLASS { result = "class" }
+ | CLASSNAME { result = val[0][:value] }
+ | CLASS { result = "class" }
# Multiple hostnames, as used for node names. These are all literal
# strings, not AST objects.
hostnames: nodename
- | hostnames COMMA nodename {
- result = val[0]
- result = [result] unless result.is_a?(Array)
- result << val[2]
+ | hostnames COMMA nodename {
+ result = val[0]
+ result = [result] unless result.is_a?(Array)
+ result << val[2]
}
nodename: hostname {
@@ -731,9 +737,9 @@ nodename: hostname {
}
hostname: NAME { result = val[0][:value] }
- | STRING { result = val[0][:value] }
- | DEFAULT { result = val[0][:value] }
- | regex
+ | STRING { result = val[0][:value] }
+ | DEFAULT { result = val[0][:value] }
+ | regex
nil: {
result = nil
@@ -744,28 +750,28 @@ nothing: {
}
argumentlist: nil
- | LPAREN nothing RPAREN {
- result = nil
+ | LPAREN nothing RPAREN {
+ result = nil
}
- | LPAREN arguments RPAREN {
- result = val[1]
- result = [result] unless result[0].is_a?(Array)
+ | LPAREN arguments RPAREN {
+ result = val[1]
+ result = [result] unless result[0].is_a?(Array)
}
arguments: argument
- | arguments COMMA argument {
- result = val[0]
- result = [result] unless result[0].is_a?(Array)
- result << val[2]
+ | arguments COMMA argument {
+ result = val[0]
+ result = [result] unless result[0].is_a?(Array)
+ result << val[2]
}
argument: NAME EQUALS rvalue {
Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype")
result = [val[0][:value], val[2]]
}
- | NAME {
- Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype")
- result = [val[0][:value]]
+ | NAME {
+ Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype")
+ result = [val[0][:value]]
} | VARIABLE EQUALS rvalue {
result = [val[0][:value], val[2]]
} | VARIABLE {
@@ -773,13 +779,13 @@ argument: NAME EQUALS rvalue {
}
nodeparent: nil
- | INHERITS hostname {
- result = val[1]
+ | INHERITS hostname {
+ result = val[1]
}
classparent: nil
- | INHERITS classnameordefault {
- result = val[1]
+ | INHERITS classnameordefault {
+ result = val[1]
}
classnameordefault: classname | DEFAULT
@@ -795,8 +801,8 @@ array: LBRACK rvalues RBRACK {
result = ast AST::ASTArray, :children => [val[1]]
end
}
- | LBRACK rvalues COMMA RBRACK {
- if val[1].instance_of?(AST::ASTArray)
+ | LBRACK rvalues COMMA RBRACK {
+ if val[1].instance_of?(AST::ASTArray)
result = val[1]
else
result = ast AST::ASTArray, :children => [val[1]]
@@ -806,10 +812,10 @@ array: LBRACK rvalues RBRACK {
}
comma: FARROW
- | COMMA
+ | COMMA
endcomma: # nothing
- | COMMA { result = nil }
+ | COMMA { result = nil }
regex: REGEX {
result = ast AST::Regex, :value => val[0][:value]
@@ -822,8 +828,8 @@ hash: LBRACE hashpairs RBRACE {
result = ast AST::ASTHash, { :value => val[1] }
end
}
- | LBRACE hashpairs COMMA RBRACE {
- if val[1].instance_of?(AST::ASTHash)
+ | LBRACE hashpairs COMMA RBRACE {
+ if val[1].instance_of?(AST::ASTHash)
result = val[1]
else
result = ast AST::ASTHash, { :value => val[1] }
@@ -833,8 +839,8 @@ hash: LBRACE hashpairs RBRACE {
}
hashpairs: hashpair
- | hashpairs COMMA hashpair {
- if val[0].instance_of?(AST::ASTHash)
+ | hashpairs COMMA hashpair {
+ if val[0].instance_of?(AST::ASTHash)
result = val[0].merge(val[2])
else
result = ast AST::ASTHash, :value => val[0]
@@ -847,15 +853,15 @@ hashpair: key FARROW rvalue {
}
key: NAME { result = val[0][:value] }
- | quotedtext { result = val[0] }
+ | quotedtext { result = val[0] }
hasharrayaccess: VARIABLE LBRACK rvalue RBRACK {
- result = ast AST::HashOrArrayAccess, :variable => val[0][:value], :key => val[2]
+ result = ast AST::HashOrArrayAccess, :variable => val[0][:value], :key => val[2]
}
hasharrayaccesses: hasharrayaccess
- | hasharrayaccess LBRACK rvalue RBRACK {
- result = ast AST::HashOrArrayAccess, :variable => val[0], :key => val[2]
+ | hasharrayaccess LBRACK rvalue RBRACK {
+ result = ast AST::HashOrArrayAccess, :variable => val[0], :key => val[2]
}
end
diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index 3ac16b56a..5d1ce8bc7 100644
--- a/lib/puppet/parser/lexer.rb
+++ b/lib/puppet/parser/lexer.rb
@@ -18,7 +18,7 @@ class Puppet::Parser::Lexer
def lex_error msg
raise Puppet::LexError.new(msg)
end
-
+
class Token
attr_accessor :regex, :name, :string, :skip, :incr_line, :skip_text, :accumulate
@@ -45,10 +45,10 @@ class Puppet::Parser::Lexer
@name.to_s
end
end
-
+
def acceptable?(context={})
# By default tokens are aceeptable in any context
- true
+ true
end
end
@@ -108,55 +108,58 @@ class Puppet::Parser::Lexer
end
TOKENS = TokenList.new
- TOKENS.add_tokens(
- '[' => :LBRACK,
- ']' => :RBRACK,
- '{' => :LBRACE,
- '}' => :RBRACE,
- '(' => :LPAREN,
- ')' => :RPAREN,
- '=' => :EQUALS,
- '+=' => :APPENDS,
- '==' => :ISEQUAL,
- '>=' => :GREATEREQUAL,
- '>' => :GREATERTHAN,
- '<' => :LESSTHAN,
- '<=' => :LESSEQUAL,
- '!=' => :NOTEQUAL,
- '!' => :NOT,
- ',' => :COMMA,
- '.' => :DOT,
- ':' => :COLON,
- '@' => :AT,
- '<<|' => :LLCOLLECT,
- '->' => :IN_EDGE,
- '<-' => :OUT_EDGE,
- '~>' => :IN_EDGE_SUB,
- '<~' => :OUT_EDGE_SUB,
- '|>>' => :RRCOLLECT,
- '<|' => :LCOLLECT,
- '|>' => :RCOLLECT,
- ';' => :SEMIC,
- '?' => :QMARK,
- '\\' => :BACKSLASH,
- '=>' => :FARROW,
- '+>' => :PARROW,
- '+' => :PLUS,
- '-' => :MINUS,
- '/' => :DIV,
- '*' => :TIMES,
- '<<' => :LSHIFT,
- '>>' => :RSHIFT,
- '=~' => :MATCH,
- '!~' => :NOMATCH,
- %r{([a-z][-\w]*)?(::[a-z][-\w]*)+} => :CLASSNAME, # Require '::' in the class name, else we'd compete with NAME
- %r{((::){0,1}[A-Z][-\w]*)+} => :CLASSREF,
- "<string>" => :STRING,
- "<dqstring up to first interpolation>" => :DQPRE,
- "<dqstring between two interpolations>" => :DQMID,
- "<dqstring after final interpolation>" => :DQPOST,
- "<boolean>" => :BOOLEAN
- )
+
+ TOKENS.add_tokens(
+
+ '[' => :LBRACK,
+ ']' => :RBRACK,
+ '{' => :LBRACE,
+ '}' => :RBRACE,
+ '(' => :LPAREN,
+
+ ')' => :RPAREN,
+ '=' => :EQUALS,
+ '+=' => :APPENDS,
+ '==' => :ISEQUAL,
+ '>=' => :GREATEREQUAL,
+ '>' => :GREATERTHAN,
+ '<' => :LESSTHAN,
+ '<=' => :LESSEQUAL,
+ '!=' => :NOTEQUAL,
+ '!' => :NOT,
+ ',' => :COMMA,
+ '.' => :DOT,
+ ':' => :COLON,
+ '@' => :AT,
+ '<<|' => :LLCOLLECT,
+ '->' => :IN_EDGE,
+ '<-' => :OUT_EDGE,
+ '~>' => :IN_EDGE_SUB,
+ '<~' => :OUT_EDGE_SUB,
+ '|>>' => :RRCOLLECT,
+ '<|' => :LCOLLECT,
+ '|>' => :RCOLLECT,
+ ';' => :SEMIC,
+ '?' => :QMARK,
+ '\\' => :BACKSLASH,
+ '=>' => :FARROW,
+ '+>' => :PARROW,
+ '+' => :PLUS,
+ '-' => :MINUS,
+ '/' => :DIV,
+ '*' => :TIMES,
+ '<<' => :LSHIFT,
+ '>>' => :RSHIFT,
+ '=~' => :MATCH,
+ '!~' => :NOMATCH,
+ %r{([a-z][-\w]*)?(::[a-z][-\w]*)+} => :CLASSNAME, # Require '::' in the class name, else we'd compete with NAME
+ %r{((::){0,1}[A-Z][-\w]*)+} => :CLASSREF,
+ "<string>" => :STRING,
+ "<dqstring up to first interpolation>" => :DQPRE,
+ "<dqstring between two interpolations>" => :DQMID,
+ "<dqstring after final interpolation>" => :DQPOST,
+ "<boolean>" => :BOOLEAN
+ )
TOKENS.add_token :NUMBER, %r{\b(?:0[xX][0-9A-Fa-f]+|0?\d+(?:\.\d+)?(?:[eE]-?\d+)?)\b} do |lexer, value|
[TOKENS[:NAME], value]
@@ -224,8 +227,8 @@ class Puppet::Parser::Lexer
DQ_initial_token_types = {'$' => :DQPRE,'"' => :STRING}
DQ_continuation_token_types = {'$' => :DQMID,'"' => :DQPOST}
- TOKENS.add_token :DQUOTE, /"/ do |lexer, value|
- lexer.tokenize_interpolated_string(DQ_initial_token_types)
+ TOKENS.add_token :DQUOTE, /"/ do |lexer, value|
+ lexer.tokenize_interpolated_string(DQ_initial_token_types)
end
TOKENS.add_token :DQCONT, /\}/ do |lexer, value|
@@ -261,23 +264,26 @@ class Puppet::Parser::Lexer
KEYWORDS = TokenList.new
- KEYWORDS.add_tokens(
- "case" => :CASE,
- "class" => :CLASS,
- "default" => :DEFAULT,
- "define" => :DEFINE,
- "import" => :IMPORT,
- "if" => :IF,
- "elsif" => :ELSIF,
- "else" => :ELSE,
- "inherits" => :INHERITS,
- "node" => :NODE,
- "and" => :AND,
- "or" => :OR,
- "undef" => :UNDEF,
- "false" => :FALSE,
- "true" => :TRUE,
- "in" => :IN
+
+ KEYWORDS.add_tokens(
+
+ "case" => :CASE,
+ "class" => :CLASS,
+ "default" => :DEFAULT,
+ "define" => :DEFINE,
+ "import" => :IMPORT,
+ "if" => :IF,
+ "elsif" => :ELSIF,
+ "else" => :ELSE,
+ "inherits" => :INHERITS,
+ "node" => :NODE,
+ "and" => :AND,
+ "or" => :OR,
+ "undef" => :UNDEF,
+ "false" => :FALSE,
+ "true" => :TRUE,
+
+ "in" => :IN
)
def clear
@@ -318,7 +324,7 @@ class Puppet::Parser::Lexer
# until we either match or run out of chars. This way our worst-case is three
# tries, where it is otherwise the number of string token we have. Also,
# the lookups are optimized hash lookups, instead of regex scans.
- #
+ #
s = @scanner.peek(3)
token = TOKENS.lookup(s[0,3]) || TOKENS.lookup(s[0,2]) || TOKENS.lookup(s[0,1])
[ token, token && @scanner.scan(token.regex) ]
@@ -352,7 +358,7 @@ class Puppet::Parser::Lexer
end
def indefine?
- if defined? @indefine
+ if defined?(@indefine)
@indefine
else
false
@@ -380,8 +386,8 @@ class Puppet::Parser::Lexer
@expected = []
@commentstack = [ ['', @line] ]
@lexing_context = {
- :after => nil,
- :start_of_line => true,
+ :after => nil,
+ :start_of_line => true,
:string_interpolation_depth => 0
}
end
@@ -527,7 +533,7 @@ class Puppet::Parser::Lexer
ch
else
Puppet.warning "Unrecognised escape sequence '\\#{ch}'#{file && " in file #{file}"}#{line && " at line #{line}"}"
- "\\#{ch}"
+ "\\#{ch}"
end
end
}
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 644170f60..e1af32fba 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -214,10 +214,10 @@ class Puppet::Parser::Resource < Puppet::Resource
# the database interaction doesn't have to worry about
# whether it returns an array or a string.
result[p] = if v.is_a?(Array) and v.length == 1
- v[0]
- else
- v
- end
+ v[0]
+ else
+ v
+ end
end
result.file = self.file
@@ -302,14 +302,14 @@ class Puppet::Parser::Resource < Puppet::Resource
# If we've gotten this far, we're allowed to override.
- # Merge with previous value, if the parameter was generated with the +>
- # syntax. It's important that we use a copy of the new param instance
- # here, not the old one, and not the original new one, so that the source
- # is registered correctly for later overrides but the values aren't
+ # Merge with previous value, if the parameter was generated with the +>
+ # syntax. It's important that we use a copy of the new param instance
+ # here, not the old one, and not the original new one, so that the source
+ # is registered correctly for later overrides but the values aren't
# implcitly shared when multiple resources are overrriden at once (see
# ticket #3556).
if param.add
- param = param.dup
+ param = param.dup
param.value = [current.value, param.value].flatten
end
@@ -331,8 +331,7 @@ class Puppet::Parser::Resource < Puppet::Resource
params.each do |param|
# Don't set the same parameter twice
if @parameters[param.name]
- self.fail Puppet::ParseError, "Duplicate parameter '%s' for on %s" %
- [param.name, self.to_s]
+ self.fail Puppet::ParseError, "Duplicate parameter '%s' for on %s" % [param.name, self.to_s]
end
set_parameter(param)
diff --git a/lib/puppet/parser/resource/param.rb b/lib/puppet/parser/resource/param.rb
index f44d5a6e9..26b067703 100644
--- a/lib/puppet/parser/resource/param.rb
+++ b/lib/puppet/parser/resource/param.rb
@@ -1,7 +1,7 @@
require 'puppet/file_collection/lookup'
require 'puppet/parser/yaml_trimmer'
- # The parameters we stick in Resources.
+# The parameters we stick in Resources.
class Puppet::Parser::Resource::Param
attr_accessor :name, :value, :source, :add
include Puppet::Util
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 39317a729..d9ea3cc8f 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -416,8 +416,7 @@ class Puppet::Parser::Scope
tmp = ss.scan(/[^\\$]+/)
# Puppet.debug("Got other: pos:%d; m:%s" % [ss.pos, tmp])
unless tmp
- error = Puppet::ParseError.new("Could not parse string %s" %
- string.inspect)
+ error = Puppet::ParseError.new("Could not parse string %s" % string.inspect)
{:file= => file, :line= => line}.each do |m,v|
error.send(m, v) if v
end
@@ -455,7 +454,7 @@ class Puppet::Parser::Scope
if level == :all
@ephemeral = [ Ephemeral.new ]
else
- (@ephemeral.size - level).times do
+ (@ephemeral.size - level).times do
@ephemeral.pop
end
end
diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb
index 71f0dc084..5f779cb8d 100644
--- a/lib/puppet/parser/type_loader.rb
+++ b/lib/puppet/parser/type_loader.rb
@@ -15,9 +15,9 @@ class Puppet::Parser::TypeLoader
if !self.has_key? item
self[item] = { :loader => Thread.current, :busy => self.new_cond}
:nobody
- elsif self[item][:loader] == Thread.current
+ elsif self[item][:loader] == Thread.current
:this_thread
- else
+ else
flag = self[item][:busy]
flag.wait
flag.signal
@@ -79,8 +79,8 @@ class Puppet::Parser::TypeLoader
name2files(namespaces, name).each do |filename|
modname = nil
import_if_possible(filename) do
- modname = import(filename)
- @loaded << filename
+ modname = import(filename)
+ @loaded << filename
end
if result = yield(filename)
Puppet.info "Automatically imported #{name} from #{filename}"
@@ -131,14 +131,14 @@ class Puppet::Parser::TypeLoader
def import_if_possible(file)
return if @loaded.include?(file)
begin
- case @loading.owner_of(file)
- when :this_thread
- return
- when :another_thread
- return import_if_possible(file)
- when :nobody
- yield
- end
+ case @loading.owner_of(file)
+ when :this_thread
+ return
+ when :another_thread
+ return import_if_possible(file)
+ when :nobody
+ yield
+ end
rescue Puppet::ImportError => detail
# We couldn't load the item
ensure
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index 7601d783c..f18709721 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -190,9 +190,12 @@ class Puppet::Property < Puppet::Parameter
# Send a log message.
def log(msg)
- Puppet::Util::Log.create(
+
+ Puppet::Util::Log.create(
+
:level => resource[:loglevel],
:message => msg,
+
:source => self
)
end
@@ -273,7 +276,7 @@ class Puppet::Property < Puppet::Parameter
# Only return the first value
def should
- return nil unless defined? @should
+ return nil unless defined?(@should)
unless @should.is_a?(Array)
self.devfail "should for #{self.class.name} on #{resource.name} is not an array"
diff --git a/lib/puppet/property/ensure.rb b/lib/puppet/property/ensure.rb
index 908de8b1b..2b1d1d433 100644
--- a/lib/puppet/property/ensure.rb
+++ b/lib/puppet/property/ensure.rb
@@ -49,14 +49,12 @@ class Puppet::Property::Ensure < Puppet::Property
elsif newvalue == :absent
return "removed"
else
- return "%s changed '%s' to '%s'" %
- [self.name, self.is_to_s(currentvalue), self.should_to_s(newvalue)]
+ return "%s changed '%s' to '%s'" % [self.name, self.is_to_s(currentvalue), self.should_to_s(newvalue)]
end
rescue Puppet::Error, Puppet::DevError
raise
rescue => detail
- raise Puppet::DevError, "Could not convert change %s to string: %s" %
- [self.name, detail]
+ raise Puppet::DevError, "Could not convert change %s to string: %s" % [self.name, detail]
end
end
@@ -71,8 +69,7 @@ class Puppet::Property::Ensure < Puppet::Property
elsif @resource.respond_to?(:exists?)
result = @resource.exists?
else
- raise Puppet::DevError, "No ability to determine if %s exists" %
- @resource.class.name
+ raise Puppet::DevError, "No ability to determine if %s exists" % @resource.class.name
end
if result
return :present
diff --git a/lib/puppet/property/keyvalue.rb b/lib/puppet/property/keyvalue.rb
index 6c0800c79..df6560643 100644
--- a/lib/puppet/property/keyvalue.rb
+++ b/lib/puppet/property/keyvalue.rb
@@ -52,7 +52,7 @@ module Puppet
end
def should
- unless defined? @should and @should
+ unless defined?(@should) and @should
return nil
end
@@ -81,7 +81,7 @@ module Puppet
end
def insync?(is)
- unless defined? @should and @should
+ unless defined?(@should) and @should
return true
end
diff --git a/lib/puppet/property/list.rb b/lib/puppet/property/list.rb
index 31af76b82..2e38aeccc 100644
--- a/lib/puppet/property/list.rb
+++ b/lib/puppet/property/list.rb
@@ -38,7 +38,7 @@ module Puppet
end
def should
- unless defined? @should and @should
+ unless defined?(@should) and @should
return nil
end
@@ -72,7 +72,7 @@ module Puppet
end
def insync?(is)
- unless defined? @should and @should
+ unless defined?(@should) and @should
return true
end
diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb
index 26279260a..b68602aae 100644
--- a/lib/puppet/provider.rb
+++ b/lib/puppet/provider.rb
@@ -40,8 +40,7 @@ class Puppet::Provider
elsif superclass.respond_to? :command and command = superclass.command(name)
# nothing
else
- raise Puppet::DevError, "No command %s defined for provider %s" %
- [name, self.name]
+ raise Puppet::DevError, "No command %s defined for provider %s" % [name, self.name]
end
return binary(command)
@@ -109,7 +108,7 @@ class Puppet::Provider
# Create the methods for a given command.
def self.make_command_methods(name)
# Now define a method for that command
- unless singleton_class.method_defined? name
+ unless singleton_class.method_defined?(name)
meta_def(name) do |*args|
unless command(name)
raise Puppet::Error, "Command %s is missing" % name
@@ -126,7 +125,7 @@ class Puppet::Provider
# And then define an instance method that just calls the class method.
# We need both, so both instances and classes can easily run the commands.
- unless method_defined? name
+ unless method_defined?(name)
define_method(name) do |*args|
self.class.send(name, *args)
end
@@ -179,7 +178,7 @@ class Puppet::Provider
# Retrieve the data source. Defaults to the provider name.
def self.source
- unless defined? @source
+ unless defined?(@source)
@source = self.name
end
@source
@@ -204,7 +203,7 @@ class Puppet::Provider
end
# def self.to_s
-# unless defined? @str
+# unless defined?(@str)
# if self.resource_type
# @str = "%s provider %s" % [resource_type.name, self.name]
# else
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 3a35c3241..163c864fa 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -31,17 +31,17 @@ Puppet::Type.type(:augeas).provide(:augeas) do
SAVE_OVERWRITE = "overwrite"
COMMANDS = {
- "set" => [ :path, :string ],
- "rm" => [ :path ],
- "clear" => [ :path ],
- "insert" => [ :string, :string, :path ],
- "get" => [ :path, :comparator, :string ],
- "match" => [ :path, :glob ],
- "size" => [:comparator, :int],
- "include" => [:string],
- "not_include" => [:string],
- "==" => [:glob],
- "!=" => [:glob]
+ "set" => [ :path, :string ],
+ "rm" => [ :path ],
+ "clear" => [ :path ],
+ "insert" => [ :string, :string, :path ],
+ "get" => [ :path, :comparator, :string ],
+ "match" => [ :path, :glob ],
+ "size" => [:comparator, :int],
+ "include" => [:string],
+ "not_include" => [:string],
+ "==" => [:glob],
+ "!=" => [:glob]
}
COMMANDS["ins"] = COMMANDS["insert"]
diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb
index 6dee2e515..c7ccd190f 100755
--- a/lib/puppet/provider/cron/crontab.rb
+++ b/lib/puppet/provider/cron/crontab.rb
@@ -10,9 +10,12 @@ tab = case Facter.value(:operatingsystem)
end
-Puppet::Type.type(:cron).provide(:crontab,
+
+ Puppet::Type.type(:cron).provide(
+ :crontab,
:parent => Puppet::Provider::ParsedFile,
:default_target => ENV["USER"] || "root",
+
:filetype => tab
) do
commands :crontab => "crontab"
diff --git a/lib/puppet/provider/file/posix.rb b/lib/puppet/provider/file/posix.rb
index 43b745d37..63d80ead1 100644
--- a/lib/puppet/provider/file/posix.rb
+++ b/lib/puppet/provider/file/posix.rb
@@ -64,7 +64,7 @@ Puppet::Type.type(:file).provide :posix do
return false
end
end
-
+
def retrieve(resource)
unless stat = resource.stat(false)
return :absent
@@ -82,7 +82,7 @@ Puppet::Type.type(:file).provide :posix do
return currentvalue
end
-
+
def sync(path, links, should)
# Set our method appropriately, depending on links.
if links == :manage
diff --git a/lib/puppet/provider/file/win32.rb b/lib/puppet/provider/file/win32.rb
index 21cc2deff..da6db1e8c 100644
--- a/lib/puppet/provider/file/win32.rb
+++ b/lib/puppet/provider/file/win32.rb
@@ -6,7 +6,7 @@ Puppet::Type.type(:file).provide :microsoft_windows do
include Puppet::Util::Warnings
require 'sys/admin' if Puppet.features.microsoft_windows?
-
+
def id2name(id)
return id.to_s if id.is_a?(Symbol)
return nil if id > Puppet[:maximum_uid].to_i
diff --git a/lib/puppet/provider/host/parsed.rb b/lib/puppet/provider/host/parsed.rb
index d69dcbec4..f4282c5a6 100644
--- a/lib/puppet/provider/host/parsed.rb
+++ b/lib/puppet/provider/host/parsed.rb
@@ -7,9 +7,12 @@ else
hosts = "/etc/hosts"
end
-Puppet::Type.type(:host).provide(:parsed,
+
+ Puppet::Type.type(:host).provide(
+ :parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => hosts,
+
:filetype => :flat
) do
confine :exists => hosts
diff --git a/lib/puppet/provider/macauthorization/macauthorization.rb b/lib/puppet/provider/macauthorization/macauthorization.rb
index d1e2b229f..696b5bb82 100644
--- a/lib/puppet/provider/macauthorization/macauthorization.rb
+++ b/lib/puppet/provider/macauthorization/macauthorization.rb
@@ -37,10 +37,10 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
# This map exists due to the use of hyphens and reserved words in
# the authorization schema.
PuppetToNativeAttributeMap = { :allow_root => "allow-root",
- :authenticate_user => "authenticate-user",
- :auth_class => "class",
- :k_of_n => "k-of-n",
- :session_owner => "session-owner", }
+ :authenticate_user => "authenticate-user",
+ :auth_class => "class",
+ :k_of_n => "k-of-n",
+ :session_owner => "session-owner", }
class << self
attr_accessor :parsed_auth_db
@@ -196,8 +196,11 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
Plist::Emit.save_plist(values, tmp.path)
cmds = []
cmds << :security << "authorizationdb" << "write" << name
- output = execute(cmds, :combine => false,
- :stdinfile => tmp.path.to_s)
+
+ output = execute(
+ cmds, :combine => false,
+
+ :stdinfile => tmp.path.to_s)
rescue Errno::EACCES => e
raise Puppet::Error.new("Cannot save right to #{tmp.path}: #{e}")
ensure
@@ -285,8 +288,8 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
# case due to not being in the actual authorization db schema.
properties = [ :allow_root, :authenticate_user, :auth_class, :comment,
- :group, :k_of_n, :mechanisms, :rule, :session_owner,
- :shared, :timeout, :tries ]
+ :group, :k_of_n, :mechanisms, :rule, :session_owner,
+ :shared, :timeout, :tries ]
properties.each do |field|
define_method(field.to_s) do
diff --git a/lib/puppet/provider/mailalias/aliases.rb b/lib/puppet/provider/mailalias/aliases.rb
index f880ccea1..5b7f0e2ec 100755
--- a/lib/puppet/provider/mailalias/aliases.rb
+++ b/lib/puppet/provider/mailalias/aliases.rb
@@ -1,8 +1,11 @@
require 'puppet/provider/parsedfile'
-Puppet::Type.type(:mailalias).provide(:aliases,
+
+ Puppet::Type.type(:mailalias).provide(
+ :aliases,
:parent => Puppet::Provider::ParsedFile,
:default_target => "/etc/aliases",
+
:filetype => :flat
) do
text_line :comment, :match => /^#/
@@ -18,11 +21,11 @@ Puppet::Type.type(:mailalias).provide(:aliases,
end
def process(line)
- ret = {}
- records = line.split(':',2)
- ret[:name] = records[0].strip()
- ret[:recipient] = records[1].strip()
- ret
+ ret = {}
+ records = line.split(':',2)
+ ret[:name] = records[0].strip()
+ ret[:recipient] = records[1].strip()
+ ret
end
def to_line(record)
diff --git a/lib/puppet/provider/mcx/mcxcontent.rb b/lib/puppet/provider/mcx/mcxcontent.rb
index 002bb0dae..de60de15a 100644
--- a/lib/puppet/provider/mcx/mcxcontent.rb
+++ b/lib/puppet/provider/mcx/mcxcontent.rb
@@ -68,10 +68,13 @@ Puppet::Type.type(:mcx).provide :mcxcontent, :parent => Puppet::Provider do
Puppet.debug "/#{TypeMap[ds_type]}/#{ds_name} has no MCX data."
else
# This node has MCX data.
- rsrc = self.new(:name => "/#{TypeMap[ds_type]}/#{ds_name}",
- :ds_type => ds_type,
- :ds_name => ds_name,
- :content => content)
+
+ rsrc = self.new(
+ :name => "/#{TypeMap[ds_type]}/#{ds_name}",
+ :ds_type => ds_type,
+ :ds_name => ds_name,
+
+ :content => content)
mcx_list << rsrc
end
end
@@ -184,17 +187,23 @@ Puppet::Type.type(:mcx).provide :mcxcontent, :parent => Puppet::Provider do
def content
ds_parms = get_dsparams
- mcx = self.class.mcxexport(ds_parms[:ds_type],
- ds_parms[:ds_name])
+
+ mcx = self.class.mcxexport(
+ ds_parms[:ds_type],
+
+ ds_parms[:ds_name])
return mcx
end
def content=(value)
# dscl localhost -mcximport
ds_parms = get_dsparams
- mcx = mcximport(ds_parms[:ds_type],
- ds_parms[:ds_name],
- resource[:content])
+
+ mcx = mcximport(
+ ds_parms[:ds_type],
+ ds_parms[:ds_name],
+
+ resource[:content])
return mcx
end
diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb
index b30de2bc7..1100ad62c 100755
--- a/lib/puppet/provider/mount/parsed.rb
+++ b/lib/puppet/provider/mount/parsed.rb
@@ -8,9 +8,12 @@ else
fstab = "/etc/fstab"
end
-Puppet::Type.type(:mount).provide(:parsed,
+
+ Puppet::Type.type(:mount).provide(
+ :parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => fstab,
+
:filetype => :flat
) do
include Puppet::Provider::Mount
@@ -21,8 +24,7 @@ Puppet::Type.type(:mount).provide(:parsed,
@platform = Facter["operatingsystem"].value
case @platform
when "Solaris"
- @fields = [:device, :blockdevice, :name, :fstype, :pass, :atboot,
- :options]
+ @fields = [:device, :blockdevice, :name, :fstype, :pass, :atboot, :options]
else
@fields = [:device, :name, :fstype, :options, :dump, :pass]
@fielddefaults = [ nil ] * 4 + [ "0", "2" ]
diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb
index 57441ddf6..8a759e4f3 100644
--- a/lib/puppet/provider/nameservice.rb
+++ b/lib/puppet/provider/nameservice.rb
@@ -6,7 +6,7 @@ require 'puppet'
class Puppet::Provider::NameService < Puppet::Provider
class << self
def autogen_default(param)
- if defined? @autogen_defaults
+ if defined?(@autogen_defaults)
return @autogen_defaults[symbolize(param)]
else
return nil
@@ -36,7 +36,7 @@ class Puppet::Provider::NameService < Puppet::Provider
def option(name, option)
name = name.intern if name.is_a? String
- if defined? @options and @options.include? name and @options[name].include? option
+ if defined?(@options) and @options.include? name and @options[name].include? option
return @options[name][option]
else
return nil
@@ -45,8 +45,7 @@ class Puppet::Provider::NameService < Puppet::Provider
def options(name, hash)
unless resource_type.valid_parameter?(name)
- raise Puppet::DevError, "%s is not a valid attribute for %s" %
- [name, resource_type.name]
+ raise Puppet::DevError, "%s is not a valid attribute for %s" % [name, resource_type.name]
end
@options ||= {}
@options[name] ||= {}
@@ -93,7 +92,7 @@ class Puppet::Provider::NameService < Puppet::Provider
# This is annoying, but there really aren't that many options,
# and this *is* built into Ruby.
def section
- unless defined? @resource_type
+ unless defined?(@resource_type)
raise Puppet::DevError,
"Cannot determine Etc section without a resource type"
@@ -111,8 +110,7 @@ class Puppet::Provider::NameService < Puppet::Provider
if @checks.include? name
block = @checks[name][:block]
unless block.call(value)
- raise ArgumentError, "Invalid value %s: %s" %
- [value, @checks[name][:error]]
+ raise ArgumentError, "Invalid value %s: %s" % [value, @checks[name][:error]]
end
end
end
@@ -161,7 +159,7 @@ class Puppet::Provider::NameService < Puppet::Provider
end
# Make sure we don't use the same value multiple times
- if defined? @@prevauto
+ if defined?(@@prevauto)
@@prevauto += 1
else
Etc.send(group) { |obj|
@@ -179,7 +177,7 @@ class Puppet::Provider::NameService < Puppet::Provider
end
def create
- if exists?
+ if exists?
info "already exists"
# The object already exists
return nil
@@ -188,8 +186,7 @@ class Puppet::Provider::NameService < Puppet::Provider
begin
execute(self.addcmd)
rescue Puppet::ExecutionFailure => detail
- raise Puppet::Error, "Could not create %s %s: %s" %
- [@resource.class.name, @resource.name, detail]
+ raise Puppet::Error, "Could not create %s %s: %s" % [@resource.class.name, @resource.name, detail]
end
end
@@ -203,8 +200,7 @@ class Puppet::Provider::NameService < Puppet::Provider
begin
execute(self.deletecmd)
rescue Puppet::ExecutionFailure => detail
- raise Puppet::Error, "Could not delete %s %s: %s" %
- [@resource.class.name, @resource.name, detail]
+ raise Puppet::Error, "Could not delete %s %s: %s" % [@resource.class.name, @resource.name, detail]
end
end
diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb
index b882e808a..1eb0aec6c 100644
--- a/lib/puppet/provider/nameservice/directoryservice.rb
+++ b/lib/puppet/provider/nameservice/directoryservice.rb
@@ -93,7 +93,7 @@ class DirectoryService < Puppet::Provider::NameService
# For example, if we're working with an user type, this will be /Users
# with a group type, this will be /Groups.
# @ds_path is an attribute of the class itself.
- if defined? @ds_path
+ if defined?(@ds_path)
return @ds_path
end
# JJM: "Users" or "Groups" etc ... (Based on the Puppet::Type)
@@ -104,7 +104,7 @@ class DirectoryService < Puppet::Provider::NameService
end
def self.get_macosx_version_major
- if defined? @macosx_version_major
+ if defined?(@macosx_version_major)
return @macosx_version_major
end
begin
@@ -115,7 +115,7 @@ class DirectoryService < Puppet::Provider::NameService
product_version_major = Facter.value(:macosx_productversion_major)
else
# TODO: remove this code chunk once we require Facter 1.5.5 or higher.
- Puppet.warning("DEPRECATION WARNING: Future versions of the directoryservice provider will require Facter 1.5.5 or newer.")
+ Puppet.warning("DEPRECATION WARNING: Future versions of the directoryservice provider will require Facter 1.5.5 or newer.")
product_version = Facter.value(:macosx_productversion)
if product_version.nil?
fail("Could not determine OS X version from Facter")
@@ -138,7 +138,7 @@ class DirectoryService < Puppet::Provider::NameService
begin
dscl_output = execute(get_exec_preamble("-list"))
rescue Puppet::ExecutionFailure => detail
- fail("Could not get %s list from DirectoryService" % [ @resource_type.name.to_s ])
+ fail("Could not get %s list from DirectoryService" % [ @resource_type.name.to_s ])
end
return dscl_output.split("\n")
end
@@ -155,12 +155,12 @@ class DirectoryService < Puppet::Provider::NameService
dscl_plist = {}
dscl_output.split("\n").inject([]) do |array, line|
- if line =~ /^\s+/ # it's a value
- array[-1] << line # add the value to the previous key
- else
- array << line
- end
- array
+ if line =~ /^\s+/ # it's a value
+ array[-1] << line # add the value to the previous key
+ else
+ array << line
+ end
+ array
end.compact
dscl_output.each do |line|
@@ -357,19 +357,19 @@ class DirectoryService < Puppet::Provider::NameService
end
def password=(passphrase)
- exec_arg_vector = self.class.get_exec_preamble("-read", @resource.name)
- exec_arg_vector << @@ns_to_ds_attribute_map[:guid]
- begin
- guid_output = execute(exec_arg_vector)
- guid_plist = Plist.parse_xml(guid_output)
- # Although GeneratedUID like all DirectoryService values can be multi-valued
- # according to the schema, in practice user accounts cannot have multiple UUIDs
- # otherwise Bad Things Happen, so we just deal with the first value.
- guid = guid_plist["dsAttrTypeStandard:#{@@ns_to_ds_attribute_map[:guid]}"][0]
- self.class.set_password(@resource.name, guid, passphrase)
- rescue Puppet::ExecutionFailure => detail
- fail("Could not set %s on %s[%s]: %s" % [param, @resource.class.name, @resource.name, detail])
- end
+ exec_arg_vector = self.class.get_exec_preamble("-read", @resource.name)
+ exec_arg_vector << @@ns_to_ds_attribute_map[:guid]
+ begin
+ guid_output = execute(exec_arg_vector)
+ guid_plist = Plist.parse_xml(guid_output)
+ # Although GeneratedUID like all DirectoryService values can be multi-valued
+ # according to the schema, in practice user accounts cannot have multiple UUIDs
+ # otherwise Bad Things Happen, so we just deal with the first value.
+ guid = guid_plist["dsAttrTypeStandard:#{@@ns_to_ds_attribute_map[:guid]}"][0]
+ self.class.set_password(@resource.name, guid, passphrase)
+ rescue Puppet::ExecutionFailure => detail
+ fail("Could not set %s on %s[%s]: %s" % [param, @resource.class.name, @resource.name, detail])
+ end
end
# NBK: we override @parent.set as we need to execute a series of commands
@@ -385,10 +385,10 @@ class DirectoryService < Puppet::Provider::NameService
# in the manifest.
if @resource[:auth_membership] and not current_members.nil?
remove_unwanted_members(current_members, value)
- end
+ end
- # if they're not a member, make them one.
- add_members(current_members, value)
+ # if they're not a member, make them one.
+ add_members(current_members, value)
else
exec_arg_vector = self.class.get_exec_preamble("-create", @resource[:name])
# JJM: The following line just maps the NS name to the DS name
@@ -424,14 +424,13 @@ class DirectoryService < Puppet::Provider::NameService
exec_arg_vector = self.class.get_exec_preamble("-create", @resource[:name])
exec_arg_vector << @@ns_to_ds_attribute_map[:guid] << guid
begin
- execute(exec_arg_vector)
+ execute(exec_arg_vector)
rescue Puppet::ExecutionFailure => detail
- fail("Could not set GeneratedUID for %s %s: %s" %
- [@resource.class.name, @resource.name, detail])
+ fail("Could not set GeneratedUID for %s %s: %s" % [@resource.class.name, @resource.name, detail])
end
if value = @resource.should(:password) and value != ""
- self.class.set_password(@resource[:name], guid, value)
+ self.class.set_password(@resource[:name], guid, value)
end
# Now we create all the standard properties
@@ -446,10 +445,9 @@ class DirectoryService < Puppet::Provider::NameService
next if property == :password # skip setting the password here
exec_arg_vector << value.to_s
begin
- execute(exec_arg_vector)
+ execute(exec_arg_vector)
rescue Puppet::ExecutionFailure => detail
- fail("Could not create %s %s: %s" %
- [@resource.class.name, @resource.name, detail])
+ fail("Could not create %s %s: %s" % [@resource.class.name, @resource.name, detail])
end
end
end
@@ -461,24 +459,24 @@ class DirectoryService < Puppet::Provider::NameService
if not new_members.include?(member)
cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-d", member, @resource[:name]]
begin
- execute(cmd)
+ execute(cmd)
rescue Puppet::ExecutionFailure => detail
- fail("Could not remove %s from group: %s, %s" % [member, @resource.name, detail])
+ fail("Could not remove %s from group: %s, %s" % [member, @resource.name, detail])
end
- end
- end
+ end
+ end
end
def add_members(current_members, new_members)
new_members.each do |new_member|
- if current_members.nil? or not current_members.include?(new_member)
- cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-a", new_member, @resource[:name]]
- begin
+ if current_members.nil? or not current_members.include?(new_member)
+ cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-a", new_member, @resource[:name]]
+ begin
execute(cmd)
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
fail("Could not add %s to group: %s, %s" % [new_member, @resource.name, detail])
- end
- end
+ end
+ end
end
end
diff --git a/lib/puppet/provider/package/aix.rb b/lib/puppet/provider/package/aix.rb
index 5cccdf376..385d33fac 100644
--- a/lib/puppet/provider/package/aix.rb
+++ b/lib/puppet/provider/package/aix.rb
@@ -43,7 +43,7 @@ Puppet::Type.type(:package).provide :aix, :parent => Puppet::Provider::Package d
previous = updates[current[:name]]
unless Puppet::Util::Package.versioncmp(previous[:version], current[:version]) == 1
- updates[ current[:name] ] = current
+ updates[ current[:name] ] = current
end
else
diff --git a/lib/puppet/provider/package/appdmg.rb b/lib/puppet/provider/package/appdmg.rb
index 352f8738f..a07b43f07 100644
--- a/lib/puppet/provider/package/appdmg.rb
+++ b/lib/puppet/provider/package/appdmg.rb
@@ -17,7 +17,7 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag
desc "Package management which copies application bundles to a target."
confine :operatingsystem => :darwin
-
+
commands :hdiutil => "/usr/bin/hdiutil"
commands :curl => "/usr/bin/curl"
commands :ditto => "/usr/bin/ditto"
@@ -40,12 +40,12 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag
end
def self.installapp(source, name, orig_source)
- appname = File.basename(source);
- ditto "--rsrc", source, "/Applications/#{appname}"
- File.open("/var/db/.puppet_appdmg_installed_#{name}", "w") do |t|
- t.print "name: '#{name}'\n"
- t.print "source: '#{orig_source}'\n"
- end
+ appname = File.basename(source);
+ ditto "--rsrc", source, "/Applications/#{appname}"
+ File.open("/var/db/.puppet_appdmg_installed_#{name}", "w") do |t|
+ t.print "name: '#{name}'\n"
+ t.print "source: '#{orig_source}'\n"
+ end
end
def self.installpkgdmg(source, name)
diff --git a/lib/puppet/provider/package/apple.rb b/lib/puppet/provider/package/apple.rb
index 063470fc4..9214d4eb5 100755
--- a/lib/puppet/provider/package/apple.rb
+++ b/lib/puppet/provider/package/apple.rb
@@ -13,9 +13,12 @@ Puppet::Type.type(:package).provide :apple, :parent => Puppet::Provider::Package
def self.instances
instance_by_name.collect do |name|
- self.new(
+
+ self.new(
+
:name => name,
:provider => :apple,
+
:ensure => :installed
)
end
diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb
index c43bb4dfc..9ae2a861e 100755
--- a/lib/puppet/provider/package/apt.rb
+++ b/lib/puppet/provider/package/apt.rb
@@ -19,7 +19,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do
# install packages from remote sites.
def checkforcdrom
- unless defined? @@checkedforcdrom
+ unless defined?(@@checkedforcdrom)
if FileTest.exists? "/etc/apt/sources.list"
if File.read("/etc/apt/sources.list") =~ /^[^#]*cdrom:/
@@checkedforcdrom = true
diff --git a/lib/puppet/provider/package/aptrpm.rb b/lib/puppet/provider/package/aptrpm.rb
index 0471fb915..4b3841d88 100644
--- a/lib/puppet/provider/package/aptrpm.rb
+++ b/lib/puppet/provider/package/aptrpm.rb
@@ -12,12 +12,12 @@ Puppet::Type.type(:package).provide :aptrpm, :parent => :rpm, :source => :rpm do
if command('rpm')
confine :true => begin
- rpm('-ql', 'rpm')
- rescue Puppet::ExecutionFailure
- false
- else
- true
- end
+ rpm('-ql', 'rpm')
+ rescue Puppet::ExecutionFailure
+ false
+ else
+ true
+ end
end
# Install a package using 'apt-get'. This function needs to support
diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb
index fda9e02fb..aaa277944 100755
--- a/lib/puppet/provider/package/dpkg.rb
+++ b/lib/puppet/provider/package/dpkg.rb
@@ -106,13 +106,15 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
# list out our specific package
begin
- output = dpkgquery("-W", "--showformat",
+
+ output = dpkgquery(
+ "-W", "--showformat",
+
'${Status} ${Package} ${Version}\\n', @resource[:name]
)
rescue Puppet::ExecutionFailure
# dpkg-query exits 1 if the package is not found.
- return {:ensure => :purged, :status => 'missing',
- :name => @resource[:name], :error => 'ok'}
+ return {:ensure => :purged, :status => 'missing', :name => @resource[:name], :error => 'ok'}
end
@@ -120,8 +122,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
if hash[:error] != "ok"
raise Puppet::Error.new(
- "Package %s, version %s is in error state: %s" %
- [hash[:name], hash[:ensure], hash[:error]]
+ "Package %s, version %s is in error state: %s" % [hash[:name], hash[:ensure], hash[:error]]
)
end
@@ -144,7 +145,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
tmpfile.flush
execute([:dpkg, "--set-selections"], :stdinfile => tmpfile.path.to_s)
}
- end
+ end
end
def unhold
diff --git a/lib/puppet/provider/package/fink.rb b/lib/puppet/provider/package/fink.rb
index 5d9e86313..d859c0e32 100755
--- a/lib/puppet/provider/package/fink.rb
+++ b/lib/puppet/provider/package/fink.rb
@@ -79,6 +79,6 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do
def purge
aptget '-y', '-q', 'remove', '--purge', @resource[:name]
- end
+ end
end
diff --git a/lib/puppet/provider/package/freebsd.rb b/lib/puppet/provider/package/freebsd.rb
index f4ca35466..79316f80f 100755
--- a/lib/puppet/provider/package/freebsd.rb
+++ b/lib/puppet/provider/package/freebsd.rb
@@ -6,8 +6,8 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
libraries."
commands :pkginfo => "/usr/sbin/pkg_info",
- :pkgadd => "/usr/sbin/pkg_add",
- :pkgdelete => "/usr/sbin/pkg_delete"
+ :pkgadd => "/usr/sbin/pkg_add",
+ :pkgdelete => "/usr/sbin/pkg_delete"
confine :operatingsystem => :freebsd
diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb
index 56350fd36..9dca08d5c 100755
--- a/lib/puppet/provider/package/gem.rb
+++ b/lib/puppet/provider/package/gem.rb
@@ -4,9 +4,9 @@ require 'uri'
# Ruby gems support.
Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package do
desc "Ruby Gem support. If a URL is passed via ``source``, then that URL is used as the
- remote gem repository; if a source is present but is not a valid URL, it will be
- interpreted as the path to a local gem file. If source is not present at all,
- the gem will be installed from the default gem repositories."
+ remote gem repository; if a source is present but is not a valid URL, it will be
+ interpreted as the path to a local gem file. If source is not present at all,
+ the gem will be installed from the default gem repositories."
has_feature :versionable
diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb
index 0c4fb36f0..76922dc09 100644
--- a/lib/puppet/provider/package/hpux.rb
+++ b/lib/puppet/provider/package/hpux.rb
@@ -7,8 +7,8 @@ Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package
desc "HP-UX's packaging system."
commands :swinstall => "/usr/sbin/swinstall",
- :swlist => "/usr/sbin/swlist",
- :swremove => "/usr/sbin/swremove"
+ :swlist => "/usr/sbin/swlist",
+ :swremove => "/usr/sbin/swremove"
confine :operatingsystem => "hp-ux"
diff --git a/lib/puppet/provider/package/nim.rb b/lib/puppet/provider/package/nim.rb
index 670136e6b..a798f338a 100644
--- a/lib/puppet/provider/package/nim.rb
+++ b/lib/puppet/provider/package/nim.rb
@@ -19,7 +19,7 @@ Puppet::Type.type(:package).provide :nim, :parent => :aix, :source => :aix do
def self.srclistcmd(source)
return [ command(:nimclient), "-o", "showres", "-a", "installp_flags=L", "-a", "resource=#{source}" ]
- end
+ end
def install(useversion = true)
unless source = @resource[:source]
diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb
index 1c873fdad..254c9ab61 100755
--- a/lib/puppet/provider/package/openbsd.rb
+++ b/lib/puppet/provider/package/openbsd.rb
@@ -78,24 +78,24 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
end
def get_version
- begin
+ begin
execpipe([command(:pkginfo), " -I ", @resource[:name]]) do |process|
# our regex for matching pkg_info output
regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
fields = [ :name, :version, :flavor ]
master_version = 0
-
+
process.each do |line|
- if match = regex.match(line.split()[0])
+ if match = regex.match(line.split()[0])
# now we return the first version, unless ensure is latest
version = match.captures[1]
return version unless @resource[:ensure] == "latest"
-
+
master_version = version unless master_version > version
end
end
-
- return master_version unless master_version == 0
+
+ return master_version unless master_version == 0
raise Puppet::Error, "#{version} is not available for this package"
end
rescue Puppet::ExecutionFailure
diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb
index 148ef0d62..7d21acb66 100644
--- a/lib/puppet/provider/package/pkg.rb
+++ b/lib/puppet/provider/package/pkg.rb
@@ -66,8 +66,7 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d
when "installed"
version = v
else
- Puppet.warn "unknown package state for %s: %s" %
- [@resource[:name], v]
+ Puppet.warn "unknown package state for %s: %s" % [@resource[:name], v]
end
end
version
@@ -95,17 +94,14 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d
rescue Puppet::ExecutionFailure
# pkg returns 1 if the package is not found.
return {:ensure => :absent, :status => 'missing',
- :name => @resource[:name], :error => 'ok'}
+ :name => @resource[:name], :error => 'ok'}
end
- hash = self.class.parse_line(output) ||
- {:ensure => :absent, :status => 'missing',
- :name => @resource[:name], :error => 'ok'}
+ hash = self.class.parse_line(output) ||
+ {:ensure => :absent, :status => 'missing', :name => @resource[:name], :error => 'ok'}
if hash[:error] != "ok"
- raise Puppet::Error.new(
- "Package %s, version %s is in error state: %s" %
- [hash[:name], hash[:version], hash[:error]])
+ raise Puppet::Error.new( "Package %s, version %s is in error state: %s" % [hash[:name], hash[:version], hash[:error]])
end
return hash
diff --git a/lib/puppet/provider/package/pkgdmg.rb b/lib/puppet/provider/package/pkgdmg.rb
index 25edc9109..4e9e50802 100644
--- a/lib/puppet/provider/package/pkgdmg.rb
+++ b/lib/puppet/provider/package/pkgdmg.rb
@@ -30,7 +30,7 @@ require 'facter/util/plist'
Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Package do
desc "Package management based on Apple's Installer.app and DiskUtility.app. This package works by checking the contents of a DMG image for Apple pkg or mpkg files. Any number of pkg or mpkg files may exist in the root directory of the DMG file system. Sub directories are not checked for packages. See `the wiki docs </trac/puppet/wiki/DmgPackages>` for more detail."
-
+
confine :operatingsystem => :darwin
defaultfor :operatingsystem => :darwin
commands :installer => "/usr/sbin/installer"
@@ -50,21 +50,24 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag
def self.instances
instance_by_name.collect do |name|
+
new(
+
:name => name,
:provider => :pkgdmg,
+
:ensure => :installed
)
end
end
def self.installpkg(source, name, orig_source)
- installer "-pkg", source, "-target", "/"
- # Non-zero exit status will throw an exception.
- File.open("/var/db/.puppet_pkgdmg_installed_#{name}", "w") do |t|
- t.print "name: '#{name}'\n"
- t.print "source: '#{orig_source}'\n"
- end
+ installer "-pkg", source, "-target", "/"
+ # Non-zero exit status will throw an exception.
+ File.open("/var/db/.puppet_pkgdmg_installed_#{name}", "w") do |t|
+ t.print "name: '#{name}'\n"
+ t.print "source: '#{orig_source}'\n"
+ end
end
def self.installpkgdmg(source, name)
diff --git a/lib/puppet/provider/package/ports.rb b/lib/puppet/provider/package/ports.rb
index 21696721e..16e065ef8 100755
--- a/lib/puppet/provider/package/ports.rb
+++ b/lib/puppet/provider/package/ports.rb
@@ -2,9 +2,9 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre
desc "Support for FreeBSD's ports. Again, this still mixes packages and ports."
commands :portupgrade => "/usr/local/sbin/portupgrade",
- :portversion => "/usr/local/sbin/portversion",
- :portuninstall => "/usr/local/sbin/pkg_deinstall",
- :portinfo => "/usr/sbin/pkg_info"
+ :portversion => "/usr/local/sbin/portversion",
+ :portuninstall => "/usr/local/sbin/pkg_deinstall",
+ :portinfo => "/usr/sbin/pkg_info"
defaultfor :operatingsystem => :freebsd
diff --git a/lib/puppet/provider/package/portupgrade.rb b/lib/puppet/provider/package/portupgrade.rb
index 531cab219..acdcab6f7 100644
--- a/lib/puppet/provider/package/portupgrade.rb
+++ b/lib/puppet/provider/package/portupgrade.rb
@@ -3,248 +3,248 @@
require 'puppet/provider/package'
Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::Package do
- include Puppet::Util::Execution
-
- desc "Support for FreeBSD's ports using the portupgrade ports management software.
- Use the port's full origin as the resource name. eg (ports-mgmt/portupgrade)
- for the portupgrade port."
-
- ## has_features is usually autodetected based on defs below.
- # has_features :installable, :uninstallable, :upgradeable
-
- commands :portupgrade => "/usr/local/sbin/portupgrade",
- :portinstall => "/usr/local/sbin/portinstall",
- :portversion => "/usr/local/sbin/portversion",
- :portuninstall => "/usr/local/sbin/pkg_deinstall",
- :portinfo => "/usr/sbin/pkg_info"
-
- ## Activate this only once approved by someone important.
- # defaultfor :operatingsystem => :freebsd
-
- # Remove unwanted environment variables.
- %w{INTERACTIVE UNAME}.each do |var|
- if ENV.include?(var)
- ENV.delete(var)
- end
- end
-
- ######## instances sub command (builds the installed packages list)
-
- def self.instances
- Puppet.debug "portupgrade.rb Building packages list from installed ports"
-
- # regex to match output from pkg_info
- regex = %r{^(\S+)-([^-\s]+):(\S+)$}
- # Corresponding field names
- fields = [:portname, :ensure, :portorigin]
- # define Temporary hash used, packages array of hashes
- hash = Hash.new
- packages = []
-
- # exec command
- cmdline = ["-aoQ"]
- begin
- output = portinfo(*cmdline)
- rescue Puppet::ExecutionFailure
- raise Puppet::Error.new(output)
- return nil
- end
-
- # split output and match it and populate temp hash
- output.split("\n").each { |data|
- # reset hash to nil for each line
- hash.clear
- if match = regex.match(data)
- # Output matched regex
- fields.zip(match.captures) { |field, value|
- hash[field] = value
- }
-
- # populate the actual :name field from the :portorigin
- # Set :provider to this object name
- hash[:name] = hash[:portorigin]
- hash[:provider] = self.name
-
- # Add to the full packages listing
- packages << new(hash)
-
- else
- # unrecognised output from pkg_info
- Puppet.debug "portupgrade.Instances() - unable to match output: %s" % data
- end
- }
-
- # return the packages array of hashes
- return packages
-
- end
-
- ######## Installation sub command
-
- def install
- Puppet.debug "portupgrade.install() - Installation call on %s" % @resource[:name]
- # -M: yes, we're a batch, so don't ask any questions
+ include Puppet::Util::Execution
+
+ desc "Support for FreeBSD's ports using the portupgrade ports management software.
+ Use the port's full origin as the resource name. eg (ports-mgmt/portupgrade)
+ for the portupgrade port."
+
+ ## has_features is usually autodetected based on defs below.
+ # has_features :installable, :uninstallable, :upgradeable
+
+ commands :portupgrade => "/usr/local/sbin/portupgrade",
+ :portinstall => "/usr/local/sbin/portinstall",
+ :portversion => "/usr/local/sbin/portversion",
+ :portuninstall => "/usr/local/sbin/pkg_deinstall",
+ :portinfo => "/usr/sbin/pkg_info"
+
+ ## Activate this only once approved by someone important.
+ # defaultfor :operatingsystem => :freebsd
+
+ # Remove unwanted environment variables.
+ %w{INTERACTIVE UNAME}.each do |var|
+ if ENV.include?(var)
+ ENV.delete(var)
+ end
+ end
+
+ ######## instances sub command (builds the installed packages list)
+
+ def self.instances
+ Puppet.debug "portupgrade.rb Building packages list from installed ports"
+
+ # regex to match output from pkg_info
+ regex = %r{^(\S+)-([^-\s]+):(\S+)$}
+ # Corresponding field names
+ fields = [:portname, :ensure, :portorigin]
+ # define Temporary hash used, packages array of hashes
+ hash = Hash.new
+ packages = []
+
+ # exec command
+ cmdline = ["-aoQ"]
+ begin
+ output = portinfo(*cmdline)
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error.new(output)
+ return nil
+ end
+
+ # split output and match it and populate temp hash
+ output.split("\n").each { |data|
+ # reset hash to nil for each line
+ hash.clear
+ if match = regex.match(data)
+ # Output matched regex
+ fields.zip(match.captures) { |field, value|
+ hash[field] = value
+ }
+
+ # populate the actual :name field from the :portorigin
+ # Set :provider to this object name
+ hash[:name] = hash[:portorigin]
+ hash[:provider] = self.name
+
+ # Add to the full packages listing
+ packages << new(hash)
+
+ else
+ # unrecognised output from pkg_info
+ Puppet.debug "portupgrade.Instances() - unable to match output: %s" % data
+ end
+ }
+
+ # return the packages array of hashes
+ return packages
+
+ end
+
+ ######## Installation sub command
+
+ def install
+ Puppet.debug "portupgrade.install() - Installation call on %s" % @resource[:name]
+ # -M: yes, we're a batch, so don't ask any questions
cmdline = ["-M BATCH=yes", @resource[:name]]
- # FIXME: it's possible that portinstall prompts for data so locks up.
- begin
- output = portinstall(*cmdline)
- rescue Puppet::ExecutionFailure
- raise Puppet::Error.new(output)
- end
-
- if output =~ /\*\* No such /
- raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name]
- end
-
- # No return code required, so do nil to be clean
- return nil
- end
-
- ######## Latest subcommand (returns the latest version available, or current version if installed is latest)
-
- def latest
- Puppet.debug "portupgrade.latest() - Latest check called on %s" % @resource[:name]
- # search for latest version available, or return current version.
- # cmdline = "portversion -v <portorigin>", returns "<portname> <code> <stuff>"
- # or "** No matching package found: <portname>"
+ # FIXME: it's possible that portinstall prompts for data so locks up.
+ begin
+ output = portinstall(*cmdline)
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error.new(output)
+ end
+
+ if output =~ /\*\* No such /
+ raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name]
+ end
+
+ # No return code required, so do nil to be clean
+ return nil
+ end
+
+ ######## Latest subcommand (returns the latest version available, or current version if installed is latest)
+
+ def latest
+ Puppet.debug "portupgrade.latest() - Latest check called on %s" % @resource[:name]
+ # search for latest version available, or return current version.
+ # cmdline = "portversion -v <portorigin>", returns "<portname> <code> <stuff>"
+ # or "** No matching package found: <portname>"
cmdline = ["-v", @resource[:name]]
- begin
- output = portversion(*cmdline)
- rescue Puppet::ExecutionFailure
- raise Puppet::Error.new(output)
- end
-
- # Check: output format.
- if output =~ /^\S+-([^-\s]+)\s+(\S)\s+(.*)/
- # $1 = installed version, $2 = comparison, $3 other data
- # latest installed
- installedversion = $1
- comparison = $2
- otherdata = $3
-
- # Only return a new version number when it's clear that there is a new version
- # all others return the current version so no unexpected 'upgrades' occur.
- case comparison
- when "=", ">"
- Puppet.debug "portupgrade.latest() - Installed package is latest (%s)" % installedversion
- return installedversion
- when "<"
- # "portpkg-1.7_5 < needs updating (port has 1.14)"
- # "portpkg-1.7_5 < needs updating (port has 1.14) (=> 'newport/pkg')
- if otherdata =~ /\(port has (\S+)\)/
- newversion = $1
- Puppet.debug "portupgrade.latest() - Installed version needs updating to (%s)" % newversion
- return newversion
- else
- Puppet.debug "portupgrade.latest() - Unable to determine new version from (%s)" % otherdata
- return installedversion
- end
- when "?", "!", "#"
- Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (%s)" % output
- return installedversion
- else
- Puppet.debug "portupgrade.latest() - Unknown code from portversion output (%s)" % output
- return installedversion
- end
-
- else
- # error: output not parsed correctly, error out with nil.
- # Seriously - this section should never be called in a perfect world.
- # as verification that the port is installed has already happened in query.
- if output =~ /^\*\* No matching package /
- raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name]
- else
- # Any other error (dump output to log)
- raise Puppet::ExecutionFailure, "Unexpected output from portversion: %s" % output
- end
-
- # Just in case we still are running, return nil
- return nil
- end
-
- # At this point normal operation has finished and we shouldn't have been called.
- # Error out and let the admin deal with it.
- raise Puppet::Error, "portversion.latest() - fatal error with portversion: %s" % output
- return nil
-
- end
-
- ###### Query subcommand - return a hash of details if exists, or nil if it doesn't.
- # Used to make sure the package is installed
-
- def query
- Puppet.debug "portupgrade.query() - Called on %s" % @resource[:name]
-
- cmdline = ["-qO", @resource[:name]]
- begin
- output = portinfo(*cmdline)
- rescue Puppet::ExecutionFailure
- raise Puppet::Error.new(output)
- end
-
- # Check: if output isn't in the right format, return nil
- if output =~ /^(\S+)-([^-\s]+)/
- # Fill in the details
- hash = Hash.new
- hash[:portorigin] = self.name
- hash[:portname] = $1
- hash[:ensure] = $2
-
- # If more details are required, then we can do another pkg_info query here
- # and parse out that output and add to the hash
-
- # return the hash to the caller
- return hash
- else
- Puppet.debug "portupgrade.query() - package (%s) not installed" % @resource[:name]
- return nil
- end
-
- end # def query
-
- ####### Uninstall command
-
- def uninstall
- Puppet.debug "portupgrade.uninstall() - called on %s" % @resource[:name]
- # Get full package name from port origin to uninstall with
- cmdline = ["-qO", @resource[:name]]
- begin
- output = portinfo(*cmdline)
- rescue Puppet::ExecutionFailure
- raise Puppet::Error.new(output)
- end
-
- if output =~ /^(\S+)/
- # output matches, so uninstall it
+ begin
+ output = portversion(*cmdline)
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error.new(output)
+ end
+
+ # Check: output format.
+ if output =~ /^\S+-([^-\s]+)\s+(\S)\s+(.*)/
+ # $1 = installed version, $2 = comparison, $3 other data
+ # latest installed
+ installedversion = $1
+ comparison = $2
+ otherdata = $3
+
+ # Only return a new version number when it's clear that there is a new version
+ # all others return the current version so no unexpected 'upgrades' occur.
+ case comparison
+ when "=", ">"
+ Puppet.debug "portupgrade.latest() - Installed package is latest (%s)" % installedversion
+ return installedversion
+ when "<"
+ # "portpkg-1.7_5 < needs updating (port has 1.14)"
+ # "portpkg-1.7_5 < needs updating (port has 1.14) (=> 'newport/pkg')
+ if otherdata =~ /\(port has (\S+)\)/
+ newversion = $1
+ Puppet.debug "portupgrade.latest() - Installed version needs updating to (%s)" % newversion
+ return newversion
+ else
+ Puppet.debug "portupgrade.latest() - Unable to determine new version from (%s)" % otherdata
+ return installedversion
+ end
+ when "?", "!", "#"
+ Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (%s)" % output
+ return installedversion
+ else
+ Puppet.debug "portupgrade.latest() - Unknown code from portversion output (%s)" % output
+ return installedversion
+ end
+
+ else
+ # error: output not parsed correctly, error out with nil.
+ # Seriously - this section should never be called in a perfect world.
+ # as verification that the port is installed has already happened in query.
+ if output =~ /^\*\* No matching package /
+ raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name]
+ else
+ # Any other error (dump output to log)
+ raise Puppet::ExecutionFailure, "Unexpected output from portversion: %s" % output
+ end
+
+ # Just in case we still are running, return nil
+ return nil
+ end
+
+ # At this point normal operation has finished and we shouldn't have been called.
+ # Error out and let the admin deal with it.
+ raise Puppet::Error, "portversion.latest() - fatal error with portversion: %s" % output
+ return nil
+
+ end
+
+ ###### Query subcommand - return a hash of details if exists, or nil if it doesn't.
+ # Used to make sure the package is installed
+
+ def query
+ Puppet.debug "portupgrade.query() - Called on %s" % @resource[:name]
+
+ cmdline = ["-qO", @resource[:name]]
+ begin
+ output = portinfo(*cmdline)
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error.new(output)
+ end
+
+ # Check: if output isn't in the right format, return nil
+ if output =~ /^(\S+)-([^-\s]+)/
+ # Fill in the details
+ hash = Hash.new
+ hash[:portorigin] = self.name
+ hash[:portname] = $1
+ hash[:ensure] = $2
+
+ # If more details are required, then we can do another pkg_info query here
+ # and parse out that output and add to the hash
+
+ # return the hash to the caller
+ return hash
+ else
+ Puppet.debug "portupgrade.query() - package (%s) not installed" % @resource[:name]
+ return nil
+ end
+
+ end # def query
+
+ ####### Uninstall command
+
+ def uninstall
+ Puppet.debug "portupgrade.uninstall() - called on %s" % @resource[:name]
+ # Get full package name from port origin to uninstall with
+ cmdline = ["-qO", @resource[:name]]
+ begin
+ output = portinfo(*cmdline)
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error.new(output)
+ end
+
+ if output =~ /^(\S+)/
+ # output matches, so uninstall it
portuninstall $1
- end
-
- end
-
- ######## Update/upgrade command
-
- def update
- Puppet.debug "portupgrade.update() - called on (%s)" % @resource[:name]
-
- cmdline = ["-qO", @resource[:name]]
- begin
- output = portinfo(*cmdline)
- rescue Puppet::ExecutionFailure
- raise Puppet::Error.new(output)
- end
-
- if output =~ /^(\S+)/
- # output matches, so upgrade the software
- cmdline = ["-M BATCH=yes", $1]
- begin
- output = portupgrade(*cmdline)
- rescue Puppet::ExecutionFailure
- raise Puppet::Error.new(output)
- end
- end
- end
+ end
+
+ end
+
+ ######## Update/upgrade command
+
+ def update
+ Puppet.debug "portupgrade.update() - called on (%s)" % @resource[:name]
+
+ cmdline = ["-qO", @resource[:name]]
+ begin
+ output = portinfo(*cmdline)
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error.new(output)
+ end
+
+ if output =~ /^(\S+)/
+ # output matches, so upgrade the software
+ cmdline = ["-M BATCH=yes", $1]
+ begin
+ output = portupgrade(*cmdline)
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error.new(output)
+ end
+ end
+ end
## EOF
end
diff --git a/lib/puppet/provider/package/rpm.rb b/lib/puppet/provider/package/rpm.rb
index a9da43fac..6d5adf2ef 100755
--- a/lib/puppet/provider/package/rpm.rb
+++ b/lib/puppet/provider/package/rpm.rb
@@ -14,12 +14,12 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr
if command('rpm')
confine :true => begin
- rpm('--version')
- rescue Puppet::ExecutionFailure
- false
- else
- true
- end
+ rpm('--version')
+ rescue Puppet::ExecutionFailure
+ false
+ else
+ true
+ end
end
def self.instances
diff --git a/lib/puppet/provider/package/sun.rb b/lib/puppet/provider/package/sun.rb
index 4f8b311ab..f0a1c6ac5 100755
--- a/lib/puppet/provider/package/sun.rb
+++ b/lib/puppet/provider/package/sun.rb
@@ -6,8 +6,8 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d
desc "Sun's packaging system. Requires that you specify the source for
the packages you're managing."
commands :pkginfo => "/usr/bin/pkginfo",
- :pkgadd => "/usr/sbin/pkgadd",
- :pkgrm => "/usr/sbin/pkgrm"
+ :pkgadd => "/usr/sbin/pkgadd",
+ :pkgrm => "/usr/sbin/pkgrm"
confine :operatingsystem => :solaris
diff --git a/lib/puppet/provider/package/up2date.rb b/lib/puppet/provider/package/up2date.rb
index 284bbaf42..1de7c6ea5 100644
--- a/lib/puppet/provider/package/up2date.rb
+++ b/lib/puppet/provider/package/up2date.rb
@@ -5,7 +5,7 @@ Puppet::Type.type(:package).provide :up2date, :parent => :rpm, :source => :rpm d
commands :up2date => "/usr/sbin/up2date-nox"
defaultfor :operatingsystem => [:redhat, :oel, :ovm],
- :lsbdistrelease => ["2.1", "3", "4"]
+ :lsbdistrelease => ["2.1", "3", "4"]
confine :operatingsystem => [:redhat, :oel, :ovm]
diff --git a/lib/puppet/provider/package/urpmi.rb b/lib/puppet/provider/package/urpmi.rb
index a79e96227..05eed42d7 100644
--- a/lib/puppet/provider/package/urpmi.rb
+++ b/lib/puppet/provider/package/urpmi.rb
@@ -4,12 +4,12 @@ Puppet::Type.type(:package).provide :urpmi, :parent => :rpm, :source => :rpm do
if command('rpm')
confine :true => begin
- rpm('-ql', 'rpm')
- rescue Puppet::ExecutionFailure
- false
- else
- true
- end
+ rpm('-ql', 'rpm')
+ rescue Puppet::ExecutionFailure
+ false
+ else
+ true
+ end
end
defaultfor :operatingsystem => [:mandriva, :mandrake]
diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb
index 6fdff6997..32ab2c124 100755
--- a/lib/puppet/provider/package/yum.rb
+++ b/lib/puppet/provider/package/yum.rb
@@ -11,12 +11,12 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
if command('rpm')
confine :true => begin
- rpm('--version')
- rescue Puppet::ExecutionFailure
- false
- else
- true
- end
+ rpm('--version')
+ rescue Puppet::ExecutionFailure
+ false
+ else
+ true
+ end
end
defaultfor :operatingsystem => [:fedora, :centos, :redhat]
@@ -28,26 +28,26 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
super
return unless packages.detect { |name, package| package.should(:ensure) == :latest }
- # collect our 'latest' info
- updates = {}
- python(YUMHELPER).each_line do |l|
- l.chomp!
- next if l.empty?
- if l[0,4] == "_pkg"
- hash = nevra_to_hash(l[5..-1])
- [hash[:name], "#{hash[:name]}.#{hash[:arch]}"].each do |n|
- updates[n] ||= []
- updates[n] << hash
- end
- end
- end
-
- # Add our 'latest' info to the providers.
- packages.each do |name, package|
- if info = updates[package[:name]]
- package.provider.latest_info = info[0]
- end
- end
+ # collect our 'latest' info
+ updates = {}
+ python(YUMHELPER).each_line do |l|
+ l.chomp!
+ next if l.empty?
+ if l[0,4] == "_pkg"
+ hash = nevra_to_hash(l[5..-1])
+ [hash[:name], "#{hash[:name]}.#{hash[:arch]}"].each do |n|
+ updates[n] ||= []
+ updates[n] << hash
+ end
+ end
+ end
+
+ # Add our 'latest' info to the providers.
+ packages.each do |name, package|
+ if info = updates[package[:name]]
+ package.provider.latest_info = info[0]
+ end
+ end
end
def install
@@ -104,5 +104,5 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
def purge
yum "-y", :erase, @resource[:name]
end
- end
+end
diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb
index 40e172785..47e4fcd69 100755
--- a/lib/puppet/provider/parsedfile.rb
+++ b/lib/puppet/provider/parsedfile.rb
@@ -36,7 +36,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
end
def self.filetype
- unless defined? @filetype
+ unless defined?(@filetype)
@filetype = Puppet::Util::FileType.filetype(:flat)
end
return @filetype
@@ -151,7 +151,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
if @property_hash[attr] or self.class.valid_attr?(self.class.name, attr)
@property_hash[attr] || :absent
else
- if defined? @resource
+ if defined?(@resource)
@resource.should(attr)
else
nil
@@ -385,7 +385,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
# Mark both the resource and provider target as modified.
def mark_target_modified
- if defined? @resource and restarget = @resource.should(:target) and restarget != @property_hash[:target]
+ if defined?(@resource) and restarget = @resource.should(:target) and restarget != @property_hash[:target]
self.class.modified(restarget)
end
if @property_hash[:target] != :absent and @property_hash[:target]
diff --git a/lib/puppet/provider/selboolean/getsetsebool.rb b/lib/puppet/provider/selboolean/getsetsebool.rb
index 4614c6c38..c993c3748 100644
--- a/lib/puppet/provider/selboolean/getsetsebool.rb
+++ b/lib/puppet/provider/selboolean/getsetsebool.rb
@@ -34,14 +34,14 @@ Puppet::Type.type(:selboolean).provide(:getsetsebool) do
# 'setsebool("...")' construct from working.
def execoutput (cmd)
- output = ''
- begin
- execpipe(cmd) do |out|
- output = out.readlines.join('').chomp!
+ output = ''
+ begin
+ execpipe(cmd) do |out|
+ output = out.readlines.join('').chomp!
+ end
+ rescue Puppet::ExecutionFailure
+ raise Puppet::ExecutionFailure, output.split("\n")[0]
end
- rescue Puppet::ExecutionFailure
- raise Puppet::ExecutionFailure, output.split("\n")[0]
- end
- return output
+ return output
end
end
diff --git a/lib/puppet/provider/selmodule/semodule.rb b/lib/puppet/provider/selmodule/semodule.rb
index 2b65c0d4a..c75acfa5e 100644
--- a/lib/puppet/provider/selmodule/semodule.rb
+++ b/lib/puppet/provider/selmodule/semodule.rb
@@ -25,7 +25,7 @@ Puppet::Type.type(:selmodule).provide(:semodule) do
execpipe("#{command(:semodule)} --list") do |out|
out.each do |line|
if line =~ /#{@resource[:name]}\b/
- return :true
+ return :true
end
end
end
@@ -57,15 +57,15 @@ Puppet::Type.type(:selmodule).provide(:semodule) do
# Helper functions
def execoutput (cmd)
- output = ''
- begin
- execpipe(cmd) do |out|
- output = out.readlines.join('').chomp!
+ output = ''
+ begin
+ execpipe(cmd) do |out|
+ output = out.readlines.join('').chomp!
+ end
+ rescue Puppet::ExecutionFailure
+ raise Puppet::ExecutionFailure, output.split("\n")[0]
end
- rescue Puppet::ExecutionFailure
- raise Puppet::ExecutionFailure, output.split("\n")[0]
- end
- return output
+ return output
end
def selmod_name_to_filename
diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb
index 183bf33e3..aa11f26fc 100755
--- a/lib/puppet/provider/service/base.rb
+++ b/lib/puppet/provider/service/base.rb
@@ -49,7 +49,7 @@ Puppet::Type.type(:service).provide :base do
end
end
- # There is no default command, which causes other methods to be used
+ # There is no default command, which causes other methods to be used
def restartcmd
end
@@ -77,10 +77,10 @@ Puppet::Type.type(:service).provide :base do
end
end
- # There is no default command, which causes other methods to be used
+ # There is no default command, which causes other methods to be used
def statuscmd
end
-
+
# Run the 'start' parameter command, or the specified 'startcmd'.
def start
ucommand(:start)
@@ -114,14 +114,13 @@ Puppet::Type.type(:service).provide :base do
begin
output = kill pid
rescue Puppet::ExecutionFailure => detail
- @resource.fail "Could not kill %s, PID %s: %s" %
- [self.name, pid, output]
+ @resource.fail "Could not kill %s, PID %s: %s" % [self.name, pid, output]
end
return true
end
end
-
- # There is no default command, which causes other methods to be used
+
+ # There is no default command, which causes other methods to be used
def stopcmd
end
diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb
index 3749f9c2c..cb3ac51a1 100644
--- a/lib/puppet/provider/service/daemontools.rb
+++ b/lib/puppet/provider/service/daemontools.rb
@@ -19,10 +19,10 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
or this can be overriden in the service resource parameters::
- service {
- \"myservice\":
- provider => \"daemontools\", path => \"/path/to/daemons\";
- }
+ service {
+ \"myservice\":
+ provider => \"daemontools\", path => \"/path/to/daemons\";
+ }
This provider supports out of the box:
diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb
index 51fb7a22b..34e2cf8b1 100755
--- a/lib/puppet/provider/service/debian.rb
+++ b/lib/puppet/provider/service/debian.rb
@@ -13,7 +13,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
# http://projects.reductivelabs.com/issues/2538
# is resolved.
commands :invoke_rc => "/usr/sbin/invoke-rc.d"
-
+
defaultfor :operatingsystem => [:debian, :ubuntu]
def self.defpath
@@ -30,7 +30,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
# TODO: Replace system() call when Puppet::Util.execute gives us a way
# to determine exit status. http://projects.reductivelabs.com/issues/2538
system("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start")
-
+
# 104 is the exit status when you query start an enabled service.
# 106 is the exit status when the policy layer supplies a fallback action
# See x-man-page://invoke-rc.d
diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb
index 27f3715ee..32f8abb7c 100644
--- a/lib/puppet/provider/service/freebsd.rb
+++ b/lib/puppet/provider/service/freebsd.rb
@@ -1,139 +1,139 @@
Puppet::Type.type(:service).provide :freebsd, :parent => :init do
- desc "Provider for FreeBSD. Makes use of rcvar argument of init scripts and parses/edits rc files."
-
- confine :operatingsystem => [:freebsd]
- defaultfor :operatingsystem => [:freebsd]
-
- @@rcconf = '/etc/rc.conf'
- @@rcconf_local = '/etc/rc.conf.local'
- @@rcconf_dir = '/etc/rc.conf.d'
-
- def self.defpath
- superclass.defpath
- end
-
- # Executing an init script with the 'rcvar' argument returns
- # the service name, rcvar name and whether it's enabled/disabled
- def rcvar
- rcvar = execute([self.initscript, :rcvar], :failonfail => true, :squelch => false)
- rcvar = rcvar.split("\n")
- return rcvar
- end
-
- # Extract service name
- def service_name
- name = self.rcvar[0]
- self.error("No service name found in rcvar") if name.nil?
- name = name.gsub!(/# (.*)/, '\1')
- self.error("Service name is empty") if name.nil?
- self.debug("Service name is #{name}")
- return name
- end
-
- # Extract rcvar name
- def rcvar_name
- name = self.rcvar[1]
- self.error("No rcvar name found in rcvar") if name.nil?
- name = name.gsub!(/(.*)_enable=(.*)/, '\1')
- self.error("rcvar name is empty") if name.nil?
- self.debug("rcvar name is #{name}")
- return name
- end
-
- # Extract rcvar value
- def rcvar_value
- value = self.rcvar[1]
- self.error("No rcvar value found in rcvar") if value.nil?
- value = value.gsub!(/(.*)_enable=\"?(.*)\"?/, '\2')
- self.error("rcvar value is empty") if value.nil?
- self.debug("rcvar value is #{value}")
- return value
- end
-
- # Edit rc files and set the service to yes/no
- def rc_edit(yesno)
- service = self.service_name
- rcvar = self.rcvar_name
- self.debug("Editing rc files: setting #{rcvar} to #{yesno} for #{service}")
- if not self.rc_replace(service, rcvar, yesno)
- self.rc_add(service, rcvar, yesno)
+ desc "Provider for FreeBSD. Makes use of rcvar argument of init scripts and parses/edits rc files."
+
+ confine :operatingsystem => [:freebsd]
+ defaultfor :operatingsystem => [:freebsd]
+
+ @@rcconf = '/etc/rc.conf'
+ @@rcconf_local = '/etc/rc.conf.local'
+ @@rcconf_dir = '/etc/rc.conf.d'
+
+ def self.defpath
+ superclass.defpath
+ end
+
+ # Executing an init script with the 'rcvar' argument returns
+ # the service name, rcvar name and whether it's enabled/disabled
+ def rcvar
+ rcvar = execute([self.initscript, :rcvar], :failonfail => true, :squelch => false)
+ rcvar = rcvar.split("\n")
+ return rcvar
+ end
+
+ # Extract service name
+ def service_name
+ name = self.rcvar[0]
+ self.error("No service name found in rcvar") if name.nil?
+ name = name.gsub!(/# (.*)/, '\1')
+ self.error("Service name is empty") if name.nil?
+ self.debug("Service name is #{name}")
+ return name
+ end
+
+ # Extract rcvar name
+ def rcvar_name
+ name = self.rcvar[1]
+ self.error("No rcvar name found in rcvar") if name.nil?
+ name = name.gsub!(/(.*)_enable=(.*)/, '\1')
+ self.error("rcvar name is empty") if name.nil?
+ self.debug("rcvar name is #{name}")
+ return name
+ end
+
+ # Extract rcvar value
+ def rcvar_value
+ value = self.rcvar[1]
+ self.error("No rcvar value found in rcvar") if value.nil?
+ value = value.gsub!(/(.*)_enable=\"?(.*)\"?/, '\2')
+ self.error("rcvar value is empty") if value.nil?
+ self.debug("rcvar value is #{value}")
+ return value
+ end
+
+ # Edit rc files and set the service to yes/no
+ def rc_edit(yesno)
+ service = self.service_name
+ rcvar = self.rcvar_name
+ self.debug("Editing rc files: setting #{rcvar} to #{yesno} for #{service}")
+ if not self.rc_replace(service, rcvar, yesno)
+ self.rc_add(service, rcvar, yesno)
+ end
end
- end
-
- # Try to find an existing setting in the rc files
- # and replace the value
- def rc_replace(service, rcvar, yesno)
- success = false
- # Replace in all files, not just in the first found with a match
- [@@rcconf, @@rcconf_local, @@rcconf_dir + "/#{service}"].each do |filename|
- if File.exists?(filename)
- s = File.read(filename)
- if s.gsub!(/(#{rcvar}_enable)=\"?(YES|NO)\"?/, "\\1=\"#{yesno}\"")
- File.open(filename, File::WRONLY) { |f| f << s }
- self.debug("Replaced in #{filename}")
- success = true
+
+ # Try to find an existing setting in the rc files
+ # and replace the value
+ def rc_replace(service, rcvar, yesno)
+ success = false
+ # Replace in all files, not just in the first found with a match
+ [@@rcconf, @@rcconf_local, @@rcconf_dir + "/#{service}"].each do |filename|
+ if File.exists?(filename)
+ s = File.read(filename)
+ if s.gsub!(/(#{rcvar}_enable)=\"?(YES|NO)\"?/, "\\1=\"#{yesno}\"")
+ File.open(filename, File::WRONLY) { |f| f << s }
+ self.debug("Replaced in #{filename}")
+ success = true
+ end
+ end
+ end
+ return success
+ end
+
+ # Add a new setting to the rc files
+ def rc_add(service, rcvar, yesno)
+ append = "\n\# Added by Puppet\n#{rcvar}_enable=\"#{yesno}\""
+ # First, try the one-file-per-service style
+ if File.exists?(@@rcconf_dir)
+ File.open(@@rcconf_dir + "/#{service}", File::WRONLY | File::APPEND | File::CREAT, 0644) {
+ |f| f << append
+ self.debug("Appended to #{f.path}")
+ }
+ else
+ # Else, check the local rc file first, but don't create it
+ if File.exists?(@@rcconf_local)
+ File.open(@@rcconf_local, File::WRONLY | File::APPEND) {
+ |f| f << append
+ self.debug("Appended to #{f.path}")
+ }
+ else
+ # At last use the standard rc.conf file
+ File.open(@@rcconf, File::WRONLY | File::APPEND | File::CREAT, 0644) {
+ |f| f << append
+ self.debug("Appended to #{f.path}")
+ }
+ end
+ end
+ end
+
+ def enabled?
+ if /YES$/ =~ self.rcvar_value then
+ self.debug("Is enabled")
+ return :true
end
- end
+ self.debug("Is disabled")
+ return :false
end
- return success
- end
-
- # Add a new setting to the rc files
- def rc_add(service, rcvar, yesno)
- append = "\n\# Added by Puppet\n#{rcvar}_enable=\"#{yesno}\""
- # First, try the one-file-per-service style
- if File.exists?(@@rcconf_dir)
- File.open(@@rcconf_dir + "/#{service}", File::WRONLY | File::APPEND | File::CREAT, 0644) {
- |f| f << append
- self.debug("Appended to #{f.path}")
- }
- else
- # Else, check the local rc file first, but don't create it
- if File.exists?(@@rcconf_local)
- File.open(@@rcconf_local, File::WRONLY | File::APPEND) {
- |f| f << append
- self.debug("Appended to #{f.path}")
- }
- else
- # At last use the standard rc.conf file
- File.open(@@rcconf, File::WRONLY | File::APPEND | File::CREAT, 0644) {
- |f| f << append
- self.debug("Appended to #{f.path}")
- }
- end
+
+ def enable
+ self.debug("Enabling")
+ self.rc_edit("YES")
+ end
+
+ def disable
+ self.debug("Disabling")
+ self.rc_edit("NO")
+ end
+
+ def startcmd
+ [self.initscript, :onestart]
+ end
+
+ def stopcmd
+ [self.initscript, :onestop]
end
- end
- def enabled?
- if /YES$/ =~ self.rcvar_value then
- self.debug("Is enabled")
- return :true
+ def statuscmd
+ [self.initscript, :onestatus]
end
- self.debug("Is disabled")
- return :false
- end
-
- def enable
- self.debug("Enabling")
- self.rc_edit("YES")
- end
-
- def disable
- self.debug("Disabling")
- self.rc_edit("NO")
- end
-
- def startcmd
- [self.initscript, :onestart]
- end
-
- def stopcmd
- [self.initscript, :onestop]
- end
-
- def statuscmd
- [self.initscript, :onestatus]
- end
end
diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb
index ed643119d..0327eb297 100644
--- a/lib/puppet/provider/service/gentoo.rb
+++ b/lib/puppet/provider/service/gentoo.rb
@@ -21,8 +21,7 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do
begin
output = update :del, @resource[:name], :default
rescue Puppet::ExecutionFailure
- raise Puppet::Error, "Could not disable %s: %s" %
- [self.name, output]
+ raise Puppet::Error, "Could not disable %s: %s" % [self.name, output]
end
end
@@ -49,8 +48,7 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do
begin
output = update :add, @resource[:name], :default
rescue Puppet::ExecutionFailure
- raise Puppet::Error, "Could not enable %s: %s" %
- [self.name, output]
+ raise Puppet::Error, "Could not enable %s: %s" % [self.name, output]
end
end
end
diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb
index 4c73845a3..5804732ed 100755
--- a/lib/puppet/provider/service/init.rb
+++ b/lib/puppet/provider/service/init.rb
@@ -49,7 +49,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
Dir.entries(path).each do |name|
fullpath = File.join(path, name)
next if name =~ /^\./
- next if exclude.include? name
+ next if exclude.include? name
next if not FileTest.executable?(fullpath)
instances << new(:name => name, :path => path, :hasstatus => true)
end
@@ -63,8 +63,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
when true, "true"; @parameters[:hasstatus] = true
when false, "false"; @parameters[:hasstatus] = false
else
- raise Puppet::Error, "Invalid 'hasstatus' value %s" %
- value.inspect
+ raise Puppet::Error, "Invalid 'hasstatus' value %s" % value.inspect
end
end
diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb
index 770a7b154..c65e1cc1a 100644
--- a/lib/puppet/provider/service/launchd.rb
+++ b/lib/puppet/provider/service/launchd.rb
@@ -8,28 +8,28 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
other platforms.
See:
- * http://developer.apple.com/macosx/launchd.html
- * http://launchd.macosforge.org/
+ * http://developer.apple.com/macosx/launchd.html
+ * http://launchd.macosforge.org/
This provider reads plists out of the following directories:
- * /System/Library/LaunchDaemons
- * /System/Library/LaunchAgents
- * /Library/LaunchDaemons
- * /Library/LaunchAgents
+ * /System/Library/LaunchDaemons
+ * /System/Library/LaunchAgents
+ * /Library/LaunchDaemons
+ * /Library/LaunchAgents
and builds up a list of services based upon each plists \"Label\" entry.
This provider supports:
- * ensure => running/stopped,
- * enable => true/false
- * status
- * restart
+ * ensure => running/stopped,
+ * enable => true/false
+ * status
+ * restart
Here is how the Puppet states correspond to launchd states:
- * stopped => job unloaded
- * started => job loaded
- * enabled => 'Disable' removed from job plist file
- * disabled => 'Disable' added to job plist file
+ * stopped => job unloaded
+ * started => job loaded
+ * enabled => 'Disable' removed from job plist file
+ * disabled => 'Disable' added to job plist file
Note that this allows you to do something launchctl can't do, which is to
be in a state of \"stopped/enabled\ or \"running/disabled\".
@@ -45,9 +45,9 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
has_feature :enableable
Launchd_Paths = ["/Library/LaunchAgents",
- "/Library/LaunchDaemons",
- "/System/Library/LaunchAgents",
- "/System/Library/LaunchDaemons",]
+ "/Library/LaunchDaemons",
+ "/System/Library/LaunchAgents",
+ "/System/Library/LaunchDaemons",]
Launchd_Overrides = "/var/db/launchd.db/com.apple.launchd/overrides.plist"
@@ -89,10 +89,10 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
new(:name => job, :provider => :launchd, :path => jobs[job])
end
end
-
-
+
+
def self.get_macosx_version_major
- if defined? @macosx_version_major
+ if defined?(@macosx_version_major)
return @macosx_version_major
end
begin
@@ -103,7 +103,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
product_version_major = Facter.value(:macosx_productversion_major)
else
# TODO: remove this code chunk once we require Facter 1.5.5 or higher.
- Puppet.warning("DEPRECATION WARNING: Future versions of the launchd provider will require Facter 1.5.5 or newer.")
+ Puppet.warning("DEPRECATION WARNING: Future versions of the launchd provider will require Facter 1.5.5 or newer.")
product_version = Facter.value(:macosx_productversion)
if product_version.nil?
fail("Could not determine OS X version from Facter")
@@ -211,15 +211,15 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
def enabled?
job_plist_disabled = nil
overrides_disabled = nil
-
+
job_path, job_plist = plist_from_label(resource[:name])
if job_plist.has_key?("Disabled")
job_plist_disabled = job_plist["Disabled"]
end
-
+
if self.class.get_macosx_version_major == "10.6":
overrides = Plist::parse_xml(Launchd_Overrides)
-
+
unless overrides.nil?
if overrides.has_key?(resource[:name])
if overrides[resource[:name]].has_key?("Disabled")
@@ -228,7 +228,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
end
end
end
-
+
if overrides_disabled.nil?
if job_plist_disabled.nil? or job_plist_disabled == false
return :true
diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb
index 27bdbb820..f3d5caee0 100755
--- a/lib/puppet/provider/service/redhat.rb
+++ b/lib/puppet/provider/service/redhat.rb
@@ -25,8 +25,7 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init
begin
output = chkconfig(@resource[:name], :off)
rescue Puppet::ExecutionFailure
- raise Puppet::Error, "Could not disable %s: %s" %
- [self.name, output]
+ raise Puppet::Error, "Could not disable %s: %s" % [self.name, output]
end
end
@@ -52,8 +51,7 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init
begin
output = chkconfig(@resource[:name], :on)
rescue Puppet::ExecutionFailure => detail
- raise Puppet::Error, "Could not enable %s: %s" %
- [self.name, detail]
+ raise Puppet::Error, "Could not enable %s: %s" % [self.name, detail]
end
end
diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb
index b8b444e34..265111469 100644
--- a/lib/puppet/provider/service/runit.rb
+++ b/lib/puppet/provider/service/runit.rb
@@ -4,31 +4,31 @@
Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
desc "Runit service management.
- This provider manages daemons running supervised by Runit.
- It tries to detect the service directory, with by order of preference:
+ This provider manages daemons running supervised by Runit.
+ It tries to detect the service directory, with by order of preference:
- * /service
- * /var/service
- * /etc/service
+ * /service
+ * /var/service
+ * /etc/service
- The daemon directory should be placed in a directory that can be
- by default in:
+ The daemon directory should be placed in a directory that can be
+ by default in:
- * /etc/sv
+ * /etc/sv
- or this can be overriden in the service resource parameters::
+ or this can be overriden in the service resource parameters::
- service {
- \"myservice\":
- provider => \"runit\", path => \"/path/to/daemons\";
- }
+ service {
+ \"myservice\":
+ provider => \"runit\", path => \"/path/to/daemons\";
+ }
- This provider supports out of the box:
+ This provider supports out of the box:
- * start/stop
- * enable/disable
- * restart
- * status
+ * start/stop
+ * enable/disable
+ * restart
+ * status
"
diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb
index 957a1ae82..685889386 100755
--- a/lib/puppet/provider/service/smf.rb
+++ b/lib/puppet/provider/service/smf.rb
@@ -90,11 +90,10 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
return :maintenance
when "legacy_run"
raise Puppet::Error,
- "Cannot manage legacy services through SMF"
+ "Cannot manage legacy services through SMF"
else
raise Puppet::Error,
- "Unmanageable state '%s' on service %s" %
- [state, self.name]
+ "Unmanageable state '%s' on service %s" % [state, self.name]
end
end
diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb
index eadce8e96..fe178ab4f 100755
--- a/lib/puppet/provider/service/src.rb
+++ b/lib/puppet/provider/service/src.rb
@@ -1,7 +1,7 @@
# AIX System Resource controller (SRC)
Puppet::Type.type(:service).provide :src, :parent => :base do
- desc "Support for AIX's System Resource controller.
+ desc "Support for AIX's System Resource controller.
Services are started/stopped based on the stopsrc and startsrc
commands, and some services can be refreshed with refresh command.
@@ -31,7 +31,7 @@ Puppet::Type.type(:service).provide :src, :parent => :base do
end
def restart
- begin
+ begin
execute([command(:lssrc), "-Ss", @resource[:name]]).each do |line|
args = line.split(":")
@@ -65,14 +65,14 @@ Puppet::Type.type(:service).provide :src, :parent => :base do
end
def status
- begin
+ begin
execute([command(:lssrc), "-s", @resource[:name]]).each do |line|
args = line.split
# This is the header line
next unless args[0] == @resource[:name]
- # PID is the 3rd field, but inoperative subsystems
+ # PID is the 3rd field, but inoperative subsystems
# skip this so split doesn't work right
state = case args[-1]
when "active" then :running
diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb
index cc4e27954..a39f59c54 100644
--- a/lib/puppet/provider/ssh_authorized_key/parsed.rb
+++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb
@@ -1,8 +1,11 @@
require 'puppet/provider/parsedfile'
-Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
+
+ Puppet::Type.type(:ssh_authorized_key).provide(
+ :parsed,
:parent => Puppet::Provider::ParsedFile,
:filetype => :flat,
+
:default_target => ''
) do
desc "Parse and generate authorized_keys files for SSH."
diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb
index e84e3e5c5..4fefc4067 100755
--- a/lib/puppet/provider/sshkey/parsed.rb
+++ b/lib/puppet/provider/sshkey/parsed.rb
@@ -7,9 +7,12 @@ else
known = "/etc/ssh/ssh_known_hosts"
end
-Puppet::Type.type(:sshkey).provide(:parsed,
+
+ Puppet::Type.type(:sshkey).provide(
+ :parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => known,
+
:filetype => :flat
) do
desc "Parse and generate host-wide known hosts files for SSH."
diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb
index aa01f8e52..961cb5e73 100644
--- a/lib/puppet/provider/user/user_role_add.rb
+++ b/lib/puppet/provider/user/user_role_add.rb
@@ -67,8 +67,7 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
begin
execute(cmd)
rescue Puppet::ExecutionFailure => detail
- raise Puppet::Error, "Could not %s %s %s: %s" %
- [msg, @resource.class.name, @resource.name, detail]
+ raise Puppet::Error, "Could not %s %s %s: %s" % [msg, @resource.class.name, @resource.name, detail]
end
end
diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb
index 532be1e83..714dda80c 100644
--- a/lib/puppet/rails.rb
+++ b/lib/puppet/rails.rb
@@ -59,13 +59,13 @@ module Puppet::Rails
socket = Puppet[:dbsocket]
args[:socket] = socket unless socket.to_s.empty?
-
+
connections = Puppet[:dbconnections].to_i
- args[:pool] = connections if connections > 0
+ args[:pool] = connections if connections > 0
when "oracle_enhanced":
- args[:database] = Puppet[:dbname] unless Puppet[:dbname].to_s.empty?
- args[:username] = Puppet[:dbuser] unless Puppet[:dbuser].to_s.empty?
- args[:password] = Puppet[:dbpassword] unless Puppet[:dbpassword].to_s.empty?
+ args[:database] = Puppet[:dbname] unless Puppet[:dbname].to_s.empty?
+ args[:username] = Puppet[:dbuser] unless Puppet[:dbuser].to_s.empty?
+ args[:password] = Puppet[:dbpassword] unless Puppet[:dbpassword].to_s.empty?
connections = Puppet[:dbconnections].to_i
args[:pool] = connections if connections > 0
@@ -137,7 +137,7 @@ module Puppet::Rails
ActiveRecord::Base.establish_connection(database_arguments())
rescue => detail
if Puppet[:trace]
- puts detail.backtrace
+ puts detail.backtrace
end
raise Puppet::Error, "Could not connect to database: %s" % detail
end
diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb
index 20d2e967f..a2477f2e6 100644
--- a/lib/puppet/rails/database/schema.rb
+++ b/lib/puppet/rails/database/schema.rb
@@ -21,7 +21,7 @@ class Puppet::Rails::Schema
# Thanks, mysql! MySQL requires a length on indexes in text fields.
# So, we provide them for mysql and handle everything else specially.
- # Oracle doesn't index on CLOB fields, so we skip it
+ # Oracle doesn't index on CLOB fields, so we skip it
if Puppet[:dbadapter] == "mysql"
execute "CREATE INDEX typentitle ON resources (restype,title(50));"
elsif Puppet[:dbadapter] != "oracle_enhanced"
@@ -51,10 +51,10 @@ class Puppet::Rails::Schema
t.column :created_at, :datetime
end
- # Oracle automatically creates a primary key index
- if Puppet[:dbadapter] != "oracle_enhanced"
+ # Oracle automatically creates a primary key index
+ if Puppet[:dbadapter] != "oracle_enhanced"
add_index :puppet_tags, :id, :integer => true
- end
+ end
create_table :hosts do |t|
t.column :name, :string, :null => false
diff --git a/lib/puppet/rails/fact_value.rb b/lib/puppet/rails/fact_value.rb
index e4cc6dd3c..a451cbb88 100644
--- a/lib/puppet/rails/fact_value.rb
+++ b/lib/puppet/rails/fact_value.rb
@@ -3,7 +3,7 @@ class Puppet::Rails::FactValue < ActiveRecord::Base
belongs_to :host
def to_label
- "#{self.fact_name.name}"
+ "#{self.fact_name.name}"
end
end
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index 6b057dd2d..7a3fe75bc 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -83,8 +83,11 @@ class Puppet::Rails::Host < ActiveRecord::Base
# Return the value of a fact.
def fact(name)
- if fv = self.fact_values.find(:all, :include => :fact_name,
- :conditions => "fact_names.name = '#{name}'")
+
+ if fv = self.fact_values.find(
+ :all, :include => :fact_name,
+
+ :conditions => "fact_names.name = '#{name}'")
return fv
else
return nil
diff --git a/lib/puppet/rails/resource_tag.rb b/lib/puppet/rails/resource_tag.rb
index 8d088fd2d..f094eabb8 100644
--- a/lib/puppet/rails/resource_tag.rb
+++ b/lib/puppet/rails/resource_tag.rb
@@ -3,7 +3,7 @@ class Puppet::Rails::ResourceTag < ActiveRecord::Base
belongs_to :resource
def to_label
- "#{self.puppet_tag.name}"
+ "#{self.puppet_tag.name}"
end
# returns an array of hash containing tags of resource
diff --git a/lib/puppet/rails/source_file.rb b/lib/puppet/rails/source_file.rb
index de95f755a..6a691893a 100644
--- a/lib/puppet/rails/source_file.rb
+++ b/lib/puppet/rails/source_file.rb
@@ -3,6 +3,6 @@ class Puppet::Rails::SourceFile < ActiveRecord::Base
has_one :resource
def to_label
- "#{self.filename}"
+ "#{self.filename}"
end
end
diff --git a/lib/puppet/reference/metaparameter.rb b/lib/puppet/reference/metaparameter.rb
index 2d24a4209..8e0a89ac6 100644
--- a/lib/puppet/reference/metaparameter.rb
+++ b/lib/puppet/reference/metaparameter.rb
@@ -8,17 +8,17 @@ metaparameter = Puppet::Util::Reference.newreference :metaparameter, :doc => "Al
types[type.name] = type
}
- str = %{
-Metaparameters
---------------
-Metaparameters are parameters that work with any resource type; they are part of the
-Puppet framework itself rather than being part of the implementation of any
-given instance. Thus, any defined metaparameter can be used with any instance
-in your manifest, including defined components.
+ str = %{
+ Metaparameters
+ --------------
+ Metaparameters are parameters that work with any resource type; they are part of the
+ Puppet framework itself rather than being part of the implementation of any
+ given instance. Thus, any defined metaparameter can be used with any instance
+ in your manifest, including defined components.
-Available Metaparameters
-++++++++++++++++++++++++
-}
+ Available Metaparameters
+ ++++++++++++++++++++++++
+ }
begin
params = []
Puppet::Type.eachmetaparam { |param|
diff --git a/lib/puppet/reference/type.rb b/lib/puppet/reference/type.rb
index 335f4a41a..c18681c1f 100644
--- a/lib/puppet/reference/type.rb
+++ b/lib/puppet/reference/type.rb
@@ -10,64 +10,63 @@ type = Puppet::Util::Reference.newreference :type, :doc => "All Puppet resource
str = %{
-Resource Types
---------------
+ Resource Types
+ --------------
-- The *namevar* is the parameter used to uniquely identify a type instance.
- This is the parameter that gets assigned when a string is provided before
- the colon in a type declaration. In general, only developers will need to
- worry about which parameter is the ``namevar``.
+ - The *namevar* is the parameter used to uniquely identify a type instance.
+ This is the parameter that gets assigned when a string is provided before
+ the colon in a type declaration. In general, only developers will need to
+ worry about which parameter is the ``namevar``.
- In the following code::
+ In the following code::
- file { "/etc/passwd":
- owner => root,
- group => root,
- mode => 644
- }
+ file { "/etc/passwd":
+ owner => root,
+ group => root,
+ mode => 644
+ }
- ``/etc/passwd`` is considered the title of the file object (used for things like
- dependency handling), and because ``path`` is the namevar for ``file``, that
- string is assigned to the ``path`` parameter.
+ ``/etc/passwd`` is considered the title of the file object (used for things like
+ dependency handling), and because ``path`` is the namevar for ``file``, that
+ string is assigned to the ``path`` parameter.
- *Parameters* determine the specific configuration of the instance. They either
- directly modify the system (internally, these are called properties) or they affect
- how the instance behaves (e.g., adding a search path for ``exec`` instances
- or determining recursion on ``file`` instances).
+ directly modify the system (internally, these are called properties) or they affect
+ how the instance behaves (e.g., adding a search path for ``exec`` instances or determining recursion on ``file`` instances).
- *Providers* provide low-level functionality for a given resource type. This is
- usually in the form of calling out to external commands.
+ usually in the form of calling out to external commands.
- When required binaries are specified for providers, fully qualifed paths
- indicate that the binary must exist at that specific path and unqualified
- binaries indicate that Puppet will search for the binary using the shell
- path.
+ When required binaries are specified for providers, fully qualifed paths
+ indicate that the binary must exist at that specific path and unqualified
+ binaries indicate that Puppet will search for the binary using the shell
+ path.
- *Features* are abilities that some providers might not support. You can use the list
- of supported features to determine how a given provider can be used.
+ of supported features to determine how a given provider can be used.
- Resource types define features they can use, and providers can be tested to see
- which features they provide.
+ Resource types define features they can use, and providers can be tested to see
+ which features they provide.
- }
+ }
- types.sort { |a,b|
- a.to_s <=> b.to_s
- }.each { |name,type|
+ types.sort { |a,b|
+ a.to_s <=> b.to_s
+ }.each { |name,type|
- str += "
+ str += "
----------------
"
- str += h(name, 3)
- str += scrub(type.doc) + "\n\n"
+ str += h(name, 3)
+ str += scrub(type.doc) + "\n\n"
- # Handle the feature docs.
- if featuredocs = type.featuredocs
- str += h("Features", 4)
- str += featuredocs
+ # Handle the feature docs.
+ if featuredocs = type.featuredocs
+ str += h("Features", 4)
+ str += featuredocs
end
docs = {}
diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb
index 18eb4eaeb..95f347539 100644
--- a/lib/puppet/relationship.rb
+++ b/lib/puppet/relationship.rb
@@ -31,7 +31,7 @@ class Puppet::Relationship
new(source, target, args)
end
-
+
def event=(event)
if event != :NONE and ! callback
raise ArgumentError, "You must pass a callback for non-NONE events"
diff --git a/lib/puppet/reports/rrdgraph.rb b/lib/puppet/reports/rrdgraph.rb
index 3e2eeb7a6..508b1d28b 100644
--- a/lib/puppet/reports/rrdgraph.rb
+++ b/lib/puppet/reports/rrdgraph.rb
@@ -22,7 +22,7 @@ Puppet::Reports.register_report(:rrdgraph) do
which defaults to the ``runinterval``."
def hostdir
- unless defined? @hostdir
+ unless defined?(@hostdir)
@hostdir = File.join(Puppet[:rrddir], self.host)
end
@hostdir
@@ -31,8 +31,7 @@ Puppet::Reports.register_report(:rrdgraph) do
def htmlfile(type, graphs, field)
file = File.join(hostdir, "%s.html" % type)
File.open(file, "w") do |of|
- of.puts "<html><head><title>%s graphs for %s</title></head><body>" %
- [type.capitalize, host]
+ of.puts "<html><head><title>%s graphs for %s</title></head><body>" % [type.capitalize, host]
graphs.each do |graph|
if field == :first
@@ -87,12 +86,9 @@ Puppet::Reports.register_report(:rrdgraph) do
end
File.open(File.join(hostdir, "index.html"), "w") do |of|
- of.puts "<html><head><title>Report graphs for %s</title></head><body>" %
- host
+ of.puts "<html><head><title>Report graphs for %s</title></head><body>" % host
files.each do |file|
- of.puts "<a href='%s'>%s</a><br/>" %
- [File.basename(file),
- File.basename(file).sub(".html",'').capitalize]
+ of.puts "<a href='%s'>%s</a><br/>" % [File.basename(file), File.basename(file).sub(".html",'').capitalize]
end
of.puts "</body></html>"
end
diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb
index a71cd3387..8317ee243 100644
--- a/lib/puppet/reports/store.rb
+++ b/lib/puppet/reports/store.rb
@@ -10,13 +10,16 @@ Puppet::Reports.register_report(:store) do
def mkclientdir(client, dir)
config = Puppet::Util::Settings.new
- config.setdefaults("reportclient-#{client}".to_sym,
+
+ config.setdefaults(
+ "reportclient-#{client}".to_sym,
"client-#{client}-dir" => { :default => dir,
:mode => 0750,
:desc => "Client dir for %s" % client,
:owner => 'service',
:group => 'service'
},
+
:noop => [false, "Used by settings internally."]
)
@@ -51,8 +54,7 @@ Puppet::Reports.register_report(:store) do
if Puppet[:trace]
puts detail.backtrace
end
- Puppet.warning "Could not write report for %s at %s: %s" %
- [client, file, detail]
+ Puppet.warning "Could not write report for %s at %s: %s" % [client, file, detail]
end
# Only testing cares about the return value
diff --git a/lib/puppet/reports/tagmail.rb b/lib/puppet/reports/tagmail.rb
index 9f71782f0..01ff1b033 100644
--- a/lib/puppet/reports/tagmail.rb
+++ b/lib/puppet/reports/tagmail.rb
@@ -31,8 +31,7 @@ Puppet::Reports.register_report(:tagmail) do
webservers that are not also from mailservers to ``httpadmins@domain.com``.
If you are using anti-spam controls, such as grey-listing, on your mail
- server you should whitelist the sending email (controlled by ``reportform``
- configuration option) to ensure your email is not discarded as spam.
+ server you should whitelist the sending email (controlled by ``reportform`` configuration option) to ensure your email is not discarded as spam.
"
@@ -109,8 +108,7 @@ Puppet::Reports.register_report(:tagmail) do
# Process the report. This just calls the other associated messages.
def process
unless FileTest.exists?(Puppet[:tagmap])
- Puppet.notice "Cannot send tagmail report; no tagmap file %s" %
- Puppet[:tagmap]
+ Puppet.notice "Cannot send tagmail report; no tagmap file %s" % Puppet[:tagmap]
return
end
@@ -130,12 +128,12 @@ Puppet::Reports.register_report(:tagmail) do
Net::SMTP.start(Puppet[:smtpserver]) do |smtp|
reports.each do |emails, messages|
smtp.open_message_stream(Puppet[:reportfrom], *emails) do |p|
- p.puts "From: #{Puppet[:reportfrom]}"
- p.puts "Subject: Puppet Report for %s" % self.host
- p.puts "To: " + emails.join(", ")
- p.puts "Date: " + Time.now.rfc2822
- p.puts
- p.puts messages
+ p.puts "From: #{Puppet[:reportfrom]}"
+ p.puts "Subject: Puppet Report for %s" % self.host
+ p.puts "To: " + emails.join(", ")
+ p.puts "Date: " + Time.now.rfc2822
+ p.puts
+ p.puts messages
end
end
end
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 3b96e7e99..8d1fb39a2 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -224,13 +224,13 @@ class Puppet::Resource
# Convert our resource to Puppet code.
def to_manifest
"%s { '%s':\n%s\n}" % [self.type.to_s.downcase, self.title,
- @parameters.collect { |p, v|
- if v.is_a? Array
- " #{p} => [\'#{v.join("','")}\']"
- else
- " #{p} => \'#{v}\'"
- end
- }.join(",\n")
+ @parameters.collect { |p, v|
+ if v.is_a? Array
+ " #{p} => [\'#{v.join("','")}\']"
+ else
+ " #{p} => \'#{v}\'"
+ end
+ }.join(",\n")
]
end
@@ -287,10 +287,10 @@ class Puppet::Resource
# the database interaction doesn't have to worry about
# whether it returns an array or a string.
result[p.to_s] = if v.is_a?(Array) and v.length == 1
- v[0]
- else
- v
- end
+ v[0]
+ else
+ v
+ end
end
result.tags = self.tags
@@ -405,11 +405,11 @@ class Puppet::Resource
end
def extract_type_and_title(argtype, argtitle)
- if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
- elsif argtitle then [ argtype, argtitle ]
- elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
- else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
- end
+ if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
+ elsif argtitle then [ argtype, argtitle ]
+ elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
+ else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
+ end
end
def munge_type_name(value)
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index 3cd4d7a8e..2c5c94920 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -311,7 +311,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
# Create a graph of all of the relationships in our catalog.
def relationship_graph
- unless defined? @relationship_graph and @relationship_graph
+ unless defined?(@relationship_graph) and @relationship_graph
# It's important that we assign the graph immediately, because
# the debug messages below use the relationships in the
# relationship graph to determine the path to the resources
@@ -394,11 +394,11 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
def self.from_pson(data)
result = new(data['name'])
- if tags = data['tags']
+ if tags = data['tags']
result.tag(*tags)
end
- if version = data['version']
+ if version = data['version']
result.version = version
end
@@ -460,11 +460,11 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
'metadata' => {
'api_version' => 1
}
- }
+ }
end
def to_pson(*args)
- to_pson_data_hash.to_pson(*args)
+ to_pson_data_hash.to_pson(*args)
end
# Convert our catalog into a RAL catalog.
@@ -477,7 +477,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
to_catalog :to_resource
end
- # filter out the catalog, applying +block+ to each resource.
+ # filter out the catalog, applying +block+ to each resource.
# If the block result is false, the resource will
# be kept otherwise it will be skipped
def filter(&block)
@@ -519,8 +519,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
msg = "Duplicate definition: %s is already defined" % resource.ref
if existing_resource.file and existing_resource.line
- msg << " in file %s at line %s" %
- [existing_resource.file, existing_resource.line]
+ msg << " in file %s at line %s" % [existing_resource.file, existing_resource.line]
end
if resource.line or resource.file
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index d9673ab04..a6cab8b8b 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -201,7 +201,7 @@ class Puppet::Resource::Type
arguments.each do |param, default|
param = param.to_sym
next if set.include?(param)
-
+
# Even if 'default' is a false value, it's an AST value, so this works fine
fail Puppet::ParseError, "Must pass #{param} to #{resource.ref}" unless default
diff --git a/lib/puppet/run.rb b/lib/puppet/run.rb
index 20e21dc57..4e9c160de 100644
--- a/lib/puppet/run.rb
+++ b/lib/puppet/run.rb
@@ -34,8 +34,7 @@ class Puppet::Run
def log_run
msg = ""
- msg += "triggered run" %
- if options[:tags]
+ msg += "triggered run" % if options[:tags]
msg += " with tags #{options[:tags].inspect}"
end
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index cf0eff38e..51382682c 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -122,7 +122,7 @@ class Puppet::SimpleGraph
def dependencies(resource)
# Cache the reversal graph, because it's somewhat expensive
# to create.
- unless defined? @reversal and @reversal
+ unless defined?(@reversal) and @reversal
@reversal = reversal
end
# Strangely, it's significantly faster to search a reversed
@@ -395,28 +395,28 @@ class Puppet::SimpleGraph
# rdot.rb. If an edge or vertex label is a kind of Hash then the keys
# which match +dot+ properties will be used as well.
def to_dot_graph (params = {})
- params['name'] ||= self.class.name.gsub(/:/,'_')
- fontsize = params['fontsize'] ? params['fontsize'] : '8'
- graph = (directed? ? DOT::DOTDigraph : DOT::DOTSubgraph).new(params)
- edge_klass = directed? ? DOT::DOTDirectedEdge : DOT::DOTEdge
- vertices.each do |v|
- name = v.to_s
- params = {'name' => '"'+name+'"',
- 'fontsize' => fontsize,
- 'label' => name}
- v_label = v.to_s
- params.merge!(v_label) if v_label and v_label.kind_of? Hash
- graph << DOT::DOTNode.new(params)
- end
- edges.each do |e|
- params = {'from' => '"'+ e.source.to_s + '"',
- 'to' => '"'+ e.target.to_s + '"',
- 'fontsize' => fontsize }
- e_label = e.to_s
- params.merge!(e_label) if e_label and e_label.kind_of? Hash
- graph << edge_klass.new(params)
- end
- graph
+ params['name'] ||= self.class.name.gsub(/:/,'_')
+ fontsize = params['fontsize'] ? params['fontsize'] : '8'
+ graph = (directed? ? DOT::DOTDigraph : DOT::DOTSubgraph).new(params)
+ edge_klass = directed? ? DOT::DOTDirectedEdge : DOT::DOTEdge
+ vertices.each do |v|
+ name = v.to_s
+ params = {'name' => '"'+name+'"',
+ 'fontsize' => fontsize,
+ 'label' => name}
+ v_label = v.to_s
+ params.merge!(v_label) if v_label and v_label.kind_of? Hash
+ graph << DOT::DOTNode.new(params)
+ end
+ edges.each do |e|
+ params = {'from' => '"'+ e.source.to_s + '"',
+ 'to' => '"'+ e.target.to_s + '"',
+ 'fontsize' => fontsize }
+ e_label = e.to_s
+ params.merge!(e_label) if e_label and e_label.kind_of? Hash
+ graph << edge_klass.new(params)
+ end
+ graph
end
# Output the dot format as a string
@@ -425,20 +425,20 @@ class Puppet::SimpleGraph
# Call +dotty+ for the graph which is written to the file 'graph.dot'
# in the # current directory.
def dotty (params = {}, dotfile = 'graph.dot')
- File.open(dotfile, 'w') {|f| f << to_dot(params) }
- system('dotty', dotfile)
+ File.open(dotfile, 'w') {|f| f << to_dot(params) }
+ system('dotty', dotfile)
end
# Use +dot+ to create a graphical representation of the graph. Returns the
# filename of the graphics file.
def write_to_graphic_file (fmt='png', dotfile='graph')
- src = dotfile + '.dot'
- dot = dotfile + '.' + fmt
+ src = dotfile + '.dot'
+ dot = dotfile + '.' + fmt
- File.open(src, 'w') {|f| f << self.to_dot << "\n"}
+ File.open(src, 'w') {|f| f << self.to_dot << "\n"}
- system( "dot -T#{fmt} #{src} -o #{dot}" )
- dot
+ system( "dot -T#{fmt} #{src} -o #{dot}" )
+ dot
end
# Produce the graph files if requested.
diff --git a/lib/puppet/sslcertificates.rb b/lib/puppet/sslcertificates.rb
index 62cfad1f0..ae539cc74 100755
--- a/lib/puppet/sslcertificates.rb
+++ b/lib/puppet/sslcertificates.rb
@@ -82,8 +82,11 @@ module Puppet::SSLCertificates
raise Puppet::Error, "unknown cert type '%s'" % hash[:type]
end
- ex << ef.create_extension("nsComment",
- "Puppet Ruby/OpenSSL Generated Certificate")
+
+ ex << ef.create_extension(
+ "nsComment",
+
+ "Puppet Ruby/OpenSSL Generated Certificate")
ex << ef.create_extension("basicConstraints", basic_constraint, true)
ex << ef.create_extension("subjectKeyIdentifier", "hash")
diff --git a/lib/puppet/sslcertificates/ca.rb b/lib/puppet/sslcertificates/ca.rb
index d4fc7b60f..5f32dd0a4 100644
--- a/lib/puppet/sslcertificates/ca.rb
+++ b/lib/puppet/sslcertificates/ca.rb
@@ -27,8 +27,7 @@ class Puppet::SSLCertificates::CA
end
File.unlink(file)
rescue => detail
- raise Puppet::Error, "Could not delete %s: %s" %
- [file, detail]
+ raise Puppet::Error, "Could not delete %s: %s" % [file, detail]
end
end
@@ -159,13 +158,16 @@ class Puppet::SSLCertificates::CA
if domain = Facter["domain"].value
name += "." + domain
end
- cert = Certificate.new(
+
+ cert = Certificate.new(
+
:name => name,
:cert => @config[:cacert],
:encrypt => @config[:capass],
:key => @config[:cakey],
:selfsign => true,
:ttl => ttl,
+
:type => :ca
)
@@ -239,8 +241,7 @@ class Puppet::SSLCertificates::CA
def sign(csr)
unless csr.is_a?(OpenSSL::X509::Request)
raise Puppet::Error,
- "CA#sign only accepts OpenSSL::X509::Request objects, not %s" %
- csr.class
+ "CA#sign only accepts OpenSSL::X509::Request objects, not %s" % csr.class
end
unless csr.verify(csr.public_key)
@@ -254,12 +255,15 @@ class Puppet::SSLCertificates::CA
f << "%04X" % (serial + 1)
}
- newcert = Puppet::SSLCertificates.mkcert(
+
+ newcert = Puppet::SSLCertificates.mkcert(
+
:type => :server,
:name => csr.subject,
:ttl => ttl,
:issuer => @cert,
:serial => serial,
+
:publickey => csr.public_key
)
@@ -293,8 +297,7 @@ class Puppet::SSLCertificates::CA
certfile = host2certfile(host)
if File.exists?(certfile)
- Puppet.notice "Overwriting signed certificate %s for %s" %
- [certfile, host]
+ Puppet.notice "Overwriting signed certificate %s for %s" % [certfile, host]
end
Puppet::SSLCertificates::Inventory::add(cert)
diff --git a/lib/puppet/sslcertificates/certificate.rb b/lib/puppet/sslcertificates/certificate.rb
index 191f553b0..d1acc1269 100644
--- a/lib/puppet/sslcertificates/certificate.rb
+++ b/lib/puppet/sslcertificates/certificate.rb
@@ -25,7 +25,7 @@ class Puppet::SSLCertificates::Certificate
end
}
- if defined? @hash and @hash
+ if defined?(@hash) and @hash
if FileTest.symlink?(@hash)
File.unlink(@hash)
end
@@ -41,8 +41,11 @@ class Puppet::SSLCertificates::Certificate
self.mkkey()
end
if @password
+
@key = OpenSSL::PKey::RSA.new(
+
File.read(@keyfile),
+
@password
)
else
@@ -137,7 +140,7 @@ class Puppet::SSLCertificates::Certificate
# this only works for servers, not for users
def mkcsr
- unless defined? @key and @key
+ unless defined?(@key) and @key
self.getkey
end
@@ -177,11 +180,14 @@ class Puppet::SSLCertificates::Certificate
# end
# }
- if @password
- #passwdproc = proc { @password }
- keytext = @key.export(
- OpenSSL::Cipher::DES.new(:EDE3, :CBC),
- @password
+ if @password
+ # passwdproc = proc { @password }
+
+ keytext = @key.export(
+
+ OpenSSL::Cipher::DES.new(:EDE3, :CBC),
+
+ @password
)
File.open(@keyfile, "w", 0400) { |f|
f << keytext
@@ -196,11 +202,11 @@ class Puppet::SSLCertificates::Certificate
end
def mkselfsigned
- unless defined? @key and @key
+ unless defined?(@key) and @key
self.getkey
end
- if defined? @cert and @cert
+ if defined?(@cert) and @cert
raise Puppet::Error, "Cannot replace existing certificate"
end
@@ -226,7 +232,7 @@ class Puppet::SSLCertificates::Certificate
def subject(string = false)
subj = @@params2names.collect { |param, name|
if @params.include?(param)
- [name, @params[param]]
+ [name, @params[param]]
end
}.reject { |ary| ary.nil? }
@@ -249,12 +255,12 @@ class Puppet::SSLCertificates::Certificate
@certfile => @cert,
@keyfile => @key,
}
- if defined? @cacert
+ if defined?(@cacert)
files[@cacertfile] = @cacert
end
files.each { |file,thing|
- if defined? thing and thing
+ if defined?(thing) and thing
if FileTest.exists?(file)
next
end
@@ -262,8 +268,11 @@ class Puppet::SSLCertificates::Certificate
text = nil
if thing.is_a?(OpenSSL::PKey::RSA) and @password
+
text = thing.export(
+
OpenSSL::Cipher::DES.new(:EDE3, :CBC),
+
@password
)
else
@@ -274,7 +283,7 @@ class Puppet::SSLCertificates::Certificate
end
}
- if defined? @cacert
+ if defined?(@cacert)
SSLCertificates.mkhash(Puppet[:certdir], @cacert, @cacertfile)
end
end
diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb
index 5ca06721d..6fa220f24 100644
--- a/lib/puppet/sslcertificates/support.rb
+++ b/lib/puppet/sslcertificates/support.rb
@@ -66,8 +66,7 @@ module Puppet::SSLCertificates::Support
# Our certificate request
keytype :csr, :param => :hostcsr, :class => OpenSSL::X509::Request do
- Puppet.info "Creating a new certificate request for %s" %
- Puppet[:certname]
+ Puppet.info "Creating a new certificate request for %s" % Puppet[:certname]
csr = OpenSSL::X509::Request.new
csr.version = 0
@@ -96,8 +95,7 @@ module Puppet::SSLCertificates::Support
if Puppet[:trace]
puts detail.backtrace
end
- raise Puppet::Error.new("Certificate retrieval failed: %s" %
- detail)
+ raise Puppet::Error.new("Certificate retrieval failed: %s" % detail)
end
if cert.nil? or cert == ""
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index ebbc7898f..b7cb39b92 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -342,7 +342,7 @@ class Puppet::Transaction
# The tags we should be checking.
def tags
- unless defined? @tags
+ unless defined?(@tags)
self.tags = Puppet[:tags]
end
diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb
index bc589fe84..cb6c24edb 100644
--- a/lib/puppet/transaction/event.rb
+++ b/lib/puppet/transaction/event.rb
@@ -3,7 +3,7 @@ require 'puppet/util/tagging'
require 'puppet/util/logging'
# A simple struct for storing what happens on the system.
-class Puppet::Transaction::Event
+class Puppet::Transaction::Event
include Puppet::Util::Tagging
include Puppet::Util::Logging
@@ -18,7 +18,7 @@ class Puppet::Transaction::Event
def initialize(*args)
options = args.last.is_a?(Hash) ? args.pop : ATTRIBUTES.inject({}) { |hash, attr| hash[attr] = args.pop; hash }
options.each { |attr, value| send(attr.to_s + "=", value) unless value.nil? }
-
+
@time = Time.now
end
diff --git a/lib/puppet/transaction/resource_harness.rb b/lib/puppet/transaction/resource_harness.rb
index e42b0969d..d6076681a 100644
--- a/lib/puppet/transaction/resource_harness.rb
+++ b/lib/puppet/transaction/resource_harness.rb
@@ -53,7 +53,7 @@ class Puppet::Transaction::ResourceHarness
end
resource.properties.reject { |p| p.name == :ensure }.reject do |param|
- param.should.nil?
+ param.should.nil?
end.reject do |param|
param_is_insync?(current, param)
end.collect do |param|
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index e6852da22..52747da66 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -34,7 +34,7 @@ module Puppet
end
def ref
- unless defined? @ref
+ unless defined?(@ref)
@ref = Puppet::Resource.new(@type, @name)
end
@ref.to_s
@@ -65,15 +65,14 @@ module Puppet
end
def to_manifest
- "%s { '%s':\n%s\n}" %
- [self.type.to_s, self.name,
- @params.collect { |p, v|
- if v.is_a? Array
- " #{p} => [\'#{v.join("','")}\']"
- else
- " #{p} => \'#{v}\'"
- end
- }.join(",\n")
+ "%s { '%s':\n%s\n}" % [self.type.to_s, self.name,
+ @params.collect { |p, v|
+ if v.is_a? Array
+ " #{p} => [\'#{v.join("','")}\']"
+ else
+ " #{p} => \'#{v}\'"
+ end
+ }.join(",\n")
]
end
@@ -151,8 +150,7 @@ module Puppet
# nada
else
raise Puppet::DevError,
- "TransBuckets cannot handle objects of type %s" %
- arg.class
+ "TransBuckets cannot handle objects of type %s" % arg.class
end
}
@children += args
@@ -161,7 +159,7 @@ module Puppet
# Convert to a parseable manifest
def to_manifest
unless self.top
- unless defined? @keyword and @keyword
+ unless defined?(@keyword) and @keyword
raise Puppet::DevError, "No keyword; cannot convert to manifest"
end
end
@@ -222,7 +220,7 @@ module Puppet
end
def to_ref
- unless defined? @ref
+ unless defined?(@ref)
if self.type and self.name
@ref = Puppet::Resource.new(self.type, self.name)
elsif self.type and ! self.name # This is old-school node types
@@ -247,7 +245,7 @@ module Puppet
end
def param(param,value)
- unless defined? @parameters
+ unless defined?(@parameters)
@parameters = {}
end
@parameters[param] = value
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 2da4e037b..3ac68c173 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -154,12 +154,15 @@ class Type
@@metaparamhash ||= {}
name = symbolize(name)
- param = genclass(name,
+
+ param = genclass(
+ name,
:parent => options[:parent] || Puppet::Parameter,
:prefix => "MetaParam",
:hash => @@metaparamhash,
:array => @@metaparams,
:attributes => options[:attributes],
+
&block
)
@@ -206,12 +209,15 @@ class Type
# @parameters array, and does some basic checking on it.
def self.newparam(name, options = {}, &block)
options[:attributes] ||= {}
- param = genclass(name,
+
+ param = genclass(
+ name,
:parent => options[:parent] || Puppet::Parameter,
:attributes => options[:attributes],
:block => block,
:prefix => "Parameter",
:array => @parameters,
+
:hash => @paramhash
)
@@ -228,8 +234,7 @@ class Type
end
def self.newstate(name, options = {}, &block)
- Puppet.warning "newstate() has been deprecrated; use newproperty(%s)" %
- name
+ Puppet.warning "newstate() has been deprecrated; use newproperty(%s)" % name
newproperty(name, options, &block)
end
@@ -250,8 +255,7 @@ class Type
end
if @validproperties.include?(name)
- raise Puppet::DevError, "Class %s already has a property named %s" %
- [self.name, name]
+ raise Puppet::DevError, "Class %s already has a property named %s" % [self.name, name]
end
if parent = options[:parent]
@@ -293,7 +297,7 @@ class Type
# Return the parameter names
def self.parameters
- return [] unless defined? @parameters
+ return [] unless defined?(@parameters)
@parameters.collect { |klass| klass.name }
end
@@ -335,14 +339,14 @@ class Type
# Return the list of validproperties
def self.validproperties
- return {} unless defined? @parameters
+ return {} unless defined?(@parameters)
return @validproperties.keys
end
# does the name reflect a valid parameter?
def self.validparameter?(name)
- unless defined? @parameters
+ unless defined?(@parameters)
raise Puppet::DevError, "Class %s has not defined parameters" % self
end
if @paramhash.include?(name) or @@metaparamhash.include?(name)
@@ -438,8 +442,7 @@ class Type
# make sure the parameter doesn't have any errors
property.value = value
rescue => detail
- error = Puppet::Error.new("Parameter %s failed: %s" %
- [name, detail])
+ error = Puppet::Error.new("Parameter %s failed: %s" % [name, detail])
error.set_backtrace(detail.backtrace)
raise error
end
@@ -594,7 +597,7 @@ class Type
# name conflicts, does it necessarily mean that the objects conflict?
# Defaults to true.
def self.isomorphic?
- if defined? @isomorphic
+ if defined?(@isomorphic)
return @isomorphic
else
return true
@@ -613,7 +616,7 @@ class Type
# Once an object is managed, it always stays managed; but an object
# that is listed as unmanaged might become managed later in the process,
# so we have to check that every time
- if defined? @managed and @managed
+ if defined?(@managed) and @managed
return @managed
else
@managed = false
@@ -634,7 +637,7 @@ class Type
# this is a retarded hack method to get around the difference between
# component children and file children
def self.depthfirst?
- if defined? @depthfirst
+ if defined?(@depthfirst)
return @depthfirst
else
return false
@@ -683,9 +686,8 @@ class Type
if property = @parameters[:ensure]
unless is.include? property
- raise Puppet::DevError,
- "The is value is not in the is array for '%s'" %
- [property.name]
+ raise Puppet::DevError,
+ "The is value is not in the is array for '%s'" % [property.name]
end
ensureis = is[property]
if property.insync?(ensureis) and property.should == :absent
@@ -695,15 +697,13 @@ class Type
properties.each { |property|
unless is.include? property
- raise Puppet::DevError,
- "The is value is not in the is array for '%s'" %
- [property.name]
+ raise Puppet::DevError,
+ "The is value is not in the is array for '%s'" % [property.name]
end
propis = is[property]
unless property.insync?(propis)
- property.debug("Not in sync: %s vs %s" %
- [propis.inspect, property.should.inspect])
+ property.debug("Not in sync: %s vs %s" % [propis.inspect, property.should.inspect])
insync = false
#else
# property.debug("In sync")
@@ -809,16 +809,13 @@ class Type
end
if exobj = @objects[name] and self.isomorphic?
- msg = "Object '%s[%s]' already exists" %
- [newobj.class.name, name]
+ msg = "Object '%s[%s]' already exists" % [newobj.class.name, name]
if exobj.file and exobj.line
- msg += ("in file %s at line %s" %
- [object.file, object.line])
+ msg += ("in file %s at line %s" % [object.file, object.line])
end
if object.file and object.line
- msg += ("and cannot be redefined in file %s at line %s" %
- [object.file, object.line])
+ msg += ("and cannot be redefined in file %s at line %s" % [object.file, object.line])
end
error = Puppet::Error.new(msg)
raise error
@@ -836,8 +833,7 @@ class Type
if @objects.include?(name)
unless @objects[name] == obj
raise Puppet::Error.new(
- "Cannot create alias %s: object already exists" %
- [name]
+ "Cannot create alias %s: object already exists" % [name]
)
end
end
@@ -845,8 +841,7 @@ class Type
if @aliases.include?(name)
unless @aliases[name] == obj
raise Puppet::Error.new(
- "Object %s already has alias %s" %
- [@aliases[name].name, name]
+ "Object %s already has alias %s" % [@aliases[name].name, name]
)
end
end
@@ -857,13 +852,13 @@ class Type
# remove all of the instances of a single type
def self.clear
raise "Global resource removal is deprecated"
- if defined? @objects
+ if defined?(@objects)
@objects.each do |name, obj|
obj.remove(true)
end
@objects.clear
end
- if defined? @aliases
+ if defined?(@aliases)
@aliases.clear
end
end
@@ -879,7 +874,7 @@ class Type
# remove a specified object
def self.delete(resource)
raise "Global resource removal is deprecated"
- return unless defined? @objects
+ return unless defined?(@objects)
if @objects.include?(resource.title)
@objects.delete(resource.title)
end
@@ -900,7 +895,7 @@ class Type
# iterate across each of the type's instances
def self.each
raise "Global resource iteration is deprecated"
- return unless defined? @objects
+ return unless defined?(@objects)
@objects.each { |name,instance|
yield instance
}
@@ -952,7 +947,7 @@ class Type
def self.hash2resource(hash)
hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
- title = hash.delete(:title)
+ title = hash.delete(:title)
title ||= hash[:name]
title ||= hash[key_attributes.first] if key_attributes.length == 1
@@ -1047,7 +1042,7 @@ class Type
property.name
end
end
-
+
def properties_to_audit(list)
if list == :all
list = all_properties() if list == :all
@@ -1069,8 +1064,8 @@ class Type
newmetaparam(:loglevel) do
desc "Sets the level that information will be logged.
- The log levels have the biggest impact when logs are sent to
- syslog (which is currently the default)."
+ The log levels have the biggest impact when logs are sent to
+ syslog (which is currently the default)."
defaultto :notice
newvalues(*Puppet::Util::Log.levels)
@@ -1401,7 +1396,7 @@ class Type
# Find the default provider.
def self.defaultprovider
- unless defined? @defaultprovider and @defaultprovider
+ unless defined?(@defaultprovider) and @defaultprovider
suitable = suitableprovider()
# Find which providers are a default for this system.
@@ -1415,16 +1410,13 @@ class Type
retval = nil
if defaults.length > 1
Puppet.warning(
- "Found multiple default providers for %s: %s; using %s" %
- [self.name, defaults.collect { |i| i.name.to_s }.join(", "),
- defaults[0].name]
+ "Found multiple default providers for %s: %s; using %s" % [self.name, defaults.collect { |i| i.name.to_s }.join(", "), defaults[0].name]
)
retval = defaults.shift
elsif defaults.length == 1
retval = defaults.shift
else
- raise Puppet::DevError, "Could not find a default provider for %s" %
- self.name
+ raise Puppet::DevError, "Could not find a default provider for %s" % self.name
end
@defaultprovider = retval
@@ -1483,8 +1475,7 @@ class Type
provider
else
raise Puppet::DevError,
- "Could not find parent provider %s of %s" %
- [pname, name]
+ "Could not find parent provider %s of %s" % [pname, name]
end
end
else
@@ -1495,13 +1486,16 @@ class Type
self.providify
- provider = genclass(name,
+
+ provider = genclass(
+ name,
:parent => parent,
:hash => provider_hash,
:prefix => "Provider",
:block => block,
:include => feature_module,
:extend => feature_module,
+
:attributes => options
)
@@ -1566,8 +1560,11 @@ class Type
def self.unprovide(name)
if provider_hash.has_key? name
- rmclass(name,
+
+ rmclass(
+ name,
:hash => provider_hash,
+
:prefix => "Provider"
)
if @defaultprovider and @defaultprovider.name == name
@@ -1595,8 +1592,7 @@ class Type
elsif klass = self.class.provider(name)
@provider = klass.new(self)
else
- raise ArgumentError, "Could not find %s provider of %s" %
- [name, self.class.name]
+ raise ArgumentError, "Could not find %s provider of %s" % [name, self.class.name]
end
end
@@ -1706,7 +1702,7 @@ class Type
@defaults = {}
- unless defined? @parameters
+ unless defined?(@parameters)
@parameters = []
end
@@ -1718,24 +1714,24 @@ class Type
@attr_aliases = {}
@paramdoc = Hash.new { |hash,key|
- if key.is_a?(String)
- key = key.intern
- end
- if hash.include?(key)
- hash[key]
- else
- "Param Documentation for %s not found" % key
- end
+ if key.is_a?(String)
+ key = key.intern
+ end
+ if hash.include?(key)
+ hash[key]
+ else
+ "Param Documentation for %s not found" % key
+ end
}
- unless defined? @doc
+ unless defined?(@doc)
@doc = ""
end
end
def self.to_s
- if defined? @name
+ if defined?(@name)
"Puppet::Type::" + @name.to_s.capitalize
else
super
@@ -1760,9 +1756,12 @@ class Type
# create a log at specified level
def log(msg)
+
Puppet::Util::Log.create(
+
:level => @parameters[:loglevel].value,
:message => msg,
+
:source => self
)
end
@@ -1899,7 +1898,7 @@ class Type
# Is this resource being purged? Used by transactions to forbid
# deletion when there are dependencies.
def purging?
- if defined? @purging
+ if defined?(@purging)
@purging
else
false
@@ -1909,14 +1908,13 @@ class Type
# Retrieve the title of an object. If no title was set separately,
# then use the object's name.
def title
- unless defined? @title and @title
+ unless defined?(@title) and @title
if self.class.validparameter?(name_var)
@title = self[:name]
elsif self.class.validproperty?(name_var)
@title = self.should(name_var)
else
- self.devfail "Could not find namevar %s for %s" %
- [name_var, self.class.name]
+ self.devfail "Could not find namevar %s for %s" % [name_var, self.class.name]
end
end
diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb
index 3deed136d..d29bf30cb 100644
--- a/lib/puppet/type/augeas.rb
+++ b/lib/puppet/type/augeas.rb
@@ -27,19 +27,19 @@ Puppet::Type.newtype(:augeas) do
@doc = "Apply the changes (single or array of changes) to the filesystem
via the augeas tool.
- Requires:
- - augeas to be installed (http://www.augeas.net)
- - ruby-augeas bindings
+ Requires:
+ - augeas to be installed (http://www.augeas.net)
+ - ruby-augeas bindings
- Sample usage with a string::
+ Sample usage with a string::
augeas{\"test1\" :
- context => \"/files/etc/sysconfig/firstboot\",
- changes => \"set RUN_FIRSTBOOT YES\",
- onlyif => \"match other_value size > 0\",
- }
+ context => \"/files/etc/sysconfig/firstboot\",
+ changes => \"set RUN_FIRSTBOOT YES\",
+ onlyif => \"match other_value size > 0\",
+ }
- Sample usage with an array and custom lenses::
+ Sample usage with an array and custom lenses::
augeas{\"jboss_conf\":
context => \"/files\",
@@ -50,7 +50,7 @@ Puppet::Type.newtype(:augeas) do
load_path => \"$/usr/share/jbossas/lenses\",
}
- "
+ "
newparam (:name) do
desc "The name of this task. Used for uniqueness"
@@ -71,23 +71,23 @@ Puppet::Type.newtype(:augeas) do
newparam (:onlyif) do
desc "Optional augeas command and comparisons to control the execution of this type.
- Supported onlyif syntax::
-
- get [AUGEAS_PATH] [COMPARATOR] [STRING]
- match [MATCH_PATH] size [COMPARATOR] [INT]
- match [MATCH_PATH] include [STRING]
- match [MATCH_PATH] not_include [STRING]
- match [MATCH_PATH] == [AN_ARRAY]
- match [MATCH_PATH] != [AN_ARRAY]
-
- where::
-
- AUGEAS_PATH is a valid path scoped by the context
- MATCH_PATH is a valid match synatx scoped by the context
- COMPARATOR is in the set [> >= != == <= <]
- STRING is a string
- INT is a number
- AN_ARRAY is in the form ['a string', 'another']"
+ Supported onlyif syntax::
+
+ get [AUGEAS_PATH] [COMPARATOR] [STRING]
+ match [MATCH_PATH] size [COMPARATOR] [INT]
+ match [MATCH_PATH] include [STRING]
+ match [MATCH_PATH] not_include [STRING]
+ match [MATCH_PATH] == [AN_ARRAY]
+ match [MATCH_PATH] != [AN_ARRAY]
+
+ where::
+
+ AUGEAS_PATH is a valid path scoped by the context
+ MATCH_PATH is a valid match synatx scoped by the context
+ COMPARATOR is in the set [> >= != == <= <]
+ STRING is a string
+ INT is a number
+ AN_ARRAY is in the form ['a string', 'another']"
defaultto ""
end
@@ -97,14 +97,14 @@ Puppet::Type.newtype(:augeas) do
can be either a string which contains a command or an array of commands.
Commands supported are::
- set [PATH] [VALUE] Sets the value VALUE at loction PATH
- rm [PATH] Removes the node at location PATH
- remove [PATH] Synonym for rm
- clear [PATH] Keeps the node at PATH, but removes the value.
- ins [LABEL] [WHERE] [PATH]
- Inserts an empty node LABEL either [WHERE={before|after}] PATH.
- insert [LABEL] [WHERE] [PATH]
- Synonym for ins
+ set [PATH] [VALUE] Sets the value VALUE at loction PATH
+ rm [PATH] Removes the node at location PATH
+ remove [PATH] Synonym for rm
+ clear [PATH] Keeps the node at PATH, but removes the value.
+ ins [LABEL] [WHERE] [PATH]
+ Inserts an empty node LABEL either [WHERE={before|after}] PATH.
+ insert [LABEL] [WHERE] [PATH]
+ Synonym for ins
If the parameter 'context' is set that value is prepended to PATH"
end
diff --git a/lib/puppet/type/computer.rb b/lib/puppet/type/computer.rb
index ba394f57b..b27d8a481 100644
--- a/lib/puppet/type/computer.rb
+++ b/lib/puppet/type/computer.rb
@@ -1,20 +1,20 @@
Puppet::Type.newtype(:computer) do
@doc = "Computer object management using DirectoryService
- on OS X.
+ on OS X.
- Note that these are distinctly different kinds of objects to 'hosts',
- as they require a MAC address and can have all sorts of policy attached to
- them.
+ Note that these are distinctly different kinds of objects to 'hosts',
+ as they require a MAC address and can have all sorts of policy attached to
+ them.
- This provider only manages Computer objects in the local directory service
- domain, not in remote directories.
+ This provider only manages Computer objects in the local directory service
+ domain, not in remote directories.
- If you wish to manage /etc/hosts on Mac OS X, then simply use the host
- type as per other platforms.
+ If you wish to manage /etc/hosts on Mac OS X, then simply use the host
+ type as per other platforms.
- This type primarily exists to create localhost Computer objects that MCX
- policy can then be attached to."
+ This type primarily exists to create localhost Computer objects that MCX
+ policy can then be attached to."
# ensurable
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index 1cdd56184..4151610f1 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -54,7 +54,7 @@ Puppet::Type.newtype(:cron) do
# We have to override the parent method, because we consume the entire
# "should" array
def insync?(is)
- if defined? @should and @should
+ if defined?(@should) and @should
self.is_to_s(is) == self.should_to_s
else
true
@@ -197,8 +197,7 @@ Puppet::Type.newtype(:cron) do
if retval
return retval.to_s
else
- self.fail "%s is not a valid %s" %
- [value, self.class.name]
+ self.fail "%s is not a valid %s" % [value, self.class.name]
end
end
end
@@ -221,12 +220,12 @@ Puppet::Type.newtype(:cron) do
remove any existing values for that field."
def retrieve
- return_value = super
- if return_value && return_value.is_a?(Array)
- return_value = return_value[0]
- end
+ return_value = super
+ if return_value && return_value.is_a?(Array)
+ return_value = return_value[0]
+ end
- return return_value
+ return return_value
end
def should
@@ -251,8 +250,7 @@ Puppet::Type.newtype(:cron) do
validate do |value|
unless specials().include?(value)
- raise ArgumentError, "Invalid special schedule %s" %
- value.inspect
+ raise ArgumentError, "Invalid special schedule %s" % value.inspect
end
end
end
@@ -313,8 +311,7 @@ Puppet::Type.newtype(:cron) do
validate do |value|
unless value =~ /^\s*(\w+)\s*=\s*(.*)\s*$/ or value == :absent or value == "absent"
- raise ArgumentError, "Invalid environment setting %s" %
- value.inspect
+ raise ArgumentError, "Invalid environment setting %s" % value.inspect
end
end
@@ -356,8 +353,7 @@ Puppet::Type.newtype(:cron) do
is used for human reference only and is generated automatically
for cron jobs found on the system. This generally won't
matter, as Puppet will do its best to match existing cron jobs
- against specified jobs (and Puppet adds a comment to cron jobs it
- adds), but it is at least possible that converting from
+ against specified jobs (and Puppet adds a comment to cron jobs it adds), but it is at least possible that converting from
unmanaged jobs to managed jobs might require manual
intervention."
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 065f1b65d..cd9c02034 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -44,8 +44,7 @@ module Puppet
It is recommended to avoid duplicate names whenever possible.
Note that if an ``exec`` receives an event from another resource,
- it will get executed again (or execute the command specified in
- ``refresh``, if there is one).
+ it will get executed again (or execute the command specified in ``refresh``, if there is one).
There is a strong tendency to use ``exec`` to do whatever work Puppet
can't already do; while this is obviously acceptable (and unavoidable)
@@ -121,8 +120,8 @@ module Puppet
@output, @status = @resource.run(self.resource[:command])
break if self.should.include?(@status.exitstatus.to_s)
if try_sleep > 0 and tries > 1
- debug("Sleeping for #{try_sleep} seconds between tries")
- sleep try_sleep
+ debug("Sleeping for #{try_sleep} seconds between tries")
+ sleep try_sleep
end
end
rescue Timeout::Error
@@ -148,8 +147,7 @@ module Puppet
end
unless self.should.include?(@status.exitstatus.to_s)
- self.fail("%s returned %s instead of one of [%s]" %
- [self.resource[:command], @status.exitstatus, self.should.join(",")])
+ self.fail("%s returned %s instead of one of [%s]" % [self.resource[:command], @status.exitstatus, self.should.join(",")])
end
return event
@@ -584,7 +582,7 @@ module Puppet
end
end
end
-
+
unless FileTest.exists?(exe)
raise ArgumentError, "Could not find executable '%s'" % exe
end
@@ -656,8 +654,7 @@ module Puppet
value = $2
if environment.include? name
warning(
- "Overriding environment setting '%s' with '%s'" %
- [name, value]
+ "Overriding environment setting '%s' with '%s'" % [name, value]
)
end
environment[name] = value
@@ -693,7 +690,7 @@ module Puppet
self.fail "'%s' is both unqualifed and specified no search path" % cmd
end
end
-
+
def extractexe(cmd)
# easy case: command was quoted
if cmd =~ /^"([^"]+)"/
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 1995c40fa..08bc78327 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -208,8 +208,7 @@ Puppet::Type.newtype(:file) do
``follow`` will copy the target file instead of the link, ``manage``
will copy the link itself, and ``ignore`` will just pass it by.
When not copying, ``manage`` and ``ignore`` behave equivalently
- (because you cannot really ignore links entirely during local
- recursion), and ``follow`` will manage the file to which the
+ (because you cannot really ignore links entirely during local recursion), and ``follow`` will manage the file to which the
link points."
newvalues(:follow, :manage)
@@ -511,9 +510,9 @@ Puppet::Type.newtype(:file) do
def remove_less_specific_files(files)
mypath = self[:path].split(File::Separator)
other_paths = catalog.vertices.
- select { |r| r.is_a?(self.class) and r[:path] != self[:path] }.
- collect { |r| r[:path].split(File::Separator) }.
- select { |p| p[0,mypath.length] == mypath }
+ select { |r| r.is_a?(self.class) and r[:path] != self[:path] }.
+ collect { |r| r[:path].split(File::Separator) }.
+ select { |p| p[0,mypath.length] == mypath }
return files if other_paths.empty?
@@ -605,10 +604,13 @@ Puppet::Type.newtype(:file) do
end
def perform_recursion(path)
+
Puppet::FileServing::Metadata.search(
+
path,
:links => self[:links],
:recurse => (self[:recurse] == :remote ? true : self[:recurse]),
+
:recurselimit => self[:recurselimit],
:ignore => self[:ignore],
:checksum_type => (self[:source] || self[:content]) ? self[:checksum] : :none
@@ -635,8 +637,7 @@ Puppet::Type.newtype(:file) do
notice "Not removing directory; use 'force' to override"
end
when "link", "file"
- debug "Removing existing %s for replacement with %s" %
- [s.ftype, should]
+ debug "Removing existing %s for replacement with %s" % [s.ftype, should]
File.unlink(self[:path])
else
self.fail "Could not back up files of type %s" % s.ftype
@@ -765,7 +766,7 @@ Puppet::Type.newtype(:file) do
# Should we validate the checksum of the file we're writing?
def validate_checksum?
- self[:checksum] !~ /time/
+ self[:checksum] !~ /time/
end
# Make sure the file we wrote out is what we think it is.
@@ -787,7 +788,7 @@ Puppet::Type.newtype(:file) do
def write_temporary_file?
# unfortunately we don't know the source file size before fetching it
- # so let's assume the file won't be empty
+ # so let's assume the file won't be empty
(c = property(:content) and c.length) || (s = @parameters[:source] and 1)
end
diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb
index d7bb022a3..8d832a6d1 100755
--- a/lib/puppet/type/file/content.rb
+++ b/lib/puppet/type/file/content.rb
@@ -16,8 +16,7 @@ module Puppet
attr_reader :actual_content
desc "Specify the contents of a file as a string. Newlines, tabs, and
- spaces can be specified using the escaped syntax (e.g., \\n for a
- newline). The primary purpose of this parameter is to provide a
+ spaces can be specified using the escaped syntax (e.g., \\n for a newline). The primary purpose of this parameter is to provide a
kind of limited templating::
define resolve(nameserver1, nameserver2, domain, search) {
diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb
index 83f3d3e6a..1a7fe5e4f 100755
--- a/lib/puppet/type/file/ensure.rb
+++ b/lib/puppet/type/file/ensure.rb
@@ -62,8 +62,7 @@ module Puppet
parent = File.dirname(@resource[:path])
unless FileTest.exists? parent
raise Puppet::Error,
- "Cannot create %s; parent directory %s does not exist" %
- [@resource[:path], parent]
+ "Cannot create %s; parent directory %s does not exist" % [@resource[:path], parent]
end
if mode
Puppet::Util.withumask(000) do
@@ -93,7 +92,7 @@ module Puppet
value = super(value)
value,resource[:target] = :link,value unless value.is_a? Symbol
resource[:links] = :manage if value == :link and resource[:links] != :follow
- value
+ value
end
def change_to_s(currentvalue, newvalue)
@@ -123,12 +122,10 @@ module Puppet
if ! FileTest.exists?(basedir)
raise Puppet::Error,
- "Can not create %s; parent directory does not exist" %
- @resource.title
+ "Can not create %s; parent directory does not exist" % @resource.title
elsif ! FileTest.directory?(basedir)
raise Puppet::Error,
- "Can not create %s; %s is not a directory" %
- [@resource.title, dirname]
+ "Can not create %s; %s is not a directory" % [@resource.title, dirname]
end
end
diff --git a/lib/puppet/type/file/mode.rb b/lib/puppet/type/file/mode.rb
index 83034cbd9..71cd1b4ae 100755
--- a/lib/puppet/type/file/mode.rb
+++ b/lib/puppet/type/file/mode.rb
@@ -6,21 +6,21 @@ module Puppet
require 'etc'
desc "Mode the file should be. Currently relatively limited:
you must specify the exact mode the file should be.
-
+
Note that when you set the mode of a directory, Puppet always
- sets the search/traverse (1) bit anywhere the read (4) bit is set.
+ sets the search/traverse (1) bit anywhere the read (4) bit is set.
This is almost always what you want: read allows you to list the
- entries in a directory, and search/traverse allows you to access
- (read/write/execute) those entries.) Because of this feature, you
- can recursively make a directory and all of the files in it
+ entries in a directory, and search/traverse allows you to access
+ (read/write/execute) those entries.) Because of this feature, you
+ can recursively make a directory and all of the files in it
world-readable by setting e.g.::
file { '/some/dir':
- mode => 644,
- recurse => true,
+ mode => 644,
+ recurse => true,
}
- In this case all of the files underneath ``/some/dir`` will have
+ In this case all of the files underneath ``/some/dir`` will have
mode 644, and all of the directories will have mode 755."
@event = :file_changed
@@ -34,8 +34,7 @@ module Puppet
when Symbol
return currentvalue
else
- raise Puppet::DevError, "Invalid current value for mode: %s" %
- currentvalue.inspect
+ raise Puppet::DevError, "Invalid current value for mode: %s" % currentvalue.inspect
end
end
@@ -46,8 +45,7 @@ module Puppet
when Symbol
return newvalue
else
- raise Puppet::DevError, "Invalid 'should' value for mode: %s" %
- newvalue.inspect
+ raise Puppet::DevError, "Invalid 'should' value for mode: %s" % newvalue.inspect
end
end
@@ -57,8 +55,7 @@ module Puppet
value = should
if value.is_a?(String)
unless value =~ /^\d+$/
- raise Puppet::Error, "File modes can only be numbers, not %s" %
- value.inspect
+ raise Puppet::Error, "File modes can only be numbers, not %s" % value.inspect
end
# Make sure our number looks like octal.
unless value =~ /^0/
@@ -68,8 +65,7 @@ module Puppet
begin
value = Integer(value)
rescue ArgumentError => detail
- raise Puppet::DevError, "Could not convert %s to integer" %
- old.inspect
+ raise Puppet::DevError, "Could not convert %s to integer" % old.inspect
end
end
@@ -108,8 +104,8 @@ module Puppet
# off mode management entirely.
if stat = @resource.stat(false)
- unless defined? @fixed
- if defined? @should and @should
+ unless defined?(@fixed)
+ if defined?(@should) and @should
@should = @should.collect { |s| self.dirmask(s) }
end
end
@@ -125,8 +121,7 @@ module Puppet
begin
File.chmod(mode, @resource[:path])
rescue => detail
- error = Puppet::Error.new("failed to chmod %s: %s" %
- [@resource[:path], detail.message])
+ error = Puppet::Error.new("failed to chmod %s: %s" % [@resource[:path], detail.message])
error.set_backtrace detail.backtrace
raise error
end
diff --git a/lib/puppet/type/file/owner.rb b/lib/puppet/type/file/owner.rb
index 519bb1221..a610a85e3 100755
--- a/lib/puppet/type/file/owner.rb
+++ b/lib/puppet/type/file/owner.rb
@@ -1,6 +1,6 @@
module Puppet
Puppet::Type.type(:file).newproperty(:owner) do
-
+
desc "To whom the file should belong. Argument can be user name or
user ID."
@event = :file_changed
@@ -23,8 +23,7 @@ module Puppet
when String
newvalue
else
- raise Puppet::DevError, "Invalid uid type %s(%s)" %
- [newvalue.class, newvalue]
+ raise Puppet::DevError, "Invalid uid type %s(%s)" % [newvalue.class, newvalue]
end
end
diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb
index 717f58805..dc94cb9da 100644
--- a/lib/puppet/type/file/selcontext.rb
+++ b/lib/puppet/type/file/selcontext.rb
@@ -46,8 +46,8 @@ module Puppet
def insync?(value)
if not selinux_support?
- debug("SELinux bindings not found. Ignoring parameter.")
- return true
+ debug("SELinux bindings not found. Ignoring parameter.")
+ return true
end
super
end
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index 77fb4f38c..fd32f13d6 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -114,7 +114,7 @@ module Puppet
end
end
- if resource[:ensure] == :absent
+ if resource[:ensure] == :absent
# We know all we need to
elsif metadata.ftype != "link"
resource[:ensure] = metadata.ftype
diff --git a/lib/puppet/type/filebucket.rb b/lib/puppet/type/filebucket.rb
index 4754e9f3a..73cd56cd7 100755
--- a/lib/puppet/type/filebucket.rb
+++ b/lib/puppet/type/filebucket.rb
@@ -11,8 +11,7 @@ module Puppet
it can be specified as the value of *backup* in a **file** object.
Currently, filebuckets are only useful for manual retrieval of
- accidentally removed files (e.g., you look in the log for the md5
- sum and retrieve the file with that sum from the filebucket), but
+ accidentally removed files (e.g., you look in the log for the md5 sum and retrieve the file with that sum from the filebucket), but
when transactions are fully supported filebuckets will be used to
undo transactions.
@@ -35,9 +34,9 @@ module Puppet
newparam(:server) do
desc "The server providing the remote filebucket. If this is not
- specified then *path* is checked. If it is set, then the
- bucket is local. Otherwise the puppetmaster server specified
- in the config or at the commandline is used."
+ specified then *path* is checked. If it is set, then the
+ bucket is local. Otherwise the puppetmaster server specified
+ in the config or at the commandline is used."
defaultto { Puppet[:server] }
end
@@ -62,7 +61,7 @@ module Puppet
end
def bucket
- mkbucket() unless defined? @bucket
+ mkbucket() unless defined?(@bucket)
return @bucket
end
diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb
index d184fdd68..5bfcd239c 100755
--- a/lib/puppet/type/host.rb
+++ b/lib/puppet/type/host.rb
@@ -6,9 +6,9 @@ module Puppet
desc "The host's IP address, IPv4 or IPv6."
validate do |value|
- unless value =~ /((([0-9a-fA-F]+:){7}[0-9a-fA-F]+)|(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?::(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?)|((25[0-5]|2[0-4][\d]|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3})/
- raise Puppet::Error, "Invalid IP address"
- end
+ unless value =~ /((([0-9a-fA-F]+:){7}[0-9a-fA-F]+)|(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?::(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?)|((25[0-5]|2[0-4][\d]|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3})/
+ raise Puppet::Error, "Invalid IP address"
+ end
end
end
@@ -46,7 +46,7 @@ module Puppet
# We actually want to return the whole array here, not just the first
# value.
def should
- if defined? @should
+ if defined?(@should)
if @should == [:absent]
return :absent
else
@@ -71,7 +71,7 @@ module Puppet
those providers that write to disk."
defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
- @resource.class.defaultprovider.default_target
+ @resource.class.defaultprovider.default_target
else
nil
end
@@ -84,12 +84,12 @@ module Puppet
isnamevar
validate do |value|
- # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
- x = value.split('.').each do |hostpart|
- unless hostpart =~ /^([\d\w]+|[\d\w][\d\w\-]+[\d\w])$/
- raise Puppet::Error, "Invalid host name"
- end
- end
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
+ x = value.split('.').each do |hostpart|
+ unless hostpart =~ /^([\d\w]+|[\d\w][\d\w\-]+[\d\w])$/
+ raise Puppet::Error, "Invalid host name"
+ end
+ end
end
end
diff --git a/lib/puppet/type/macauthorization.rb b/lib/puppet/type/macauthorization.rb
index 7fdc5bfa3..ff87d3a57 100644
--- a/lib/puppet/type/macauthorization.rb
+++ b/lib/puppet/type/macauthorization.rb
@@ -1,8 +1,8 @@
Puppet::Type.newtype(:macauthorization) do
@doc = "Manage the Mac OS X authorization database.
- See:
- http://developer.apple.com/documentation/Security/Conceptual/Security_Overview/Security_Services/chapter_4_section_5.html for more information."
+ See:
+ http://developer.apple.com/documentation/Security/Conceptual/Security_Overview/Security_Services/chapter_4_section_5.html for more information."
ensurable
@@ -20,12 +20,12 @@ Puppet::Type.newtype(:macauthorization) do
fail("munge_boolean only takes booleans")
end
end
-
+
def munge_integer(value)
begin
- Integer(value)
+ Integer(value)
rescue ArgumentError
- fail("munge_integer only takes integers")
+ fail("munge_integer only takes integers")
end
end
@@ -102,7 +102,7 @@ Puppet::Type.newtype(:macauthorization) do
then 'k' (the integer value of this parameter) mechanisms must succeed.
The most common setting for this parameter is '1'. If k-of-n is not
set, then 'n-of-n' mechanisms must succeed."
-
+
munge do |value|
@resource.munge_integer(value)
end
@@ -150,7 +150,7 @@ Puppet::Type.newtype(:macauthorization) do
authenticate every time, set the timeout to 0. For minimum security,
remove the timeout attribute so the user authenticates only once per
session."
-
+
munge do |value|
@resource.munge_integer(value)
end
diff --git a/lib/puppet/type/maillist.rb b/lib/puppet/type/maillist.rb
index fb53bfd0b..af5ed51e4 100755
--- a/lib/puppet/type/maillist.rb
+++ b/lib/puppet/type/maillist.rb
@@ -11,8 +11,8 @@ module Puppet
end
def change_to_s(current_value, newvalue)
- return "Purged #{resource}" if newvalue == :purged
- super
+ return "Purged #{resource}" if newvalue == :purged
+ super
end
def insync?(is)
diff --git a/lib/puppet/type/mcx.rb b/lib/puppet/type/mcx.rb
index e7a83e6a2..6e0266948 100644
--- a/lib/puppet/type/mcx.rb
+++ b/lib/puppet/type/mcx.rb
@@ -53,9 +53,9 @@ to other machines.
desc "The name of the resource being managed.
The default naming convention follows Directory Service paths::
- /Computers/localhost
- /Groups/admin
- /Users/localadmin
+ /Computers/localhost
+ /Groups/admin
+ /Users/localadmin
The ds_type and ds_name type parameters are not necessary if the
default naming convention is followed."
diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb
index 64ba22bb2..342c84377 100755
--- a/lib/puppet/type/mount.rb
+++ b/lib/puppet/type/mount.rb
@@ -16,8 +16,7 @@ module Puppet
newproperty(:ensure) do
desc "Control what to do with this mount. Set this attribute to
``umounted`` to make sure the filesystem is in the filesystem table
- but not mounted (if the filesystem is currently mounted, it will be
- unmounted). Set it to ``absent`` to unmount (if necessary) and remove
+ but not mounted (if the filesystem is currently mounted, it will be unmounted). Set it to ``absent`` to unmount (if necessary) and remove
the filesystem from the fstab. Set to ``mounted`` to add it to the
fstab and mount it. Set to ``present`` to add to fstab but not change
mount/unmount status"
@@ -28,7 +27,7 @@ module Puppet
end
aliasvalue :present, :defined
-
+
newvalue(:unmounted) do
if provider.mounted?
syncothers()
@@ -155,10 +154,10 @@ module Puppet
end
newproperty(:dump) do
- desc "Whether to dump the mount. Not all platform support this.
- Valid values are ``1`` or ``0``. or ``2`` on FreeBSD, Default is ``0``."
-
- if Facter["operatingsystem"].value == "FreeBSD"
+ desc "Whether to dump the mount. Not all platform support this.
+ Valid values are ``1`` or ``0``. or ``2`` on FreeBSD, Default is ``0``."
+
+ if Facter["operatingsystem"].value == "FreeBSD"
newvalue(%r{(0|1|2)})
else
newvalue(%r{(0|1)})
diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb
index 237cefd46..4fee3b496 100644
--- a/lib/puppet/type/package.rb
+++ b/lib/puppet/type/package.rb
@@ -7,8 +7,7 @@ module Puppet
newtype(:package) do
@doc = "Manage packages. There is a basic dichotomy in package
support right now: Some package types (e.g., yum and apt) can
- retrieve their own package files, while others (e.g., rpm and
- sun) cannot. For those package formats that cannot retrieve
+ retrieve their own package files, while others (e.g., rpm and sun) cannot. For those package formats that cannot retrieve
their own files, you can use the ``source`` parameter to point to
the correct file.
@@ -113,7 +112,7 @@ module Puppet
def insync?(is)
@should ||= []
- @latest = nil unless defined? @latest
+ @latest = nil unless defined?(@latest)
@lateststamp ||= (Time.now.to_i - 1000)
# Iterate across all of the should values, and see how they
# turn out.
@@ -148,8 +147,7 @@ module Puppet
# that can't query versions.
return true
else
- self.debug "%s %s is installed, latest is %s" %
- [@resource.name, is.inspect, @latest.inspect]
+ self.debug "%s %s is installed, latest is %s" % [@resource.name, is.inspect, @latest.inspect]
end
when :absent
return true if is == :absent or is == :purged
diff --git a/lib/puppet/type/port.rb b/lib/puppet/type/port.rb
index f186023be..6b9ace239 100755
--- a/lib/puppet/type/port.rb
+++ b/lib/puppet/type/port.rb
@@ -29,7 +29,7 @@
# # We actually want to return the whole array here, not just the first
# # value.
# def should
-# if defined? @should
+# if defined?(@should)
# if @should[0] == :absent
# return :absent
# else
@@ -61,13 +61,13 @@
# desc 'Any aliases the port might have. Multiple values must be
# specified as an array. Note that this property is not the same as
# the "alias" metaparam; use this property to add aliases to a port
-# in the services file, and "alias" to aliases for use in your Puppet
+# in the services file, and "alias" to aliases for use in your Puppet
# scripts.'
#
# # We actually want to return the whole array here, not just the first
# # value.
# def should
-# if defined? @should
+# if defined?(@should)
# if @should[0] == :absent
# return :absent
# else
diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb
index 00808461b..8e0649118 100644
--- a/lib/puppet/type/resources.rb
+++ b/lib/puppet/type/resources.rb
@@ -72,10 +72,10 @@ Puppet::Type.newtype(:resources) do
end
def check(resource)
- unless defined? @checkmethod
+ unless defined?(@checkmethod)
@checkmethod = "%s_check" % self[:name]
end
- unless defined? @hascheck
+ unless defined?(@hascheck)
@hascheck = respond_to?(@checkmethod)
end
if @hascheck
@@ -104,18 +104,18 @@ Puppet::Type.newtype(:resources) do
select { |r| r.class.validproperty?(:ensure) }.
select { |r| able_to_ensure_absent?(r) }.
each { |resource|
- @parameters.each do |name, param|
- resource[name] = param.value if param.metaparam?
- end
-
- # Mark that we're purging, so transactions can handle relationships
- # correctly
- resource.purging
- }
+ @parameters.each do |name, param|
+ resource[name] = param.value if param.metaparam?
+ end
+
+ # Mark that we're purging, so transactions can handle relationships
+ # correctly
+ resource.purging
+ }
end
def resource_type
- unless defined? @resource_type
+ unless defined?(@resource_type)
unless type = Puppet::Type.type(self[:name])
raise Puppet::DevError, "Could not find resource type"
end
diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb
index e51744c69..e52249ac1 100755
--- a/lib/puppet/type/schedule.rb
+++ b/lib/puppet/type/schedule.rb
@@ -153,8 +153,7 @@ module Puppet
unless time.hour == range[0]
self.devfail(
- "Incorrectly converted time: %s: %s vs %s" %
- [time, time.hour, range[0]]
+ "Incorrectly converted time: %s: %s vs %s" % [time, time.hour, range[0]]
)
end
@@ -222,8 +221,7 @@ module Puppet
At the moment, Puppet cannot guarantee that level of
repetition; that is, it can run up to every 10 minutes, but
internal factors might prevent it from actually running that
- often (e.g., long-running Puppet runs will squash conflictingly
- scheduled runs).
+ often (e.g., long-running Puppet runs will squash conflictingly scheduled runs).
See the ``periodmatch`` attribute for tuning whether to match
times by their distance apart or by their specific value."
@@ -293,8 +291,7 @@ module Puppet
if value != 1 and @resource[:periodmatch] != :distance
raise Puppet::Error,
- "Repeat must be 1 unless periodmatch is 'distance', not '%s'" %
- @resource[:periodmatch]
+ "Repeat must be 1 unless periodmatch is 'distance', not '%s'" % @resource[:periodmatch]
end
end
@@ -318,16 +315,22 @@ module Puppet
def self.mkdefaultschedules
result = []
Puppet.debug "Creating default schedules"
- result << self.new(
+
+ result << self.new(
+
:name => "puppet",
:period => :hourly,
+
:repeat => "2"
)
# And then one for every period
@parameters.find { |p| p.name == :period }.value_collection.values.each { |value|
- result << self.new(
+
+ result << self.new(
+
:name => value.to_s,
+
:period => value
)
}
diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb
index d02170e4a..dc9193620 100644
--- a/lib/puppet/type/ssh_authorized_key.rb
+++ b/lib/puppet/type/ssh_authorized_key.rb
@@ -40,7 +40,7 @@ module Puppet
defaultto :absent
def should
- if defined? @should and @should[0] != :absent
+ if defined?(@should) and @should[0] != :absent
return super
end
@@ -61,7 +61,7 @@ module Puppet
newproperty(:options, :array_matching => :all) do
desc "Key options, see sshd(8) for possible values. Multiple values
- should be specified as an array."
+ should be specified as an array."
defaultto do :absent end
diff --git a/lib/puppet/type/sshkey.rb b/lib/puppet/type/sshkey.rb
index c1407a6ee..31473e387 100755
--- a/lib/puppet/type/sshkey.rb
+++ b/lib/puppet/type/sshkey.rb
@@ -22,7 +22,7 @@ module Puppet
# FIXME This should automagically check for aliases to the hosts, just
# to see if we can automatically glean any aliases.
newproperty(:host_aliases) do
- desc 'Any aliases the host might have. Multiple values must be
+ desc 'Any aliases the host might have. Multiple values must be
specified as an array. Note that this property is not the same as
the "alias" metaparam; use this property to add aliases to a host
on disk, and "alias" to aliases for use in your Puppet scripts.'
@@ -35,7 +35,7 @@ module Puppet
# We actually want to return the whole array here, not just the first
# value.
def should
- if defined? @should
+ if defined?(@should)
return @should
else
return nil
@@ -63,7 +63,7 @@ module Puppet
the ``parsed`` provider."
defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
- @resource.class.defaultprovider.default_target
+ @resource.class.defaultprovider.default_target
else
nil
end
diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb
index 978ff2012..5eb01194c 100755
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -58,14 +58,14 @@ Puppet::Type.newtype(:tidy) do
This removes files from \/tmp if they are one week old or older,
are not in a subdirectory and match one of the shell globs given.
- Note that the patterns are matched against the basename of each
- file -- that is, your glob patterns should not have any '/'
- characters in them, since you are only specifying against the last
+ Note that the patterns are matched against the basename of each
+ file -- that is, your glob patterns should not have any '/'
+ characters in them, since you are only specifying against the last
bit of the file.
-
- Finally, note that you must now specify a non-zero/non-false value
+
+ Finally, note that you must now specify a non-zero/non-false value
for recurse if matches is used, as matches only apply to files found
- by recursion (there's no reason to use static patterns match against
+ by recursion (there's no reason to use static patterns match against
a statically determined path). Requiering explicit recursion clears
up a common source of confusion."
diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
index 2b082ee94..b3c8619ec 100755
--- a/lib/puppet/type/user.rb
+++ b/lib/puppet/type/user.rb
@@ -150,9 +150,9 @@ module Puppet
def change_to_s(currentvalue, newvalue)
if currentvalue == :absent
- return "created password"
+ return "created password"
else
- return "changed password"
+ return "changed password"
end
end
end
diff --git a/lib/puppet/type/yumrepo.rb b/lib/puppet/type/yumrepo.rb
index 36e95ebf1..b6aceb55c 100644
--- a/lib/puppet/type/yumrepo.rb
+++ b/lib/puppet/type/yumrepo.rb
@@ -52,16 +52,15 @@ module Puppet
newtype(:yumrepo) do
@doc = "The client-side description of a yum repository. Repository
- configurations are found by parsing /etc/yum.conf and
- the files indicated by reposdir in that file (see yum.conf(5)
- for details)
+ configurations are found by parsing /etc/yum.conf and
+ the files indicated by reposdir in that file (see yum.conf(5) for details)
- Most parameters are identical to the ones documented
- in yum.conf(5)
+ Most parameters are identical to the ones documented
+ in yum.conf(5)
- Continuation lines that yum supports for example for the
- baseurl are not supported. No attempt is made to access
- files included with the **include** directive"
+ Continuation lines that yum supports for example for the
+ baseurl are not supported. No attempt is made to access
+ files included with the **include** directive"
class << self
attr_accessor :filetype
@@ -210,14 +209,14 @@ module Puppet
newparam(:name) do
desc "The name of the repository. This corresponds to the
- repositoryid parameter in yum.conf(5)."
+ repositoryid parameter in yum.conf(5)."
isnamevar
end
newproperty(:descr, :parent => Puppet::IniProperty) do
desc "A human readable description of the repository.
- This corresponds to the name parameter in yum.conf(5).
- #{ABSENT_DOC}"
+ This corresponds to the name parameter in yum.conf(5).
+ #{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(/.*/) { }
inikey "name"
@@ -225,7 +224,7 @@ module Puppet
newproperty(:mirrorlist, :parent => Puppet::IniProperty) do
desc "The URL that holds the list of mirrors for this repository.
- #{ABSENT_DOC}"
+ #{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
# Should really check that it's a valid URL
newvalue(/.*/) { }
@@ -240,22 +239,22 @@ module Puppet
newproperty(:enabled, :parent => Puppet::IniProperty) do
desc "Whether this repository is enabled or disabled. Possible
- values are '0', and '1'.\n#{ABSENT_DOC}"
+ values are '0', and '1'.\n#{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(%r{(0|1)}) { }
end
newproperty(:gpgcheck, :parent => Puppet::IniProperty) do
desc "Whether to check the GPG signature on packages installed
- from this repository. Possible values are '0', and '1'.
- \n#{ABSENT_DOC}"
+ from this repository. Possible values are '0', and '1'.
+ \n#{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(%r{(0|1)}) { }
end
newproperty(:gpgkey, :parent => Puppet::IniProperty) do
desc "The URL for the GPG key with which packages from this
- repository are signed.\n#{ABSENT_DOC}"
+ repository are signed.\n#{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
# Should really check that it's a valid URL
newvalue(/.*/) { }
@@ -270,24 +269,24 @@ module Puppet
newproperty(:exclude, :parent => Puppet::IniProperty) do
desc "List of shell globs. Matching packages will never be
- considered in updates or installs for this repo.
- #{ABSENT_DOC}"
+ considered in updates or installs for this repo.
+ #{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(/.*/) { }
end
newproperty(:includepkgs, :parent => Puppet::IniProperty) do
desc "List of shell globs. If this is set, only packages
- matching one of the globs will be considered for
- update or install.\n#{ABSENT_DOC}"
+ matching one of the globs will be considered for
+ update or install.\n#{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(/.*/) { }
end
newproperty(:enablegroups, :parent => Puppet::IniProperty) do
desc "Determines whether yum will allow the use of
- package groups for this repository. Possible
- values are '0', and '1'.\n#{ABSENT_DOC}"
+ package groups for this repository. Possible
+ values are '0', and '1'.\n#{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(%r{(0|1)}) { }
end
@@ -300,37 +299,37 @@ module Puppet
newproperty(:keepalive, :parent => Puppet::IniProperty) do
desc "Either '1' or '0'. This tells yum whether or not HTTP/1.1
- keepalive should be used with this repository.\n#{ABSENT_DOC}"
+ keepalive should be used with this repository.\n#{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(%r{(0|1)}) { }
end
newproperty(:timeout, :parent => Puppet::IniProperty) do
desc "Number of seconds to wait for a connection before timing
- out.\n#{ABSENT_DOC}"
+ out.\n#{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(%r{[0-9]+}) { }
end
newproperty(:metadata_expire, :parent => Puppet::IniProperty) do
desc "Number of seconds after which the metadata will expire.
- #{ABSENT_DOC}"
+ #{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(%r{[0-9]+}) { }
end
newproperty(:protect, :parent => Puppet::IniProperty) do
desc "Enable or disable protection for this repository. Requires
- that the protectbase plugin is installed and enabled.
- #{ABSENT_DOC}"
+ that the protectbase plugin is installed and enabled.
+ #{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(%r{(0|1)}) { }
end
newproperty(:priority, :parent => Puppet::IniProperty) do
desc "Priority of this repository from 1-99. Requires that
- the priorities plugin is installed and enabled.
- #{ABSENT_DOC}"
+ the priorities plugin is installed and enabled.
+ #{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
newvalue(%r{[1-9][0-9]?}) { }
end
diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb
index 70dd3e093..97b8d126f 100644
--- a/lib/puppet/type/zone.rb
+++ b/lib/puppet/type/zone.rb
@@ -172,8 +172,7 @@ Puppet::Type.newtype(:zone) do
end
provider.send(method)
else
- raise Puppet::DevError, "Cannot move %s from %s" %
- [direction, st[:name]]
+ raise Puppet::DevError, "Cannot move %s from %s" % [direction, st[:name]]
end
end
@@ -200,9 +199,9 @@ Puppet::Type.newtype(:zone) do
newparam(:clone) do
desc "Instead of installing the zone, clone it from another zone.
- If the zone root resides on a zfs file system, a snapshot will be
- used to create the clone, is it redisides on ufs, a copy of the zone
- will be used. The zone you clone from must not be running."
+ If the zone root resides on a zfs file system, a snapshot will be
+ used to create the clone, is it redisides on ufs, a copy of the zone
+ will be used. The zone you clone from must not be running."
end
newproperty(:ip, :parent => ZoneMultiConfigProperty) do
@@ -327,13 +326,12 @@ Puppet::Type.newtype(:zone) do
security_policy=NONE
root_password=&lt;%= password %>
timeserver=localhost
- name_service=DNS {domain_name=&lt;%= domain %>
- name_server=&lt;%= nameserver %>}
+ name_service=DNS {domain_name=&lt;%= domain %> name_server=&lt;%= nameserver %>}
network_interface=primary {hostname=&lt;%= realhostname %>
- ip_address=&lt;%= ip %>
- netmask=&lt;%= netmask %>
- protocol_ipv6=no
- default_route=&lt;%= defaultroute %>}
+ ip_address=&lt;%= ip %>
+ netmask=&lt;%= netmask %>
+ protocol_ipv6=no
+ default_route=&lt;%= defaultroute %>}
nfs4_domain=dynamic
And then call that::
@@ -405,9 +403,9 @@ Puppet::Type.newtype(:zone) do
interface, address, defrouter = value.split(':')
if self[:iptype] == :shared
if (interface && address && defrouter.nil?) ||
- (interface && address && defrouter)
- validate_ip(address, "IP address")
- validate_ip(defrouter, "default router")
+ (interface && address && defrouter)
+ validate_ip(address, "IP address")
+ validate_ip(defrouter, "default router")
else
self.fail "ip must contain interface name and ip address separated by a \":\""
end
diff --git a/lib/puppet/type/zpool.rb b/lib/puppet/type/zpool.rb
index 11618256f..85f394fa0 100755
--- a/lib/puppet/type/zpool.rb
+++ b/lib/puppet/type/zpool.rb
@@ -35,7 +35,7 @@ module Puppet
newtype(:zpool) do
@doc = "Manage zpools. Create and delete zpools. The provider WILL NOT SYNC, only report differences.
- Supports vdevs with mirrors, raidz, logs and spares."
+ Supports vdevs with mirrors, raidz, logs and spares."
ensurable
@@ -45,7 +45,7 @@ module Puppet
newproperty(:mirror, :array_matching => :all, :parent => Puppet::Property::MultiVDev) do
desc "List of all the devices to mirror for this pool. Each mirror should be a space separated string.
- mirror => [\"disk1 disk2\", \"disk3 disk4\"]"
+ mirror => [\"disk1 disk2\", \"disk3 disk4\"]"
validate do |value|
if value.include?(",")
@@ -56,7 +56,7 @@ module Puppet
newproperty(:raidz, :array_matching => :all, :parent => Puppet::Property::MultiVDev) do
desc "List of all the devices to raid for this pool. Should be an array of space separated strings.
- raidz => [\"disk1 disk2\", \"disk3 disk4\"]"
+ raidz => [\"disk1 disk2\", \"disk3 disk4\"]"
validate do |value|
if value.include?(",")
@@ -76,7 +76,7 @@ module Puppet
newparam(:pool) do
desc "The name for this pool."
isnamevar
- end
+ end
newparam(:raid_parity) do
desc "Determines parity when using raidz property."
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index f9786fbe0..386100270 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -38,8 +38,7 @@ module Util
Puppet::Util::SUIDManager.egid = group
Puppet::Util::SUIDManager.gid = group
rescue => detail
- Puppet.warning "could not change to group %s: %s" %
- [group.inspect, detail]
+ Puppet.warning "could not change to group %s: %s" % [group.inspect, detail]
$stderr.puts "could not change to group %s" % group.inspect
# Don't exit on failed group changes, since it's
@@ -77,14 +76,20 @@ module Util
args = args.join(" ")
end
if useself
+
Puppet::Util::Log.create(
+
:level => level,
:source => self,
+
:message => args
)
else
+
Puppet::Util::Log.create(
+
:level => level,
+
:message => args
)
end
@@ -130,8 +135,7 @@ module Util
elsif FileTest.directory?(File.join(path))
next
else FileTest.exist?(File.join(path))
- raise "Cannot create %s: basedir %s is a file" %
- [dir, File.join(path)]
+ raise "Cannot create %s: basedir %s is a file" % [dir, File.join(path)]
end
}
return true
@@ -189,10 +193,10 @@ module Util
if bin =~ /^\//
return bin if FileTest.file? bin and FileTest.executable? bin
else
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir|
- dest=File.join(dir, bin)
- return dest if FileTest.file? dest and FileTest.executable? dest
- end
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir|
+ dest=File.join(dir, bin)
+ return dest if FileTest.file? dest and FileTest.executable? dest
+ end
end
return nil
end
@@ -318,8 +322,7 @@ module Util
elsif Puppet.features.microsoft_windows?
command = command.collect {|part| '"' + part.gsub(/"/, '\\"') + '"'}.join(" ") if command.is_a?(Array)
Puppet.debug "Creating process '%s'" % command
- processinfo = Process.create(
- :command_line => command )
+ processinfo = Process.create( :command_line => command )
child_status = (Process.waitpid2(child_pid)[1]).to_i >> 8
end # if posix or win32
@@ -375,7 +378,7 @@ module Util
module_function :benchmark
def memory
- unless defined? @pmap
+ unless defined?(@pmap)
pmap = %x{which pmap 2>/dev/null}.chomp
if $? != 0 or pmap =~ /^no/
@pmap = nil
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb
index a1c44cdd6..27a361396 100644
--- a/lib/puppet/util/autoload.rb
+++ b/lib/puppet/util/autoload.rb
@@ -66,7 +66,7 @@ class Puppet::Util::Autoload
end
end
- unless defined? @wrap
+ unless defined?(@wrap)
@wrap = true
end
end
diff --git a/lib/puppet/util/backups.rb b/lib/puppet/util/backups.rb
index 6cabd248e..4270f528c 100644
--- a/lib/puppet/util/backups.rb
+++ b/lib/puppet/util/backups.rb
@@ -10,10 +10,10 @@ module Puppet::Util::Backups
# let the path be specified
file ||= self[:path]
- return true unless FileTest.exists?(file)
+ return true unless FileTest.exists?(file)
return perform_backup_with_bucket(file) if self.bucket
- return perform_backup_with_backuplocal(file, self[:backup])
+ return perform_backup_with_backuplocal(file, self[:backup])
end
private
@@ -84,5 +84,5 @@ module Puppet::Util::Backups
sum = self.bucket.backup(f)
self.info "Filebucketed %s to %s with sum %s" % [f, self.bucket.name, sum]
return sum
- end
+ end
end
diff --git a/lib/puppet/util/classgen.rb b/lib/puppet/util/classgen.rb
index 1aa961399..83c302c01 100644
--- a/lib/puppet/util/classgen.rb
+++ b/lib/puppet/util/classgen.rb
@@ -52,7 +52,7 @@ module Puppet::Util::ClassGen
options = symbolize_options(options)
const = genconst_string(name, options)
retval = false
- if const_defined? const
+ if const_defined?(const)
remove_const(const)
retval = true
end
@@ -132,7 +132,7 @@ module Puppet::Util::ClassGen
def handleclassconst(klass, name, options)
const = genconst_string(name, options)
- if const_defined? const
+ if const_defined?(const)
if options[:overwrite]
Puppet.info "Redefining %s in %s" % [name, self]
remove_const(const)
diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb
index 8c8eb91d5..9ccc94a23 100644
--- a/lib/puppet/util/command_line.rb
+++ b/lib/puppet/util/command_line.rb
@@ -1,7 +1,9 @@
module Puppet
module Util
class CommandLine
- LegacyName = Hash.new{|h,k| k}.update({
+
+ LegacyName = Hash.new{|h,k| k}.update(
+ {
'agent' => 'puppetd',
'cert' => 'puppetca',
'doc' => 'puppetdoc',
@@ -12,6 +14,7 @@ module Puppet
'resource' => 'ralsh',
'kick' => 'puppetrun',
'master' => 'puppetmasterd',
+
})
def initialize( zero = $0, argv = ARGV, stdin = STDIN )
diff --git a/lib/puppet/util/diff.rb b/lib/puppet/util/diff.rb
index ac3a1c3c9..0e5deab82 100644
--- a/lib/puppet/util/diff.rb
+++ b/lib/puppet/util/diff.rb
@@ -35,9 +35,12 @@ module Puppet::Util::Diff
diffs.each do |piece|
begin
- hunk = ::Diff::LCS::Hunk.new(data_old, data_new, piece,
- context_lines,
- file_length_difference)
+
+ hunk = ::Diff::LCS::Hunk.new(
+ data_old, data_new, piece,
+ context_lines,
+
+ file_length_difference)
file_length_difference = hunk.file_length_difference
next unless oldhunk
# Hunks may overlap, which is why we need to be careful when our
diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb
index 860a5453c..02374d8b7 100644
--- a/lib/puppet/util/docs.rb
+++ b/lib/puppet/util/docs.rb
@@ -22,7 +22,7 @@ module Puppet::Util::Docs
self.send(m)
}.join(" ")
- if defined? @doc and @doc
+ if defined?(@doc) and @doc
@doc + extra
else
extra
diff --git a/lib/puppet/util/errors.rb b/lib/puppet/util/errors.rb
index 0d2f2da9f..a44c1ca18 100644
--- a/lib/puppet/util/errors.rb
+++ b/lib/puppet/util/errors.rb
@@ -38,8 +38,7 @@ module Puppet::Util::Errors
rescue Puppet::Error => detail
raise adderrorcontext(detail)
rescue => detail
- message = options[:message] || "%s failed with error %s: %s" %
- [self.class, detail.class, detail.to_s]
+ message = options[:message] || "%s failed with error %s: %s" % [self.class, detail.class, detail.to_s]
error = options[:type].new(message)
# We can't use self.fail here because it always expects strings,
diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb
index 06f8a2e7d..7965532fd 100644
--- a/lib/puppet/util/fileparsing.rb
+++ b/lib/puppet/util/fileparsing.rb
@@ -64,7 +64,7 @@ module Puppet::Util::FileParsing
self.separator ||= /\s+/
self.joiner ||= " "
self.optional ||= []
- unless defined? @rollup
+ unless defined?(@rollup)
@rollup = true
end
end
@@ -354,7 +354,7 @@ module Puppet::Util::FileParsing
# Whether to add a trailing separator to the file. Defaults to true
def trailing_separator
- if defined? @trailing_separator
+ if defined?(@trailing_separator)
return @trailing_separator
else
return true
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
index 898753226..c2291a3ab 100755
--- a/lib/puppet/util/filetype.rb
+++ b/lib/puppet/util/filetype.rb
@@ -18,9 +18,12 @@ class Puppet::Util::FileType
def self.newfiletype(name, &block)
@filetypes ||= {}
- klass = genclass(name,
+
+ klass = genclass(
+ name,
:block => block,
:prefix => "FileType",
+
:hash => @filetypes
)
@@ -44,8 +47,7 @@ class Puppet::Util::FileType
if Puppet[:trace]
puts detail.backtrace
end
- raise Puppet::Error, "%s could not read %s: %s" %
- [self.class, @path, detail]
+ raise Puppet::Error, "%s could not read %s: %s" % [self.class, @path, detail]
end
end
@@ -62,8 +64,7 @@ class Puppet::Util::FileType
if Puppet[:debug]
puts detail.backtrace
end
- raise Puppet::Error, "%s could not write %s: %s" %
- [self.class, @path, detail]
+ raise Puppet::Error, "%s could not write %s: %s" % [self.class, @path, detail]
end
end
end
@@ -260,7 +261,7 @@ class Puppet::Util::FileType
begin
output = Puppet::Util.execute(%w{crontab -l}, :uid => @path)
if output.include?("You are not authorized to use the cron command")
- raise Puppet::Error, "User %s not authorized to use cron" % @path
+ raise Puppet::Error, "User %s not authorized to use cron" % @path
end
return output
rescue => detail
diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb
index eb943fe13..0a957d447 100644
--- a/lib/puppet/util/inifile.rb
+++ b/lib/puppet/util/inifile.rb
@@ -113,8 +113,7 @@ module Puppet::Util::IniConfig
text.each_line do |l|
line += 1
if l.strip.empty? || "#;".include?(l[0,1]) ||
- (l.split(nil, 2)[0].downcase == "rem" &&
- l[0,1].downcase == "r")
+ (l.split(nil, 2)[0].downcase == "rem" && l[0,1].downcase == "r")
# Whitespace or comment
if section.nil?
@files[file] << l
diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb
index 19c53a2e6..18d9bf5ab 100644
--- a/lib/puppet/util/ldap/connection.rb
+++ b/lib/puppet/util/ldap/connection.rb
@@ -11,12 +11,12 @@ class Puppet::Util::Ldap::Connection
# Return a default connection, using our default settings.
def self.instance
ssl = if Puppet[:ldaptls]
- :tls
- elsif Puppet[:ldapssl]
- true
- else
- false
- end
+ :tls
+ elsif Puppet[:ldapssl]
+ true
+ else
+ false
+ end
options = {}
options[:ssl] = ssl
diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb
index 237887eb5..57be5f5ba 100644
--- a/lib/puppet/util/log.rb
+++ b/lib/puppet/util/log.rb
@@ -16,9 +16,12 @@ class Puppet::Util::Log
# Create a new destination type.
def self.newdesttype(name, options = {}, &block)
- dest = genclass(name, :parent => Puppet::Util::Log::Destination, :prefix => "Dest",
+
+ dest = genclass(
+ name, :parent => Puppet::Util::Log::Destination, :prefix => "Dest",
:block => block,
:hash => @desttypes,
+
:attributes => options
)
dest.match(dest.name)
@@ -234,7 +237,7 @@ class Puppet::Util::Log
Log.newmessage(self)
end
-
+
def message=(msg)
raise ArgumentError, "Puppet::Util::Log requires a message" unless msg
@message = msg.to_s
diff --git a/lib/puppet/util/log/destination.rb b/lib/puppet/util/log/destination.rb
index 85959072e..81baa9301 100644
--- a/lib/puppet/util/log/destination.rb
+++ b/lib/puppet/util/log/destination.rb
@@ -29,7 +29,7 @@ class Puppet::Util::Log::Destination
end
def name
- if defined? @name
+ if defined?(@name)
return @name
else
return self.class.name
diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb
index e748e5108..9fe61d484 100644
--- a/lib/puppet/util/log/destinations.rb
+++ b/lib/puppet/util/log/destinations.rb
@@ -30,8 +30,7 @@ Puppet::Util::Log.newdesttype :syslog do
if msg.source == "Puppet"
@syslog.send(msg.level, msg.to_s.gsub("%", '%%'))
else
- @syslog.send(msg.level, "(%s) %s" %
- [msg.source.to_s.gsub("%", ""),
+ @syslog.send(msg.level, "(%s) %s" % [msg.source.to_s.gsub("%", ""),
msg.to_s.gsub("%", '%%')
]
)
@@ -43,14 +42,14 @@ Puppet::Util::Log.newdesttype :file do
match(/^\//)
def close
- if defined? @file
+ if defined?(@file)
@file.close
@file = nil
end
end
def flush
- if defined? @file
+ if defined?(@file)
@file.flush
end
end
@@ -74,8 +73,7 @@ Puppet::Util::Log.newdesttype :file do
end
def handle(msg)
- @file.puts("%s %s (%s): %s" %
- [msg.time, msg.source, msg.level, msg.to_s])
+ @file.puts("%s %s (%s): %s" % [msg.time, msg.source, msg.level, msg.to_s])
@file.flush if @autoflush
end
@@ -160,10 +158,10 @@ Puppet::Util::Log.newdesttype :host do
def handle(msg)
unless msg.is_a?(String) or msg.remote
- unless defined? @hostname
+ unless defined?(@hostname)
@hostname = Facter["hostname"].value
end
- unless defined? @domain
+ unless defined?(@domain)
@domain = Facter["domain"].value
if @domain
@hostname += "." + @domain
diff --git a/lib/puppet/util/log_paths.rb b/lib/puppet/util/log_paths.rb
index 46f6c481d..b5bdc50de 100644
--- a/lib/puppet/util/log_paths.rb
+++ b/lib/puppet/util/log_paths.rb
@@ -5,7 +5,7 @@ module Puppet::Util::LogPaths
# return the full path to us, for logging and rollback
# some classes (e.g., FileTypeRecords) will have to override this
def path
- unless defined? @path
+ unless defined?(@path)
@path = pathbuilder
end
diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb
index 8717fe0b9..cf8ed9ee1 100644
--- a/lib/puppet/util/metric.rb
+++ b/lib/puppet/util/metric.rb
@@ -19,7 +19,7 @@ class Puppet::Util::Metric
end
def basedir
- if defined? @basedir
+ if defined?(@basedir)
@basedir
else
Puppet[:rrddir]
diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb
index a25be7d52..e5e835ef0 100644
--- a/lib/puppet/util/monkey_patches.rb
+++ b/lib/puppet/util/monkey_patches.rb
@@ -1,6 +1,6 @@
Process.maxgroups = 1024
-module RDoc
+module RDoc
def self.caller(skip=nil)
in_gem_wrapper = false
Kernel.caller.reject { |call|
diff --git a/lib/puppet/util/provider_features.rb b/lib/puppet/util/provider_features.rb
index 7986f6eae..86f30cc8b 100644
--- a/lib/puppet/util/provider_features.rb
+++ b/lib/puppet/util/provider_features.rb
@@ -107,7 +107,7 @@ module Puppet::Util::ProviderFeatures
# Generate a module that sets up the boolean methods to test for given
# features.
def feature_module
- unless defined? @feature_module
+ unless defined?(@feature_module)
@features ||= {}
@feature_module = ::Module.new
const_set("FeatureModule", @feature_module)
diff --git a/lib/puppet/util/pson.rb b/lib/puppet/util/pson.rb
index 3356437b3..87afbe0c5 100644
--- a/lib/puppet/util/pson.rb
+++ b/lib/puppet/util/pson.rb
@@ -1,4 +1,4 @@
-# A simple module to provide consistency between how we use PSON and how
+# A simple module to provide consistency between how we use PSON and how
# ruby expects it to be used. Basically, we don't want to require
# that the sender specify a class.
# Ruby wants everyone to provide a 'type' field, and the PSON support
diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb
index cb9610c0a..1bc48abd0 100644
--- a/lib/puppet/util/rdoc.rb
+++ b/lib/puppet/util/rdoc.rb
@@ -16,15 +16,18 @@ module Puppet::Util::RDoc
require 'puppet/util/rdoc/parser'
r = RDoc::RDoc.new
- RDoc::RDoc::GENERATORS["puppet"] = RDoc::RDoc::Generator.new("puppet/util/rdoc/generators/puppet_generator.rb",
- "PuppetGenerator".intern,
- "puppet")
+
+ RDoc::RDoc::GENERATORS["puppet"] = RDoc::RDoc::Generator.new(
+ "puppet/util/rdoc/generators/puppet_generator.rb",
+ "PuppetGenerator".intern,
+
+ "puppet")
# specify our own format & where to output
options = [ "--fmt", "puppet",
- "--quiet",
- "--force-update",
- "--exclude", "/modules/[^/]*/files/.*\.pp$",
- "--op", outputdir ]
+ "--quiet",
+ "--force-update",
+ "--exclude", "/modules/[^/]*/files/.*\.pp$",
+ "--op", outputdir ]
options += [ "--charset", charset] if charset
options += files
diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb
index 31181f05a..c2c27c8eb 100644
--- a/lib/puppet/util/rdoc/generators/puppet_generator.rb
+++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb
@@ -215,9 +215,12 @@ module Generators
gen_an_index(@classes, 'All Classes', RDoc::Page::CLASS_INDEX, "fr_class_index.html")
@allfiles.each do |file|
unless file['file'].context.file_relative_name =~ /\.rb$/
- gen_composite_index(file,
- RDoc::Page::COMBO_INDEX,
- "#{MODULE_DIR}/fr_#{file["file"].context.module_name}.html")
+
+ gen_composite_index(
+ file,
+ RDoc::Page::COMBO_INDEX,
+
+ "#{MODULE_DIR}/fr_#{file["file"].context.module_name}.html")
end
end
end
@@ -365,8 +368,8 @@ module Generators
res = []
resources.each do |r|
res << {
- "name" => CGI.escapeHTML(r.name),
- "aref" => CGI.escape(path_prefix)+"\#"+CGI.escape(r.aref)
+ "name" => CGI.escapeHTML(r.name),
+ "aref" => CGI.escape(path_prefix)+"\#"+CGI.escape(r.aref)
}
end
res
@@ -480,9 +483,12 @@ module Generators
def write_on(f)
value_hash
- template = TemplatePage.new(RDoc::Page::BODYINC,
- RDoc::Page::NODE_PAGE,
- RDoc::Page::METHOD_LIST)
+
+ template = TemplatePage.new(
+ RDoc::Page::BODYINC,
+ RDoc::Page::NODE_PAGE,
+
+ RDoc::Page::METHOD_LIST)
template.write_html_on(f, @values)
end
@@ -733,9 +739,12 @@ module Generators
def write_on(f)
value_hash
- template = TemplatePage.new(RDoc::Page::BODYINC,
- RDoc::Page::PLUGIN_PAGE,
- RDoc::Page::PLUGIN_LIST)
+
+ template = TemplatePage.new(
+ RDoc::Page::BODYINC,
+ RDoc::Page::PLUGIN_PAGE,
+
+ RDoc::Page::PLUGIN_LIST)
template.write_html_on(f, @values)
end
diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb
index a1679bcb6..f34e54b8c 100644
--- a/lib/puppet/util/reference.rb
+++ b/lib/puppet/util/reference.rb
@@ -70,7 +70,7 @@ class Puppet::Util::Reference
def self.markdown(name, text)
puts "Creating markdown for #{name} reference."
dir = "/tmp/" + Puppet::PUPPETVERSION
- FileUtils.mkdir(dir) unless File.directory?(dir)
+ FileUtils.mkdir(dir) unless File.directory?(dir)
Puppet::Util.secure_open(dir + "/" + "#{name}.rst", "w") do |f|
f.puts text
end
@@ -89,7 +89,7 @@ class Puppet::Util::Reference
$stderr.puts output
exit(1)
end
-
+
File.unlink(dir + "/" + "#{name}.rst")
end
diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb
index 3801ecdb0..28752cfac 100644
--- a/lib/puppet/util/selinux.rb
+++ b/lib/puppet/util/selinux.rb
@@ -14,7 +14,7 @@ require 'pathname'
module Puppet::Util::SELinux
def selinux_support?
- unless defined? Selinux
+ unless defined?(Selinux)
return false
end
if Selinux.is_selinux_enabled == 1
@@ -89,7 +89,7 @@ module Puppet::Util::SELinux
# I believe that the OS should always provide at least a fall-through context
# though on any well-running system.
def set_selinux_context(file, value, component = false)
- unless selinux_support? && selinux_label_support?(file)
+ unless selinux_support? && selinux_label_support?(file)
return nil
end
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 56a13f847..3a823d30b 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -67,7 +67,7 @@ class Puppet::Util::Settings
unsafe_clear(exceptcli)
end
end
-
+
# Remove all set values, potentially skipping cli values.
def unsafe_clear(exceptcli = false)
@values.each do |name, values|
@@ -227,8 +227,8 @@ class Puppet::Util::Settings
if include?(v)
#if there is only one value, just print it for back compatibility
if v == val
- puts value(val,env)
- break
+ puts value(val,env)
+ break
end
puts "%s = %s" % [v, value(v,env)]
else
@@ -434,7 +434,7 @@ class Puppet::Util::Settings
end
def reuse
- return unless defined? @used
+ return unless defined?(@used)
@sync.synchronize do # yay, thread-safe
new = @used
@used = []
@@ -477,7 +477,7 @@ class Puppet::Util::Settings
end
def legacy_to_mode(type, param)
- if not defined? @app_names then
+ if not defined?(@app_names) then
require 'puppet/util/command_line'
command_line = Puppet::Util::CommandLine.new
@app_names = Puppet::Util::CommandLine::LegacyName.inject({}) do |hash, pair|
@@ -524,7 +524,7 @@ class Puppet::Util::Settings
# Clear the list of environments, because they cache, at least, the module path.
# We *could* preferentially just clear them if the modulepath is changed,
# but we don't really know if, say, the vardir is changed and the modulepath
- # is defined relative to it. We need the defined? stuff because of loading
+ # is defined relative to it. We need the defined?(stuff) because of loading
# order issues.
Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment)
end
@@ -610,9 +610,9 @@ Generated on #{Time.now}.
}.gsub(/^/, "# ")
- # Add a section heading that matches our name.
- if @config.include?(:run_mode)
- str += "[%s]\n" % self[:run_mode]
+# Add a section heading that matches our name.
+if @config.include?(:run_mode)
+ str += "[%s]\n" % self[:run_mode]
end
eachsection do |section|
persection(section) do |obj|
@@ -689,7 +689,7 @@ Generated on #{Time.now}.
end
throw :foundval, nil
end
-
+
# If we didn't get a value, use the default
val = @config[param].default if val.nil?
@@ -769,16 +769,14 @@ Generated on #{Time.now}.
tmpfile = file + ".tmp"
sync = Sync.new
unless FileTest.directory?(File.dirname(tmpfile))
- raise Puppet::DevError, "Cannot create %s; directory %s does not exist" %
- [file, File.dirname(file)]
+ raise Puppet::DevError, "Cannot create %s; directory %s does not exist" % [file, File.dirname(file)]
end
sync.synchronize(Sync::EX) do
File.open(file, ::File::CREAT|::File::RDWR, 0600) do |rf|
rf.lock_exclusive do
if File.exist?(tmpfile)
- raise Puppet::Error, ".tmp file already exists for %s; Aborting locked write. Check the .tmp file and delete if appropriate" %
- [file]
+ raise Puppet::Error, ".tmp file already exists for %s; Aborting locked write. Check the .tmp file and delete if appropriate" % [file]
end
# If there's a failure, remove our tmpfile
diff --git a/lib/puppet/util/settings/boolean_setting.rb b/lib/puppet/util/settings/boolean_setting.rb
index cc2704c4e..aa365fd8e 100644
--- a/lib/puppet/util/settings/boolean_setting.rb
+++ b/lib/puppet/util/settings/boolean_setting.rb
@@ -5,11 +5,9 @@ class Puppet::Util::Settings::BooleanSetting < Puppet::Util::Settings::Setting
# get the arguments in getopt format
def getopt_args
if short
- [["--#{name}", "-#{short}", GetoptLong::NO_ARGUMENT],
- ["--no-#{name}", GetoptLong::NO_ARGUMENT]]
+ [["--#{name}", "-#{short}", GetoptLong::NO_ARGUMENT], ["--no-#{name}", GetoptLong::NO_ARGUMENT]]
else
- [["--#{name}", GetoptLong::NO_ARGUMENT],
- ["--no-#{name}", GetoptLong::NO_ARGUMENT]]
+ [["--#{name}", GetoptLong::NO_ARGUMENT], ["--no-#{name}", GetoptLong::NO_ARGUMENT]]
end
end
@@ -26,8 +24,7 @@ class Puppet::Util::Settings::BooleanSetting < Puppet::Util::Settings::Setting
when true, "true"; return true
when false, "false"; return false
else
- raise ArgumentError, "Invalid value '%s' for %s" %
- [value.inspect, @name]
+ raise ArgumentError, "Invalid value '%s' for %s" % [value.inspect, @name]
end
end
end
diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb
index 6f0f315eb..815bdcf52 100644
--- a/lib/puppet/util/settings/file_setting.rb
+++ b/lib/puppet/util/settings/file_setting.rb
@@ -16,7 +16,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
def group=(value)
unless AllowedGroups.include?(value)
- identifying_fields = [desc,name,default].compact.join(': ')
+ identifying_fields = [desc,name,default].compact.join(': ')
raise SettingError, "Internal error: The :group setting for %s must be 'service', not '%s'" % [identifying_fields,value]
end
@group = value
@@ -29,7 +29,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
def owner=(value)
unless AllowedOwners.include?(value)
- identifying_fields = [desc,name,default].compact.join(': ')
+ identifying_fields = [desc,name,default].compact.join(': ')
raise SettingError, "Internal error: The :owner setting for %s must be either 'root' or 'service', not '%s'" % [identifying_fields,value]
end
@owner = value
@@ -115,8 +115,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
name = $1
unless @settings.include?(name)
raise ArgumentError,
- "Settings parameter '%s' is undefined" %
- name
+ "Settings parameter '%s' is undefined" % name
end
}
end
diff --git a/lib/puppet/util/settings/setting.rb b/lib/puppet/util/settings/setting.rb
index e64cfd6c6..489dfd01d 100644
--- a/lib/puppet/util/settings/setting.rb
+++ b/lib/puppet/util/settings/setting.rb
@@ -54,7 +54,7 @@ class Puppet::Util::Settings::Setting
end
def iscreated?
- if defined? @iscreated
+ if defined?(@iscreated)
return @iscreated
else
return false
@@ -62,7 +62,7 @@ class Puppet::Util::Settings::Setting
end
def set?
- if defined? @value and ! @value.nil?
+ if defined?(@value) and ! @value.nil?
return true
else
return false
@@ -82,7 +82,7 @@ class Puppet::Util::Settings::Setting
str = @desc.gsub(/^/, "# ") + "\n"
# Add in a statement about the default.
- if defined? @default and @default
+ if defined?(@default) and @default
str += "# The default value is '%s'.\n" % @default
end
diff --git a/lib/puppet/util/storage.rb b/lib/puppet/util/storage.rb
index de2f3825e..076952c1d 100644
--- a/lib/puppet/util/storage.rb
+++ b/lib/puppet/util/storage.rb
@@ -47,7 +47,7 @@ class Puppet::Util::Storage
Puppet.settings.use(:main) unless FileTest.directory?(Puppet[:statedir])
unless File.exists?(Puppet[:statefile])
- unless defined? @@state and ! @@state.nil?
+ unless defined?(@@state) and ! @@state.nil?
self.init
end
return
@@ -61,15 +61,12 @@ class Puppet::Util::Storage
begin
@@state = YAML.load(file)
rescue => detail
- Puppet.err "Checksumfile %s is corrupt (%s); replacing" %
- [Puppet[:statefile], detail]
+ Puppet.err "Checksumfile %s is corrupt (%s); replacing" % [Puppet[:statefile], detail]
begin
- File.rename(Puppet[:statefile],
- Puppet[:statefile] + ".bad")
+ File.rename(Puppet[:statefile], Puppet[:statefile] + ".bad")
rescue
raise Puppet::Error,
- "Could not rename corrupt %s; remove manually" %
- Puppet[:statefile]
+ "Could not rename corrupt %s; remove manually" % Puppet[:statefile]
end
end
end
diff --git a/lib/puppet/util/subclass_loader.rb b/lib/puppet/util/subclass_loader.rb
index b71ec7293..80a3672c9 100644
--- a/lib/puppet/util/subclass_loader.rb
+++ b/lib/puppet/util/subclass_loader.rb
@@ -19,7 +19,10 @@ module Puppet::Util::SubclassLoader
raise ArgumentError, "Must be a class to use SubclassLoader"
end
@subclasses = []
- @loader = Puppet::Util::Autoload.new(self,
+
+ @loader = Puppet::Util::Autoload.new(
+ self,
+
path, :wrap => false
)
@@ -63,7 +66,7 @@ module Puppet::Util::SubclassLoader
unless self == self.classloader
super
end
- return nil unless defined? @subclassname
+ return nil unless defined?(@subclassname)
if c = self.send(@subclassname, method)
return c
else
@@ -73,7 +76,7 @@ module Puppet::Util::SubclassLoader
# Retrieve or calculate a name.
def name(dummy_argument=:work_arround_for_ruby_GC_bug)
- unless defined? @name
+ unless defined?(@name)
@name = self.to_s.sub(/.+::/, '').intern
end
diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb
index 777c36411..b8e7d534c 100644
--- a/lib/puppet/util/suidmanager.rb
+++ b/lib/puppet/util/suidmanager.rb
@@ -6,8 +6,7 @@ module Puppet::Util::SUIDManager
extend Forwardable
# Note groups= is handled specially due to a bug in OS X 10.6
- to_delegate_to_process = [ :euid=, :euid, :egid=, :egid,
- :uid=, :uid, :gid=, :gid, :groups ]
+ to_delegate_to_process = [ :euid=, :euid, :egid=, :egid, :uid=, :uid, :gid=, :gid, :groups ]
to_delegate_to_process.each do |method|
def_delegator Process, method
@@ -19,8 +18,8 @@ module Puppet::Util::SUIDManager
require 'facter'
# 'kernel' is available without explicitly loading all facts
if Facter.value('kernel') != 'Darwin'
- @osx_maj_ver = false
- return @osx_maj_ver
+ @osx_maj_ver = false
+ return @osx_maj_ver
end
# But 'macosx_productversion_major' requires it.
Facter.loadfacts
@@ -28,7 +27,7 @@ module Puppet::Util::SUIDManager
return @osx_maj_ver
end
module_function :osx_maj_ver
-
+
def groups=(grouplist)
if osx_maj_ver == '10.6'
return true
@@ -75,7 +74,7 @@ module Puppet::Util::SUIDManager
raise ArgumentError, "Invalid id type %s" % type unless map.include?(type)
ret = Puppet::Util.send(type, id)
if ret == nil
- raise Puppet::Error, "Invalid %s: %s" % [map[type], id]
+ raise Puppet::Error, "Invalid %s: %s" % [map[type], id]
end
return ret
end
diff --git a/lib/puppet/util/zaml.rb b/lib/puppet/util/zaml.rb
index b0e22a3ff..88c660cac 100644
--- a/lib/puppet/util/zaml.rb
+++ b/lib/puppet/util/zaml.rb
@@ -1,14 +1,14 @@
#
# ZAML -- A partial replacement for YAML, writen with speed and code clarity
-# in mind. ZAML fixes one YAML bug (loading Exceptions) and provides
+# in mind. ZAML fixes one YAML bug (loading Exceptions) and provides
# a replacement for YAML.dump() unimaginatively called ZAML.dump(),
-# which is faster on all known cases and an order of magnitude faster
+# which is faster on all known cases and an order of magnitude faster
# with complex structures.
#
# http://github.com/hallettj/zaml
#
# Authors: Markus Roberts, Jesse Hallett, Ian McIntosh, Igal Koshevoy, Simon Chiang
-#
+#
require 'yaml'
@@ -40,19 +40,19 @@ class ZAML
end
class Label
#
- # YAML only wants objects in the datastream once; if the same object
- # occurs more than once, we need to emit a label ("&idxxx") on the
+ # YAML only wants objects in the datastream once; if the same object
+ # occurs more than once, we need to emit a label ("&idxxx") on the
# first occurrence and then emit a back reference (*idxxx") on any
- # subsequent occurrence(s).
+ # subsequent occurrence(s).
#
# To accomplish this we keeps a hash (by object id) of the labels of
# the things we serialize as we begin to serialize them. The labels
# initially serialize as an empty string (since most objects are only
- # going to be be encountered once), but can be changed to a valid
- # (by assigning it a number) the first time it is subsequently used,
- # if it ever is. Note that we need to do the label setup BEFORE we
- # start to serialize the object so that circular structures (in
- # which we will encounter a reference to the object as we serialize
+ # going to be be encountered once), but can be changed to a valid
+ # (by assigning it a number) the first time it is subsequently used,
+ # if it ever is. Note that we need to do the label setup BEFORE we
+ # start to serialize the object so that circular structures (in
+ # which we will encounter a reference to the object as we serialize
# it can be handled).
#
def self.counter_reset
@@ -81,9 +81,9 @@ class ZAML
def first_time_only(obj)
if label = Label.for(obj)
emit(label.reference)
- else
+ else
if @structured_key_prefix and not obj.is_a? String
- emit(@structured_key_prefix)
+ emit(@structured_key_prefix)
@structured_key_prefix = nil
end
emit(new_label_for(obj))
@@ -95,7 +95,7 @@ class ZAML
@recent_nl = false unless s.kind_of?(Label)
end
def nl(s='')
- emit(@indent || "\n") unless @recent_nl
+ emit(@indent || "\n") unless @recent_nl
emit(s)
@recent_nl = true
end
@@ -126,19 +126,19 @@ class Object
end
def to_zaml(z)
z.first_time_only(self) {
- z.emit(zamlized_class_name(Object))
+ z.emit(zamlized_class_name(Object))
z.nested {
instance_variables = to_yaml_properties
if instance_variables.empty?
z.emit(" {}")
- else
+ else
instance_variables.each { |v|
z.nl
v[1..-1].to_zaml(z) # Remove leading '@'
z.emit(': ')
instance_variable_get(v).to_zaml(z)
}
- end
+ end
}
}
end
@@ -221,50 +221,50 @@ class String
gsub( /([\x80-\xFF])/ ) { |x| "\\x#{x.unpack("C")[0].to_s(16)}" }
end
def to_zaml(z)
- z.first_time_only(self) {
+ z.first_time_only(self) {
num = '[-+]?(0x)?\d+\.?\d*'
case
- when self == ''
- z.emit('""')
- # when self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/
- # z.emit("!binary |\n")
- # z.emit([self].pack("m*"))
- when (
- (self =~ /\A(true|false|yes|no|on|null|off|#{num}(:#{num})*|!|=|~)$/i) or
+ when self == ''
+ z.emit('""')
+ # when self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/
+ # z.emit("!binary |\n")
+ # z.emit([self].pack("m*"))
+ when (
+ (self =~ /\A(true|false|yes|no|on|null|off|#{num}(:#{num})*|!|=|~)$/i) or
(self =~ /\A\n* /) or
(self =~ /[\s:]$/) or
(self =~ /^[>|][-+\d]*\s/i) or
- (self[-1..-1] =~ /\s/) or
+ (self[-1..-1] =~ /\s/) or
(self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/) or
- (self =~ /[,\[\]\{\}\r\t]|:\s|\s#/) or
- (self =~ /\A([-:?!#&*'"]|<<|%.+:.)/)
+ (self =~ /[,\[\]\{\}\r\t]|:\s|\s#/) or
+ (self =~ /\A([-:?!#&*'"]|<<|%.+:.)/)
)
- z.emit("\"#{escaped_for_zaml}\"")
- when self =~ /\n/
- if self[-1..-1] == "\n" then z.emit('|+') else z.emit('|-') end
- z.nested { split("\n",-1).each { |line| z.nl; z.emit(line.chomp("\n")) } }
- z.nl
- else
- z.emit(self)
- end
+ z.emit("\"#{escaped_for_zaml}\"")
+ when self =~ /\n/
+ if self[-1..-1] == "\n" then z.emit('|+') else z.emit('|-') end
+ z.nested { split("\n",-1).each { |line| z.nl; z.emit(line.chomp("\n")) } }
+ z.nl
+ else
+ z.emit(self)
+ end
}
end
end
class Hash
def to_zaml(z)
- z.first_time_only(self) {
+ z.first_time_only(self) {
z.nested {
if empty?
z.emit('{}')
- else
+ else
each_pair { |k, v|
z.nl
z.prefix_structured_keys('? ') { k.to_zaml(z) }
z.emit(': ')
v.to_zaml(z)
}
- end
+ end
}
}
end
@@ -273,13 +273,13 @@ end
class Array
def to_zaml(z)
z.first_time_only(self) {
- z.nested {
+ z.nested {
if empty?
z.emit('[]')
- else
+ else
each { |v| z.nl('- '); v.to_zaml(z) }
- end
- }
+ end
+ }
}
end
end
@@ -302,7 +302,7 @@ end
class Range
def to_zaml(z)
z.first_time_only(self) {
- z.emit(zamlized_class_name(Range))
+ z.emit(zamlized_class_name(Range))
z.nested {
z.nl
z.emit('begin: ')
diff --git a/spec/integration/defaults_spec.rb b/spec/integration/defaults_spec.rb
index 3f66a0e8b..3fa753823 100755
--- a/spec/integration/defaults_spec.rb
+++ b/spec/integration/defaults_spec.rb
@@ -195,13 +195,13 @@ describe "Puppet defaults" do
it "should have a setting for determining the configuration version and should default to an empty string" do
Puppet.settings[:config_version].should == ""
end
-
+
describe "when enabling reports" do
it "should use the default server value when report server is unspecified" do
Puppet.settings[:server] = "server"
Puppet.settings[:report_server].should == "server"
end
-
+
it "should use the default masterport value when report port is unspecified" do
Puppet.settings[:masterport] = "1234"
Puppet.settings[:report_port].should == "1234"
@@ -211,20 +211,20 @@ describe "Puppet defaults" do
Puppet.settings[:reportserver] = "reportserver"
Puppet.settings[:report_server].should == "reportserver"
end
-
+
it "should use report_port when set" do
Puppet.settings[:masterport] = "1234"
Puppet.settings[:report_port] = "5678"
Puppet.settings[:report_port].should == "5678"
end
-
+
it "should prefer report_server over reportserver" do
Puppet.settings[:reportserver] = "reportserver"
Puppet.settings[:report_server] = "report_server"
Puppet.settings[:report_server].should == "report_server"
end
end
-
+
it "should have a :caname setting that defaults to the cert name" do
Puppet.settings[:certname] = "foo"
Puppet.settings[:ca_name].should == "foo"
diff --git a/spec/integration/indirector/report/rest_spec.rb b/spec/integration/indirector/report/rest_spec.rb
index 76b3b9003..1ddced9f9 100644
--- a/spec/integration/indirector/report/rest_spec.rb
+++ b/spec/integration/indirector/report/rest_spec.rb
@@ -84,7 +84,10 @@ describe "Report REST Terminus" do
}
report.add_metric(:times, timemetrics)
- report.add_metric(:changes,
+
+ report.add_metric(
+ :changes,
+
:total => 20
)
diff --git a/spec/integration/transaction_spec.rb b/spec/integration/transaction_spec.rb
index c93de1761..57dd490dd 100755
--- a/spec/integration/transaction_spec.rb
+++ b/spec/integration/transaction_spec.rb
@@ -106,20 +106,29 @@ describe Puppet::Transaction do
path = tmpfile("path")
file1 = tmpfile("file1")
file2 = tmpfile("file2")
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:path => path,
+
:ensure => "file"
)
- exec1 = Puppet::Type.type(:exec).new(
+
+ exec1 = Puppet::Type.type(:exec).new(
+
:path => ENV["PATH"],
:command => "touch %s" % file1,
:refreshonly => true,
+
:subscribe => Puppet::Resource.new(:file, path)
)
- exec2 = Puppet::Type.type(:exec).new(
+
+ exec2 = Puppet::Type.type(:exec).new(
+
:path => ENV["PATH"],
:command => "touch %s" % file2,
:refreshonly => true,
+
:subscribe => Puppet::Resource.new(:file, path)
)
@@ -132,24 +141,33 @@ describe Puppet::Transaction do
it "should not let one failed refresh result in other refreshes failing" do
path = tmpfile("path")
newfile = tmpfile("file")
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:path => path,
+
:ensure => "file"
)
- exec1 = Puppet::Type.type(:exec).new(
+
+ exec1 = Puppet::Type.type(:exec).new(
+
:path => ENV["PATH"],
:command => "touch /this/cannot/possibly/exist",
:logoutput => true,
:refreshonly => true,
:subscribe => file,
+
:title => "one"
)
- exec2 = Puppet::Type.type(:exec).new(
+
+ exec2 = Puppet::Type.type(:exec).new(
+
:path => ENV["PATH"],
:command => "touch %s" % newfile,
:logoutput => true,
:refreshonly => true,
:subscribe => [file, exec1],
+
:title => "two"
)
@@ -165,17 +183,23 @@ describe Puppet::Transaction do
catalog.add_resource(*Puppet::Type.type(:schedule).mkdefaultschedules)
Puppet[:ignoreschedules] = false
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => tmpfile("file"),
+
:ensure => "file",
:backup => false
)
fname = tmpfile("exec")
- exec = Puppet::Type.type(:exec).new(
+
+ exec = Puppet::Type.type(:exec).new(
+
:name => "touch #{fname}",
:path => "/usr/bin:/bin",
:schedule => "monthly",
+
:subscribe => Puppet::Resource.new("file", file.name)
)
@@ -211,21 +235,30 @@ describe Puppet::Transaction do
end
it "should not attempt to evaluate resources with failed dependencies" do
- exec = Puppet::Type.type(:exec).new(
+
+ exec = Puppet::Type.type(:exec).new(
+
:command => "/bin/mkdir /this/path/cannot/possibly/exit",
+
:title => "mkdir"
)
- file1 = Puppet::Type.type(:file).new(
+
+ file1 = Puppet::Type.type(:file).new(
+
:title => "file1",
:path => tmpfile("file1"),
+
:require => exec,
:ensure => :file
)
- file2 = Puppet::Type.type(:file).new(
+
+ file2 = Puppet::Type.type(:file).new(
+
:title => "file2",
:path => tmpfile("file2"),
+
:require => file1,
:ensure => :file
)
diff --git a/spec/integration/type/file_spec.rb b/spec/integration/type/file_spec.rb
index f215f0b08..e16da67cc 100755
--- a/spec/integration/type/file_spec.rb
+++ b/spec/integration/type/file_spec.rb
@@ -392,8 +392,11 @@ describe Puppet::Type.type(:file) do
it "should be able to create files when 'content' is specified but 'ensure' is not" do
dest = tmpfile("files_with_content")
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => dest,
+
:content => "this is some content, yo"
)
@@ -407,9 +410,12 @@ describe Puppet::Type.type(:file) do
it "should create files with content if both 'content' and 'ensure' are set" do
dest = tmpfile("files_with_content")
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => dest,
:ensure => "file",
+
:content => "this is some content, yo"
)
@@ -426,10 +432,13 @@ describe Puppet::Type.type(:file) do
File.open(source, "w") { |f| f.puts "yay" }
File.open(dest, "w") { |f| f.puts "boo" }
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => dest,
:ensure => :absent,
:source => source,
+
:backup => false
)
@@ -455,18 +464,24 @@ describe Puppet::Type.type(:file) do
# this file should get removed
File.open(@purgee, "w") { |f| f.puts "footest" }
- @lfobj = Puppet::Type.newfile(
+
+ @lfobj = Puppet::Type.newfile(
+
:title => "localfile",
:path => @localfile,
:content => "rahtest\n",
:ensure => :file,
+
:backup => false
)
- @destobj = Puppet::Type.newfile(:title => "destdir", :path => @destdir,
+
+ @destobj = Puppet::Type.newfile(
+ :title => "destdir", :path => @destdir,
:source => @sourcedir,
:backup => false,
:purge => true,
+
:recurse => true)
@catalog = Puppet::Resource::Catalog.new
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index e38d1e218..c32fb7885 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,4 +1,4 @@
-unless defined? SPEC_HELPER_IS_LOADED
+unless defined?(SPEC_HELPER_IS_LOADED)
SPEC_HELPER_IS_LOADED = 1
dir = File.expand_path(File.dirname(__FILE__))
@@ -51,11 +51,11 @@ Spec::Runner.configure do |config|
if Puppet.features.posix? and file !~ /^\/tmp/ and file !~ /^\/var\/folders/
puts "Not deleting tmpfile #{file} outside of /tmp or /var/folders"
next
- elsif Puppet.features.microsoft_windows?
+ elsif Puppet.features.microsoft_windows?
tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp"))
if file !~ /^#{tempdir}/
puts "Not deleting tmpfile #{file} outside of #{tempdir}"
- next
+ next
end
end
if FileTest.exist?(file)
diff --git a/spec/unit/application/resource_spec.rb b/spec/unit/application/resource_spec.rb
index 939042977..71e35dc18 100755
--- a/spec/unit/application/resource_spec.rb
+++ b/spec/unit/application/resource_spec.rb
@@ -50,8 +50,8 @@ describe Puppet::Application::Resource do
end
it "should load Facter facts" do
- Facter.expects(:loadfacts).once
- @resource.preinit
+ Facter.expects(:loadfacts).once
+ @resource.preinit
end
end
diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb
index 06ed16c4d..08ca79cfd 100755
--- a/spec/unit/file_bucket/dipper_spec.rb
+++ b/spec/unit/file_bucket/dipper_spec.rb
@@ -37,9 +37,12 @@ describe Puppet::FileBucket::Dipper do
bucketfile.stubs(:checksum_data).returns("DIGEST123")
bucketfile.expects(:save).with('md5/DIGEST123')
- Puppet::FileBucket::File.stubs(:new).with(
+
+ Puppet::FileBucket::File.stubs(:new).with(
+
"my contents",
:bucket_path => '/my/bucket',
+
:path => '/my/file'
).returns(bucketfile)
@@ -65,8 +68,11 @@ describe Puppet::FileBucket::Dipper do
end
it "should backup files to a remote server" do
- @dipper = Puppet::FileBucket::Dipper.new(
+
+ @dipper = Puppet::FileBucket::Dipper.new(
+
:Server => "puppetmaster",
+
:Port => "31337"
)
@@ -78,9 +84,12 @@ describe Puppet::FileBucket::Dipper do
bucketfile.stubs(:checksum_data).returns("DIGEST123")
bucketfile.expects(:save).with('https://puppetmaster:31337/production/file_bucket_file/md5/DIGEST123')
- Puppet::FileBucket::File.stubs(:new).with(
+
+ Puppet::FileBucket::File.stubs(:new).with(
+
"my contents",
:bucket_path => nil,
+
:path => '/my/file'
).returns(bucketfile)
@@ -88,8 +97,11 @@ describe Puppet::FileBucket::Dipper do
end
it "should retrieve files from a remote server" do
- @dipper = Puppet::FileBucket::Dipper.new(
+
+ @dipper = Puppet::FileBucket::Dipper.new(
+
:Server => "puppetmaster",
+
:Port => "31337"
)
diff --git a/spec/unit/file_serving/metadata_spec.rb b/spec/unit/file_serving/metadata_spec.rb
index ef2b3b6f0..0e2e71284 100755
--- a/spec/unit/file_serving/metadata_spec.rb
+++ b/spec/unit/file_serving/metadata_spec.rb
@@ -22,15 +22,15 @@ describe Puppet::FileServing::Metadata do
end
it "should support pson serialization" do
- Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:to_pson)
+ Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:to_pson)
end
it "should support to_pson_data_hash" do
- Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:to_pson_data_hash)
+ Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:to_pson_data_hash)
end
it "should support pson deserialization" do
- Puppet::FileServing::Metadata.should respond_to(:from_pson)
+ Puppet::FileServing::Metadata.should respond_to(:from_pson)
end
describe "when serializing" do
@@ -42,7 +42,7 @@ describe Puppet::FileServing::Metadata do
pdh_as_pson = mock "data as pson"
@metadata.expects(:to_pson_data_hash).returns pdh
pdh.expects(:to_pson).returns pdh_as_pson
- @metadata.to_pson.should == pdh_as_pson
+ @metadata.to_pson.should == pdh_as_pson
end
it "should serialize as FileMetadata" do
@@ -221,7 +221,7 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
@stat.stubs(:ftype).returns("link")
File.expects(:readlink).with("/my/file").returns("/path/to/link")
@metadata.collect
-
+
@checksum = Digest::MD5.hexdigest("some content\n") # Remove these when :managed links are no longer checksumed.
@file.stubs(:md5_file).returns(@checksum) #
end
diff --git a/spec/unit/indirector/file_bucket_file/file_spec.rb b/spec/unit/indirector/file_bucket_file/file_spec.rb
index f821ca45d..652da3df0 100755
--- a/spec/unit/indirector/file_bucket_file/file_spec.rb
+++ b/spec/unit/indirector/file_bucket_file/file_spec.rb
@@ -155,7 +155,7 @@ describe Puppet::FileBucketFile::File do
it "should use the bucketdir, the 8 sum character directories, the full filebucket, and 'contents' as the full file name" do
path = Puppet::FileBucketFile::File.new.send(:contents_path_for, @bucket)
path.should == ['/dev/null/bucketdir', @digest[0..7].split(""), @digest, "contents"].flatten.join(::File::SEPARATOR)
- end
+ end
end
describe "when saving files" do
diff --git a/spec/unit/indirector/indirection_spec.rb b/spec/unit/indirector/indirection_spec.rb
index 8e62e1525..872daad11 100755
--- a/spec/unit/indirector/indirection_spec.rb
+++ b/spec/unit/indirector/indirection_spec.rb
@@ -137,7 +137,7 @@ describe Puppet::Indirector::Indirection do
end
after do
- @indirection.delete if defined? @indirection
+ @indirection.delete if defined?(@indirection)
end
end
@@ -604,7 +604,7 @@ describe Puppet::Indirector::Indirection do
end
after do
- @indirection.delete if defined? @indirection
+ @indirection.delete if defined?(@indirection)
end
end
@@ -638,7 +638,7 @@ describe Puppet::Indirector::Indirection do
end
after do
- @indirection.delete if defined? @indirection
+ @indirection.delete if defined?(@indirection)
end
end
@@ -682,7 +682,7 @@ describe Puppet::Indirector::Indirection do
end
after do
- @indirection.delete if defined? @indirection
+ @indirection.delete if defined?(@indirection)
end
end
diff --git a/spec/unit/indirector/node/active_record_spec.rb b/spec/unit/indirector/node/active_record_spec.rb
index e33a4945f..8e7d1d6bd 100755
--- a/spec/unit/indirector/node/active_record_spec.rb
+++ b/spec/unit/indirector/node/active_record_spec.rb
@@ -10,7 +10,7 @@ describe "Puppet::Node::ActiveRecord" do
confine "Missing Rails" => Puppet.features.rails?
confine "Missing sqlite" => Puppet.features.sqlite?
- before do
+ before do
require 'puppet/indirector/node/active_record'
end
diff --git a/spec/unit/indirector/report/rest_spec.rb b/spec/unit/indirector/report/rest_spec.rb
index 1f71eb357..ce6188334 100755
--- a/spec/unit/indirector/report/rest_spec.rb
+++ b/spec/unit/indirector/report/rest_spec.rb
@@ -8,19 +8,19 @@ describe Puppet::Transaction::Report::Rest do
it "should be a subclass of Puppet::Indirector::REST" do
Puppet::Transaction::Report::Rest.superclass.should equal(Puppet::Indirector::REST)
end
-
+
it "should use the :report_server setting in preference to :reportserver" do
Puppet.settings[:reportserver] = "reportserver"
Puppet.settings[:report_server] = "report_server"
Puppet::Transaction::Report::Rest.server.should == "report_server"
end
-
+
it "should use the :report_server setting in preference to :server" do
Puppet.settings[:server] = "server"
Puppet.settings[:report_server] = "report_server"
Puppet::Transaction::Report::Rest.server.should == "report_server"
end
-
+
it "should have a value for report_server and report_port" do
Puppet::Transaction::Report::Rest.server.should_not be_nil
Puppet::Transaction::Report::Rest.port.should_not be_nil
diff --git a/spec/unit/indirector/yaml_spec.rb b/spec/unit/indirector/yaml_spec.rb
index 44ecf96d6..bd207a878 100755
--- a/spec/unit/indirector/yaml_spec.rb
+++ b/spec/unit/indirector/yaml_spec.rb
@@ -116,31 +116,31 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
end
describe Puppet::Indirector::Yaml, " when searching" do
- it "should return an array of fact instances with one instance for each file when globbing *" do
- @request = stub 'request', :key => "*", :instance => @subject
- @one = mock 'one'
- @two = mock 'two'
- @store.expects(:base).returns "/my/yaml/dir"
- Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml two.yaml})
- YAML.expects(:load_file).with("one.yaml").returns @one;
- YAML.expects(:load_file).with("two.yaml").returns @two;
- @store.search(@request).should == [@one, @two]
- end
-
- it "should return an array containing a single instance of fact when globbing 'one*'" do
- @request = stub 'request', :key => "one*", :instance => @subject
- @one = mock 'one'
- @store.expects(:base).returns "/my/yaml/dir"
- Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml})
- YAML.expects(:load_file).with("one.yaml").returns @one;
- @store.search(@request).should == [@one]
- end
-
- it "should return an empty array when the glob doesn't match anything" do
- @request = stub 'request', :key => "f*ilglobcanfail*", :instance => @subject
- @store.expects(:base).returns "/my/yaml/dir"
- Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns([])
- @store.search(@request).should == []
- end
+ it "should return an array of fact instances with one instance for each file when globbing *" do
+ @request = stub 'request', :key => "*", :instance => @subject
+ @one = mock 'one'
+ @two = mock 'two'
+ @store.expects(:base).returns "/my/yaml/dir"
+ Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml two.yaml})
+ YAML.expects(:load_file).with("one.yaml").returns @one;
+ YAML.expects(:load_file).with("two.yaml").returns @two;
+ @store.search(@request).should == [@one, @two]
+ end
+
+ it "should return an array containing a single instance of fact when globbing 'one*'" do
+ @request = stub 'request', :key => "one*", :instance => @subject
+ @one = mock 'one'
+ @store.expects(:base).returns "/my/yaml/dir"
+ Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml})
+ YAML.expects(:load_file).with("one.yaml").returns @one;
+ @store.search(@request).should == [@one]
+ end
+
+ it "should return an empty array when the glob doesn't match anything" do
+ @request = stub 'request', :key => "f*ilglobcanfail*", :instance => @subject
+ @store.expects(:base).returns "/my/yaml/dir"
+ Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns([])
+ @store.search(@request).should == []
+ end
end
end
diff --git a/spec/unit/network/authstore_spec.rb b/spec/unit/network/authstore_spec.rb
index 58eb92693..e3f819479 100644
--- a/spec/unit/network/authstore_spec.rb
+++ b/spec/unit/network/authstore_spec.rb
@@ -67,7 +67,7 @@ describe Puppet::Network::AuthStore::Declaration do
@declaration.should_not be_match('www.testsite.org',other.join('.'))
end
end
- }
+ }
}
describe "when the pattern is a numeric IP with a back reference" do
@@ -93,56 +93,56 @@ describe Puppet::Network::AuthStore::Declaration do
"3ffe:b00::1::a",
"1:2:3::4:5::7:8",
"12345::6:7:8",
- "1::5:400.2.3.4",
- "1::5:260.2.3.4",
- "1::5:256.2.3.4",
- "1::5:1.256.3.4",
- "1::5:1.2.256.4",
- "1::5:1.2.3.256",
- "1::5:300.2.3.4",
- "1::5:1.300.3.4",
- "1::5:1.2.300.4",
- "1::5:1.2.3.300",
- "1::5:900.2.3.4",
- "1::5:1.900.3.4",
- "1::5:1.2.900.4",
- "1::5:1.2.3.900",
- "1::5:300.300.300.300",
- "1::5:3000.30.30.30",
- "1::400.2.3.4",
- "1::260.2.3.4",
- "1::256.2.3.4",
- "1::1.256.3.4",
- "1::1.2.256.4",
- "1::1.2.3.256",
- "1::300.2.3.4",
- "1::1.300.3.4",
- "1::1.2.300.4",
- "1::1.2.3.300",
- "1::900.2.3.4",
- "1::1.900.3.4",
- "1::1.2.900.4",
- "1::1.2.3.900",
- "1::300.300.300.300",
- "1::3000.30.30.30",
- "::400.2.3.4",
- "::260.2.3.4",
- "::256.2.3.4",
- "::1.256.3.4",
- "::1.2.256.4",
- "::1.2.3.256",
- "::300.2.3.4",
- "::1.300.3.4",
- "::1.2.300.4",
- "::1.2.3.300",
- "::900.2.3.4",
- "::1.900.3.4",
- "::1.2.900.4",
- "::1.2.3.900",
- "::300.300.300.300",
- "::3000.30.30.30",
- "2001:DB8:0:0:8:800:200C:417A:221", # unicast, full
- "FF01::101::2" # multicast, compressed
+ "1::5:400.2.3.4",
+ "1::5:260.2.3.4",
+ "1::5:256.2.3.4",
+ "1::5:1.256.3.4",
+ "1::5:1.2.256.4",
+ "1::5:1.2.3.256",
+ "1::5:300.2.3.4",
+ "1::5:1.300.3.4",
+ "1::5:1.2.300.4",
+ "1::5:1.2.3.300",
+ "1::5:900.2.3.4",
+ "1::5:1.900.3.4",
+ "1::5:1.2.900.4",
+ "1::5:1.2.3.900",
+ "1::5:300.300.300.300",
+ "1::5:3000.30.30.30",
+ "1::400.2.3.4",
+ "1::260.2.3.4",
+ "1::256.2.3.4",
+ "1::1.256.3.4",
+ "1::1.2.256.4",
+ "1::1.2.3.256",
+ "1::300.2.3.4",
+ "1::1.300.3.4",
+ "1::1.2.300.4",
+ "1::1.2.3.300",
+ "1::900.2.3.4",
+ "1::1.900.3.4",
+ "1::1.2.900.4",
+ "1::1.2.3.900",
+ "1::300.300.300.300",
+ "1::3000.30.30.30",
+ "::400.2.3.4",
+ "::260.2.3.4",
+ "::256.2.3.4",
+ "::1.256.3.4",
+ "::1.2.256.4",
+ "::1.2.3.256",
+ "::300.2.3.4",
+ "::1.300.3.4",
+ "::1.2.300.4",
+ "::1.2.3.300",
+ "::900.2.3.4",
+ "::1.900.3.4",
+ "::1.2.900.4",
+ "::1.2.3.900",
+ "::300.300.300.300",
+ "::3000.30.30.30",
+ "2001:DB8:0:0:8:800:200C:417A:221", # unicast, full
+ "FF01::101::2" # multicast, compressed
].each { |invalid_ip|
describe "when the pattern is an invalid IPv6 address such as #{invalid_ip}" do
it "should raise an exception" do
@@ -152,97 +152,97 @@ describe Puppet::Network::AuthStore::Declaration do
}
[
- "1.2.3.4",
- "2001:0000:1234:0000:0000:C1C0:ABCD:0876",
- "3ffe:0b00:0000:0000:0001:0000:0000:000a",
- "FF02:0000:0000:0000:0000:0000:0000:0001",
- "0000:0000:0000:0000:0000:0000:0000:0001",
- "0000:0000:0000:0000:0000:0000:0000:0000",
- "::ffff:192.168.1.26",
- "2::10",
- "ff02::1",
- "fe80::",
- "2002::",
- "2001:db8::",
- "2001:0db8:1234::",
- "::ffff:0:0",
- "::1",
- "::ffff:192.168.1.1",
- "1:2:3:4:5:6:7:8",
- "1:2:3:4:5:6::8",
- "1:2:3:4:5::8",
- "1:2:3:4::8",
- "1:2:3::8",
- "1:2::8",
- "1::8",
- "1::2:3:4:5:6:7",
- "1::2:3:4:5:6",
- "1::2:3:4:5",
- "1::2:3:4",
- "1::2:3",
- "1::8",
- "::2:3:4:5:6:7:8",
- "::2:3:4:5:6:7",
- "::2:3:4:5:6",
- "::2:3:4:5",
- "::2:3:4",
- "::2:3",
- "::8",
- "1:2:3:4:5:6::",
- "1:2:3:4:5::",
- "1:2:3:4::",
- "1:2:3::",
- "1:2::",
- "1::",
- "1:2:3:4:5::7:8",
- "1:2:3:4::7:8",
- "1:2:3::7:8",
- "1:2::7:8",
- "1::7:8",
- "1:2:3:4:5:6:1.2.3.4",
- "1:2:3:4:5::1.2.3.4",
- "1:2:3:4::1.2.3.4",
- "1:2:3::1.2.3.4",
- "1:2::1.2.3.4",
- "1::1.2.3.4",
- "1:2:3:4::5:1.2.3.4",
- "1:2:3::5:1.2.3.4",
- "1:2::5:1.2.3.4",
- "1::5:1.2.3.4",
- "1::5:11.22.33.44",
- "fe80::217:f2ff:254.7.237.98",
- "fe80::217:f2ff:fe07:ed62",
- "2001:DB8:0:0:8:800:200C:417A", # unicast, full
- "FF01:0:0:0:0:0:0:101", # multicast, full
- "0:0:0:0:0:0:0:1", # loopback, full
- "0:0:0:0:0:0:0:0", # unspecified, full
- "2001:DB8::8:800:200C:417A", # unicast, compressed
- "FF01::101", # multicast, compressed
- "::1", # loopback, compressed, non-routable
- "::", # unspecified, compressed, non-routable
- "0:0:0:0:0:0:13.1.68.3", # IPv4-compatible IPv6 address, full, deprecated
- "0:0:0:0:0:FFFF:129.144.52.38", # IPv4-mapped IPv6 address, full
- "::13.1.68.3", # IPv4-compatible IPv6 address, compressed, deprecated
- "::FFFF:129.144.52.38", # IPv4-mapped IPv6 address, compressed
- "2001:0DB8:0000:CD30:0000:0000:0000:0000/60", # full, with prefix
- "2001:0DB8::CD30:0:0:0:0/60", # compressed, with prefix
- "2001:0DB8:0:CD30::/60", # compressed, with prefix #2
- "::/128", # compressed, unspecified address type, non-routable
- "::1/128", # compressed, loopback address type, non-routable
- "FF00::/8", # compressed, multicast address type
- "FE80::/10", # compressed, link-local unicast, non-routable
- "FEC0::/10", # compressed, site-local unicast, deprecated
- "127.0.0.1", # standard IPv4, loopback, non-routable
- "0.0.0.0", # standard IPv4, unspecified, non-routable
- "255.255.255.255", # standard IPv4
- "fe80:0000:0000:0000:0204:61ff:fe9d:f156",
- "fe80:0:0:0:204:61ff:fe9d:f156",
- "fe80::204:61ff:fe9d:f156",
- "fe80:0000:0000:0000:0204:61ff:254.157.241.086",
- "fe80:0:0:0:204:61ff:254.157.241.86",
- "fe80::204:61ff:254.157.241.86",
- "::1",
- "fe80::",
+ "1.2.3.4",
+ "2001:0000:1234:0000:0000:C1C0:ABCD:0876",
+ "3ffe:0b00:0000:0000:0001:0000:0000:000a",
+ "FF02:0000:0000:0000:0000:0000:0000:0001",
+ "0000:0000:0000:0000:0000:0000:0000:0001",
+ "0000:0000:0000:0000:0000:0000:0000:0000",
+ "::ffff:192.168.1.26",
+ "2::10",
+ "ff02::1",
+ "fe80::",
+ "2002::",
+ "2001:db8::",
+ "2001:0db8:1234::",
+ "::ffff:0:0",
+ "::1",
+ "::ffff:192.168.1.1",
+ "1:2:3:4:5:6:7:8",
+ "1:2:3:4:5:6::8",
+ "1:2:3:4:5::8",
+ "1:2:3:4::8",
+ "1:2:3::8",
+ "1:2::8",
+ "1::8",
+ "1::2:3:4:5:6:7",
+ "1::2:3:4:5:6",
+ "1::2:3:4:5",
+ "1::2:3:4",
+ "1::2:3",
+ "1::8",
+ "::2:3:4:5:6:7:8",
+ "::2:3:4:5:6:7",
+ "::2:3:4:5:6",
+ "::2:3:4:5",
+ "::2:3:4",
+ "::2:3",
+ "::8",
+ "1:2:3:4:5:6::",
+ "1:2:3:4:5::",
+ "1:2:3:4::",
+ "1:2:3::",
+ "1:2::",
+ "1::",
+ "1:2:3:4:5::7:8",
+ "1:2:3:4::7:8",
+ "1:2:3::7:8",
+ "1:2::7:8",
+ "1::7:8",
+ "1:2:3:4:5:6:1.2.3.4",
+ "1:2:3:4:5::1.2.3.4",
+ "1:2:3:4::1.2.3.4",
+ "1:2:3::1.2.3.4",
+ "1:2::1.2.3.4",
+ "1::1.2.3.4",
+ "1:2:3:4::5:1.2.3.4",
+ "1:2:3::5:1.2.3.4",
+ "1:2::5:1.2.3.4",
+ "1::5:1.2.3.4",
+ "1::5:11.22.33.44",
+ "fe80::217:f2ff:254.7.237.98",
+ "fe80::217:f2ff:fe07:ed62",
+ "2001:DB8:0:0:8:800:200C:417A", # unicast, full
+ "FF01:0:0:0:0:0:0:101", # multicast, full
+ "0:0:0:0:0:0:0:1", # loopback, full
+ "0:0:0:0:0:0:0:0", # unspecified, full
+ "2001:DB8::8:800:200C:417A", # unicast, compressed
+ "FF01::101", # multicast, compressed
+ "::1", # loopback, compressed, non-routable
+ "::", # unspecified, compressed, non-routable
+ "0:0:0:0:0:0:13.1.68.3", # IPv4-compatible IPv6 address, full, deprecated
+ "0:0:0:0:0:FFFF:129.144.52.38", # IPv4-mapped IPv6 address, full
+ "::13.1.68.3", # IPv4-compatible IPv6 address, compressed, deprecated
+ "::FFFF:129.144.52.38", # IPv4-mapped IPv6 address, compressed
+ "2001:0DB8:0000:CD30:0000:0000:0000:0000/60", # full, with prefix
+ "2001:0DB8::CD30:0:0:0:0/60", # compressed, with prefix
+ "2001:0DB8:0:CD30::/60", # compressed, with prefix #2
+ "::/128", # compressed, unspecified address type, non-routable
+ "::1/128", # compressed, loopback address type, non-routable
+ "FF00::/8", # compressed, multicast address type
+ "FE80::/10", # compressed, link-local unicast, non-routable
+ "FEC0::/10", # compressed, site-local unicast, deprecated
+ "127.0.0.1", # standard IPv4, loopback, non-routable
+ "0.0.0.0", # standard IPv4, unspecified, non-routable
+ "255.255.255.255", # standard IPv4
+ "fe80:0000:0000:0000:0204:61ff:fe9d:f156",
+ "fe80:0:0:0:204:61ff:fe9d:f156",
+ "fe80::204:61ff:fe9d:f156",
+ "fe80:0000:0000:0000:0204:61ff:254.157.241.086",
+ "fe80:0:0:0:204:61ff:254.157.241.86",
+ "fe80::204:61ff:254.157.241.86",
+ "::1",
+ "fe80::",
"fe80::1"
].each { |ip|
describe "when the pattern is a valid IP such as #{ip}" do
diff --git a/spec/unit/network/format_handler_spec.rb b/spec/unit/network/format_handler_spec.rb
index 622f7e5a1..13a9b8300 100755
--- a/spec/unit/network/format_handler_spec.rb
+++ b/spec/unit/network/format_handler_spec.rb
@@ -61,7 +61,7 @@ describe Puppet::Network::FormatHandler do
describe "that is supported" do
before do
Puppet.settings.expects(:value).with(:preferred_serialization_format).returns :one
- end
+ end
it "should return the preferred serialization format first" do
FormatTester.supported_formats.should == [:one, :two]
end
diff --git a/spec/unit/network/formats_spec.rb b/spec/unit/network/formats_spec.rb
index fd78ebf52..0811d61ce 100755
--- a/spec/unit/network/formats_spec.rb
+++ b/spec/unit/network/formats_spec.rb
@@ -141,7 +141,7 @@ describe "Puppet Network Format" do
end
it "use_zlib? should return false" do
- @yaml.use_zlib?.should == false
+ @yaml.use_zlib?.should == false
end
it "should refuse to encode" do
diff --git a/spec/unit/network/handler/fileserver_spec.rb b/spec/unit/network/handler/fileserver_spec.rb
index fbb5c8ae2..35da33278 100644
--- a/spec/unit/network/handler/fileserver_spec.rb
+++ b/spec/unit/network/handler/fileserver_spec.rb
@@ -64,15 +64,13 @@ describe Puppet::Network::Handler::FileServer do
it "should list the contents of a nested directory" do
create_nested_file()
list = @mount.list("/", true, false)
- list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ,
- ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
+ list.sort.should == [ ["/aFile", "file"], ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
end
it "should list the contents of a directory ignoring files that match" do
create_nested_file()
list = @mount.list("/", true, "*File")
- list.sort.should == [ ["/", "directory"] ,
- ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
+ list.sort.should == [ ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
end
it "should list the contents of a directory ignoring directories that match" do
@@ -102,15 +100,13 @@ describe Puppet::Network::Handler::FileServer do
it "should list the base directory and files and nested directory to a depth of two" do
create_nested_file()
list = @mount.list("/", 2, false)
- list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ,
- ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
+ list.sort.should == [ ["/aFile", "file"], ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
end
it "should list the base directory and files and nested directory to a depth greater than the directory structure" do
create_nested_file()
list = @mount.list("/", 42, false)
- list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ,
- ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
+ list.sort.should == [ ["/aFile", "file"], ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
end
it "should list a valid symbolic link as a file when recursing base dir" do
@@ -156,7 +152,7 @@ describe Puppet::Network::Handler::FileServer do
it "should list a file within a directory when given the file path with recursion" do
@mount.list("facter/fact.rb", true, "false").should == [["/", "file"], ["/", "file"]]
- end
+ end
it "should return a merged view of all plugins for all modules" do
list = @mount.list("facter",true,false)
diff --git a/spec/unit/network/rest_authconfig_spec.rb b/spec/unit/network/rest_authconfig_spec.rb
index fe17d5626..2d41c3e5b 100755
--- a/spec/unit/network/rest_authconfig_spec.rb
+++ b/spec/unit/network/rest_authconfig_spec.rb
@@ -32,7 +32,7 @@ describe Puppet::Network::RestAuthConfig do
@authconfig.rights = @acl
@request = stub 'request', :indirection_name => "path", :key => "to/resource", :ip => "127.0.0.1",
- :node => "me", :method => :save, :environment => :env, :authenticated => true
+ :node => "me", :method => :save, :environment => :env, :authenticated => true
end
it "should use the puppet default rest authorization file" do
@@ -115,7 +115,7 @@ describe Puppet::Network::RestAuthConfig do
describe "when adding default ACLs" do
- DEFAULT_ACL.each do |acl|
+ DEFAULT_ACL.each do |acl|
it "should create a default right for #{acl[:acl]}" do
@authconfig.stubs(:mk_acl)
@authconfig.expects(:mk_acl).with(acl)
diff --git a/spec/unit/network/server_spec.rb b/spec/unit/network/server_spec.rb
index 2aeb99a8b..d981a7586 100755
--- a/spec/unit/network/server_spec.rb
+++ b/spec/unit/network/server_spec.rb
@@ -471,11 +471,11 @@ describe Puppet::Network::Server do
end
it "should pass the listening address to the HTTP server" do
- @server.stubs(:http_server).returns(@mock_http_server)
- @mock_http_server.expects(:listen).with do |args|
- args[:address] == '127.0.0.1'
- end
- @server.listen
+ @server.stubs(:http_server).returns(@mock_http_server)
+ @mock_http_server.expects(:listen).with do |args|
+ args[:address] == '127.0.0.1'
+ end
+ @server.listen
end
it "should pass the listening port to the HTTP server" do
@@ -505,7 +505,7 @@ describe Puppet::Network::Server do
it "should pass a list of protocols to the HTTP server" do
@server.stubs(:http_server).returns(@mock_http_server)
@mock_http_server.expects(:listen).with do |args|
- args[:protocols] == [ :rest, :xmlrpc ]
+ args[:protocols] == [ :rest, :xmlrpc ]
end
@server.listen
end
diff --git a/spec/unit/node/environment_spec.rb b/spec/unit/node/environment_spec.rb
index d0db2504c..11f1c9ce1 100755
--- a/spec/unit/node/environment_spec.rb
+++ b/spec/unit/node/environment_spec.rb
@@ -63,7 +63,7 @@ describe Puppet::Node::Environment do
it "should reuse any existing resource type collection" do
@env.known_resource_types.should equal(@env.known_resource_types)
end
-
+
it "should perform the initial import when creating a new collection" do
@collection.expects(:perform_initial_import)
Puppet::Resource::TypeCollection.expects(:new).returns @collection
diff --git a/spec/unit/node/facts_spec.rb b/spec/unit/node/facts_spec.rb
index 43532cc53..d276de28d 100755
--- a/spec/unit/node/facts_spec.rb
+++ b/spec/unit/node/facts_spec.rb
@@ -18,7 +18,7 @@ describe Puppet::Node::Facts, "when indirecting" do
it "should add the node's certificate name as the 'clientcert' fact when adding local facts" do
@facts.add_local_facts
@facts.values["clientcert"].should == Puppet.settings[:certname]
- end
+ end
it "should add the Puppet version as a 'clientversion' fact when adding local facts" do
@facts.add_local_facts
diff --git a/spec/unit/other/selinux_spec.rb b/spec/unit/other/selinux_spec.rb
index 2287570e7..46e07b8af 100644
--- a/spec/unit/other/selinux_spec.rb
+++ b/spec/unit/other/selinux_spec.rb
@@ -7,11 +7,14 @@ require 'puppet/type/selmodule'
describe Puppet::Type.type(:file), " when manipulating file contexts" do
before :each do
- @file = Puppet::Type::File.new(
+
+ @file = Puppet::Type::File.new(
+
:name => "/tmp/foo",
:ensure => "file",
:seluser => "user_u",
:selrole => "role_r",
+
:seltype => "type_t" )
end
it "should use :seluser to get/set an SELinux user file context attribute" do
@@ -30,9 +33,12 @@ describe Puppet::Type.type(:selboolean), " when manipulating booleans" do
provider_class = Puppet::Type::Selboolean.provider(Puppet::Type::Selboolean.providers[0])
Puppet::Type::Selboolean.stubs(:defaultprovider).returns provider_class
- @bool = Puppet::Type::Selboolean.new(
+
+ @bool = Puppet::Type::Selboolean.new(
+
:name => "foo",
:value => "on",
+
:persistent => true )
end
it "should be able to access :name" do
@@ -59,10 +65,13 @@ describe Puppet::Type.type(:selmodule), " when checking policy modules" do
provider_class = Puppet::Type::Selmodule.provider(Puppet::Type::Selmodule.providers[0])
Puppet::Type::Selmodule.stubs(:defaultprovider).returns provider_class
- @module = Puppet::Type::Selmodule.new(
+
+ @module = Puppet::Type::Selmodule.new(
+
:name => "foo",
:selmoduledir => "/some/path",
:selmodulepath => "/some/path/foo.pp",
+
:syncversion => true)
end
it "should be able to access :name" do
diff --git a/spec/unit/parser/ast/casestatement_spec.rb b/spec/unit/parser/ast/casestatement_spec.rb
index 240d3bfea..187dd5822 100755
--- a/spec/unit/parser/ast/casestatement_spec.rb
+++ b/spec/unit/parser/ast/casestatement_spec.rb
@@ -136,11 +136,13 @@ describe Puppet::Parser::AST::CaseStatement do
}
options = tests.collect do |result, values|
values = values.collect { |v| AST::Leaf.new :value => v }
- AST::CaseOpt.new(:value => AST::ASTArray.new(:children => values),
+
+ AST::CaseOpt.new(
+ :value => AST::ASTArray.new(:children => values),
+
:statements => AST::Leaf.new(:value => result))
end
- options << AST::CaseOpt.new(:value => AST::Default.new(:value => "default"),
- :statements => AST::Leaf.new(:value => "default"))
+ options << AST::CaseOpt.new(:value => AST::Default.new(:value => "default"), :statements => AST::Leaf.new(:value => "default"))
ast = nil
param = AST::Variable.new(:value => "testparam")
diff --git a/spec/unit/parser/ast/comparison_operator_spec.rb b/spec/unit/parser/ast/comparison_operator_spec.rb
index 97402433f..51f4cc516 100755
--- a/spec/unit/parser/ast/comparison_operator_spec.rb
+++ b/spec/unit/parser/ast/comparison_operator_spec.rb
@@ -54,11 +54,11 @@ describe Puppet::Parser::AST::ComparisonOperator do
end
%w{< > <= >= ==}.each do |oper|
- it "should return the result of using '#{oper}' to compare the left and right sides" do
- operator = Puppet::Parser::AST::ComparisonOperator.new :lval => @one, :operator => oper, :rval => @two
+ it "should return the result of using '#{oper}' to compare the left and right sides" do
+ operator = Puppet::Parser::AST::ComparisonOperator.new :lval => @one, :operator => oper, :rval => @two
- operator.evaluate(@scope).should == 1.send(oper,2)
- end
+ operator.evaluate(@scope).should == 1.send(oper,2)
+ end
end
it "should return the result of using '!=' to compare the left and right sides" do
@@ -81,12 +81,12 @@ describe Puppet::Parser::AST::ComparisonOperator do
# see ticket #1759
%w{< > <= >=}.each do |oper|
it "should return the correct result of using '#{oper}' to compare 10 and 9" do
- ten = stub 'one', :safeevaluate => "10"
- nine = stub 'two', :safeevaluate => "9"
- operator = Puppet::Parser::AST::ComparisonOperator.new :lval => ten, :operator => oper, :rval => nine
+ ten = stub 'one', :safeevaluate => "10"
+ nine = stub 'two', :safeevaluate => "9"
+ operator = Puppet::Parser::AST::ComparisonOperator.new :lval => ten, :operator => oper, :rval => nine
- operator.evaluate(@scope).should == 10.send(oper,9)
- end
+ operator.evaluate(@scope).should == 10.send(oper,9)
+ end
end
end
diff --git a/spec/unit/parser/ast/vardef_spec.rb b/spec/unit/parser/ast/vardef_spec.rb
index a6863e75f..369a9f847 100755
--- a/spec/unit/parser/ast/vardef_spec.rb
+++ b/spec/unit/parser/ast/vardef_spec.rb
@@ -17,7 +17,7 @@ describe Puppet::Parser::AST::VarDef do
value.expects(:safeevaluate).with(@scope)
vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil,
- :line => nil
+ :line => nil
vardef.evaluate(@scope)
end
@@ -28,7 +28,7 @@ describe Puppet::Parser::AST::VarDef do
@scope.expects(:setvar).with { |name,value,options| options[:append] == nil }
vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil,
- :line => nil
+ :line => nil
vardef.evaluate(@scope)
end
@@ -39,7 +39,7 @@ describe Puppet::Parser::AST::VarDef do
@scope.expects(:setvar).with { |name,value,options| options[:append] == true }
vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil,
- :line => nil, :append => true
+ :line => nil, :append => true
vardef.evaluate(@scope)
end
diff --git a/spec/unit/parser/ast_spec.rb b/spec/unit/parser/ast_spec.rb
index ca6f8080a..cd271af98 100644
--- a/spec/unit/parser/ast_spec.rb
+++ b/spec/unit/parser/ast_spec.rb
@@ -21,9 +21,9 @@ describe Puppet::Parser::AST do
end
[ Puppet::Parser::AST::Collection, Puppet::Parser::AST::Else,
- Puppet::Parser::AST::Function, Puppet::Parser::AST::IfStatement,
- Puppet::Parser::AST::Resource, Puppet::Parser::AST::ResourceDefaults,
- Puppet::Parser::AST::ResourceOverride, Puppet::Parser::AST::VarDef
+ Puppet::Parser::AST::Function, Puppet::Parser::AST::IfStatement,
+ Puppet::Parser::AST::Resource, Puppet::Parser::AST::ResourceDefaults,
+ Puppet::Parser::AST::ResourceOverride, Puppet::Parser::AST::VarDef
].each do |k|
it "#{k}.use_docs should return true" do
ast = k.new({})
diff --git a/spec/unit/parser/functions/defined_spec.rb b/spec/unit/parser/functions/defined_spec.rb
index 03b0ef9dd..90f2f5239 100755
--- a/spec/unit/parser/functions/defined_spec.rb
+++ b/spec/unit/parser/functions/defined_spec.rb
@@ -18,7 +18,7 @@ describe "the 'defined' function" do
@scope.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "yayness")
@scope.function_defined("yayness").should be_true
end
-
+
it "should be true when the name is defined as a definition" do
@scope.known_resource_types.add Puppet::Resource::Type.new(:definition, "yayness")
@scope.function_defined("yayness").should be_true
diff --git a/spec/unit/parser/functions/regsubst_spec.rb b/spec/unit/parser/functions/regsubst_spec.rb
index 5a533efb1..6ff619f8d 100755
--- a/spec/unit/parser/functions/regsubst_spec.rb
+++ b/spec/unit/parser/functions/regsubst_spec.rb
@@ -13,29 +13,24 @@ describe "the regsubst function" do
end
it "should raise a ParseError if there is less than 3 arguments" do
- lambda { @scope.function_regsubst(["foo", "bar"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst(["foo", "bar"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError if there is more than 5 arguments" do
- lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "del", "x", "y"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "del", "x", "y"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError when given a bad flag" do
- lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "X"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "X"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError for non-string and non-array target" do
- lambda { @scope.function_regsubst([4711, "bar", "gazonk"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst([4711, "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError for array target with non-string element" do
- lambda { @scope.function_regsubst([["x", ["y"], "z"], "bar", "gazonk"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst([["x", ["y"], "z"], "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError for a bad regular expression" do
@@ -44,63 +39,80 @@ describe "the regsubst function" do
end
it "should raise a ParseError for a non-string regular expression" do
- lambda { @scope.function_regsubst(["foo", ["bar"], "gazonk"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_regsubst(["foo", ["bar"], "gazonk"]) }.should( raise_error(Puppet::ParseError))
end
it "should handle groups" do
+
result = @scope.function_regsubst(
+
[ '130.236.254.10',
- '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$',
- '\4-\3-\2-\1'
+
+ '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$',
+ '\4-\3-\2-\1'
])
result.should(eql("10-254-236-130"))
end
it "should handle simple regexps" do
+
result = @scope.function_regsubst(
+
[ "the monkey breaks banana trees",
- "b[an]*a",
- "coconut"
+ "b[an]*a",
+
+ "coconut"
])
result.should(eql("the monkey breaks coconut trees"))
end
it "should handle case-sensitive regexps" do
+
result = @scope.function_regsubst(
+
[ "the monkey breaks baNAna trees",
- "b[an]+a",
- "coconut"
+ "b[an]+a",
+
+ "coconut"
])
result.should(eql("the monkey breaks baNAna trees"))
end
it "should handle case-insensitive regexps" do
+
result = @scope.function_regsubst(
+
[ "the monkey breaks baNAna trees",
- "b[an]+a",
- "coconut",
- "I"
+ "b[an]+a",
+ "coconut",
+
+ "I"
])
result.should(eql("the monkey breaks coconut trees"))
end
it "should handle global substitutions" do
+
result = @scope.function_regsubst(
+
[ "the monkey breaks\tbanana trees",
- "[ \t]",
- "--",
- "G"
+ "[ \t]",
+ "--",
+
+ "G"
])
result.should(eql("the--monkey--breaks--banana--trees"))
end
it "should handle global substitutions with groups" do
+
result = @scope.function_regsubst(
+
[ '130.236.254.10',
- '([0-9]+)',
- '<\1>',
- 'G'
+
+ '([0-9]+)',
+ '<\1>',
+ 'G'
])
result.should(eql('<130>.<236>.<254>.<10>'))
end
@@ -108,59 +120,71 @@ describe "the regsubst function" do
it "should apply on all elements of an array" do
data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40']
result = @scope.function_regsubst([ data, '[.]', '-'])
- result.should(eql(
- ['130-236.254.10', 'foo-example.com', 'coconut', '10-20.30.40']))
+ result.should(eql( ['130-236.254.10', 'foo-example.com', 'coconut', '10-20.30.40']))
end
it "should apply global substitutions on all elements of an array" do
data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40']
result = @scope.function_regsubst([ data, '[.]', '-', 'G'])
- result.should(eql(
- ['130-236-254-10', 'foo-example-com', 'coconut', '10-20-30-40']))
+ result.should(eql( ['130-236-254-10', 'foo-example-com', 'coconut', '10-20-30-40']))
end
it "should handle groups on all elements of an array" do
data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40']
- result = @scope.function_regsubst(
- [ data,
- '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$',
- '\4-\3-\2-\1'
+
+ result = @scope.function_regsubst(
+
+ [ data,
+
+ '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$',
+ '\4-\3-\2-\1'
])
- result.should(eql(
- ['10-254-236-130', 'foo.example.com', 'coconut', '40-30-20-10']))
+ result.should(eql( ['10-254-236-130', 'foo.example.com', 'coconut', '40-30-20-10']))
end
it "should handle global substitutions with groups on all elements of an array" do
data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40']
- result = @scope.function_regsubst(
- [ data,
- '([^.]+)',
- '<\1>',
- 'G'
+
+ result = @scope.function_regsubst(
+
+ [ data,
+
+ '([^.]+)',
+ '<\1>',
+ 'G'
])
- result.should(eql(
- ['<130>.<236>.<254>.<10>', '<foo>.<example>.<com>',
- '<coconut>', '<10>.<20>.<30>.<40>']))
+
+ result.should(eql(
+
+ ['<130>.<236>.<254>.<10>', '<foo>.<example>.<com>',
+
+ '<coconut>', '<10>.<20>.<30>.<40>']))
end
it "should return an array (not a string) for a single element array parameter" do
data = ['130.236.254.10']
- result = @scope.function_regsubst(
- [ data,
- '([^.]+)',
- '<\1>',
- 'G'
+
+ result = @scope.function_regsubst(
+
+ [ data,
+
+ '([^.]+)',
+ '<\1>',
+ 'G'
])
result.should(eql(['<130>.<236>.<254>.<10>']))
end
it "should return a string (not a one element array) for a simple string parameter" do
data = '130.236.254.10'
- result = @scope.function_regsubst(
- [ data,
- '([^.]+)',
- '<\1>',
- 'G'
+
+ result = @scope.function_regsubst(
+
+ [ data,
+
+ '([^.]+)',
+ '<\1>',
+ 'G'
])
result.should(eql('<130>.<236>.<254>.<10>'))
end
diff --git a/spec/unit/parser/functions/shellquote_spec.rb b/spec/unit/parser/functions/shellquote_spec.rb
index 283a4de1e..8286be32e 100755
--- a/spec/unit/parser/functions/shellquote_spec.rb
+++ b/spec/unit/parser/functions/shellquote_spec.rb
@@ -19,74 +19,63 @@ describe "the shellquote function" do
end
it "should handle several simple arguments" do
- result = @scope.function_shellquote(
- ['foo', 'bar@example.com', 'localhost:/dev/null', 'xyzzy+-4711,23'])
- result.should(eql(
- 'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
+ result = @scope.function_shellquote( ['foo', 'bar@example.com', 'localhost:/dev/null', 'xyzzy+-4711,23'])
+ result.should(eql( 'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
end
it "should handle array arguments" do
+
result = @scope.function_shellquote(
+
['foo', ['bar@example.com', 'localhost:/dev/null'],
- 'xyzzy+-4711,23'])
+
+ 'xyzzy+-4711,23'])
result.should(eql(
'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
end
it "should quote unsafe characters" do
- result = @scope.function_shellquote(
- ['/etc/passwd ', '(ls)', '*', '[?]', "'&'"])
- result.should(eql(
- '"/etc/passwd " "(ls)" "*" "[?]" "\'&\'"'))
+ result = @scope.function_shellquote( ['/etc/passwd ', '(ls)', '*', '[?]', "'&'"])
+ result.should(eql( '"/etc/passwd " "(ls)" "*" "[?]" "\'&\'"'))
end
it "should deal with double quotes" do
result = @scope.function_shellquote(
- ['"foo"bar"'])
+ ['"foo"bar"'])
result.should(eql(
'\'"foo"bar"\''))
end
it "should cope with dollar signs" do
- result = @scope.function_shellquote(
- ['$PATH', 'foo$bar', '"x$"'])
- result.should(eql(
- "'$PATH' 'foo$bar' '\"x$\"'"))
+ result = @scope.function_shellquote( ['$PATH', 'foo$bar', '"x$"'])
+ result.should(eql( "'$PATH' 'foo$bar' '\"x$\"'"))
end
it "should deal with apostrophes (single quotes)" do
result = @scope.function_shellquote(
- ["'foo'bar'", "`$'EDITOR'`"])
+ ["'foo'bar'", "`$'EDITOR'`"])
result.should(eql(
'"\'foo\'bar\'" "\\`\\$\'EDITOR\'\\`"'))
end
it "should cope with grave accents (backquotes)" do
- result = @scope.function_shellquote(
- ['`echo *`', '`ls "$MAILPATH"`'])
- result.should(eql(
- "'`echo *`' '`ls \"$MAILPATH\"`'"))
+ result = @scope.function_shellquote( ['`echo *`', '`ls "$MAILPATH"`'])
+ result.should(eql( "'`echo *`' '`ls \"$MAILPATH\"`'"))
end
it "should deal with both single and double quotes" do
- result = @scope.function_shellquote(
- ['\'foo"bar"xyzzy\'', '"foo\'bar\'xyzzy"'])
- result.should(eql(
- '"\'foo\\"bar\\"xyzzy\'" "\\"foo\'bar\'xyzzy\\""'))
+ result = @scope.function_shellquote( ['\'foo"bar"xyzzy\'', '"foo\'bar\'xyzzy"'])
+ result.should(eql( '"\'foo\\"bar\\"xyzzy\'" "\\"foo\'bar\'xyzzy\\""'))
end
it "should handle multiple quotes *and* dollars and backquotes" do
- result = @scope.function_shellquote(
- ['\'foo"$x`bar`"xyzzy\''])
- result.should(eql(
- '"\'foo\\"\\$x\\`bar\\`\\"xyzzy\'"'))
+ result = @scope.function_shellquote( ['\'foo"$x`bar`"xyzzy\''])
+ result.should(eql( '"\'foo\\"\\$x\\`bar\\`\\"xyzzy\'"'))
end
it "should handle linefeeds" do
- result = @scope.function_shellquote(
- ["foo \n bar"])
- result.should(eql(
- "\"foo \n bar\""))
+ result = @scope.function_shellquote( ["foo \n bar"])
+ result.should(eql( "\"foo \n bar\""))
end
end
diff --git a/spec/unit/parser/functions/split_spec.rb b/spec/unit/parser/functions/split_spec.rb
index 8aa031d19..3d0240af4 100755
--- a/spec/unit/parser/functions/split_spec.rb
+++ b/spec/unit/parser/functions/split_spec.rb
@@ -13,39 +13,37 @@ describe "the split function" do
end
it "should raise a ParseError if there is less than 2 arguments" do
- lambda { @scope.function_split(["foo"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_split(["foo"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a ParseError if there is more than 2 arguments" do
- lambda { @scope.function_split(["foo", "bar", "gazonk"]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_split(["foo", "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError))
end
it "should raise a RegexpError if the regexp is malformed" do
lambda { @scope.function_split(["foo", "("]) }.should(
- raise_error(RegexpError))
+ raise_error(RegexpError))
end
it "should handle simple string without metacharacters" do
- result = @scope.function_split([ "130;236;254;10", ";"])
- result.should(eql(["130", "236", "254", "10"]))
+ result = @scope.function_split([ "130;236;254;10", ";"])
+ result.should(eql(["130", "236", "254", "10"]))
end
it "should handle simple regexps" do
- result = @scope.function_split([ "130.236;254.;10", "[.;]+"])
- result.should(eql(["130", "236", "254", "10"]))
+ result = @scope.function_split([ "130.236;254.;10", "[.;]+"])
+ result.should(eql(["130", "236", "254", "10"]))
end
it "should handle groups" do
- result = @scope.function_split([ "130.236;254.;10", "([.;]+)"])
- result.should(eql(["130", ".", "236", ";", "254", ".;", "10"]))
+ result = @scope.function_split([ "130.236;254.;10", "([.;]+)"])
+ result.should(eql(["130", ".", "236", ";", "254", ".;", "10"]))
end
it "should handle simple string without metacharacters" do
- result = @scope.function_split([ "130.236.254.10", ";"])
- result.should(eql(["130.236.254.10"]))
+ result = @scope.function_split([ "130.236.254.10", ";"])
+ result.should(eql(["130.236.254.10"]))
end
end
diff --git a/spec/unit/parser/functions/sprintf_spec.rb b/spec/unit/parser/functions/sprintf_spec.rb
index 949dc3fcc..71921e0e0 100755
--- a/spec/unit/parser/functions/sprintf_spec.rb
+++ b/spec/unit/parser/functions/sprintf_spec.rb
@@ -13,8 +13,7 @@ describe "the sprintf function" do
end
it "should raise a ParseError if there is less than 1 argument" do
- lambda { @scope.function_sprintf([]) }.should(
- raise_error(Puppet::ParseError))
+ lambda { @scope.function_sprintf([]) }.should( raise_error(Puppet::ParseError))
end
it "should format integers" do
@@ -35,7 +34,7 @@ describe "the sprintf function" do
it "should perform more complex formatting" do
result = @scope.function_sprintf(
[ "<%.8s:%#5o %#8X (%-8s)>",
- "overlongstring", "23", "48879", "foo" ])
+ "overlongstring", "23", "48879", "foo" ])
result.should(eql("<overlong: 027 0XBEEF (foo )>"))
end
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index c437034a4..47a768469 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -357,8 +357,8 @@ describe Puppet::Parser::Lexer::TOKENS[:MLCOMMENT] do
it "should match multiple lines enclosed with '/*' and '*/'" do
@token.regex.should =~ """/*
- this is a comment
- */"""
+ this is a comment
+ */"""
end
it "should increase the lexer current line number by the amount of lines spanned by the comment" do
@@ -480,8 +480,8 @@ describe Puppet::Parser::Lexer::TOKENS[:REGEX] do
:CASE,:VARIABLE,:LBRACE,:STRING,:COLON,:LBRACE,:VARIABLE,:EQUALS,:NAME,:DIV,:NAME,:RBRACE,[:REGEX,/regex/],:COLON,:LBRACE,:NAME,:LPAREN,:STRING,:RPAREN,:RBRACE,:RBRACE
)
end
-
- end
+
+ end
it "should return the REGEX token and a Regexp" do
diff --git a/spec/unit/parser/parser_spec.rb b/spec/unit/parser/parser_spec.rb
index 2cbb80f9b..53a16e62a 100755
--- a/spec/unit/parser/parser_spec.rb
+++ b/spec/unit/parser/parser_spec.rb
@@ -32,7 +32,7 @@ describe Puppet::Parser do
parser = Puppet::Parser::Parser.new "development"
parser.known_resource_types.should equal(rtc)
end
-
+
it "should delegate importing to the known resource type loader" do
parser = Puppet::Parser::Parser.new "development"
parser.known_resource_types.loader.expects(:import).with("newfile", "current_file")
@@ -100,32 +100,32 @@ describe Puppet::Parser do
end
it "comparison operation, it should create the correct ast objects" do
- ast::ComparisonOperator.expects(:new).with {
- |h| h[:lval].is_a?(ast::Name) and h[:rval].is_a?(ast::Name) and h[:operator]=="<"
- }
- @parser.parse("if 1 < 2 { $var = 1 }")
+ ast::ComparisonOperator.expects(:new).with {
+ |h| h[:lval].is_a?(ast::Name) and h[:rval].is_a?(ast::Name) and h[:operator]=="<"
+ }
+ @parser.parse("if 1 < 2 { $var = 1 }")
end
end
describe "when parsing if complex expressions" do
- it "should create a correct ast tree" do
- aststub = stub_everything 'ast'
- ast::ComparisonOperator.expects(:new).with {
- |h| h[:rval].is_a?(ast::Name) and h[:lval].is_a?(ast::Name) and h[:operator]==">"
- }.returns(aststub)
- ast::ComparisonOperator.expects(:new).with {
- |h| h[:rval].is_a?(ast::Name) and h[:lval].is_a?(ast::Name) and h[:operator]=="=="
- }.returns(aststub)
- ast::BooleanOperator.expects(:new).with {
- |h| h[:rval]==aststub and h[:lval]==aststub and h[:operator]=="and"
- }
- @parser.parse("if (1 > 2) and (1 == 2) { $var = 1 }")
- end
-
- it "should raise an error on incorrect expression" do
- lambda { @parser.parse("if (1 > 2 > ) or (1 == 2) { $var = 1 }") }.should raise_error
+ it "should create a correct ast tree" do
+ aststub = stub_everything 'ast'
+ ast::ComparisonOperator.expects(:new).with {
+ |h| h[:rval].is_a?(ast::Name) and h[:lval].is_a?(ast::Name) and h[:operator]==">"
+ }.returns(aststub)
+ ast::ComparisonOperator.expects(:new).with {
+ |h| h[:rval].is_a?(ast::Name) and h[:lval].is_a?(ast::Name) and h[:operator]=="=="
+ }.returns(aststub)
+ ast::BooleanOperator.expects(:new).with {
+ |h| h[:rval]==aststub and h[:lval]==aststub and h[:operator]=="and"
+ }
+ @parser.parse("if (1 > 2) and (1 == 2) { $var = 1 }")
+ end
+
+ it "should raise an error on incorrect expression" do
+ lambda { @parser.parse("if (1 > 2 > ) or (1 == 2) { $var = 1 }") }.should raise_error
end
end
@@ -194,7 +194,7 @@ describe Puppet::Parser do
it "should build a chain of 'ifs' if there's an 'elsif'" do
ast = @parser.parse(<<-PP)
- if true { notice('test') } elsif true {} else { }
+ if true { notice('test') } elsif true {} else { }
PP
end
@@ -398,12 +398,12 @@ describe Puppet::Parser do
@krt.add(Puppet::Resource::Type.new(:hostclass, "foobar", :arguments => {"biz" => nil}))
lambda { @parser.parse("class { foobar: biz => stuff }") }.should_not raise_error
end
-
+
it "should correctly mark exported resources as exported" do
@parser.parse("@@file { '/file': }")
@krt.hostclass("").code[0].exported.should be_true
end
-
+
it "should correctly mark virtual resources as virtual" do
@parser.parse("@file { '/file': }")
@krt.hostclass("").code[0].virtual.should be_true
diff --git a/spec/unit/parser/resource_spec.rb b/spec/unit/parser/resource_spec.rb
index 9d407c0e7..31bde27dd 100755
--- a/spec/unit/parser/resource_spec.rb
+++ b/spec/unit/parser/resource_spec.rb
@@ -496,7 +496,7 @@ describe Puppet::Parser::Resource do
end
it "should fail if the same param is declared twice" do
- lambda do
+ lambda do
@parser_resource = mkresource :source => @source, :parameters => [
Puppet::Parser::Resource::Param.new(
:name => :foo, :value => "bar", :source => @source
diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb
index 29dca38f4..94192a693 100755
--- a/spec/unit/parser/scope_spec.rb
+++ b/spec/unit/parser/scope_spec.rb
@@ -11,7 +11,7 @@ describe Puppet::Parser::Scope do
@scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo"))
@scope.parent = @topscope
end
-
+
it "should be able to store references to class scopes" do
lambda { @scope.class_set "myname", "myscope" }.should_not raise_error
end
@@ -500,8 +500,7 @@ describe Puppet::Parser::Scope do
assert_equal("value", scope.lookupvar("::test"), "did not look up qualified value correctly")
tests.each do |input, output|
assert_nothing_raised("Failed to scan %s" % input.inspect) do
- assert_equal(output, scope.strinterp(input),
- 'did not parserret %s correctly' % input.inspect)
+ assert_equal(output, scope.strinterp(input), 'did not parserret %s correctly' % input.inspect)
end
end
@@ -513,11 +512,17 @@ describe Puppet::Parser::Scope do
%w{d f h l w z}.each do |l|
string = "\\" + l
assert_nothing_raised do
- assert_equal(string, scope.strinterp(string),
+
+ assert_equal(
+ string, scope.strinterp(string),
+
'did not parserret %s correctly' % string)
end
- assert(logs.detect { |m| m.message =~ /Unrecognised escape/ },
+
+ assert(
+ logs.detect { |m| m.message =~ /Unrecognised escape/ },
+
"Did not get warning about escape sequence with %s" % string)
logs.clear
end
diff --git a/spec/unit/parser/templatewrapper_spec.rb b/spec/unit/parser/templatewrapper_spec.rb
index 1b4121643..9a16666fd 100755
--- a/spec/unit/parser/templatewrapper_spec.rb
+++ b/spec/unit/parser/templatewrapper_spec.rb
@@ -120,18 +120,18 @@ describe Puppet::Parser::TemplateWrapper do
@tw.result("template contents")
@tw.instance_variable_get("@one").should == "foo"
- end
+ end
- it "should not error out if one of the variables is a symbol" do
+ it "should not error out if one of the variables is a symbol" do
template_mock = mock("template", :result => "woot!")
ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
@scope.expects(:to_hash).returns(:_timestamp => "1234")
@tw.result("template contents")
- end
+ end
- %w{! . ; :}.each do |badchar|
- it "should translate #{badchar} to _ when setting the instance variables" do
+ %w{! . ; :}.each do |badchar|
+ it "should translate #{badchar} to _ when setting the instance variables" do
template_mock = mock("template", :result => "woot!")
ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
@@ -139,6 +139,6 @@ describe Puppet::Parser::TemplateWrapper do
@tw.result("template contents")
@tw.instance_variable_get("@one_").should == "foo"
- end
- end
+ end
+ end
end
diff --git a/spec/unit/property/list_spec.rb b/spec/unit/property/list_spec.rb
index 84d14478b..588e71ce1 100644
--- a/spec/unit/property/list_spec.rb
+++ b/spec/unit/property/list_spec.rb
@@ -118,7 +118,7 @@ describe list_class do
end
end
- describe "when calling insync?" do
+ describe "when calling insync?" do
it "should return true unless @should is defined and not nil" do
@property.must be_insync("foo")
end
diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb
index 0cf206d4b..4dc33708e 100755
--- a/spec/unit/provider/mount/parsed_spec.rb
+++ b/spec/unit/provider/mount/parsed_spec.rb
@@ -29,7 +29,7 @@ module ParsedMountTesting
def mkmountargs
mount = nil
- if defined? @pcount
+ if defined?(@pcount)
@pcount += 1
else
@pcount = 1
@@ -151,7 +151,7 @@ describe provider_class do
it "should write the mount to disk when :flush is called" do
old_text = @provider_class.target_object(@provider_class.default_target).read
-
+
@mount.flush
text = @provider_class.target_object(@provider_class.default_target).read
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index 861029838..54f2c0771 100755
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -39,7 +39,7 @@ describe provider do
Installed: 1:1.0
Candidate: 1:1.1
Version table:
- 1:1.0
+1:1.0
650 http://ftp.osuosl.org testing/main Packages
*** 1:1.1
100 /var/lib/dpkg/status"
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index d0c1d2622..68ffb19a4 100755
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -163,9 +163,9 @@ describe provider do
describe "when holding or unholding" do
before do
- @tempfile = stub 'tempfile', :print => nil, :close => nil, :flush => nil, :path => "/other/file"
- @tempfile.stubs(:write)
- Tempfile.stubs(:new).returns @tempfile
+ @tempfile = stub 'tempfile', :print => nil, :close => nil, :flush => nil, :path => "/other/file"
+ @tempfile.stubs(:write)
+ Tempfile.stubs(:new).returns @tempfile
end
it "should install first if holding" do
diff --git a/spec/unit/provider/package/hpux_spec.rb b/spec/unit/provider/package/hpux_spec.rb
index 32eae5189..8343c6052 100644
--- a/spec/unit/provider/package/hpux_spec.rb
+++ b/spec/unit/provider/package/hpux_spec.rb
@@ -49,4 +49,4 @@ describe provider_class do
@provider.uninstall
end
end
- end
+end
diff --git a/spec/unit/provider/package/nim_spec.rb b/spec/unit/provider/package/nim_spec.rb
index 2018f6506..5d9083b70 100755
--- a/spec/unit/provider/package/nim_spec.rb
+++ b/spec/unit/provider/package/nim_spec.rb
@@ -39,4 +39,4 @@ describe provider_class do
@provider.install
end
end
- end
+end
diff --git a/spec/unit/provider/package/pkg_spec.rb b/spec/unit/provider/package/pkg_spec.rb
index d0d933d5e..b29405e26 100644
--- a/spec/unit/provider/package/pkg_spec.rb
+++ b/spec/unit/provider/package/pkg_spec.rb
@@ -19,36 +19,36 @@ describe provider do
end
end
end
-
+
it_should_respond_to :install, :uninstall, :update, :query, :latest
-
+
it "should be versionable" do
provider.should_not be_versionable
end
-
+
it "should use :install to update" do
@provider.expects(:install)
@provider.update
end
-
+
it "should parse a line correctly" do
result = provider.parse_line("dummy 1.0@1.0-1.0 installed ----")
result.should == {:name => "dummy", :version => "1.0@1.0-1.0",
- :ensure => :present, :status => "installed",
- :provider => :pkg, :error => "ok"}
+ :ensure => :present, :status => "installed",
+ :provider => :pkg, :error => "ok"}
end
-
+
it "should fail to parse an incorrect line" do
- result = provider.parse_line("foo")
- result.should be_nil
+ result = provider.parse_line("foo")
+ result.should be_nil
end
it "should fail to list a missing package" do
@provider.expects(:pkg).with(:list, "-H", "dummy").returns "1"
@provider.query.should == {:status=>"missing", :ensure=>:absent,
- :name=>"dummy", :error=>"ok"}
+ :name=>"dummy", :error=>"ok"}
end
-
+
it "should fail to list a package when it can't parse the output line" do
@provider.expects(:pkg).with(:list, "-H", "dummy").returns "failed"
@provider.query.should == {:status=>"missing", :ensure=>:absent, :name=>"dummy", :error=>"ok"}
@@ -57,7 +57,7 @@ describe provider do
it "should list package correctly" do
@provider.expects(:pkg).with(:list, "-H", "dummy").returns "dummy 1.0@1.0-1.0 installed ----"
@provider.query.should == {:name => "dummy", :version => "1.0@1.0-1.0",
- :ensure => :present, :status => "installed",
- :provider => :pkg, :error => "ok"}
+ :ensure => :present, :status => "installed",
+ :provider => :pkg, :error => "ok"}
end
end
diff --git a/spec/unit/provider/package/pkgdmg_spec.rb b/spec/unit/provider/package/pkgdmg_spec.rb
index 3f007e01b..d4c5a9287 100755
--- a/spec/unit/provider/package/pkgdmg_spec.rb
+++ b/spec/unit/provider/package/pkgdmg_spec.rb
@@ -15,7 +15,7 @@ describe provider do
@fakehdiutilplist = Plist::Emit.dump(@fakehdiutilinfo)
@hdiutilmountargs = ["mount", "-plist", "-nobrowse", "-readonly",
- "-noidme", "-mountrandom", "/tmp"]
+ "-noidme", "-mountrandom", "/tmp"]
end
it "should not be versionable" do
@@ -76,9 +76,9 @@ describe provider do
it "should call installpkg if a flat pkg file is found instead of a .dmg image" do
@resource.stubs(:[]).with(:source).returns "/tmp/test.pkg"
@resource.stubs(:[]).with(:name).returns "testpkg"
- @provider.class.expects(:installpkgdmg).with("#{@fakepkgfile}", "testpkg").returns ""
- @provider.install
- end
+ @provider.class.expects(:installpkgdmg).with("#{@fakepkgfile}", "testpkg").returns ""
+ @provider.install
+ end
end
-
+
end
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index be45a4cc7..b7f3687c6 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -68,14 +68,14 @@ describe provider_class do
fake_data = "Loading repository data...
Reading installed packages...
-S | Repository | Name | Version | Arch
+S | Repository | Name | Version | Arch
--+----------------+-----------------------+-----------------+-------
v | SLES11-Updates | cups | 1.1.1 | x86_64
v | SLES11-Updates | mypackage | 1.3.9h-8.20.1 | x86_64"
- @provider.expects(:zypper).with("list-updates").returns fake_data
- @provider.latest.should == "1.3.9h-8.20.1"
+ @provider.expects(:zypper).with("list-updates").returns fake_data
+ @provider.latest.should == "1.3.9h-8.20.1"
end
end
- end
+end
diff --git a/spec/unit/provider/selmodule_spec.rb b/spec/unit/provider/selmodule_spec.rb
index 5f60322d8..ed20ea97f 100755
--- a/spec/unit/provider/selmodule_spec.rb
+++ b/spec/unit/provider/selmodule_spec.rb
@@ -61,6 +61,6 @@ describe provider_class do
@provider.syncversion.should == :false
end
- end
+ end
end
diff --git a/spec/unit/provider/service/daemontools_spec.rb b/spec/unit/provider/service/daemontools_spec.rb
index a2198bb9d..2d61d2322 100755
--- a/spec/unit/provider/service/daemontools_spec.rb
+++ b/spec/unit/provider/service/daemontools_spec.rb
@@ -163,4 +163,4 @@ describe provider_class do
end
end
- end
+end
diff --git a/spec/unit/provider/service/debian_spec.rb b/spec/unit/provider/service/debian_spec.rb
index ea87c375d..08cf50c27 100755
--- a/spec/unit/provider/service/debian_spec.rb
+++ b/spec/unit/provider/service/debian_spec.rb
@@ -57,25 +57,25 @@ describe provider_class do
@provider.disable
end
end
-
+
describe "when checking whether it is enabled" do
it "should call Kernel.system() with the appropriate parameters" do
@provider.expects(:system).with("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start").once
@provider.enabled?
end
-
+
it "should return true when invoke-rc.d exits with 104 status" do
@provider.stubs(:system)
$?.stubs(:exitstatus).returns(104)
@provider.enabled?.should == :true
end
-
+
it "should return true when invoke-rc.d exits with 106 status" do
@provider.stubs(:system)
$?.stubs(:exitstatus).returns(106)
@provider.enabled?.should == :true
end
-
+
# pick a range of non-[104.106] numbers, strings and booleans to test with.
[-100, -1, 0, 1, 100, "foo", "", :true, :false].each do |exitstatus|
it "should return false when invoke-rc.d exits with #{exitstatus} status" do
@@ -86,4 +86,4 @@ describe provider_class do
end
end
- end
+end
diff --git a/spec/unit/provider/service/init_spec.rb b/spec/unit/provider/service/init_spec.rb
index 6dd42f54c..a685cc0d0 100755
--- a/spec/unit/provider/service/init_spec.rb
+++ b/spec/unit/provider/service/init_spec.rb
@@ -18,13 +18,13 @@ describe provider_class do
@resource.stubs(:[]).with(:path).returns ["/service/path","/alt/service/path"]
# @resource.stubs(:ref).returns "Service[myservice]"
File.stubs(:directory?).returns(true)
-
+
@provider = provider_class.new
@provider.resource = @resource
end
describe "when getting all service instances" do
- before :each do
+ before :each do
@services = ['one', 'two', 'three', 'four']
Dir.stubs(:entries).returns @services
FileTest.stubs(:directory?).returns(true)
@@ -59,14 +59,14 @@ describe provider_class do
@class.expects(:new).with{|hash| hash[:path] == @class.defpath}.returns("#{inst}_instance")
end
results = @services.sort.collect {|x| "#{x}_instance"}
- @class.instances.sort.should == results
+ @class.instances.sort.should == results
end
it "should set hasstatus to true for providers" do
@services.each do |inst|
@class.expects(:new).with{|hash| hash[:name] == inst && hash[:hasstatus] == true}.returns("#{inst}_instance")
end
results = @services.collect {|x| "#{x}_instance"}
- @class.instances.should == results
+ @class.instances.should == results
end
end
@@ -95,18 +95,18 @@ describe provider_class do
lambda { @provider.initscript }.should raise_error(Puppet::Error, "Could not find init script for 'myservice'")
end
end
-
+
describe "if the init script is present" do
before :each do
File.stubs(:stat).with("/service/path/myservice").returns true
end
-
+
[:start, :stop, :status, :restart].each do |method|
it "should have a #{method} method" do
@provider.should respond_to(method)
end
describe "when running #{method}" do
-
+
it "should use any provided explicit command" do
@resource.stubs(:[]).with(method).returns "/user/specified/command"
@provider.expects(:execute).with { |command, *args| command == ["/user/specified/command"] }
@@ -117,7 +117,7 @@ describe provider_class do
@resource.stubs(:[]).with("has#{method}".intern).returns :true
@provider.expects(:execute).with { |command, *args| command == ["/service/path/myservice",method]}
@provider.send(method)
- end
+ end
end
end
diff --git a/spec/unit/provider/service/launchd_spec.rb b/spec/unit/provider/service/launchd_spec.rb
index fa86a21a5..62570e2a8 100755
--- a/spec/unit/provider/service/launchd_spec.rb
+++ b/spec/unit/provider/service/launchd_spec.rb
@@ -33,10 +33,10 @@ describe provider_class do
@provider.stubs(:plist_from_label).returns([@joblabel, @jobplist])
@provider.stubs(:execute).returns("")
@provider.stubs(:resource).returns @resource
-
+
# We stub this out for the normal case as 10.6 is "special".
provider_class.stubs(:get_macosx_version_major).returns("10.5")
-
+
end
it "should have a start method for #{@provider.object_id}" do
@@ -78,7 +78,7 @@ describe provider_class do
@provider.status.should == :running
end
end
-
+
describe "when checking whether the service is enabled" do
it "should return true if the job plist says disabled is false" do
@provider.stubs(:plist_from_label).returns(["foo", {"Disabled" => false}])
@@ -93,7 +93,7 @@ describe provider_class do
@provider.enabled?.should == :false
end
end
-
+
describe "when checking whether the service is enabled on OS X 10.6" do
it "should return true if the job plist says disabled is true and the global overrides says disabled is false" do
provider_class.stubs(:get_macosx_version_major).returns("10.6")
@@ -178,7 +178,7 @@ describe provider_class do
@provider.stop
end
end
-
+
describe "when enabling the service on OS X 10.6" do
it "should write to the global launchd overrides file once" do
provider_class.stubs(:get_macosx_version_major).returns("10.6")
@@ -187,7 +187,7 @@ describe provider_class do
@provider.enable
end
end
-
+
describe "when disabling the service on OS X 10.6" do
it "should write to the global launchd overrides file once" do
provider_class.stubs(:get_macosx_version_major).returns("10.6")
@@ -197,4 +197,4 @@ describe provider_class do
end
end
- end
+end
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 591ef2d96..0f919ac84 100755
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -20,10 +20,10 @@ describe provider_class do
FileTest.stubs(:file?).with('/sbin/service').returns true
FileTest.stubs(:executable?).with('/sbin/service').returns true
end
-
+
# test self.instances
describe "when getting all service instances" do
- before :each do
+ before :each do
@services = ['one', 'two', 'three', 'four', 'kudzu', 'functions', 'halt', 'killall', 'single', 'linuxconf']
@not_services = ['functions', 'halt', 'killall', 'single', 'linuxconf']
Dir.stubs(:entries).returns @services
@@ -62,7 +62,7 @@ describe provider_class do
@provider.should respond_to(method)
end
describe "when running #{method}" do
-
+
it "should use any provided explicit command" do
@resource.stubs(:[]).with(method).returns "/user/specified/command"
@provider.expects(:execute).with { |command, *args| command == ["/user/specified/command"] }
@@ -73,7 +73,7 @@ describe provider_class do
@resource.stubs(:[]).with("has#{method}".intern).returns :true
@provider.expects(:execute).with { |command, *args| command == ['/sbin/service', 'myservice', method.to_s]}
@provider.send(method)
- end
+ end
end
end
@@ -105,8 +105,8 @@ describe provider_class do
@provider.status.should == :running
end
it "should consider the service :stopped if it doesn't have a pid" do
- @provider.expects(:getpid).returns nil
- @provider.status.should == :stopped
+ @provider.expects(:getpid).returns nil
+ @provider.status.should == :stopped
end
end
end
diff --git a/spec/unit/provider/service/runit_spec.rb b/spec/unit/provider/service/runit_spec.rb
index dd8d0dac1..42309ee5f 100755
--- a/spec/unit/provider/service/runit_spec.rb
+++ b/spec/unit/provider/service/runit_spec.rb
@@ -137,4 +137,4 @@ describe provider_class do
end
end
- end
+end
diff --git a/spec/unit/provider/service/src_spec.rb b/spec/unit/provider/service/src_spec.rb
index 76a6cf850..eaa968f6e 100755
--- a/spec/unit/provider/service/src_spec.rb
+++ b/spec/unit/provider/service/src_spec.rb
@@ -34,12 +34,12 @@ describe provider_class do
end
end
- it "should execute the startsrc command" do
+ it "should execute the startsrc command" do
@provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:squelch => true, :failonfail => true})
@provider.start
- end
+ end
- it "should execute the stopsrc command" do
+ it "should execute the stopsrc command" do
@provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:squelch => true, :failonfail => true})
@provider.stop
end
diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
index 9fdd7f499..3b14ad3d7 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
@@ -56,24 +56,30 @@ describe provider_class do
}
it "should be able to generate a basic authorized_keys file" do
- key = mkkey({
- :name => "Just Testing",
- :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
- :type => "ssh-dss",
- :ensure => :present,
- :options => [:absent]
+
+ key = mkkey(
+ {
+ :name => "Just Testing",
+ :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
+ :type => "ssh-dss",
+ :ensure => :present,
+
+ :options => [:absent]
})
genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just Testing\n"
end
it "should be able to generate a authorized_keys file with options" do
- key = mkkey({
- :name => "root@localhost",
- :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
- :type => "ssh-rsa",
- :ensure => :present,
- :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"]
+
+ key = mkkey(
+ {
+ :name => "root@localhost",
+ :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
+ :type => "ssh-rsa",
+ :ensure => :present,
+
+ :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"]
})
genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n"
@@ -117,7 +123,7 @@ describe provider_class do
@resource.stubs(:should).with(:user).returns "random_bob"
target = "/tmp/.ssh_dir/place_to_put_authorized_keys"
@resource.stubs(:should).with(:target).returns target
- end
+ end
it "should create the directory" do
File.stubs(:exist?).with("/tmp/.ssh_dir").returns false
@@ -147,7 +153,7 @@ describe provider_class do
before :each do
@resource.stubs(:should).with(:user).returns "nobody"
@resource.stubs(:should).with(:target).returns nil
- #
+ #
# I'd like to use random_bob here and something like
#
# File.stubs(:expand_path).with("~random_bob/.ssh").returns "/users/r/random_bob/.ssh"
diff --git a/spec/unit/provider/sshkey/parsed_spec.rb b/spec/unit/provider/sshkey/parsed_spec.rb
index fc6c85dbd..4180ffbaf 100755
--- a/spec/unit/provider/sshkey/parsed_spec.rb
+++ b/spec/unit/provider/sshkey/parsed_spec.rb
@@ -11,27 +11,27 @@ describe provider_class do
@key = 'AAAAB3NzaC1yc2EAAAABIwAAAQEAzwHhxXvIrtfIwrudFqc8yQcIfMudrgpnuh1F3AV6d2BrLgu/yQE7W5UyJMUjfj427sQudRwKW45O0Jsnr33F4mUw+GIMlAAmp9g24/OcrTiB8ZUKIjoPy/cO4coxGi8/NECtRzpD/ZUPFh6OEpyOwJPMb7/EC2Az6Otw4StHdXUYw22zHazBcPFnv6zCgPx1hA7QlQDWTu4YcL0WmTYQCtMUb3FUqrcFtzGDD0ytosgwSd+JyN5vj5UwIABjnNOHPZ62EY1OFixnfqX/+dUwrFSs5tPgBF/KkC6R7tmbUfnBON6RrGEmu+ajOTOLy23qUZB4CQ53V7nyAWhzqSK+hw=='
end
- it "should parse the name from the first field" do
+ it "should parse the name from the first field" do
@provider_class.parse_line('test ssh-rsa '+@key)[:name].should == "test"
end
- it "should parse the first component of the first field as the name" do
+ it "should parse the first component of the first field as the name" do
@provider_class.parse_line('test,alias ssh-rsa '+@key)[:name].should == "test"
end
- it "should parse host_aliases from the remaining components of the first field" do
+ it "should parse host_aliases from the remaining components of the first field" do
@provider_class.parse_line('test,alias ssh-rsa '+@key)[:host_aliases].should == ["alias"]
end
- it "should parse multiple host_aliases" do
+ it "should parse multiple host_aliases" do
@provider_class.parse_line('test,alias1,alias2,alias3 ssh-rsa '+@key)[:host_aliases].should == ["alias1","alias2","alias3"]
end
- it "should not drop an empty host_alias" do
+ it "should not drop an empty host_alias" do
@provider_class.parse_line('test,alias, ssh-rsa '+@key)[:host_aliases].should == ["alias",""]
end
- it "should recognise when there are no host aliases" do
+ it "should recognise when there are no host aliases" do
@provider_class.parse_line('test ssh-rsa '+@key)[:host_aliases].should == []
end
diff --git a/spec/unit/provider/user/user_role_add_spec.rb b/spec/unit/provider/user/user_role_add_spec.rb
index 781eba428..4dbfb83be 100644
--- a/spec/unit/provider/user/user_role_add_spec.rb
+++ b/spec/unit/provider/user/user_role_add_spec.rb
@@ -68,40 +68,40 @@ describe provider_class do
end
end
- describe "when calling destroy" do
- it "should use the delete command if the user exists and is not a role" do
+ describe "when calling destroy" do
+ it "should use the delete command if the user exists and is not a role" do
@provider.stubs(:exists?).returns(true)
@provider.stubs(:is_role?).returns(false)
@provider.expects(:deletecmd)
@provider.expects(:run)
@provider.destroy
- end
+ end
- it "should use the delete command if the user is a role" do
+ it "should use the delete command if the user is a role" do
@provider.stubs(:exists?).returns(true)
@provider.stubs(:is_role?).returns(true)
@provider.expects(:deletecmd)
@provider.expects(:run)
@provider.destroy
- end
- end
+ end
+ end
- describe "when calling create_role" do
- it "should use the transition(role) if the user exists" do
+ describe "when calling create_role" do
+ it "should use the transition(role) if the user exists" do
@provider.stubs(:exists?).returns(true)
@provider.stubs(:is_role?).returns(false)
@provider.expects(:transition).with("role")
@provider.expects(:run)
@provider.create_role
- end
+ end
- it "should use the add command when role doesn't exists" do
+ it "should use the add command when role doesn't exists" do
@provider.stubs(:exists?).returns(false)
@provider.expects(:addcmd)
@provider.expects(:run)
@provider.create_role
- end
- end
+ end
+ end
describe "when allow duplicate is enabled" do
before do
diff --git a/spec/unit/rails_spec.rb b/spec/unit/rails_spec.rb
index dd8d7def4..f9c68ca37 100755
--- a/spec/unit/rails_spec.rb
+++ b/spec/unit/rails_spec.rb
@@ -176,7 +176,7 @@ describe Puppet::Rails, "when initializing a postgresql connection" do
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
Puppet.settings.stubs(:value).with(:dbsocket).returns("")
- Puppet.settings.stubs(:value).with(:dbconnections).returns(1)
+ Puppet.settings.stubs(:value).with(:dbconnections).returns(1)
Puppet::Rails.database_arguments.should == {
:adapter => "postgresql",
@@ -226,7 +226,7 @@ describe Puppet::Rails, "when initializing an Oracle connection" do
Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
- Puppet.settings.stubs(:value).with(:dbconnections).returns(1)
+ Puppet.settings.stubs(:value).with(:dbconnections).returns(1)
Puppet::Rails.database_arguments.should == {
:adapter => "oracle_enhanced",
@@ -252,7 +252,7 @@ describe Puppet::Rails, "when initializing an Oracle connection" do
:username => "testuser",
:password => "testpassword",
:database => "testname",
- :pool => 1
+ :pool => 1
}
end
end
diff --git a/spec/unit/run_spec.rb b/spec/unit/run_spec.rb
index 4c5f6b1af..4b654ea42 100755
--- a/spec/unit/run_spec.rb
+++ b/spec/unit/run_spec.rb
@@ -123,9 +123,12 @@ describe Puppet::Run do
"background" => true,
}
- Puppet::Run.expects(:new).with({
+
+ Puppet::Run.expects(:new).with(
+ {
:tags => "whatever",
:background => true,
+
})
Puppet::Run.from_pson(options)
diff --git a/spec/unit/ssl/certificate_authority/interface_spec.rb b/spec/unit/ssl/certificate_authority/interface_spec.rb
index f3b9107c5..4d76b7e70 100755
--- a/spec/unit/ssl/certificate_authority/interface_spec.rb
+++ b/spec/unit/ssl/certificate_authority/interface_spec.rb
@@ -215,7 +215,7 @@ describe Puppet::SSL::CertificateAuthority::Interface do
end
end
- describe "and :signed was provided" do
+ describe "and :signed was provided" do
it "should print a string containing all signed certificate requests and certificates" do
@ca.expects(:list).returns %w{host1 host2}
diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb
index 4b9e06cad..1ce68b3c5 100755
--- a/spec/unit/transaction/report_spec.rb
+++ b/spec/unit/transaction/report_spec.rb
@@ -165,13 +165,13 @@ describe Puppet::Transaction::Report do
describe "for times" do
it "should provide the total amount of time for each resource type" do
add_statuses(3, :file) do |status|
- status.evaluation_time = 1
+ status.evaluation_time = 1
end
add_statuses(3, :exec) do |status|
- status.evaluation_time = 2
+ status.evaluation_time = 2
end
add_statuses(3, :mount) do |status|
- status.evaluation_time = 3
+ status.evaluation_time = 3
end
@report.calculate_metrics
diff --git a/spec/unit/transaction_spec.rb b/spec/unit/transaction_spec.rb
index 999dc77e1..f0e311371 100755
--- a/spec/unit/transaction_spec.rb
+++ b/spec/unit/transaction_spec.rb
@@ -85,7 +85,7 @@ describe Puppet::Transaction do
@transaction.add_resource_status(status)
@transaction.should be_any_failed
end
-
+
it "should not consider there to be failed resources if no statuses are marked failed" do
resource = Puppet::Type.type(:notify).new :name => "yayness"
status = Puppet::Resource::Status.new(resource)
diff --git a/spec/unit/type/computer_spec.rb b/spec/unit/type/computer_spec.rb
index c81ee45ee..7522b9599 100755
--- a/spec/unit/type/computer_spec.rb
+++ b/spec/unit/type/computer_spec.rb
@@ -8,9 +8,12 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
before do
provider_class = Puppet::Type::Computer.provider(Puppet::Type::Computer.providers[0])
Puppet::Type::Computer.expects(:defaultprovider).returns provider_class
- @resource = Puppet::Type::Computer.new(
+
+ @resource = Puppet::Type::Computer.new(
+
:name => "puppetcomputertest",
:en_address => "aa:bb:cc:dd:ee:ff",
+
:ip_address => "1.2.3.4")
@properties = {}
@ensure = Puppet::Type::Computer.attrclass(:ensure).new(:resource => @resource)
diff --git a/spec/unit/type/exec_spec.rb b/spec/unit/type/exec_spec.rb
index 1eaf80390..2a3408fc8 100755
--- a/spec/unit/type/exec_spec.rb
+++ b/spec/unit/type/exec_spec.rb
@@ -58,13 +58,13 @@ describe Puppet::Type.type(:exec) do
proc { @execer.refresh }.should raise_error(Puppet::Error)
end
-
+
it "should not report a failure if the exit status is specified in a returns array" do
command = "false"
create_resource(command, "", 1, [0,1])
proc { @execer.refresh }.should_not raise_error(Puppet::Error)
end
-
+
it "should report a failure if the exit status is not specified in a returns array" do
command = "false"
create_resource(command, "", 1, [0,100])
diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb
index 2c00e50dc..a07fcba2f 100755
--- a/spec/unit/type/file/content_spec.rb
+++ b/spec/unit/type/file/content_spec.rb
@@ -173,7 +173,7 @@ describe content do
Puppet[:show_diff] = true
end
- it "should display a diff if the current contents are different from the desired content" do
+ it "should display a diff if the current contents are different from the desired content" do
@content.should = "some content"
@content.expects(:diff).returns("my diff").once
@content.expects(:print).with("my diff").once
@@ -181,7 +181,7 @@ describe content do
@content.insync?("other content")
end
- it "should not display a diff if the sum for the current contents is the same as the sum for the desired content" do
+ it "should not display a diff if the sum for the current contents is the same as the sum for the desired content" do
@content.should = "some content"
@content.expects(:diff).never
diff --git a/spec/unit/type/file/group_spec.rb b/spec/unit/type/file/group_spec.rb
index 93d09adb4..0062f0345 100755
--- a/spec/unit/type/file/group_spec.rb
+++ b/spec/unit/type/file/group_spec.rb
@@ -70,7 +70,7 @@ describe property do
@group.must be_insync(10)
end
-
+
it "should not validate that groups exist when a group is specified as an integer" do
@group.expects(:gid).never
@group.validgroup?(10)
diff --git a/spec/unit/type/file/owner_spec.rb b/spec/unit/type/file/owner_spec.rb
index a077ccec2..8b58505bd 100755
--- a/spec/unit/type/file/owner_spec.rb
+++ b/spec/unit/type/file/owner_spec.rb
@@ -7,7 +7,7 @@ property = Puppet::Type.type(:file).attrclass(:owner)
describe property do
before do
# FIXME: many of these tests exercise the provider rather than `owner`
- # and should be moved into provider tests. ~JW
+ # and should be moved into provider tests. ~JW
@provider = Puppet::Type.type(:file).provider(:posix).new
@provider.stubs(:uid).with("one").returns(1)
@@ -96,7 +96,7 @@ describe property do
@owner.must be_insync(10)
end
-
+
it "should not validate that users exist when a user is specified as an integer" do
@provider.expects(:uid).never
@provider.validuser?(10)
diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb
index 327044db6..5388dc237 100755
--- a/spec/unit/type/file_spec.rb
+++ b/spec/unit/type/file_spec.rb
@@ -195,7 +195,7 @@ describe Puppet::Type.type(:file) do
file[:path].should == "/"
end
end
-
+
describe "on Microsoft Windows systems" do
before do
Puppet.features.stubs(:posix?).returns(false)
@@ -379,8 +379,11 @@ describe Puppet::Type.type(:file) do
File.open(@file, "w", 0644) { |f| f.puts "yayness"; f.flush }
File.symlink(@file, @link)
- @resource = Puppet::Type.type(:file).new(
+
+ @resource = Puppet::Type.type(:file).new(
+
:path => @link,
+
:mode => "755"
)
@catalog.add_resource @resource
@@ -406,7 +409,7 @@ describe Puppet::Type.type(:file) do
else # @real_posix
# should recode tests using expectations instead of using the filesystem
end
-
+
describe "on Microsoft Windows systems" do
before do
Puppet.features.stubs(:posix?).returns(false)
diff --git a/spec/unit/type/macauthorization_spec.rb b/spec/unit/type/macauthorization_spec.rb
index 8785984fe..cc9f6783b 100755
--- a/spec/unit/type/macauthorization_spec.rb
+++ b/spec/unit/type/macauthorization_spec.rb
@@ -20,8 +20,8 @@ describe Puppet::Type.type(:macauthorization), "when checking macauthorization o
parameters = [:name,]
properties = [:auth_type, :allow_root, :authenticate_user, :auth_class,
- :comment, :group, :k_of_n, :mechanisms, :rule,
- :session_owner, :shared, :timeout, :tries]
+ :comment, :group, :k_of_n, :mechanisms, :rule,
+ :session_owner, :shared, :timeout, :tries]
parameters.each do |parameter|
it "should have a %s parameter" % parameter do
diff --git a/spec/unit/type/maillist_spec.rb b/spec/unit/type/maillist_spec.rb
index 585336665..5dac0519f 100755
--- a/spec/unit/type/maillist_spec.rb
+++ b/spec/unit/type/maillist_spec.rb
@@ -14,7 +14,7 @@ describe maillist do
@provider_class.stubs(:new).returns(@provider)
Puppet::Type.type(:maillist).stubs(:defaultprovider).returns(@provider_class)
-
+
@maillist = Puppet::Type.type(:maillist).new( :name => 'test' )
@catalog = Puppet::Resource::Catalog.new
diff --git a/spec/unit/type/mount_spec.rb b/spec/unit/type/mount_spec.rb
index 0cf52e8d7..30c3aafef 100755
--- a/spec/unit/type/mount_spec.rb
+++ b/spec/unit/type/mount_spec.rb
@@ -120,7 +120,7 @@ describe Puppet::Type.type(:mount)::Ensure do
@ensure.should = :defined
@ensure.sync
end
-
+
it "should not unmount itself if it is mounted and should be defined" do
@provider.stubs(:ensure).returns(:mounted)
@provider.stubs(:mounted?).returns(true)
@@ -131,7 +131,7 @@ describe Puppet::Type.type(:mount)::Ensure do
@ensure.should = :defined
@ensure.sync
end
-
+
it "should not mount itself if it is unmounted and should be defined" do
@provider.stubs(:ensure).returns(:unmounted)
@provider.stubs(:mounted?).returns(false)
@@ -186,7 +186,7 @@ describe Puppet::Type.type(:mount)::Ensure do
@ensure.should = :defined
@ensure.insync?(:mounted).should == true
end
-
+
it "should be insync if it is unmounted and should be defined" do
@ensure.should = :defined
@ensure.insync?(:unmounted).should == true
@@ -196,7 +196,7 @@ describe Puppet::Type.type(:mount)::Ensure do
@ensure.should = :present
@ensure.insync?(:mounted).should == true
end
-
+
it "should be insync if it is unmounted and should be present" do
@ensure.should = :present
@ensure.insync?(:unmounted).should == true
diff --git a/spec/unit/type/resources_spec.rb b/spec/unit/type/resources_spec.rb
index 3e65aec14..2e1cb3a55 100644
--- a/spec/unit/type/resources_spec.rb
+++ b/spec/unit/type/resources_spec.rb
@@ -23,80 +23,80 @@ describe resources do
end
describe "#generate" do
- before do
- @host1 = Puppet::Type.type(:host).new(:name => 'localhost', :ip => '127.0.0.1')
- @catalog = Puppet::Resource::Catalog.new
- @context = Puppet::Transaction.new(@catalog)
- end
-
- describe "when dealing with non-purging resources" do
- before do
- @resources = Puppet::Type.type(:resources).new(:name => 'host')
- end
-
- it "should not generate any resource" do
- @resources.generate.should be_empty
- end
+ before do
+ @host1 = Puppet::Type.type(:host).new(:name => 'localhost', :ip => '127.0.0.1')
+ @catalog = Puppet::Resource::Catalog.new
+ @context = Puppet::Transaction.new(@catalog)
end
- describe "when the catalog contains a purging resource" do
- before do
- @resources = Puppet::Type.type(:resources).new(:name => 'host', :purge => true)
- @purgeable_resource = Puppet::Type.type(:host).new(:name => 'localhost', :ip => '127.0.0.1')
- @catalog.add_resource @resources
- end
+ describe "when dealing with non-purging resources" do
+ before do
+ @resources = Puppet::Type.type(:resources).new(:name => 'host')
+ end
- it "should not generate a duplicate of that resource" do
- Puppet::Type.type(:host).stubs(:instances).returns [@host1]
- @catalog.add_resource @host1
- @resources.generate.collect { |r| r.ref }.should_not include(@host1.ref)
+ it "should not generate any resource" do
+ @resources.generate.should be_empty
+ end
end
- it "should not include the skipped users" do
- res = Puppet::Type.type(:resources).new :name => :user, :purge => true
- res.catalog = Puppet::Resource::Catalog.new
+ describe "when the catalog contains a purging resource" do
+ before do
+ @resources = Puppet::Type.type(:resources).new(:name => 'host', :purge => true)
+ @purgeable_resource = Puppet::Type.type(:host).new(:name => 'localhost', :ip => '127.0.0.1')
+ @catalog.add_resource @resources
+ end
+
+ it "should not generate a duplicate of that resource" do
+ Puppet::Type.type(:host).stubs(:instances).returns [@host1]
+ @catalog.add_resource @host1
+ @resources.generate.collect { |r| r.ref }.should_not include(@host1.ref)
+ end
- users = [
- Puppet::Type.type(:user).new(:name => "root")
- ]
- Puppet::Type.type(:user).expects(:instances).returns users
- list = res.generate
+ it "should not include the skipped users" do
+ res = Puppet::Type.type(:resources).new :name => :user, :purge => true
+ res.catalog = Puppet::Resource::Catalog.new
- names = list.collect { |r| r[:name] }
- names.should_not be_include("root")
- end
+ users = [
+ Puppet::Type.type(:user).new(:name => "root")
+ ]
+ Puppet::Type.type(:user).expects(:instances).returns users
+ list = res.generate
- describe "when generating a purgeable resource" do
- it "should be included in the generated resources" do
- Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
- @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
+ names = list.collect { |r| r[:name] }
+ names.should_not be_include("root")
end
- end
- describe "when the instance's do not have an ensure property" do
- it "should not be included in the generated resources" do
- @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo')
- Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
- @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
+ describe "when generating a purgeable resource" do
+ it "should be included in the generated resources" do
+ Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
+ @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
+ end
end
- end
- describe "when the instance's ensure property does not accept absent" do
- it "should not be included in the generated resources" do
- @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar')
- Puppet::Type.type(:host).stubs(:instances).returns [@no_absent_resource]
- @resources.generate.collect { |r| r.ref }.should_not include(@no_absent_resource.ref)
+ describe "when the instance's do not have an ensure property" do
+ it "should not be included in the generated resources" do
+ @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo')
+ Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
+ @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
+ end
+ end
+
+ describe "when the instance's ensure property does not accept absent" do
+ it "should not be included in the generated resources" do
+ @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar')
+ Puppet::Type.type(:host).stubs(:instances).returns [@no_absent_resource]
+ @resources.generate.collect { |r| r.ref }.should_not include(@no_absent_resource.ref)
+ end
end
- end
- describe "when checking the instance fails" do
- it "should not be included in the generated resources" do
- @purgeable_resource = Puppet::Type.type(:host).new(:name => 'foobar')
- Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
- @resources.expects(:check).with(@purgeable_resource).returns(false)
- @resources.generate.collect { |r| r.ref }.should_not include(@purgeable_resource.ref)
+ describe "when checking the instance fails" do
+ it "should not be included in the generated resources" do
+ @purgeable_resource = Puppet::Type.type(:host).new(:name => 'foobar')
+ Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
+ @resources.expects(:check).with(@purgeable_resource).returns(false)
+ @resources.generate.collect { |r| r.ref }.should_not include(@purgeable_resource.ref)
+ end
end
end
- end
end
end
diff --git a/spec/unit/type/schedule_spec.rb b/spec/unit/type/schedule_spec.rb
index 8807d0fa0..c81930873 100755
--- a/spec/unit/type/schedule_spec.rb
+++ b/spec/unit/type/schedule_spec.rb
@@ -41,9 +41,9 @@ end
describe Puppet::Type.type(:schedule) do
before :each do
- Puppet.settings.stubs(:value).with(:ignoreschedules).returns(false)
+ Puppet.settings.stubs(:value).with(:ignoreschedules).returns(false)
- @schedule = Puppet::Type.type(:schedule).new(:name => "testing")
+ @schedule = Puppet::Type.type(:schedule).new(:name => "testing")
end
describe Puppet::Type.type(:schedule) do
diff --git a/spec/unit/type/ssh_authorized_key_spec.rb b/spec/unit/type/ssh_authorized_key_spec.rb
index 2fc34d318..e2262df4a 100755
--- a/spec/unit/type/ssh_authorized_key_spec.rb
+++ b/spec/unit/type/ssh_authorized_key_spec.rb
@@ -92,20 +92,26 @@ describe ssh_authorized_key do
describe "when neither user nor target is specified" do
it "should raise an error" do
proc do
+
@class.create(
- :name => "Test",
- :key => "AAA",
- :type => "ssh-rsa",
- :ensure => :present)
+
+ :name => "Test",
+ :key => "AAA",
+ :type => "ssh-rsa",
+
+ :ensure => :present)
end.should raise_error(Puppet::Error)
end
end
describe "when both target and user are specified" do
it "should use target" do
+
resource = @class.create(
+
:name => "Test",
:user => "root",
+
:target => "/tmp/blah")
resource.should(:target).should == "/tmp/blah"
end
@@ -114,8 +120,11 @@ describe ssh_authorized_key do
describe "when user is specified" do
it "should determine target" do
+
resource = @class.create(
+
:name => "Test",
+
:user => "root")
target = File.expand_path("~root/.ssh/authorized_keys")
resource.should(:target).should == target
@@ -127,12 +136,15 @@ describe ssh_authorized_key do
target = File.expand_path("~root/.ssh/authorized_keys")
resource.property(:target).insync?(target).should == true
end
- end
+ end
describe "when calling validate" do
it "should not crash on a non-existant user" do
+
resource = @class.create(
+
:name => "Test",
+
:user => "ihopesuchuserdoesnotexist")
proc { resource.validate }.should_not raise_error
end
diff --git a/spec/unit/type/zone_spec.rb b/spec/unit/type/zone_spec.rb
index 679141ee9..746d62a5c 100755
--- a/spec/unit/type/zone_spec.rb
+++ b/spec/unit/type/zone_spec.rb
@@ -6,10 +6,10 @@ zone = Puppet::Type.type(:zone)
describe zone do
before do
- zone = Puppet::Type.type(:zone)
+ zone = Puppet::Type.type(:zone)
provider = stub 'provider'
- provider.stubs(:name).returns(:solaris)
- zone.stubs(:defaultprovider).returns(provider)
+ provider.stubs(:name).returns(:solaris)
+ zone.stubs(:defaultprovider).returns(provider)
resource = stub 'resource', :resource => nil, :provider => provider, :line => nil, :file => nil
end
@@ -38,13 +38,11 @@ describe zone do
end
it "should be invalid when :ip has a \":\" and iptype is :exclusive" do
- lambda { zone.new(:name => "dummy", :ip => "if:1.2.3.4",
- :iptype => :exclusive) }.should raise_error
+ lambda { zone.new(:name => "dummy", :ip => "if:1.2.3.4", :iptype => :exclusive) }.should raise_error
end
it "should be invalid when :ip has two \":\" and iptype is :exclusive" do
- lambda { zone.new(:name => "dummy", :ip => "if:1.2.3.4:2.3.4.5",
- :iptype => :exclusive) }.should raise_error
+ lambda { zone.new(:name => "dummy", :ip => "if:1.2.3.4:2.3.4.5", :iptype => :exclusive) }.should raise_error
end
it "should be valid when :iptype is :shared and using interface and ip" do
@@ -56,8 +54,7 @@ describe zone do
end
it "should be valid when :iptype is :exclusive and using interface" do
- zone.new(:name => "dummy", :path => "/dummy", :ip => "if",
- :iptype => :exclusive)
+ zone.new(:name => "dummy", :path => "/dummy", :ip => "if", :iptype => :exclusive)
end
end
diff --git a/spec/unit/util/cache_accumulator_spec.rb b/spec/unit/util/cache_accumulator_spec.rb
index 2d976d0b1..3b5d68118 100644
--- a/spec/unit/util/cache_accumulator_spec.rb
+++ b/spec/unit/util/cache_accumulator_spec.rb
@@ -25,16 +25,22 @@ describe Puppet::Util::CacheAccumulator do
end
it 'should delegate bulk lookups to find with appropriate arguments and returning result count' do
- @test_class.expects(:find).with(:all,
- :conditions => {:name => ['a', 'b', 'c']}
- ).returns(['a','b','c'].collect {|n| @test_class.new(n)}).once
+
+ @test_class.expects(:find).with(
+ :all,
+
+ :conditions => {:name => ['a', 'b', 'c']}
+ ).returns(['a','b','c'].collect {|n| @test_class.new(n)}).once
@test_class.accumulate_by_name('a', 'b', 'c').should == 3
end
it 'should only need find_or_create_by_name lookup for missing bulk entries' do
- @test_class.expects(:find).with(:all,
- :conditions => {:name => ['a', 'b']}
- ).returns([ @test_class.new('a') ]).once
+
+ @test_class.expects(:find).with(
+ :all,
+
+ :conditions => {:name => ['a', 'b']}
+ ).returns([ @test_class.new('a') ]).once
@test_class.expects(:find_or_create_by_name).with('b').returns(@test_class.new('b')).once
@test_class.expects(:find_or_create_by_name).with('a').never
@test_class.accumulate_by_name('a','b').should == 1
diff --git a/spec/unit/util/file_locking_spec.rb b/spec/unit/util/file_locking_spec.rb
index 35e7f781e..9a8fad1f2 100755
--- a/spec/unit/util/file_locking_spec.rb
+++ b/spec/unit/util/file_locking_spec.rb
@@ -30,7 +30,7 @@ describe Puppet::Util::FileLocking do
File.stubs(:exists?).with('/file').returns true
File.stubs(:file?).with('/file').returns true
end
-
+
it "should use a global shared mutex" do
@sync = mock 'sync'
@sync.expects(:synchronize).with(Sync::SH).once
@@ -66,7 +66,7 @@ describe Puppet::Util::FileLocking do
File.expects(:exists?).with('/file').returns false
File.expects(:open).with('/file').once
- Puppet::Util::FileLocking.readlock('/file')
+ Puppet::Util::FileLocking.readlock('/file')
end
end
@@ -150,7 +150,7 @@ describe Puppet::Util::FileLocking do
File.expects(:exists?).with('/file').returns false
File.expects(:open).with('/file', 'w', 0600).once
- Puppet::Util::FileLocking.writelock('/file')
+ Puppet::Util::FileLocking.writelock('/file')
end
end
end
diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb
index 917ad7dab..6414a37ff 100755
--- a/spec/unit/util/log_spec.rb
+++ b/spec/unit/util/log_spec.rb
@@ -15,7 +15,7 @@ describe Puppet::Util::Log do
describe Puppet::Util::Log::DestConsole do
before do
- @console = Puppet::Util::Log::DestConsole.new
+ @console = Puppet::Util::Log::DestConsole.new
end
it "should colorize if Puppet[:color] is :ansi" do
@@ -173,7 +173,7 @@ describe Puppet::Util::Log do
it "should use the source_descriptors" do
source = stub "source"
source.stubs(:source_descriptors).returns(:tags => ["tag","tag2"], :path => "path", :version => 100)
-
+
log = Puppet::Util::Log.new(:level => "notice", :message => :foo)
log.expects(:tag).with("tag")
log.expects(:tag).with("tag2")
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index 88f4ac809..3e10b59ed 100755
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -19,20 +19,20 @@ describe Puppet::Util::SELinux do
before do
end
it "should return :true if this system has SELinux enabled" do
- Selinux.expects(:is_selinux_enabled).returns 1
- selinux_support?.should be_true
+ Selinux.expects(:is_selinux_enabled).returns 1
+ selinux_support?.should be_true
end
it "should return :false if this system lacks SELinux" do
- Selinux.expects(:is_selinux_enabled).returns 0
- selinux_support?.should be_false
+ Selinux.expects(:is_selinux_enabled).returns 0
+ selinux_support?.should be_false
end
-
+
it "should return nil if /proc/mounts does not exist" do
File.stubs(:open).with("/proc/mounts").raises("No such file or directory - /proc/mounts")
read_mounts.should == nil
end
- end
+ end
describe "filesystem detection" do
before :each do
@@ -77,7 +77,7 @@ describe Puppet::Util::SELinux do
describe "realpath" do
it "should handle files that don't exist" do
- # Since I'm stubbing Pathname.new for this test,
+ # Since I'm stubbing Pathname.new for this test,
# I need to also stub the internal calls to Pathname.new,
# which happen in Pathname.dirname and Parthname.basename
# I want those to return real Pathname objects,
@@ -194,7 +194,7 @@ describe Puppet::Util::SELinux do
end
describe "set_selinux_context" do
- before :each do
+ before :each do
fh = stub 'fh', :close => nil
File.stubs(:open).with("/proc/mounts").returns fh
fh.stubs(:read_nonblock).returns(
@@ -206,7 +206,7 @@ describe Puppet::Util::SELinux do
).then.raises EOFError
end
- it "should return nil if there is no SELinux support" do
+ it "should return nil if there is no SELinux support" do
self.expects(:selinux_support?).returns false
set_selinux_context("/foo", "user_u:role_r:type_t:s0").should be_nil
end
diff --git a/spec/unit/util/settings/file_setting_spec.rb b/spec/unit/util/settings/file_setting_spec.rb
index 55ad2df8e..1fe372ccf 100755
--- a/spec/unit/util/settings/file_setting_spec.rb
+++ b/spec/unit/util/settings/file_setting_spec.rb
@@ -61,7 +61,7 @@ describe Puppet::Util::Settings::FileSetting do
describe "when reading the owner" do
it "should be root when the setting specifies root" do
- setting = FileSetting.new(:settings => mock("settings"), :owner => "root", :desc => "a setting")
+ setting = FileSetting.new(:settings => mock("settings"), :owner => "root", :desc => "a setting")
setting.owner.should == "root"
end
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index 56769af71..d7925101c 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -122,7 +122,7 @@ describe Puppet::Util::Settings do
@settings[:bool].should == true
end
- it "should not consider a cli setting of a non boolean with a boolean as an argument to be a boolean" do
+ it "should not consider a cli setting of a non boolean with a boolean as an argument to be a boolean" do
# Turn it off first
@settings[:myval] = "bob"
@settings.handlearg("--no-myval", "")
diff --git a/spec/unit/util/user_attr_spec.rb b/spec/unit/util/user_attr_spec.rb
index 57787b1a6..88f538bb8 100644
--- a/spec/unit/util/user_attr_spec.rb
+++ b/spec/unit/util/user_attr_spec.rb
@@ -20,7 +20,7 @@ describe UserAttr do
end
it "should return a hash with the name value from /etc/user_attr" do
- UserAttr.get_attributes_by_name('foo')[:name].should == 'foo'
+ UserAttr.get_attributes_by_name('foo')[:name].should == 'foo'
end
#this test is contrived
diff --git a/spec/unit/util/zaml_spec.rb b/spec/unit/util/zaml_spec.rb
index 1f21c4e29..e39dbdf99 100644
--- a/spec/unit/util/zaml_spec.rb
+++ b/spec/unit/util/zaml_spec.rb
@@ -12,7 +12,7 @@ describe "Pure ruby yaml implementation" do
[] => "--- []",
:symbol => "--- !ruby/sym symbol",
{:a => "A"} => "--- \n !ruby/sym a: A"
- }.each { |o,y|
+ }.each { |o,y|
it "should convert the #{o.class} #{o.inspect} to yaml" do
o.to_yaml.should == y
end
@@ -26,7 +26,7 @@ describe "Pure ruby yaml implementation" do
Object.new => "--- !ruby/object {}",
[Object.new] => "--- \n - !ruby/object {}",
{Object.new => Object.new} => "--- \n ? !ruby/object {}\n : !ruby/object {}"
- }.each { |o,y|
+ }.each { |o,y|
it "should convert the #{o.class} #{o.inspect} to yaml" do
o.to_yaml.should == y
end
diff --git a/test/certmgr/ca.rb b/test/certmgr/ca.rb
index 5b7944b46..969bd935f 100755
--- a/test/certmgr/ca.rb
+++ b/test/certmgr/ca.rb
@@ -12,8 +12,8 @@ class TestCA < Test::Unit::TestCase
include PuppetTest
def setup
- super
- Puppet::Util::SUIDManager.stubs(:asuser).yields
+ super
+ Puppet::Util::SUIDManager.stubs(:asuser).yields
end
def hosts
diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb
index de63fc399..ab4372c5b 100755
--- a/test/certmgr/certmgr.rb
+++ b/test/certmgr/certmgr.rb
@@ -23,8 +23,11 @@ class TestCertMgr < Test::Unit::TestCase
cert = nil
name = "testing"
newcert = proc {
- Puppet::SSLCertificates::Certificate.new(
+
+ Puppet::SSLCertificates::Certificate.new(
+
:name => name,
+
:selfsign => true
)
}
@@ -67,9 +70,12 @@ class TestCertMgr < Test::Unit::TestCase
name = "testing"
keyfile = mkPassFile
assert_nothing_raised {
- cert = Puppet::SSLCertificates::Certificate.new(
+
+ cert = Puppet::SSLCertificates::Certificate.new(
+
:name => name,
:selfsign => true,
+
:capass => keyfile
)
}
@@ -120,7 +126,9 @@ class TestCertMgr < Test::Unit::TestCase
cert = nil
assert_nothing_raised {
- cert = Puppet::SSLCertificates::Certificate.new(
+
+ cert = Puppet::SSLCertificates::Certificate.new(
+
:name => "signedcertest",
:property => "TN",
:city => "Nashville",
@@ -128,6 +136,7 @@ class TestCertMgr < Test::Unit::TestCase
:email => "luke@madstop.com",
:org => "Puppet",
:ou => "Development",
+
:encrypt => mkPassFile()
)
diff --git a/test/certmgr/inventory.rb b/test/certmgr/inventory.rb
index 9c1e19ffe..a0617525d 100755
--- a/test/certmgr/inventory.rb
+++ b/test/certmgr/inventory.rb
@@ -13,8 +13,8 @@ class TestCertInventory < Test::Unit::TestCase
Inventory = Puppet::SSLCertificates::Inventory
def setup
- super
- Puppet::Util::SUIDManager.stubs(:asuser).yields
+ super
+ Puppet::Util::SUIDManager.stubs(:asuser).yields
end
def test_format
@@ -25,9 +25,12 @@ class TestCertInventory < Test::Unit::TestCase
format = Inventory.format(cert)
end
- assert(format =~ /^0x0001 \S+ \S+ #{cert.subject}/,
- "Did not create correct format")
- end
+
+ assert(
+ format =~ /^0x0001 \S+ \S+ #{cert.subject}/,
+
+ "Did not create correct format")
+ end
def test_init
# First create a couple of certificates
@@ -42,8 +45,7 @@ class TestCertInventory < Test::Unit::TestCase
end
[cert1, cert2].each do |cert|
- assert(init.include?(cert.subject.to_s),
- "Did not catch %s" % cert.subject.to_s)
+ assert(init.include?(cert.subject.to_s), "Did not catch %s" % cert.subject.to_s)
end
end
@@ -58,7 +60,7 @@ class TestCertInventory < Test::Unit::TestCase
end
Puppet::Util::Settings.any_instance.stubs(:write)
Puppet::Util::Settings.any_instance.expects(:write).
- with(:cert_inventory, 'a').yields(file)
+ with(:cert_inventory, 'a').yields(file)
Puppet::SSLCertificates::Inventory.add(cert)
end
diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb
index d418c6771..645d43c42 100755
--- a/test/certmgr/support.rb
+++ b/test/certmgr/support.rb
@@ -25,11 +25,9 @@ class TestCertSupport < Test::Unit::TestCase
# Yay, metaprogramming
def test_keytype
[:key, :csr, :cert, :ca_cert].each do |name|
- assert(Puppet::SSLCertificates::Support.method_defined?(name),
- "No retrieval method for %s" % name)
+ assert(Puppet::SSLCertificates::Support.method_defined?(name), "No retrieval method for %s" % name)
maker = "mk_%s" % name
- assert(Puppet::SSLCertificates::Support.method_defined?(maker),
- "No maker method for %s" % name)
+ assert(Puppet::SSLCertificates::Support.method_defined?(maker), "No maker method for %s" % name)
end
end
@@ -43,7 +41,10 @@ class TestCertSupport < Test::Unit::TestCase
assert_logged(:info, /Creating a new SSL/, "Did not log about new key")
keys.each do |file|
- assert(FileTest.exists?(Puppet[file]),
+
+ assert(
+ FileTest.exists?(Puppet[file]),
+
"Did not create %s key file" % file)
end
diff --git a/test/language/ast.rb b/test/language/ast.rb
index a4d4d8773..d11c87f6d 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -23,9 +23,12 @@ class TestAST < Test::Unit::TestCase
astelse = AST::Else.new(:statements => fakeelse)
}
assert_nothing_raised {
- astif = AST::IfStatement.new(
+
+ astif = AST::IfStatement.new(
+
:test => faketest,
:statements => fakeif,
+
:else => astelse
)
}
diff --git a/test/language/functions.rb b/test/language/functions.rb
index 5463cf256..a9d7c1a7f 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -14,8 +14,11 @@ class TestLangFunctions < Test::Unit::TestCase
def test_functions
Puppet::Node::Environment.stubs(:current).returns nil
assert_nothing_raised do
+
Puppet::Parser::AST::Function.new(
+
:name => "fakefunction",
+
:arguments => AST::ASTArray.new(
:children => [nameobj("avalue")]
)
@@ -23,8 +26,11 @@ class TestLangFunctions < Test::Unit::TestCase
end
assert_raise(Puppet::ParseError) do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "fakefunction",
+
:arguments => AST::ASTArray.new(
:children => [nameobj("avalue")]
)
@@ -40,9 +46,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "fakefunction",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [nameobj("avalue")]
)
@@ -84,12 +93,14 @@ class TestLangFunctions < Test::Unit::TestCase
def test_failfunction
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "fail",
:ftype => :statement,
+
:arguments => AST::ASTArray.new(
- :children => [stringobj("this is a failure"),
- stringobj("and another")]
+ :children => [stringobj("this is a failure"), stringobj("and another")]
)
)
end
@@ -116,12 +127,14 @@ class TestLangFunctions < Test::Unit::TestCase
end
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
- :children => [stringobj("one"),
- stringobj("two")]
+ :children => [stringobj("one"), stringobj("two")]
)
)
end
@@ -142,8 +155,7 @@ class TestLangFunctions < Test::Unit::TestCase
end
# Ensure that we got the output we expected from that evaluation.
- assert_equal("template One\ntemplate \n", scope.lookupvar("output"),
- "Undefined template variables do not raise exceptions")
+ assert_equal("template One\ntemplate \n", scope.lookupvar("output"), "Undefined template variables do not raise exceptions")
# Now, fill in the last variable and make sure the whole thing
# evaluates correctly.
@@ -153,7 +165,10 @@ class TestLangFunctions < Test::Unit::TestCase
ast.evaluate(scope)
end
- assert_equal("template One\ntemplate Two\n", scope.lookupvar("output"),
+
+ assert_equal(
+ "template One\ntemplate Two\n", scope.lookupvar("output"),
+
"Templates were not handled correctly")
end
@@ -167,9 +182,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -188,7 +206,10 @@ class TestLangFunctions < Test::Unit::TestCase
ast.evaluate(scope)
end
- assert_equal("template this is yay\n", scope.lookupvar("output"),
+
+ assert_equal(
+ "template this is yay\n", scope.lookupvar("output"),
+
"Templates were not handled correctly")
end
@@ -203,9 +224,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -225,8 +249,11 @@ class TestLangFunctions < Test::Unit::TestCase
ast.evaluate(scope)
end
- assert_equal("template deprecated value\n", scope.lookupvar("output"),
- "Deprecated template variables were not handled correctly")
+
+ assert_equal(
+ "template deprecated value\n", scope.lookupvar("output"),
+
+ "Deprecated template variables were not handled correctly")
end
# Make sure that problems with kernel method visibility still exist.
@@ -236,9 +263,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -262,9 +292,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -302,7 +335,10 @@ class TestLangFunctions < Test::Unit::TestCase
fileobj = catalog.vertices.find { |r| r.title == file }
assert(fileobj, "File was not in catalog")
- assert_equal("original text\n", fileobj["content"],
+
+ assert_equal(
+ "original text\n", fileobj["content"],
+
"Template did not work")
Puppet[:filetimeout] = -5
@@ -328,9 +364,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -350,8 +389,11 @@ class TestLangFunctions < Test::Unit::TestCase
ast.evaluate(scope)
end
- assert_equal("template #{value}\n", scope.lookupvar("output"),
- "%s did not get evaluated correctly" % string.inspect)
+
+ assert_equal(
+ "template #{value}\n", scope.lookupvar("output"),
+
+ "%s did not get evaluated correctly" % string.inspect)
end
end
@@ -378,8 +420,7 @@ class TestLangFunctions < Test::Unit::TestCase
}
assert(obj, "Did not autoload function")
- assert(Puppet::Parser::Functions.environment_module.method_defined?(:function_autofunc),
- "Did not set function correctly")
+ assert(Puppet::Parser::Functions.environment_module.method_defined?(:function_autofunc), "Did not set function correctly")
end
def test_search
diff --git a/test/language/parser.rb b/test/language/parser.rb
index 18688aa40..b26982d16 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -80,8 +80,7 @@ class TestParser < Test::Unit::TestCase
@@tmpfiles << name
File.open(file, "w") { |f|
- f.puts "file { \"%s\": ensure => file, mode => 755 }\n" %
- name
+ f.puts "file { \"%s\": ensure => file, mode => 755 }\n" % name
}
end
@@ -673,8 +672,7 @@ file { "/tmp/yayness":
end
[one, two].each do |file|
- assert(@logs.detect { |l| l.message =~ /importing '#{file}'/},
- "did not import %s" % file)
+ assert(@logs.detect { |l| l.message =~ /importing '#{file}'/}, "did not import %s" % file)
end
end
@@ -743,7 +741,6 @@ file { "/tmp/yayness":
assert_nothing_raised do
result = parser.newdefine "FunTest"
end
- assert_equal(result, parser.find_definition("", "fUntEst"),
- "%s was not matched" % "fUntEst")
+ assert_equal(result, parser.find_definition("", "fUntEst"), "%s was not matched" % "fUntEst")
end
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 0bed35c14..16149a6be 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -63,29 +63,40 @@ class TestScope < Test::Unit::TestCase
# Test that the scopes convert to hash structures correctly.
# For topscope recursive vs non-recursive should be identical
assert_equal(topscope.to_hash(false), topscope.to_hash(true),
- "Recursive and non-recursive hash is identical for topscope")
+ "Recursive and non-recursive hash is identical for topscope")
# Check the variable we expect is present.
- assert_equal({"first" => "topval"}, topscope.to_hash(),
- "topscope returns the expected hash of variables")
+ assert_equal({"first" => "topval"}, topscope.to_hash(), "topscope returns the expected hash of variables")
# Now, check that midscope does the right thing in all cases.
- assert_equal({"second" => "midval"},
- midscope.to_hash(false),
- "midscope non-recursive hash contains only midscope variable")
- assert_equal({"first" => "topval", "second" => "midval"},
- midscope.to_hash(true),
- "midscope recursive hash contains topscope variable also")
+
+ assert_equal(
+ {"second" => "midval"},
+ midscope.to_hash(false),
+
+ "midscope non-recursive hash contains only midscope variable")
+
+ assert_equal(
+ {"first" => "topval", "second" => "midval"},
+ midscope.to_hash(true),
+
+ "midscope recursive hash contains topscope variable also")
# Finally, check the ability to shadow symbols by adding a shadow to
# bottomscope, then checking that we see the right stuff.
botscope.setvar("first", "shadowval")
- assert_equal({"third" => "botval", "first" => "shadowval"},
- botscope.to_hash(false),
- "botscope has the right non-recursive hash")
- assert_equal({"third" => "botval", "first" => "shadowval", "second" => "midval"},
- botscope.to_hash(true),
- "botscope values shadow parent scope values")
+
+ assert_equal(
+ {"third" => "botval", "first" => "shadowval"},
+ botscope.to_hash(false),
+
+ "botscope has the right non-recursive hash")
+
+ assert_equal(
+ {"third" => "botval", "first" => "shadowval", "second" => "midval"},
+ botscope.to_hash(true),
+
+ "botscope values shadow parent scope values")
end
def test_declarative
@@ -120,15 +131,30 @@ class TestScope < Test::Unit::TestCase
# Make sure we know what we consider to be truth.
def test_truth
- assert_equal(true, Puppet::Parser::Scope.true?("a string"),
+
+ assert_equal(
+ true, Puppet::Parser::Scope.true?("a string"),
+
"Strings not considered true")
- assert_equal(true, Puppet::Parser::Scope.true?(true),
+
+ assert_equal(
+ true, Puppet::Parser::Scope.true?(true),
+
"True considered true")
- assert_equal(false, Puppet::Parser::Scope.true?(""),
+
+ assert_equal(
+ false, Puppet::Parser::Scope.true?(""),
+
"Empty strings considered true")
- assert_equal(false, Puppet::Parser::Scope.true?(false),
+
+ assert_equal(
+ false, Puppet::Parser::Scope.true?(false),
+
"false considered true")
- assert_equal(false, Puppet::Parser::Scope.true?(:undef),
+
+ assert_equal(
+ false, Puppet::Parser::Scope.true?(:undef),
+
"undef considered true")
end
@@ -195,15 +221,15 @@ include yay
@@host { puppet: ip => \"192.168.0.3\" }
Host <<||>>"
- config = nil
- # We run it twice because we want to make sure there's no conflict
- # if we pull it up from the database.
- node = mknode
- node.merge "hostname" => node.name
- 2.times { |i|
- catalog = Puppet::Parser::Compiler.new(node).compile
- assert_instance_of(Puppet::Parser::Resource, catalog.resource(:host, "puppet"))
- assert_instance_of(Puppet::Parser::Resource, catalog.resource(:host, "myhost"))
+ config = nil
+ # We run it twice because we want to make sure there's no conflict
+ # if we pull it up from the database.
+ node = mknode
+ node.merge "hostname" => node.name
+ 2.times { |i|
+ catalog = Puppet::Parser::Compiler.new(node).compile
+ assert_instance_of(Puppet::Parser::Resource, catalog.resource(:host, "puppet"))
+ assert_instance_of(Puppet::Parser::Resource, catalog.resource(:host, "myhost"))
}
ensure
Puppet[:storeconfigs] = false
@@ -218,14 +244,15 @@ Host <<||>>"
def test_namespaces
scope = mkscope
- assert_equal([""], scope.namespaces,
+
+ assert_equal(
+ [""], scope.namespaces,
+
"Started out with incorrect namespaces")
assert_nothing_raised { scope.add_namespace("fun::test") }
- assert_equal(["fun::test"], scope.namespaces,
- "Did not add namespace correctly")
+ assert_equal(["fun::test"], scope.namespaces, "Did not add namespace correctly")
assert_nothing_raised { scope.add_namespace("yay::test") }
- assert_equal(["fun::test", "yay::test"], scope.namespaces,
- "Did not add extra namespace correctly")
+ assert_equal(["fun::test", "yay::test"], scope.namespaces, "Did not add extra namespace correctly")
end
# #629 - undef should be "" or :undef
@@ -234,10 +261,16 @@ Host <<||>>"
scope.setvar("testing", :undef)
- assert_equal(:undef, scope.lookupvar("testing", false),
+
+ assert_equal(
+ :undef, scope.lookupvar("testing", false),
+
"undef was not returned as :undef when not string")
- assert_equal("", scope.lookupvar("testing", true),
+
+ assert_equal(
+ "", scope.lookupvar("testing", true),
+
"undef was not returned as '' when string")
end
end
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 0d647f7de..14a267d99 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -412,7 +412,10 @@ class TestSnippets < Test::Unit::TestCase
def snippet_componentrequire
%w{1 2}.each do |num|
- assert_file("/tmp/testing_component_requires#{num}",
+
+ assert_file(
+ "/tmp/testing_component_requires#{num}",
+
"#{num} does not exist")
end
end
@@ -433,29 +436,22 @@ class TestSnippets < Test::Unit::TestCase
end
def snippet_fqdefinition
- assert_file("/tmp/fqdefinition",
- "Did not make file from fully-qualified definition")
+ assert_file("/tmp/fqdefinition", "Did not make file from fully-qualified definition")
end
def snippet_subclass_name_duplication
- assert_file("/tmp/subclass_name_duplication1",
- "Did not make first file from duplicate subclass names")
- assert_file("/tmp/subclass_name_duplication2",
- "Did not make second file from duplicate subclass names")
+ assert_file("/tmp/subclass_name_duplication1", "Did not make first file from duplicate subclass names")
+ assert_file("/tmp/subclass_name_duplication2", "Did not make second file from duplicate subclass names")
end
def snippet_funccomma
- assert_file("/tmp/funccomma1",
- "Did not make first file from trailing function comma")
- assert_file("/tmp/funccomma2",
- "Did not make second file from trailing function comma")
+ assert_file("/tmp/funccomma1", "Did not make first file from trailing function comma")
+ assert_file("/tmp/funccomma2", "Did not make second file from trailing function comma")
end
def snippet_arraytrailingcomma
- assert_file("/tmp/arraytrailingcomma1",
- "Did not make first file from array")
- assert_file("/tmp/arraytrailingcomma2",
- "Did not make second file from array")
+ assert_file("/tmp/arraytrailingcomma1", "Did not make first file from array")
+ assert_file("/tmp/arraytrailingcomma2", "Did not make second file from array")
end
def snippet_multipleclass
diff --git a/test/language/transportable.rb b/test/language/transportable.rb
index 7ea6a176d..247a6eda3 100755
--- a/test/language/transportable.rb
+++ b/test/language/transportable.rb
@@ -78,8 +78,11 @@ class TestTransportable < Test::Unit::TestCase
assert(objects.include?(obj), "Missing obj %s[%s]" % [obj.type, obj.name])
end
- assert_equal(found.length,
+
+ assert_equal(
+ found.length,
top.flatten.find_all { |o| o.file == :funtest }.length,
+
"Found incorrect number of objects")
end
end
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index f94fb4cec..e11de04e2 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -52,11 +52,14 @@ module PuppetTest
def self.munge_argv
require 'getoptlong'
- result = GetoptLong.new(
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--resolve", "-r", GetoptLong::REQUIRED_ARGUMENT ],
- [ "-n", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+
+ result = GetoptLong.new(
+
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--resolve", "-r", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "-n", GetoptLong::REQUIRED_ARGUMENT ],
+
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
usage = "USAGE: TESTOPTS='[-n <method> -n <method> ...] [-d]' rake [target] [target] ..."
@@ -93,7 +96,7 @@ module PuppetTest
# Find the root of the Puppet tree; this is not the test directory, but
# the parent of that dir.
def basedir(*list)
- unless defined? @@basedir
+ unless defined?(@@basedir)
Dir.chdir(File.dirname(__FILE__)) do
@@basedir = File.dirname(File.dirname(Dir.getwd))
end
@@ -110,7 +113,7 @@ module PuppetTest
end
def exampledir(*args)
- unless defined? @@exampledir
+ unless defined?(@@exampledir)
@@exampledir = File.join(basedir, "examples")
end
@@ -170,13 +173,16 @@ module PuppetTest
ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin"
end
@memoryatstart = Puppet::Util.memory
- if defined? @@testcount
+ if defined?(@@testcount)
@@testcount += 1
else
@@testcount = 0
end
- @configpath = File.join(tmpdir,
+
+ @configpath = File.join(
+ tmpdir,
+
"configdir" + @@testcount.to_s + "/"
)
@@ -232,7 +238,7 @@ module PuppetTest
end
def tempfile
- if defined? @@tmpfilenum
+ if defined?(@@tmpfilenum)
@@tmpfilenum += 1
else
@@tmpfilenum = 1
@@ -259,13 +265,13 @@ module PuppetTest
end
def tmpdir
- unless defined? @tmpdir and @tmpdir
+ unless defined?(@tmpdir) and @tmpdir
@tmpdir = case Facter["operatingsystem"].value
- when "Darwin"; "/private/tmp"
- when "SunOS"; "/var/tmp"
- else
- "/tmp"
- end
+ when "Darwin"; "/private/tmp"
+ when "SunOS"; "/var/tmp"
+ else
+ "/tmp"
+ end
@tmpdir = File.join(@tmpdir, "puppettesting" + Process.pid.to_s)
@@ -314,8 +320,7 @@ module PuppetTest
diff = @memoryatend - @memoryatstart
if diff > 1000
- Puppet.info "%s#%s memory growth (%s to %s): %s" %
- [self.class, @method_name, @memoryatstart, @memoryatend, diff]
+ Puppet.info "%s#%s memory growth (%s to %s): %s" % [self.class, @method_name, @memoryatstart, @memoryatend, diff]
end
# reset all of the logs
diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb
index 30387f606..d421b292f 100644
--- a/test/lib/puppettest/fakes.rb
+++ b/test/lib/puppettest/fakes.rb
@@ -36,8 +36,7 @@ module PuppetTest
def []=(param, value)
param = symbolize(param)
unless @realresource.valid_parameter?(param)
- raise Puppet::DevError, "Invalid attribute %s for %s" %
- [param, @realresource.name]
+ raise Puppet::DevError, "Invalid attribute %s for %s" % [param, @realresource.name]
end
if @realresource.attrtype(param) == :property
@should[param] = value
diff --git a/test/lib/puppettest/filetesting.rb b/test/lib/puppettest/filetesting.rb
index 1aa1cf703..605de6a73 100644
--- a/test/lib/puppettest/filetesting.rb
+++ b/test/lib/puppettest/filetesting.rb
@@ -88,9 +88,7 @@ module PuppetTest::FileTesting
tolist = file_list(todir).sort
fromlist.sort.zip(tolist.sort).each { |a,b|
- assert_equal(a, b,
- "Fromfile %s with length %s does not match tofile %s with length %s" %
- [a, fromlist.length, b, tolist.length])
+ assert_equal(a, b, "Fromfile %s with length %s does not match tofile %s with length %s" % [a, fromlist.length, b, tolist.length])
}
#assert_equal(fromlist,tolist)
@@ -103,18 +101,21 @@ module PuppetTest::FileTesting
fromstat = File.stat(fromfile)
tostat = File.stat(tofile)
[:ftype,:gid,:mode,:uid].each { |method|
+
assert_equal(
- fromstat.send(method),
- tostat.send(method)
- )
- next if fromstat.ftype == "directory"
- if checked < 10 and i % 3 == 0
- from = File.open(fromfile) { |f| f.read }
- to = File.open(tofile) { |f| f.read }
+ fromstat.send(method),
+
+ tostat.send(method)
+ )
+
+ next if fromstat.ftype == "directory"
+ if checked < 10 and i % 3 == 0
+ from = File.open(fromfile) { |f| f.read }
+ to = File.open(tofile) { |f| f.read }
- assert_equal(from,to)
- checked += 1
+ assert_equal(from,to)
+ checked += 1
end
}
}
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index 5ca5123e8..f4f0eeb44 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -12,7 +12,7 @@ module PuppetTest::ParserTesting
attr_writer :evaluate
def evaluated?
- defined? @evaluated and @evaluated
+ defined?(@evaluated) and @evaluated
end
def evaluate(*args)
@@ -101,11 +101,14 @@ module PuppetTest::ParserTesting
title = stringobj(title)
end
assert_nothing_raised("Could not create %s %s" % [type, title]) {
+
return AST::Resource.new(
+
:file => __FILE__,
:line => __LINE__,
:title => title,
:type => type,
+
:parameters => resourceinst(params)
)
}
@@ -119,10 +122,13 @@ module PuppetTest::ParserTesting
def resourceoverride(type, title, params)
assert_nothing_raised("Could not create %s %s" % [type, name]) {
+
return AST::ResourceOverride.new(
+
:file => __FILE__,
:line => __LINE__,
:object => resourceref(type, title),
+
:type => type,
:parameters => resourceinst(params)
)
@@ -131,10 +137,13 @@ module PuppetTest::ParserTesting
def resourceref(type, title)
assert_nothing_raised("Could not create %s %s" % [type, title]) {
+
return AST::ResourceReference.new(
+
:file => __FILE__,
:line => __LINE__,
:type => type,
+
:title => stringobj(title)
)
}
@@ -148,34 +157,46 @@ module PuppetTest::ParserTesting
def nameobj(name)
assert_nothing_raised("Could not create name %s" % name) {
+
return AST::Name.new(
- :file => tempfile(),
- :line => rand(100),
- :value => name
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :value => name
+ )
}
end
def typeobj(name)
assert_nothing_raised("Could not create type %s" % name) {
+
return AST::Type.new(
- :file => tempfile(),
- :line => rand(100),
- :value => name
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :value => name
+ )
}
end
def nodedef(name)
assert_nothing_raised("Could not create node %s" % name) {
+
return AST::NodeDef.new(
+
:file => tempfile(),
+
:line => rand(100),
:names => nameobj(name),
- :code => AST::ASTArray.new(
- :children => [
- varobj("%svar" % name, "%svalue" % name),
- fileobj("/%s" % name)
+
+ :code => AST::ASTArray.new(
+
+ :children => [
+ varobj("%svar" % name, "%svalue" % name),
+
+ fileobj("/%s" % name)
]
)
)
@@ -187,11 +208,14 @@ module PuppetTest::ParserTesting
params = hash.collect { |param, value|
resourceparam(param, value)
}
- return AST::ResourceInstance.new(
- :file => tempfile(),
- :line => rand(100),
- :children => params
- )
+
+ return AST::ResourceInstance.new(
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :children => params
+ )
}
end
@@ -201,21 +225,27 @@ module PuppetTest::ParserTesting
value = stringobj(value)
end
assert_nothing_raised("Could not create param %s" % param) {
+
return AST::ResourceParam.new(
- :file => tempfile(),
- :line => rand(100),
- :param => param,
- :value => value
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :param => param,
+ :value => value
+ )
}
end
def stringobj(value)
+
AST::String.new(
- :file => tempfile(),
- :line => rand(100),
- :value => value
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :value => value
+ )
end
def varobj(name, value)
@@ -223,54 +253,69 @@ module PuppetTest::ParserTesting
value = stringobj(value)
end
assert_nothing_raised("Could not create %s code" % name) {
+
return AST::VarDef.new(
- :file => tempfile(),
- :line => rand(100),
- :name => nameobj(name),
- :value => value
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :name => nameobj(name),
+ :value => value
+ )
}
end
def varref(name)
assert_nothing_raised("Could not create %s variable" % name) {
+
return AST::Variable.new(
- :file => __FILE__,
- :line => __LINE__,
- :value => name
- )
+
+ :file => __FILE__,
+ :line => __LINE__,
+
+ :value => name
+ )
}
end
def argobj(name, value)
assert_nothing_raised("Could not create %s compargument" % name) {
return AST::CompArgument.new(
- :children => [nameobj(name), stringobj(value)]
- )
+ :children => [nameobj(name), stringobj(value)]
+ )
}
end
def defaultobj(type, params)
pary = []
params.each { |p,v|
+
pary << AST::ResourceParam.new(
- :file => __FILE__,
- :line => __LINE__,
- :param => p,
- :value => stringobj(v)
- )
+
+ :file => __FILE__,
+ :line => __LINE__,
+ :param => p,
+
+ :value => stringobj(v)
+ )
}
- past = AST::ASTArray.new(
- :file => __FILE__,
- :line => __LINE__,
- :children => pary
- )
+
+ past = AST::ASTArray.new(
+
+ :file => __FILE__,
+ :line => __LINE__,
+
+ :children => pary
+ )
assert_nothing_raised("Could not create defaults for %s" % type) {
+
return AST::ResourceDefaults.new(
+
:file => __FILE__,
:line => __LINE__,
:type => type,
+
:parameters => past
)
}
@@ -283,9 +328,12 @@ module PuppetTest::ParserTesting
def functionobj(function, name, ftype = :statement)
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => function,
:ftype => ftype,
+
:arguments => AST::ASTArray.new(
:children => [nameobj(name)]
)
diff --git a/test/lib/puppettest/railstesting.rb b/test/lib/puppettest/railstesting.rb
index 04ed0bf09..3af593762 100644
--- a/test/lib/puppettest/railstesting.rb
+++ b/test/lib/puppettest/railstesting.rb
@@ -32,8 +32,11 @@ module PuppetTest::RailsTesting
# Now build a resource
resources = []
- resources << mkresource(:type => type, :title => title, :exported => true,
- :parameters => params)
+
+ resources << mkresource(
+ :type => type, :title => title, :exported => true,
+
+ :parameters => params)
# Now collect our facts
facts = Facter.to_hash
diff --git a/test/lib/puppettest/resourcetesting.rb b/test/lib/puppettest/resourcetesting.rb
index 2e4db1d76..0949dfff4 100644
--- a/test/lib/puppettest/resourcetesting.rb
+++ b/test/lib/puppettest/resourcetesting.rb
@@ -4,9 +4,15 @@ module PuppetTest::ResourceTesting
def mkevaltest(parser = nil)
parser ||= mkparser
- @parser.newdefine("evaltest",
+
+ @parser.newdefine(
+ "evaltest",
+
:arguments => [%w{one}, ["two", stringobj("755")]],
- :code => resourcedef("file", "/tmp",
+
+ :code => resourcedef(
+ "file", "/tmp",
+
"owner" => varref("one"), "mode" => varref("two"))
)
end
diff --git a/test/lib/puppettest/servertest.rb b/test/lib/puppettest/servertest.rb
index d658ddba7..bda99c66a 100644
--- a/test/lib/puppettest/servertest.rb
+++ b/test/lib/puppettest/servertest.rb
@@ -6,7 +6,7 @@ module PuppetTest::ServerTest
def setup
super
- if defined? @@port
+ if defined?(@@port)
@@port += 1
else
@@port = 20000
@@ -47,8 +47,11 @@ module PuppetTest::ServerTest
# then create the actual server
server = nil
assert_nothing_raised {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => handlers
)
}
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index 4d9dd2129..db850d699 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -55,7 +55,7 @@ module PuppetTest::Support::Utils
else
puts id
end
- unless defined? @me
+ unless defined?(@me)
raise "Could not retrieve user name; 'id' did not work"
end
end
diff --git a/test/network/authconfig.rb b/test/network/authconfig.rb
index b619bec7e..6437aefea 100755
--- a/test/network/authconfig.rb
+++ b/test/network/authconfig.rb
@@ -43,16 +43,11 @@ class TestAuthConfig < Test::Unit::TestCase
}
assert_nothing_raised {
- assert(config.allowed?(request("pelementserver.describe",
- "culain.madstop.com", "1.1.1.1")), "Did not allow host")
- assert(! config.allowed?(request("pelementserver.describe",
- "culain.madstop.com", "10.10.1.1")), "Allowed host")
- assert(config.allowed?(request("fileserver.yay",
- "culain.madstop.com", "10.1.1.1")), "Did not allow host to fs")
- assert(! config.allowed?(request("fileserver.yay",
- "culain.madstop.com", "10.10.1.1")), "Allowed host to fs")
- assert(config.allowed?(request("fileserver.list",
- "culain.madstop.com", "10.10.1.1")), "Did not allow host to fs.list")
+ assert(config.allowed?(request("pelementserver.describe", "culain.madstop.com", "1.1.1.1")), "Did not allow host")
+ assert(! config.allowed?(request("pelementserver.describe", "culain.madstop.com", "10.10.1.1")), "Allowed host")
+ assert(config.allowed?(request("fileserver.yay", "culain.madstop.com", "10.1.1.1")), "Did not allow host to fs")
+ assert(! config.allowed?(request("fileserver.yay", "culain.madstop.com", "10.10.1.1")), "Allowed host to fs")
+ assert(config.allowed?(request("fileserver.list", "culain.madstop.com", "10.10.1.1")), "Did not allow host to fs.list")
}
end
@@ -63,7 +58,10 @@ class TestAuthConfig < Test::Unit::TestCase
other = nil
assert_nothing_raised { other = Puppet::Network::AuthConfig.main }
- assert_equal(auth.object_id, other.object_id,
+
+ assert_equal(
+ auth.object_id, other.object_id,
+
"did not get same authconfig from class")
end
end
diff --git a/test/network/authorization.rb b/test/network/authorization.rb
index 3c1f71e49..680d5676d 100755
--- a/test/network/authorization.rb
+++ b/test/network/authorization.rb
@@ -61,8 +61,7 @@ class TestAuthConfig < Test::Unit::TestCase
auth = nil
assert_nothing_raised { auth = obj.send(:authconfig) }
assert(auth, "did not get auth")
- assert_equal(Puppet::Network::AuthConfig.main.object_id, auth.object_id,
- "did not get main authconfig")
+ assert_equal(Puppet::Network::AuthConfig.main.object_id, auth.object_id, "did not get main authconfig")
end
def test_authorize
@@ -84,7 +83,10 @@ class TestAuthConfig < Test::Unit::TestCase
# Now set our run_mode to master, so calls are allowed
Puppet.run_mode.stubs(:master?).returns true
- assert(@obj.authorized?(@request),
+
+ assert(
+ @obj.authorized?(@request),
+
"Denied call with no config file and master")
assert_logged(:debug, /Allowing/, "did not log call")
diff --git a/test/network/authstore.rb b/test/network/authstore.rb
index 93f379164..c225b246b 100755
--- a/test/network/authstore.rb
+++ b/test/network/authstore.rb
@@ -93,9 +93,15 @@ class TestAuthStore < Test::Unit::TestCase
@store.deny("*.sub.madstop.com")
}
- assert(@store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
+ assert(
+ @store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
"hostname not allowed")
- assert(! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),
+
+ assert(
+ ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),
+
"subname name allowed")
end
@@ -105,9 +111,15 @@ class TestAuthStore < Test::Unit::TestCase
@store.deny("192.168.0.0/24")
}
- assert(@store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
+ assert(
+ @store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
"hostname not allowed")
- assert(! @store.allowed?("hostname.madstop.com", "192.168.0.50"),
+
+ assert(
+ ! @store.allowed?("hostname.madstop.com", "192.168.0.50"),
+
"Host allowed over IP")
end
@@ -128,22 +140,31 @@ class TestAuthStore < Test::Unit::TestCase
def test_store
assert_nothing_raised do
- assert_nil(@store.send(:store, :allow, "*.host.com"),
+
+ assert_nil(
+ @store.send(:store, :allow, "*.host.com"),
+
"store did not return nil")
end
assert_equal([Declaration.new(:allow, "*.host.com")],
- @store.send(:instance_variable_get, "@declarations"),
+ @store.send(:instance_variable_get, "@declarations"),
"Did not store declaration")
# Now add another one and make sure it gets sorted appropriately
assert_nothing_raised do
- assert_nil(@store.send(:store, :allow, "me.host.com"),
+
+ assert_nil(
+ @store.send(:store, :allow, "me.host.com"),
+
"store did not return nil")
end
- assert_equal([
- Declaration.new(:allow, "me.host.com"),
- Declaration.new(:allow, "*.host.com")
+
+ assert_equal(
+ [
+ Declaration.new(:allow, "me.host.com"),
+
+ Declaration.new(:allow, "*.host.com")
],
@store.send(:instance_variable_get, "@declarations"),
"Did not sort declarations")
@@ -160,11 +181,17 @@ class TestAuthStore < Test::Unit::TestCase
store = Puppet::Network::AuthStore.new
assert_nothing_raised do
- assert_nil(store.allow("*"),
+
+ assert_nil(
+ store.allow("*"),
+
"allow did not return nil")
end
- assert(store.globalallow?,
+
+ assert(
+ store.globalallow?,
+
"did not enable global allow")
end
@@ -186,7 +213,10 @@ class TestAuthStore < Test::Unit::TestCase
inval$id
}.each { |pat|
- assert_raise(Puppet::AuthStoreError,
+
+ assert_raise(
+ Puppet::AuthStoreError,
+
"name '%s' was allowed" % pat) {
@store.allow(pat)
}
@@ -216,7 +246,10 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("domain.*.com")
}
- assert(!@store.allowed?("very.long.domain.name.com", "1.2.3.4"),
+
+ assert(
+ !@store.allowed?("very.long.domain.name.com", "1.2.3.4"),
+
"Long hostname allowed")
assert_raise(Puppet::AuthStoreError) {
@@ -229,14 +262,16 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("hostname.com")
%w{hostname.com Hostname.COM hostname.Com HOSTNAME.COM}.each do |name|
- assert(@store.allowed?(name, "127.0.0.1"),
- "did not allow %s" % name)
+ assert(@store.allowed?(name, "127.0.0.1"), "did not allow %s" % name)
end
end
def test_allowed?
Puppet[:trace] = false
- assert(@store.allowed?(nil, nil),
+
+ assert(
+ @store.allowed?(nil, nil),
+
"Did not default to true for local checks")
assert_raise(Puppet::DevError, "did not fail on one input") do
@store.allowed?("host.com", nil)
@@ -252,13 +287,19 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("host.madstop.com")
@store.deny("*.madstop.com")
- assert(@store.allowed?("host.madstop.com", "192.168.0.1"),
+
+ assert(
+ @store.allowed?("host.madstop.com", "192.168.0.1"),
+
"More specific allowal by name failed")
@store.allow("192.168.0.1")
@store.deny("192.168.0.0/24")
- assert(@store.allowed?("host.madstop.com", "192.168.0.1"),
+
+ assert(
+ @store.allowed?("host.madstop.com", "192.168.0.1"),
+
"More specific allowal by ip failed")
end
@@ -344,8 +385,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
end
[:name, :pattern, :length].zip(output).each do |method, value|
- assert_equal(value, @decl.send(method),
- "Got incorrect value for %s from %s" % [method, input])
+ assert_equal(value, @decl.send(method), "Got incorrect value for %s from %s" % [method, input])
end
end
@@ -365,14 +405,16 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
def test_result
["allow", :allow].each do |val|
assert_nothing_raised { @decl.type = val }
- assert_equal(true, @decl.result, "did not result to true with %s" %
- val.inspect)
+ assert_equal(true, @decl.result, "did not result to true with %s" % val.inspect)
end
[:deny, "deny"].each do |val|
assert_nothing_raised { @decl.type = val }
- assert_equal(false, @decl.result,
- "did not result to false with %s" % val.inspect)
+
+ assert_equal(
+ false, @decl.result,
+
+ "did not result to false with %s" % val.inspect)
end
["yay", 1, nil, false, true].each do |val|
@@ -391,8 +433,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
"*.HOSTNAME.Com" => %w{com hostname *},
}.each do |input, output|
- assert_equal(output, @decl.send(:munge_name, input),
- "munged %s incorrectly" % input)
+ assert_equal(output, @decl.send(:munge_name, input), "munged %s incorrectly" % input)
end
end
@@ -414,10 +455,16 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
ip_exact = Declaration.new(:allow, "192.168.0.1")
ip_range = Declaration.new(:allow, "192.168.0.*")
- assert_equal(-1, host_exact <=> host_range,
+
+ assert_equal(
+ -1, host_exact <=> host_range,
+
"exact name match did not sort first")
- assert_equal(-1, ip_exact <=> ip_range,
+
+ assert_equal(
+ -1, ip_exact <=> ip_range,
+
"exact ip match did not sort first")
# Next make sure we sort by length
@@ -431,10 +478,12 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert_equal(-1, ip24 <=> ip16, "/16 sorted before /24 in ip with masks")
# Make sure ip checks sort before host checks
- assert_equal(-1, ip_exact <=> host_exact,
- "IP exact did not sort before host exact")
+ assert_equal(-1, ip_exact <=> host_exact, "IP exact did not sort before host exact")
+
+
+ assert_equal(
+ -1, ip_range <=> host_range,
- assert_equal(-1, ip_range <=> host_range,
"IP range did not sort before host range")
host_long = Declaration.new(:allow, "*.domain.host.com")
@@ -447,20 +496,21 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert_equal(-1, host_deny <=> host_exact, "deny did not sort before allow when exact")
host_range_deny = Declaration.new(:deny, "*.host.com")
- assert_equal(-1, host_range_deny <=> host_range,
- "deny did not sort before allow when ranged")
+ assert_equal(-1, host_range_deny <=> host_range, "deny did not sort before allow when ranged")
ip_allow = Declaration.new(:allow, "192.168.0.0/16")
ip_deny = Declaration.new(:deny, "192.168.0.0/16")
- assert_equal(-1, ip_deny <=> ip_allow,
+
+ assert_equal(
+ -1, ip_deny <=> ip_allow,
+
"deny did not sort before allow in ip range")
%w{host.com *.domain.com 192.168.0.1 192.168.0.1/24}.each do |decl|
assert_equal(0, Declaration.new(:allow, decl) <=>
Declaration.new(:allow, decl),
- "Equivalent declarations for %s were considered different" %
- decl
+ "Equivalent declarations for %s were considered different" % decl
)
end
end
@@ -481,10 +531,8 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert(! host.send(:matchname?, "yay.com"), "incorrect match")
domain = Declaration.new(:allow, "*.domain.com")
- %w{host.domain.com domain.com very.long.domain.com very-long.domain.com
- }.each do |name|
- assert(domain.send(:matchname?, name),
- "Did not match %s" % name)
+ %w{host.domain.com domain.com very.long.domain.com very-long.domain.com }.each do |name|
+ assert(domain.send(:matchname?, name), "Did not match %s" % name)
end
end
end
diff --git a/test/network/client/ca.rb b/test/network/client/ca.rb
index 1741c850a..ae81547db 100755
--- a/test/network/client/ca.rb
+++ b/test/network/client/ca.rb
@@ -23,8 +23,7 @@ class TestClientCA < Test::Unit::TestCase
end
[:hostprivkey, :hostcert, :localcacert].each do |name|
- assert(FileTest.exists?(Puppet.settings[name]),
- "Did not create cert %s" % name)
+ assert(FileTest.exists?(Puppet.settings[name]), "Did not create cert %s" % name)
end
end
@@ -64,8 +63,7 @@ class TestClientCA < Test::Unit::TestCase
end
# And then make sure the cert isn't written to disk
- assert(! FileTest.exists?(Puppet[:hostcert]),
- "Invalid cert got written to disk")
+ assert(! FileTest.exists?(Puppet[:hostcert]), "Invalid cert got written to disk")
end
end
diff --git a/test/network/handler/ca.rb b/test/network/handler/ca.rb
index 503d0188d..4d1531228 100755
--- a/test/network/handler/ca.rb
+++ b/test/network/handler/ca.rb
@@ -191,8 +191,11 @@ class TestCA < Test::Unit::TestCase
server = nil
Puppet.stubs(:master?).returns true
assert_nothing_raised {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb
index f17d82bf6..357192716 100755
--- a/test/network/handler/fileserver.rb
+++ b/test/network/handler/fileserver.rb
@@ -72,8 +72,11 @@ class TestFileServer < Test::Unit::TestCase
def test_namefailures
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -95,8 +98,11 @@ class TestFileServer < Test::Unit::TestCase
# and make our fileserver
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -129,8 +135,11 @@ class TestFileServer < Test::Unit::TestCase
file = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -183,8 +192,11 @@ class TestFileServer < Test::Unit::TestCase
checks = Puppet::Network::Handler.fileserver::CHECKPARAMS
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -221,8 +233,11 @@ class TestFileServer < Test::Unit::TestCase
def test_mountroot
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -250,8 +265,11 @@ class TestFileServer < Test::Unit::TestCase
def test_recursionlevels
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -301,8 +319,11 @@ class TestFileServer < Test::Unit::TestCase
def test_listedpath
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -344,8 +365,11 @@ class TestFileServer < Test::Unit::TestCase
def test_widelists
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -384,8 +408,11 @@ class TestFileServer < Test::Unit::TestCase
checks = Puppet::Network::Handler.fileserver::CHECKPARAMS
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -425,7 +452,10 @@ class TestFileServer < Test::Unit::TestCase
# Now try to describe some sources that don't even exist
retval = nil
- assert_raise(Puppet::Network::Handler::FileServerError,
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
"Describing non-existent mount did not raise an error") {
retval = server.describe("/notmounted/" + "noexisties")
}
@@ -480,14 +510,17 @@ class TestFileServer < Test::Unit::TestCase
path #{basedir}/those
"
- }
+ }
- # create a server with the file
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => false,
- :Config => conffile
+ # create a server with the file
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
@@ -545,15 +578,16 @@ class TestFileServer < Test::Unit::TestCase
case type
when :deny
- assert_raise(Puppet::AuthorizationError,
- "Host %s, ip %s, allowed %s" %
- [host, ip, mount]) {
+
+ assert_raise(
+ Puppet::AuthorizationError,
+
+ "Host %s, ip %s, allowed %s" % [host, ip, mount]) {
list = server.list(mount, :manage, true, false, host, ip)
}
when :allow
- assert_nothing_raised("Host %s, ip %s, denied %s" %
- [host, ip, mount]) {
- list = server.list(mount, :manage, true, false, host, ip)
+ assert_nothing_raised("Host %s, ip %s, denied %s" % [host, ip, mount]) {
+ list = server.list(mount, :manage, true, false, host, ip)
}
end
}
@@ -574,8 +608,8 @@ class TestFileServer < Test::Unit::TestCase
"
}
- invalidconfigs = [
-"[not valid]
+ invalidconfigs = [
+ "[not valid]
path /this/path/does/not/exist
allow 192.168.0.*
",
@@ -589,24 +623,30 @@ class TestFileServer < Test::Unit::TestCase
"
]
- invalidmounts.each { |mount, text|
- File.open(conffile, "w") { |f|
- f.print text
+ invalidmounts.each { |mount, text|
+ File.open(conffile, "w") { |f|
+ f.print text
}
# create a server with the file
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => conffile
)
}
- assert_raise(Puppet::Network::Handler::FileServerError,
- "Invalid mount was mounted") {
- server.list(mount, :manage)
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
+ "Invalid mount was mounted") {
+ server.list(mount, :manage)
}
}
@@ -618,11 +658,17 @@ class TestFileServer < Test::Unit::TestCase
# create a server with the file
server = nil
- assert_raise(Puppet::Network::Handler::FileServerError,
- "Invalid config %s did not raise error" % i) {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => true,
- :Config => conffile
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
+ "Invalid config %s did not raise error" % i) {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => true,
+
+ :Config => conffile
)
}
}
@@ -643,29 +689,34 @@ class TestFileServer < Test::Unit::TestCase
path #{dir}
allow test1.domain.com
"
- }
+ }
- # Reset the timeout, so we reload faster
- Puppet[:filetimeout] = 0.5
+ # Reset the timeout, so we reload faster
+ Puppet[:filetimeout] = 0.5
- # start our server with a fast timeout
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => false,
- :Config => conffile
+ # start our server with a fast timeout
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
list = nil
assert_nothing_raised {
- list = server.list("/thing/", :manage, false, false,
+
+ list = server.list(
+ "/thing/", :manage, false, false,
+
"test1.domain.com", "127.0.0.1")
}
assert(list != "", "List returned nothing in rereard test")
assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
- list = server.list("/thing/", :manage, false, false,
- "test2.domain.com", "127.0.0.1")
+ list = server.list("/thing/", :manage, false, false, "test2.domain.com", "127.0.0.1")
}
sleep 1
@@ -676,16 +727,14 @@ class TestFileServer < Test::Unit::TestCase
path #{dir}
allow test2.domain.com
"
- }
+ }
- assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
- list = server.list("/thing/", :manage, false, false,
- "test1.domain.com", "127.0.0.1")
+ assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
+ list = server.list("/thing/", :manage, false, false, "test1.domain.com", "127.0.0.1")
}
assert_nothing_raised {
- list = server.list("/thing/", :manage, false, false,
- "test2.domain.com", "127.0.0.1")
+ list = server.list("/thing/", :manage, false, false, "test2.domain.com", "127.0.0.1")
}
assert(list != "", "List returned nothing in rereard test")
@@ -716,8 +765,11 @@ class TestFileServer < Test::Unit::TestCase
File.open(file, "w") { |f| f.puts "yay" }
File.symlink(file, link)
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -773,8 +825,7 @@ class TestFileServer < Test::Unit::TestCase
client1_hostdir => "client1\n",
client2_fqdndir => client2 + "\n"
}
- [fsdir, hostdir, fqdndir,
- client1_hostdir, client2_fqdndir].each { |d| Dir.mkdir(d) }
+ [fsdir, hostdir, fqdndir, client1_hostdir, client2_fqdndir].each { |d| Dir.mkdir(d) }
[client1_hostdir, client2_fqdndir].each do |d|
File.open(File.join(d, "file.txt"), "w") do |f|
@@ -791,13 +842,16 @@ allow *
path #{fqdndir}/%H
allow *
")
- end
+ end
- server = nil
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => true,
- :Config => conffile
+ server = nil
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => true,
+
+ :Config => conffile
)
}
@@ -938,34 +992,37 @@ allow *
# Do a round of checks with a fake client
client = "host.domain.com"
{"%h" => "host", # Short name
- "%H" => client, # Full name
- "%d" => "domain.com", # domain
- "%%" => "%", # escape
- "%o" => "%o" # other
- }.each do |pat, repl|
- result = check.call(client, pat, repl)
- end
+ "%H" => client, # Full name
+ "%d" => "domain.com", # domain
+ "%%" => "%", # escape
+ "%o" => "%o" # other
+ }.each do |pat, repl|
+ result = check.call(client, pat, repl)
+ end
# Now, check that they use Facter info
client = nil
Facter.stubs(:value).with { |v| v.to_s == "hostname" }.returns("myhost")
Facter.stubs(:value).with { |v| v.to_s == "domain" }.returns("mydomain.com")
- Facter.stubs(:to_hash).returns({
- :ipaddress => "127.0.0.1",
- :hostname => "myhost",
- :domain => "mydomain.com",
+
+ Facter.stubs(:to_hash).returns(
+ {
+ :ipaddress => "127.0.0.1",
+ :hostname => "myhost",
+ :domain => "mydomain.com",
+
})
{"%h" => "myhost", # Short name
- "%H" => "myhost.mydomain.com", # Full name
- "%d" => "mydomain.com", # domain
- "%%" => "%", # escape
- "%o" => "%o" # other
- }.each do |pat, repl|
- check.call(client, pat, repl)
- end
+ "%H" => "myhost.mydomain.com", # Full name
+ "%d" => "mydomain.com", # domain
+ "%%" => "%", # escape
+ "%o" => "%o" # other
+ }.each do |pat, repl|
+ check.call(client, pat, repl)
+ end
end
@@ -973,8 +1030,11 @@ allow *
def test_fileserver_expansion
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -986,11 +1046,14 @@ allow *
ip = '127.0.0.1'
- Facter.stubs(:to_hash).returns({
- :kernel => kernel_fact,
- :ipaddress => "127.0.0.1",
- :hostname => "myhost",
- :domain => "mydomain.com",
+
+ Facter.stubs(:to_hash).returns(
+ {
+ :kernel => kernel_fact,
+ :ipaddress => "127.0.0.1",
+ :hostname => "myhost",
+ :domain => "mydomain.com",
+
})
Dir.mkdir(dir)
@@ -1047,7 +1110,7 @@ allow *
File::open(file, "w") { |f| f.print name }
end
- Puppet::Module::find(name)
+ Puppet::Module::find(name)
end
conffile = tempfile
@@ -1057,8 +1120,11 @@ allow *
# create a server with the file
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler::FileServer.new(
+
:Local => false ,
+
:Config => conffile
)
}
@@ -1080,8 +1146,7 @@ allow *
end
assert_nothing_raised("Host 'allow' denied #{mount}") {
- server.list(mount, :manage, true, false,
- 'allow.example.com', "192.168.0.1")
+ server.list(mount, :manage, true, false, 'allow.example.com', "192.168.0.1")
}
end
end
@@ -1109,14 +1174,17 @@ allow *
path #{basedir}/thing
allow 192.168.0.*
"
- }
+ }
- # create a server with the file
- server = nil
- assert_nothing_raised {
- server = Puppet::Network::Handler::FileServer.new(
- :Local => false,
- :Config => conffile
+ # create a server with the file
+ server = nil
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler::FileServer.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
@@ -1136,14 +1204,15 @@ allow *
assert_describe(mount, file, server)
# now let's check that things are being correctly forbidden
- assert_raise(Puppet::AuthorizationError,
- "Host 'deny' allowed #{mount}") {
- server.list(mount, :manage, true, false,
- 'deny.example.com', "192.168.1.1")
+
+ assert_raise(
+ Puppet::AuthorizationError,
+
+ "Host 'deny' allowed #{mount}") {
+ server.list(mount, :manage, true, false, 'deny.example.com', "192.168.1.1")
}
assert_nothing_raised("Host 'allow' denied #{mount}") {
- server.list(mount, :manage, true, false,
- 'allow.example.com', "192.168.0.1")
+ server.list(mount, :manage, true, false, 'allow.example.com', "192.168.0.1")
}
end
@@ -1161,8 +1230,11 @@ allow *
].each do |failer|
File.open(config, "w") { |f| f.puts failer }
assert_raise(Puppet::Network::Handler::FileServerError, "Did not fail on %s" % failer.inspect) {
+
server = Puppet::Network::Handler::FileServer.new(
+
:Local => false,
+
:Config => config
)
}
@@ -1172,8 +1244,8 @@ allow *
def test_can_start_without_configuration
Puppet[:fileserverconfig] = tempfile
assert_nothing_raised("Could not create fileserver when configuration is absent") do
- server = Puppet::Network::Handler::FileServer.new(
- :Local => false
+ server = Puppet::Network::Handler::FileServer.new(
+ :Local => false
)
end
end
diff --git a/test/network/rights.rb b/test/network/rights.rb
index 71b8c3765..80d6ceafe 100755
--- a/test/network/rights.rb
+++ b/test/network/rights.rb
@@ -23,7 +23,10 @@ class TestRights < Test::Unit::TestCase
@store.newright(:write)
}
- assert(! @store.allowed?(:write, "host.madstop.com", "0.0.0.0"),
+
+ assert(
+ ! @store.allowed?(:write, "host.madstop.com", "0.0.0.0"),
+
"Defaulted to allowing access")
assert_nothing_raised {
diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb
index e2493b424..7fd362b39 100755
--- a/test/network/server/webrick.rb
+++ b/test/network/server/webrick.rb
@@ -24,8 +24,11 @@ class TestWebrickServer < Test::Unit::TestCase
def test_basics
server = nil
assert_raise(Puppet::Error, "server succeeded with no cert") do
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:Status => nil
}
@@ -33,8 +36,11 @@ class TestWebrickServer < Test::Unit::TestCase
end
assert_nothing_raised("Could not create simple server") do
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
@@ -70,8 +76,11 @@ class TestWebrickServer < Test::Unit::TestCase
client = nil
assert_nothing_raised() {
- client = Puppet::Network::Client.status.new(
+
+ client = Puppet::Network::Client.status.new(
+
:Server => "localhost",
+
:Port => @@port
)
}
@@ -82,8 +91,11 @@ class TestWebrickServer < Test::Unit::TestCase
server = nil
Puppet[:certdnsnames] = "localhost"
assert_nothing_raised() {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
diff --git a/test/network/xmlrpc/processor.rb b/test/network/xmlrpc/processor.rb
index 079194efa..0b0646728 100755
--- a/test/network/xmlrpc/processor.rb
+++ b/test/network/xmlrpc/processor.rb
@@ -65,8 +65,7 @@ class TestXMLRPCProcessor < Test::Unit::TestCase
request.expects(:method=).with("mymethod")
@processor.stubs(:verify)
- @processor.expects(:handle).with(request.call,
- "params", request.name, request.ip)
+ @processor.expects(:handle).with(request.call, "params", request.name, request.ip)
@processor.send(:process, ["myhandler.mymethod", ["params"]], request)
end
diff --git a/test/network/xmlrpc/server.rb b/test/network/xmlrpc/server.rb
index ae9f17ddf..88652a261 100755
--- a/test/network/xmlrpc/server.rb
+++ b/test/network/xmlrpc/server.rb
@@ -18,8 +18,7 @@ class TestXMLRPCServer < Test::Unit::TestCase
assert(@server.get_service_hook, "no service hook defined")
assert_nothing_raised("Did not init @loadedhandlers") do
- assert(! @server.handler_loaded?(:puppetca),
- "server thinks handlers are loaded")
+ assert(! @server.handler_loaded?(:puppetca), "server thinks handlers are loaded")
end
end
end
diff --git a/test/network/xmlrpc/webrick_servlet.rb b/test/network/xmlrpc/webrick_servlet.rb
index 1d83d36ad..d3daa4c0d 100755
--- a/test/network/xmlrpc/webrick_servlet.rb
+++ b/test/network/xmlrpc/webrick_servlet.rb
@@ -24,7 +24,10 @@ class TestXMLRPCWEBrickServlet < Test::Unit::TestCase
assert(servlet.get_service_hook, "service hook was not set up")
- assert(servlet.handler_loaded?(:puppetca),
+
+ assert(
+ servlet.handler_loaded?(:puppetca),
+
"Did not load handler")
end
end
diff --git a/test/other/relationships.rb b/test/other/relationships.rb
index e9d3a9376..abdb537a3 100755
--- a/test/other/relationships.rb
+++ b/test/other/relationships.rb
@@ -14,8 +14,11 @@ class TestRelationships < Test::Unit::TestCase
def newfile
assert_nothing_raised() {
- return Puppet::Type.type(:file).new(
+
+ return Puppet::Type.type(:file).new(
+
:path => tempfile,
+
:check => [:mode, :owner, :group]
)
}
@@ -39,8 +42,7 @@ class TestRelationships < Test::Unit::TestCase
sources.each do |source|
targets.each do |target|
edge = deps.find { |e| e.source == source and e.target == target }
- assert(edge, "Could not find edge for %s => %s" %
- [source.ref, target.ref])
+ assert(edge, "Could not find edge for %s => %s" % [source.ref, target.ref])
if refresher
assert_equal(:ALL_EVENTS, edge.event)
@@ -57,9 +59,15 @@ class TestRelationships < Test::Unit::TestCase
# We know that execs autorequire their cwd, so we'll use that
path = tempfile()
- file = Puppet::Type.type(:file).new(:title => "myfile", :path => path,
+
+ file = Puppet::Type.type(:file).new(
+ :title => "myfile", :path => path,
+
:ensure => :directory)
- exec = Puppet::Type.newexec(:title => "myexec", :cwd => path,
+
+ exec = Puppet::Type.newexec(
+ :title => "myexec", :cwd => path,
+
:command => "/bin/echo")
catalog = mk_catalog(file, exec)
diff --git a/test/other/report.rb b/test/other/report.rb
index 9e0a9bbbe..af9ecea81 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -21,8 +21,11 @@ class TestReports < Test::Unit::TestCase
# Make every third file
File.open(file, "w") { |f| f.puts "" } if i % 3 == 0
- objects << Puppet::Type.type(:file).new(
+
+ objects << Puppet::Type.type(:file).new(
+
:path => file,
+
:ensure => "file"
)
end
@@ -124,8 +127,7 @@ class TestReports < Test::Unit::TestCase
assert(FileTest.exists?(file), "Did not create rrd file for %s" % type)
daily = file.sub ".rrd", "-daily.png"
- assert(FileTest.exists?(daily),
- "Did not make daily graph for %s" % type)
+ assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type)
end
end
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 5c21755fb..5c73f1b9d 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -146,8 +146,7 @@ class TestTransactions < Test::Unit::TestCase
end
%w{ya ra y r}.each do |name|
- assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]),
- "Generated %s was not a vertex" % name)
+ assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]), "Generated %s was not a vertex" % name)
assert($finished.include?(name), "%s was not finished" % name)
end
end
@@ -323,13 +322,22 @@ class TestTransactions < Test::Unit::TestCase
path = tempfile
epath = tempfile
spath = tempfile
- file = Puppet::Type.type(:file).new(:path => path, :ensure => :file,
+
+ file = Puppet::Type.type(:file).new(
+ :path => path, :ensure => :file,
+
:title => "file")
- exec = Puppet::Type.type(:exec).new(:command => "touch %s" % epath,
+
+ exec = Puppet::Type.type(:exec).new(
+ :command => "touch %s" % epath,
:path => ENV["PATH"], :subscribe => file, :refreshonly => true,
+
:title => 'exec1')
- exec2 = Puppet::Type.type(:exec).new(:command => "touch %s" % spath,
+
+ exec2 = Puppet::Type.type(:exec).new(
+ :command => "touch %s" % spath,
:path => ENV["PATH"], :subscribe => exec, :refreshonly => true,
+
:title => 'exec2')
Puppet[:noop] = true
@@ -347,11 +355,17 @@ class TestTransactions < Test::Unit::TestCase
assert(@logs.detect { |l|
l.message =~ /should be/ and l.source == file.property(:ensure).path},
"did not log file change")
- assert(@logs.detect { |l|
+
+ assert(
+ @logs.detect { |l|
l.message =~ /Would have/ and l.source == exec.path },
+
"did not log first exec trigger")
- assert(@logs.detect { |l|
+
+ assert(
+ @logs.detect { |l|
l.message =~ /Would have/ and l.source == exec2.path },
+
"did not log second exec trigger")
end
@@ -361,7 +375,10 @@ class TestTransactions < Test::Unit::TestCase
3.times do |i|
path = tempfile
paths << path
- file = Puppet::Type.type(:file).new(:path => path, :ensure => :absent,
+
+ file = Puppet::Type.type(:file).new(
+ :path => path, :ensure => :absent,
+
:backup => false, :title => "file%s" % i)
File.open(path, "w") { |f| f.puts "" }
files << file
diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb
index bab6644d2..86c67e0be 100755
--- a/test/puppet/defaults.rb
+++ b/test/puppet/defaults.rb
@@ -49,8 +49,7 @@ class TestPuppetDefaults < Test::Unit::TestCase
value = Puppet[param]
unless value !~ notval
- assert_nothing_raised { raise "%s is incorrectly set to %s" %
- [param,value] }
+ assert_nothing_raised { raise "%s is incorrectly set to %s" % [param,value] }
end
}
end
diff --git a/test/puppet/tc_suidmanager.rb b/test/puppet/tc_suidmanager.rb
index 2075427f8..0d51ddacd 100755
--- a/test/puppet/tc_suidmanager.rb
+++ b/test/puppet/tc_suidmanager.rb
@@ -81,16 +81,19 @@ class TestSUIDManager < Test::Unit::TestCase
else
set_exit_status!
- Puppet::Util.expects(:execute).with( 'yay',
- { :failonfail => false,
- :uid => @user.uid,
- :gid => @user.gid }
- ).returns('output')
+
+ Puppet::Util.expects(:execute).with(
+ 'yay',
+ { :failonfail => false,
+ :uid => @user.uid,
+
+ :gid => @user.gid }
+ ).returns('output')
output = Puppet::Util::SUIDManager.run_and_capture 'yay',
- @user.uid,
- @user.gid
+ @user.uid,
+ @user.gid
assert_equal 'output', output.first
assert_kind_of Process::Status, output.last
@@ -119,8 +122,8 @@ class TestSUIDManager < Test::Unit::TestCase
end
def set_exit_status!
- # We want to make sure $? is set, this is the only way I know how.
- Kernel.system '' if $?.nil?
+ # We want to make sure $? is set, this is the only way I know how.
+ Kernel.system '' if $?.nil?
end
end
diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb
index 60bbdc06c..73d6ab664 100755
--- a/test/rails/railsparameter.rb
+++ b/test/rails/railsparameter.rb
@@ -28,10 +28,13 @@ class TestRailsParameter < Test::Unit::TestCase
host.save
- resource = host.resources.create(
- :title => "/tmp/to_resource",
- :restype => "file",
- :exported => true)
+
+ resource = host.resources.create(
+
+ :title => "/tmp/to_resource",
+ :restype => "file",
+
+ :exported => true)
# Use array and non-array values, to make sure we get things back in
# the same form.
@@ -43,8 +46,11 @@ class TestRailsParameter < Test::Unit::TestCase
values = [value]
end
valueobjects = values.collect do |v|
- resource.param_values.create(:value => v,
- :param_name => param)
+
+ resource.param_values.create(
+ :value => v,
+
+ :param_name => param)
end
assert(param, "Did not create rails parameter")
diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb
index 5ddd27f97..4502a3258 100755
--- a/test/ral/manager/attributes.rb
+++ b/test/ral/manager/attributes.rb
@@ -43,13 +43,14 @@ class TestTypeAttributes < Test::Unit::TestCase
if param == :property
assert(inst.property(param), "did not get obj for %s" % param)
- assert_equal(true, inst.should(param),
+
+ assert_equal(
+ true, inst.should(param),
+
"should value did not get set")
else
- assert_equal(true, inst[param],
- "did not get correct value for %s from symbol" % param)
- assert_equal(true, inst[param.to_s],
- "did not get correct value for %s from string" % param)
+ assert_equal(true, inst[param], "did not get correct value for %s from symbol" % param)
+ assert_equal(true, inst[param.to_s], "did not get correct value for %s from string" % param)
end
end
end
@@ -94,7 +95,10 @@ class TestTypeAttributes < Test::Unit::TestCase
assert(klass, "did not get class for %s" % name)
obj = yield inst, klass
assert_instance_of(klass, obj, "did not get object back")
- assert_equal("value", inst.value(klass.name),
+
+ assert_equal(
+ "value", inst.value(klass.name),
+
"value was not correct from value method")
assert_equal("value", obj.value, "value was not correct")
end
@@ -159,8 +163,7 @@ class TestTypeAttributes < Test::Unit::TestCase
end
aliases.each do |new, old|
- assert_equal(old, type.attr_alias(new), "did not return alias info for %s" %
- new)
+ assert_equal(old, type.attr_alias(new), "did not return alias info for %s" % new)
end
assert_nil(type.attr_alias(:name), "got invalid alias info for name")
@@ -176,11 +179,13 @@ class TestTypeAttributes < Test::Unit::TestCase
case old
when :one # param
- assert_equal(val, inst[new],
+
+ assert_equal(
+ val, inst[new],
+
"Incorrect alias value for %s in []" % new)
else
- assert_equal(val, inst.should(new),
- "Incorrect alias value for %s in should" % new)
+ assert_equal(val, inst.should(new), "Incorrect alias value for %s in should" % new)
end
assert_equal(val, inst.value(new), "Incorrect alias value for %s" % new)
assert_equal(val, inst.value(old), "Incorrect orig value for %s" % old)
diff --git a/test/ral/manager/provider.rb b/test/ral/manager/provider.rb
index 48d6f2dce..82c27b6c6 100755
--- a/test/ral/manager/provider.rb
+++ b/test/ral/manager/provider.rb
@@ -37,8 +37,7 @@ class TestTypeProviders < Test::Unit::TestCase
# Make sure the provider is always the first parameter created.
def test_provider_sorting
should = [:name, :ensure]
- assert_equal(should, @type.allattrs.reject { |p| ! should.include?(p) },
- "Got wrong order of parameters")
+ assert_equal(should, @type.allattrs.reject { |p| ! should.include?(p) }, "Got wrong order of parameters")
@type.provide(:yay) { }
should = [:name, :provider, :ensure]
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index 662339419..04ecf95ea 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -10,16 +10,18 @@ class TestType < Test::Unit::TestCase
def test_typemethods
Puppet::Type.eachtype { |type|
name = nil
- assert_nothing_raised("Searching for name for %s caused failure" %
- type.to_s) {
+ assert_nothing_raised("Searching for name for %s caused failure" % type.to_s) {
name = type.name
}
assert(name, "Could not find name for %s" % type.to_s)
- assert_equal(
+
+ assert_equal(
+
type,
Puppet::Type.type(name),
+
"Failed to retrieve %s by name" % name
)
@@ -29,13 +31,19 @@ class TestType < Test::Unit::TestCase
#end
assert_nothing_raised {
- assert_not_nil(
+
+ assert_not_nil(
+
type.properties,
+
"Properties for %s are nil" % name
)
- assert_not_nil(
+
+ assert_not_nil(
+
type.validproperties,
+
"Valid properties for %s are nil" % name
)
}
@@ -43,8 +51,11 @@ class TestType < Test::Unit::TestCase
end
def test_aliases_are_added_to_catalog
- resource = Puppet::Type.type(:file).new(
+
+ resource = Puppet::Type.type(:file).new(
+
:name => "/path/to/some/missing/file",
+
:ensure => "file"
)
resource.stubs(:path).returns("")
@@ -60,8 +71,11 @@ class TestType < Test::Unit::TestCase
end
def test_aliasing_fails_without_a_catalog
- resource = Puppet::Type.type(:file).new(
+
+ resource = Puppet::Type.type(:file).new(
+
:name => "/no/such/file",
+
:ensure => "file"
)
@@ -73,8 +87,11 @@ class TestType < Test::Unit::TestCase
def test_ensuredefault
user = nil
assert_nothing_raised {
- user = Puppet::Type.type(:user).new(
+
+ user = Puppet::Type.type(:user).new(
+
:name => "pptestAA",
+
:check => [:uid]
)
}
@@ -83,8 +100,11 @@ class TestType < Test::Unit::TestCase
assert(! user.property(:ensure), "User got an ensure property")
assert_nothing_raised {
- user = Puppet::Type.type(:user).new(
+
+ user = Puppet::Type.type(:user).new(
+
:name => "pptestAB",
+
:comment => "Testingness"
)
}
@@ -92,8 +112,11 @@ class TestType < Test::Unit::TestCase
assert(user.property(:ensure), "User did not add ensure property")
assert_nothing_raised {
- user = Puppet::Type.type(:user).new(
+
+ user = Puppet::Type.type(:user).new(
+
:name => "pptestBC",
+
:comment => "A fake user"
)
}
@@ -108,7 +131,10 @@ class TestType < Test::Unit::TestCase
end
}
- assert(Puppet::Type.respond_to?(:newmytype),
+
+ assert(
+ Puppet::Type.respond_to?(:newmytype),
+
"new<type> method did not get created")
obj = nil
@@ -144,8 +170,7 @@ class TestType < Test::Unit::TestCase
newparam(:rah) do isnamevar end
end
}
- assert_equal(parammethod, Puppet::Type.method(:newparam),
- "newparam method got replaced by newtype")
+ assert_equal(parammethod, Puppet::Type.method(:newparam), "newparam method got replaced by newtype")
end
def test_newproperty_options
@@ -215,8 +240,11 @@ class TestType < Test::Unit::TestCase
path = tempfile()
assert_nothing_raised do
- file = fileclass.create(
+
+ file = fileclass.create(
+
:title => "Myfile",
+
:path => path
)
end
@@ -228,8 +256,11 @@ class TestType < Test::Unit::TestCase
# Now make sure we can specify both and still get the right answers
assert_nothing_raised do
- file = fileclass.create(
+
+ file = fileclass.create(
+
:title => "Myfile",
+
:name => path
)
end
@@ -248,15 +279,21 @@ class TestType < Test::Unit::TestCase
echo = Puppet::Util.binary "echo"
exec1 = exec2 = nil
assert_nothing_raised do
- exec1 = Puppet::Type.type(:exec).new(
+
+ exec1 = Puppet::Type.type(:exec).new(
+
:title => "exec1",
+
:command => "#{echo} funtest"
)
end
catalog.add_resource(exec1)
assert_nothing_raised do
- exec2 = Puppet::Type.type(:exec).new(
+
+ exec2 = Puppet::Type.type(:exec).new(
+
:title => "exec2",
+
:command => "#{echo} funtest"
)
end
@@ -265,16 +302,22 @@ class TestType < Test::Unit::TestCase
# Now do files, since they are. This should fail.
file1 = file2 = nil
path = tempfile()
- file1 = Puppet::Type.type(:file).new(
+
+ file1 = Puppet::Type.type(:file).new(
+
:title => "file1",
:path => path,
+
:content => "yayness"
)
catalog.add_resource(file1)
- file2 = Puppet::Type.type(:file).new(
+
+ file2 = Puppet::Type.type(:file).new(
+
:title => "file2",
:path => path,
+
:content => "rahness"
)
assert_raise(ArgumentError) { catalog.add_resource(file2) }
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 6a745a10c..f1e404ccf 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -23,7 +23,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
# a full cron job. These tests assume individual record types will always be correctly
# parsed, so all they
def sample_crons
- unless defined? @sample_crons
+ unless defined?(@sample_crons)
@sample_crons = YAML.load(File.read(File.join(@crondir, "crontab_collections.yaml")))
end
@sample_crons
@@ -33,7 +33,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
# mapping between records and lines. We have plenty of redundancy here because
# we use these records to build up our complex, multi-line cron jobs below.
def sample_records
- unless defined? @sample_records
+ unless defined?(@sample_records)
@sample_records = YAML.load(File.read(File.join(@crondir, "crontab_sample_records.yaml")))
end
@sample_records
@@ -253,7 +253,10 @@ class TestCronParsedProvider < Test::Unit::TestCase
sis.dup.each do |p,v|
is.delete(p) if v == :absent
end
- assert_equal(should, is,
+
+ assert_equal(
+ should, is,
+
"Did not parse %s correctly" % file)
end
@@ -295,7 +298,10 @@ class TestCronParsedProvider < Test::Unit::TestCase
str = @provider.to_line(args)
}
- assert_equal("# Puppet Name: #{name}\n30 * * * * date > /dev/null", str,
+
+ assert_equal(
+ "# Puppet Name: #{name}\n30 * * * * date > /dev/null", str,
+
"Cron did not generate correctly")
end
@@ -370,8 +376,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
@provider.flush :target => @me, :command => "/do/something",
:record_type => :crontab
created = @provider.retrieve(@me)
- assert(created.detect { |r| r[:command] == "/do/something" },
- "Did not create cron tab")
+ assert(created.detect { |r| r[:command] == "/do/something" }, "Did not create cron tab")
end
# Make sure we correctly bidirectionally parse things.
@@ -393,7 +398,10 @@ class TestCronParsedProvider < Test::Unit::TestCase
@provider.initvars
str += "\n"
target.write(str)
- assert_equal(str, target.read,
+
+ assert_equal(
+ str, target.read,
+
"Did not write correctly")
assert_nothing_raised("Could not prefetch with %s" % str.inspect) do
@provider.prefetch
@@ -402,7 +410,10 @@ class TestCronParsedProvider < Test::Unit::TestCase
@provider.flush_target(@me)
end
- assert_equal(str, target.read,
+
+ assert_equal(
+ str, target.read,
+
"Changed in read/write")
@provider.clear
@@ -435,30 +446,42 @@ class TestCronParsedProvider < Test::Unit::TestCase
# Now make some crons that should match
matchers = [
- @type.new(
+
+ @type.new(
+
:name => "yaycron",
:minute => [0, 30],
:command => "date",
+
:user => @me
),
- @type.new(
+
+ @type.new(
+
:name => "youtest",
:command => "yaytest",
+
:user => you
)
]
nonmatchers = [
- @type.new(
+
+ @type.new(
+
:name => "footest",
:minute => [0, 30],
:hour => 1,
:command => "fooness",
+
:user => @me # wrong target
),
- @type.new(
+
+ @type.new(
+
:name => "funtest2",
:command => "funtest",
+
:user => you # wrong target for this cron
)
]
@@ -509,8 +532,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
# Ignore whitespace differences, since those don't affect function.
modtext = text.gsub(/[ \t]+/, " ")
modtarget = target.read.gsub(/[ \t]+/, " ")
- assert_equal(modtext, modtarget,
- "File was not rewritten the same")
+ assert_equal(modtext, modtarget, "File was not rewritten the same")
@provider.clear
end
@@ -535,14 +557,20 @@ class TestCronParsedProvider < Test::Unit::TestCase
end
records = @provider.send(:instance_variable_get, "@records")
records.each do |r|
- assert_equal(:freebsd_special, r[:record_type],
+
+ assert_equal(
+ :freebsd_special, r[:record_type],
+
"Did not create lines as freebsd lines")
end
assert_nothing_raised("Could not flush with %s" % str.inspect) do
@provider.flush_target(@me)
end
- assert_equal(str, target.read,
+
+ assert_equal(
+ str, target.read,
+
"Changed in read/write")
@provider.clear
diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb
index cedbf137c..990b0b42c 100755
--- a/test/ral/providers/group.rb
+++ b/test/ral/providers/group.rb
@@ -63,8 +63,7 @@ class TestGroupProvider < Test::Unit::TestCase
def gid(name)
%x{nireport / /groups name gid}.split("\n").each { |line|
group, id = line.chomp.split(/\s+/)
- assert(id =~ /^-?\d+$/, "Group id %s for %s is not a number" %
- [id.inspect, group])
+ assert(id =~ /^-?\d+$/, "Group id %s for %s is not a number" % [id.inspect, group])
if group == name
return Integer(id)
end
diff --git a/test/ral/providers/host/parsed.rb b/test/ral/providers/host/parsed.rb
index 839761286..0339f7c27 100755
--- a/test/ral/providers/host/parsed.rb
+++ b/test/ral/providers/host/parsed.rb
@@ -36,7 +36,7 @@ class TestParsedHostProvider < Test::Unit::TestCase
end
def mkhosthash
- if defined? @hcount
+ if defined?(@hcount)
@hcount += 1
else
@hcount = 1
@@ -100,12 +100,15 @@ class TestParsedHostProvider < Test::Unit::TestCase
instances = @provider.parse(text)
end
- assert_equal([
+
+ assert_equal(
+ [
{:record_type => :comment, :line => "# comment one"},
{:record_type => :blank, :line => ""},
{:record_type => :parsed, :name => "myhost", :ip => "192.168.43.56", :host_aliases => %w{another host}},
{:record_type => :blank, :line => " "},
{:record_type => :comment, :line => "# another comment"},
+
{:record_type => :parsed, :name => "anotherhost", :ip => "192.168.43.57", :host_aliases => []}
], instances)
@@ -145,7 +148,10 @@ class TestParsedHostProvider < Test::Unit::TestCase
# Make sure we get the host back
assert_nothing_raised {
- assert(file.read.include?(host.name),
+
+ assert(
+ file.read.include?(host.name),
+
"Did not flush host to disk")
}
@@ -155,7 +161,10 @@ class TestParsedHostProvider < Test::Unit::TestCase
assert_nothing_raised {
host.flush
- assert(! file.read.include?(name[0]),
+
+ assert(
+ ! file.read.include?(name[0]),
+
"Did not remove host_aliases from disk")
}
diff --git a/test/ral/providers/mailalias/aliases.rb b/test/ral/providers/mailalias/aliases.rb
index 6406e83e9..76bbc60c6 100755
--- a/test/ral/providers/mailalias/aliases.rb
+++ b/test/ral/providers/mailalias/aliases.rb
@@ -26,7 +26,7 @@ class TestMailaliasAliasesProvider < Test::Unit::TestCase
end
def mkalias(name = "me")
- if defined? @pcount
+ if defined?(@pcount)
@pcount += 1
else
@pcount = 1
diff --git a/test/ral/providers/package.rb b/test/ral/providers/package.rb
index 4435188be..b408d9482 100755
--- a/test/ral/providers/package.rb
+++ b/test/ral/providers/package.rb
@@ -83,8 +83,7 @@ class TestPackageProvider < Test::Unit::TestCase
assert_nothing_raised("Could not query provider") do
result = provider.query
end
- assert((result == :listed or result.is_a?(Hash)),
- "query did not return hash or :listed")
+ assert((result == :listed or result.is_a?(Hash)), "query did not return hash or :listed")
if result == :listed
assert(provider.resource.is(:ensure) != :absent, msg)
else
@@ -192,8 +191,7 @@ class TestPackageProvider < Test::Unit::TestCase
end
provider.flush
new = provider.properties
- assert(current != new, "package was not upgraded: %s did not change" %
- current.inspect)
+ assert(current != new, "package was not upgraded: %s did not change" % current.inspect)
end
unless versions.empty?
@@ -204,8 +202,7 @@ class TestPackageProvider < Test::Unit::TestCase
end
provider.flush
new = provider.properties
- assert(current != new, "package was not upgraded: %s did not change" %
- current.inspect)
+ assert(current != new, "package was not upgraded: %s did not change" % current.inspect)
end
# Now call 'latest' after the package is installed
diff --git a/test/ral/providers/package/aptitude.rb b/test/ral/providers/package/aptitude.rb
index 113085c75..ba736f948 100755
--- a/test/ral/providers/package/aptitude.rb
+++ b/test/ral/providers/package/aptitude.rb
@@ -17,30 +17,36 @@ class AptitudePackageProviderTest < PuppetTest::TestCase
def test_install
pkg = @type.new :name => 'faff',
- :provider => :aptitude,
- :ensure => :present,
- :source => "/tmp/faff.deb"
+ :provider => :aptitude,
+ :ensure => :present,
+ :source => "/tmp/faff.deb"
pkg.provider.expects(
- :dpkgquery
- ).with(
- '-W',
- '--showformat',
- '${Status} ${Package} ${Version}\n',
- 'faff'
- ).returns(
+ :dpkgquery
+
+ ).with(
+
+ '-W',
+ '--showformat',
+ '${Status} ${Package} ${Version}\n',
+
+ 'faff'
+ ).returns(
"deinstall ok config-files faff 1.2.3-1\n"
- ).times(1)
+ ).times(1)
pkg.provider.expects(
- :aptitude
- ).with(
- '-y',
- '-o',
- 'DPkg::Options::=--force-confold',
- :install,
- 'faff'
- ).returns(0)
+ :aptitude
+
+ ).with(
+
+ '-y',
+ '-o',
+ 'DPkg::Options::=--force-confold',
+ :install,
+
+ 'faff'
+ ).returns(0)
assert_apply( pkg )
end
@@ -49,22 +55,28 @@ class AptitudePackageProviderTest < PuppetTest::TestCase
pkg = @type.new :name => 'faff', :provider => :aptitude, :ensure => :purged
pkg.provider.expects(
- :dpkgquery
- ).with(
- '-W',
- '--showformat',
- '${Status} ${Package} ${Version}\n',
- 'faff'
- ).returns(
+ :dpkgquery
+
+ ).with(
+
+ '-W',
+ '--showformat',
+ '${Status} ${Package} ${Version}\n',
+
+ 'faff'
+ ).returns(
"install ok installed faff 1.2.3-1\n"
- ).times(1)
+ ).times(1)
pkg.provider.expects(
- :aptitude
- ).with(
- '-y',
- 'purge',
- 'faff'
- ).returns(0)
+ :aptitude
+
+ ).with(
+
+ '-y',
+ 'purge',
+
+ 'faff'
+ ).returns(0)
assert_apply( pkg )
end
diff --git a/test/ral/providers/package/aptrpm.rb b/test/ral/providers/package/aptrpm.rb
index a3010cc92..dbb6a0029 100755
--- a/test/ral/providers/package/aptrpm.rb
+++ b/test/ral/providers/package/aptrpm.rb
@@ -15,28 +15,34 @@ class AptrpmPackageProviderTest < PuppetTest::TestCase
def test_install
pkg = @type.new :name => 'faff',
- :provider => :aptrpm,
- :ensure => :present,
- :source => "/tmp/faff.rpm"
+ :provider => :aptrpm,
+ :ensure => :present,
+ :source => "/tmp/faff.rpm"
pkg.provider.expects(
- :rpm
- ).with(
- '-q',
- 'faff',
- '--nosignature',
- '--nodigest',
- '--qf',
- "%{NAME}-%{VERSION}-%{RELEASE} %{VERSION}-%{RELEASE}\n"
- ).raises(Puppet::ExecutionFailure, "couldn't find rpm").times(1)
+ :rpm
+
+ ).with(
+
+ '-q',
+ 'faff',
+ '--nosignature',
+ '--nodigest',
+ '--qf',
+
+ "%{NAME}-%{VERSION}-%{RELEASE} %{VERSION}-%{RELEASE}\n"
+ ).raises(Puppet::ExecutionFailure, "couldn't find rpm").times(1)
pkg.provider.expects(
- :aptget
- ).with(
- '-q',
- '-y',
- "install",
- 'faff'
+ :aptget
+
+ ).with(
+
+ '-q',
+ '-y',
+ "install",
+
+ 'faff'
).returns(0)
pkg.evaluate.each { |state| state.forward }
@@ -46,24 +52,30 @@ class AptrpmPackageProviderTest < PuppetTest::TestCase
pkg = @type.new :name => 'faff', :provider => :aptrpm, :ensure => :absent
pkg.provider.expects(
- :rpm
- ).with(
- '-q',
- 'faff',
- '--nosignature',
- '--nodigest',
- '--qf',
- "%{NAME}-%{VERSION}-%{RELEASE} %{VERSION}-%{RELEASE}\n"
+ :rpm
+
+ ).with(
+
+ '-q',
+ 'faff',
+ '--nosignature',
+ '--nodigest',
+ '--qf',
+
+ "%{NAME}-%{VERSION}-%{RELEASE} %{VERSION}-%{RELEASE}\n"
).returns(
"faff-1.2.3-1 1.2.3-1\n"
).times(1)
pkg.provider.expects(
- :aptget
- ).with(
- '-y',
- '-q',
- 'remove',
- 'faff'
+ :aptget
+
+ ).with(
+
+ '-y',
+ '-q',
+ 'remove',
+
+ 'faff'
).returns(0)
pkg.evaluate.each { |state| state.forward }
diff --git a/test/ral/providers/parsedfile.rb b/test/ral/providers/parsedfile.rb
index 9794a71bb..a1d2435d1 100755
--- a/test/ral/providers/parsedfile.rb
+++ b/test/ral/providers/parsedfile.rb
@@ -36,8 +36,7 @@ class TestParsedFile < Test::Unit::TestCase
# A simple block to skip the complexity of a full transaction.
def apply(resource)
[:one, :two, :ensure, :target].each do |st|
- Puppet.info "Setting %s: %s => %s" %
- [resource[:name], st, resource.should(st)]
+ Puppet.info "Setting %s: %s => %s" % [resource[:name], st, resource.should(st)]
resource.provider.send(st.to_s + "=", resource.should(st))
end
end
@@ -51,8 +50,7 @@ class TestParsedFile < Test::Unit::TestCase
end
def mkprovider(name = :parsed)
- @provider = @type.provide(name, :parent => Puppet::Provider::ParsedFile,
- :filetype => :ram, :default_target => "yayness") do
+ @provider = @type.provide(name, :parent => Puppet::Provider::ParsedFile, :filetype => :ram, :default_target => "yayness") do
record_line name, :fields => %w{name one two}
end
end
@@ -63,7 +61,7 @@ class TestParsedFile < Test::Unit::TestCase
end
def teardown
- if defined? @provider
+ if defined?(@provider)
@type.unprovide(@provider.name)
@provider = nil
end
@@ -369,16 +367,14 @@ class TestParsedFile < Test::Unit::TestCase
assert_equal(:c, one.provider.two)
# And make sure it's right on disk
- assert(prov.target_object(:yayness).read.include?("one a c"),
- "Did not write out correct data")
+ assert(prov.target_object(:yayness).read.include?("one a c"), "Did not write out correct data")
# Make sure the second resource has not been modified
assert_equal("a", two.provider.one, "Two was flushed early")
assert_equal("c", two.provider.two, "Two was flushed early")
# And on disk
- assert(prov.target_object(:yayness).read.include?("two a c"),
- "Wrote out other resource")
+ assert(prov.target_object(:yayness).read.include?("two a c"), "Wrote out other resource")
# Now fetch the data again and make sure we're still right
assert_nothing_raised { prov.prefetch(resources) }
@@ -422,8 +418,7 @@ class TestParsedFile < Test::Unit::TestCase
end
# And make sure our resource doesn't appear twice in the file.
- assert_equal("yay b c\n", prov.target_object(:basic).read,
- "Wrote record to file twice")
+ assert_equal("yay b c\n", prov.target_object(:basic).read, "Wrote record to file twice")
end
# Make sure a record can switch targets.
@@ -452,8 +447,7 @@ class TestParsedFile < Test::Unit::TestCase
end
check = proc do |target, name|
- assert(prov.target_object(target).read.include?("%s a c" % name),
- "Did not sync %s" % name)
+ assert(prov.target_object(target).read.include?("%s a c" % name), "Did not sync %s" % name)
end
# Make sure the data is there
check.call(:first, :first)
@@ -479,8 +473,7 @@ class TestParsedFile < Test::Unit::TestCase
check.call(:second, :mover)
# And make sure the mover is no longer in the first file
- assert(prov.target_object(:first) !~ /mover/,
- "Mover was not removed from first file")
+ assert(prov.target_object(:first) !~ /mover/, "Mover was not removed from first file")
end
# Make sure that 'ensure' correctly calls 'sync' on all properties.
@@ -497,7 +490,10 @@ class TestParsedFile < Test::Unit::TestCase
prov.target_object(:first).write "ondisk a c\n"
prov.prefetch("ondisk" => ondisk, "notdisk" => notdisk)
- assert_equal(:present, notdisk.should(:ensure),
+
+ assert_equal(
+ :present, notdisk.should(:ensure),
+
"Did not get default ensure value")
# Try creating the object
@@ -528,10 +524,8 @@ class TestParsedFile < Test::Unit::TestCase
assert_nothing_raised { notdisk.flush }
# And make sure it's no longer present
- assert(prov.target_object(:first).read !~ /^notdisk/,
- "Did not remove thing from disk")
- assert(prov.target_object(:first).read =~ /^ondisk/,
- "Lost object on disk")
+ assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk")
+ assert(prov.target_object(:first).read =~ /^ondisk/, "Lost object on disk")
assert_equal(:present, ondisk.provider.ensure)
end
@@ -588,14 +582,14 @@ class TestParsedFile < Test::Unit::TestCase
end
assert(bills_values[bill.property(:one)],
- "Bill does not have a value for 'one'")
+ "Bill does not have a value for 'one'")
assert(bills_values[bill.property(:one)],
- "Bill does not have a value for 'one' on second try")
+ "Bill does not have a value for 'one' on second try")
assert_nothing_raised do
bill.retrieve
end
assert(bills_values[bill.property(:one)],
- "bill's value for 'one' disappeared")
+ "bill's value for 'one' disappeared")
end
# Make sure that creating a new resource finds existing records in memory
@@ -615,7 +609,10 @@ class TestParsedFile < Test::Unit::TestCase
# Make sure invalid fields always show up as insync
def test_invalid_fields
- prov = @type.provide(:test, :parent => Puppet::Provider::ParsedFile,
+
+ prov = @type.provide(
+ :test, :parent => Puppet::Provider::ParsedFile,
+
:filetype => :ram, :default_target => :yayness) do
record_line :test, :fields => %w{name two}
end
@@ -640,7 +637,10 @@ class TestParsedFile < Test::Unit::TestCase
# Make sure we call the prefetch hook at the right place.
def test_prefetch_hook
- prov = @type.provide(:test, :parent => Puppet::Provider::ParsedFile,
+
+ prov = @type.provide(
+ :test, :parent => Puppet::Provider::ParsedFile,
+
:filetype => :ram, :default_target => :yayness) do
def self.prefetch_hook(records)
@@ -678,14 +678,16 @@ class TestParsedFile < Test::Unit::TestCase
otarget.write("oname b d\n")
# Now make a resource that targets elsewhat.
- res = @type.new(:name => "test", :one => "a", :two => "c",
- :target => opath)
+ res = @type.new(:name => "test", :one => "a", :two => "c", :target => opath)
assert(res.property(:target), "Target is a parameter, not a property")
assert_apply(res)
- assert_equal("oname b d\ntest a c\n", otarget.read,
+
+ assert_equal(
+ "oname b d\ntest a c\n", otarget.read,
+
"did not get correct results in specified target")
end
end
diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb
index 79535bef2..e7625b95d 100755
--- a/test/ral/providers/provider.rb
+++ b/test/ral/providers/provider.rb
@@ -213,11 +213,17 @@ class TestProvider < Test::Unit::TestCase
out = detail.to_s
end
- assert(out =~ /A Failure/,
- "Did not receive command output on failure")
- assert(out =~ /Execution of/,
- "Did not receive info wrapper on failure")
+ assert(
+ out =~ /A Failure/,
+
+ "Did not receive command output on failure")
+
+
+ assert(
+ out =~ /Execution of/,
+
+ "Did not receive info wrapper on failure")
end
def test_mk_resource_methods
@@ -236,14 +242,20 @@ class TestProvider < Test::Unit::TestCase
assert(prov.public_method_defined?(param), "no getter for %s" % param)
assert(prov.public_method_defined?(param + "="), "no setter for %s" % param)
- assert_equal(:absent, obj.send(param),
- "%s did not default to :absent")
+
+ assert_equal(
+ :absent, obj.send(param),
+
+ "%s did not default to :absent")
val = "testing %s" % param
assert_nothing_raised("Could not call setter for %s" % param) do
obj.send(param + "=", val)
end
- assert_equal(val, obj.send(param),
- "did not get correct value for %s" % param)
+
+ assert_equal(
+ val, obj.send(param),
+
+ "did not get correct value for %s" % param)
end
end
@@ -382,47 +394,32 @@ class TestProviderFeatures < Test::Unit::TestCase
end
resource = @type.new(:name => "foo")
- {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha],
- :mixed => [], :neither => []}.each do |name, should|
- should.sort! { |a,b| a.to_s <=> b.to_s }
- provider = @type.provider(name)
- assert(provider, "Could not find provider %s" % name)
- assert_equal(should, provider.features,
- "Provider %s has incorrect features" % name)
-
- inst = provider.new(resource)
- # Make sure the boolean methods work on both the provider and
- # instance.
- @features.keys.each do |feature|
- method = feature.to_s + "?"
- assert(inst.respond_to?(method),
- "No boolean instance method for %s on %s" %
- [name, feature])
- assert(provider.respond_to?(method),
- "No boolean class method for %s on %s" % [name, feature])
-
- if should.include?(feature)
- assert(provider.feature?(feature),
- "class missing feature? %s" % feature)
- assert(inst.feature?(feature),
- "instance missing feature? %s" % feature)
- assert(provider.send(method),
- "class missing feature %s" % feature)
- assert(inst.send(method),
- "instance missing feature %s" % feature)
- assert(inst.satisfies?(feature),
- "instance.satisfy %s returned false" % feature)
+ {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha], :mixed => [], :neither => []}.each do |name, should|
+ should.sort! { |a,b| a.to_s <=> b.to_s }
+ provider = @type.provider(name)
+ assert(provider, "Could not find provider %s" % name)
+ assert_equal(should, provider.features, "Provider %s has incorrect features" % name)
+
+ inst = provider.new(resource)
+ # Make sure the boolean methods work on both the provider and
+ # instance.
+ @features.keys.each do |feature|
+ method = feature.to_s + "?"
+ assert(inst.respond_to?(method), "No boolean instance method for %s on %s" % [name, feature])
+ assert(provider.respond_to?(method), "No boolean class method for %s on %s" % [name, feature])
+
+ if should.include?(feature)
+ assert(provider.feature?(feature), "class missing feature? %s" % feature)
+ assert(inst.feature?(feature), "instance missing feature? %s" % feature)
+ assert(provider.send(method), "class missing feature %s" % feature)
+ assert(inst.send(method), "instance missing feature %s" % feature)
+ assert(inst.satisfies?(feature), "instance.satisfy %s returned false" % feature)
else
- assert(! provider.feature?(feature),
- "class has feature? %s" % feature)
- assert(! inst.feature?(feature),
- "instance has feature? %s" % feature)
- assert(! provider.send(method),
- "class has feature %s" % feature)
- assert(! inst.send(method),
- "instance has feature %s" % feature)
- assert(! inst.satisfies?(feature),
- "instance.satisfy %s returned true" % feature)
+ assert(! provider.feature?(feature), "class has feature? %s" % feature)
+ assert(! inst.feature?(feature), "instance has feature? %s" % feature)
+ assert(! provider.send(method), "class has feature %s" % feature)
+ assert(! inst.send(method), "instance has feature %s" % feature)
+ assert(! inst.satisfies?(feature), "instance.satisfy %s returned true" % feature)
end
end
@@ -431,8 +428,7 @@ class TestProviderFeatures < Test::Unit::TestCase
Puppet[:trace] = true
Puppet::Type.loadall
Puppet::Type.eachtype do |type|
- assert(type.respond_to?(:feature),
- "No features method defined for %s" % type.name)
+ assert(type.respond_to?(:feature), "No features method defined for %s" % type.name)
end
end
@@ -443,9 +439,15 @@ class TestProviderFeatures < Test::Unit::TestCase
# Define a provider with nothing
provider = @type.provide(:nothing) {}
- assert(provider.respond_to?(:has_features),
+
+ assert(
+ provider.respond_to?(:has_features),
+
"Provider did not get 'has_features' method added")
- assert(provider.respond_to?(:has_feature),
+
+ assert(
+ provider.respond_to?(:has_feature),
+
"Provider did not get the 'has_feature' alias method")
# One with the numeric methods and nothing else
diff --git a/test/ral/providers/service/base.rb b/test/ral/providers/service/base.rb
index e23e2fd11..015905180 100755
--- a/test/ral/providers/service/base.rb
+++ b/test/ral/providers/service/base.rb
@@ -22,10 +22,13 @@ class TestBaseServiceProvider < Test::Unit::TestCase
end
commands[c.to_sym] = path
end
- service = Puppet::Type.type(:service).new(
+
+ service = Puppet::Type.type(:service).new(
+
:name => "yaytest", :provider => :base,
:start => "%s %s" % [commands[:touch], running],
:status => "%s -f %s" % [commands[:test], running],
+
:stop => "%s %s" % [commands[:rm], running]
)
@@ -51,11 +54,14 @@ class TestBaseServiceProvider < Test::Unit::TestCase
# Testing #454
def test_that_failures_propagate
nope = "/no/such/command"
- service = Puppet::Type.type(:service).new(
+
+ service = Puppet::Type.type(:service).new(
+
:name => "yaytest", :provider => :base,
:start => nope,
:status => nope,
:stop => nope,
+
:restart => nope
)
diff --git a/test/ral/providers/sshkey/parsed.rb b/test/ral/providers/sshkey/parsed.rb
index cad758568..8a18d5e9a 100755
--- a/test/ral/providers/sshkey/parsed.rb
+++ b/test/ral/providers/sshkey/parsed.rb
@@ -24,7 +24,7 @@ class TestParsedSSHKey < Test::Unit::TestCase
end
def mkkey(name = "host.domain.com")
- if defined? @pcount
+ if defined?(@pcount)
@pcount += 1
else
@pcount = 1
@@ -96,11 +96,14 @@ class TestParsedSSHKey < Test::Unit::TestCase
assert_equal("one", result[:name], "Did not call post hook")
assert_equal(%w{two}, result[:host_aliases], "Did not call post hook")
- assert_equal("one,two type key",
+
+ assert_equal(
+ "one,two type key",
@provider.to_line(:record_type => :parsed,
:name => "one",
:host_aliases => %w{two},
:type => "type",
+
:key => "key"),
"Did not use pre-hook when generating line"
)
diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb
index 9abf850ad..7b031891b 100755
--- a/test/ral/providers/user.rb
+++ b/test/ral/providers/user.rb
@@ -192,8 +192,11 @@ class TestUserProvider < Test::Unit::TestCase
val = user.send(property)
}
- assert(val != :absent,
- "Property %s is missing" % property)
+
+ assert(
+ val != :absent,
+
+ "Property %s is missing" % property)
assert(val, "Did not get value for %s" % property)
end
@@ -202,12 +205,18 @@ class TestUserProvider < Test::Unit::TestCase
def test_exists
user = mkuser("nosuchuserok")
- assert(! user.exists?,
- "Fake user exists?")
+
+ assert(
+ ! user.exists?,
+
+ "Fake user exists?")
user = mkuser(@me)
- assert(user.exists?,
- "I don't exist?")
+
+ assert(
+ user.exists?,
+
+ "I don't exist?")
end
def attrtest_ensure(user)
@@ -238,14 +247,20 @@ class TestUserProvider < Test::Unit::TestCase
user.comment = newname
}
- assert_equal(newname, current?(:comment, user),
+
+ assert_equal(
+ newname, current?(:comment, user),
+
"Comment was not changed")
assert_nothing_raised {
user.comment = old
}
- assert_equal(old, current?(:comment, user),
+
+ assert_equal(
+ old, current?(:comment, user),
+
"Comment was not reverted")
end
@@ -278,7 +293,10 @@ class TestUserProvider < Test::Unit::TestCase
user.shell = newshell
}
- assert_equal(newshell, current?(:shell, user),
+
+ assert_equal(
+ newshell, current?(:shell, user),
+
"Shell was not changed")
assert_nothing_raised {
@@ -292,8 +310,8 @@ class TestUserProvider < Test::Unit::TestCase
old = current?(:gid, user)
newgroup = %w{nogroup nobody staff users daemon}.find { |gid|
- begin
- group = Etc.getgrnam(gid)
+ begin
+ group = Etc.getgrnam(gid)
rescue ArgumentError => detail
next
end
@@ -369,9 +387,12 @@ class TestUserProvider < Test::Unit::TestCase
5.times do |i|
i += 1
name = "pptstgr%s" % i
- tmpgroup = Puppet::Type.type(:group).new(
- :name => name,
- :gid => max + i
+
+ tmpgroup = Puppet::Type.type(:group).new(
+
+ :name => name,
+
+ :gid => max + i
)
groups << tmpgroup
@@ -439,7 +460,7 @@ class TestUserProvider < Test::Unit::TestCase
}
assert_equal("Puppet's Testing User pptest",
- user.comment,
+ user.comment,
"Comment was not set")
assert_nothing_raised {
@@ -507,8 +528,11 @@ class TestUserProvider < Test::Unit::TestCase
user2.resource[:allowdupe] = :true
}
assert_nothing_raised { user2.create }
- assert_equal(:present, user2.ensure,
- "User did not get created")
+
+ assert_equal(
+ :present, user2.ensure,
+
+ "User did not get created")
end
else
$stderr.puts "Not root; skipping user creation/modification tests"
@@ -528,10 +552,16 @@ class TestUserProvider < Test::Unit::TestCase
user = useradd.new(fakeresource)
}
- assert_equal("-d", user.send(:flag, :home),
+
+ assert_equal(
+ "-d", user.send(:flag, :home),
+
"Incorrect home flag")
- assert_equal("-s", user.send(:flag, :shell),
+
+ assert_equal(
+ "-s", user.send(:flag, :shell),
+
"Incorrect shell flag")
end
diff --git a/test/ral/providers/user/useradd.rb b/test/ral/providers/user/useradd.rb
index 25798d637..7dedeefc9 100755
--- a/test/ral/providers/user/useradd.rb
+++ b/test/ral/providers/user/useradd.rb
@@ -35,7 +35,10 @@ class UserAddProviderTest < PuppetTest::TestCase
def test_features
[:manages_homedir].each do |feature|
- assert(@provider.feature?(feature),
+
+ assert(
+ @provider.feature?(feature),
+
"useradd provider is missing %s" % feature)
end
end
@@ -56,8 +59,7 @@ class UserAddProviderTest < PuppetTest::TestCase
"Got incorrect command")
if %w{Fedora RedHat}.include?(Facter.value(:operatingsystem))
- assert(params.include?("-M"),
- "Did not disable homedir creation on red hat")
+ assert(params.include?("-M"), "Did not disable homedir creation on red hat")
params.delete("-M")
end
@@ -72,8 +74,7 @@ class UserAddProviderTest < PuppetTest::TestCase
:uid => "-u", :comment => "-c"}
flags.each do |param, flag|
- assert_equal(@vals[param], options[flag],
- "Got incorrect value for %s" % param)
+ assert_equal(@vals[param], options[flag], "Got incorrect value for %s" % param)
end
true
@@ -87,7 +88,10 @@ class UserAddProviderTest < PuppetTest::TestCase
@vals[:managehome] = true
setup_user
- assert(@user.provider.respond_to?(:manages_homedir?),
+
+ assert(
+ @user.provider.respond_to?(:manages_homedir?),
+
"provider did not get managehome test set")
assert(@user.managehome?, "provider did not get managehome")
@@ -96,12 +100,9 @@ class UserAddProviderTest < PuppetTest::TestCase
@user.expects(:managehome?).returns(true)
@user.provider.expects(:execute).with do |params|
- assert_equal(params[0], @provider.command(:add),
- "useradd was not called")
- assert(params.include?("-m"),
- "Did not add -m when managehome was in affect")
- assert(! params.include?("-M"),
- "Added -M when managehome was in affect")
+ assert_equal(params[0], @provider.command(:add), "useradd was not called")
+ assert(params.include?("-m"), "Did not add -m when managehome was in affect")
+ assert(! params.include?("-M"), "Added -M when managehome was in affect")
true
end
@@ -116,14 +117,11 @@ class UserAddProviderTest < PuppetTest::TestCase
@user.expects(:managehome?).returns(false)
@user.provider.expects(:execute).with do |params|
- assert_equal(params[0], @provider.command(:add),
- "useradd was not called")
+ assert_equal(params[0], @provider.command(:add), "useradd was not called")
if %w{Fedora RedHat}.include?(Facter.value(:operatingsystem))
- assert(params.include?("-M"),
- "Did not add -M on Red Hat")
+ assert(params.include?("-M"), "Did not add -M on Red Hat")
end
- assert(! params.include?("-m"),
- "Added -m when managehome was disabled")
+ assert(! params.include?("-m"), "Added -m when managehome was disabled")
true
end
@@ -135,7 +133,10 @@ class UserAddProviderTest < PuppetTest::TestCase
@vals[:allowdupe] = true
setup_user
- assert(@user.provider.respond_to?(:allows_duplicates?),
+
+ assert(
+ @user.provider.respond_to?(:allows_duplicates?),
+
"provider did not get allowdupe test set")
assert(@user.allowdupe?, "provider did not get allowdupe")
@@ -144,10 +145,8 @@ class UserAddProviderTest < PuppetTest::TestCase
@user.expects(:allowdupe?).returns(true)
@user.provider.expects(:execute).with do |params|
- assert_equal(params[0], @provider.command(:add),
- "useradd was not called")
- assert(params.include?("-o"),
- "Did not add -o when allowdupe was in affect")
+ assert_equal(params[0], @provider.command(:add), "useradd was not called")
+ assert(params.include?("-o"), "Did not add -o when allowdupe was in affect")
true
end
@@ -162,10 +161,8 @@ class UserAddProviderTest < PuppetTest::TestCase
@user.expects(:allowdupe?).returns(false)
@user.provider.expects(:execute).with do |params|
- assert_equal(params[0], @provider.command(:add),
- "useradd was not called")
- assert(! params.include?("-o"),
- "Added -o when allowdupe was disabled")
+ assert_equal(params[0], @provider.command(:add), "useradd was not called")
+ assert(! params.include?("-o"), "Added -o when allowdupe was disabled")
true
end
@@ -181,8 +178,7 @@ class UserAddProviderTest < PuppetTest::TestCase
setup_user
@user.provider.expects(:execute).with do |params|
- assert_equal(params[0], @provider.command(:add),
- "useradd was not called")
+ assert_equal(params[0], @provider.command(:add), "useradd was not called")
params.shift
options = {}
params.each_with_index do |p, i|
@@ -190,8 +186,7 @@ class UserAddProviderTest < PuppetTest::TestCase
options[p] = params[i + 1]
end
end
- assert_equal(options["-p"], @vals[:password],
- "Did not set password in useradd call")
+ assert_equal(options["-p"], @vals[:password], "Did not set password in useradd call")
true
end
@@ -202,8 +197,7 @@ class UserAddProviderTest < PuppetTest::TestCase
@vals[:password] = "somethingelse"
@user.provider.expects(:execute).with do |params|
- assert_equal(params[0], @provider.command(:modify),
- "usermod was not called")
+ assert_equal(params[0], @provider.command(:modify), "usermod was not called")
options = {}
params.each_with_index do |p, i|
@@ -211,7 +205,10 @@ class UserAddProviderTest < PuppetTest::TestCase
options[p] = params[i + 1]
end
end
- assert_equal(options["-p"], @vals[:password],
+
+ assert_equal(
+ options["-p"], @vals[:password],
+
"Did not set password in useradd call")
true
end
diff --git a/test/ral/type/cron.rb b/test/ral/type/cron.rb
index 2c0a70199..fc2d03e93 100755
--- a/test/ral/type/cron.rb
+++ b/test/ral/type/cron.rb
@@ -124,10 +124,13 @@ class TestCron < Test::Unit::TestCase
name = "yaytest"
command = "date > /dev/null "
assert_nothing_raised {
+
cron = @crontype.new(
+
:name => name,
:command => "date > /dev/null ",
:month => "May",
+
:user => @me
)
}
@@ -195,12 +198,10 @@ class TestCron < Test::Unit::TestCase
}
if value.is_a?(Integer)
- assert_equal([value.to_s], cron.should(param),
- "Cron value was not set correctly")
+ assert_equal([value.to_s], cron.should(param), "Cron value was not set correctly")
end
when :invalid
- assert_raise(Puppet::Error, "%s is incorrectly a valid %s" %
- [value, param]) {
+ assert_raise(Puppet::Error, "%s is incorrectly a valid %s" % [value, param]) {
cron[param] = value
}
end
@@ -219,10 +220,13 @@ class TestCron < Test::Unit::TestCase
eachprovider do |provider|
cron = nil
assert_nothing_raised {
+
cron = @crontype.new(
+
:command => "/bin/date > /dev/null",
:minute => [0, 30],
:name => "crontest",
+
:provider => provider.name
)
}
@@ -245,10 +249,13 @@ class TestCron < Test::Unit::TestCase
def test_fieldremoval
cron = nil
assert_nothing_raised {
+
cron = @crontype.new(
+
:command => "/bin/date > /dev/null",
:minute => [0, 30],
:name => "crontest",
+
:provider => :crontab
)
}
@@ -277,9 +284,12 @@ class TestCron < Test::Unit::TestCase
cleanup { provider.filetype = ft }
setme
- cron = @crontype.new(:name => "testing",
+
+ cron = @crontype.new(
+ :name => "testing",
:minute => [0, 30],
:command => "/bin/testing",
+
:user => @me
)
# Write it to our file
@@ -294,8 +304,11 @@ class TestCron < Test::Unit::TestCase
crons.each do |cron|
assert_instance_of(@crontype, cron, "Did not receive a real cron object")
- assert_instance_of(String, cron.value(:user),
- "Cron user is not a string")
+
+ assert_instance_of(
+ String, cron.value(:user),
+
+ "Cron user is not a string")
end
end
@@ -334,11 +347,11 @@ class TestCron < Test::Unit::TestCase
def provider_set(cron, param, value)
- unless param =~ /=$/
- param = "%s=" % param
- end
+ unless param =~ /=$/
+ param = "%s=" % param
+ end
- cron.provider.send(param, value)
+ cron.provider.send(param, value)
end
def test_value
@@ -352,8 +365,8 @@ class TestCron < Test::Unit::TestCase
assert(property, "Did not get %s property" % param)
assert_nothing_raised {
-# property.is = :absent
- provider_set(cron, param, :absent)
+ # property.is = :absent
+ provider_set(cron, param, :absent)
}
val = "*"
@@ -419,10 +432,13 @@ class TestCron < Test::Unit::TestCase
crons = []
users = ["root", nonrootuser.name]
users.each do |user|
+
cron = Puppet::Type.type(:cron).new(
+
:name => "testcron-#{user}",
:user => user,
:command => "/bin/echo",
+
:minute => [0,30]
)
crons << cron
@@ -439,9 +455,11 @@ class TestCron < Test::Unit::TestCase
next if user == other
text = provider.target_object(other).read
- assert(text !~ /testcron-#{user}/,
- "%s's cron job is in %s's tab" %
- [user, other])
+
+ assert(
+ text !~ /testcron-#{user}/,
+
+ "%s's cron job is in %s's tab" % [user, other])
end
end
end
@@ -450,20 +468,27 @@ class TestCron < Test::Unit::TestCase
def test_default_user
crontab = @crontype.provider(:crontab)
if crontab.suitable?
+
inst = @crontype.new(
+
:name => "something", :command => "/some/thing",
+
:provider => :crontab)
- assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:user),
- "user did not default to current user with crontab")
- assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:target),
- "target did not default to current user with crontab")
+ assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:user), "user did not default to current user with crontab")
+ assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:target), "target did not default to current user with crontab")
# Now make a new cron with a user, and make sure it gets copied
# over
- inst = @crontype.new(:name => "yay", :command => "/some/thing",
- :user => "bin", :provider => :crontab)
- assert_equal("bin", inst.should(:target),
- "target did not default to user with crontab")
+
+ inst = @crontype.new(
+ :name => "yay", :command => "/some/thing",
+
+ :user => "bin", :provider => :crontab)
+
+ assert_equal(
+ "bin", inst.should(:target),
+
+ "target did not default to user with crontab")
end
end
diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb
index 98d111444..cc163ead5 100755
--- a/test/ral/type/exec.rb
+++ b/test/ral/type/exec.rb
@@ -11,8 +11,11 @@ class TestExec < Test::Unit::TestCase
command = nil
output = nil
assert_nothing_raised {
+
command = Puppet::Type.type(:exec).new(
+
:command => "/bin/echo",
+
:returns => val
)
}
@@ -29,8 +32,11 @@ class TestExec < Test::Unit::TestCase
)
}
assert_nothing_raised {
+
command = Puppet::Type.type(:exec).new(
+
:command => "echo",
+
:path => "/usr/bin:/bin:/usr/sbin:/sbin"
)
}
@@ -40,8 +46,11 @@ class TestExec < Test::Unit::TestCase
)
}
assert_nothing_raised {
+
command = Puppet::Type.type(:exec).new(
+
:command => "/bin/echo",
+
:path => "/usr/bin:/bin:/usr/sbin:/sbin"
)
}
@@ -49,23 +58,32 @@ class TestExec < Test::Unit::TestCase
def test_nonzero_returns
assert_nothing_raised {
+
command = Puppet::Type.type(:exec).new(
+
:command => "mkdir /this/directory/does/not/exist",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
+
:returns => 1
)
}
assert_nothing_raised {
+
command = Puppet::Type.type(:exec).new(
+
:command => "touch /etc",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
+
:returns => 1
)
}
assert_nothing_raised {
+
command = Puppet::Type.type(:exec).new(
+
:command => "thiscommanddoesnotexist",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
+
:returns => 127
)
}
@@ -78,10 +96,13 @@ class TestExec < Test::Unit::TestCase
Dir.getwd
}
assert_nothing_raised {
+
command = Puppet::Type.type(:exec).new(
+
:command => "pwd",
:cwd => dir,
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
+
:returns => 0
)
}
@@ -95,9 +116,12 @@ class TestExec < Test::Unit::TestCase
tmpfile = tempfile()
@@tmpfiles.push tmpfile
trans = nil
- file = Puppet::Type.type(:file).new(
- :path => tmpfile,
- :content => "yay"
+
+ file = Puppet::Type.type(:file).new(
+
+ :path => tmpfile,
+
+ :content => "yay"
)
# Get the file in sync
assert_apply(file)
@@ -105,10 +129,13 @@ class TestExec < Test::Unit::TestCase
# Now make an exec
maker = tempfile()
assert_nothing_raised {
+
cmd = Puppet::Type.type(:exec).new(
+
:command => "touch %s" % maker,
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:subscribe => file,
+
:refreshonly => true
)
}
@@ -131,9 +158,12 @@ class TestExec < Test::Unit::TestCase
def test_refreshonly
cmd = true
assert_nothing_raised {
+
cmd = Puppet::Type.type(:exec).new(
+
:command => "pwd",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
+
:refreshonly => true
)
}
@@ -154,9 +184,12 @@ class TestExec < Test::Unit::TestCase
exec = nil
assert(! FileTest.exists?(file), "File already exists")
assert_nothing_raised {
+
exec = Puppet::Type.type(:exec).new(
+
:command => "touch %s" % file,
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
+
:creates => file
)
}
@@ -173,15 +206,21 @@ class TestExec < Test::Unit::TestCase
sh = %x{which sh}
File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" }
- file = Puppet::Type.type(:file).new(
- :path => oexe,
- :source => exe,
- :mode => 0755
+
+ file = Puppet::Type.type(:file).new(
+
+ :path => oexe,
+ :source => exe,
+
+ :mode => 0755
)
- exec = Puppet::Type.type(:exec).new(
- :command => oexe,
- :require => Puppet::Resource.new(:file, oexe)
+
+ exec = Puppet::Type.type(:exec).new(
+
+ :command => oexe,
+
+ :require => Puppet::Resource.new(:file, oexe)
)
comp = mk_catalog("Testing", file, exec)
@@ -196,33 +235,48 @@ class TestExec < Test::Unit::TestCase
sh = %x{which sh}
File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" }
- file = Puppet::Type.type(:file).new(
- :path => oexe,
- :source => exe,
- :mode => 755
+
+ file = Puppet::Type.type(:file).new(
+
+ :path => oexe,
+ :source => exe,
+
+ :mode => 755
)
basedir = File.dirname(oexe)
- baseobj = Puppet::Type.type(:file).new(
- :path => basedir,
- :source => exe,
- :mode => 755
+
+ baseobj = Puppet::Type.type(:file).new(
+
+ :path => basedir,
+ :source => exe,
+
+ :mode => 755
)
- ofile = Puppet::Type.type(:file).new(
- :path => exe,
- :mode => 755
+
+ ofile = Puppet::Type.type(:file).new(
+
+ :path => exe,
+
+ :mode => 755
)
- exec = Puppet::Type.type(:exec).new(
- :command => oexe,
- :path => ENV["PATH"],
- :cwd => basedir
+
+ exec = Puppet::Type.type(:exec).new(
+
+ :command => oexe,
+ :path => ENV["PATH"],
+
+ :cwd => basedir
)
- cat = Puppet::Type.type(:exec).new(
- :command => "cat %s %s" % [exe, oexe],
- :path => ENV["PATH"]
+
+ cat = Puppet::Type.type(:exec).new(
+
+ :command => "cat %s %s" % [exe, oexe],
+
+ :path => ENV["PATH"]
)
catalog = mk_catalog(file, baseobj, ofile, exec, cat)
@@ -255,9 +309,12 @@ class TestExec < Test::Unit::TestCase
exec = nil
assert_nothing_raised {
+
exec = Puppet::Type.type(:exec).new(
+
:command => "touch %s" % bfile,
:onlyif => "test -f %s" % afile,
+
:path => ENV['PATH']
)
}
@@ -276,9 +333,12 @@ class TestExec < Test::Unit::TestCase
exec = nil
assert_nothing_raised {
+
exec = Puppet::Type.type(:exec).new(
+
:command => "touch %s" % bfile,
:unless => "test -f %s" % afile,
+
:path => ENV['PATH']
)
}
@@ -359,10 +419,13 @@ class TestExec < Test::Unit::TestCase
def test_logoutput
exec = nil
assert_nothing_raised {
+
exec = Puppet::Type.type(:exec).new(
+
:title => "logoutputesting",
:path => "/usr/bin:/bin",
:command => "echo logoutput is false",
+
:logoutput => false
)
}
@@ -390,20 +453,26 @@ class TestExec < Test::Unit::TestCase
basedir = tempfile()
path = File.join(basedir, "subfile")
assert_nothing_raised {
+
exec = Puppet::Type.type(:exec).new(
+
:title => "mkdir",
:path => "/usr/bin:/bin",
:creates => basedir,
+
:command => "mkdir %s; touch %s" % [basedir, path]
)
}
assert_nothing_raised {
+
file = Puppet::Type.type(:file).new(
+
:path => basedir,
:recurse => true,
:mode => "755",
+
:require => Puppet::Resource.new("exec", "mkdir")
)
}
@@ -440,18 +509,24 @@ class TestExec < Test::Unit::TestCase
file = tempfile()
assert_nothing_raised {
+
exec1 = Puppet::Type.type(:exec).new(
+
:title => "one",
:path => ENV["PATH"],
+
:command => "mkdir #{dir}"
)
}
assert_nothing_raised("Could not create exec w/out existing cwd") {
+
exec2 = Puppet::Type.type(:exec).new(
+
:title => "two",
:path => ENV["PATH"],
:command => "touch #{file}",
+
:cwd => dir
)
}
@@ -482,8 +557,11 @@ class TestExec < Test::Unit::TestCase
test = "test -f #{file}"
assert_nothing_raised {
+
exec = Puppet::Type.type(:exec).new(
+
:path => ENV["PATH"],
+
:command => "touch #{file}"
)
}
@@ -519,11 +597,14 @@ class TestExec < Test::Unit::TestCase
def test_missing_checks_cause_failures
# Solaris's sh exits with 1 here instead of 127
return if Facter.value(:operatingsystem) == "Solaris"
- exec = Puppet::Type.type(:exec).new(
- :command => "echo true",
- :path => ENV["PATH"],
- :onlyif => "/bin/nosuchthingexists"
- )
+
+ exec = Puppet::Type.type(:exec).new(
+
+ :command => "echo true",
+ :path => ENV["PATH"],
+
+ :onlyif => "/bin/nosuchthingexists"
+ )
assert_raise(ArgumentError, "Missing command did not raise error") {
exec.run("/bin/nosuchthingexists")
@@ -531,9 +612,12 @@ class TestExec < Test::Unit::TestCase
end
def test_envparam
+
exec = Puppet::Type.newexec(
+
:command => "echo $envtest",
:path => ENV["PATH"],
+
:env => "envtest=yayness"
)
@@ -550,11 +634,11 @@ class TestExec < Test::Unit::TestCase
assert_nothing_raised do
exec[:env] = "envtest=a list of things
and stuff"
- end
+ end
- output = status = nil
- assert_nothing_raised {
- output, status = exec.run('echo "$envtest"')
+ output = status = nil
+ assert_nothing_raised {
+ output, status = exec.run('echo "$envtest"')
}
assert_equal("a list of things\nand stuff\n", output)
@@ -571,9 +655,12 @@ and stuff"
end
def test_environmentparam
+
exec = Puppet::Type.newexec(
+
:command => "echo $environmenttest",
:path => ENV["PATH"],
+
:environment => "environmenttest=yayness"
)
@@ -590,11 +677,11 @@ and stuff"
assert_nothing_raised do
exec[:environment] = "environmenttest=a list of things
and stuff"
- end
+ end
- output = status = nil
- assert_nothing_raised {
- output, status = exec.run('echo "$environmenttest"')
+ output = status = nil
+ assert_nothing_raised {
+ output, status = exec.run('echo "$environmenttest"')
}
assert_equal("a list of things\nand stuff\n", output)
@@ -629,8 +716,11 @@ and stuff"
if Process.uid == 0
user = "nosuchuser"
assert_nothing_raised("Could not create exec with non-existent user") do
+
exec = Puppet::Type.type(:exec).new(
+
:command => "/bin/echo yay",
+
:user => user
)
end
@@ -639,8 +729,11 @@ and stuff"
# Now try the group
group = "nosuchgroup"
assert_nothing_raised("Could not create exec with non-existent user") do
+
exec = Puppet::Type.type(:exec).new(
+
:command => "/bin/echo yay",
+
:group => group
)
end
@@ -651,18 +744,15 @@ and stuff"
path = %w{/usr/bin /usr/sbin /sbin}
exec = nil
assert_nothing_raised("Could not use an array for the path") do
- exec = Puppet::Type.type(:exec).new(:command => "echo yay",
- :path => path)
+ exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => path)
end
assert_equal(path, exec[:path], "array-based path did not match")
assert_nothing_raised("Could not use a string for the path") do
- exec = Puppet::Type.type(:exec).new(:command => "echo yay",
- :path => path.join(":"))
+ exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => path.join(":"))
end
assert_equal(path, exec[:path], "string-based path did not match")
assert_nothing_raised("Could not use a colon-separated strings in an array for the path") do
- exec = Puppet::Type.type(:exec).new(:command => "echo yay",
- :path => ["/usr/bin", "/usr/sbin:/sbin"])
+ exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => ["/usr/bin", "/usr/sbin:/sbin"])
end
assert_equal(path, exec[:path], "colon-separated array path did not match")
end
@@ -670,10 +760,13 @@ and stuff"
def test_checks_apply_to_refresh
file = tempfile()
maker = tempfile()
- exec = Puppet::Type.type(:exec).new(
- :title => "maker",
- :command => "touch #{maker}",
- :path => ENV["PATH"]
+
+ exec = Puppet::Type.type(:exec).new(
+
+ :title => "maker",
+ :command => "touch #{maker}",
+
+ :path => ENV["PATH"]
)
# Make sure it runs normally
@@ -709,10 +802,13 @@ and stuff"
def test_explicit_refresh
refresher = tempfile()
maker = tempfile()
- exec = Puppet::Type.type(:exec).new(
- :title => "maker",
- :command => "touch #{maker}",
- :path => ENV["PATH"]
+
+ exec = Puppet::Type.type(:exec).new(
+
+ :title => "maker",
+ :command => "touch #{maker}",
+
+ :path => ENV["PATH"]
)
# Call refresh normally
diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb
index 5416d8ceb..24aab1fd6 100755
--- a/test/ral/type/file.rb
+++ b/test/ral/type/file.rb
@@ -119,10 +119,13 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:path => path,
:owner => user.name,
:ensure => "file",
+
:mode => "755"
)
}
@@ -149,8 +152,11 @@ class TestFile < Test::Unit::TestCase
obj = nil
assert_nothing_raised {
- obj = Puppet::Type.type(:file).new(
+
+ obj = Puppet::Type.type(:file).new(
+
:title => link,
+
:owner => user.name
)
}
@@ -280,8 +286,11 @@ class TestFile < Test::Unit::TestCase
assert(File.stat(file).uid > 120000, "eh?")
user = nonrootuser
- obj = Puppet::Type.newfile(
+
+ obj = Puppet::Type.newfile(
+
:path => file,
+
:owner => user.name
)
@@ -298,8 +307,11 @@ class TestFile < Test::Unit::TestCase
%w{a b c d}.collect { |name| tempfile() + name.to_s }.each { |path|
file =nil
assert_nothing_raised() {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => path,
+
:ensure => "file"
)
}
@@ -316,13 +328,15 @@ class TestFile < Test::Unit::TestCase
%w{a b c d}.collect { |name| "#{basedir}/%s" % name }.each { |path|
file = nil
assert_nothing_raised() {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => path,
+
:ensure => "directory"
)
}
- assert(! FileTest.directory?(path), "Directory %s already exists" %
- [path])
+ assert(! FileTest.directory?(path), "Directory %s already exists" % [path])
assert_events([:directory_created], file)
assert_events([], file)
assert(FileTest.directory?(path))
@@ -357,9 +371,12 @@ class TestFile < Test::Unit::TestCase
initstorage
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
param => path,
:recurse => true,
+
:checksum => "md5"
)
}
@@ -383,8 +400,11 @@ class TestFile < Test::Unit::TestCase
# Verify it retrieves files of type directory
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => tmpdir(),
+
:check => :type
)
}
@@ -393,8 +413,11 @@ class TestFile < Test::Unit::TestCase
# And then check files
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => tempfile(),
+
:ensure => "file"
)
}
@@ -419,9 +442,12 @@ class TestFile < Test::Unit::TestCase
file = nil
dirobj = nil
assert_nothing_raised("Could not make file object") {
- dirobj = Puppet::Type.type(:file).new(
+
+ dirobj = Puppet::Type.type(:file).new(
+
:path => dir,
:recurse => true,
+
:check => %w{mode owner group}
)
}
@@ -444,13 +470,19 @@ class TestFile < Test::Unit::TestCase
basedir = tempfile()
subfile = File.join(basedir, "subfile")
- baseobj = Puppet::Type.type(:file).new(
+
+ baseobj = Puppet::Type.type(:file).new(
+
:name => basedir,
+
:ensure => "directory"
)
- subobj = Puppet::Type.type(:file).new(
+
+ subobj = Puppet::Type.type(:file).new(
+
:name => subfile,
+
:ensure => "file"
)
catalog = mk_catalog(baseobj, subobj)
@@ -468,9 +500,12 @@ class TestFile < Test::Unit::TestCase
subpath = File.join(path, "this", "is", "a", "dir")
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => subpath,
:ensure => "directory",
+
:recurse => true
)
}
@@ -490,10 +525,13 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => dest,
:checksum => "md5",
:content => "This is some content",
+
:backup => false
)
}
@@ -511,9 +549,12 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => dest,
:checksum => "md5",
+
:ensure => "file"
)
}
@@ -530,9 +571,12 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:title => "fileness",
:path => path,
+
:content => "this is some content"
)
}
@@ -546,8 +590,11 @@ class TestFile < Test::Unit::TestCase
def test_missinggroup
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:path => tempfile(),
+
:group => "fakegroup"
)
}
@@ -557,21 +604,21 @@ class TestFile < Test::Unit::TestCase
def test_modecreation
path = tempfile()
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:path => path,
:ensure => "file",
+
:mode => "0777"
)
- assert_equal(0777, file.should(:mode),
- "Mode did not get set correctly")
+ assert_equal(0777, file.should(:mode), "Mode did not get set correctly")
assert_apply(file)
- assert_equal(0777, File.stat(path).mode & 007777,
- "file mode is incorrect")
+ assert_equal(0777, File.stat(path).mode & 007777, "file mode is incorrect")
File.unlink(path)
file[:ensure] = "directory"
assert_apply(file)
- assert_equal(0777, File.stat(path).mode & 007777,
- "directory mode is incorrect")
+ assert_equal(0777, File.stat(path).mode & 007777, "directory mode is incorrect")
end
# If both 'ensure' and 'content' are used, make sure that all of the other
@@ -581,10 +628,13 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:path => path,
:ensure => "file",
:content => "some text\n",
+
:mode => 0755
)
}
@@ -602,9 +652,12 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:ensure => path,
:path => link,
+
:backup => false
)
}
@@ -623,8 +676,11 @@ class TestFile < Test::Unit::TestCase
dest = File.join(dir, "another space")
File.open(source, "w") { |f| f.puts :yay }
- obj = Puppet::Type.type(:file).new(
+
+ obj = Puppet::Type.type(:file).new(
+
:path => dest,
+
:source => source
)
assert(obj, "Did not create file")
@@ -656,15 +712,21 @@ class TestFile < Test::Unit::TestCase
home = nil
ogroup = nil
assert_nothing_raised {
- user = Puppet::Type.type(:user).new(
+
+ user = Puppet::Type.type(:user).new(
+
:name => "pptestu",
:home => file,
+
:gid => "pptestg"
)
- home = Puppet::Type.type(:file).new(
+
+ home = Puppet::Type.type(:file).new(
+
:path => file,
:owner => "pptestu",
:group => "pptestg",
+
:ensure => "directory"
)
group = Puppet::Type.type(:group).new(
@@ -809,12 +871,14 @@ class TestFile < Test::Unit::TestCase
else
current = stat.send(should)
end
- assert_equal(sval, current,
- "Attr %s was not correct %s" % [should, msg])
+ assert_equal(sval, current, "Attr %s was not correct %s" % [should, msg])
end
end
- file = Puppet::Type.newfile(:path => path, :owner => user.name,
+
+ file = Puppet::Type.newfile(
+ :path => path, :owner => user.name,
+
:group => group.name, :mode => 0640, :backup => false)
{:source => source, :content => "some content"}.each do |attr, value|
file[attr] = value
diff --git a/test/ral/type/file/target.rb b/test/ral/type/file/target.rb
index 89792c4b6..6b252d28f 100755
--- a/test/ral/type/file/target.rb
+++ b/test/ral/type/file/target.rb
@@ -24,9 +24,12 @@ class TestFileTarget < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:title => "somethingelse",
:ensure => path,
+
:path => link
)
}
@@ -52,9 +55,12 @@ class TestFileTarget < Test::Unit::TestCase
system("mkdir -p %s" % subdir)
system("touch %s" % file)
- link = Puppet::Type.type(:file).new(
+
+ link = Puppet::Type.type(:file).new(
+
:ensure => source,
:path => path,
+
:recurse => true
)
@@ -96,9 +102,12 @@ class TestFileTarget < Test::Unit::TestCase
link = nil
assert_nothing_raised {
- link = Puppet::Type.type(:file).new(
+
+ link = Puppet::Type.type(:file).new(
+
:ensure => source,
:path => dest,
+
:recurse => true
)
}
@@ -131,8 +140,11 @@ class TestFileTarget < Test::Unit::TestCase
link = nil
assert_nothing_raised {
- link = Puppet::Type.type(:file).new(
+
+ link = Puppet::Type.type(:file).new(
+
:path => dest,
+
:ensure => "source"
)
}
@@ -148,15 +160,21 @@ class TestFileTarget < Test::Unit::TestCase
dest = tempfile()
resources = []
- resources << Puppet::Type.type(:exec).new(
+
+ resources << Puppet::Type.type(:exec).new(
+
:command => "mkdir %s; touch %s/file" % [source, source],
:title => "yay",
+
:path => ENV["PATH"]
)
- resources << Puppet::Type.type(:file).new(
+
+ resources << Puppet::Type.type(:file).new(
+
:ensure => source,
:path => dest,
:recurse => true,
+
:require => resources[0]
)
@@ -175,19 +193,28 @@ class TestFileTarget < Test::Unit::TestCase
prop = obj.send(:property, :target)
prop.send(:instance_variable_set, "@should", [:nochange])
- assert(prop.insync?(prop.retrieve),
+
+ assert(
+ prop.insync?(prop.retrieve),
+
"Property not in sync with should == :nochange")
prop = obj.send(:property, :target)
prop.send(:instance_variable_set, "@should", [:notlink])
- assert(prop.insync?(prop.retrieve),
+
+ assert(
+ prop.insync?(prop.retrieve),
+
"Property not in sync with should == :nochange")
# Lastly, make sure that we don't try to do anything when we're
# recursing, since 'ensure' does the work.
obj[:recurse] = true
prop.should = dest
- assert(prop.insync?(prop.retrieve),
+
+ assert(
+ prop.insync?(prop.retrieve),
+
"Still out of sync during recursion")
end
@@ -202,9 +229,12 @@ class TestFileTarget < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:ensure => path,
:path => link,
+
:backup => false
)
}
@@ -233,14 +263,20 @@ class TestFileTarget < Test::Unit::TestCase
File.open(file, "w") { |f| f.puts "yayness" }
File.symlink(file, link)
- obj = Puppet::Type.type(:file).new(
+
+ obj = Puppet::Type.type(:file).new(
+
:path => link,
+
:ensure => "file"
)
assert_apply(obj)
- assert_equal("yayness\n", File.read(file),
+
+ assert_equal(
+ "yayness\n", File.read(file),
+
"Original file got changed")
assert_equal("file", File.lstat(link).ftype, "File is still a link")
end
@@ -264,10 +300,13 @@ class TestFileTarget < Test::Unit::TestCase
File.open(sourcefile, "w") { |f| f.puts "source" }
File.symlink(file, link)
- obj = Puppet::Type.type(:file).new(
+
+ obj = Puppet::Type.type(:file).new(
+
:path => dirs["target"],
:ensure => :file,
:source => dirs["source"],
+
:recurse => true
)
config = mk_catalog obj
@@ -281,7 +320,10 @@ class TestFileTarget < Test::Unit::TestCase
assert_equal(File.read(sourcefile), File.read(newfile),
"File did not get copied correctly.")
- assert_equal("other\n", File.read(file),
+
+ assert_equal(
+ "other\n", File.read(file),
+
"Original file got changed")
assert_equal("file", File.lstat(link).ftype, "File is still a link")
end
@@ -294,8 +336,11 @@ class TestFileTarget < Test::Unit::TestCase
File.open(dest, "w") { |f| f.puts "boo" }
File.open(otherdest, "w") { |f| f.puts "yay" }
- obj = Puppet::Type.type(:file).new(
+
+ obj = Puppet::Type.type(:file).new(
+
:path => link,
+
:ensure => otherdest
)
diff --git a/test/ral/type/fileignoresource.rb b/test/ral/type/fileignoresource.rb
index ad68f703c..f158ac20d 100755
--- a/test/ral/type/fileignoresource.rb
+++ b/test/ral/type/fileignoresource.rb
@@ -56,23 +56,32 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#create source files
- File.open(File.join(frompath,sourcefile1),
- File::WRONLY|File::CREAT|File::APPEND) { |of|
- of.puts "yayness"
+
+ File.open(
+ File.join(frompath,sourcefile1),
+
+ File::WRONLY|File::CREAT|File::APPEND) { |of|
+ of.puts "yayness"
}
- File.open(File.join(frompath,sourcefile2),
- File::WRONLY|File::CREAT|File::APPEND) { |of|
- of.puts "even yayer"
+
+ File.open(
+ File.join(frompath,sourcefile2),
+
+ File::WRONLY|File::CREAT|File::APPEND) { |of|
+ of.puts "even yayer"
}
#makes Puppet file Object
assert_nothing_raised {
+
tofile = Puppet::Type.type(:file).new(
+
:name => topath,
:source => frompath,
:recurse => true,
+
:ignore => "sourcefile2"
)
}
@@ -119,24 +128,33 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#create source files
dir.each { |dir|
- File.open(File.join(dir,sourcefile1),
- File::WRONLY|File::CREAT|File::APPEND) { |of|
+
+ File.open(
+ File.join(dir,sourcefile1),
+
+ File::WRONLY|File::CREAT|File::APPEND) { |of|
of.puts "yayness"
}
- File.open(File.join(dir,sourcefile2),
- File::WRONLY|File::CREAT|File::APPEND) { |of|
- of.puts "even yayer"
+
+ File.open(
+ File.join(dir,sourcefile2),
+
+ File::WRONLY|File::CREAT|File::APPEND) { |of|
+ of.puts "even yayer"
}
}
#makes Puppet file Object
assert_nothing_raised {
+
tofile = Puppet::Type.type(:file).new(
+
:name => topath,
:source => frompath,
:recurse => true,
+
:ignore => "*2"
)
}
@@ -190,14 +208,20 @@ class TestFileIgnoreSources < Test::Unit::TestCase
sourcedir.each { |dir|
- File.open(File.join(dir,sourcefile1),
- File::WRONLY|File::CREAT|File::APPEND) { |of|
+
+ File.open(
+ File.join(dir,sourcefile1),
+
+ File::WRONLY|File::CREAT|File::APPEND) { |of|
of.puts "yayness"
}
- File.open(File.join(dir,sourcefile2),
- File::WRONLY|File::CREAT|File::APPEND) { |of|
- of.puts "even yayer"
+
+ File.open(
+ File.join(dir,sourcefile2),
+
+ File::WRONLY|File::CREAT|File::APPEND) { |of|
+ of.puts "even yayer"
}
}
@@ -205,12 +229,15 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#makes Puppet file Object
assert_nothing_raised {
+
tofile = Puppet::Type.type(:file).new(
+
:name => topath,
:source => frompath,
:recurse => true,
+
:ignore => ["*2", "an*"]
- # :ignore => ["*2", "an*", "nomatch"]
+ # :ignore => ["*2", "an*", "nomatch"]
)
}
diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb
index 408439d45..0ca09d2ff 100755
--- a/test/ral/type/filesources.rb
+++ b/test/ral/type/filesources.rb
@@ -13,7 +13,7 @@ class TestFileSources < Test::Unit::TestCase
include PuppetTest::FileTesting
def setup
super
- if defined? @port
+ if defined?(@port)
@port += 1
else
@port = 12345
@@ -59,10 +59,13 @@ class TestFileSources < Test::Unit::TestCase
tofile = nil
trans = nil
- tofile = Puppet::Type.type(:file).new(
+
+ tofile = Puppet::Type.type(:file).new(
+
:path => todir,
:recurse => true,
:backup => false,
+
:source => fromdir
)
catalog = mk_catalog(tofile)
@@ -192,10 +195,13 @@ class TestFileSources < Test::Unit::TestCase
File.open(file1, "w") { |f| f.puts "yay" }
rootobj = nil
assert_nothing_raised {
- rootobj = Puppet::Type.type(:file).new(
+
+ rootobj = Puppet::Type.type(:file).new(
+
:name => basedir,
:recurse => true,
:check => %w{type owner},
+
:mode => 0755
)
}
@@ -240,8 +246,11 @@ class TestFileSources < Test::Unit::TestCase
serverpid = nil
assert_nothing_raised("Could not start on port %s" % @port) {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:FileServer => {
@@ -264,8 +273,11 @@ class TestFileSources < Test::Unit::TestCase
sleep(1)
name = File.join(tmpdir(), "nosourcefile")
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:source => "puppet://localhost/noexist/file",
+
:name => name
)
@@ -291,8 +303,11 @@ class TestFileSources < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => to,
+
:source => files
)
}
@@ -316,9 +331,12 @@ class TestFileSources < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:name => dest,
:ensure => "file",
+
:source => source
)
}
@@ -357,9 +375,12 @@ class TestFileSources < Test::Unit::TestCase
# are.
def test_replace
dest = tempfile()
- file = Puppet::Type.newfile(
+
+ file = Puppet::Type.newfile(
+
:path => dest,
:content => "foobar",
+
:recurse => true
)
@@ -373,15 +394,13 @@ class TestFileSources < Test::Unit::TestCase
assert_apply(file)
# Make sure it doesn't change.
- assert_equal("yayness\n", File.read(dest),
- "File got replaced when :replace was false")
+ assert_equal("yayness\n", File.read(dest), "File got replaced when :replace was false")
file[:replace] = true
assert_apply(file)
# Make sure it changes.
- assert_equal("foobar", File.read(dest),
- "File was not replaced when :replace was true")
+ assert_equal("foobar", File.read(dest), "File was not replaced when :replace was true")
end
def test_sourceselect
@@ -406,7 +425,10 @@ class TestFileSources < Test::Unit::TestCase
}
end
- obj = Puppet::Type.newfile(:path => dest, :recurse => true,
+
+ obj = Puppet::Type.newfile(
+ :path => dest, :recurse => true,
+
:source => sources)
assert_equal(:first, obj[:sourceselect], "sourceselect has the wrong default")
diff --git a/test/ral/type/host.rb b/test/ral/type/host.rb
index 308e84bc0..81a4c0876 100755
--- a/test/ral/type/host.rb
+++ b/test/ral/type/host.rb
@@ -33,7 +33,7 @@ class TestHost < Test::Unit::TestCase
end
def mkhost
- if defined? @hcount
+ if defined?(@hcount)
@hcount += 1
else
@hcount = 1
@@ -43,10 +43,13 @@ class TestHost < Test::Unit::TestCase
host = nil
assert_nothing_raised {
- host = Puppet::Type.type(:host).new(
+
+ host = Puppet::Type.type(:host).new(
+
:name => "fakehost%s" % @hcount,
:ip => "192.168.27.%s" % @hcount,
:alias => "alias%s" % @hcount,
+
:catalog => @catalog
)
}
@@ -68,8 +71,11 @@ class TestHost < Test::Unit::TestCase
host = nil
assert_nothing_raised {
- host = Puppet::Type.type(:host).new(
+
+ host = Puppet::Type.type(:host).new(
+
:name => "culain",
+
:ip => "192.168.0.3"
)
}
diff --git a/test/ral/type/port.rb b/test/ral/type/port.rb
index ae5d89c2d..fa57cf55f 100755
--- a/test/ral/type/port.rb
+++ b/test/ral/type/port.rb
@@ -34,7 +34,7 @@ require 'puppettest'
# def mkport
# port = nil
#
-# if defined? @pcount
+# if defined?(@pcount)
# @pcount += 1
# else
# @pcount = 1
diff --git a/test/ral/type/sshkey.rb b/test/ral/type/sshkey.rb
index b68c14b34..a774af393 100755
--- a/test/ral/type/sshkey.rb
+++ b/test/ral/type/sshkey.rb
@@ -40,7 +40,7 @@ class TestSSHKey < Test::Unit::TestCase
def mkkey
key = nil
- if defined? @kcount
+ if defined?(@kcount)
@kcount += 1
else
@kcount = 1
@@ -48,11 +48,14 @@ class TestSSHKey < Test::Unit::TestCase
@catalog ||= mk_catalog
- key = @sshkeytype.new(
+
+ key = @sshkeytype.new(
+
:name => "host%s.madstop.com" % @kcount,
:key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount,
:type => "ssh-dss",
:alias => ["192.168.0.%s" % @kcount],
+
:catalog => @catalog
)
diff --git a/test/ral/type/user.rb b/test/ral/type/user.rb
index 797fa0139..8e1bc9359 100755
--- a/test/ral/type/user.rb
+++ b/test/ral/type/user.rb
@@ -27,7 +27,7 @@ class TestUser < Test::Unit::TestCase
end
def exists?
- if defined? @ensure and @ensure == :present
+ if defined?(@ensure) and @ensure == :present
true
else
false
@@ -64,11 +64,14 @@ class TestUser < Test::Unit::TestCase
def mkuser(name)
user = nil
assert_nothing_raised {
- user = Puppet::Type.type(:user).new(
+
+ user = Puppet::Type.type(:user).new(
+
:name => name,
:comment => "Puppet Testing User",
:gid => Puppet::Util::SUIDManager.gid,
:shell => findshell(),
+
:home => "/home/%s" % name
)
}
@@ -86,15 +89,21 @@ class TestUser < Test::Unit::TestCase
home = nil
ogroup = nil
assert_nothing_raised {
- user = Puppet::Type.type(:user).new(
+
+ user = Puppet::Type.type(:user).new(
+
:name => "pptestu",
:home => file,
:gid => "pptestg",
+
:groups => "yayness"
)
- home = Puppet::Type.type(:file).new(
+
+ home = Puppet::Type.type(:file).new(
+
:path => file,
:owner => "pptestu",
+
:ensure => "directory"
)
group = Puppet::Type.type(:group).new(
diff --git a/test/ral/type/yumrepo.rb b/test/ral/type/yumrepo.rb
index e1ac53820..fcfd73f99 100755
--- a/test/ral/type/yumrepo.rb
+++ b/test/ral/type/yumrepo.rb
@@ -67,9 +67,12 @@ class TestYumRepo < Test::Unit::TestCase
def test_absent
copy_datafiles
baseurl = 'http://example.com/'
- devel = make_repo("development",
- { :mirrorlist => 'absent',
- :baseurl => baseurl })
+
+ devel = make_repo(
+ "development",
+ { :mirrorlist => 'absent',
+
+ :baseurl => baseurl })
devel.retrieve
assert_apply(devel)
inifile = Puppet::Type.type(:yumrepo).read()
diff --git a/test/ral/type/zone.rb b/test/ral/type/zone.rb
index a784b8bcf..eaf850f59 100755
--- a/test/ral/type/zone.rb
+++ b/test/ral/type/zone.rb
@@ -21,9 +21,12 @@ class TestZone < PuppetTest::TestCase
File.chmod(0700, base)
root = File.join(base, "zonebase")
assert_nothing_raised {
+
zone = Puppet::Type.type(:zone).new(
+
:name => name,
:path => root,
+
:ensure => "configured" # don't want to install zones automatically
)
}
@@ -111,9 +114,11 @@ class TestZone < PuppetTest::TestCase
methods.each do |m|
Puppet::Type.type(:zone).suitableprovider.each do |prov|
- assert(prov.method_defined?(m),
- "Zone provider %s does not define method %s" %
- [prov.name, m])
+
+ assert(
+ prov.method_defined?(m),
+
+ "Zone provider %s does not define method %s" % [prov.name, m])
end
end
@@ -130,12 +135,18 @@ class TestZone < PuppetTest::TestCase
property = zone.property(:inherit)
assert(zone, "Did not get 'inherit' property")
- assert_equal("add inherit-pkg-dir\nset dir=/usr\nend", property.configtext,
+
+ assert_equal(
+ "add inherit-pkg-dir\nset dir=/usr\nend", property.configtext,
+
"Got incorrect config text")
zone.provider.inherit = "/usr"
- assert_equal("", property.configtext,
+
+ assert_equal(
+ "", property.configtext,
+
"Got incorrect config text")
# Now we want multiple directories
@@ -149,7 +160,10 @@ add inherit-pkg-dir
set dir=/sbin
end"
- assert_equal(text, property.configtext,
+
+ assert_equal(
+ text, property.configtext,
+
"Got incorrect config text")
zone.provider.inherit = %w{/usr /sbin /lib}
@@ -157,7 +171,10 @@ end"
text = "remove inherit-pkg-dir dir=/lib"
- assert_equal(text, property.configtext,
+
+ assert_equal(
+ text, property.configtext,
+
"Got incorrect config text")
end
end
@@ -230,13 +247,13 @@ set address=#{ip}
set physical=bge0
end
}
- end
+ end
- assert_equal(0, $?, "Did not successfully create zone")
+ assert_equal(0, $?, "Did not successfully create zone")
- hash = nil
- assert_nothing_raised {
- hash = zone.provider.send(:getconfig)
+ hash = nil
+ assert_nothing_raised {
+ hash = zone.provider.send(:getconfig)
}
zone[:check] = [:inherit, :autoboot]
@@ -247,14 +264,23 @@ end
end
# And make sure it gets set correctly.
- assert_equal(%w{/sbin /usr /opt/csw /lib /platform}.sort,
+
+ assert_equal(
+ %w{/sbin /usr /opt/csw /lib /platform}.sort,
+
values[:inherit].sort, "Inherited dirs did not get collected correctly."
)
- assert_equal(["#{interface}:#{ip}"], values[:ip],
+
+ assert_equal(
+ ["#{interface}:#{ip}"], values[:ip],
+
"IP addresses did not get collected correctly.")
- assert_equal(:true, values[:autoboot],
+
+ assert_equal(
+ :true, values[:autoboot],
+
"Autoboot did not get collected correctly.")
end
@@ -280,7 +306,10 @@ end
assert(zone.insync?(zone.retrieve), "Zone is not insync")
- assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /dir: \/sbin/,
+
+ assert(
+ %x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /dir: \/sbin/,
+
"sbin was not added")
# And then remove it.
@@ -291,7 +320,10 @@ end
assert(zone.insync?(zone.retrieve), "Zone is not insync")
- assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} !~ /dir: \/sbin/,
+
+ assert(
+ %x{/usr/sbin/zonecfg -z #{zone[:name]} info} !~ /dir: \/sbin/,
+
"sbin was not removed")
# Now add an ip adddress. Fortunately (or not), zonecfg doesn't verify
@@ -302,18 +334,19 @@ end
assert_apply(zone)
assert(zone.insync?(zone.retrieve), "Zone is not in sync")
- assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /192.168.0.1/,
+
+ assert(
+ %x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /192.168.0.1/,
+
"ip was not added")
zone[:ip] = ["hme1:192.168.0.2", "hme0:192.168.0.1"]
assert_apply(zone)
assert(zone.insync?(zone.retrieve), "Zone is not in sync")
- assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /192.168.0.2/,
- "ip was not added")
+ assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /192.168.0.2/, "ip was not added")
zone[:ip] = ["hme1:192.168.0.2"]
assert_apply(zone)
zone.retrieve
- assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} !~ /192.168.0.1/,
- "ip was not removed")
+ assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} !~ /192.168.0.1/, "ip was not removed")
end
# Test creating and removing a zone, but only up to the configured property,
@@ -345,7 +378,7 @@ end
currentvalues = zone.retrieve
assert_equal(:absent, currentvalues[zone.property(:ensure)],
- "Zone is not absent")
+ "Zone is not absent")
end
# Just go through each method linearly and make sure it works.
@@ -377,9 +410,7 @@ end
assert_nothing_raised {
current_values = zone.retrieve
}
- assert_equal(property, current_values[zone.property(:ensure)],
- "Method %s did not correctly set property %s" %
- [method, property])
+ assert_equal(property, current_values[zone.property(:ensure)], "Method %s did not correctly set property %s" % [method, property])
end
end
@@ -412,7 +443,7 @@ end
currentvalues = zone.retrieve
assert_equal(:absent, currentvalues[zone.property(:ensure)],
- "Zone is not absent")
+ "Zone is not absent")
end
end
diff --git a/test/util/classgen.rb b/test/util/classgen.rb
index 24908069d..83b64813c 100755
--- a/test/util/classgen.rb
+++ b/test/util/classgen.rb
@@ -55,14 +55,20 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
# Now make sure we can choose our own constant
assert_nothing_raised do
- const = sub.send(:handleclassconst, newklass, klass.name,
+
+ const = sub.send(
+ :handleclassconst, newklass, klass.name,
+
:constant => "Fooness")
end
assert(defined?(Baseconst::Fooness), "Specified constant was not defined")
# And make sure prefixes work
assert_nothing_raised do
- const = sub.send(:handleclassconst, newklass, klass.name,
+
+ const = sub.send(
+ :handleclassconst, newklass, klass.name,
+
:prefix => "Test")
end
assert(defined?(Baseconst::TestGenconst), "prefix was not used")
@@ -111,7 +117,10 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
assert(!klass.one, "'one' was already set")
- assert_nothing_raised do sub.send(:initclass, klass,
+
+ assert_nothing_raised do sub.send(
+ :initclass, klass,
+
:attributes => {:one => :a, :two => :b}) end
assert_equal(:a, klass.one, "Class was initialized incorrectly")
@@ -135,7 +144,10 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
assert(! klass.respond_to?(:extended), "Class already responds to extended")
assert(! klass.new.respond_to?(:included), "Class already responds to included")
- assert_nothing_raised do sub.send(:initclass, klass,
+
+ assert_nothing_raised do sub.send(
+ :initclass, klass,
+
:include => incl, :extend => ext)
end
@@ -150,8 +162,7 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
name = "yayness"
klass = nil
assert_nothing_raised {
- klass = GenTest.genclass(name, :array => array,
- :hash => hash, :parent => FakeBase) do
+ klass = GenTest.genclass(name, :array => array, :hash => hash, :parent => FakeBase) do
class << self
attr_accessor :name
end
@@ -160,9 +171,15 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
assert(klass.respond_to?(:name=), "Class did not execute block")
- assert(hash.include?(klass.name),
+
+ assert(
+ hash.include?(klass.name),
+
"Class did not get added to hash")
- assert(array.include?(klass),
+
+ assert(
+ array.include?(klass),
+
"Class did not get added to array")
assert_equal(klass.superclass, FakeBase, "Parent class was wrong")
end
@@ -209,10 +226,8 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
assert(mod.respond_to?(:yaytest), "Class did not execute block")
assert_instance_of(Module, mod)
- assert(hash.include?(mod.name),
- "Class did not get added to hash")
- assert(array.include?(mod),
- "Class did not get added to array")
+ assert(hash.include?(mod.name), "Class did not get added to hash")
+ assert(array.include?(mod), "Class did not get added to array")
end
def test_genconst_string
diff --git a/test/util/fileparsing.rb b/test/util/fileparsing.rb
index c88bcb23a..097254a50 100755
--- a/test/util/fileparsing.rb
+++ b/test/util/fileparsing.rb
@@ -21,21 +21,22 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
def test_lines
- assert_equal("\n", @parser.line_separator,
- "Default separator was incorrect")
+ assert_equal("\n", @parser.line_separator, "Default separator was incorrect")
{"\n" => ["one two\nthree four", "one two\nthree four\n"],
- "\t" => ["one two\tthree four", "one two\tthree four\t"],
+ "\t" => ["one two\tthree four", "one two\tthree four\t"],
}.each do |sep, tests|
assert_nothing_raised do
@parser.line_separator = sep
end
- assert_equal(sep, @parser.line_separator,
- "Did not set separator")
+
+ assert_equal(
+ sep, @parser.line_separator,
+
+ "Did not set separator")
tests.each do |test|
- assert_equal(["one two", "three four"], @parser.lines(test),
- "Incorrectly parsed %s" % test.inspect)
+ assert_equal(["one two", "three four"], @parser.lines(test), "Incorrectly parsed %s" % test.inspect)
end
end
end
@@ -72,8 +73,11 @@ class TestUtilFileParsing < Test::Unit::TestCase
# Make sure it matches
assert_nothing_raised do
- assert_equal({:record_type => :comment, :line => comment},
- @parser.parse_line(comment))
+
+ assert_equal(
+ {:record_type => :comment, :line => comment},
+
+ @parser.parse_line(comment))
end
# But not something else
@@ -88,14 +92,20 @@ class TestUtilFileParsing < Test::Unit::TestCase
# The comment should still match
assert_nothing_raised do
- assert_equal({:record_type => :comment, :line => comment},
- @parser.parse_line(comment))
+
+ assert_equal(
+ {:record_type => :comment, :line => comment},
+
+ @parser.parse_line(comment))
end
# As should our new line type
assert_nothing_raised do
- assert_equal({:record_type => :blank, :line => ""},
- @parser.parse_line(""))
+
+ assert_equal(
+ {:record_type => :blank, :line => ""},
+
+ @parser.parse_line(""))
end
end
@@ -141,13 +151,11 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
assert_nothing_raised("Did not parse old comment") do
- assert_equal({:record_type => :comment, :line => comment},
- @parser.parse_line(comment))
+ assert_equal({:record_type => :comment, :line => comment}, @parser.parse_line(comment))
end
comment = '" another type of comment'
assert_nothing_raised("Did not parse new comment") do
- assert_equal({:record_type => :comment2, :line => comment},
- @parser.parse_line(comment))
+ assert_equal({:record_type => :comment2, :line => comment}, @parser.parse_line(comment))
end
# Now define two overlapping record types and make sure we keep the
@@ -158,8 +166,7 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
assert_nothing_raised do
- assert_equal({:record_type => :one, :line => "yayness"},
- @parser.parse_line("yayness"))
+ assert_equal({:record_type => :one, :line => "yayness"}, @parser.parse_line("yayness"))
end
end
@@ -182,8 +189,7 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
# Make sure out tab line gets matched
- tabshould = {:record_type => :tabs, :name => "tab", :first => "separated",
- :second => "content"}
+ tabshould = {:record_type => :tabs, :name => "tab", :first => "separated", :second => "content"}
assert_nothing_raised do
assert_equal(tabshould, @parser.handle_record_line(tabrecord, tabs))
end
@@ -195,8 +201,7 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
# Now make sure both lines parse correctly
- spaceshould = {:record_type => :spaces, :name => "space",
- :first => "separated", :second => "content"}
+ spaceshould = {:record_type => :spaces, :name => "space", :first => "separated", :second => "content"}
assert_nothing_raised do
assert_equal(tabshould, @parser.handle_record_line(tabrecord, tabs))
@@ -243,8 +248,7 @@ class TestUtilFileParsing < Test::Unit::TestCase
ordered_records = order.collect { |name| records[name] }
# Make sure we default to a trailing separator
- assert_equal(true, @parser.trailing_separator,
- "Did not default to a trailing separtor")
+ assert_equal(true, @parser.trailing_separator, "Did not default to a trailing separtor")
# Start without a trailing separator
@parser.trailing_separator = false
@@ -280,7 +284,10 @@ class TestUtilFileParsing < Test::Unit::TestCase
result = nil
assert_nothing_raised do
- result = @parser.to_line(:record_type => :record,
+
+ result = @parser.to_line(
+ :record_type => :record,
+
:one => "a", :two => :absent, :three => "b")
end
@@ -289,15 +296,17 @@ class TestUtilFileParsing < Test::Unit::TestCase
# Now try using a different replacement character
record.absent = "*" # Because cron is a pain in my ass
assert_nothing_raised do
- result = @parser.to_line(:record_type => :record,
- :one => "a", :two => :absent, :three => "b")
+ result = @parser.to_line(:record_type => :record, :one => "a", :two => :absent, :three => "b")
end
assert_equal("a * b", result, "Absent was not correctly replaced")
# Make sure we deal correctly with the string 'absent'
assert_nothing_raised do
- result = @parser.to_line(:record_type => :record,
+
+ result = @parser.to_line(
+ :record_type => :record,
+
:one => "a", :two => "b", :three => 'absent')
end
@@ -305,7 +314,10 @@ class TestUtilFileParsing < Test::Unit::TestCase
# And, of course, make sure we can swap things around.
assert_nothing_raised do
- result = @parser.to_line(:record_type => :record,
+
+ result = @parser.to_line(
+ :record_type => :record,
+
:one => "a", :two => "b", :three => :absent)
end
@@ -318,14 +330,15 @@ class TestUtilFileParsing < Test::Unit::TestCase
# Check parsing first
result = @parser.parse_line(start)
[:one, :two].each do |param|
- assert_equal(record[param], result[param],
+
+ assert_equal(
+ record[param], result[param],
+
"Did not correctly parse %s" % start.inspect)
end
# And generating
- assert_equal(final, @parser.to_line(result),
- "Did not correctly generate %s from %s" %
- [final.inspect, record.inspect])
+ assert_equal(final, @parser.to_line(result), "Did not correctly generate %s from %s" % [final.inspect, record.inspect])
end
# First try it with symmetric characters
@@ -361,23 +374,32 @@ class TestUtilFileParsing < Test::Unit::TestCase
johnny one two
billy three four\n"
- # Just parse and generate, to make sure it's isomorphic.
- assert_nothing_raised do
- assert_equal(text, @parser.to_file(@parser.parse(text)),
- "parsing was not isomorphic")
+# Just parse and generate, to make sure it's isomorphic.
+assert_nothing_raised do
+ assert_equal(text, @parser.to_file(@parser.parse(text)),
+ "parsing was not isomorphic")
end
end
def test_valid_attrs
@parser.record_line :record, :fields => %w{one two three}
- assert(@parser.valid_attr?(:record, :one),
+
+ assert(
+ @parser.valid_attr?(:record, :one),
+
"one was considered invalid")
- assert(@parser.valid_attr?(:record, :ensure),
+
+ assert(
+ @parser.valid_attr?(:record, :ensure),
+
"ensure was considered invalid")
- assert(! @parser.valid_attr?(:record, :four),
+
+ assert(
+ ! @parser.valid_attr?(:record, :four),
+
"four was considered valid")
end
@@ -433,11 +455,9 @@ billy three four\n"
assert(result, "Did not get a result back for '%s'" % line)
should.each do |field|
if field == :alias and line =~ /null/
- assert_equal(%w{sink null}, result[field],
- "Field %s was not right in '%s'" % [field, line])
+ assert_equal(%w{sink null}, result[field], "Field %s was not right in '%s'" % [field, line])
else
- assert_equal(values[field], result[field],
- "Field %s was not right in '%s'" % [field, line])
+ assert_equal(values[field], result[field], "Field %s was not right in '%s'" % [field, line])
end
end
end
@@ -457,9 +477,9 @@ billy three four\n"
end
{ "a b c d" => [],
- "a b * d" => [:three],
- "a b * *" => [:three, :four],
- "a b c *" => [:four]
+ "a b * d" => [:three],
+ "a b * *" => [:three, :four],
+ "a b c *" => [:four]
}.each do |line, absentees|
record = nil
assert_nothing_raised do
@@ -495,7 +515,10 @@ billy three four\n"
:optional => %w{three four}
end
- assert_equal("a b ",
+
+ assert_equal(
+ "a b ",
+
@parser.to_line(:record_type => :record, :one => "a", :two => "b")
)
@@ -508,7 +531,10 @@ billy three four\n"
:rts => true
end
- assert_equal("a b",
+
+ assert_equal(
+ "a b",
+
@parser.to_line(:record_type => :record, :one => "a", :two => "b")
)
@@ -522,7 +548,10 @@ billy three four\n"
:rts => /[ *]+$/
end
- assert_equal("a b",
+
+ assert_equal(
+ "a b",
+
@parser.to_line(:record_type => :record, :one => "a", :two => "b")
)
end
@@ -536,7 +565,10 @@ billy three four\n"
assert_nothing_raised do
result = @parser.send(:parse_line, "Name One Two Three")
end
- assert_equal("Two Three", result[:two],
+
+ assert_equal(
+ "Two Three", result[:two],
+
"Did not roll up last fields by default")
@parser = FParser.new
@@ -548,7 +580,10 @@ billy three four\n"
assert_nothing_raised do
result = @parser.send(:parse_line, "Name One Two Three")
end
- assert_equal("Two", result[:two],
+
+ assert_equal(
+ "Two", result[:two],
+
"Rolled up last fields when rollup => false")
end
@@ -560,7 +595,10 @@ billy three four\n"
end
end
- assert(record.respond_to?(:process),
+
+ assert(
+ record.respond_to?(:process),
+
"Block was not used with text line")
assert_equal("YAYNESS", record.process("yayness")[:line],
@@ -616,8 +654,7 @@ class TestUtilFileRecord < Test::Unit::TestCase
assert_nothing_raised do
record = Record.new(:record, :fields => %w{one two})
end
- assert_equal([:one, :two], record.fields,
- "Did not symbolize fields")
+ assert_equal([:one, :two], record.fields, "Did not symbolize fields")
# Make sure we fail on invalid fields
[:record_type, :target, :on_disk].each do |field|
@@ -634,9 +671,8 @@ class TestUtilFileRecord < Test::Unit::TestCase
end
record = Record.new(:record, :fields => %w{fields})
- {:absent => "", :separator => /\s+/, :joiner => " ",
- :optional => []}.each do |field, default|
- assert_equal(default, record.send(field), "%s was not default" % field)
+ {:absent => "", :separator => /\s+/, :joiner => " ", :optional => []}.each do |field, default|
+ assert_equal(default, record.send(field), "%s was not default" % field)
end
end
@@ -650,10 +686,16 @@ class TestUtilFileRecord < Test::Unit::TestCase
line = "This is a line"
- assert(record.respond_to?(:process),
+
+ assert(
+ record.respond_to?(:process),
+
"Record did not define :process method")
- assert_equal(line.upcase, record.process(line),
+
+ assert_equal(
+ line.upcase, record.process(line),
+
"Record did not process line correctly")
end
diff --git a/test/util/inifile.rb b/test/util/inifile.rb
index 8ce52ee8d..b4d7f9353 100755
--- a/test/util/inifile.rb
+++ b/test/util/inifile.rb
@@ -29,22 +29,28 @@ class TestFileType < Test::Unit::TestCase
@file['main']['key2'] = 'newvalue2'
@file['main']['key3'] = 'newvalue3'
text = s.format
- assert_equal("[main]\nkey1=value1\n# Comment\nkey2=newvalue2\nkey3=newvalue3\n",
- s.format)
+
+ assert_equal(
+ "[main]\nkey1=value1\n# Comment\nkey2=newvalue2\nkey3=newvalue3\n",
+
+ s.format)
end
def test_multi
fmain = mkfile("[main]\nkey1=main.value1\n# Comment\nkey2=main.value2")
fsub = mkfile("[sub1]\nkey1=sub1 value1\n\n" +
- "[sub2]\nkey1=sub2.value1")
+ "[sub2]\nkey1=sub2.value1")
main_mtime = File::stat(fmain).mtime
assert_nothing_raised {
@file.read(fmain)
@file.read(fsub)
}
main = get_section('main')
- assert_entries(main,
- { 'key1' => 'main.value1', 'key2' => 'main.value2' })
+
+ assert_entries(
+ main,
+
+ { 'key1' => 'main.value1', 'key2' => 'main.value2' })
sub1 = get_section('sub1')
assert_entries(sub1, { 'key1' => 'sub1 value1' })
sub2 = get_section('sub2')
@@ -60,14 +66,17 @@ class TestFileType < Test::Unit::TestCase
assert( File.exists?(fsub) )
assert_equal(main_mtime, File::stat(fmain).mtime)
subtext = File.read(fsub)
- assert_equal("[sub1]\nkey1=sub1 newvalue1\n\n" +
- "[sub2]\nkey1=sub2.value1\nkey2=sub2 newvalue2\n",
- subtext)
+
+ assert_equal(
+ "[sub1]\nkey1=sub1 newvalue1\n\n" +
+ "[sub2]\nkey1=sub2.value1\nkey2=sub2 newvalue2\n",
+
+ subtext)
end
def test_format_nil
fname = mkfile("[main]\nkey1=value1\n# Comment\nkey2=value2\n" +
- "# Comment2\n")
+ "# Comment2\n")
assert_nothing_raised {
@file.read(fname)
}
@@ -75,8 +84,11 @@ class TestFileType < Test::Unit::TestCase
s['key2'] = nil
s['key3'] = nil
text = s.format
- assert_equal("[main]\nkey1=value1\n# Comment\n# Comment2\n",
- s.format)
+
+ assert_equal(
+ "[main]\nkey1=value1\n# Comment\n# Comment2\n",
+
+ s.format)
end
def test_whitespace
@@ -107,9 +119,12 @@ class TestFileType < Test::Unit::TestCase
def assert_entries(section, hash)
hash.each do |k, v|
- assert_equal(v, section[k],
- "Expected <#{v}> for #{section.name}[#{k}] " +
- "but got <#{section[k]}>")
+
+ assert_equal(
+ v, section[k],
+
+ "Expected <#{v}> for #{section.name}[#{k}] " +
+ "but got <#{section[k]}>")
end
end
diff --git a/test/util/log.rb b/test/util/log.rb
index b28d601e9..5fb30cf05 100755
--- a/test/util/log.rb
+++ b/test/util/log.rb
@@ -35,9 +35,12 @@ class TestLog < Test::Unit::TestCase
levels.collect { |level|
next if level == :alert
assert_nothing_raised() {
- Puppet::Util::Log.new(
+
+ Puppet::Util::Log.new(
+
:level => level,
:source => "Test",
+
:message => "Unit test for %s" % level
)
}
@@ -118,8 +121,11 @@ class TestLog < Test::Unit::TestCase
Puppet::Util::Log.newdestination :syslog
assert_nothing_raised {
- Puppet::Util::Log.new(
+
+ Puppet::Util::Log.new(
+
:level => :info,
+
:message => "A message with %s in it"
)
}
@@ -128,8 +134,11 @@ class TestLog < Test::Unit::TestCase
# Verify that the error and source are always strings
def test_argsAreStrings
msg = nil
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:path => tempfile(),
+
:check => %w{owner group}
)
assert_nothing_raised {
@@ -169,11 +178,9 @@ class TestLog < Test::Unit::TestCase
Puppet::Util::Log.close(:console)
Puppet::Util::Log.newdestination(file)
Puppet.warning "A test"
- assert(File.read(file) !~ /A test/,
- "File defualted to autoflush")
+ assert(File.read(file) !~ /A test/, "File defualted to autoflush")
Puppet::Util::Log.flush
- assert(File.read(file) =~ /A test/,
- "File did not flush")
+ assert(File.read(file) =~ /A test/, "File did not flush")
Puppet::Util::Log.close(file)
# Now try one with autoflush enabled
@@ -181,8 +188,7 @@ class TestLog < Test::Unit::TestCase
file = tempfile
Puppet::Util::Log.newdestination(file)
Puppet.warning "A test"
- assert(File.read(file) =~ /A test/,
- "File did not autoflush")
+ assert(File.read(file) =~ /A test/, "File did not autoflush")
Puppet::Util::Log.close(file)
end
@@ -206,8 +212,7 @@ class TestLog < Test::Unit::TestCase
# Now reopen the log
Puppet::Util::Log.reopen
Puppet.warning "Reopen test"
- assert(File.read(file) =~ /Reopen test/,
- "File did not reopen")
+ assert(File.read(file) =~ /Reopen test/, "File did not reopen")
Puppet::Util::Log.close(file)
end
end
diff --git a/test/util/package.rb b/test/util/package.rb
index b77850d4b..c252db1d8 100755
--- a/test/util/package.rb
+++ b/test/util/package.rb
@@ -11,8 +11,7 @@ class TestPuppetUtilPackage < Test::Unit::TestCase
include Puppet::Util::Package
def test_versioncmp
- ary = %w{ 1.1.6 2.3 1.1a 3.0 1.5 1 2.4 1.1-4
- 2.3.1 1.2 2.3.0 1.1-3 2.4b 2.4 2.40.2 2.3a.1 3.1 0002 1.1-5 1.1.a 1.06}
+ ary = %w{ 1.1.6 2.3 1.1a 3.0 1.5 1 2.4 1.1-4 2.3.1 1.2 2.3.0 1.1-3 2.4b 2.4 2.40.2 2.3a.1 3.1 0002 1.1-5 1.1.a 1.06}
newary = nil
assert_nothing_raised do
diff --git a/test/util/settings.rb b/test/util/settings.rb
index 272ced9f5..354a5d7fc 100755
--- a/test/util/settings.rb
+++ b/test/util/settings.rb
@@ -20,17 +20,23 @@ class TestSettings < Test::Unit::TestCase
def set_configs(config = nil)
config ||= @config
- config.setdefaults("main",
+
+ config.setdefaults(
+ "main",
:one => ["a", "one"],
:two => ["a", "two"],
:yay => ["/default/path", "boo"],
:mkusers => [true, "uh, yeah"],
+
:name => ["testing", "a"]
)
- config.setdefaults("section1",
+
+ config.setdefaults(
+ "section1",
:attr => ["a", "one"],
:attrdir => ["/another/dir", "two"],
+
:attr3 => ["$attrdir/maybe", "boo"]
)
end
@@ -183,13 +189,13 @@ class TestSettings < Test::Unit::TestCase
def test_parse_file
text = %{
-one = this is a test
-two = another test
-owner = root
-group = root
-yay = /a/path
+ one = this is a test
+ two = another test
+ owner = root
+ group = root
+ yay = /a/path
-[main]
+ [main]
four = five
six = seven
@@ -241,10 +247,13 @@ yay = /a/path
c = mkconfig
assert_nothing_raised {
- @config.setdefaults("testing",
+
+ @config.setdefaults(
+ "testing",
:onboolean => [true, "An on bool"],
:offboolean => [false, "An off bool"],
:string => ["a string", "A string arg"],
+
:file => ["/path/to/file", "A file arg"]
)
}
@@ -270,8 +279,7 @@ yay = /a/path
arg = val
end
- assert_nothing_raised("Could not handle arg %s with value %s" %
- [opt, val]) {
+ assert_nothing_raised("Could not handle arg %s with value %s" % [opt, val]) {
@config.handlearg(opt, arg)
}
@@ -280,12 +288,15 @@ yay = /a/path
end
def test_addargs
- @config.setdefaults("testing",
- :onboolean => [true, "An on bool"],
- :offboolean => [false, "An off bool"],
- :string => ["a string", "A string arg"],
- :file => ["/path/to/file", "A file arg"]
- )
+
+ @config.setdefaults(
+ "testing",
+ :onboolean => [true, "An on bool"],
+ :offboolean => [false, "An off bool"],
+ :string => ["a string", "A string arg"],
+
+ :file => ["/path/to/file", "A file arg"]
+ )
should = []
@config.each { |name, element|
@@ -303,10 +314,13 @@ yay = /a/path
def test_addargs_functional
@config = Puppet::Util::Settings.new
- @config.setdefaults("testing",
- :onboolean => [true, "An on bool"],
- :string => ["a string", "A string arg"]
- )
+
+ @config.setdefaults(
+ "testing",
+ :onboolean => [true, "An on bool"],
+
+ :string => ["a string", "A string arg"]
+ )
result = []
should = []
assert_nothing_raised("Add args failed") do
@@ -430,7 +444,10 @@ yay = /a/path
config = mkconfig
file = tempfile()
- config.setdefaults(:mysection,
+
+ config.setdefaults(
+ :mysection,
+
:mydir => [file, "a file"]
)
@@ -442,7 +459,10 @@ yay = /a/path
assert(FileTest.directory?(file), "Directory did not get created")
- assert_equal("yayness", Puppet[:tags],
+
+ assert_equal(
+ "yayness", Puppet[:tags],
+
"Tags got changed during config")
end
@@ -457,7 +477,10 @@ yay = /a/path
val = config[:url]
}
- assert_equal("http://yayness/rahness", val,
+
+ assert_equal(
+ "http://yayness/rahness", val,
+
"Settings got messed up")
end
@@ -485,8 +508,11 @@ yay = /a/path
}
elem = config.setting(name)
- assert_instance_of(type, elem,
- "%s got created as wrong type" % value.inspect)
+
+ assert_instance_of(
+ type, elem,
+
+ "%s got created as wrong type" % value.inspect)
end
end
@@ -506,12 +532,12 @@ yay = /a/path
none = one
middle = mid"quote
}
- }
+ }
- config.setdefaults(:mysection, :config => [file, "eh"])
+ config.setdefaults(:mysection, :config => [file, "eh"])
- assert_nothing_raised {
- config.parse
+ assert_nothing_raised {
+ config.parse
}
%w{singleq doubleq none}.each do |p|
@@ -574,8 +600,11 @@ yay = /a/path
def test_no_modify_root
config = mkconfig
- config.setdefaults(:yay,
+
+ config.setdefaults(
+ :yay,
:mydir => {:default => tempfile(),
+
:mode => 0644,
:owner => "root",
:group => "service",
@@ -643,25 +672,37 @@ yay = /a/path
end
def test_multiple_interpolations
- @config.setdefaults(:section,
+
+ @config.setdefaults(
+ :section,
:one => ["oneval", "yay"],
:two => ["twoval", "yay"],
+
:three => ["$one/$two", "yay"]
)
- assert_equal("oneval/twoval", @config[:three],
+
+ assert_equal(
+ "oneval/twoval", @config[:three],
+
"Did not interpolate multiple variables")
end
# Make sure we can replace ${style} var names
def test_curly_replacements
- @config.setdefaults(:section,
+
+ @config.setdefaults(
+ :section,
:one => ["oneval", "yay"],
:two => ["twoval", "yay"],
+
:three => ["$one/${two}/${one}/$two", "yay"]
)
- assert_equal("oneval/twoval/oneval/twoval", @config[:three],
+
+ assert_equal(
+ "oneval/twoval/oneval/twoval", @config[:three],
+
"Did not interpolate curlied variables")
end
@@ -682,16 +723,25 @@ yay = /a/path
def test_celement_short_name_not_duplicated
config = mkconfig
assert_nothing_raised("Could not create celement with short name.") do
- config.setdefaults(:main,
- :one => { :default => "blah", :desc => "anything", :short => "o" })
+
+ config.setdefaults(
+ :main,
+
+ :one => { :default => "blah", :desc => "anything", :short => "o" })
end
assert_nothing_raised("Could not create second celement with short name.") do
- config.setdefaults(:main,
- :two => { :default => "blah", :desc => "anything", :short => "i" })
+
+ config.setdefaults(
+ :main,
+
+ :two => { :default => "blah", :desc => "anything", :short => "i" })
end
assert_raise(ArgumentError, "Could create second celement with duplicate short name.") do
- config.setdefaults(:main,
- :three => { :default => "blah", :desc => "anything", :short => "i" })
+
+ config.setdefaults(
+ :main,
+
+ :three => { :default => "blah", :desc => "anything", :short => "i" })
end
# make sure that when the above raises an expection that the config is not included
assert(!config.include?(:three), "Invalid configuration item was retained")
@@ -706,12 +756,18 @@ yay = /a/path
assert_equal([["--foo", "-n", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")
element = BooleanSetting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new
- assert_equal([["--foo", GetoptLong::NO_ARGUMENT], ["--no-foo", GetoptLong::NO_ARGUMENT]],
- element.getopt_args, "Did not produce appropriate getopt args")
+
+ assert_equal(
+ [["--foo", GetoptLong::NO_ARGUMENT], ["--no-foo", GetoptLong::NO_ARGUMENT]],
+
+ element.getopt_args, "Did not produce appropriate getopt args")
element.short = "n"
- assert_equal([["--foo", "-n", GetoptLong::NO_ARGUMENT],["--no-foo", GetoptLong::NO_ARGUMENT]],
- element.getopt_args, "Did not produce appropriate getopt args")
+
+ assert_equal(
+ [["--foo", "-n", GetoptLong::NO_ARGUMENT],["--no-foo", GetoptLong::NO_ARGUMENT]],
+
+ element.getopt_args, "Did not produce appropriate getopt args")
end
end
diff --git a/test/util/storage.rb b/test/util/storage.rb
index b0efff317..2259a59d2 100755
--- a/test/util/storage.rb
+++ b/test/util/storage.rb
@@ -12,8 +12,11 @@ class TestStorage < Test::Unit::TestCase
path = tempfile()
File.open(path, "w") { |f| f.puts :yayness }
- f = Puppet::Type.type(:file).new(
+
+ f = Puppet::Type.type(:file).new(
+
:name => path,
+
:check => %w{checksum type}
)
diff --git a/test/util/subclass_loader.rb b/test/util/subclass_loader.rb
index 0efd636f4..ca2522dbf 100755
--- a/test/util/subclass_loader.rb
+++ b/test/util/subclass_loader.rb
@@ -15,7 +15,7 @@ class TestPuppetUtilSubclassLoader < Test::Unit::TestCase
def mk_subclass(name, path, parent)
# Make a fake client
- unless defined? @basedir
+ unless defined?(@basedir)
@basedir ||= tempfile()
$: << @basedir
cleanup { $:.delete(@basedir) if $:.include?(@basedir) }
@@ -40,8 +40,7 @@ class TestPuppetUtilSubclassLoader < Test::Unit::TestCase
fake = LoadTest.faker(:fake)
end
assert_nothing_raised do
- assert_equal(fake, LoadTest.fake,
- "Did not get subclass back from main method")
+ assert_equal(fake, LoadTest.fake, "Did not get subclass back from main method")
end
assert(fake, "did not load subclass")
@@ -83,10 +82,8 @@ class TestPuppetUtilSubclassLoader < Test::Unit::TestCase
end
assert(othersub, "did not get other sub")
assert(mainsub, "did not get main sub")
- assert(othersub.ancestors.include?(OtherLoader),
- "othersub is not a subclass of otherloader")
- assert(mainsub.ancestors.include?(LoadTest),
- "mainsub is not a subclass of loadtest")
+ assert(othersub.ancestors.include?(OtherLoader), "othersub is not a subclass of otherloader")
+ assert(mainsub.ancestors.include?(LoadTest), "mainsub is not a subclass of loadtest")
end
end
diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb
index 62179084f..82016f3aa 100755
--- a/test/util/utiltest.rb
+++ b/test/util/utiltest.rb
@@ -78,8 +78,7 @@ class TestPuppetUtil < Test::Unit::TestCase
end
[:yay, "cool"].each do |var|
- assert_equal(inst.hash[var], inst[var],
- "Var %s did not take" % var)
+ assert_equal(inst.hash[var], inst[var], "Var %s did not take" % var)
end
assert_nothing_raised do
@@ -88,8 +87,7 @@ class TestPuppetUtil < Test::Unit::TestCase
end
[:Yay, "Cool"].each do |var|
- assert_equal(inst.hash[var], inst[var],
- "Var %s did not take" % var)
+ assert_equal(inst.hash[var], inst[var], "Var %s did not take" % var)
end
end
@@ -191,31 +189,34 @@ class TestPuppetUtil < Test::Unit::TestCase
end
def test_lang_environ_in_execute
- orig_lang = ENV["LANG"]
- orig_lc_all = ENV["LC_ALL"]
- orig_lc_messages = ENV["LC_MESSAGES"]
- orig_language = ENV["LANGUAGE"]
-
- cleanup do
- ENV["LANG"] = orig_lang
- ENV["LC_ALL"] = orig_lc_all
- ENV["LC_MESSAGES"] = orig_lc_messages
- ENV["LANGUAGE"] = orig_lc_messages
- end
-
- # Mmm, we love gettext(3)
- ENV["LANG"] = "en_US"
- ENV["LC_ALL"] = "en_US"
- ENV["LC_MESSAGES"] = "en_US"
- ENV["LANGUAGE"] = "en_US"
-
- %w{LANG LC_ALL LC_MESSAGES LANGUAGE}.each do |env|
- assert_equal('C',
- Puppet::Util.execute(['ruby', '-e', "print ENV['#{env}']"]),
- "Environment var #{env} wasn't set to 'C'")
-
- assert_equal 'en_US', ENV[env], "Environment var #{env} not set back correctly"
- end
+ orig_lang = ENV["LANG"]
+ orig_lc_all = ENV["LC_ALL"]
+ orig_lc_messages = ENV["LC_MESSAGES"]
+ orig_language = ENV["LANGUAGE"]
+
+ cleanup do
+ ENV["LANG"] = orig_lang
+ ENV["LC_ALL"] = orig_lc_all
+ ENV["LC_MESSAGES"] = orig_lc_messages
+ ENV["LANGUAGE"] = orig_lc_messages
+ end
+
+ # Mmm, we love gettext(3)
+ ENV["LANG"] = "en_US"
+ ENV["LC_ALL"] = "en_US"
+ ENV["LC_MESSAGES"] = "en_US"
+ ENV["LANGUAGE"] = "en_US"
+
+ %w{LANG LC_ALL LC_MESSAGES LANGUAGE}.each do |env|
+
+ assert_equal(
+ 'C',
+ Puppet::Util.execute(['ruby', '-e', "print ENV['#{env}']"]),
+
+ "Environment var #{env} wasn't set to 'C'")
+
+ assert_equal 'en_US', ENV[env], "Environment var #{env} not set back correctly"
+ end
end