whatisquiz 0.0.2

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 12aaa4d1df079e8ea55ae8d8c1dd37899615f481
4
+ data.tar.gz: 64d30fa96562741b5ca2e1a82cc711bd15382904
5
+ SHA512:
6
+ metadata.gz: 687b107a13aaddc5af63a6c873c523e34323531f5775e2e16b29e34211f58d03914b03c4d6be820352643c8779ce476dfea8f82a9e590f04a5fed7522a5a88a8
7
+ data.tar.gz: 4c65a2e80c03f2c734d65ebad17eb4e3d1250ee83c676d88972f58b9849173248086fdc7662b541a360a2acdd80e688b1ac3ea21a9943055a61750ded077260e
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in whatisquiz.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 chakirin
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,21 @@
1
+ # Whatisquiz
2
+
3
+ *whatisquiz* is a command-line program to enjoy unix command quiz.
4
+ ## Installation
5
+
6
+ To install it, type:
7
+
8
+ $ gem install whatisquiz
9
+
10
+ ## Usage
11
+
12
+ On your terminal, just type *whatisquiz*
13
+ then, start a quiz.
14
+
15
+ ## Contributing
16
+
17
+ 1. Fork it ( https://github.com/[my-github-username]/whatisquiz/fork )
18
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
19
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
20
+ 4. Push to the branch (`git push origin my-new-feature`)
21
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/whatisquiz ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ require 'csv'
3
+
4
+ $HOME = Dir.home
5
+ $DB_PATH = Dir.home + '/.whatisquiz/db'
6
+
7
+ def create_dict
8
+ commands = Array.new
9
+ Dir.open("/bin") do |dir|
10
+ dir.each do |name|
11
+ commands << name
12
+ end
13
+ end
14
+ CSV.open($DB_PATH + "/quizdb.csv", "w") do |line|
15
+ commands.each do |cmd|
16
+ `whatis #{cmd}` =~ /- (.*) *$/
17
+ next if $1 == nil
18
+ line << [cmd, $1]
19
+ end
20
+ end
21
+ end
22
+
23
+ def repl
24
+ header=<<EOF
25
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26
+ % %%% %%%% %%%% %%%%% %%%%%%%% %%%%%%%% %%%%% %%%% %%
27
+ % %%% %%%% %%%% %%%%% %%%%%%% %% %%%%%%%%%%% %%%%%%%%%%%% %%%%%% %%%%%%%
28
+ %% % % % %%%%% %%%%% %%%%%%%%% %%%%%%%%%%%% %%%%%%%% %%%%
29
+ %% % % % %%%%% %%%%% %%%% %%%%%%% %%%%%%%% %%%%%%%%%%%% %%%%%%%%%% %%
30
+ %%% %%%% %%%%%%% %%%%% %%% %%%%%%%%% %%%%%%% %%%%%%%%% %%%% %%%
31
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33
+ %%%%%%%%%%% %%%%%%% %%%%%%% %%%%%% %%%%%% %%%%%%%%%%%%%%%%%%%
34
+ %%%%%%%%%% %%%%%% %%%%%% %%%%%%% %%%%%%%%% %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%
35
+ %%%%%%%%% %%%%%%%% %%%%% %%%%%%% %%%%%%%%% %%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
36
+ %%%%%%%%% %%%%%%%% %%%%% %%%%%%% %%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%
37
+ %%%%%%%%% %%%%% %% %%%%% %%%%%%% %%%%%%%%% %%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%
38
+ %%%%%%%%%% %%%%% %%%%%%% %%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
39
+ %%%%%%%%%%% % %%%%%%% %%%%%%%% %%%%%% %%%%%%%%%%%%%%%%%%%
40
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41
+ EOF
42
+ design=<<-EOF
43
+ ######################################
44
+ EOF
45
+
46
+ helpstr=<<EOF
47
+ .----------------------------------.
48
+ |init: recreate database for quiz |
49
+ |quit: exit the game |
50
+ |help: show commands |
51
+ *----------------------------------*
52
+ EOF
53
+ prompt = '$ '
54
+ puts header
55
+ if Dir.glob($DB_PATH + "/quizdb.csv").empty?
56
+ puts "database not found"
57
+ puts "initialize setup..."
58
+ Dir.mkdir(Dir.home + '/.whatisquiz', mode = 0777)
59
+ Dir.mkdir($DB_PATH, mode = 0777)
60
+ create_dict
61
+ print "\n\n\n\n\n\n"
62
+ puts "welcome whatisquiz!!"
63
+ puts "whatisquiz is a quiz about unix command"
64
+ puts helpstr
65
+ print "\n\n\n"
66
+ end
67
+ db = Array.new
68
+ CSV.foreach($DB_PATH + "/quizdb.csv") do |row|
69
+ db << row
70
+ end
71
+
72
+ while true
73
+ randarr = (1..File.read($DB_PATH + '/quizdb.csv').count("\n")).to_a.shuffle!
74
+ puts design
75
+ puts ' ' + db[randarr[0]][1]
76
+ puts design
77
+ ans = db[randarr[0]][0]
78
+ nans1 = db[randarr[1]][0]
79
+ nans2 = db[randarr[2]][0]
80
+ nans3 = db[randarr[3]][0]
81
+ selecters = [ans,nans1,nans2,nans3].shuffle!
82
+ printf("%20s%20s\n", selecters[0], selecters[1])
83
+ printf("%20s%20s\n", selecters[2], selecters[3])
84
+ puts "input your answer"
85
+ print prompt
86
+ input = gets.chomp
87
+ case input
88
+ when "help"
89
+ puts helpstr
90
+ gets
91
+ when "quit"
92
+ puts "see you again"
93
+ exit
94
+ when "init"
95
+ create_dict
96
+ when db[randarr[0]][0]
97
+ puts "great!\n"
98
+ else
99
+ puts "miss..."
100
+ puts "the answer is " + ans
101
+ puts "\n"
102
+ end
103
+ end
104
+ end
105
+ repl
@@ -0,0 +1,3 @@
1
+ module Whatisquiz
2
+ VERSION = "0.0.2"
3
+ end
data/lib/whatisquiz.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "whatisquiz/version"
2
+
3
+ module Whatisquiz
4
+ # Your code goes here...
5
+ end
data/test/helper.rb ADDED
File without changes
File without changes
@@ -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 'whatisquiz/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "whatisquiz"
8
+ spec.version = Whatisquiz::VERSION
9
+ spec.authors = ["chakirin"]
10
+ spec.email = ["takeme_imd1122@me.com"]
11
+ spec.summary = %q{unix command quiz}
12
+ spec.description = %q{unix command quiz}
13
+ spec.homepage = ""
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.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whatisquiz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - chakirin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: unix command quiz
42
+ email:
43
+ - takeme_imd1122@me.com
44
+ executables:
45
+ - whatisquiz
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/whatisquiz
55
+ - lib/whatisquiz.rb
56
+ - lib/whatisquiz/version.rb
57
+ - test/helper.rb
58
+ - test/test_whatisquiz.rb
59
+ - whatisquiz.gemspec
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.5
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: unix command quiz
84
+ test_files:
85
+ - test/helper.rb
86
+ - test/test_whatisquiz.rb
87
+ has_rdoc: