wordwise 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1947e162210a172708d21e999c7768353bc347cbc29172471129dfc1262992d
4
- data.tar.gz: 5fa3952b37f6112138aca33bbd3673114c9042c99d502d2248fe4ca0cf92705e
3
+ metadata.gz: ea617b3ed88889e8f480f611d6a09565378984b548619a2b1e59f328d97dd8ba
4
+ data.tar.gz: e11409a2fba66a31f8f69baf4f9f0e65bb8ee6a91e81112857da67b1c1d5ba42
5
5
  SHA512:
6
- metadata.gz: 51986ba8891c9bebe953c7de9d65f93806f064c5ac420a914353bd0914ffd37dbee340ba9979d3c979f32813f96decac6a536ee49f0a3d55c2b27c39bc1ff286
7
- data.tar.gz: f6adfe9314385aed6ca33d5b2aa5825743624c0b9625279d0abafa191f99f908c3e9ece7e1de900a7413aeda0c246fd71834bdc61e26737ea283aa8b801e3b87
6
+ metadata.gz: 38221fdb3e912e8ed3dae3ba41c95adb3f90f49367c0b7c1addfe51f3900dab1c96371384d7b342d756a55a0a930cad1a24dd91856b7497b47b0833c974759f0
7
+ data.tar.gz: c2c04d0fd46a6033aeef4a042ea45f2a04eddf82ca94104743e8f5e6bc1c8982af22d3e00a7c9a053fe361bb9e2fd0e59b55a7bcbf0e29d3219e22a8fc44d038
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wordwise (0.1.1)
4
+ wordwise (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- On starting, WordWise will choose a word and several definitions, one of which is correct. (This process may take a few seconds). Once you've made your choice, type the corresponding number and hit 'enter'. WordWise will tell you if you're correct and, if not, the correct definition. Type 'o' and 'enter' to see the word's origin (etymology) or 'n' and 'enter' for the next question. To exit the game, type 'e' and 'enter'.
23
+ Start the program in your terminal with "ruby bin/wordise". On starting, WordWise will choose a word and several definitions, one of which is correct. (This process may take a few seconds). Once you've made your choice, type the corresponding number and hit 'enter'. WordWise will tell you if you're correct and, if not, the correct definition. Type 'o' and 'enter' to see the word's origin (etymology) or 'n' and 'enter' for the next question. To exit the game, type 'e' and 'enter'.
24
24
 
25
25
  ## Development
26
26
 
data/lib/cli.rb CHANGED
@@ -9,13 +9,20 @@ class Wordwise::CLI
9
9
  puts "You can learn more about the words in this quiz at https://www.oxforddictionaries.com.\n\n".center(80)
10
10
  puts "Get ready to test your word wisdom....\n\n".center(80)
11
11
  puts "What category would you like to test your knowledge on?\n"
12
- display_lists
12
+ list
13
13
  end
14
14
 
15
- # Presents list of categories.
16
- def display_lists
15
+ # Checks if @lists is populated. If not, calls .scrape_word_lists and populates it.
16
+ # Otherwise, call display_list and pass in the list.
17
+ def list
18
+ @list ||= Wordwise::Scraper.scrape_word_lists
17
19
  puts ''
18
- Wordwise::Scraper.scrape_word_lists.each_with_index do |l, i|
20
+ display_list
21
+ end
22
+
23
+ # Presents list of categories.
24
+ def display_list
25
+ @list.each_with_index do |l, i|
19
26
  puts wrap_indent("#{i + 1}) #{l}")
20
27
  puts ''
21
28
  end
@@ -45,19 +52,19 @@ class Wordwise::CLI
45
52
  end
46
53
  end
47
54
 
48
- # Checks if there are enough unused words and definitions to form question.
49
- # Minumum size is set at 5 because sample method in #sample_words_defs
50
- # is not called on first item in array.
51
- def check_remaining
52
- if @words_defs_ary.size >= 5
53
- sample_words_defs
54
- else
55
- ask_c_or_e
56
- end
55
+ # Checks if there are enough unused words and definitions to form question.
56
+ # Minumum size is set at 5 because sample method in #sample_words_defs
57
+ # is not called on first item in array.
58
+ def check_remaining
59
+ if @words_defs_ary.size >= 5
60
+ sample_words_defs
61
+ else
62
+ ask_c_or_e
63
+ end
57
64
  end
58
65
 
66
+ # Samples starting at index 1 of array to avoid any column headings.
59
67
  def sample_words_defs
60
- # Samples starting at index 1 of array to avoid any column headings.
61
68
  @question_words_defs = @words_defs_ary[1..@words_defs_ary.size - 1].sample(4)
62
69
  # Prevents repetition of words in questions.
63
70
  @words_defs_ary.delete_if { |wd| wd == @question_words_defs[0] }
@@ -91,13 +98,13 @@ class Wordwise::CLI
91
98
  ask_no
92
99
  end
93
100
 
94
- def self.get_question_words
101
+ def self.question_words
95
102
  @@question_words
96
103
  end
97
104
 
98
- def self.get_question_array
105
+ # Array is return value to be used in Question.
106
+ def self.question_array
99
107
  origin = Wordwise::Scraper.scrape_entry_pages
100
- # Array is return value to be used in Question.
101
108
  [@@question_words, @@question_defs, origin]
102
109
  end
103
110
 
@@ -160,7 +167,7 @@ class Wordwise::CLI
160
167
  when 'n'
161
168
  check_remaining
162
169
  when 'c'
163
- display_lists
170
+ display_list
164
171
  when 'e'
165
172
  goodbye
166
173
  else
@@ -201,6 +208,7 @@ class Wordwise::CLI
201
208
  end
202
209
  end
203
210
 
211
+ # Presents main words, their definitions and origins from session.
204
212
  def display_review
205
213
  Wordwise::Question.all.each_index do |i|
206
214
  question = Wordwise::Question.all[i]
@@ -7,7 +7,7 @@ class Wordwise::Question
7
7
 
8
8
  # Set instance variables for Question objects.
9
9
  def initialize
10
- question_array = Wordwise::CLI.get_question_array
10
+ question_array = Wordwise::CLI.question_array
11
11
  @word = question_array[0][0]
12
12
  @def = question_array[1][0]
13
13
  @defs = question_array[1].shuffle
@@ -15,7 +15,8 @@ class Wordwise::Question
15
15
  @@all << self
16
16
  end
17
17
 
18
- def self.all
18
+ def self.all
19
19
  @@all
20
20
  end
21
+
21
22
  end
@@ -42,7 +42,7 @@ class Wordwise::Scraper
42
42
  # definition, and 3 more definitions.
43
43
  def self.scrape_entry_pages
44
44
  docs, word_urls = [], []
45
- question_words = Wordwise::CLI.get_question_words
45
+ question_words = Wordwise::CLI.question_words
46
46
  # Iterates over array to make array of urls that are parsed by Nokogiri
47
47
  # and put in another array.
48
48
  question_words.each_index do |i|
@@ -1,3 +1,3 @@
1
1
  module Wordwise
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -8,7 +8,7 @@ require 'nokogiri'
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = "wordwise"
10
10
  spec.version = Wordwise::VERSION
11
- spec.authors = ["RonSala"]
11
+ spec.authors = ["Ron Sala"]
12
12
  spec.email = ["ron.sala@gmail.com"]
13
13
 
14
14
  spec.summary = %q{A quiz game. Challenge your vocabulary!}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordwise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - RonSala
7
+ - Ron Sala
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-06 00:00:00.000000000 Z
11
+ date: 2018-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,6 @@ files:
80
80
  - lib/wordwise.rb
81
81
  - lib/wordwise/version.rb
82
82
  - spec.md
83
- - spec.rb
84
83
  - wordwise.gemspec
85
84
  homepage: https://github.com/ronsala/wordwise
86
85
  licenses:
data/spec.rb DELETED
@@ -1,6 +0,0 @@
1
- # Specifications for the CLI Assessment
2
-
3
- Specs:
4
- - [x] Have a CLI for interfacing with the application
5
- - [X] Pull data from an external source
6
- - [ ] Implement both list and detail views