commands:

app:
  start:
    - foreman start
db:
  dump: pg_dump -Fc --no-acl --no-owner -h localhost <%= app_name %>_development > <%= app_name %>_development.dump
  restore: pg_restore --verbose --clean --no-acl --no-owner -h localhost -d <%= app_name %>_development {dumpfile}
deploy:
  default_environment: staging
  staging:
    branch: master
    heroku:
      app_name: <%= app_name %>-staging
  production:
    branch: production
    heroku:
      app_name: <%= app_name %>-production
  notifications:
    airbrake: bin/rake airbrake:deploy RAILS_ENV={environment} TO={environment}
    new_relic: bin/newrelic deployments -e {environment} -r {revision}
dotenv:
  heroku:
    app_name: <%= app_name %>-staging
    vars:
      - AIRBRAKE_API_KEY
      - ELASTICSEARCH_URL
  custom:
    vars:
      RAILS_ENV: development
      AWS_S3_BUCKET: <%= app_name %>-dev-{env:USER}
      AWS_S3_REGION: us-west-2
      AWS_DYNAMO_DB_REGION: us-west-2
dynamo_db:
  table_prefix: 'dev-{env:USER}'
  tables:
    clicks:
      region: '{env:AWS_DYNAMO_DB_REGION}'
      primary_key:
        name: uuid
        type: string
      read_capacity_units: 10
      write_capacity_units: 10
    impressions:
      region: '{env:AWS_DYNAMO_DB_REGION}'
      primary_key:
        name: uuid
        type: string
      read_capacity_units: 10
      write_capacity_units: 10
elasticsearch:
  url: '{env:ELASTICSEARCH_URL}'
  indexes:
    stories-development:
      create:
        - thor stories:create
      import:
        - thor stories:index
heroku:
  staging:
    app_name: <%= app_name %>-staging
  production:
    app_name: <%= app_name %>-production
js_deps:
platform_deps:
  homebrew:
    - node
    - postgres
    - redis
    - heroku
  rubygems:
    - bundler
  shell:
    mailcatcher:
      install:
        - rvm default@mailcatcher --create do gem install mailcatcher
        - rvm wrapper default@mailcatcher --no-prefix mailcatcher catchmail
        # https://github.com/sj26/mailcatcher/issues/155
        - rvm default@mailcatcher do gem install i18n -v 0.6.11
        # - rvm default@mailcatcher do gem uninstall i18n -Ix --version '>0.6.11'
      update:
        - rvm default@mailcatcher do gem update mailcatcher
ruby_deps:
services:
  launchctl:
    postgres:
      plist: /usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist
    redis:
      plist: /usr/local/opt/redis/homebrew.mxcl.redis.plist
  shell:
    mailcatcher:
      start: mailcatcher
      stop: killall mailcatcher
s3:
  buckets:
    default:
      name: '{env:AWS_S3_BUCKET}'
      region: '{env:AWS_S3_REGION}'
      cors:
        local:
          allowed_methods:
            - POST
            - PUT
          allowed_origins: 'http://*.example.com'
          allowed_headers: '*'
      files:
        crossdomain:
          path: etc/crossdomain.xml
          key: 'crossdomain.xml'
          acl: public_read
setup:
  platform_deps: install
  services: restart
  ruby_deps: install
  js_deps: install
  db: init
  dotenv: heroku
test:
  server:
    - bin/rake spec
  client:
    - bin/rake teaspoon