querinator 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ .rbx
2
+ .idea
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - jruby-18mode # JRuby in 1.8 mode
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+ - rbx-18mode
9
+ - rbx-19mode
10
+ # uncomment this line if your project needs to run something other than `rake`:
11
+ # script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in querinator.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'minitest' do
5
+
6
+ watch(%r|^spec/(.*)_spec\.rb|)
7
+ watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
8
+ watch(%r|^spec/spec_helper\.rb|) { "spec" }
9
+
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Robie Lutsey
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ <a href="https://codeclimate.com/github/robie1373/querinator"><img src="https://codeclimate.com/badge.png" /></a>
2
+ [![Build Status](https://secure.travis-ci.org/robie1373/querinator.png?branch=master)](http://travis-ci.org/robie1373/querinator)
3
+ # Querinator
4
+
5
+ Querinator querinates you. What? Querinates? That's perfectly cromulent.
6
+ In any case it will ingest structured text, style(s) TBD, and quiz the user.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'querinator'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install querinator
21
+
22
+ ## Usage
23
+
24
+ As of today, if you run bin/querinator it will ask you a meaningful question. That's it.
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs.push "lib"
7
+ t.test_files = FileList['spec/**/*_spec.rb']
8
+ t.verbose = true
9
+ end
data/bin/querinator ADDED
@@ -0,0 +1,23 @@
1
+ #! /usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require "querinator"
5
+
6
+ @path = "./spec/test_question_file.txt"
7
+ def runit
8
+ questions = Querinator::Importer.new.parse(@path)
9
+ random_question = questions.sample
10
+ puts random_question.pose
11
+
12
+ input = gets()
13
+ input = input.chomp
14
+
15
+ if random_question.is_correct?(input)
16
+ puts "Hooray!!"
17
+ else
18
+ puts "oooooh."
19
+ puts "The correct answer was '#{random_question.answer}'"
20
+ end
21
+ end
22
+
23
+ runit
@@ -0,0 +1,18 @@
1
+ module Querinator
2
+ class Importer
3
+
4
+ def parse(path)
5
+ @query_objects = []
6
+ json_input = JSON.parse(IO.read(path), opts = { :symbolize_names => TRUE })
7
+ json_input.each do |json_question|
8
+ @query_objects << Query.new(:question => json_question[:question], :answer => json_question[:answer])
9
+ end
10
+ @query_objects
11
+ end
12
+
13
+ def question_pool
14
+ @query_objects
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ module Querinator
2
+ class Query
3
+ def initialize (args)
4
+ @question = args[:question]
5
+ @answer = args[:answer]
6
+ @times_correct = args[:times_correct]
7
+ @times_seen = args[:times_seen]
8
+ end
9
+
10
+ def pose
11
+ @question
12
+ end
13
+
14
+ def is_correct?(response)
15
+ response == @answer ? TRUE : FALSE
16
+ end
17
+
18
+ def answer
19
+ @answer
20
+ end
21
+
22
+ def times_correct
23
+ @times_correct
24
+ end
25
+
26
+ def times_correct=(value)
27
+ @times_correct = value
28
+ end
29
+
30
+ def times_seen
31
+ @times_seen
32
+ end
33
+
34
+ def times_seen=(value)
35
+ @times_seen = value
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,3 @@
1
+ module Querinator
2
+ VERSION = "0.0.1"
3
+ end
data/lib/querinator.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+ require "querinator/version"
3
+ require 'querinator/importer'
4
+ require 'querinator/query'
5
+
6
+ module Querinator
7
+ class Game
8
+
9
+ def get_questions
10
+ file_name = "./spec/test_question_file.txt"
11
+ Importer.new.parse(file_name)
12
+ end
13
+ end
14
+
15
+
16
+ end
17
+
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/querinator/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Robie Lutsey"]
6
+ gem.email = ["robie1373@gmail.com"]
7
+ gem.description = %q{manages and presents flash card data}
8
+ gem.summary = %q{Will import JSON hashes of questions and asnwers, track times seen and times correct for each question.}
9
+ gem.homepage = "http://robie1373.github.com/querinator"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "querinator"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Querinator::VERSION
17
+
18
+ gem.add_development_dependency 'rb-fsevent', '~>0.9.1'
19
+ gem.add_development_dependency 'minitest-reporters', '~>0.9.0'
20
+ gem.add_development_dependency 'guard', '~>1.2.3'
21
+ gem.add_development_dependency 'guard-minitest', '~>0.5.0'
22
+ gem.add_development_dependency 'growl', '~>1.0.3'
23
+ gem.add_development_dependency 'turn', '~>0.9.6'
24
+ gem.add_development_dependency 'rake', '~>0.9.2'
25
+ end
@@ -0,0 +1,55 @@
1
+ require_relative '../spec_helper'
2
+ module Querinator
3
+ describe Importer do
4
+ def setup
5
+ @file_importer = Importer.new
6
+ @file_name = "./spec/test_question_file.txt"
7
+ end
8
+
9
+ # describe "#import" do
10
+ # it "must try to import qna data" do
11
+ # Importer.new.must_respond_to :import
12
+ # end
13
+ # end
14
+
15
+ #describe "read data from file" do
16
+ #it "must read data in from a file" do
17
+ # skip("I don't think I need this method. It's functionality was moved to parse.")
18
+ # @file_importer.read(@file_name).must_equal (File.open(@file_name) { |f| f.readlines })
19
+ #end
20
+ #end
21
+
22
+ describe "#parse data" do
23
+ it "must parse the data into an array." do
24
+ #@file_importer.read(@file_name)
25
+ @file_importer.parse(@file_name).must_be_instance_of Array
26
+ end
27
+
28
+ it "must parse the data into an array of Query objects" do
29
+ Importer.new.parse(@file_name).must_be_instance_of Array
30
+ Importer.new.parse(@file_name)[0].must_be_instance_of Query
31
+ end
32
+ end
33
+
34
+ describe "#question_pool" do
35
+ def setup
36
+ @importer = Importer.new
37
+ @file_name = "./spec/test_question_file.txt"
38
+ @importer.parse(@file_name)
39
+ end
40
+
41
+ # This is repetitive because it is just a convenience function to make things more readable.
42
+ it "must return an array" do
43
+
44
+ @importer.question_pool.must_be_instance_of Array
45
+ end
46
+
47
+ it "must return an array of Query objects" do
48
+ @importer.question_pool.each do |query|
49
+ query.must_be_instance_of Query
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,100 @@
1
+ require_relative '../spec_helper'
2
+ module Querinator
3
+ describe Query do
4
+ def setup
5
+ @query = Query.new({ :question => "Do you get Tom Servo?", :answer => "Nobody does. I'm like the wind baby." })
6
+ @query_src0 = { :question => "Do you get Tom Servo?",
7
+ :answer => "No one does. I'm like the wind baby.",
8
+ :times_seen => 21,
9
+ :times_correct => 4 }
10
+ @query_src1 = { :question => "Was there ever a monster?",
11
+ :answer => "We will never speak of this movie again.",
12
+ :times_seen => 8,
13
+ :times_correct => 140 }
14
+ @test_questions = [Query.new(@query_src0), Query.new(@query_src1)]
15
+ #@queries = @test_questions.each { |qa| Query.new(qa[0][:question], qa[0][:answer]) }
16
+ end
17
+
18
+ it "creates an instance of query" do
19
+ @query.must_be_instance_of Query
20
+ end
21
+
22
+ describe "#pose" do
23
+ it "must try to ask a question" do
24
+ @query.must_respond_to :pose
25
+ end
26
+ end
27
+
28
+ describe "#is_correct?" do
29
+ it "must try to decide if my answer is correct" do
30
+ @query.must_respond_to :is_correct?
31
+ end
32
+
33
+ it "must reply TRUE if the answer is correct" do
34
+ @test_questions.each do |question|
35
+ question.is_correct?(question.answer).must_equal TRUE
36
+ end
37
+ end
38
+
39
+ it "must reply FALSE if the answer is incorrect" do
40
+ @test_questions.each do |question|
41
+ question.is_correct?("foo is not the answer").must_equal FALSE
42
+ end
43
+ end
44
+ end
45
+
46
+ describe "#answer" do
47
+ it "must tell the right answer when asked." do
48
+ @test_questions[0].answer.must_equal "No one does. I'm like the wind baby."
49
+ @test_questions[1].answer.must_equal "We will never speak of this movie again."
50
+ end
51
+ end
52
+
53
+ describe "#times_correct" do
54
+ it "must tell me how many times this question was answered correctly" do
55
+ @test_questions.each do |question|
56
+ question.times_correct.must_be_instance_of Fixnum
57
+ end
58
+ end
59
+
60
+ it "must let me increment times correct" do
61
+ @test_questions.each_with_index do |question, index|
62
+ old_value = (eval "@query_src" + index.to_s)[:times_correct]
63
+ question.times_correct += 1
64
+ new_value = question.times_correct
65
+ new_value.must_equal (old_value += 1)
66
+ end
67
+ end
68
+
69
+ it "must be set when you instantiate the query" do
70
+ @test_questions.each_with_index do |question, index|
71
+ question.times_correct.must_equal (eval "@query_src" + index.to_s)[:times_correct]
72
+ end
73
+ end
74
+ end
75
+
76
+ describe "#times_seen" do
77
+ it "must tell me how many times this question has been seen" do
78
+ @test_questions.each do |question|
79
+ question.times_seen.must_be_instance_of Fixnum
80
+ end
81
+ end
82
+
83
+ it "must let me increment times seen" do
84
+ @test_questions.each_with_index do |question, index|
85
+ old_value = (eval "@query_src" + index.to_s)[:times_seen]
86
+ question.times_seen += 1
87
+ new_value = question.times_seen
88
+ new_value.must_equal (old_value += 1)
89
+ end
90
+ end
91
+
92
+ it "must be set when you instantiate the query" do
93
+ @test_questions.each_with_index do |question, index|
94
+ question.times_seen.must_equal (eval "@query_src" + index.to_s)[:times_seen]
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "spec_helper"
2
+
3
+ module Querinator
4
+ #describe Game do
5
+ # it "must be an instance of Game" do
6
+ # Game.new.must_be_instance_of Game
7
+ # end
8
+ #end
9
+ #
10
+ #describe "#get_questions should return an array" do
11
+ # it "must return an array" do
12
+ # Game.new.get_questions.must_be_instance_of Array
13
+ # end
14
+ #
15
+ # it "The returned array must be full of query objects" do
16
+ # Game.new.get_questions.first.must_be_instance_of Query
17
+ # end
18
+ #end
19
+ end
@@ -0,0 +1,13 @@
1
+ require 'minitest/spec'
2
+ require "minitest/autorun"
3
+ require 'minitest/reporters'
4
+ require 'turn'
5
+ require 'growl'
6
+ require_relative '../lib/querinator'
7
+ #require_relative 'querinator/importer_spec'
8
+ #require_relative 'querinator/query_spec'
9
+ MiniTest::Reporters.use!
10
+
11
+ module Querinator
12
+
13
+ end
@@ -0,0 +1,12 @@
1
+ [{"question":"Do you get Tom Servo?","answer":"Nobody does. I'm the wind baby."},
2
+ {"question":"Was there ever a monster?","answer":"We will never speak of this movie again."},
3
+ {"question":"What is 2+2","answer":"4"},
4
+ {"question":"What is the capital of Colorado?","answer":"Denver"},
5
+ {"question":"Which is more dense: lead or meatloaf?","answer":"lead"},
6
+ {"question":"What is the chemical symbol for gold?","answer":"Au"},
7
+ {"question":"Does Robie kick butt?","answer":"yes"},
8
+ {"question":"Which is better, Ruby or Python?","answer":"Ruby, duh!"},
9
+ {"question":"What does every rose have at least one of?","answer":"thorns"},
10
+ {"question":"The english word for 'azul' is...","answer":"blue"},
11
+ {"question":"This is a.) fun; b.) boring; c.) neither of the above","answer":"a"}
12
+ ]
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: querinator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Robie Lutsey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rb-fsevent
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.1
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: 0.9.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: minitest-reporters
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.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.9.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: guard
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.3
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard-minitest
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.5.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.5.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: growl
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.0.3
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.0.3
94
+ - !ruby/object:Gem::Dependency
95
+ name: turn
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.9.6
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.9.6
110
+ - !ruby/object:Gem::Dependency
111
+ name: rake
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.9.2
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.9.2
126
+ description: manages and presents flash card data
127
+ email:
128
+ - robie1373@gmail.com
129
+ executables:
130
+ - querinator
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - .travis.yml
136
+ - Gemfile
137
+ - Guardfile
138
+ - LICENSE
139
+ - README.md
140
+ - Rakefile
141
+ - bin/querinator
142
+ - lib/querinator.rb
143
+ - lib/querinator/importer.rb
144
+ - lib/querinator/query.rb
145
+ - lib/querinator/version.rb
146
+ - querinator.gemspec
147
+ - spec/querinator/importer_spec.rb
148
+ - spec/querinator/query_spec.rb
149
+ - spec/querinator_spec.rb
150
+ - spec/spec_helper.rb
151
+ - spec/test_question_file.txt
152
+ homepage: http://robie1373.github.com/querinator
153
+ licenses: []
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ none: false
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ! '>='
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 1.8.24
173
+ signing_key:
174
+ specification_version: 3
175
+ summary: Will import JSON hashes of questions and asnwers, track times seen and times
176
+ correct for each question.
177
+ test_files:
178
+ - spec/querinator/importer_spec.rb
179
+ - spec/querinator/query_spec.rb
180
+ - spec/querinator_spec.rb
181
+ - spec/spec_helper.rb
182
+ - spec/test_question_file.txt