README.md in filegen-0.3.1 vs README.md in filegen-0.4.0
- old
+ new
@@ -24,11 +24,11 @@
$ gem install filegen
This gem ships with an executable called `filegen`. It makes the power of ERB
available on the commandline.
-## Usage
+## Usage on Commandline
### General advice
Please make sure you have an ERB-template available. It needs to end with
`.erb`! Place in anywhere you like. It's important that the name of variable in
@@ -125,10 +125,52 @@
```text
Hello my name is: Karl
```
+## Usage within ruby
+
+### Hash with Symbol-Keys
+
+```ruby
+require 'filegen'
+require 'stringio'
+
+template = <<-EOS
+Hi <%= lookup('name') %>
+EOS
+
+data = {
+ name: 'Karl'
+}
+
+generator = Filegen::Rubygen.new
+puts generator.run(template, data)
+
+# => Hi Karl
+```
+
+### Hash with String-Keys
+
+```ruby
+require 'filegen'
+require 'stringio'
+
+template = <<-EOS
+Hi <%= lookup('name') %>
+EOS
+
+data = {
+ 'name' => 'Karl'
+}
+
+generator = Filegen::Rubygen.new
+puts generator.run(template, data)
+
+# => Hi Karl
+```
+
## Use Cases
### RPM packaging
Say you would like to package a ruby-based application for a rpm-based
@@ -160,11 +202,10 @@
chmod +x <wrapper>
```
## Future
-* Maybe I will add additional data sources. Please see the
- [Moneta](https://github.com/minad/moneta)-gem for possible candidates.
+* Maybe I will add additional data sources.
## Contributing
Please have a look at the {file:README.DEVELOPER.md developer readme}