README.md in chef-sugar-1.2.6 vs README.md in chef-sugar-1.3.0
- old
+ new
@@ -1,18 +1,25 @@
Chef::Sugar
================
-[](http://travis-ci.org/sethvargo/chef-sugar)
-[](http://badge.fury.io/rb/chef-sugar)
-[](https://gemnasium.com/sethvargo/chef-sugar)
-[](https://codeclimate.com/github/sethvargo/chef-sugar)
+[][gem]
+[][travis]
+[][gemnasium]
+[][codeclimate]
+[][gittip]
-Chef Sugar is a Gem & Chef Recipe that includes series of helpful sugar of the Chef core and other resources to make a cleaner, more lean recipd DSL, enforce DRY principles, and make writing Chef recipes an awesome experience!
+[gem]: https://rubygems.org/gems/chef-sugar
+[travis]: http://travis-ci.org/sethvargo/chef-suguar
+[gemnasium]: https://gemnasium.com/sethvargo/chef-sugar
+[codeclimate]: https://codeclimate.com/github/sethvargo/chef-sugar
+[gittip]: https://www.gittip.com/sethvargo
+Chef Sugar is a Gem & Chef Recipe that includes series of helpful sugar of the Chef core and other resources to make a cleaner, more lean recipe DSL, enforce DRY principles, and make writing Chef recipes an awesome experience!
+
Installation
------------
-If you want to development/hack on chef-sugar, please see the Contributing.md.
+If you want to develop/hack on chef-sugar, please see the Contributing.md.
If you are using Berkshelf, add `chef-sugar` to your `Berksfile`:
```ruby
cookbook 'chef-sugar'
@@ -105,10 +112,35 @@
ipaddress: cloud? ? node['local_ipv4'] : node['public_ipv4']
)
end
```
+### Core Extensions
+**Note:** Core extensions are **not** included by default. You must require the `chef/sugar/core_extensions` module manually to gain access to these APIs:
+
+```ruby
+require 'chef/sugar/core_extensions'
+```
+
+- `String#satisfies?`
+- `String#satisfied_by?`
+- `Array#satisfied_by?`
+- `Object#blank?`
+
+#### Examples
+```ruby
+# Checking version constraints
+'1.0.0'.satisfies?('~> 1.0') #=> true
+'~> 1.0'.satisfied_by?('1.0') #=> true
+```
+
+```ruby
+# Check for an object's presence
+''.blank? #=> true
+['hello'].blank? #=> false
+```
+
### Data Bag
- `encrypted_data_bag_item` - a handy DSL method for loading encrypted data bag items the same way you load a regular data bag item; this requires `Chef::Config[:encrypted_data_bag_secret]` is set!
- `encrypted_data_bag_item_for_environment` - find the data bag entry for the current node's Chef environment.
#### Examples
@@ -217,11 +249,10 @@
### Node
- `deep_fetch` - safely fetch a nested attribute.
- `deep_fetch!` - fetch a nested attribute, raising a more semantic error if the key does not exist.
- `in?` - determine if the node is in the given Chef environment.
-- `includes_recipe?`
#### Examples
```ruby
credentials = if in?('production')
Chef::EncryptedDataBag.new('...')
@@ -229,18 +260,10 @@
data_bag('...')
end
```
```ruby
-if includes_recipe?('apache2::default')
- apache_module 'my_module' do
- # ...
- end
-end
-```
-
-```ruby
node.deep_fetch('apache2', 'config', 'root') => node['apache2']['config']['root']
```
### Platform
- `amazon_linux?`
@@ -303,9 +326,20 @@
- `ruby_19?`
#### Examples
```ruby
log 'This has been known to fail on Ruby 2.0' if ruby_20?
+```
+
+### Run Context
+- `includes_recipe?` - determines if the current run context includes the recipe
+
+```ruby
+if includes_recipe?('apache2::default')
+ apache_module 'my_module' do
+ # ...
+ end
+end
```
### Shell
- `which`
- `dev_null`