<commit_before># Effective

Let's you choose between a 'current' and 'desired' state through a series of
conditional checks, and run triggers based on the results.

## Installation

Add this line to your application's Gemfile:

    gem 'effective'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install effective

## Usage

```ruby
require 'effective'

e = Effective.new(1, 2)
e.condition("always true", lambda { true })
result, data = e.check
puts result
# Success, result == 2 

e.condition("always false", lambda { false })
result, data = e.check
puts result
# Failure, result == 1

result, data = e.check("or")
puts result
# Success, result == 2, because we are "or" not "and"-ing.
```

## Inside Chef

### Data Bag state_fantastic

#### Data Bag Item "2005..."

{
  id: "2005..",
  "data": {
    ... # whatever # ..
  },
  "operator": "and",
  "retry_count": 10,
  "random_wait": 10,
  "conditions": { 
    "by fqdn" => {
      "query" => "fqdn:* AND role:fantastic",
      "attribute" => [ "fqdn" ]
    }
  }
}

### Environment Attributes

default[:effective] = {
  "state" => {
    "fantastic" => {
      "desired" => "2005..."
    }
  }
}

### Node Attributes

default[:effective] = {
  "state" => {
    "fantastic" => {
      "current" => "2004..." # ideally discovered by an attribute lookup
    }
  }
}

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

New contributors will need to sign a CLA at http://wiki.opscode.com/display/chef/How+to+Contribute.
<commit_msg>Adding some syntax highlighting to the readme<commit_after># Effective

Let's you choose between a 'current' and 'desired' state through a series of
conditional checks, and run triggers based on the results.

## Installation

Add this line to your application's Gemfile:

    gem 'effective'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install effective

## Usage

```ruby
require 'effective'

e = Effective.new(1, 2)
e.condition("always true", lambda { true })
result, data = e.check
puts result
# Success, result == 2 

e.condition("always false", lambda { false })
result, data = e.check
puts result
# Failure, result == 1

result, data = e.check("or")
puts result
# Success, result == 2, because we are "or" not "and"-ing.
```

## Inside Chef

### Data Bag state_fantastic

#### Data Bag Item "2005..."

```javascript
{
  id: "2005..",
  "data": {
  },
  "operator": "and",
  "retry_count": 10,
  "random_wait": 10,
  "conditions": { 
    "by fqdn" => {
      "query" => "fqdn:* AND role:fantastic",
      "attribute" => [ "fqdn" ]
    }
  }
}
```

### Environment Attributes

```ruby
default[:effective] = {
  "state" => {
    "fantastic" => {
      "desired" => "2005..."
    }
  }
}
```
### Node Attributes

```ruby
default[:effective] = {
  "state" => {
    "fantastic" => {
      "current" => "2004..." # ideally discovered by an attribute lookup
    }
  }
}
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

New contributors will need to sign a CLA at http://wiki.opscode.com/display/chef/How+to+Contribute.

{'fraction_non_alphanumeric': 0.1551673944687045, 'fraction_numerical': 0.017467248908296942, 'mean_word_length': 3.231527093596059, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '545152', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1120, 'n_words': 380}