README.rdoc in tronprint-0.0.6 vs README.rdoc in tronprint-0.0.7
- old
+ new
@@ -18,11 +18,12 @@
== Getting Started
If you haven't already, go to http://keys.brighterplanet.com and sign up for an
API key. Non-commercial use of CM1 is free, but commercial use is
-{charged}[http://carbon.brighterplanet.com/pricing] per-query.
+{charged}[http://carbon.brighterplanet.com/pricing] per-query. Heroku users are
+charged per-month.
=== Rails
Add tronprint to your Gemfile:
@@ -42,24 +43,29 @@
built-in view helper: TronprintHelper. Feel free to cache your footprint
to minimize the number of API requests made to CM1.
==== Heroku
+Tronprint is available as a Heroku add-on. Add tronprint to your app, and
+your app will have an environment variable provided: `ENV['TRONPRINT_API_KEY']`.
+
+The tronprint gem will handle API key setup for you, but you will still
+need to configure your app to store statistics in MongoDB.
+
The easiest way to get started on Heroku is to sign up for a free MongoHQ
account to be used for the Tronprint::Aggregator. Since Heroku doesn't
allow access to the filesystem, Tronprint::Aggregator's default YAML
-storage option will not work. Once you have MongoDB set up, change
-config/tronprint.yml to:
+storage option will not work. Once you have MongoDB set up, configure
+tronprint with a Rails initializer:
- ---
- :aggregator_options:
- :adapter: :mongodb
- :host: example.mongohq.com
- :port: 1234
- :db: tronprint
- :collection: tronprint
- :application_name: my_app
+1. Open a new file, config/initializers/tronprint.rb
+1. In it, write:
+ Tronprint.aggregator_options = {
+ :adapter => :mongodb,
+ :uri => ENV['MONGOHQ_URL'],
+ :collection => 'tronprint'
+ }
=== Other Ruby Apps
Tronprint will work with any Ruby app, but you have to do a little self-configuration.
@@ -71,25 +77,36 @@
returns an instance of {Carbon::EmissionEstimate}[https://github.com/brighterplanet/carbon/blob/master/lib/carbon/emission_estimate.rb].
It can be converted to a float for the amount in kilograms or other
methods, such as EmissionEstimate#methodology can provide a link to the
methodology statement used to derive the estimate.
-=== Aggregator Configuration Notes
-
-If you want to hide your aggregator configuration, you can leave the :aggregator_options
-item blank in config/tronprint.yml. In your application, manually set
-Tronprint.aggregator_options to the values you desire.
-
== Configuration
There are several properties of Tronprint that can be configured. The configuration
is persisted in `pwd`/config/tronprint.yml. Here is a list of options that
can be set:
:zip_code:: The ZIP code where the server or host computer resides.
:brighter_planet_key:: Your Brighter Planet CM1 key. Get one from {keys.brighterplanet.com}[http://keys.brighterplanet.com].
:application_name:: The name of your application.
-:aggregator_options:: A hash of options to send to the aggregator. A sub-option of :adapter is required. This corresponds to the name of an adapter supported by {moneta}[http://github.com/wycats/moneta]. All other sub-options given are passed on to the moneta adapter's initializer.
+:aggregator_options:: A hash of options to send to the aggregator. A sub-option of :adapter is required. This corresponds to the name of an adapter supported by {moneta}[http://github.com/dkastner/moneta]. All other sub-options given are passed on to the moneta adapter's initializer.
+
+=== Configuring the aggregator
+
+Tronprint needs to write the statistics it collects to a persistent data
+store. There are two ways to configure this.
+
+The first way is to edit config/tronprint.yml as mentioned above.
+
+The second way is to manually set the aggregator options before Tronprint.run is called.
+In Rails, this can be done with an initializer. Just set Tronprint.aggregator_options to
+the options you would normally set in config/tronprint.yml.
+
+== Examples
+
+You can see an example Rails app using tronprint at http://github.com/brighterplanet/yaktrak.
+Files of note: config/initializers/tronprint.rb, Gemfile, app/views/trackings/_form.html.rb.
+The live example is at http://yaktrak.org
== Note on Patches/Pull Requests
* Fork the project.
* Make your feature addition or bug fix.