2021-12-26 09:59:48 -08:00
# questiongenerator
2014-12-08 15:59:33 -08:00
2015-01-17 16:05:42 -08:00
A simple question generator, used by Retrospring (formerly justask).
2014-12-08 15:59:33 -08:00
## Installation
Add this line to your application's Gemfile:
gem 'questiongenerator'
If you're feeling _edgy_ , you can add this line instead:
2021-12-26 09:59:48 -08:00
gem 'questiongenerator', git: 'https://github.com/nilsding/questiongenerator.git'
2014-12-08 15:59:33 -08:00
## Usage
``` ruby
require 'questiongenerator'
# Configure it
QuestionGenerator.question_base_path = '/home/nilsding/questions'
QuestionGenerator.default_locale = :en
2015-01-17 16:05:42 -08:00
# Compile the questions for increased randomness
QuestionGenerator.compile
2014-12-08 15:59:33 -08:00
# Get some questions
puts QuestionGenerator.generate
# => "What is the best thing about the internet?"
# You can also specify the locale, if you want to
2015-01-17 16:05:42 -08:00
puts QuestionGenerator.generate locale: :de
2014-12-08 15:59:33 -08:00
# => "Was war das letzte, das du gegessen hast?"
2015-06-09 10:12:12 -07:00
# You can also specify an own prefix or suffix:
puts QuestionGenerator.generate locale: :fr, prefix: '[FR] ', suffix: ' ?'
# => "[FR] Quelle est la personne la plus célèbre que vous avez rencontrée ?"
2014-12-08 15:59:33 -08:00
```
2015-05-24 13:34:38 -07:00
## How it works
The question generator uses a simple branching structure inside the specified locale to generate questions from it, here is a quick example:
```yml
Can:
you:
- swim
- speak:
- different:
- languages
- play:
- any:
- sports
- the:
- piano
- guitar
- trumpet
- baseball
- ski
- cook
- dance
# The following example outputs:
# Can you swim?
# Can you speak different languages?
# Can you play any sports?
# Can you play the piano?
# ...guitar?
# ...trumpet?
# Can you play baseball?
# Can you ski?
# Can you cook?
# Can you dance?
```
If you can't break sentences in parts in your language, you can also specify the entire question in one line.
```yml
2015-05-24 13:37:59 -07:00
- Can you swim
2015-05-24 13:34:38 -07:00
# The following example outputs:
# Can you swim?
```
2014-12-08 15:59:33 -08:00
## Contributing
2015-05-24 13:34:38 -07:00
The files for questions are located in `lib/questions/`
If you want to add a new language, create a new file and name it with the [ISO-639-1 language code ](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ) of it (just like `en.yml` )
2021-12-26 09:59:48 -08:00
1. Fork it ( https://github.com/nilsding/questiongenerator/fork )
2014-12-08 15:59:33 -08:00
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
2015-05-24 13:34:38 -07:00
Please don't add harassing, scaring or upsetting content to the questions or content that otherwise violates the [Retrospring Terms of Service ](https://retrospring.net/terms ).
If you add questions in another language to the questiongenerator and purposely add wrong translations, further Pull Requests will be ignored.