README.md in rodimus-1.3.0 vs README.md in rodimus-1.3.1
- old
+ new
@@ -28,9 +28,45 @@
## Usage
tl;dr: See the examples directory for the quickest path to success.
+```ruby
+require 'rodimus'
+require 'csv'
+require 'json'
+
+class CsvInput < Rodimus::Step
+ def before_run_set_incoming
+ @incoming = CSV.open('examples/worldbank-sample.csv')
+ @incoming.readline # skip the headers
+ end
+
+ def process_row(row)
+ row.to_json
+ end
+end
+
+class FormattedText < Rodimus::Step
+ def before_run_set_stdout
+ @outgoing = STDOUT.dup
+ end
+
+ def process_row(row)
+ data = JSON.parse(row)
+ "In #{data.first} during #{data[1]}, CO2 emissions were #{data[2]} metric tons per capita."
+ end
+end
+
+t = Rodimus::Transformation.new
+s1 = CsvInput.new
+s2 = FormattedText.new
+t.steps << s1
+t.steps << s2
+t.run
+puts "Transformation complete!"
+```
+
A transformation is an operation that consists of many steps. Each step may
manipulate the data in some way. Typically, the first step is reserved for
reading from your data source, and the last step is used to write to the new
destination.