Sha256: db79366f97f93d34b2f8089df298d9e7435f96c0ad3091758db14c59628c7aee

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require_relative "data_handler_base"
require_relative "../../environment"

class Chef
  module ChefFS
    module DataHandler
      class EnvironmentDataHandler < DataHandlerBase
        def normalize(environment, entry)
          normalize_hash(environment, {
            "name" => remove_file_extension(entry.name),
            "description" => "",
            "cookbook_versions" => {},
            "default_attributes" => {},
            "override_attributes" => {},
            "json_class" => "Chef::Environment",
            "chef_type" => "environment",
          })
        end

        def preserve_key?(key)
          key == "name"
        end

        def chef_class
          Chef::Environment
        end

        def to_ruby(object)
          result = to_ruby_keys(object, %w{name description default_attributes override_attributes})
          if object["cookbook_versions"]
            object["cookbook_versions"].each_pair do |name, version|
              result << "cookbook #{name.inspect}, #{version.inspect}"
            end
          end
          result
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chef-15.0.300-universal-mingw32 lib/chef/chef_fs/data_handler/environment_data_handler.rb
chef-15.0.298-universal-mingw32 lib/chef/chef_fs/data_handler/environment_data_handler.rb
chef-15.0.293-universal-mingw32 lib/chef/chef_fs/data_handler/environment_data_handler.rb