Quby

CircleCI Code Climate Dependency Status

Usage

Quby is a Rails mountable engine, which means that you have to mount it into your existing Rails application. First, you need to include Quby as a gem in your Gemfile:

gem 'quby',         git: "[email protected]:roqua/quby_engine.git"
gem 'quby-mongoid'

Then, mount it at a path in your application. You can do this by putting a line in config/routes.rb. Note that "/quby" could be anything you want.

mount Quby::Engine => "/quby", :as => "quby_engine"

In config/initializers/quby.rb, you need to tell Quby where it can find its questionnaire definitions, and where it can store its answers.

Quby.questionnaire_repo      = Quby::Questionnaires::Repos::DiskRepo.new(Rails.root.join("db/questionnaires/definitions"))
Quby.answer_repo             = Quby::Answers::Repos::MongoidRepo.new
Quby::Settings.shared_secret = ENV["QUBY_SHARED_SECRET"]

If you use an OpenCPU server you can configure it through environment variables (or directly through OpenCPU.configure).

ENV['OPENCPU_ENDPOINT_URL'] = 'http://opencpu.dev/ocpu'
ENV['OPENCPU_USERNAME']     = 'optional_basicauth_username'
ENV['OPENCPU_PASSWORD']     = 'optional_basicauth_password'
ENV['OPENCPU_TIMEOUT']      = '30' # request timeout in seconds.

To generate PDF files, the html_to_pdf docker container must be running and an environment variable with the address of this container should be configured.

ENV['HTML_TO_PDF_URL']      = 'http://127.0.0.1:7768'

Testing

When testing with guard or teaspoon, choose the Rails version you want to use and set the teaspoon environment:

bundle exec appraisal rails52 bundle # install dependencies for Rails 5.2
TEASPOON_RAILS_ENV=test bundle exec appraisal rails52 guard

Contributing to Quby

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.