mHealth Example Loader is a small tool to help load example data into mHealth accounts, as well as provide some example URLs to fetch data with. It uses the omniauth-mhealth gem to get authorization, and the faraday gem to perform OAuth2 HTTP requests.
-
Clone this project from github
git clone https://github.com/bkerley/mhealth-example-loader.git
-
Change directory to
mhealth-example-loader
:cd mhealth-example-loader
-
Install dependencies:
bundle install
-
Get OAuth2 credentials for mHealth at mhealth.att.com/dev/apps
-
Load the OAuth credentials into environment variables. For local development using rbenv, I put this in
.rbenv-vars
:MHEALTH_KEY=mhealth-example-loader-dev MHEALTH_SECRET=example-secret-dont-use-this
-
Start the app:
rails server
-
Go to localhost:3000/ and you’ll see:
"mHealth Example Loader"
-
Follow the UI to load example data into your account. For more information on developing with mHealth, visit mhealth.dev.attcompute.com/hack
The default directory structure of a generated Ruby on Rails application:
|-- app | |-- assets | |-- images | |-- javascripts | `-- stylesheets | |-- controllers | |-- helpers | |-- mailers | |-- models | `-- views | `-- layouts |-- config | |-- environments | |-- initializers | `-- locales |-- db |-- doc |-- lib | `-- tasks |-- log |-- public |-- script |-- test | |-- fixtures | |-- functional | |-- integration | |-- performance | `-- unit |-- tmp | |-- cache | |-- pids | |-- sessions | `-- sockets `-- vendor |-- assets `-- stylesheets `-- plugins
app
Holds all the code that's specific to this particular application.
app/assets
Contains subdirectories for images, stylesheets, and JavaScript files.
app/controllers
Holds controllers. authorization_controller receives credentials from omniauth and stores them in the session. samples_controller does the hard work of loading data in to mHealth.
app/models
Holds mhealth_field, the very lonely model we use. It reads the metadata about what fields a given OAuth2 key has, and provides an easy way to generate sample values.
app/views
Holds the template files for the views. I use HAML because I like it the best.
app/views/layouts
Holds the template files for layouts to be used with views. I'm using Twitter Bootstrap.
app/helpers
Holds a bunch of empty files and authorization_helper, which has a method that makes checkboxes.
config
Configuration files for the Rails environment, the routing map, the database, and other dependencies.
config/initializers/omniauth.rb
This is where I hook omniauth up to the rest of the app.
db
Contains the database schema in schema.rb. db/migrate contains all the sequence of Migrations for your schema.
doc
This directory is where your application documentation will be stored when generated using <tt>rake doc:app</tt>
lib
Application specific libraries. Basically, any kind of custom code that doesn't belong under controllers, models, or helpers. This directory is in the load path.
public
The directory available for the web server. Also contains the dispatchers and the default HTML files. This should be set as the DOCUMENT_ROOT of your web server.
script
Helper scripts for automation and generation.
test
Nothing of value because I've been bad!
vendor
External libraries that the application depends on. Not much in this case!