Skip to content

Commit

Permalink
add changelog for 0.5 and some extended documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarres-mdsol committed Feb 21, 2013
1 parent 3e8bdad commit cd51aa5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
# 0.5

* Generated templates should be commited to the git repo
* New extension .dice for Dicebag's templates

# 0.4.1

* Bugfix: templates are generated in config/ for Rails projects
Expand Down
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -12,7 +12,7 @@ templates for common configuration files are provided.
Add the following to your `Gemfile`:

```ruby
gem 'dice_bag', :git => 'git@github.com:mdsol/dice_bag.git'
gem 'dice_bag'
```

If you are using these tasks outside of a Rails project, add the following to
Expand All @@ -30,12 +30,14 @@ Run the following command to see the new tasks:

## Create configuration files from templates

When the rake task `config` is run, configuration files in the `config`
directory are generated by looking for ERB template files with the `.erb`
extension in that directory. Configuration values from the environment are made
When the rake task `config` is run, configuration files are generated
for any Dice bag template file you have in your configuration directory.
Templates have a default .dice extension and in the future this will be
the only supported extension.
Configuration values from the environment are made
available to the templates through the `configured` object.

For example, given the `config/database.yml.erb` file contains this template:
For example, given the `config/database.yml.dice` file contains this template:

```erb
development:
Expand Down
13 changes: 12 additions & 1 deletion templates.md
Expand Up @@ -20,8 +20,19 @@ class MyTemplates << Dicebag::AvailableTemplates
def templates
all_templates = []
pwd = File.dirname(__FILE__)
all_templates.push(File.join(pwd, "my_template.yml.erb))
all_templates.push(File.join(pwd, "my_template.yml.dice))
all_templates
end
end
```
This class has to be load in memory when your rake task is executed.
If you are adding a template to a gem called 'gem_name'. Make sure the file with this
class is loaded from 'lib/gem_name.rb' in your Gem. When the Gem is
required this file will be in memory and Dicebag will find it.
The Template file you need to create will be rendered by ERB. This gives
you flexibility to introduce logic in your template.
You can use the 'configured' object to get the information from
environment variables.
Check the default templates from Dicebag for examples.

0 comments on commit cd51aa5

Please sign in to comment.