questiongenerator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +23 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +23 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/lib/questiongenerator.rb +38 -0
- data/lib/questions/en.yml +68 -0
- data/questiongenerator.gemspec +23 -0
- metadata +87 -0
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
questiongenerator
|
2
|
+
Copyright (c) 2014 nilsding
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# questiongenerator
|
2
|
+
|
3
|
+
A simple question generator, used by justask.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'questiongenerator'
|
10
|
+
|
11
|
+
If you're feeling _edgy_, you can add this line instead:
|
12
|
+
|
13
|
+
gem 'questiongenerator', git: 'https://github.com/justask/questiongenerator.git'
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
``` ruby
|
18
|
+
require 'questiongenerator'
|
19
|
+
|
20
|
+
# Configure it
|
21
|
+
QuestionGenerator.question_base_path = '/home/nilsding/questions'
|
22
|
+
QuestionGenerator.default_locale = :en
|
23
|
+
|
24
|
+
# Get some questions
|
25
|
+
puts QuestionGenerator.generate
|
26
|
+
# => "What is the best thing about the internet?"
|
27
|
+
|
28
|
+
# You can also specify the locale, if you want to
|
29
|
+
puts QuestionGenerator.generate :de
|
30
|
+
# => "Was war das letzte, das du gegessen hast?"
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/justask/questiongenerator/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module QuestionGenerator
|
4
|
+
VERSION = "0.0.1"
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :question_base_path
|
8
|
+
attr_accessor :default_locale
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.setup
|
12
|
+
yield self
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.generate(locale = @default_locale)
|
16
|
+
questions = YAML.load_file(File.expand_path("#{locale.to_s}.yml", @question_base_path))
|
17
|
+
"#{get_question(questions)}?"
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def self.get_question questions
|
23
|
+
question = ""
|
24
|
+
if questions.is_a? Hash
|
25
|
+
key = questions.keys.sample
|
26
|
+
value = questions[key]
|
27
|
+
question = "#{key} #{get_question(value)}"
|
28
|
+
elsif questions.is_a? Array
|
29
|
+
question = get_question questions.sample
|
30
|
+
elsif questions.is_a? String
|
31
|
+
question = questions
|
32
|
+
end
|
33
|
+
question
|
34
|
+
end
|
35
|
+
|
36
|
+
@question_base_path = File.expand_path("../questions/", __FILE__)
|
37
|
+
@default_locale = :en
|
38
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
Do:
|
2
|
+
you:
|
3
|
+
like:
|
4
|
+
- social networks
|
5
|
+
- muffins
|
6
|
+
- video games
|
7
|
+
your:
|
8
|
+
friends:
|
9
|
+
like:
|
10
|
+
- you:
|
11
|
+
- the way you are
|
12
|
+
- social networks
|
13
|
+
- muffins
|
14
|
+
- video games
|
15
|
+
know:
|
16
|
+
much:
|
17
|
+
about:
|
18
|
+
- your:
|
19
|
+
- life
|
20
|
+
- hobbies
|
21
|
+
- family
|
22
|
+
- you
|
23
|
+
What:
|
24
|
+
was:
|
25
|
+
the:
|
26
|
+
last:
|
27
|
+
thing:
|
28
|
+
you:
|
29
|
+
have:
|
30
|
+
- eaten
|
31
|
+
- done
|
32
|
+
your:
|
33
|
+
favourite:
|
34
|
+
song:
|
35
|
+
- as a 5 year old
|
36
|
+
- from a few weeks ago
|
37
|
+
would:
|
38
|
+
you:
|
39
|
+
do:
|
40
|
+
if:
|
41
|
+
you:
|
42
|
+
had:
|
43
|
+
- one million dollars
|
44
|
+
- the ability to fly
|
45
|
+
were:
|
46
|
+
- a dragon
|
47
|
+
do:
|
48
|
+
you:
|
49
|
+
think:
|
50
|
+
about:
|
51
|
+
- the:
|
52
|
+
- internet
|
53
|
+
- dragons
|
54
|
+
is:
|
55
|
+
the:
|
56
|
+
best: &is_the_best
|
57
|
+
thing:
|
58
|
+
about:
|
59
|
+
the:
|
60
|
+
- internet
|
61
|
+
your:
|
62
|
+
- favourite:
|
63
|
+
- series
|
64
|
+
- movie
|
65
|
+
- book
|
66
|
+
- country
|
67
|
+
- hometown
|
68
|
+
worst: *is_the_best
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'questiongenerator'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "questiongenerator"
|
8
|
+
spec.version = QuestionGenerator::VERSION
|
9
|
+
spec.authors = ["nilsding"]
|
10
|
+
spec.email = ["nilsding@nilsding.org"]
|
11
|
+
spec.summary = %q{A simple question generator.}
|
12
|
+
spec.description = %q{A simple question generator.}
|
13
|
+
spec.homepage = "https://github.com/justask/questiongenerator"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: questiongenerator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- nilsding
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A simple question generator.
|
47
|
+
email:
|
48
|
+
- nilsding@nilsding.org
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/questiongenerator.rb
|
59
|
+
- lib/questions/en.yml
|
60
|
+
- questiongenerator.gemspec
|
61
|
+
homepage: https://github.com/justask/questiongenerator
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.23.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: A simple question generator.
|
86
|
+
test_files: []
|
87
|
+
has_rdoc:
|