Book Image

Mastering Chef

By : Mayank Joshi
Book Image

Mastering Chef

By: Mayank Joshi

Overview of this book

Table of Contents (20 chapters)
Mastering Chef
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Knife and Its Associated Plugins
10
Data Bags and Templates
Index

Attribute naming


This can be confusing for some people, especially those who aren't coming from the Ruby world. You looked up two different cookbooks and, in one of them, you found something like the following in the attributes file:

default[:app][:user] = "web-admin"

On the other hand, the other cookbook had something like the following:

default['app]['user'] = "web-admin"

These are two different styles of specifying the keys in a Ruby hash. In one, you are making use of symbols; in the other, you are using strings. You can choose either of these but, for the sake of sanity, try to be consistent. There are some pitfalls in using either approach and there are some inherent benefits too. For example, symbols are immutable and are allocated just once, which is a performance gain. On the other hand, they can be pretty irritating if you are trying to include stuff such as hyphens in their names. If symbols confuse you, stick with strings or vice-versa.

Note

One of the popular lint tools called Foodcritic...